From 51a35395e90543c64125aee016681a8db3c3b407 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Sun, 12 Jan 2020 03:54:39 +0100 Subject: [PATCH] wip 0.8.7 --- Crow.sln | 14 ++-- Crow/Crow.csproj | 5 +- Crow/Templates/Button.template | 4 +- Crow/Templates/ListBox.template | 2 +- Crow/Templates/ToolWindow.template | 2 +- Crow/src/IListChanged.cs | 7 +- Crow/src/Instantiator.cs | 63 +++++++--------- Crow/src/Interface.cs | 2 +- Crow/src/ItemTemplate.cs | 26 +------ Crow/src/ObservableList.cs | 108 +++++++++++++++++++-------- Crow/src/Widgets/Image.cs | 26 +------ Crow/src/Widgets/ListBox.cs | 2 + Crow/src/Widgets/TabView.cs | 2 +- Crow/src/Widgets/Table.cs | 57 ++++++++++++++ Crow/src/Widgets/TemplatedGroup.cs | 49 ++++++++++-- Crow/src/Widgets/Window.cs | 26 +------ CrowIDE/CrowIDE.csproj | 1 + CrowIDE/src/CrowIDE.cs | 12 +-- CrowIDE/src/Workspace.cs | 10 +-- CrowIDE/ui/Options.crow | 11 +-- Samples/HelloWorld/HelloWorld.csproj | 3 +- Samples/ShowCase/ShowCase.csproj | 2 +- 22 files changed, 249 insertions(+), 185 deletions(-) create mode 100644 Crow/src/Widgets/Table.cs diff --git a/Crow.sln b/Crow.sln index 6481a424..b8997182 100644 --- a/Crow.sln +++ b/Crow.sln @@ -9,10 +9,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "Samples\Hello EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShowCase", "Samples\ShowCase\ShowCase.csproj", "{56329D48-D382-4850-93DE-59C453894E8A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrowIDE", "CrowIDE\CrowIDE.csproj", "{C40A3F21-0558-4265-9251-718C1564D10A}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlLib", "Samples\ControlLib\ControlLib.csproj", "{91F1CE07-EECE-4F1D-A3EE-7239B563654A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrowIDE", "CrowIDE\CrowIDE.csproj", "{1E5C7065-28F9-4A1A-A2FB-DB5E03A63CB3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -25,20 +25,16 @@ Global {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Any CPU.Build.0 = Release|Any CPU {F535A8AB-CD93-49AB-B1B0-FFF9AE51ED6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F535A8AB-CD93-49AB-B1B0-FFF9AE51ED6A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F535A8AB-CD93-49AB-B1B0-FFF9AE51ED6A}.Release|Any CPU.Build.0 = Release|Any CPU {F535A8AB-CD93-49AB-B1B0-FFF9AE51ED6A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F535A8AB-CD93-49AB-B1B0-FFF9AE51ED6A}.Release|Any CPU.Build.0 = Release|Any CPU {56329D48-D382-4850-93DE-59C453894E8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {56329D48-D382-4850-93DE-59C453894E8A}.Release|Any CPU.ActiveCfg = Release|Any CPU {56329D48-D382-4850-93DE-59C453894E8A}.Release|Any CPU.Build.0 = Release|Any CPU {56329D48-D382-4850-93DE-59C453894E8A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C40A3F21-0558-4265-9251-718C1564D10A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C40A3F21-0558-4265-9251-718C1564D10A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C40A3F21-0558-4265-9251-718C1564D10A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C40A3F21-0558-4265-9251-718C1564D10A}.Release|Any CPU.Build.0 = Release|Any CPU {91F1CE07-EECE-4F1D-A3EE-7239B563654A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {91F1CE07-EECE-4F1D-A3EE-7239B563654A}.Debug|Any CPU.Build.0 = Debug|Any CPU {91F1CE07-EECE-4F1D-A3EE-7239B563654A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {91F1CE07-EECE-4F1D-A3EE-7239B563654A}.Release|Any CPU.Build.0 = Release|Any CPU + {1E5C7065-28F9-4A1A-A2FB-DB5E03A63CB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1E5C7065-28F9-4A1A-A2FB-DB5E03A63CB3}.Release|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution Policies = $0 diff --git a/Crow/Crow.csproj b/Crow/Crow.csproj index e2bbd3f7..7f92e6e7 100644 --- a/Crow/Crow.csproj +++ b/Crow/Crow.csproj @@ -1,11 +1,11 @@ - netstandard2.0 + netstandard2.0 Crow - 0.8.6 + 0.8.7 C.R.O.W. is a widget toolkit and rendering engine entirely developed in C# with templates, styles, compositing, and bindings. false false @@ -22,6 +22,7 @@ Copyright 2013-2019 DESIGN_MODE + 0.8.0 full diff --git a/Crow/Templates/Button.template b/Crow/Templates/Button.template index d2f6c602..14b14a2f 100755 --- a/Crow/Templates/Button.template +++ b/Crow/Templates/Button.template @@ -1,8 +1,8 @@ diff --git a/Crow/Templates/ListBox.template b/Crow/Templates/ListBox.template index a1aea50f..eb162ba7 100755 --- a/Crow/Templates/ListBox.template +++ b/Crow/Templates/ListBox.template @@ -1,5 +1,5 @@ - + diff --git a/Crow/Templates/ToolWindow.template b/Crow/Templates/ToolWindow.template index e5c9fe74..bad53fea 100755 --- a/Crow/Templates/ToolWindow.template +++ b/Crow/Templates/ToolWindow.template @@ -6,7 +6,7 @@ - diff --git a/Crow/src/IListChanged.cs b/Crow/src/IListChanged.cs index b2b23375..fd6e60a7 100644 --- a/Crow/src/IListChanged.cs +++ b/Crow/src/IListChanged.cs @@ -37,7 +37,12 @@ namespace Crow } public interface IObservableList { event EventHandler ListAdd; - event EventHandler ListRemove; + event EventHandler ListRemove; + event EventHandler ListEdit; + + void Insert (); + void Remove (); + void RaiseEdit (); } } diff --git a/Crow/src/Instantiator.cs b/Crow/src/Instantiator.cs index bf9ad37b..1952006c 100644 --- a/Crow/src/Instantiator.cs +++ b/Crow/src/Instantiator.cs @@ -1,28 +1,6 @@ -// -// Instantiator.cs +// Copyright (c) 2013-2019 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.Collections.Generic; @@ -256,7 +234,6 @@ namespace Crow.IML { emitGOLoad (ctx, tmpXml); ctx.curLine = curLine; - //emitCheckAndBindValueChanged (ctx); } /// /// Parses the item template tag. @@ -1141,22 +1118,39 @@ namespace Crow.IML { Debug.WriteLine("\tDataSource Changed: " + dm.Name); #endif } + /// /// create the valuechanged handler, the datasourcechanged handler and emit event handling /// - void emitDataSourceBindings(IMLContext ctx, BindingDefinition bindingDef){ + void emitDataSourceBindings (IMLContext ctx, BindingDefinition bindingDef) + { + Delegate del = emitDataSourceBindings (ctx.CurrentNodeType.GetProperty (bindingDef.SourceMember), bindingDef); + + //store dschange delegate in instatiator instance for access while instancing graphic object + int delDSIndex = cachedDelegates.Count; + cachedDelegates.Add (del); + + ctx.emitCachedDelegateHandlerAddition (delDSIndex, CompilerServices.eiDSChange); + } + + /// + /// create the valuechanged handler and the datasourcechanged handler and return the + /// DataSourceChange delegate + /// + public Delegate emitDataSourceBindings (PropertyInfo piSource, BindingDefinition bindingDef){ + #if DEBUG_BINDING_FUNC_CALLS Console.WriteLine ($"emitDataSourceBindings: {bindingDef}"); #endif DynamicMethod dm = null; ILGenerator il = null; int dmVC = 0; - PropertyInfo piSource = ctx.CurrentNodeType.GetProperty(bindingDef.SourceMember); + //if no dataSource member name is provided, valuechange is not handle and datasource change //will be used as origine value string delName = $"dyn_DSvalueChanged_{bindingDef.SourceMember}_{bindingDef.TargetMember}_{NewId}"; if (!string.IsNullOrEmpty(bindingDef.TargetMember)){ -#region create valuechanged method + #region create valuechanged method dm = new DynamicMethod (delName, typeof (void), CompilerServices.argsBoundValueChange, true); @@ -1303,17 +1297,13 @@ namespace Crow.IML { il.MarkLabel (newDSIsNull); il.Emit (OpCodes.Ret); - //store dschange delegate in instatiator instance for access while instancing graphic object - int delDSIndex = cachedDelegates.Count; - cachedDelegates.Add(dm.CreateDelegate (CompilerServices.ehTypeDSChange, this)); -#endregion - - ctx.emitCachedDelegateHandlerAddition(delDSIndex, CompilerServices.eiDSChange); - #if DEBUG_BINDING Debug.WriteLine("\tDataSource ValueChanged: " + delName); Debug.WriteLine("\tDataSource Changed: " + dm.Name); #endif + + return dm.CreateDelegate (CompilerServices.ehTypeDSChange, this); +#endregion } static void emitSetValue (ILGenerator il, MemberInfo mi) @@ -1322,8 +1312,7 @@ namespace Crow.IML { il.Emit (OpCodes.Stfld, mi as FieldInfo); else if (mi.MemberType == MemberTypes.Property) { MethodInfo mt = (mi as PropertyInfo).GetSetMethod (); - //il.Emit (mt.IsVirtual?OpCodes.Callvirt:OpCodes.Call, mt); - il.Emit (OpCodes.Callvirt, mt); + il.Emit (mt.IsVirtual?OpCodes.Callvirt:OpCodes.Call, mt); } else throw new NotImplementedException (); } diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs index 5488b559..72f01bee 100644 --- a/Crow/src/Interface.cs +++ b/Crow/src/Interface.cs @@ -135,7 +135,7 @@ namespace Crow loadStyling (); initTooltip (); - //initContextMenus (); + initContextMenus (); Startup (); } diff --git a/Crow/src/ItemTemplate.cs b/Crow/src/ItemTemplate.cs index 3b6cf0b2..1d779be7 100644 --- a/Crow/src/ItemTemplate.cs +++ b/Crow/src/ItemTemplate.cs @@ -1,28 +1,6 @@ -// -// ItemTemplate.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 System.IO; diff --git a/Crow/src/ObservableList.cs b/Crow/src/ObservableList.cs index 96bfccc9..52ada9ac 100644 --- a/Crow/src/ObservableList.cs +++ b/Crow/src/ObservableList.cs @@ -1,47 +1,89 @@ -// -// IListChanged.cs +// Copyright (c) 2013-2019 Bruyère Jean-Philippe jp_bruyere@hotmail.com // -// 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.Collections.Generic; namespace Crow -{ - public class ObservableList : List , IObservableList { +{ + public class ObservableList : List, IObservableList, IValueChange { + #region IValueChange implementation + public event EventHandler ValueChanged; + public virtual void NotifyValueChanged (string MemberName, object _value) + { + ValueChanged?.Invoke (this, new ValueChangeEventArgs (MemberName, _value)); + } + #endregion + + #region IObservableList implementation public event EventHandler ListAdd; - public event EventHandler ListRemove; + public event EventHandler ListRemove; + public event EventHandler ListEdit; + #endregion + + public ObservableList() : base () {} + public ObservableList (IEnumerable collection) : base (collection) { } + + int selectedIndex = -1; + + public int SelectedIndex { + get => selectedIndex; + set { + if (selectedIndex == value) + return; - public void AddElement (T elem) { - this.Add(elem); + if (value > Count - 1) + selectedIndex = Count - 1; + else + selectedIndex = value; + + NotifyValueChanged ("SelectedIndex", selectedIndex); + NotifyValueChanged ("SelectedItem", SelectedItem); + } + } + public T SelectedItem { + get => selectedIndex < 0 ? default(T) : this [selectedIndex]; + set { + this [selectedIndex] = value; + } + } + public new void Add (T elem) { + base.Add (elem); ListAdd.Raise (this, new ListChangedEventArg (this.Count - 1, elem)); + SelectedIndex = this.Count - 1; } - public void RemoveElement (T elem) { - System.Diagnostics.Debug.WriteLine ("remove elem:" + elem); - int idx = this.IndexOf (elem); - this.RemoveAt (idx); + public new void Remove (T elem) { + int idx = IndexOf (elem); + base.RemoveAt (idx); ListRemove.Raise (this, new ListChangedEventArg (idx, elem)); } + public void Remove () { + if (selectedIndex < 0) + return; + RemoveAt (selectedIndex); + SelectedIndex--; + } + public void Insert () + { + base.Insert (selectedIndex+1, default(T)); + SelectedIndex++; + ListAdd.Raise (this, new ListChangedEventArg (selectedIndex, SelectedItem)); + } + public void RaiseEdit () { + if (selectedIndex < 0) + return; + ListEdit.Raise (this, new ListChangedEventArg (selectedIndex, SelectedItem)); + } + + public new void RemoveAt (int index) + { + base.RemoveAt (index); + ListRemove.Raise (this, new ListChangedEventArg (index, null)); + } + public void RaiseEditAt (int index) { + ListEdit.Raise (this, new ListChangedEventArg (index, this[index])); + } } } diff --git a/Crow/src/Widgets/Image.cs b/Crow/src/Widgets/Image.cs index 98f86e58..87111e84 100644 --- a/Crow/src/Widgets/Image.cs +++ b/Crow/src/Widgets/Image.cs @@ -1,28 +1,6 @@ -// -// Image.cs +// Copyright (c) 2013-2019 Jean-Philippe Bruyère jp_bruyere@hotmail.com // -// 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.Cairo; diff --git a/Crow/src/Widgets/ListBox.cs b/Crow/src/Widgets/ListBox.cs index 438e8d60..f605fa55 100644 --- a/Crow/src/Widgets/ListBox.cs +++ b/Crow/src/Widgets/ListBox.cs @@ -43,6 +43,8 @@ namespace Crow public ListBox (Interface iface) : base(iface) {} #endregion + + } } diff --git a/Crow/src/Widgets/TabView.cs b/Crow/src/Widgets/TabView.cs index 423b8ab4..1f9082d4 100644 --- a/Crow/src/Widgets/TabView.cs +++ b/Crow/src/Widgets/TabView.cs @@ -46,7 +46,7 @@ namespace Crow int rightSlope; Measure tabHeight, tabWidth; Orientation _orientation; - int selectedTab; + int selectedTab = -1; #endregion #region public properties diff --git a/Crow/src/Widgets/Table.cs b/Crow/src/Widgets/Table.cs new file mode 100644 index 00000000..bc148210 --- /dev/null +++ b/Crow/src/Widgets/Table.cs @@ -0,0 +1,57 @@ +// Copyright (c) 2019 Jean-Philippe Bruyère +// +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) +using System; +namespace Crow +{ + /// + /// Table column definition + /// + public class Column : IValueChange + { + #region IValueChange implementation + public event EventHandler ValueChanged; + public virtual void NotifyValueChanged (string MemberName, object _value) + => ValueChanged.Raise (this, new ValueChangeEventArgs (MemberName, _value)); + #endregion + + string caption; + Measure width = Measure.Inherit; + + public string Caption { + get => caption; + set { + if (caption == value) + return; + caption = value; + NotifyValueChanged ("Caption", caption); + } + } + /// + /// column width, special value 'Inherit' will be used to share table width equaly among columns + /// + /// The column's width. + public Measure Width { + get => width; + set { + if (width == value) + return; + width = value; + NotifyValueChanged ("Width", width); + } + } + + //public string Data { + + //} + } + + + public class Table : TemplatedGroup + { + public Table () : base () {} + public Table (Interface iFace) : base (iFace) { } + + public ObservableList Columns = new ObservableList (); + } +} diff --git a/Crow/src/Widgets/TemplatedGroup.cs b/Crow/src/Widgets/TemplatedGroup.cs index 42e4dc06..9546174e 100644 --- a/Crow/src/Widgets/TemplatedGroup.cs +++ b/Crow/src/Widgets/TemplatedGroup.cs @@ -47,6 +47,7 @@ namespace Crow { IEnumerable data; int _selectedIndex = -1; Color selBackground, selForeground; + bool selColoring; int itemPerPage = 50; CrowThread loadingThread = null; @@ -120,23 +121,36 @@ namespace Crow { : items.Children; } } + /// + /// Enable SelectionBackground and SelectionForeground color for selected item + /// + [DefaultValue (false)] + public bool SelectionColoring { + get => selColoring; + set { + if (selColoring == value) + return; + selColoring = value; + NotifyValueChanged ("SelectionColoring", selColoring); + } + } [DefaultValue(-1)]public virtual int SelectedIndex{ get { return _selectedIndex; } set { if (value == _selectedIndex) return; - /*if (_selectedIndex >= 0 && Items.Count > _selectedIndex) { + if (selColoring && _selectedIndex >= 0 && Items.Count > _selectedIndex) { Items[_selectedIndex].Foreground = Color.Transparent; Items[_selectedIndex].Background = Color.Transparent; - }*/ + } _selectedIndex = value; - /*if (_selectedIndex >= 0 && Items.Count > _selectedIndex) { + if (selColoring && _selectedIndex >= 0 && Items.Count > _selectedIndex) { Items[_selectedIndex].Foreground = SelectionForeground; Items[_selectedIndex].Background = SelectionBackground; - }*/ + } NotifyValueChanged ("SelectedIndex", _selectedIndex); NotifyValueChanged ("SelectedItem", SelectedItem); @@ -172,6 +186,7 @@ namespace Crow { IObservableList ol = data as IObservableList; ol.ListAdd -= Ol_ListAdd; ol.ListRemove -= Ol_ListRemove; + ol.ListEdit -= Ol_ListEdit; } data = value; @@ -180,6 +195,7 @@ namespace Crow { IObservableList ol = data as IObservableList; ol.ListAdd += Ol_ListAdd; ol.ListRemove += Ol_ListRemove; + ol.ListEdit += Ol_ListEdit; } NotifyValueChanged ("Data", data); @@ -221,6 +237,13 @@ namespace Crow { } else loadItem (e.Element, items, dataTest); } + void Ol_ListEdit (object sender, ListChangedEventArg e) { + if (this.isPaged) { + throw new NotImplementedException (); + } else + items.Children [e.Index].DataSource = e.Element; + + } [DefaultValue("SteelBlue")] public virtual Color SelectionBackground { @@ -483,7 +506,8 @@ namespace Crow { } } internal virtual void itemClick(object sender, MouseButtonEventArgs e){ - SelectedIndex = (int)((IList)data)?.IndexOf((sender as Widget).DataSource); + //SelectedIndex = (int)((IList)data)?.IndexOf((sender as Widget).DataSource); + SelectedIndex = items.Children.IndexOf(sender as Widget); } bool emitHelperIsAlreadyExpanded (Widget go){ @@ -504,5 +528,20 @@ namespace Crow { { base.OnDataSourceChanged (sender, e); } + + public void OnInsertClick (object sender, MouseEventArgs e) + { + if (data is IObservableList) + (data as IObservableList).Insert (); + } + public void OnRemoveClick (object sender, MouseEventArgs e) + { + if (data is IObservableList) + (data as IObservableList).Remove (); + } + public void OnUpdateClick (object sender, MouseEventArgs e) { + if (data is IObservableList) + (data as IObservableList).RaiseEdit (); + } } } diff --git a/Crow/src/Widgets/Window.cs b/Crow/src/Widgets/Window.cs index 22ad640e..23496530 100644 --- a/Crow/src/Widgets/Window.cs +++ b/Crow/src/Widgets/Window.cs @@ -1,28 +1,6 @@ -// -// Window.cs +// Copyright (c) 2013-2019 Bruyère Jean-Philippe jp_bruyere@hotmail.com // -// 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/CrowIDE/CrowIDE.csproj b/CrowIDE/CrowIDE.csproj index beb912d6..7b180b26 100644 --- a/CrowIDE/CrowIDE.csproj +++ b/CrowIDE/CrowIDE.csproj @@ -4,6 +4,7 @@ Exe false Crow.Coding.CrowIDE + 0.8.0 diff --git a/CrowIDE/src/CrowIDE.cs b/CrowIDE/src/CrowIDE.cs index 0aa743b2..07827391 100644 --- a/CrowIDE/src/CrowIDE.cs +++ b/CrowIDE/src/CrowIDE.cs @@ -46,7 +46,7 @@ namespace Crow.Coding CMDCopy = new Command(new Action(() => copy())) { Caption = "Copy", Icon = new SvgPicture("#CrowIDE.icons.copy-file.svg"), CanExecute = false}; CMDPaste = new Command(new Action(() => paste())) { Caption = "Paste", Icon = new SvgPicture("#CrowIDE.icons.paste-on-document.svg"), CanExecute = false}; CMDHelp = new Command(new Action(() => System.Diagnostics.Debug.WriteLine("help"))) { Caption = "Help", Icon = new SvgPicture("#CrowIDE.icons.question.svg") }; - CMDOptions = new Command(new Action(() => loadWindow("#CrowIDE.ui.Options.crow"))) { Caption = "Editor Options", Icon = new SvgPicture("#CrowIDE.icons.tools.svg") }; + CMDOptions = new Command(new Action(() => loadWindow("#CrowIDE.ui.Options.crow", this))) { Caption = "Editor Options", Icon = new SvgPicture("#CrowIDE.icons.tools.svg") }; cmdCloseSolution = new Command(new Action(() => closeSolution())) { Caption = "Close Solution", Icon = new SvgPicture("#CrowIDE.icons.paste-on-document.svg"), CanExecute = false}; @@ -71,7 +71,7 @@ namespace Crow.Coding CMDViewGTExp = new Command(new Action(() => loadWindow ("#CrowIDE.ui.DockWindows.winGTExplorer.crow",this))) { Caption = "Graphic Tree Explorer", CanExecute = true}; CMDCompile = new Command(new Action(() => compileSolution())) - { Caption = "Compile", CanExecute = false}; + { Caption = "Compile Solution", CanExecute = false}; CMDViewProjProps = new Command(new Action(loadProjProps)) { Caption = "Project Properties", CanExecute = false}; } @@ -81,7 +81,7 @@ namespace Crow.Coding } void openOptionsDialog(){} void newFile() { - currentSolution.OpenedItems.AddElement(new ProjectFile()); + currentSolution.OpenedItems.Add(new ProjectFile()); } void saveFileDialog() {} void undo() {} @@ -138,7 +138,7 @@ namespace Crow.Coding public CrowIDE () : base(1024, 800) - { + { } Instantiator instFileDlg; @@ -160,8 +160,8 @@ namespace Crow.Coding if (ReopenLastSolution && !string.IsNullOrEmpty (LastOpenSolution)) { CurrentSolution = new Workspace (LastOpenSolution); - //lock(MainIFace.UpdateMutex) - // CurrentSolution.ReopenItemsSavedInUserConfig (); + lock(MainIFace.UpdateMutex) + CurrentSolution.ReopenItemsSavedInUserConfig (); } instFileDlg = Instantiator.CreateFromImlFragment diff --git a/CrowIDE/src/Workspace.cs b/CrowIDE/src/Workspace.cs index a28d0fc4..ddbd2d6e 100644 --- a/CrowIDE/src/Workspace.cs +++ b/CrowIDE/src/Workspace.cs @@ -117,7 +117,7 @@ namespace Crow.Coding t.GetCustomAttribute(false) == null).ToArray (); ToolboxItems = new ObservableList (); foreach (Type ci in crowItems) { - toolboxItems.AddElement(new GraphicObjectDesignContainer(ci)); + toolboxItems.Add(new GraphicObjectDesignContainer(ci)); } } public bool GetProjectFileFromPath (string path, out ProjectFile pi){ @@ -247,21 +247,21 @@ namespace Crow.Coding public void OpenItem (ProjectItem pi) { if (!openedItems.Contains (pi)) { - openedItems.AddElement (pi); + openedItems.Add (pi); saveOpenedItemsInUserConfig (); } } public void CloseItem (ProjectItem pi) { - openedItems.RemoveElement (pi); + openedItems.Remove (pi); saveOpenedItemsInUserConfig (); } public void CloseSolution () { while (openedItems.Count > 0) { - openedItems.RemoveElement (openedItems [0]); + openedItems.Remove (openedItems [0]); } while (toolboxItems?.Count > 0) { - toolboxItems.RemoveElement (toolboxItems [0]); + toolboxItems.Remove (toolboxItems [0]); } NotifyValueChanged ("Projects", null); } diff --git a/CrowIDE/ui/Options.crow b/CrowIDE/ui/Options.crow index 7d401e05..973beed7 100644 --- a/CrowIDE/ui/Options.crow +++ b/CrowIDE/ui/Options.crow @@ -1,16 +1,13 @@  - - + + - - - - + - + diff --git a/Samples/HelloWorld/HelloWorld.csproj b/Samples/HelloWorld/HelloWorld.csproj index 9363d574..448fb435 100644 --- a/Samples/HelloWorld/HelloWorld.csproj +++ b/Samples/HelloWorld/HelloWorld.csproj @@ -1,8 +1,9 @@  - net471;netstandard2.0 + net472 Exe false + 0.8.0 diff --git a/Samples/ShowCase/ShowCase.csproj b/Samples/ShowCase/ShowCase.csproj index 60dbd9ec..d31e0a6a 100644 --- a/Samples/ShowCase/ShowCase.csproj +++ b/Samples/ShowCase/ShowCase.csproj @@ -1,6 +1,6 @@ - net471 + net472 Exe false 0.8.0 -- 2.47.3