From: Jean-Philippe Bruyère Date: Sun, 13 Oct 2019 23:00:12 +0000 (+0200) Subject: debug X-Git-Tag: v0.8.7~3 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=c2c5d42ac0d23e0b9a5a885ace7de2713bbe40ff;p=jp%2Fcrow.git debug --- diff --git a/Crow/Crow.csproj b/Crow/Crow.csproj index 3519cc7f..e2bbd3f7 100644 --- a/Crow/Crow.csproj +++ b/Crow/Crow.csproj @@ -25,7 +25,7 @@ full - _DEBUG_DISPOSE;TRACE;_DEBUG_BINDING;DESIGN_MODE;_DEBUG_CLIP_RECTANGLE;DEBUG_FOCUS;_DEBUG_DRAGNDROP;NET471;NET461;NETFRAMEWORK;NET472;DEBUG;NETSTANDARD;NETSTANDARD2_0 + _DEBUG_DISPOSE;TRACE;_DEBUG_BINDING;DESIGN_MODE;_DEBUG_CLIP_RECTANGLE;_DEBUG_FOCUS;_DEBUG_DRAGNDROP;NET471;NET461;NETFRAMEWORK;NET472;DEBUG;NETSTANDARD;NETSTANDARD2_0 true diff --git a/Crow/src/CompilerServices/CompilerServices.cs b/Crow/src/CompilerServices/CompilerServices.cs index 88498951..7e368a08 100644 --- a/Crow/src/CompilerServices/CompilerServices.cs +++ b/Crow/src/CompilerServices/CompilerServices.cs @@ -269,6 +269,8 @@ namespace Crow.IML name = "ToInt16"; else if (targetType == typeof (int)) name = "ToInt32"; + else if (targetType == typeof (uint)) + name = "ToUInt32"; else if (targetType == typeof (long)) name = "ToInt64"; else if (targetType == typeof (double)) diff --git a/Crow/src/Instantiator.cs b/Crow/src/Instantiator.cs index 1dcb989a..1b37a7ae 100644 --- a/Crow/src/Instantiator.cs +++ b/Crow/src/Instantiator.cs @@ -1318,9 +1318,10 @@ namespace Crow.IML { { if (mi.MemberType == MemberTypes.Field) il.Emit (OpCodes.Stfld, mi as FieldInfo); - else if (mi.MemberType == MemberTypes.Property) - il.Emit (OpCodes.Callvirt, (mi as PropertyInfo).GetSetMethod ()); - else + else if (mi.MemberType == MemberTypes.Property) { + MethodInfo mt = (mi as PropertyInfo).GetSetMethod (); + il.Emit (mt.IsVirtual?OpCodes.Callvirt:OpCodes.Call, mt); + } else throw new NotImplementedException (); } /// @@ -1356,6 +1357,9 @@ namespace Crow.IML { typeof (void), CompilerServices.argsBoundValueChange, true); ILGenerator il = dm.GetILGenerator (64); + + Stack locals = new Stack (); + System.Reflection.Emit.Label endMethod = il.DefineLabel (); il.Emit (OpCodes.Nop); @@ -1377,13 +1381,17 @@ namespace Crow.IML { il.Emit (OpCodes.Ldflda, miDests [i] as FieldInfo); else if (miDests [i].MemberType == MemberTypes.Property) { PropertyInfo pi = miDests [i] as PropertyInfo; + MethodInfo mi_g = pi.GetGetMethod (); if (pi.PropertyType.IsValueType) { il.Emit (OpCodes.Dup);//dup parent for calling property set afterward - il.Emit (OpCodes.Callvirt, pi.GetGetMethod ()); - il.Emit (OpCodes.Box, pi.PropertyType); - il.Emit (OpCodes.Dup);//dup boxed valueType, should unbox before setting parent - } else - il.Emit (OpCodes.Callvirt, pi.GetGetMethod ()); + il.Emit (mi_g.IsVirtual ? OpCodes.Callvirt : OpCodes.Call, mi_g); + LocalBuilder lb = il.DeclareLocal (pi.PropertyType); + il.Emit (OpCodes.Stloc, lb); + il.Emit (OpCodes.Ldloca, lb); + locals.Push (lb); + } else { + il.Emit (mi_g.IsVirtual ? OpCodes.Callvirt : OpCodes.Call, mi_g); + } } else throw new NotImplementedException (); } @@ -1402,8 +1410,9 @@ namespace Crow.IML { PropertyInfo pi = miDests [i] as PropertyInfo; if (!pi.PropertyType.IsValueType) continue; - il.Emit (OpCodes.Ldobj, pi.PropertyType); - il.Emit (OpCodes.Callvirt, pi.GetSetMethod ());//updating parent + MethodInfo mi_s = pi.GetSetMethod (); + il.Emit (OpCodes.Ldloc, locals.Pop()); + il.Emit (mi_s.IsVirtual ? OpCodes.Callvirt : OpCodes.Call, mi_s); } il.MarkLabel (endMethod); il.Emit (OpCodes.Ret); diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs index cb836a9f..5488b559 100644 --- a/Crow/src/Interface.cs +++ b/Crow/src/Interface.cs @@ -134,8 +134,8 @@ namespace Crow public void Init () { loadStyling (); -// initTooltip (); -// initContextMenus (); + initTooltip (); + //initContextMenus (); Startup (); } @@ -210,15 +210,13 @@ namespace Crow }*/ #region Static and constants - /// - /// Crow configuration root path - /// + /// Crow configuration root path public static string CROW_CONFIG_ROOT; /// If true, mouse focus is given when mouse is over control public static bool FOCUS_ON_HOVER = true; /// Threshold to catch borders for sizing public static int BorderThreshold = 5; - /// delay before tooltip appear + /// delay before tooltip appears public static int TOOLTIP_DELAY = 500; /// Double click threshold in milisecond public static int DOUBLECLICK_TRESHOLD = 240;//max duration between two mouse_down evt for a dbl clk in milisec. @@ -340,7 +338,7 @@ namespace Crow #endregion #region Default values and Style loading - /// Default values of properties from GraphicObjects are retrieve from XML Attributes. + /// Default values of properties from Widgets are retrieve from XML Attributes. /// The reflexion process used to retrieve those values being very slow, it is compiled in MSIL /// and injected as a dynamic method referenced in the DefaultValuesLoader Dictionnary. /// The compilation is done on the first object instancing, and is also done for custom widgets @@ -368,7 +366,6 @@ namespace Crow using (Stream stream = assembly.GetManifestResourceStream (s)) { new StyleReader (this.Styling, stream, s); } - } } #endregion @@ -490,11 +487,11 @@ namespace Crow /// path of the iml file to load public virtual Widget CreateInstance (string path) { - try { + //try { return GetInstantiator (path).CreateInstance (); - } catch (Exception ex) { - throw new Exception ("Error loading <" + path + ">:", ex); - } + //} catch (Exception ex) { + // throw new Exception ("Error loading <" + path + ">:", ex); + //} } /// /// Create an instance of a GraphicObject linked to this interface but not added to the GraphicTree diff --git a/Crow/src/ItemTemplate.cs b/Crow/src/ItemTemplate.cs index e4615b7a..3b6cf0b2 100644 --- a/Crow/src/ItemTemplate.cs +++ b/Crow/src/ItemTemplate.cs @@ -114,7 +114,7 @@ namespace Crow /// /// Initializes a new instance of the class by parsing the IML fragment passed as arg. /// - /// IML fragment to parse + /// IML fragment to parse /// type this item will be choosen for, or member of the data item /// for hierarchical data, method to call for children fetching public ItemTemplate (Interface _iface, Stream ImlFragment, string _dataTest, string _dataType, string _fetchDataMethod) @@ -127,7 +127,7 @@ namespace Crow /// /// Initializes a new instance of the class using the opened XmlReader in args. /// - /// XML reader positionned before or at the root node + /// XML reader positionned before or at the root node /// type this item will be choosen for, or member of the data item /// for hierarchical data, method to call for children fetching public ItemTemplate (Interface _iface, XmlReader reader, string _dataTest = "TypeOf" , string _dataType = null, string _fetchDataMethod = null) @@ -272,9 +272,6 @@ namespace Crow else il.Emit (OpCodes.Callvirt, miGetDatas); } - - - } } diff --git a/Crow/src/Rectangle.cs b/Crow/src/Rectangle.cs index afbb192d..a0e5ccf8 100644 --- a/Crow/src/Rectangle.cs +++ b/Crow/src/Rectangle.cs @@ -41,6 +41,8 @@ namespace Crow { Height = value.Height; } } + [XmlIgnore] + public SizeD SizeD => new SizeD (Width, Height); [XmlIgnore]public Point Position{ get => new Point (X, Y); set { diff --git a/Crow/src/Widgets/EnumSelector.cs b/Crow/src/Widgets/EnumSelector.cs index 576eb953..70985f2a 100644 --- a/Crow/src/Widgets/EnumSelector.cs +++ b/Crow/src/Widgets/EnumSelector.cs @@ -53,7 +53,6 @@ namespace Crow foreach (string en in enumType.GetEnumNames ()) { RadioButton rb = new RadioButton (IFace); rb.Caption = en; - rb.Fit = true; rb.LogicalParent = this; if (enumValue.ToString () == en) rb.IsChecked = true; diff --git a/Crow/src/Widgets/Slider.cs b/Crow/src/Widgets/Slider.cs index e4942b2b..acceced0 100644 --- a/Crow/src/Widgets/Slider.cs +++ b/Crow/src/Widgets/Slider.cs @@ -83,7 +83,7 @@ namespace Crow public virtual int CursorSize { get { return _cursorSize; } set { - if (_cursorSize == value || value < 8) + if (_cursorSize == value || value < 4) return; _cursorSize = value; RegisterForGraphicUpdate (); diff --git a/Crow/src/Widgets/Spinner.cs b/Crow/src/Widgets/Spinner.cs index 8a3bcd62..d9fd51f6 100644 --- a/Crow/src/Widgets/Spinner.cs +++ b/Crow/src/Widgets/Spinner.cs @@ -17,6 +17,11 @@ namespace Crow } #endregion + public override void onMouseClick (object sender, MouseButtonEventArgs e) + { + e.Handled = true; + base.onMouseClick (sender, e); + } void onUp (object sender, MouseButtonEventArgs e) { Value += this.SmallIncrement; diff --git a/CrowIDE/src/DesignInterface.cs b/CrowIDE/src/DesignInterface.cs index 08c27448..5c9bd7f5 100644 --- a/CrowIDE/src/DesignInterface.cs +++ b/CrowIDE/src/DesignInterface.cs @@ -1,28 +1,7 @@ -// -// DesignInterface.cs +// Copyright (c) 2013-2019 Bruyère Jean-Philippe // -// 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. +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + using System; using Crow; using System.Globalization;