aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2017-04-27 15:52:59 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2017-04-27 15:52:59 +0200
commitc994e73e833331f2edfd81f77d43a12933d41d22 (patch)
tree9bb85af766909d5c46cc0ce9797fa61549a79209
parent7a9406f1be6f6d1b98b025ecbd7ef4b6feb01c21 (diff)
simple treeView presenting example with source of crow files
-rw-r--r--Tests/Showcase.cs199
-rw-r--r--Tests/Tests.csproj9
-rw-r--r--Tests/UIEditor.cs64
-rwxr-xr-xTests/ui/showcase.crow22
4 files changed, 224 insertions, 70 deletions
diff --git a/Tests/Showcase.cs b/Tests/Showcase.cs
new file mode 100644
index 00000000..517f722d
--- /dev/null
+++ b/Tests/Showcase.cs
@@ -0,0 +1,199 @@
+//
+// UIEditor.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2013-2017 Jean-Philippe Bruyère
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using OpenTK;
+using OpenTK.Graphics.OpenGL;
+using Crow;
+using System.IO;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Linq;
+
+namespace Tests
+{
+ class Showcase : CrowWindow
+ {
+ [STAThread]
+ static void Main ()
+ {
+ Showcase win = new Showcase ();
+ win.Run (30);
+ }
+
+ public Showcase ()
+ : base(1024, 800,"Showcase")
+ {
+ }
+
+ Container crowContainer;
+
+ protected override void OnLoad (EventArgs e)
+ {
+ base.OnLoad (e);
+
+ GraphicObject g = Load ("#Tests.ui.showcase.crow");
+ g.DataSource = this;
+ crowContainer = g.FindByName ("CrowContainer") as Container;
+ //I set an empty object as datasource at this level to force update when new
+ //widgets are added to the interface
+ crowContainer.DataSource = new object ();
+ }
+
+ void Dv_SelectedItemChanged (object sender, SelectionChangeEventArgs e)
+ {
+ FileSystemInfo fi = e.NewValue as FileSystemInfo;
+ if (fi == null)
+ return;
+ lock (this.ifaceControl [0].CrowInterface.UpdateMutex) {
+ GraphicObject g = this.ifaceControl [0].CrowInterface.Load (fi.FullName);
+ crowContainer.SetChild (g);
+ g.DataSource = this;
+ }
+
+ string source = "";
+ using (Stream s = new FileStream (fi.FullName, FileMode.Open)) {
+ using (StreamReader sr = new StreamReader (s)) {
+ source = sr.ReadToEnd ();
+ }
+ }
+ NotifyValueChanged ("source", source);
+ }
+
+ void Tb_TextChanged (object sender, TextChangeEventArgs e)
+ {
+ GraphicObject g = null;
+ try {
+ lock (this.ifaceControl [0].CrowInterface.UpdateMutex) {
+ Instantiator inst = null;
+ using (MemoryStream ms = new MemoryStream (System.Text.Encoding.Unicode.GetBytes (e.Text))){
+ inst = new Instantiator (ms);
+ }
+ g = inst.CreateInstance (this.ifaceControl [0].CrowInterface);
+ crowContainer.SetChild (g);
+
+ }
+ } catch (Exception ex) {
+ System.Diagnostics.Debug.WriteLine (ex.ToString ());
+ }
+ g.DataSource = this;
+ }
+ public override void OnRender (FrameEventArgs e)
+ {
+ base.OnRender (e);
+ }
+
+ #region Test values for Binding
+ public int intValue = 500;
+ DirectoryInfo curDir = new DirectoryInfo (Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
+ //DirectoryInfo curDir = new DirectoryInfo (@"/mnt/data/Images");
+ public FileSystemInfo[] CurDirectory {
+ get { return curDir.GetFileSystemInfos (); }
+ }
+ public int IntValue {
+ get {
+ return intValue;
+ }
+ set {
+ intValue = value;
+ NotifyValueChanged ("IntValue", intValue);
+ }
+ }
+ void onSpinnerValueChange(object sender, ValueChangeEventArgs e){
+ if (e.MemberName != "Value")
+ return;
+ intValue = Convert.ToInt32(e.NewValue);
+ }
+ void change_alignment(object sender, EventArgs e){
+ RadioButton rb = sender as RadioButton;
+ if (rb == null)
+ return;
+ NotifyValueChanged ("alignment", Enum.Parse(typeof(Alignment), rb.Caption));
+ }
+ public IList<String> List2 = new List<string>(new string[]
+ {
+ "string1",
+ "string2",
+ "string3",
+ // "string4",
+ // "string5",
+ // "string6",
+ // "string7",
+ // "string8",
+ // "string8",
+ // "string8",
+ // "string8",
+ // "string8",
+ // "string8",
+ // "string9"
+ }
+ );
+ public IList<String> TestList2 {
+ set{
+ List2 = value;
+ NotifyValueChanged ("TestList2", testList);
+ }
+ get { return List2; }
+ }
+ IList<Color> testList = Color.ColorDic.ToList();
+ public IList<Color> TestList {
+ set{
+ testList = value;
+ NotifyValueChanged ("TestList", testList);
+ }
+ get { return testList; }
+ }
+ string curSources = "";
+ public string CurSources {
+ get { return curSources; }
+ set {
+ if (value == curSources)
+ return;
+ curSources = value;
+ NotifyValueChanged ("CurSources", curSources);
+ }
+ }
+ bool boolVal = true;
+ public bool BoolVal {
+ get { return boolVal; }
+ set {
+ if (boolVal == value)
+ return;
+ boolVal = value;
+ NotifyValueChanged ("BoolVal", boolVal);
+ }
+ }
+
+ #endregion
+
+ void OnClear (object sender, MouseButtonEventArgs e) => TestList = null;
+
+ void OnLoadList (object sender, MouseButtonEventArgs e) => TestList = Color.ColorDic.ToList();
+
+ }
+
+
+} \ No newline at end of file
diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj
index 360f4400..16c851a3 100644
--- a/Tests/Tests.csproj
+++ b/Tests/Tests.csproj
@@ -8,7 +8,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>Tests</RootNamespace>
<AssemblyName>Tests</AssemblyName>
- <StartupObject>Tests.BasicTests</StartupObject>
+ <StartupObject>Tests.Showcase</StartupObject>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReleaseVersion>0.5</ReleaseVersion>
@@ -28,16 +28,12 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<DefineConstants>DEBUG;TRACE;MEASURE_TIME</DefineConstants>
- <IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)</IntermediateOutputPath>
- <OutputPath>$(SolutionDir)build\$(Configuration)</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<WarningLevel>0</WarningLevel>
<ConsolePause>false</ConsolePause>
- <IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)</IntermediateOutputPath>
- <OutputPath>$(SolutionDir)build\$(Configuration)</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@@ -61,11 +57,11 @@
<Compile Include="OpenGL\Texture.cs" />
<Compile Include="HelloWorld.cs" />
<Compile Include="HelloCube.cs" />
- <Compile Include="UIEditor.cs" />
<Compile Include="CrowWindow.cs" />
<Compile Include="Hello3D.cs" />
<Compile Include="OpenGL\Extensions.cs" />
<Compile Include="InterfaceControler.cs" />
+ <Compile Include="Showcase.cs" />
</ItemGroup>
<ItemGroup>
<None Include="image\u.svg">
@@ -356,6 +352,7 @@
<EmbeddedResource Include="Interfaces\treeList.crow" />
<EmbeddedResource Include="Interfaces\CheckBox2.imlt" />
<EmbeddedResource Include="Interfaces\perfMsr.crow" />
+ <EmbeddedResource Include="ui\showcase.crow" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Crow.csproj">
diff --git a/Tests/UIEditor.cs b/Tests/UIEditor.cs
deleted file mode 100644
index ed21eceb..00000000
--- a/Tests/UIEditor.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-//
-// UIEditor.cs
-//
-// Author:
-// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using OpenTK;
-using OpenTK.Graphics.OpenGL;
-using Crow;
-
-namespace Tests
-{
- class UIEditor : CrowWindow
- {
- [STAThread]
- static void Main ()
- {
- UIEditor win = new UIEditor ();
- win.Run (30);
- }
-
- public UIEditor ()
- : base(800, 600,"UIEditor")
- {
- }
-
- protected override void OnLoad (EventArgs e)
- {
- base.OnLoad (e);
-
- AddWidget(
- new Window ()
- {
- Caption = "Hello World"
- }
- );
- }
- public override void OnRender (FrameEventArgs e)
- {
- base.OnRender (e);
- }
- }
-} \ No newline at end of file
diff --git a/Tests/ui/showcase.crow b/Tests/ui/showcase.crow
new file mode 100755
index 00000000..4453e6aa
--- /dev/null
+++ b/Tests/ui/showcase.crow
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<HorizontalStack Background="Onyx" Margin="5">
+ <DirectoryView Name="dv" CurrentDirectory="Interfaces" Width="25%" SelectedItemChanged="Dv_SelectedItemChanged"
+ />
+ <Splitter Width="6"/>
+ <VerticalStack>
+ <Container Name="CrowContainer" Height="60%" Background="SmokyBlack"/>
+ <Splitter/>
+ <HorizontalStack>
+ <Scroller Name="scroller1" Background="White"
+ Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}"
+ ValueChanged="./_scroller_ValueChanged">
+ <TextBox VerticalAlignment="Top" TextChanged="Tb_TextChanged"
+ Text="{source}" Multiline="true" TextAlignment="TopLeft"
+ Font="Courriernew 10"/>
+ </Scroller>
+ <ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollY}"
+ Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical"
+ Width="14" />
+ </HorizontalStack>
+ </VerticalStack>
+</HorizontalStack>