From c29275576f75534c9fd109b3d3717ab52ec8415b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Tue, 30 Jan 2018 00:28:05 +0100 Subject: [PATCH] - test with both parameterless ctor and with iface param ctor - CurrentInterface as field --- Crow.csproj | 1 - Tests/BasicTests.cs | 2 +- Tests/HelloCube.cs | 2 +- Tests/HelloWorld.cs | 13 ++++- Tests/Showcase.cs | 3 +- Tests/Tests.csproj | 1 - src/CompilerServices/CompilerServices.cs | 2 +- src/GraphicObjects/AnalogMeter.cs | 8 +-- src/GraphicObjects/Border.cs | 1 + src/GraphicObjects/Button.cs | 10 ++-- src/GraphicObjects/CheckBox.cs | 8 +-- src/GraphicObjects/ColorPicker.cs | 7 +-- src/GraphicObjects/ColorSelector.cs | 7 +-- src/GraphicObjects/ComboBox.cs | 5 +- src/GraphicObjects/Container.cs | 15 +++--- src/GraphicObjects/DirectoryView.cs | 5 +- src/GraphicObjects/DummyTemplate.cs | 38 -------------- src/GraphicObjects/Expandable.cs | 5 +- src/GraphicObjects/FileDialog.cs | 11 ++-- src/GraphicObjects/GenericStack.cs | 6 +-- src/GraphicObjects/GraduatedSlider.cs | 19 +++---- src/GraphicObjects/GraphicObject.cs | 52 ++++++++----------- src/GraphicObjects/Grid.cs | 4 +- src/GraphicObjects/Group.cs | 4 +- src/GraphicObjects/GroupBox.cs | 3 +- src/GraphicObjects/HorizontalStack.cs | 6 ++- src/GraphicObjects/HueSelector.cs | 5 +- src/GraphicObjects/Image.cs | 3 +- src/GraphicObjects/Label.cs | 14 ++--- src/GraphicObjects/ListBox.cs | 3 +- src/GraphicObjects/Menu.cs | 3 +- src/GraphicObjects/MenuItem.cs | 3 +- src/GraphicObjects/MessageBox.cs | 9 ++-- src/GraphicObjects/NumericControl.cs | 11 ++-- src/GraphicObjects/Popper.cs | 5 +- src/GraphicObjects/PrivateContainer.cs | 6 +-- src/GraphicObjects/ProgressBar.cs | 3 +- src/GraphicObjects/RadioButton.cs | 3 +- src/GraphicObjects/SaturationValueSelector.cs | 3 +- src/GraphicObjects/ScrollBar.cs | 3 +- src/GraphicObjects/Scroller.cs | 8 +-- src/GraphicObjects/ScrollingObject.cs | 5 +- src/GraphicObjects/ScrollingTextBox.cs | 3 ++ src/GraphicObjects/Slider.cs | 11 ++-- src/GraphicObjects/Spinner.cs | 8 +-- src/GraphicObjects/Splitter.cs | 3 +- src/GraphicObjects/TabItem.cs | 3 +- src/GraphicObjects/TabView.cs | 3 +- src/GraphicObjects/TemplatedContainer.cs | 3 +- src/GraphicObjects/TemplatedControl.cs | 5 +- src/GraphicObjects/TemplatedGroup.cs | 7 ++- src/GraphicObjects/TextBox.cs | 13 ++--- src/GraphicObjects/TextRun.cs | 11 +--- src/GraphicObjects/TreeView.cs | 3 +- src/GraphicObjects/VerticalStack.cs | 4 +- src/GraphicObjects/Window.cs | 5 +- src/GraphicObjects/Wrapper.cs | 6 ++- src/IML/Context.cs | 9 +++- src/Instantiator.cs | 20 ++++++- 59 files changed, 220 insertions(+), 222 deletions(-) delete mode 100644 src/GraphicObjects/DummyTemplate.cs diff --git a/Crow.csproj b/Crow.csproj index c556bc79..4edb707b 100644 --- a/Crow.csproj +++ b/Crow.csproj @@ -108,7 +108,6 @@ - diff --git a/Tests/BasicTests.cs b/Tests/BasicTests.cs index 8d0a8026..6adabf6c 100644 --- a/Tests/BasicTests.cs +++ b/Tests/BasicTests.cs @@ -141,7 +141,7 @@ namespace Tests //testFiles = new string [] { @"Interfaces/Unsorted/testFileDialog.crow" }; //testFiles = new string [] { @"Interfaces/Divers/colorPicker.crow" }; - testFiles = new string [] { @"Interfaces/Divers/welcome.crow" }; + testFiles = new string [] { @"Interfaces/TemplatedContainer/testTabView.crow" }; testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/GraphicObject", "*.crow")).ToArray (); testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Container", "*.crow")).ToArray (); testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Group", "*.crow")).ToArray (); diff --git a/Tests/HelloCube.cs b/Tests/HelloCube.cs index aa460025..d44a9bff 100644 --- a/Tests/HelloCube.cs +++ b/Tests/HelloCube.cs @@ -69,7 +69,7 @@ namespace Tests base.OnLoad (e); AddWidget( - new Window () + new Window (this.CurrentInterface) { Caption = "Hello World" } diff --git a/Tests/HelloWorld.cs b/Tests/HelloWorld.cs index ca1560ef..ea37a142 100644 --- a/Tests/HelloWorld.cs +++ b/Tests/HelloWorld.cs @@ -40,9 +40,18 @@ namespace Tests { base.OnLoad (e); + Container c = (Container) Instantiator.CreateFromImlFragment (@"").CreateInstance (CurrentInterface); + GraphicObject obj = new GraphicObject (this.CurrentInterface) + { + Background = Color.AirForceBlueRaf, + Margin = 10, + Width = 100, + Height = 100 + }; + c.SetChild (obj); + AddWidget (c); - AddWidget(Instantiator.CreateFromImlFragment (@"").CreateInstance (CurrentInterface)); - //Load(@"Interfaces/GraphicObject/0.crow"); + //Load(@"Interfaces/GraphicObject/2.crow"); } [STAThread] diff --git a/Tests/Showcase.cs b/Tests/Showcase.cs index 4880ede5..67ef5eef 100644 --- a/Tests/Showcase.cs +++ b/Tests/Showcase.cs @@ -32,6 +32,7 @@ using System.IO; using System.Collections.Generic; using System.Reflection; using System.Linq; +using System.Text; namespace Tests { @@ -106,7 +107,7 @@ namespace Tests try { lock (this.ifaceControl [0].CrowInterface.UpdateMutex) { Instantiator inst = null; - using (MemoryStream ms = new MemoryStream (System.Text.Encoding.Unicode.GetBytes (e.Text))){ + using (MemoryStream ms = new MemoryStream (Encoding.UTF8.GetBytes (e.Text))){ inst = new Instantiator (ms); } g = inst.CreateInstance (this.ifaceControl [0].CrowInterface); diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 2adcdb16..38152f0b 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -50,7 +50,6 @@ - diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs index b119b3e7..000562d7 100644 --- a/src/CompilerServices/CompilerServices.cs +++ b/src/CompilerServices/CompilerServices.cs @@ -76,7 +76,7 @@ namespace Crow internal static MethodInfo miDSChangeEmitHelper = typeof(Instantiator).GetMethod("dataSourceChangedEmitHelper", BindingFlags.Instance | BindingFlags.NonPublic); internal static MethodInfo miDSReverseBinding = typeof(Instantiator).GetMethod("dataSourceReverseBinding", BindingFlags.Static | BindingFlags.NonPublic); - internal static FieldInfo miSetCurIface = typeof(GraphicObject).GetField ("currentInterface", BindingFlags.NonPublic | BindingFlags.Instance); + internal static FieldInfo miSetCurIface = typeof(GraphicObject).GetField ("CurrentInterface", BindingFlags.Public | BindingFlags.Instance); internal static MethodInfo miFindByName = typeof (GraphicObject).GetMethod ("FindByName"); internal static MethodInfo miGetGObjItem = typeof(List).GetMethod("get_Item", new Type[] { typeof(Int32) }); internal static MethodInfo miLoadDefaultVals = typeof (GraphicObject).GetMethod ("loadDefaultValues"); diff --git a/src/GraphicObjects/AnalogMeter.cs b/src/GraphicObjects/AnalogMeter.cs index 3875df15..fba58d9d 100644 --- a/src/GraphicObjects/AnalogMeter.cs +++ b/src/GraphicObjects/AnalogMeter.cs @@ -34,12 +34,8 @@ namespace Crow public class AnalogMeter : NumericControl { #region CTOR - public AnalogMeter() : base() - {} - public AnalogMeter(double minimum, double maximum, double step) - : base(minimum,maximum,step) - { - } + public AnalogMeter () : base(){} + public AnalogMeter (Interface iface) : base(iface){} #endregion #region GraphicObject Overrides diff --git a/src/GraphicObjects/Border.cs b/src/GraphicObjects/Border.cs index ef210b57..6ac97d7f 100644 --- a/src/GraphicObjects/Border.cs +++ b/src/GraphicObjects/Border.cs @@ -41,6 +41,7 @@ namespace Crow { #region CTOR public Border () : base(){} + public Border (Interface iface) : base(iface){} #endregion #region private fields diff --git a/src/GraphicObjects/Button.cs b/src/GraphicObjects/Button.cs index 75f43014..4f791ed9 100644 --- a/src/GraphicObjects/Button.cs +++ b/src/GraphicObjects/Button.cs @@ -40,15 +40,15 @@ namespace Crow { public class Button : TemplatedContainer { + #region CTOR + public Button() : base() {} + public Button (Interface iface) : base(iface){} + #endregion + string image; bool isPressed; Container _contentContainer; - #region CTOR - public Button() : base() - {} - #endregion - public event EventHandler Pressed; public event EventHandler Released; diff --git a/src/GraphicObjects/CheckBox.cs b/src/GraphicObjects/CheckBox.cs index 0a40d269..3a63ba2c 100644 --- a/src/GraphicObjects/CheckBox.cs +++ b/src/GraphicObjects/CheckBox.cs @@ -32,13 +32,13 @@ namespace Crow { public class CheckBox : TemplatedControl { - bool isChecked; - #region CTOR - public CheckBox() : base() - {} + public CheckBox () : base(){} + public CheckBox (Interface iface) : base(iface){} #endregion + bool isChecked; + public event EventHandler Checked; public event EventHandler Unchecked; diff --git a/src/GraphicObjects/ColorPicker.cs b/src/GraphicObjects/ColorPicker.cs index 02496b3b..b47e8ffc 100644 --- a/src/GraphicObjects/ColorPicker.cs +++ b/src/GraphicObjects/ColorPicker.cs @@ -32,9 +32,10 @@ namespace Crow { public class ColorPicker : TemplatedControl { - public ColorPicker () : base () - { - } + #region CTOR + public ColorPicker () : base(){} + public ColorPicker (Interface iface) : base(iface){} + #endregion const double div = 255.0; const double colDiv = 1.0 / div; diff --git a/src/GraphicObjects/ColorSelector.cs b/src/GraphicObjects/ColorSelector.cs index c9f3a198..4dfc68f6 100644 --- a/src/GraphicObjects/ColorSelector.cs +++ b/src/GraphicObjects/ColorSelector.cs @@ -32,9 +32,10 @@ namespace Crow { public class ColorSelector : GraphicObject { - public ColorSelector (): base() - { - } + #region CTOR + public ColorSelector () : base(){} + public ColorSelector (Interface iface) : base(iface){} + #endregion const double div = 255.0; const double colDiv = 1.0 / div; diff --git a/src/GraphicObjects/ComboBox.cs b/src/GraphicObjects/ComboBox.cs index 15b49dbe..85a04608 100644 --- a/src/GraphicObjects/ComboBox.cs +++ b/src/GraphicObjects/ComboBox.cs @@ -30,9 +30,10 @@ using System.Xml.Serialization; namespace Crow { public class ComboBox : ListBox - { + { #region CTOR - public ComboBox() : base(){ } + public ComboBox () : base(){} + public ComboBox (Interface iface) : base(iface){} #endregion Size minimumPopupSize = "10,10"; diff --git a/src/GraphicObjects/Container.cs b/src/GraphicObjects/Container.cs index df14b8e2..c7dfd78b 100644 --- a/src/GraphicObjects/Container.cs +++ b/src/GraphicObjects/Container.cs @@ -36,17 +36,18 @@ namespace Crow public class Container : PrivateContainer { #region CTOR - public Container() - : base() - { - } + public Container () : base(){} + public Container (Interface iface) : base(iface){} #endregion - [XmlIgnore] - public GraphicObject Child { + [XmlIgnore]public GraphicObject Child { get { return child; } - set { child = value; } + set { base.SetChild(value); } } + /// + /// override this to handle specific steps in child addition in derived class, + /// and don't forget to call the base.SetChild + /// public virtual void SetChild(GraphicObject _child) { base.SetChild (_child); diff --git a/src/GraphicObjects/DirectoryView.cs b/src/GraphicObjects/DirectoryView.cs index 98477cba..ab5d4aba 100644 --- a/src/GraphicObjects/DirectoryView.cs +++ b/src/GraphicObjects/DirectoryView.cs @@ -34,9 +34,8 @@ namespace Crow public class DirectoryView : TemplatedControl { #region CTOR - public DirectoryView () - : base() - {} + public DirectoryView () : base(){} + public DirectoryView (Interface iface) : base(iface){} #endregion #region events diff --git a/src/GraphicObjects/DummyTemplate.cs b/src/GraphicObjects/DummyTemplate.cs deleted file mode 100644 index 65d9e081..00000000 --- a/src/GraphicObjects/DummyTemplate.cs +++ /dev/null @@ -1,38 +0,0 @@ -// -// DummyTemplate.cs -// -// Author: -// Jean-Philippe Bruyère -// -// 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; - -namespace Crow -{ - public class DummyTemplate : TemplatedControl - { - public DummyTemplate () : base() - { - } - } -} - diff --git a/src/GraphicObjects/Expandable.cs b/src/GraphicObjects/Expandable.cs index 1cb36450..243caf06 100644 --- a/src/GraphicObjects/Expandable.cs +++ b/src/GraphicObjects/Expandable.cs @@ -33,9 +33,8 @@ namespace Crow public class Expandable : TemplatedContainer { #region CTOR - public Expandable() : base() - { - } + public Expandable () : base(){} + public Expandable (Interface iface) : base(iface){} #endregion #region Private fields diff --git a/src/GraphicObjects/FileDialog.cs b/src/GraphicObjects/FileDialog.cs index 8182e021..550e2eaf 100644 --- a/src/GraphicObjects/FileDialog.cs +++ b/src/GraphicObjects/FileDialog.cs @@ -37,18 +37,17 @@ namespace Crow { public class FileDialog: Window { + #region CTOR + public FileDialog () : base(){} + public FileDialog (Interface iface) : base(iface){} + #endregion + string searchPattern, curDir, _selectedFile, _selectedDir; #region events public event EventHandler OkClicked; #endregion - #region CTOR - public FileDialog () : base() - { - } - #endregion - [XmlAttributeAttribute][DefaultValue("/home")] public virtual string CurrentDirectory { get { return curDir; } diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index cecdaffd..e52485ac 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -34,10 +34,8 @@ namespace Crow public class GenericStack : Group { #region CTOR - public GenericStack() - : base() - { - } + public GenericStack () : base(){} + public GenericStack(Interface iface) : base(iface){} #endregion #region Private fields diff --git a/src/GraphicObjects/GraduatedSlider.cs b/src/GraphicObjects/GraduatedSlider.cs index 0721e767..b8d7d581 100644 --- a/src/GraphicObjects/GraduatedSlider.cs +++ b/src/GraphicObjects/GraduatedSlider.cs @@ -36,16 +36,17 @@ namespace Crow public class GraduatedSlider : Slider { #region CTOR - public GraduatedSlider() : base() + public GraduatedSlider () : base(){} + public GraduatedSlider(Interface iface) : base(iface) {} - public GraduatedSlider(double minimum, double maximum, double step) - : base() - { - Minimum = minimum; - Maximum = maximum; - SmallIncrement = step; - LargeIncrement = step * 5; - } +// public GraduatedSlider(double minimum, double maximum, double step) +// : base() +// { +// Minimum = minimum; +// Maximum = maximum; +// SmallIncrement = step; +// LargeIncrement = step * 5; +// } #endregion protected override void DrawGraduations(Context gr, PointD pStart, PointD pEnd) diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 1ba524d7..954c08e7 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -64,17 +64,17 @@ namespace Crow if (IsQueueForRedraw) throw new Exception("Trying to dispose an object queued for Redraw: " + this.ToString()); #endif - if (currentInterface.HoverWidget != null) { - if (currentInterface.HoverWidget.IsOrIsInside(this)) - currentInterface.HoverWidget = null; + if (CurrentInterface.HoverWidget != null) { + if (CurrentInterface.HoverWidget.IsOrIsInside(this)) + CurrentInterface.HoverWidget = null; } - if (currentInterface.ActiveWidget != null) { - if (currentInterface.ActiveWidget.IsOrIsInside (this)) - currentInterface.ActiveWidget = null; + if (CurrentInterface.ActiveWidget != null) { + if (CurrentInterface.ActiveWidget.IsOrIsInside (this)) + CurrentInterface.ActiveWidget = null; } - if (currentInterface.FocusedWidget != null) { - if (currentInterface.FocusedWidget.IsOrIsInside (this)) - currentInterface.FocusedWidget = null; + if (CurrentInterface.FocusedWidget != null) { + if (CurrentInterface.FocusedWidget.IsOrIsInside (this)) + CurrentInterface.FocusedWidget = null; } if (!localDataSourceIsNull) DataSource = null; @@ -91,20 +91,7 @@ namespace Crow internal static ulong currentUid = 0; internal ulong uid = 0; - Interface currentInterface = null; - - [XmlIgnore]public Interface CurrentInterface { - get { - if (currentInterface == null) { - currentInterface = Interface.CurrentInterface; - Initialize (); - } - return currentInterface; - } - set { - currentInterface = value; - } - } + public Interface CurrentInterface = null; public Region Clipping; @@ -118,13 +105,20 @@ namespace Crow #endregion #region CTOR - public GraphicObject () - { + /// + /// default private parameter less constructor use in instantiators + /// + protected GraphicObject () { Clipping = new Region (); #if DEBUG uid = currentUid; currentUid++; - #endif + #endif + } + public GraphicObject (Interface iface) : this() + { + CurrentInterface = iface; + Initialize (); } #endregion internal bool initialized = false; @@ -132,8 +126,8 @@ namespace Crow /// Initialize this Graphic object instance by setting style and default values and loading template if required /// public virtual void Initialize(){ - if (currentInterface == null) - currentInterface = Interface.CurrentInterface; +// if (CurrentInterface == null) +// CurrentInterface = Interface.CurrentInterface; loadDefaultValues (); initialized = true; } @@ -1336,7 +1330,7 @@ namespace Crow if (CurrentInterface.eligibleForDoubleClick == this && CurrentInterface.clickTimer.ElapsedMilliseconds < Interface.DoubleClick) onMouseDoubleClick (this, e); else - currentInterface.clickTimer.Restart(); + CurrentInterface.clickTimer.Restart(); CurrentInterface.eligibleForDoubleClick = null; if (CurrentInterface.ActiveWidget == null) diff --git a/src/GraphicObjects/Grid.cs b/src/GraphicObjects/Grid.cs index 3d1847a2..5756525e 100644 --- a/src/GraphicObjects/Grid.cs +++ b/src/GraphicObjects/Grid.cs @@ -43,8 +43,8 @@ namespace Crow public class Grid : Group { #region CTOR - public Grid() - : base() + public Grid () : base(){} + public Grid(Interface iface) : base(iface) { } #endregion diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index e4e9ba20..551db889 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -38,8 +38,8 @@ namespace Crow public class Group : GraphicObject { #region CTOR - public Group() - : base(){} + public Group () : base(){} + public Group(Interface iface) : base(iface){} #endregion #region EVENT HANDLERS diff --git a/src/GraphicObjects/GroupBox.cs b/src/GraphicObjects/GroupBox.cs index 9cabbb51..ad79231e 100644 --- a/src/GraphicObjects/GroupBox.cs +++ b/src/GraphicObjects/GroupBox.cs @@ -35,7 +35,8 @@ namespace Crow Container _contentContainer; #region CTOR - public GroupBox() : base(){} + public GroupBox () : base(){} + public GroupBox(Interface iface) : base(iface){} #endregion #region Template overrides diff --git a/src/GraphicObjects/HorizontalStack.cs b/src/GraphicObjects/HorizontalStack.cs index 620dab22..13ed4cb5 100644 --- a/src/GraphicObjects/HorizontalStack.cs +++ b/src/GraphicObjects/HorizontalStack.cs @@ -34,10 +34,12 @@ namespace Crow { public class HorizontalStack : GenericStack { - public HorizontalStack() - : base() + #region CTOR + public HorizontalStack () : base(){} + public HorizontalStack(Interface iface) : base(iface) { } + #endregion [XmlIgnore] public override Orientation Orientation diff --git a/src/GraphicObjects/HueSelector.cs b/src/GraphicObjects/HueSelector.cs index 365cc72a..a94053fd 100644 --- a/src/GraphicObjects/HueSelector.cs +++ b/src/GraphicObjects/HueSelector.cs @@ -33,9 +33,12 @@ namespace Crow { public class HueSelector : ColorSelector { - public HueSelector () : base() + #region CTOR + public HueSelector () : base(){} + public HueSelector (Interface iface) : base(iface) { } + #endregion Orientation _orientation; double hue; diff --git a/src/GraphicObjects/Image.cs b/src/GraphicObjects/Image.cs index 6a4c590d..3ec49d37 100644 --- a/src/GraphicObjects/Image.cs +++ b/src/GraphicObjects/Image.cs @@ -125,7 +125,8 @@ namespace Crow #endregion #region CTOR - public Image () : base() + public Image () : base(){} + public Image (Interface iface) : base(iface) { } #endregion diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs index e477c3f6..7c7c584c 100644 --- a/src/GraphicObjects/Label.cs +++ b/src/GraphicObjects/Label.cs @@ -38,15 +38,17 @@ namespace Crow public class Label : GraphicObject { #region CTOR - public Label() - { + public Label () : base(){} - } - public Label(string _text) - : base() + public Label(Interface iface) : base(iface) { - Text = _text; + } +// public Label(string _text) +// : base() +// { +// Text = _text; +// } #endregion public event EventHandler TextChanged; diff --git a/src/GraphicObjects/ListBox.cs b/src/GraphicObjects/ListBox.cs index f66edf61..67e4b583 100644 --- a/src/GraphicObjects/ListBox.cs +++ b/src/GraphicObjects/ListBox.cs @@ -39,7 +39,8 @@ namespace Crow public class ListBox : TemplatedGroup { #region CTOR - public ListBox () : base() {} + public ListBox () : base(){} + public ListBox (Interface iface) : base(iface) {} #endregion } diff --git a/src/GraphicObjects/Menu.cs b/src/GraphicObjects/Menu.cs index 50494815..d7a7f5a6 100644 --- a/src/GraphicObjects/Menu.cs +++ b/src/GraphicObjects/Menu.cs @@ -33,7 +33,8 @@ namespace Crow public class Menu : TemplatedGroup { #region CTOR - public Menu () : base() {} + public Menu () : base(){} + public Menu (Interface iface) : base(iface) {} #endregion Orientation orientation; diff --git a/src/GraphicObjects/MenuItem.cs b/src/GraphicObjects/MenuItem.cs index 0d99a2eb..5565ace3 100644 --- a/src/GraphicObjects/MenuItem.cs +++ b/src/GraphicObjects/MenuItem.cs @@ -33,7 +33,8 @@ namespace Crow public class MenuItem : Menu { #region CTOR - public MenuItem () : base() {} + public MenuItem () : base(){} + public MenuItem (Interface iface) : base(iface) {} #endregion public event EventHandler Open; diff --git a/src/GraphicObjects/MessageBox.cs b/src/GraphicObjects/MessageBox.cs index d8ce1dae..0e308bf9 100644 --- a/src/GraphicObjects/MessageBox.cs +++ b/src/GraphicObjects/MessageBox.cs @@ -32,13 +32,17 @@ namespace Crow { public class MessageBox : Window { + #region CTOR + public MessageBox () : base(){} + public MessageBox (Interface iface) : base(iface){} + #endregion + public enum Type { Information, YesNo, Alert, Error } - public MessageBox (): base(){} protected override void loadTemplate (GraphicObject template) { @@ -133,8 +137,7 @@ namespace Crow } public static MessageBox Show (Type msgBoxType, string message, string okMsg = "", string cancelMsg = ""){ lock (Interface.CurrentInterface.UpdateMutex) { - MessageBox mb = new MessageBox (); - mb.Initialize (); + MessageBox mb = new MessageBox (Interface.CurrentInterface); mb.CurrentInterface.AddWidget (mb); mb.MsgType = msgBoxType; mb.Message = message; diff --git a/src/GraphicObjects/NumericControl.cs b/src/GraphicObjects/NumericControl.cs index 8ab60edb..d8fdead4 100644 --- a/src/GraphicObjects/NumericControl.cs +++ b/src/GraphicObjects/NumericControl.cs @@ -33,13 +33,14 @@ namespace Crow public abstract class NumericControl : TemplatedControl { #region CTOR - public NumericControl () : base() - { - } - public NumericControl(double minimum, double maximum, double step) - : base() + public NumericControl () : base(){} + public NumericControl (Interface iface) : base(iface) { } +// public NumericControl(double minimum, double maximum, double step) +// : base() +// { +// } #endregion #region private fields diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs index 72a3fa8d..9f60aa40 100644 --- a/src/GraphicObjects/Popper.cs +++ b/src/GraphicObjects/Popper.cs @@ -33,9 +33,8 @@ namespace Crow public class Popper : TemplatedContainer { #region CTOR - public Popper() : base() - { - } + public Popper () : base(){} + public Popper (Interface iface) : base(iface){} #endregion bool _isPopped, _canPop; diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index c40bceb4..f25190ea 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -41,10 +41,8 @@ namespace Crow public class PrivateContainer : GraphicObject { #region CTOR - public PrivateContainer() - : base() - { - } + public PrivateContainer () : base(){} + public PrivateContainer (Interface iface) : base(iface){} #endregion protected GraphicObject child; diff --git a/src/GraphicObjects/ProgressBar.cs b/src/GraphicObjects/ProgressBar.cs index 34366ca7..2995272b 100644 --- a/src/GraphicObjects/ProgressBar.cs +++ b/src/GraphicObjects/ProgressBar.cs @@ -39,7 +39,8 @@ namespace Crow public class ProgressBar : NumericControl { #region CTOR - public ProgressBar() : base(){} + public ProgressBar () : base(){} + public ProgressBar(Interface iface) : base(iface){} #endregion protected override void loadTemplate (GraphicObject template) diff --git a/src/GraphicObjects/RadioButton.cs b/src/GraphicObjects/RadioButton.cs index 993ead59..bf31a42c 100644 --- a/src/GraphicObjects/RadioButton.cs +++ b/src/GraphicObjects/RadioButton.cs @@ -35,7 +35,8 @@ namespace Crow bool isChecked; #region CTOR - public RadioButton() : base(){} + public RadioButton () : base(){} + public RadioButton(Interface iface) : base(iface){} #endregion public event EventHandler Checked; diff --git a/src/GraphicObjects/SaturationValueSelector.cs b/src/GraphicObjects/SaturationValueSelector.cs index 39c324f4..fb3cbf48 100644 --- a/src/GraphicObjects/SaturationValueSelector.cs +++ b/src/GraphicObjects/SaturationValueSelector.cs @@ -32,7 +32,8 @@ namespace Crow { public class SaturationValueSelector : ColorSelector { - public SaturationValueSelector () : base() + public SaturationValueSelector () : base(){} + public SaturationValueSelector (Interface iface) : base(iface) { } diff --git a/src/GraphicObjects/ScrollBar.cs b/src/GraphicObjects/ScrollBar.cs index ca258aae..75a3b2db 100644 --- a/src/GraphicObjects/ScrollBar.cs +++ b/src/GraphicObjects/ScrollBar.cs @@ -35,7 +35,8 @@ namespace Crow Orientation _orientation; #region CTOR - public ScrollBar() : base() {} + public ScrollBar () : base(){} + public ScrollBar(Interface iface) : base(iface) {} #endregion [XmlAttributeAttribute()][DefaultValue(Orientation.Vertical)] diff --git a/src/GraphicObjects/Scroller.cs b/src/GraphicObjects/Scroller.cs index e38b2205..7f7bd5de 100644 --- a/src/GraphicObjects/Scroller.cs +++ b/src/GraphicObjects/Scroller.cs @@ -34,6 +34,11 @@ namespace Crow { public class Scroller : Container { + #region CTOR + public Scroller () : base(){} + public Scroller (Interface iface) : base(iface){} + #endregion + bool _verticalScrolling; bool _horizontalScrolling; bool _scrollbarVisible; @@ -122,9 +127,6 @@ namespace Crow } #endregion - public Scroller() - : base(){} - #region GraphicObject Overrides public override void OnLayoutChanges (LayoutingType layoutType) { diff --git a/src/GraphicObjects/ScrollingObject.cs b/src/GraphicObjects/ScrollingObject.cs index 09558984..3d8c942c 100644 --- a/src/GraphicObjects/ScrollingObject.cs +++ b/src/GraphicObjects/ScrollingObject.cs @@ -36,9 +36,8 @@ namespace Crow public class ScrollingObject : GraphicObject { #region CTOR - public ScrollingObject ():base() - { - } + public ScrollingObject ():base(){} + public ScrollingObject (Interface iface):base(iface){} #endregion int scrollX, scrollY, maxScrollX, maxScrollY, mouseWheelSpeed; diff --git a/src/GraphicObjects/ScrollingTextBox.cs b/src/GraphicObjects/ScrollingTextBox.cs index a435f9ee..0fb9a7b4 100644 --- a/src/GraphicObjects/ScrollingTextBox.cs +++ b/src/GraphicObjects/ScrollingTextBox.cs @@ -42,6 +42,9 @@ namespace Crow public class ScrollingTextBox : ScrollingObject { #region CTOR + public ScrollingTextBox (Interface iface):base(iface){ + KeyEventsOverrides = true; + } public ScrollingTextBox ():base() { KeyEventsOverrides = true; diff --git a/src/GraphicObjects/Slider.cs b/src/GraphicObjects/Slider.cs index 97c8b384..bf43f2fa 100644 --- a/src/GraphicObjects/Slider.cs +++ b/src/GraphicObjects/Slider.cs @@ -35,12 +35,13 @@ namespace Crow public class Slider : NumericControl { #region CTOR - public Slider() : base() + public Slider() : base(){} + public Slider(Interface iface) : base(iface) {} - public Slider(double minimum, double maximum, double step) - : base(minimum,maximum,step) - { - } +// public Slider(double minimum, double maximum, double step) +// : base(minimum,maximum,step) +// { +// } #endregion #region implemented abstract members of TemplatedControl diff --git a/src/GraphicObjects/Spinner.cs b/src/GraphicObjects/Spinner.cs index 1bf93a37..c29a2b27 100644 --- a/src/GraphicObjects/Spinner.cs +++ b/src/GraphicObjects/Spinner.cs @@ -31,13 +31,9 @@ namespace Crow public class Spinner : NumericControl { #region CTOR - public Spinner () : base() + public Spinner() : base(){} + public Spinner (Interface iface) : base(iface) { - } - public Spinner (double minimum, double maximum, double step) : - base (minimum, maximum, step) - { - } #endregion diff --git a/src/GraphicObjects/Splitter.cs b/src/GraphicObjects/Splitter.cs index 2f5dd15b..dab3937b 100644 --- a/src/GraphicObjects/Splitter.cs +++ b/src/GraphicObjects/Splitter.cs @@ -33,7 +33,8 @@ namespace Crow public class Splitter : GraphicObject { #region CTOR - public Splitter (): base(){} + public Splitter() : base(){} + public Splitter (Interface iface) : base(iface){} #endregion int thickness; diff --git a/src/GraphicObjects/TabItem.cs b/src/GraphicObjects/TabItem.cs index 7dac5472..2b578d18 100644 --- a/src/GraphicObjects/TabItem.cs +++ b/src/GraphicObjects/TabItem.cs @@ -34,7 +34,8 @@ namespace Crow public class TabItem : TemplatedContainer { #region CTOR - public TabItem () : base() {} + public TabItem() : base(){} + public TabItem (Interface iface) : base(iface){} #endregion #region Private fields diff --git a/src/GraphicObjects/TabView.cs b/src/GraphicObjects/TabView.cs index ecf38f10..62ada312 100644 --- a/src/GraphicObjects/TabView.cs +++ b/src/GraphicObjects/TabView.cs @@ -35,7 +35,8 @@ namespace Crow public class TabView : Group { #region CTOR - public TabView () : base() {} + public TabView() : base(){} + public TabView (Interface iface) : base(iface){} #endregion #region Private fields diff --git a/src/GraphicObjects/TemplatedContainer.cs b/src/GraphicObjects/TemplatedContainer.cs index b8a32167..c219f9b6 100644 --- a/src/GraphicObjects/TemplatedContainer.cs +++ b/src/GraphicObjects/TemplatedContainer.cs @@ -34,7 +34,8 @@ namespace Crow public abstract class TemplatedContainer : TemplatedControl { #region CTOR - public TemplatedContainer () : base(){} + public TemplatedContainer() : base(){} + public TemplatedContainer (Interface iface) : base(iface){} #endregion [XmlAttributeAttribute]public virtual GraphicObject Content{ get; set;} diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs index c4ef5788..6476265a 100644 --- a/src/GraphicObjects/TemplatedControl.cs +++ b/src/GraphicObjects/TemplatedControl.cs @@ -40,9 +40,8 @@ namespace Crow public abstract class TemplatedControl : PrivateContainer { #region CTOR - public TemplatedControl () : base() - { - } + public TemplatedControl() : base(){} + public TemplatedControl (Interface iface) : base(iface){} #endregion string _template; diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs index 3d5b7e83..dda03119 100644 --- a/src/GraphicObjects/TemplatedGroup.cs +++ b/src/GraphicObjects/TemplatedGroup.cs @@ -39,7 +39,8 @@ namespace Crow public abstract class TemplatedGroup : TemplatedControl { #region CTOR - public TemplatedGroup () : base(){} + public TemplatedGroup() : base(){} + public TemplatedGroup (Interface iface) : base(iface){} #endregion protected Group items; @@ -300,9 +301,7 @@ namespace Crow page = items; itemPerPage = int.MaxValue; } else if (typeof(GenericStack).IsAssignableFrom (items.GetType ())) { - GenericStack gs = new GenericStack (); - gs.CurrentInterface = items.CurrentInterface; - gs.Initialize (); + GenericStack gs = new GenericStack (items.CurrentInterface); gs.Orientation = (items as GenericStack).Orientation; gs.Width = items.Width; gs.Height = items.Height; diff --git a/src/GraphicObjects/TextBox.cs b/src/GraphicObjects/TextBox.cs index 0cbee9f8..2438c65a 100644 --- a/src/GraphicObjects/TextBox.cs +++ b/src/GraphicObjects/TextBox.cs @@ -34,13 +34,14 @@ namespace Crow public class TextBox : Label { #region CTOR - public TextBox() + public TextBox() : base(){} + public TextBox(Interface iface) : base(iface) { } - public TextBox(string _initialValue) - : base(_initialValue) - { - - } +// public TextBox(string _initialValue) +// : base(_initialValue) +// { +// +// } #endregion #region GraphicObject overrides diff --git a/src/GraphicObjects/TextRun.cs b/src/GraphicObjects/TextRun.cs index a312ca1e..55ac7f33 100644 --- a/src/GraphicObjects/TextRun.cs +++ b/src/GraphicObjects/TextRun.cs @@ -39,15 +39,8 @@ namespace Crow public class TextRun : GraphicObject { #region CTOR - public TextRun () - { - - } - public TextRun (string _text) - : base () - { - Text = _text; - } + public TextRun () : base(){} + public TextRun (Interface iface) : base (iface){} #endregion //TODO:change protected to private diff --git a/src/GraphicObjects/TreeView.cs b/src/GraphicObjects/TreeView.cs index 6549f148..80c3385f 100644 --- a/src/GraphicObjects/TreeView.cs +++ b/src/GraphicObjects/TreeView.cs @@ -39,7 +39,8 @@ namespace Crow bool isRoot; #region CTOR - public TreeView () : base() + public TreeView() : base(){} + public TreeView (Interface iface) : base(iface) { } #endregion diff --git a/src/GraphicObjects/VerticalStack.cs b/src/GraphicObjects/VerticalStack.cs index d5d0236b..23271624 100644 --- a/src/GraphicObjects/VerticalStack.cs +++ b/src/GraphicObjects/VerticalStack.cs @@ -33,8 +33,8 @@ namespace Crow { public class VerticalStack : GenericStack { - public VerticalStack() - : base() + public VerticalStack() : base(){} + public VerticalStack(Interface iface) : base(iface) { } diff --git a/src/GraphicObjects/Window.cs b/src/GraphicObjects/Window.cs index 7ea4db75..d4087d02 100644 --- a/src/GraphicObjects/Window.cs +++ b/src/GraphicObjects/Window.cs @@ -66,9 +66,8 @@ namespace Crow #endregion #region CTOR - public Window () : base() { - - } + public Window() : base(){} + public Window (Interface iface) : base(iface){} #endregion #region TemplatedContainer overrides diff --git a/src/GraphicObjects/Wrapper.cs b/src/GraphicObjects/Wrapper.cs index 8b282ebb..81dce154 100644 --- a/src/GraphicObjects/Wrapper.cs +++ b/src/GraphicObjects/Wrapper.cs @@ -30,8 +30,10 @@ namespace Crow { public class Wrapper : GenericStack { - public Wrapper () : base() - {} + #region CTOR + public Wrapper() : base(){} + public Wrapper (Interface iface) : base(iface){} + #endregion #region Group Overrides public override void ChildrenLayoutingConstraints (ref LayoutingType layoutType) diff --git a/src/IML/Context.cs b/src/IML/Context.cs index fb103580..7c34745d 100644 --- a/src/IML/Context.cs +++ b/src/IML/Context.cs @@ -68,8 +68,13 @@ namespace Crow.IML il.DeclareLocal (typeof (GraphicObject)); il.Emit (OpCodes.Nop); - //set local GraphicObject to root object - il.Emit (OpCodes.Newobj, rootType.GetConstructors () [0]); + //set local GraphicObject to root object + ConstructorInfo ci = rootType.GetConstructor ( + BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, + null, Type.EmptyTypes, null); + if (ci == null) + throw new Exception ("No default parameterless constructor found in " + rootType.Name); + il.Emit (OpCodes.Newobj, ci); il.Emit (OpCodes.Stloc_0); CompilerServices.emitSetCurInterface (il); } diff --git a/src/Instantiator.cs b/src/Instantiator.cs index 3520ce83..42c5de96 100644 --- a/src/Instantiator.cs +++ b/src/Instantiator.cs @@ -161,6 +161,12 @@ namespace Crow //emitCheckAndBindValueChanged (ctx); } + /// + /// process template and item template definition prior to + /// other attributes or childs processing + /// + /// Loading Context + /// xml fragment void emitTemplateLoad (Context ctx, string tmpXml) { //if its a template, first read template elements using (XmlTextReader reader = new XmlTextReader (tmpXml, XmlNodeType.Element, null)) { @@ -242,11 +248,17 @@ namespace Crow } } } + /// + /// process styling, attributes and children loading. + /// + /// parsing context + /// xml fragment void emitGOLoad (Context ctx, string tmpXml) { using (XmlTextReader reader = new XmlTextReader (tmpXml, XmlNodeType.Element, null)) { reader.Read (); #region Styling and default values loading + //first check for Style attribute then trigger default value loading if (reader.HasAttributes) { string style = reader.GetAttribute ("Style"); if (!string.IsNullOrEmpty (style)) @@ -328,8 +340,12 @@ namespace Crow Type t = tryGetGOType (reader.Name); if (t == null) throw new Exception (reader.Name + " type not found"); - - ctx.il.Emit (OpCodes.Newobj, t.GetConstructors () [0]);//TODO:search parameterless ctor + ConstructorInfo ci = t.GetConstructor ( + BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, + null, Type.EmptyTypes, null); + if (ci == null) + throw new Exception ("No default parameterless constructor found in " + t.Name); + ctx.il.Emit (OpCodes.Newobj, ci); ctx.il.Emit (OpCodes.Stloc_0);//child is now loc_0 CompilerServices.emitSetCurInterface (ctx.il); -- 2.47.3