From e6482e0efc568749f15dd12b91c56150a83a1172 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Wed, 17 May 2017 17:26:37 +0200 Subject: [PATCH] TestApp derived from Crow.Application --- testDrm/Main.cs | 69 +++++++++++++++--- testDrm/testDrm.csproj | 7 +- testDrm/tests.cs | 32 ++++++++- testDrm/ui/0.crow | 158 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 253 insertions(+), 13 deletions(-) create mode 100755 testDrm/ui/0.crow diff --git a/testDrm/Main.cs b/testDrm/Main.cs index e8485faf..73a165b6 100644 --- a/testDrm/Main.cs +++ b/testDrm/Main.cs @@ -29,23 +29,76 @@ using System.IO; using System.Collections.Generic; using Cairo; using Crow.Linux; +using Crow; namespace testDrm { - static class TestDrm - { + public class TestApp : Application, IValueChange + { static void Main () { + try { + using (TestApp crowApp = new TestApp ()) { + crowApp.Run (); + } + } catch (Exception ex) { + Console.WriteLine (ex.ToString ()); + } + } + + #region IValueChange implementation + public event EventHandler ValueChanged; + public virtual void NotifyValueChanged(string MemberName, object _value) + { + //Debug.WriteLine ("Value changed: {0}->{1} = {2}", this, MemberName, _value); + ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value)); + } + #endregion + + public bool Running = true; + + public TestApp () : base () { - using (Application drm = new Application ()) { - //drm.CrowInterface.LoadInterface (@"/mnt/data2/devel/crow/Tests/Interfaces/Divers/colorPicker.crow"); - drm.CrowInterface.LoadInterface ("#testDrm.ui.menu.crow"); - drm.CrowInterface.LoadInterface (@"/mnt/data2/devel/crow/Tests/Interfaces/Divers/0.crow"); - //drm.CrowInterface.LoadInterface (@"/mnt/data2/devel/crow/Tests/Interfaces/GraphicObject/2.crow"); - drm.Run (); + } + int frTime = 0; + int frMin = int.MaxValue; + int frMax = 0; + + public override void Run () + { + Stopwatch frame = new Stopwatch (); + Load ("#testDrm.ui.menu.crow").DataSource = this; + Load ("#testDrm.ui.0.crow").DataSource = this; + Load ("#testDrm.ui.0.crow").DataSource = this; + Load ("#testDrm.ui.0.crow").DataSource = this; + Load ("#testDrm.ui.0.crow").DataSource = this; + + while(Running){ + try { + frame.Restart(); + base.Run (); + frame.Stop(); + frTime = (int)frame.ElapsedTicks; + NotifyValueChanged("frameTime", frTime); + if (frTime > frMax){ + frMax = frTime; + NotifyValueChanged("frameMax", frMax); + } + if (frTime < frMin){ + frMin = frTime; + NotifyValueChanged("frameMin", frMin); + } + + } catch (Exception ex) { + Console.WriteLine (ex.ToString()); + } } } + void onQuitClick(object send, Crow.MouseButtonEventArgs e) + { + Running = false; + } } } diff --git a/testDrm/testDrm.csproj b/testDrm/testDrm.csproj index 5b4f7f84..5517f274 100644 --- a/testDrm/testDrm.csproj +++ b/testDrm/testDrm.csproj @@ -18,7 +18,7 @@ - testDrm.Tests + testDrm.TestApp true @@ -64,7 +64,6 @@ Code - @@ -81,6 +80,7 @@ + @@ -104,9 +104,10 @@ + - + \ No newline at end of file diff --git a/testDrm/tests.cs b/testDrm/tests.cs index 1098c10c..576b4481 100644 --- a/testDrm/tests.cs +++ b/testDrm/tests.cs @@ -37,26 +37,54 @@ using System.IO; using System.Collections.Generic; using System.Linq; using Crow; +using System.Diagnostics; namespace testDrm { - public class TestApp : Application { + public class TestApp : Application, IValueChange + { + #region IValueChange implementation + public event EventHandler ValueChanged; + public virtual void NotifyValueChanged(string MemberName, object _value) + { + //Debug.WriteLine ("Value changed: {0}->{1} = {2}", this, MemberName, _value); + ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value)); + } + #endregion public bool Running = true; public TestApp () : base () { } + int frTime = 0; + int frMin = int.MaxValue; + int frMax = 0; + public override void Run () { + Stopwatch frame = new Stopwatch (); Load ("#testDrm.ui.menu.crow").DataSource = this; - Load (@"/mnt/data2/devel/crow/Tests/Interfaces/Divers/0.crow"); + Load ("#testDrm.ui.0.crow").DataSource = this; while(Running){ try { + frame.Restart(); base.Run (); + frame.Stop(); + frTime = (int)frame.ElapsedTicks; + NotifyValueChanged("frameTime", frTime); + if (frTime > frMax){ + frMax = frTime; + NotifyValueChanged("frameMax", frMax); + } + if (frTime < frMin){ + frMin = frTime; + NotifyValueChanged("frameMin", frMin); + } + } catch (Exception ex) { Console.WriteLine (ex.ToString()); } diff --git a/testDrm/ui/0.crow b/testDrm/ui/0.crow new file mode 100755 index 00000000..744f3cb4 --- /dev/null +++ b/testDrm/ui/0.crow @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + +