From: Jean-Philippe Bruyère Date: Sat, 8 Feb 2020 06:33:36 +0000 (+0100) Subject: wip X-Git-Tag: v0.9.5-beta~132 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=2774a37e0a20412971e17571e152768b299318db;p=jp%2Fcrow.git wip --- diff --git a/Crow/Templates/ComboBox.template b/Crow/Templates/ComboBox.template index f08a8393..5b43b99c 100644 --- a/Crow/Templates/ComboBox.template +++ b/Crow/Templates/ComboBox.template @@ -16,8 +16,8 @@ - + diff --git a/Crow/Templates/DefaultItem.template b/Crow/Templates/DefaultItem.template index fc13ab4d..38840830 100644 --- a/Crow/Templates/DefaultItem.template +++ b/Crow/Templates/DefaultItem.template @@ -1,8 +1,8 @@  - - diff --git a/Crow/src/Configuration.cs b/Crow/src/Configuration.cs index b8112be4..aa938b7e 100644 --- a/Crow/src/Configuration.cs +++ b/Crow/src/Configuration.cs @@ -1,28 +1,6 @@ -// -// Configuration.cs +// Copyright (c) 2013-2020 Jean-Philippe Bruyère // -// 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 System.Reflection; @@ -107,10 +85,7 @@ namespace Crow static Configuration () { string configRoot = - Path.Combine( - - Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), - ".config"); + Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.UserProfile), ".config"); Assembly a = Assembly.GetEntryAssembly (); string appName = a.GetName().Name; diff --git a/Crow/src/ValueChangeEventArgs.cs b/Crow/src/ValueChangeEventArgs.cs index e8293de8..854e2cd3 100644 --- a/Crow/src/ValueChangeEventArgs.cs +++ b/Crow/src/ValueChangeEventArgs.cs @@ -1,39 +1,26 @@ -// -// ValueChangeEventArgs.cs +// Copyright (c) 2013-2020 Jean-Philippe Bruyère // -// 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; namespace Crow { + /// + /// Arguments for the ValueChange event used for Binding + /// public class ValueChangeEventArgs: EventArgs { + /// The name of the member whose value has changed public string MemberName; + /// New value for that member public object NewValue; - + /// + /// Initializes a new instance of the class. + /// + /// Member name. + /// New value. public ValueChangeEventArgs (string _memberName, object _newValue) : base() { MemberName = _memberName; diff --git a/Crow/src/Widgets/ComboBox.cs b/Crow/src/Widgets/ComboBox.cs index 61227055..08e844c4 100644 --- a/Crow/src/Widgets/ComboBox.cs +++ b/Crow/src/Widgets/ComboBox.cs @@ -1,28 +1,6 @@ -// -// ComboBox.cs +// Copyright (c) 2013-2020 Jean-Philippe Bruyère // -// 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 System.Xml.Serialization; diff --git a/Crow/src/Widgets/Popper.cs b/Crow/src/Widgets/Popper.cs index b6acabd2..78d35d8f 100644 --- a/Crow/src/Widgets/Popper.cs +++ b/Crow/src/Widgets/Popper.cs @@ -1,28 +1,6 @@ -// -// Popper.cs +// Copyright (c) 2013-2020 Jean-Philippe Bruyère // -// 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 System.Xml.Serialization; diff --git a/Crow/src/Widgets/TabItem.cs b/Crow/src/Widgets/TabItem.cs index 7c20a33e..7801a066 100644 --- a/Crow/src/Widgets/TabItem.cs +++ b/Crow/src/Widgets/TabItem.cs @@ -1,33 +1,9 @@ -// -// TabItem.cs +// Copyright (c) 2013-2020 Jean-Philippe Bruyère // -// 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 System.Xml.Serialization; using System.ComponentModel; -using System.Diagnostics; using Crow.Cairo; using System.Linq; @@ -146,8 +122,16 @@ namespace Crow { gr.Save (); + parentRWLock.EnterReadLock (); + TabView tv = Parent as TabView; + //TODO:this appens in designView + if (tv == null) { + parentRWLock.ExitReadLock (); + return; + } + Rectangle r = TabTitle.Slot; r.Width = TabWidth; @@ -164,6 +148,7 @@ namespace Crow r.Right + tv.RightSlope, r.Bottom-0.5); gr.LineTo (Slot.Width-0.5, r.Bottom-0.5); + parentRWLock.ExitReadLock (); gr.LineTo (Slot.Width-0.5, Slot.Height-0.5); gr.LineTo (0.5, Slot.Height-0.5); diff --git a/Crow/src/Widgets/TemplatedGroup.cs b/Crow/src/Widgets/TemplatedGroup.cs index a4a955ff..54e3e760 100644 --- a/Crow/src/Widgets/TemplatedGroup.cs +++ b/Crow/src/Widgets/TemplatedGroup.cs @@ -158,7 +158,7 @@ namespace Crow { } } [XmlIgnore]public virtual object SelectedItem{ - get { return data == null ? null : _selectedIndex < 0 ? data.GetDefaultValue() : ((IList)data)?[_selectedIndex]; } + get { return data == null ? null : _selectedIndex < 0 ? data.GetDefaultValue() : data is IList tmp ? tmp[_selectedIndex] : null; } set { if (data == null) { SelectedIndex = -1; diff --git a/Samples/BasicTests/BasicTests.cs b/Samples/BasicTests/BasicTests.cs index 059bf852..54bb8215 100644 --- a/Samples/BasicTests/BasicTests.cs +++ b/Samples/BasicTests/BasicTests.cs @@ -30,7 +30,7 @@ namespace tests //testFiles = new string [] { @"Interfaces/Experimental/testDock.crow" }; //testFiles = new string [] { @"Interfaces/Divers/welcome.crow" }; - testFiles = new string [] { @"Interfaces/Group/5.crow" }; + testFiles = new string [] { @"Interfaces/TemplatedGroup/3.crow" }; //testFiles = new string [] { @"Interfaces/Divers/perfMeasures.crow" }; //testFiles = new string [] { @"Interfaces/Divers/colorPicker.crow" }; testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/GraphicObject", "*.crow")).ToArray (); @@ -138,31 +138,78 @@ namespace tests return; NotifyValueChanged ("alignment", Enum.Parse (typeof (Alignment), rb.Caption)); } - public IList List2 = new List (new string [] + public IEnumerable List2 = new List (new string [] { "string1", "string2", "string3", -// "string4", -// "string5", -// "string6", -// "string7", -// "string8", -// "string8", -// "string8", -// "string8", -// "string8", -// "string8", -// "string9" + "string4", + "string5", + "string6", + "string7", + "string8", + "string8", + "string8", + "string8", + "string8", + "string8", + "string9" } ); - public IList TestList2 { + public IEnumerable TestList2 { set { List2 = value; NotifyValueChanged ("TestList2", testList); } get { return List2; } } + public class TestClass + { + public string Prop1 { get; set; } + public string Prop2 { get; set; } + + public override string ToString () + => $"{Prop1}, {Prop2}"; + + } + public IEnumerable List3 = new List (new TestClass [] + { + new TestClass { Prop1 = "string1", Prop2="prop2-1" }, + new TestClass { Prop1 = "string2", Prop2="prop2-2" }, + new TestClass { Prop1 = "string3", Prop2="prop2-3" }, + } + ); + public IEnumerable TestList3Props1 => List3.Select (sc => sc.Prop1).ToList(); + public IEnumerable TestList3 { + set { + List3 = value; + NotifyValueChanged ("TestList3", testList); + } + get { return List3; } + } + string prop1; + public string TestList3SelProp1 { + get => prop1; + set { + if (prop1 == value) + return; + prop1 = value; + + NotifyValueChanged ("TestList3SelProp1", prop1); + } + } + + string selString; + public string TestList2SelectedString { + get => selString; + set { + if (selString == value) + return; + selString = value; + NotifyValueChanged ("TestList2SelectedString", selString); + } + } + List testList = Color.ColorDic.Values//.OrderBy(c=>c.Hue) //.ThenBy(c=>c.Value).ThenBy(c=>c.Saturation) .ToList (); diff --git a/Samples/BasicTests/BasicTests.csproj b/Samples/BasicTests/BasicTests.csproj index e1208a42..813b9b66 100644 --- a/Samples/BasicTests/BasicTests.csproj +++ b/Samples/BasicTests/BasicTests.csproj @@ -29,5 +29,5 @@ ui.%(Filename)%(Extension) Templates\%(Filename)%(Extension) - + \ No newline at end of file diff --git a/Samples/common/ui/Interfaces/TemplatedGroup/3.crow b/Samples/common/ui/Interfaces/TemplatedGroup/3.crow new file mode 100644 index 00000000..c2192a9b --- /dev/null +++ b/Samples/common/ui/Interfaces/TemplatedGroup/3.crow @@ -0,0 +1,7 @@ + + + \ No newline at end of file