4 people like it.
Like the snippet!
Fsi with PropertyGrid
This is a small fsx script that views the current 'it' value of Fsi in a PropertyGrid.
How to use it:
- Copy the source code into a file called FsiProp.fsx and place it next to Fsi.exe
- Start Fsi.exe with --load:FsiProp.fsx
- Maximize Fsi.exe for full enjoyment. (I placed the PropertyGrid Form on the right screen half.)
(Make a .lnk to this if you find it useful, there set Maximize on Fsi.exe)
Take FsEye if you want to see what's in 'it' in detail.
But you cannot change it there. ;)
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:
|
[<AutoOpen>]
module FsiProp
open System
open System.Windows.Forms
let prop =
let screen = Screen.PrimaryScreen.Bounds
let workingArea = Screen.PrimaryScreen.WorkingArea
let prop = new PropertyGrid(Dock = DockStyle.Fill)
let form = new Form(Text = "Here you can see the properties of 'it'.")
form.Controls.Add(prop)
let gotIt = ref DateTime.Now (* HACK: save time of getting 'it' here *)
fsi.AddPrintTransformer(fun it -> (* HACK: no calls for properties of it *)
if DateTime.Now - !gotIt > TimeSpan.FromSeconds(1.0) then
prop.SelectedObject <- it
if not form.Visible then form.Visible <- true
form.Text <- if it = null then "null" else it.GetType().Name
gotIt := DateTime.Now
null)
form.Closing.Add(fun args -> args.Cancel <- true; form.Hide())
form.Show() (* position and size must be set after showing *)
form.WindowState <- FormWindowState.Normal
form.Top <- 0
let offset = 25 (* maximize Fsi to see what this means *)
form.Left <- screen.Width / 2 - offset
form.Width <- screen.Width / 2 + offset (* below: don't cover task bar *)
form.Height <- screen.Height - (screen.Height - workingArea.Height)
prop (* You can manipulate prop! Just type prop;; *)
|
Multiple items
type AutoOpenAttribute =
inherit Attribute
new : unit -> AutoOpenAttribute
new : path:string -> AutoOpenAttribute
member Path : string
Full name: Microsoft.FSharp.Core.AutoOpenAttribute
--------------------
new : unit -> AutoOpenAttribute
new : path:string -> AutoOpenAttribute
module FsiProp
namespace System
namespace System.Windows
namespace System.Windows.Forms
val prop : PropertyGrid
Full name: FsiProp.prop
val screen : Drawing.Rectangle
type Screen =
member BitsPerPixel : int
member Bounds : Rectangle
member DeviceName : string
member Equals : obj:obj -> bool
member GetHashCode : unit -> int
member Primary : bool
member ToString : unit -> string
member WorkingArea : Rectangle
static member AllScreens : Screen[]
static member FromControl : control:Control -> Screen
...
Full name: System.Windows.Forms.Screen
property Screen.PrimaryScreen: Screen
property Screen.Bounds: Drawing.Rectangle
val workingArea : Drawing.Rectangle
property Screen.WorkingArea: Drawing.Rectangle
val prop : PropertyGrid
Multiple items
type PropertyGrid =
inherit ContainerControl
new : unit -> PropertyGrid
member AutoScroll : bool with get, set
member BackColor : Color with get, set
member BackgroundImage : Image with get, set
member BackgroundImageLayout : ImageLayout with get, set
member BrowsableAttributes : AttributeCollection with get, set
member CanShowCommands : bool
member CategoryForeColor : Color with get, set
member CollapseAllGridItems : unit -> unit
member CommandsActiveLinkColor : Color with get, set
...
nested type PropertyTabCollection
Full name: System.Windows.Forms.PropertyGrid
--------------------
PropertyGrid() : unit
type DockStyle =
| None = 0
| Top = 1
| Bottom = 2
| Left = 3
| Right = 4
| Fill = 5
Full name: System.Windows.Forms.DockStyle
field DockStyle.Fill = 5
val form : 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
namespace System.Text
property Control.Controls: Control.ControlCollection
Control.ControlCollection.Add(value: Control) : unit
val gotIt : DateTime ref
Multiple items
val ref : value:'T -> 'T ref
Full name: Microsoft.FSharp.Core.Operators.ref
--------------------
type 'T ref = Ref<'T>
Full name: Microsoft.FSharp.Core.ref<_>
Multiple items
type DateTime =
struct
new : ticks:int64 -> DateTime + 10 overloads
member Add : value:TimeSpan -> DateTime
member AddDays : value:float -> DateTime
member AddHours : value:float -> DateTime
member AddMilliseconds : value:float -> DateTime
member AddMinutes : value:float -> DateTime
member AddMonths : months:int -> DateTime
member AddSeconds : value:float -> DateTime
member AddTicks : value:int64 -> DateTime
member AddYears : value:int -> DateTime
...
end
Full name: System.DateTime
--------------------
DateTime()
(+0 other overloads)
DateTime(ticks: int64) : unit
(+0 other overloads)
DateTime(ticks: int64, kind: DateTimeKind) : unit
(+0 other overloads)
DateTime(year: int, month: int, day: int) : unit
(+0 other overloads)
DateTime(year: int, month: int, day: int, calendar: Globalization.Calendar) : unit
(+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int) : unit
(+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, kind: DateTimeKind) : unit
(+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, calendar: Globalization.Calendar) : unit
(+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, millisecond: int) : unit
(+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, millisecond: int, kind: DateTimeKind) : unit
(+0 other overloads)
property DateTime.Now: DateTime
val fsi : Compiler.Interactive.InteractiveSession
Full name: Microsoft.FSharp.Compiler.Interactive.Settings.fsi
member Compiler.Interactive.InteractiveSession.AddPrintTransformer : ('T -> obj) -> unit
val it : obj
Multiple items
type TimeSpan =
struct
new : ticks:int64 -> TimeSpan + 3 overloads
member Add : ts:TimeSpan -> TimeSpan
member CompareTo : value:obj -> int + 1 overload
member Days : int
member Duration : unit -> TimeSpan
member Equals : value:obj -> bool + 1 overload
member GetHashCode : unit -> int
member Hours : int
member Milliseconds : int
member Minutes : int
...
end
Full name: System.TimeSpan
--------------------
TimeSpan()
TimeSpan(ticks: int64) : unit
TimeSpan(hours: int, minutes: int, seconds: int) : unit
TimeSpan(days: int, hours: int, minutes: int, seconds: int) : unit
TimeSpan(days: int, hours: int, minutes: int, seconds: int, milliseconds: int) : unit
TimeSpan.FromSeconds(value: float) : TimeSpan
property PropertyGrid.SelectedObject: obj
val not : value:bool -> bool
Full name: Microsoft.FSharp.Core.Operators.not
property Control.Visible: bool
property Form.Text: string
Object.GetType() : Type
event Form.Closing: IEvent<ComponentModel.CancelEventHandler,ComponentModel.CancelEventArgs>
member IObservable.Add : callback:('T -> unit) -> unit
val args : ComponentModel.CancelEventArgs
property ComponentModel.CancelEventArgs.Cancel: bool
Control.Hide() : unit
Control.Show() : unit
Form.Show(owner: IWin32Window) : unit
property Form.WindowState: FormWindowState
type FormWindowState =
| Normal = 0
| Minimized = 1
| Maximized = 2
Full name: System.Windows.Forms.FormWindowState
field FormWindowState.Normal = 0
property Control.Top: int
val offset : int
property Control.Left: int
property Drawing.Rectangle.Width: int
property Control.Width: int
property Control.Height: int
property Drawing.Rectangle.Height: int
More information