diff --git a/.bonsai/.gitignore b/.bonsai/.gitignore new file mode 100644 index 0000000..16e6b2f --- /dev/null +++ b/.bonsai/.gitignore @@ -0,0 +1,3 @@ +*.exe +*.exe.* +Packages \ No newline at end of file diff --git a/.bonsai/Bonsai.config b/.bonsai/Bonsai.config new file mode 100644 index 0000000..e85ebbb --- /dev/null +++ b/.bonsai/Bonsai.config @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.bonsai/NuGet.config b/.bonsai/NuGet.config new file mode 100644 index 0000000..97e8b73 --- /dev/null +++ b/.bonsai/NuGet.config @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/.bonsai/Setup.cmd b/.bonsai/Setup.cmd new file mode 100644 index 0000000..92d983d --- /dev/null +++ b/.bonsai/Setup.cmd @@ -0,0 +1,4 @@ +@echo off +pushd %~dp0 +powershell -ExecutionPolicy Bypass -File ./Setup.ps1 +popd \ No newline at end of file diff --git a/.bonsai/Setup.ps1 b/.bonsai/Setup.ps1 new file mode 100644 index 0000000..01cfba6 --- /dev/null +++ b/.bonsai/Setup.ps1 @@ -0,0 +1,21 @@ +Push-Location $PSScriptRoot +if (!(Test-Path "./Bonsai.exe")) { + $release = "https://github.com/bonsai-rx/bonsai/releases/latest/download/Bonsai.zip" + $configPath = "./Bonsai.config" + if (Test-Path $configPath) { + [xml]$config = Get-Content $configPath + $bootstrapper = $config.PackageConfiguration.Packages.Package.where{$_.id -eq 'Bonsai'} + if ($bootstrapper) { + $version = $bootstrapper.version + $release = "https://github.com/bonsai-rx/bonsai/releases/download/$version/Bonsai.zip" + } + } + Invoke-WebRequest $release -OutFile "temp.zip" + Move-Item -Path "NuGet.config" "temp.config" -ErrorAction SilentlyContinue + Expand-Archive "temp.zip" -DestinationPath "." -Force + Move-Item -Path "temp.config" "NuGet.config" -Force -ErrorAction SilentlyContinue + Remove-Item -Path "temp.zip" + Remove-Item -Path "Bonsai32.exe" +} +& .\Bonsai.exe --no-editor +Pop-Location \ No newline at end of file diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 528d61f..ff0a99f 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -27,8 +27,13 @@ jobs: - name: Setup DocFX run: dotnet tool restore + - name: Setup Bonsai + working-directory: .bonsai + run: .\Setup.ps1 + - name: Build Documentation - run: dotnet docfx docs/docfx.json + working-directory: docs + run: .\build.ps1 - name: Checkout gh-pages uses: actions/checkout@v4.1.1 diff --git a/docs/build.ps1 b/docs/build.ps1 new file mode 100644 index 0000000..9d1d453 --- /dev/null +++ b/docs/build.ps1 @@ -0,0 +1,2 @@ +.\bonsai\modules\Export-Image.ps1 "..\src\Bonsai.Gui.ZedGraph\bin\Release\net472" +dotnet docfx @args \ No newline at end of file diff --git a/docs/images/basic_controls.svg b/docs/images/basic_controls.svg new file mode 100644 index 0000000..e08c707 --- /dev/null +++ b/docs/images/basic_controls.svg @@ -0,0 +1,3 @@ + +]>ToggleButtonTextBoxSliderRadioButtonPropertyGridListBoxLabelComboBoxCheckBoxButton \ No newline at end of file diff --git a/docs/images/basic_graphs.svg b/docs/images/basic_graphs.svg new file mode 100644 index 0000000..1524db9 --- /dev/null +++ b/docs/images/basic_graphs.svg @@ -0,0 +1,3 @@ + +]>RollingGraphLineGraphBarGraph \ No newline at end of file diff --git a/docs/images/container_controls.svg b/docs/images/container_controls.svg new file mode 100644 index 0000000..7d72a72 --- /dev/null +++ b/docs/images/container_controls.svg @@ -0,0 +1,3 @@ + +]>TableLayoutPanelTabControlGroupBox \ No newline at end of file diff --git a/docs/images/graph_panels.svg b/docs/images/graph_panels.svg new file mode 100644 index 0000000..fd8e6e1 --- /dev/null +++ b/docs/images/graph_panels.svg @@ -0,0 +1,3 @@ + +]>RollingGraphPanelGraphPanel \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 3c24e76..c9b5960 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,3 +1,39 @@ # Getting Started -`Bonsai.Gui` is a collection of packages for the [Bonsai](https://bonsai-rx.org/) visual programming language for quickly composing user interfaces and real-time data visualization. \ No newline at end of file +`Bonsai.Gui` is a collection of packages for the [Bonsai](https://bonsai-rx.org/) visual programming language for quickly composing user interfaces and real-time data visualization. + +To install `Bonsai.Gui` use the Bonsai package manager and search for the **Bonsai - GUI** package. + +## Build user interfaces + +`Bonsai.Gui` includes a collection of several common user interface controls, including buttons, sliders, combo boxes, text boxes, etc. + +![Basic Controls](~/images/basic_controls.svg) + +At runtime, each control operator exposes its own visualizer displaying only that specific control. To combine multiple controls together, we use container controls, such as group boxes, tab controls, or table layout panels. + +![Container Controls](~/images/container_controls.svg) + +To add controls into the container, we use the [`VisualizerMapping`](xref:Bonsai.Expressions.VisualizerMappingBuilder) operator to hierarchically overlay the controls. + +## Compose real-time visualizations + +`Bonsai.Gui.ZedGraph` provides a framework for assembling complex real-time reactive plots using bar graphs, line graphs or rolling graphs. + +![Basic Graphs](~/images/basic_graphs.svg) + +Similar to GUI elements, each of these graphs exposes a visualizer, where updates are synchronized and driven by data arriving from the input sequence. Multiple traces or bars can be plotted in the same graph if the input values are complex data types. + +Multiple independent graph visualizers can also be combined and updated asynchronously using graph panels. + +![Graph Panels](~/images/graph_panels.svg) + +Similar to GUI elements, we can add graphs into a graph panel by using the [`VisualizerMapping`](xref:Bonsai.Expressions.VisualizerMappingBuilder) operator. This can be used for example to create visualizations where part of the plot is made up of continuous periodic traces, and other parts are overlaid dynamically using sparse or infrequent updates from other data sequences. + +## Example + +The following example builds a simple GUI with a slider and a button, where values of the slider are plotted continuously on a graph. A red dot is overlaid marking the current value of the slider every time the button is clicked. + +:::workflow +![Example](~/workflows/gui-demo.bonsai) +::: diff --git a/docs/workflows/.gitignore b/docs/workflows/.gitignore new file mode 100644 index 0000000..af455cb --- /dev/null +++ b/docs/workflows/.gitignore @@ -0,0 +1,2 @@ +*.layout +*.svg \ No newline at end of file diff --git a/docs/workflows/gui-demo.bonsai b/docs/workflows/gui-demo.bonsai new file mode 100644 index 0000000..71dd2a9 --- /dev/null +++ b/docs/workflows/gui-demo.bonsai @@ -0,0 +1,129 @@ + + + + + + true + true + 0 + 100 + + 55.782312925170068 + + + OnValueChanged + + + + true + true + Click this + + + OnClick + + + + OnValueChanged + + + None + 1 + + + Trace + + + + + + + + + + OnValueChanged + + + + + + OnClick + + + + + + Timestamp + Value + Circle + 0 + + + Marker + Red + + + + + + + + + false + false + + + X + Cluster + + + + + + true + true + 2 + 2 + + + + Absolute + 64 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Bonsai.Gui.ZedGraph/Properties/launchSettings.json b/src/Bonsai.Gui.ZedGraph/Properties/launchSettings.json index b48bcfa..766d23b 100644 --- a/src/Bonsai.Gui.ZedGraph/Properties/launchSettings.json +++ b/src/Bonsai.Gui.ZedGraph/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "Bonsai": { "commandName": "Executable", - "executablePath": "$(registry:HKEY_CURRENT_USER\\Software\\Bonsai Foundation\\Bonsai@InstallDir)Bonsai.exe", + "executablePath": "$(SolutionDir)../.bonsai/Bonsai.exe", "commandLineArgs": "--lib:\"$(TargetDir).\"", "nativeDebugging": true } diff --git a/src/Bonsai.Gui/Properties/launchSettings.json b/src/Bonsai.Gui/Properties/launchSettings.json index b48bcfa..766d23b 100644 --- a/src/Bonsai.Gui/Properties/launchSettings.json +++ b/src/Bonsai.Gui/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "Bonsai": { "commandName": "Executable", - "executablePath": "$(registry:HKEY_CURRENT_USER\\Software\\Bonsai Foundation\\Bonsai@InstallDir)Bonsai.exe", + "executablePath": "$(SolutionDir)../.bonsai/Bonsai.exe", "commandLineArgs": "--lib:\"$(TargetDir).\"", "nativeDebugging": true }