From e6030fa04a8de3fdae1dc19d081bf5feb3d3d73c Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bruyère Date: Sat, 3 Aug 2019 19:49:15 +0200 Subject: sample directory --- Samples/CrowIDE/src/ProjectTree/CSProjectFile.cs | 72 +++++ Samples/CrowIDE/src/ProjectTree/ImlProjectItem.cs | 89 ++++++ Samples/CrowIDE/src/ProjectTree/ProjectFile.cs | 323 +++++++++++++++++++++ Samples/CrowIDE/src/ProjectTree/ProjectItem.cs | 116 ++++++++ Samples/CrowIDE/src/ProjectTree/ProjectNodes.cs | 159 ++++++++++ .../CrowIDE/src/ProjectTree/ProjectReference.cs | 51 ++++ .../CrowIDE/src/ProjectTree/StyleProjectItem.cs | 50 ++++ 7 files changed, 860 insertions(+) create mode 100644 Samples/CrowIDE/src/ProjectTree/CSProjectFile.cs create mode 100644 Samples/CrowIDE/src/ProjectTree/ImlProjectItem.cs create mode 100644 Samples/CrowIDE/src/ProjectTree/ProjectFile.cs create mode 100644 Samples/CrowIDE/src/ProjectTree/ProjectItem.cs create mode 100644 Samples/CrowIDE/src/ProjectTree/ProjectNodes.cs create mode 100644 Samples/CrowIDE/src/ProjectTree/ProjectReference.cs create mode 100644 Samples/CrowIDE/src/ProjectTree/StyleProjectItem.cs (limited to 'Samples/CrowIDE/src/ProjectTree') diff --git a/Samples/CrowIDE/src/ProjectTree/CSProjectFile.cs b/Samples/CrowIDE/src/ProjectTree/CSProjectFile.cs new file mode 100644 index 00000000..586e2261 --- /dev/null +++ b/Samples/CrowIDE/src/ProjectTree/CSProjectFile.cs @@ -0,0 +1,72 @@ +// +// ProjectNodes.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; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace Crow.Coding +{ + public class CSProjectFile : ProjectFile + { + CSharpSyntaxTree tree; + + + #region CTOR + public CSProjectFile (ProjectItem pi) : base (pi){ + } + #endregion + + public override void UpdateSource(object sender, string newSrc) + { + base.UpdateSource(sender, newSrc); + + tree = (CSharpSyntaxTree)CSharpSyntaxTree.ParseText (Source, CSharpParseOptions.Default); + } + + public override void Open () { + base.Open (); + + tree = (CSharpSyntaxTree)CSharpSyntaxTree.ParseText (Source, CSharpParseOptions.Default); + + CompilationUnitSyntax root = (CompilationUnitSyntax)tree.GetRoot (); + MemberDeclarationSyntax firstMember = root.Members [0]; + + Console.WriteLine ( firstMember.GetType().FullName); + + SyntaxToken tok = root.GetFirstToken(); + + while (tok.Value != null) { + Console.Write (tok.Text); + tok = tok.GetNextToken (true,true); + } + Console.Out.Flush (); + } + + + } +} + diff --git a/Samples/CrowIDE/src/ProjectTree/ImlProjectItem.cs b/Samples/CrowIDE/src/ProjectTree/ImlProjectItem.cs new file mode 100644 index 00000000..8487f838 --- /dev/null +++ b/Samples/CrowIDE/src/ProjectTree/ImlProjectItem.cs @@ -0,0 +1,89 @@ +// +// ProjectNodes.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; +using System.Collections.Generic; +using System.Linq; +using System.Xml; +using System.IO; +using Crow; +using System.Threading; + +namespace Crow.Coding +{ + public class ImlProjectItem : ProjectFile + { + #region CTOR + public ImlProjectItem (ProjectItem pi) : base (pi){ + } + #endregion + + Widget instance; + Measure designWidth, designHeight; + + /// + /// instance created with an instantiator from the source by a DesignInterface, + /// for now, the one in ImlVisualEditor + /// + public Widget Instance { + get { return instance; } + set { + if (instance == value) + return; + instance = value; + NotifyValueChanged ("Instance", instance); + } + } + + public Measure DesignWidth { + get { return designWidth; } + set { + if (designWidth == value) + return; + designWidth = value; + NotifyValueChanged ("DesignWidth", designWidth); + } + } + public Measure DesignHeight { + get { return designHeight; } + set { + if (designHeight == value) + return; + designHeight = value; + NotifyValueChanged ("DesignHeight", designHeight); + } + } + + + public List GraphicTree { + get { return new List (new Widget[] {instance}); } + } + + void GTView_SelectedItemChanged (object sender, SelectionChangeEventArgs e){ + SelectedItem = e.NewValue; + } + } +} + diff --git a/Samples/CrowIDE/src/ProjectTree/ProjectFile.cs b/Samples/CrowIDE/src/ProjectTree/ProjectFile.cs new file mode 100644 index 00000000..294a28f5 --- /dev/null +++ b/Samples/CrowIDE/src/ProjectTree/ProjectFile.cs @@ -0,0 +1,323 @@ +// +// ProjectNodes.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; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Xml; + +namespace Crow.Coding { + public class ProjectFile : ProjectItem { + bool isOpened = false; + DateTime accessTime; + string source; + string origSource; + object selectedItem; + int curLine, curColumn; + + internal ReaderWriterLockSlim srcEditMtx = new ReaderWriterLockSlim(); + + public Dictionary RegisteredEditors = new Dictionary(); + List undoStack = new List(); + List redoStack = new List(); + + public Crow.Command cmdSave, cmdSaveAs, cmdOpen, cmdClose, cmdUndo, cmdRedo; + + void initCommands (){ + cmdSave = new Crow.Command (new Action (() => Save ())) + { Caption = "Save", Icon = new SvgPicture ("#CrowIDE.icons.save.svg"), CanExecute = false }; + cmdSaveAs = new Crow.Command (new Action (() => SaveAs ())) + { Caption = "Save As ..", Icon = new SvgPicture ("#CrowIDE.icons.save.svg"), CanExecute = false }; + cmdOpen = new Crow.Command (new Action (() => Open ())) + { Caption = "Open", Icon = new SvgPicture ("#CrowIDE.icons.open.svg"), CanExecute = true }; + cmdClose = new Crow.Command (new Action (() => OnQueryClose (this,null))) + { Caption = "Close", Icon = new SvgPicture ("#CrowIDE.icons.open.svg"), CanExecute = false }; + cmdUndo = new Crow.Command (new Action (() => Undo (null))) + { Caption = "Undo", Icon = new SvgPicture ("#CrowIDE.icons.undo.svg"), CanExecute = false }; + cmdRedo = new Crow.Command (new Action (() => Redo (null))) + { Caption = "Redo", Icon = new SvgPicture ("#CrowIDE.icons.redo.svg"), CanExecute = false }; + + Commands.Insert (0, cmdOpen); + Commands.Insert (1, cmdSave); + Commands.Insert (2, cmdSaveAs); + Commands.Insert (3, cmdUndo); + Commands.Insert (4, cmdRedo); + Commands.Add (cmdClose); + } + public ProjectFile () { + initCommands(); + } + public ProjectFile (ProjectItem pi) + : base (pi.Project, pi.node) { + initCommands (); + } + + public string ResourceID { + get { + return Type != ItemType.EmbeddedResource ? null : + node.SelectSingleNode ("LogicalName") == null ? + Project.Name + "." + Path.Replace ('/', '.') : + LogicalName; + } + } + public string LogicalName { + get { + return node.SelectSingleNode ("LogicalName")?.InnerText; + } + } + public bool IsOpened { + get { return isOpened; } + set { + if (isOpened == value) + return; + isOpened = value; + + cmdOpen.CanExecute = !isOpened; + cmdClose.CanExecute = isOpened; + cmdSave.CanExecute = isOpened && IsDirty; + + if (isOpened) + Project.solution.OpenItem (this); + else + Project.solution.CloseItem (this); + + NotifyValueChanged ("IsOpened", isOpened); + } + } + + public void UnregisterEditor (object editor){ + lock(RegisteredEditors){ + RegisteredEditors.Remove (editor); + } + } + public void RegisterEditor (object editor) { + lock(RegisteredEditors){ + RegisteredEditors.Add (editor, false); + } + } + public virtual void UpdateSource (object sender, string newSrc){ + System.Diagnostics.Debug.WriteLine ("update source by {0}", sender); + Source = newSrc; + signalOtherRegisteredEditors (sender); + } + public void SignalEditorOfType (){ + lock (RegisteredEditors) { + object[] keys = RegisteredEditors.Keys.ToArray (); + foreach (object ed in keys) { + T editor = (T)ed; + if (editor == null) + continue; + RegisteredEditors [editor] = false; + break; + } + } + } + protected void signalOtherRegisteredEditors (object sender) { + lock (RegisteredEditors) { + object[] keys = RegisteredEditors.Keys.ToArray (); + foreach (object editor in keys) { + if (editor != sender) + RegisteredEditors [editor] = false; + } + } + } + public string Source { + get { + if (!IsOpened) { + using (StreamReader sr = new StreamReader (AbsolutePath)) + source = sr.ReadToEnd (); + + } else { + if (DateTime.Compare ( + accessTime, + System.IO.File.GetLastWriteTime (AbsolutePath)) < 0) + Console.WriteLine ("File has been modified outside CrowIDE"); + } + return source; + } + set { + if (source == value) + return; + + srcEditMtx.EnterWriteLock (); + + undoStack.Add (source); + cmdUndo.CanExecute = true; + redoStack.Clear (); + cmdRedo.CanExecute = false; + source = value; + + NotifyValueChanged ("Source", source); + NotifyValueChanged ("IsDirty", IsDirty); + + cmdSave.CanExecute = cmdSaveAs.CanExecute = IsDirty; + + srcEditMtx.ExitWriteLock (); + } + } + public bool IsDirty { + get { return source != origSource; } + } + public int CurrentColumn{ + get { return curColumn; } + set { + if (curColumn == value) + return; + curColumn = value; + NotifyValueChanged ("CurrentColumn", curColumn); + } + } + public int CurrentLine{ + get { return curLine; } + set { + if (curLine == value) + return; + curLine = value; + NotifyValueChanged ("CurrentLine", curLine); + } + } + + public object SelectedItem { + get { return selectedItem; } + set { + if (selectedItem == value) + return; + selectedItem= value; + Project.solution.SelectedItemElement = value; + NotifyValueChanged ("SelectedItem", selectedItem); + } + } + + public CopyToOutputState CopyToOutputDirectory { + get { + XmlNode xn = node.SelectSingleNode ("CopyToOutputDirectory"); + return xn == null ? CopyToOutputState.Never : + (CopyToOutputState)Enum.Parse (typeof(CopyToOutputState), xn.InnerText, true); + } + } + + public virtual void Open () { + accessTime = System.IO.File.GetLastWriteTime (AbsolutePath); + using (StreamReader sr = new StreamReader (AbsolutePath)) { + source = sr.ReadToEnd (); + } + origSource = source; + IsOpened = true; + NotifyValueChanged ("IsDirty", false); + } + public virtual void Save () { + if (!IsDirty) + return; + using (StreamWriter sw = new StreamWriter (AbsolutePath)) { + sw.Write (source); + } + origSource = source; + NotifyValueChanged ("IsDirty", false); + } + public virtual void SaveAs () { + if (!IsDirty) + return; + using (StreamWriter sw = new StreamWriter (AbsolutePath)) { + sw.Write (source); + } + origSource = source; + NotifyValueChanged ("IsDirty", false); + } + public void Close () { + origSource = source = null; + IsOpened = false; + } + public void Undo(object sender){ + undo(); + signalOtherRegisteredEditors (sender); + } + public void Redo(object sender){ + redo(); + signalOtherRegisteredEditors (sender); + } + + void undo () { + if (undoStack.Count == 0) + return; + + srcEditMtx.EnterWriteLock (); + string step = undoStack [undoStack.Count -1]; + redoStack.Add (source); + cmdRedo.CanExecute = true; + undoStack.RemoveAt(undoStack.Count -1); + + source = step; + + NotifyValueChanged ("Source", source); + NotifyValueChanged ("IsDirty", IsDirty); + cmdSave.CanExecute = IsDirty; + + if (undoStack.Count == 0) + cmdUndo.CanExecute = false; + srcEditMtx.ExitWriteLock (); + } + + void redo () { + if (redoStack.Count == 0) + return; + srcEditMtx.EnterWriteLock (); + string step = redoStack [redoStack.Count -1]; + undoStack.Add (source); + cmdUndo.CanExecute = true; + redoStack.RemoveAt(redoStack.Count -1); + source = step; + NotifyValueChanged ("Source", source); + NotifyValueChanged ("IsDirty", IsDirty); + cmdSave.CanExecute = IsDirty; + + if (redoStack.Count == 0) + cmdRedo.CanExecute = false; + srcEditMtx.ExitWriteLock (); + + } + + public void onDoubleClick (object sender, MouseButtonEventArgs e){ + if (IsOpened) + return; + Open (); + } + + public void onClick (object sender, MouseButtonEventArgs e){ + IsSelected = true; + } + public void OnQueryClose (object sender, EventArgs e){ + if (IsDirty) { + MessageBox mb = MessageBox.ShowModal (CrowIDE.MainIFace, + MessageBox.Type.YesNoCancel, $"{DisplayName} has unsaved changes.\nSave it now?"); + mb.Yes += (object _sender, EventArgs _e) => { Save (); Close (); }; + mb.No += (object _sender, EventArgs _e) => Close(); + } else + Close (); + } + } +} + diff --git a/Samples/CrowIDE/src/ProjectTree/ProjectItem.cs b/Samples/CrowIDE/src/ProjectTree/ProjectItem.cs new file mode 100644 index 00000000..afa3e3ed --- /dev/null +++ b/Samples/CrowIDE/src/ProjectTree/ProjectItem.cs @@ -0,0 +1,116 @@ +// +// ProjectNodes.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; +using System.Collections.Generic; +using System.Linq; +using System.Xml; +using System.IO; +using Crow; +using System.Threading; + +namespace Crow.Coding +{ + public class ProjectItem : ProjectNode { + #region CTOR + public ProjectItem() {} + public ProjectItem (Project project, XmlNode _node) : base (project){ + node = _node; + } + #endregion + + public XmlNode node; + + public override Picture Icon { + get { + switch (Extension) + { + case ".cs": + return new SvgPicture("#CrowIDE.icons.cs-file.svg"); + case ".crow": + return new SvgPicture("#CrowIDE.icons.xml-file.svg"); + case ".xml": + return new SvgPicture("#CrowIDE.icons.xml-file.svg"); + default: + return base.Icon; + } + } + } + + public string Extension { + get { return System.IO.Path.GetExtension (Path); } + } + public string Path { + get { + return node.Attributes["Include"]?.Value.Replace('\\','/'); + } + } + public string AbsolutePath { + get { + return System.IO.Path.Combine (Project.RootDir, Path); + } + } + public override ItemType Type { + get { + return (ItemType)Enum.Parse (typeof(ItemType), node.Name, true); + } + } + public override string DisplayName { + get { + return Type == ItemType.Reference ? + Path : + Path.Split ('/').LastOrDefault(); + } + } + public string HintPath { + get { return node.SelectSingleNode ("HintPath")?.InnerText; } + } + + public override bool IsSelected { + get { + return isSelected; + } + set { + if (value == isSelected) + return; + + isSelected = value; + + NotifyValueChanged ("IsSelected", isSelected); + + if (isSelected) { + Project.solution.SelectedItem = this; + Project.IsExpanded = true; + ProjectNode pn = Parent; + while (pn != null) { + pn.IsExpanded = true; + pn = pn.Parent; + } + } + } + } + } +} + diff --git a/Samples/CrowIDE/src/ProjectTree/ProjectNodes.cs b/Samples/CrowIDE/src/ProjectTree/ProjectNodes.cs new file mode 100644 index 00000000..bafb9cbd --- /dev/null +++ b/Samples/CrowIDE/src/ProjectTree/ProjectNodes.cs @@ -0,0 +1,159 @@ +// +// ProjectNodes.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; +using System.Collections.Generic; +using System.Linq; +using System.Xml; +using System.IO; +using Crow; +using System.Threading; + +namespace Crow.Coding +{ + public enum ItemType { + ReferenceGroup, + Reference, + ProjectReference, + VirtualGroup, + Folder, + None, + Compile, + EmbeddedResource, + } + public enum CopyToOutputState { + Never, + Always, + PreserveNewest + } + public class ProjectNode : IValueChange + { + #region IValueChange implementation + public event EventHandler ValueChanged; + public virtual void NotifyValueChanged(string MemberName, object _value) + { + ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value)); + } + #endregion + + #region CTOR + public ProjectNode (Project project, ItemType _type, string _name) : this(project){ + type = _type; + name = _name; + initCommands (); + } + public ProjectNode (Project project){ + Project = project; + initCommands (); + } + public ProjectNode (){ + initCommands (); + } + #endregion + + void initCommands () { + Commands = new List (); + } + + ProjectNode parent; + bool isExpanded; + protected bool isSelected; + ItemType type; + string name; + List childNodes = new List(); + + public Project Project; + public List Commands;//list of command available for that node + + public virtual Crow.Picture Icon { + get { + switch (Type) { + case ItemType.Reference: + return new SvgPicture ("#Crow.Icons.assembly.svg"); + case ItemType.ProjectReference: + return new SvgPicture("#Crow.Icons.projectRef.svg"); + default: + return new SvgPicture("#CrowIDE.icons.blank-file.svg"); + } + } + } + public ProjectNode Parent { + get { return parent; } + set { parent = value; } + } + public virtual ItemType Type { + get { return type; } + } + public virtual string DisplayName { + get { return name; } + } + public List ChildNodes { + get { return childNodes; } + } + public void AddChild (ProjectNode pn) { + childNodes.Add(pn); + pn.Parent = this; + } + public void RemoveChild (ProjectNode pn){ + pn.Parent = null; + childNodes.Remove (pn); + } + public void SortChilds () { + foreach (ProjectNode pn in childNodes) + pn.SortChilds (); + childNodes = childNodes.OrderBy(c=>c.Type).ThenBy(cn=>cn.DisplayName).ToList(); + } + + public bool IsExpanded + { + get { return isExpanded; } + set + { + if (value == isExpanded) + return; + isExpanded = value; + NotifyValueChanged ("IsExpanded", isExpanded); + } + } + public virtual bool IsSelected + { + get { return isSelected; } + set + { + if (value == isSelected) + return; + + isSelected = value; + + NotifyValueChanged ("IsSelected", isSelected); + } + } + public override string ToString () + { + return DisplayName; + } + } +} + diff --git a/Samples/CrowIDE/src/ProjectTree/ProjectReference.cs b/Samples/CrowIDE/src/ProjectTree/ProjectReference.cs new file mode 100644 index 00000000..84870746 --- /dev/null +++ b/Samples/CrowIDE/src/ProjectTree/ProjectReference.cs @@ -0,0 +1,51 @@ +// +// ProjectNodes.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; +using System.Collections.Generic; +using System.Linq; +using System.Xml; +using System.IO; +using Crow; +using System.Threading; + +namespace Crow.Coding +{ + public class ProjectReference : ProjectItem { + public ProjectReference (ProjectItem pi) : base (pi.Project, pi.node){ + } + public string ProjectGUID { + get { + return node.SelectSingleNode ("Project")?.InnerText; + } + } + public override string DisplayName { + get { + return node.SelectSingleNode ("Name").InnerText; + } + } + } +} + diff --git a/Samples/CrowIDE/src/ProjectTree/StyleProjectItem.cs b/Samples/CrowIDE/src/ProjectTree/StyleProjectItem.cs new file mode 100644 index 00000000..1de77cd7 --- /dev/null +++ b/Samples/CrowIDE/src/ProjectTree/StyleProjectItem.cs @@ -0,0 +1,50 @@ +// +// ProjectNodes.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; +using System.Collections.Generic; +using System.Linq; +using System.Xml; +using System.IO; +using Crow; +using System.Threading; + +namespace Crow.Coding +{ + public class StyleProjectItem : ProjectFile + { + #region CTOR + public StyleProjectItem (ProjectItem pi) : base (pi){ + } + #endregion + + public override void UpdateSource (object sender, string newSrc) + { + base.UpdateSource (sender, newSrc); + Project.solution.ReloadStyling (); + } + } +} + -- cgit v1.3.1-4-g156e