Home

Introduction

 

Fundamentals

 

Introduction

 

 

 
   
 
 

 

 
 
   
 

Previous Copyright © 2015 FunctionX Next

Home

Visual F# Example: Movie Review

   

Introduction

This application, that we call the movie review is meant to show the functionalities of the domain up-down control. Of course, it uses other controls such as labels, text boxes, a list box, and a picture box.

Movie Review

open System
open System.Drawing
open System.Windows.Forms

let titles    = [| "Distinguished Gentleman (The)"; "Fatal Attraction"; "New Jack City"; "Showgirls"; "Annie"; "Dave"; "Housesitter"; "Beverly Hills Cop" |]
let directors = [| "Jonathan Lynn"; "Adrian Lyne"; "Mario Van Peebles"; "Paul Verhoeven"; "John Huston"; "Ivan Reitman"; "Frank Oz"; "Martin Brest" |]
let yearsReleased = [| 1992; 1987; 1991; 1995; 1982; 1993; 1992; 1984 |]
let ratings   = [|  "R"; "R"; "R"; "NC-17"; "PG"; "R"; "PG"; "R" |]
let lengths   = [| "112 Minutes"; "119 Minutes"; "97 Minutes"; "128 Minutes"; "126 Minutes"; "110 Minutes"; "110 Minutes"; "105 Minutes" |]
let pictures  = [| "distgent.jpg"; "fatal.jpg"; "newjack.jpg"; "showgirls.jpg"; "annie.jpg"; "Dave.jpg"; "housesitter.jpg"; "bhc.jpg" |]
let actors    = [| new ListBox(); new ListBox(); new ListBox(); new ListBox(); new ListBox(); new ListBox(); new ListBox(); new ListBox() |]
actors.[0].Items.Add "Eddie Murphy" |> ignore
actors.[0].Items.Add "Lane Smith" |> ignore
actors.[0].Items.Add "Sheryl Lee Ralph" |> ignore
actors.[0].Items.Add "Joe Don Baker" |> ignore
actors.[0].Items.Add "Victoria Rowell" |> ignore
actors.[0].Items.Add "Grant Shaud" |> ignore
actors.[0].Items.Add "Kevin McCarthy" |> ignore
actors.[0].Items.Add "Charles S. Dutton" |> ignore
actors.[0].Items.Add "Victor Rivers" |> ignore
actors.[0].Items.Add "Chi McBride" |> ignore
actors.[0].Items.Add "Sonny Jim Gaines" |> ignore
actors.[0].Items.Add "Noble Willingham" |> ignore
actors.[0].Items.Add "Gary Frank" |> ignore
actors.[0].Items.Add "Daniel Benzali" |> ignore
actors.[0].Items.Add "Cynthia Harris" |> ignore

actors.[1].Items.Add "Michael Douglas" |> ignore
actors.[1].Items.Add "Glenn Close" |> ignore
actors.[1].Items.Add "Anne Archer" |> ignore
actors.[1].Items.Add "Ellen Hamilton Latzen" |> ignore
actors.[1].Items.Add "Stuart Pankin" |> ignore

actors.[2].Items.Add "Wesley Snipes" |> ignore
actors.[2].Items.Add "Ice-T" |> ignore
actors.[2].Items.Add "Allen Payne" |> ignore
actors.[2].Items.Add "Chris Rock" |> ignore
actors.[2].Items.Add "Mario Van Peebles" |> ignore
actors.[2].Items.Add "Michael Michele" |> ignore
actors.[2].Items.Add "Bill Nunn" |> ignore

actors.[3].Items.Add "Elizabeth Berkley" |> ignore
actors.[3].Items.Add "Kyle MacLachlan" |> ignore
actors.[3].Items.Add "Gina Gershon" |> ignore
actors.[3].Items.Add "Glenn Plummer" |> ignore

actors.[4].Items.Add "Albert Finney" |> ignore
actors.[4].Items.Add "Carol Burnett" |> ignore
actors.[4].Items.Add "Ann Reinking" |> ignore
actors.[4].Items.Add "Tim Curry" |> ignore
actors.[4].Items.Add "Bernadette Peters" |> ignore

actors.[5].Items.Add "Kevin Kline" |> ignore
actors.[5].Items.Add "Sigourney Weaver" |> ignore
actors.[5].Items.Add "Frank Langella" |> ignore
actors.[5].Items.Add "Kevin Dunn" |> ignore
actors.[5].Items.Add "Ving Rhames" |> ignore
actors.[5].Items.Add "Ben Kingsley" |> ignore
actors.[5].Items.Add "Charles Grodin" |> ignore

actors.[6].Items.Add "Steve Martin" |> ignore
actors.[6].Items.Add "Goldie Hawn" |> ignore
actors.[6].Items.Add "Dana Delany" |> ignore
actors.[6].Items.Add "Julie Harris" |> ignore
actors.[6].Items.Add "Donald Moffat" |> ignore
actors.[6].Items.Add "Peter MacNicol" |> ignore

