Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Do something only if we actually pick a file
- // Use the built-in identity function as a 'T -> 'U option mapper here
- // for the case 'T being a FileInfo option and 'U being FileInfo
- let click = handler.openButton.Clicked
- |> Event.map (fun a -> (*
- open a file dialog,
- get a FileInfo option from the selected file name;
- where cancel => None *))
- |> Event.choose id
- // Selecting an item from the menu
- let select =
- handler.openMenu.AllChildren
- |> Seq.cast<MenuItem>
- |> Seq.map (fun (i:MenuItem) -> i.Activated
- |> Event.map (fun a -> new FileInfo((i.Child :?> Label).Text))
- |> Event.filter (fun (i:FileInfo) -> i.Exists))
- // The sum of all these events
- let accumulation = select
- |> Seq.fold Event.merge click
- // do things with a file selection event
- accumulation |> Event.add UpdateRecentFileList
- accumulation |> Event.add LoadFile
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement