Skip to content

Commit

Permalink
Merge pull request #14 from TahaHachana/master
Browse files Browse the repository at this point in the history
Minor updates to the charting and ribbon editing scripts
  • Loading branch information
moloneymb committed May 7, 2013
2 parents 6a42c1e + c974c78 commit c01f397
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 44 deletions.
48 changes: 20 additions & 28 deletions General/Charts.fsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
#r "WindowsBase.dll"
#I @"C:\Program Files\Tsunami\"
#r "WindowsBase.dll"
#r "PresentationFramework.dll"
#r "PresentationCore.dll"
#r "System.Xaml.dll"
#r "Telerik.Windows.Data.dll"
#r "Telerik.Windows.Controls.dll"
#r "Telerik.Windows.Controls.Charting.dll"
#r "Telerik.Windows.Controls.RibbonView.dll"
#r "Telerik.Windows.Controls.Docking.dll"
#r "Telerik.Windows.Controls.Navigation.dll"
#r "ActiproSoftware.SyntaxEditor.Wpf.dll"
#r "ActiproSoftware.Shared.Wpf.dll"
#r "ActiproSoftware.Text.Wpf.dll"
#r "ActiproUtilities.dll"
#r "ActiproSoftware.Docking.Wpf.dll"
#r "ActiproSoftware.Ribbon.Wpf.dll"
#r "ActiproSoftware.DataGrid.Contrib.Wpf.dll"
#r "Tsunami.IDEDesktop.exe"
#r "UIAutomationTypes.dll"


open System
open System.Windows
open System.Windows.Data
open System.Windows.Controls
open System.Windows.Input
open System.Windows.Media
open System.Windows.Shapes
open Telerik.Windows.Controls
open Telerik.Windows.Controls.Charting

let ui = System.Windows.Threading.DispatcherSynchronizationContext(Tsunami.IDE.UI.Instances.ApplicationMenu.Dispatcher)
open Tsunami.IDE

let ui = Threading.DispatcherSynchronizationContext UI.Instances.ApplicationMenu.Dispatcher

let chart =
async {
do! Async.SwitchToContext ui
let chart = RadChart()
Tsunami.IDE.UI.Instances.VisualizationPane.IsHidden <- false
Tsunami.IDE.UI.Instances.VisualizationPane.Content <- chart
UI.Instances.VisualizationPane.Dock()
UI.Instances.VisualizationPane.Content <- chart
return chart
} |> Async.RunSynchronously

type Candle =
struct
val date : DateTime
Expand All @@ -52,7 +46,7 @@ type Candle =
``close`` = c
}
end

module Chart =
let lines (xss:(string*float[])[]) =
async {
Expand All @@ -66,36 +60,34 @@ module Chart =
lineSeries.Add(DataPoint(x))
chart.DefaultView.ChartArea.DataSeries.Add(lineSeries)
} |> Async.RunSynchronously

let clear() =
async {
do! Async.SwitchToContext ui
chart.DefaultView.ChartArea.DataSeries.Clear()
} |> Async.RunSynchronously



let candleStick (name:string, xs:Candle[]) =
async {
do! Async.SwitchToContext ui
chart.DefaultView.ChartArea.AxisX.IsDateTime <- true
chart.DefaultView.ChartArea.AxisX.LayoutMode <- AxisLayoutMode.Inside
chart.DefaultView.ChartArea.AxisX.LabelRotationAngle <- 45.
chart.DefaultView.ChartArea.AxisX.DefaultLabelFormat <- "dd-MMM"

let candleStickSeries = DataSeries(LegendLabel = name, Definition = new CandleStickSeriesDefinition())
candleStickSeries.AddRange(xs |> Array.map (fun x -> DataPoint(High = x.high, Low = x.low, Open = x.``open``, Close = x.close, XValue = x.date.ToOADate())))
chart.DefaultView.ChartArea.DataSeries.Add(candleStickSeries)
} |> Async.RunSynchronously



let random = new System.Random()
let randomWalk() = [|0..20|] |> Array.scan (fun state _ -> state + random.NextDouble() * 2. - 1.) 0.
let randomWalks = [| for i in 0..5 -> ("Random Walk " + string i, randomWalk()) |]

Chart.lines randomWalks

Chart.clear()

[|
let now = DateTime.Now
for i in 0..20 ->
Expand Down
30 changes: 14 additions & 16 deletions General/EditRibbon.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,28 @@
#r "PresentationFramework.dll"
#r "PresentationCore.dll"
#r "Telerik.Windows.Controls.dll"
#r "Telerik.Windows.Controls.Navigation.dll"
#r "Telerik.Windows.Controls.Docking.dll"
#r "Telerik.Windows.Controls.RibbonView.dll"
#r "ActiproSoftware.Shared.Wpf.dll"
#r "ActiproSoftware.SyntaxEditor.Wpf.dll"
#r "ActiproSoftware.Docking.Wpf.dll"
#r "ActiproSoftware.Ribbon.Wpf.dll"
#r "ActiproSoftware.DataGrid.Contrib.Wpf.dll"
#r "System.Xaml.dll"
#r "ActiproSoftware.Shared.Wpf.dll"
#r "ActiproSoftware.Text.Wpf.dll"
#r "ActiproUtilities.dll"

open Tsunami.IDE
open Tsunami.Utilities
open System
open System.Windows
open System.Windows.Controls
open ActiproSoftware.Windows.Controls
open Telerik.Windows.Controls
open Telerik.Windows.Controls.RibbonView
open ActiproSoftware.Windows.Controls.Ribbon
open Tsunami.IDE

let ui = Threading.DispatcherSynchronizationContext(Tsunami.IDE.UI.Instances.ApplicationMenu.Dispatcher)
let ui = Threading.DispatcherSynchronizationContext(UI.Instances.ApplicationMenu.Dispatcher)

async {
do! Async.SwitchToContext ui
let button = RadRibbonButton(Text = "Run", Size = ButtonSize.Large)
let button = Button(Width = 70.)
button.Content <- "Run"
button.Click.Add(fun _ -> MessageBox.Show("Hello world") |> ignore)
let tab = button |> addItem (RadRibbonGroup(Header = "Group")) |> addItem (RadRibbonTab(Header = "Tab"))
Tsunami.IDE.UI.Instances.RibbonView.Items.Add(tab) |> ignore
let tab = Controls.Tab(Label = "Tab")
let group = Controls.Group(Label = "Group")
group.ItemsSource <- [|button|]
tab.Items.Add group
UI.Instances.RibbonView.Tabs.Add tab
} |> Async.RunSynchronously

0 comments on commit c01f397

Please sign in to comment.