actors.[7].Items.Add "Eddie Murphy" |> ignore
actors.[7].Items.Add "Judge Reinhold" |> ignore
actors.[7].Items.Add "John Ashton" |> ignore
actors.[7].Items.Add "Lisa Eilbacher" |> ignore
actors.[7].Items.Add "Ronny Cox" |> ignore
actors.[7].Items.Add "Steven Berkoff" |> ignore
actors.[7].Items.Add "James Russo" |> ignore
actors.[7].Items.Add "Jonathan Banks" |> ignore
actors.[7].Items.Add "Bronson Pinchot" |> ignore
actors.[7].Items.Add "Paul Reiser" |> ignore

// Form: Movie Review
let MovieReview = new Form(MaximizeBox = false,
                           Text = "Movie Review",
                           StartPosition = FormStartPosition.CenterScreen,
                           ClientSize = new System.Drawing.Size(416, 367))

// Label: Title
let lblTitle = new Label(Text = "Title:",
                         AutoSize = true,
                         Location = new Point(16, 12))
MovieReview.Controls.Add lblTitle
        
// Domain Up-Down: Titles
let dudTitles = new DomainUpDown(Wrap = true,
                                 Location = new Point(78, 12),
                                 UpDownAlign = LeftRightAlignment.Left,
                                 TextAlign = HorizontalAlignment.Center,
                                 Size = new System.Drawing.Size(323, 20))

dudTitles.Items.AddRange titles
dudTitles.SelectedIndex <- 0
MovieReview.Controls.Add dudTitles

// Label: Director
let lblDirector = new Label(AutoSize = true,
                            Text = "Director:",
                            Location = new Point(16, 46))
MovieReview.Controls.Add lblDirector

// Text Box: Director
let txtDirector = new TextBox(Text = directors.[0],
                              Location = new Point(78, 43),
                              Size = new System.Drawing.Size(186, 20))
MovieReview.Controls.Add txtDirector

// Label: Copyright Year
let lblCopyrightYear = new Label(AutoSize = true,
                                 Text = "© Year:",
                                 Location = new Point(16, 81))
MovieReview.Controls.Add lblCopyrightYear

// Text Box: Year Released
let txtYearReleased = new TextBox(Text = string yearsReleased.[0],
                                  Location = new Point(78, 78),
                                  Size = new System.Drawing.Size(50, 20),
                                  TextAlign = HorizontalAlignment.Right)
MovieReview.Controls.Add txtYearReleased

// Label: Rating
let lblRating = new Label(AutoSize = true,
                          Text = "Rating:",
                          Location = new Point(153, 81))
MovieReview.Controls.Add lblRating

// Text Box: Rating
let txtRating = new TextBox(Text = ratings.[0],
                            Location = new Point(200, 78),
                            Size = new System.Drawing.Size(64, 20))
MovieReview.Controls.Add txtRating
 
// Label: Length
let lblLength = new Label(AutoSize = true,
                          Text = "Length:",
                          Location = new Point(16, 116))
MovieReview.Controls.Add lblLength

// Text Box: Length
let txtLength = new TextBox(Text = lengths.[0],
                            Location = new Point(78, 113),
                            Size = new System.Drawing.Size(186, 20))
MovieReview.Controls.Add txtLength
// Picture Box: Image
let pbxImage = new PictureBox(Location = new Point(78, 150),
                              Size = new System.Drawing.Size(186, 166),
                              SizeMode = PictureBoxSizeMode.CenterImage)
pbxImage.Image <- Image.FromFile pictures.[dudTitles.SelectedIndex]
MovieReview.Controls.Add pbxImage

// Label: Cast of Characters
let lblCastOfCharacters = new Label(AutoSize = true,
                                    Location = new Point(278, 62),
                                    Text = "Cast of Characters")
MovieReview.Controls.Add lblCastOfCharacters
// List Box: Cast Members
let lbxCastMembers = new ListBox(Location = new Point(281, 78),
                                 Size = new System.Drawing.Size(120, 238))
lbxCastMembers.Items.AddRange actors.[0].Items |> ignore
                                 
MovieReview.Controls.Add lbxCastMembers

let dudTitlesSelectedItemChanged (e : EventArgs) =
    begin
        lbxCastMembers.Items.Clear()

        txtDirector.Text <- directors.[dudTitles.SelectedIndex]
        txtYearReleased.Text <- yearsReleased.[dudTitles.SelectedIndex].ToString()
        txtRating.Text <- ratings.[dudTitles.SelectedIndex]
        txtLength.Text <- lengths.[dudTitles.SelectedIndex]
        pbxImage.Image <- Image.FromFile pictures.[dudTitles.SelectedIndex]
        lbxCastMembers.Items.AddRange actors.[dudTitles.SelectedIndex].Items |> ignore
    end

dudTitles.SelectedItemChanged.Add dudTitlesSelectedItemChanged

// Button: Close
let btnClose = new Button(Text = "Close",
                          Location = new Point(326, 331))

let btnCloseClick (e : EventArgs) =
    MovieReview. Close()
btnClose.Click.Add btnCloseClick
MovieReview.Controls.Add btnClose        

[<EntryPoint>]
[<STAThread>]
let main argv =
    Application.Run MovieReview
    0

Movie Review

Movie Review

             

Home Copyright © 2015 FunctionX Home