FSharpx.Extras


 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
32: 
33: 
34: 
35: 
36: 
37: 
38: 
// ----------------------------------------------------------------------------
// F# async extensions (StockSlidingWindow.fsx)
// (c) Tomas Petricek, 2011, Available under Apache 2.0 license.
// ----------------------------------------------------------------------------

// This example demonstrates how to implement a simple mouse following
// algorithm using asynchronous sequences and Observable.window

#r @"../../bin/v4.0/FSharpx.Extras.dll"

open FSharpx.Control
open System.Drawing
open System.Windows.Forms

let form = new Form(Visible=true, TopMost=true)

// Asynchronous sequence that returns cursor position at the 50 FPS rate
let updates = 
  asyncSeq { 
    while true do
      yield form.PointToClient(Cursor.Position)
      do! Async.Sleep(20) }
  |> AsyncSeq.toObservable

// Turn the updates into floating point numbers and calculate average
// over sliding window containing the last 20 values 
updates
|> Observable.map (fun me -> float32 me.X, float32 me.Y)
|> Observable.windowed 20
|> Observable.map (fun win ->
      let x = Array.averageBy fst win
      let y = Array.averageBy snd win
      x, y)
// Draw an ellispe at the calculated location
|> Observable.add (fun (x, y) ->
    use gr = form.CreateGraphics()
    gr.Clear(Color.White)
    gr.FillEllipse(Brushes.DarkOliveGreen, x - 10.0f, y - 10.0f, 20.0f, 20.0f) )
namespace Microsoft.FSharp.Control
namespace System
namespace System.Drawing
namespace System.Windows
namespace System.Windows.Forms
val form : Form

Full name: MouseFollow.form
Multiple items
type Form =
  inherit ContainerControl
  new : unit -> Form
  member AcceptButton : IButtonControl with get, set
  member Activate : unit -> unit
  member ActiveMdiChild : Form
  member AddOwnedForm : ownedForm:Form -> unit
  member AllowTransparency : bool with get, set
  member AutoScale : bool with get, set
  member AutoScaleBaseSize : Size with get, set
  member AutoScroll : bool with get, set
  member AutoSize : bool with get, set
  ...
  nested type ControlCollection

Full name: System.Windows.Forms.Form

--------------------
Form() : unit
val updates : System.IObservable<obj>

Full name: MouseFollow.updates
Control.PointToClient(p: Point) : Point
Multiple items
type Cursor =
  new : handle:nativeint -> Cursor + 3 overloads
  member CopyHandle : unit -> nativeint
  member Dispose : unit -> unit
  member Draw : g:Graphics * targetRect:Rectangle -> unit
  member DrawStretched : g:Graphics * targetRect:Rectangle -> unit
  member Equals : obj:obj -> bool
  member GetHashCode : unit -> int
  member Handle : nativeint
  member HotSpot : Point
  member Size : Size
  ...

Full name: System.Windows.Forms.Cursor

