]> O.S.I.I.S - jp/crow.git/commitdiff
wip
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 8 Feb 2020 06:33:36 +0000 (07:33 +0100)
committerj-p <jp_bruyere@hotmail.com>
Sat, 9 May 2020 22:50:02 +0000 (00:50 +0200)
Crow/Templates/ComboBox.template
Crow/Templates/DefaultItem.template
Crow/src/Configuration.cs
Crow/src/ValueChangeEventArgs.cs
Crow/src/Widgets/ComboBox.cs
Crow/src/Widgets/Popper.cs
Crow/src/Widgets/TabItem.cs
Crow/src/Widgets/TemplatedGroup.cs
Samples/BasicTests/BasicTests.cs
Samples/BasicTests/BasicTests.csproj
Samples/common/ui/Interfaces/TemplatedGroup/3.crow [new file with mode: 0644]

index f08a8393b9b3d79c08affde90fc7de06d14b52c5..5b43b99c0e0490c7ec998e99824dcbc1f59a0487 100644 (file)
@@ -16,8 +16,8 @@
                        </Template>
                </CheckBox>
        </Template>
-       <Border Background="DimGrey" BorderWidth="1" Margin="1"
-               MinimumSize="{../../MinimumPopupSize}" Fit="true">
+       <Border Background="DimGrey" BorderWidth="1" Margin="1" Height="Fit" Width="1"
+               MinimumSize="{../../MinimumPopupSize}" >
                <Scroller Name="scroller1" Margin="2" 
                        MaximumSize="0,200"
                        HorizontalAlignment="Left">
index fc13ab4d995525e6a9ea53a7ce7ac901477ddffd..38840830fa68feeb6b6cf65f0da98bddbc656d4f 100644 (file)
@@ -1,8 +1,8 @@
 <?xml version="1.0"?>
-<Container Fit="true" Margin="0" Focusable="true"
+<Container Height="Fit" Margin="0" Focusable="true"
                HorizontalAlignment="Left"
                MouseEnter="{Background=SteelBlue}"
                MouseLeave="{Background=Transparent}">
-       <Label Text="{}"/>
+       <Label Text="{}" HorizontalAlignment="Left" />
 </Container>
 
index b8112be4bc178658daa02a276f6def6adff6a46d..aa938b7e1ceca623481e37b7fa4eeb2f8746a9f8 100644 (file)
@@ -1,28 +1,6 @@
-//
-// Configuration.cs
+// Copyright (c) 2013-2020  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
 //
-// 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.
+// 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;
index e8293de8c99a3cd40f1013750f4fc062f40fa495..854e2cd3de99d13d4bb71330ef1121840f04900e 100644 (file)
@@ -1,39 +1,26 @@
-//
-// ValueChangeEventArgs.cs
+// Copyright (c) 2013-2020  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
 //
-// 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.
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 
 using System;
 
 namespace Crow
 {
+       /// <summary>
+       /// Arguments for the ValueChange event used for Binding
+       /// </summary>
        public class ValueChangeEventArgs: EventArgs
        {
+               /// <summary>The name of the member whose value has changed</summary>
                public string MemberName;
+               /// <summary>New value for that member</summary>
                public object NewValue;
 
-
+               /// <summary>
+               /// Initializes a new instance of the <see cref="T:Crow.ValueChangeEventArgs"/> class.
+               /// </summary>
+               /// <param name="_memberName">Member name.</param>
+               /// <param name="_newValue">New value.</param>
                public ValueChangeEventArgs (string _memberName, object _newValue) : base()
                {
                        MemberName = _memberName;
index 61227055c6c1866f2e1fb90b437a178132edb59b..08e844c414f64a37217d5a272c1a623577956de4 100644 (file)
@@ -1,28 +1,6 @@
-//
-// ComboBox.cs
+// Copyright (c) 2013-2020  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
 //
-// 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.
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 
 using System;
 using System.Xml.Serialization;
index b6acabd2a42b8f615a880cb845c9728fbae4ee20..78d35d8f119ac6d367510009069fae6c6d595e03 100644 (file)
@@ -1,28 +1,6 @@
-//
-// Popper.cs
+// Copyright (c) 2013-2020  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
 //
-// 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.
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 
 using System;
 using System.Xml.Serialization;
index 7c20a33e48f41c22067f2c1abcc1346a1cbc9b3c..7801a06660414085e8767fcde4fcc21e2989c2b3 100644 (file)
@@ -1,33 +1,9 @@
-//
-// TabItem.cs
+// Copyright (c) 2013-2020  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
 //
-// 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.
+// 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);
index a4a955ffd0bb1622cd075632fcc3c6962aa3076e..54e3e760640f955f47e223797dfa23754b3734fa 100644 (file)
@@ -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;
index 059bf8521778c0644a1970caa76966de174b5ae3..54bb82158436391368a0d66e8770250f2e13f7fb 100644 (file)
@@ -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<String> List2 = new List<string> (new string []
+               public IEnumerable<String> List2 = new List<string> (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<String> TestList2 {
+               public IEnumerable<String> 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<TestClass> List3 = new List<TestClass> (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<string> TestList3Props1 => List3.Select (sc => sc.Prop1).ToList();
+               public IEnumerable<TestClass> 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<Color> testList = Color.ColorDic.Values//.OrderBy(c=>c.Hue)
                                                                                                        //.ThenBy(c=>c.Value).ThenBy(c=>c.Saturation)
                        .ToList ();
index e1208a4271b87a9bbc0365866837065cfeb7aaeb..813b9b660d97014b1f2bb9e249c753d68f05dcfe 100644 (file)
@@ -29,5 +29,5 @@
                        <LogicalName>ui.%(Filename)%(Extension)</LogicalName>
                        <Link>Templates\%(Filename)%(Extension)</Link>
                </EmbeddedResource>
-       </ItemGroup>
+       </ItemGroup>    
 </Project>
\ 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 (file)
index 0000000..c2192a9
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<VerticalStack Width="60%" Height="60%" Spacing="10" Background="DimGrey" Margin="20" ClipToClientRect="false" CornerRadius="10">
+       <Label Background="Jet" Text="{TestList3SelProp1}"/>    
+       <ComboBox Data="{TestList3Props1}">             
+       </ComboBox>
+       
+</VerticalStack>
\ No newline at end of file