--------------------
Cursor(handle: nativeint) : unit
Cursor(fileName: string) : unit
Cursor(stream: System.IO.Stream) : unit
Cursor(type: System.Type, resource: string) : unit
property Cursor.Position: Point
Multiple items
type Async
static member AsBeginEnd : computation:('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit)
static member AwaitEvent : event:IEvent<'Del,'T> * ?cancelAction:(unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate)
static member AwaitIAsyncResult : iar:IAsyncResult * ?millisecondsTimeout:int -> Async<bool>
static member AwaitTask : task:Task -> Async<unit>
static member AwaitTask : task:Task<'T> -> Async<'T>
static member AwaitWaitHandle : waitHandle:WaitHandle * ?millisecondsTimeout:int -> Async<bool>
static member CancelDefaultToken : unit -> unit
static member Catch : computation:Async<'T> -> Async<Choice<'T,exn>>
static member FromBeginEnd : beginAction:(AsyncCallback * obj -> IAsyncResult) * endAction:(IAsyncResult -> 'T) * ?cancelAction:(unit -> unit) -> Async<'T>
static member FromBeginEnd : arg:'Arg1 * beginAction:('Arg1 * AsyncCallback * obj -> IAsyncResult) * endAction:(IAsyncResult -> 'T) * ?cancelAction:(unit -> unit) -> Async<'T>
static member FromBeginEnd : arg1:'Arg1 * arg2:'Arg2 * beginAction:('Arg1 * 'Arg2 * AsyncCallback * obj -> IAsyncResult) * endAction:(IAsyncResult -> 'T) * ?cancelAction:(unit -> unit) -> Async<'T>
static member FromBeginEnd : arg1:'Arg1 * arg2:'Arg2 * arg3:'Arg3 * beginAction:('Arg1 * 'Arg2 * 'Arg3 * AsyncCallback * obj -> IAsyncResult) * endAction:(IAsyncResult -> 'T) * ?cancelAction:(unit -> unit) -> Async<'T>
static member FromContinuations : callback:(('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T>
static member Ignore : computation:Async<'T> -> Async<unit>
static member OnCancel : interruption:(unit -> unit) -> Async<IDisposable>
static member Parallel : computations:seq<Async<'T>> -> Async<'T []>
static member RunSynchronously : computation:Async<'T> * ?timeout:int * ?cancellationToken:CancellationToken -> 'T
static member Sleep : millisecondsDueTime:int -> Async<unit>
static member Start : computation:Async<unit> * ?cancellationToken:CancellationToken -> unit
static member StartAsTask : computation:Async<'T> * ?taskCreationOptions:TaskCreationOptions * ?cancellationToken:CancellationToken -> Task<'T>
static member StartChild : computation:Async<'T> * ?millisecondsTimeout:int -> Async<Async<'T>>
static member StartChildAsTask : computation:Async<'T> * ?taskCreationOptions:TaskCreationOptions -> Async<Task<'T>>
static member StartImmediate : computation:Async<unit> * ?cancellationToken:CancellationToken -> unit
static member StartWithContinuations : computation:Async<'T> * continuation:('T -> unit) * exceptionContinuation:(exn -> unit) * cancellationContinuation:(OperationCanceledException -> unit) * ?cancellationToken:CancellationToken -> unit
static member SwitchToContext : syncContext:SynchronizationContext -> Async<unit>
static member SwitchToNewThread : unit -> Async<unit>
static member SwitchToThreadPool : unit -> Async<unit>
static member TryCancelled : computation:Async<'T> * compensation:(OperationCanceledException -> unit) -> Async<'T>
static member CancellationToken : Async<CancellationToken>
static member DefaultCancellationToken : CancellationToken

Full name: Microsoft.FSharp.Control.Async

--------------------
type Async<'T>

Full name: Microsoft.FSharp.Control.Async<_>
static member Async.Sleep : millisecondsDueTime:int -> Async<unit>
module Observable

from Microsoft.FSharp.Control
val map : mapping:('T -> 'U) -> source:System.IObservable<'T> -> System.IObservable<'U>

Full name: Microsoft.FSharp.Control.Observable.map
val me : obj
Multiple items
val float32 : value:'T -> float32 (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.float32

--------------------
type float32 = System.Single

Full name: Microsoft.FSharp.Core.float32

--------------------
type float32<'Measure> = float32

Full name: Microsoft.FSharp.Core.float32<_>
val win : (float32 * float32) []
val x : float32
module Array

from Microsoft.FSharp.Collections
val averageBy : projection:('T -> 'U) -> array:'T [] -> 'U (requires member ( + ) and member DivideByInt and member get_Zero)

Full name: Microsoft.FSharp.Collections.Array.averageBy
val fst : tuple:('T1 * 'T2) -> 'T1

Full name: Microsoft.FSharp.Core.Operators.fst
val y : float32
val snd : tuple:('T1 * 'T2) -> 'T2

Full name: Microsoft.FSharp.Core.Operators.snd
val add : callback:('T -> unit) -> source:System.IObservable<'T> -> unit

Full name: Microsoft.FSharp.Control.Observable.add
val gr : Graphics
Control.CreateGraphics() : Graphics
Graphics.Clear(color: Color) : unit
type Color =
  struct
    member A : byte
    member B : byte
    member Equals : obj:obj -> bool
    member G : byte
    member GetBrightness : unit -> float32
    member GetHashCode : unit -> int
    member GetHue : unit -> float32
    member GetSaturation : unit -> float32
    member IsEmpty : bool
    member IsKnownColor : bool
    ...
  end

Full name: System.Drawing.Color
property Color.White: Color
Graphics.FillEllipse(brush: Brush, rect: Rectangle) : unit
Graphics.FillEllipse(brush: Brush, rect: RectangleF) : unit
Graphics.FillEllipse(brush: Brush, x: int, y: int, width: int, height: int) : unit
Graphics.FillEllipse(brush: Brush, x: float32, y: float32, width: float32, height: float32) : unit
type Brushes =
  static member AliceBlue : Brush
  static member AntiqueWhite : Brush
  static member Aqua : Brush
  static member Aquamarine : Brush
  static member Azure : Brush
  static member Beige : Brush
  static member Bisque : Brush
  static member Black : Brush
  static member BlanchedAlmond : Brush
  static member Blue : Brush
  ...

Full name: System.Drawing.Brushes
property Brushes.DarkOliveGreen: Brush
Fork me on GitHub