From 407690e9b8a2693a7bd831e954c079cb26c569b7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Sat, 10 Mar 2018 06:03:25 +0100 Subject: [PATCH] getStremFromPath made instanced for overriding in designiface, crowide wip --- CrowIDE/CrowIDE.csproj | 63 ++++++++++++------- CrowIDE/icons/compile.svg | 8 +-- CrowIDE/src/CrowIDE.cs | 16 +++-- CrowIDE/src/DesignInterface.cs | 13 +++- .../CodeBuffer}/CodeBuffer.cs | 0 .../CodeBuffer}/CodeBufferEventArgs.cs | 0 .../CodeBuffer}/CodeLine.cs | 0 .../CodeBuffer}/Node.cs | 0 .../CodeBuffer}/SourceEditor.cs | 2 +- .../CodeBuffer}/TextFormatting.cs | 0 .../CodeBuffer}/Token.cs | 0 CrowIDE/src/{ => Editors}/EditPane.cs | 0 CrowIDE/src/{ => Editors}/Editor.cs | 2 +- CrowIDE/src/{ => Editors}/ImlVisualEditor.cs | 18 +++++- .../Parsers}/BufferParser.cs | 0 .../Parsers}/CSharpParser.cs | 0 .../Parsers}/StyleParser.cs | 0 .../Parsers}/XMLParser.cs | 0 CrowIDE/src/{ => Editors}/SvgEditor.cs | 0 CrowIDE/src/Extensions.cs | 3 + CrowIDE/src/GraphicObjectDesignContainer.cs | 2 +- CrowIDE/src/ProjectNodes.cs | 18 ++++-- CrowIDE/src/Solution.cs | 9 +++ CrowIDE/ui/ContextMenu.template | 42 +++++++++++++ CrowIDE/ui/CrowIDE.crow | 1 + CrowIDE/ui/DockWindows/winToolbox.crow | 6 +- CrowIDE/ui/GTreeExpITemp.crow | 33 +++++----- CrowIDE/ui/GTreeExplorer.crow | 38 ++++------- CrowIDE/ui/{ => editors}/EditPane.template | 0 CrowIDE/ui/editors/EditPaneItems.template | 11 ++++ CrowIDE/ui/{ => editors}/IMLEdit.itemp | 6 +- CrowIDE/ui/{ => editors}/SourceEditor.crow | 2 +- CrowIDE/ui/{ => editors}/SrcEdit.itemp | 0 .../SvgEdit.itemp} | 36 ++++------- Tests/OpenGL/Shader.cs | 6 +- Tests/OpenGL/Texture.cs | 2 +- src/BmpPicture.cs | 9 +-- src/CompilerServices/CompilerServices.cs | 20 ++++-- src/ExtensionsMethods.cs | 7 ++- src/GraphicObjects/GraphicObject.cs | 10 +-- src/GraphicObjects/Group.cs | 22 +++---- src/GraphicObjects/Image.cs | 6 +- src/GraphicObjects/TabItem.cs | 4 +- src/IML/IMLContext.cs | 39 +++++++++--- src/Instantiator.cs | 4 +- src/Interface.cs | 46 ++++++++++---- src/Picture.cs | 16 ++--- src/SvgPicture.cs | 4 +- src/XCursor.cs | 4 +- 49 files changed, 343 insertions(+), 185 deletions(-) rename CrowIDE/src/{SourceEditor => Editors/CodeBuffer}/CodeBuffer.cs (100%) rename CrowIDE/src/{SourceEditor => Editors/CodeBuffer}/CodeBufferEventArgs.cs (100%) rename CrowIDE/src/{SourceEditor => Editors/CodeBuffer}/CodeLine.cs (100%) rename CrowIDE/src/{SourceEditor => Editors/CodeBuffer}/Node.cs (100%) rename CrowIDE/src/{SourceEditor => Editors/CodeBuffer}/SourceEditor.cs (99%) rename CrowIDE/src/{SourceEditor => Editors/CodeBuffer}/TextFormatting.cs (100%) rename CrowIDE/src/{SourceEditor => Editors/CodeBuffer}/Token.cs (100%) rename CrowIDE/src/{ => Editors}/EditPane.cs (100%) rename CrowIDE/src/{ => Editors}/Editor.cs (99%) rename CrowIDE/src/{ => Editors}/ImlVisualEditor.cs (96%) rename CrowIDE/src/{SourceEditor => Editors/Parsers}/BufferParser.cs (100%) rename CrowIDE/src/{SourceEditor => Editors/Parsers}/CSharpParser.cs (100%) rename CrowIDE/src/{SourceEditor => Editors/Parsers}/StyleParser.cs (100%) rename CrowIDE/src/{SourceEditor => Editors/Parsers}/XMLParser.cs (100%) rename CrowIDE/src/{ => Editors}/SvgEditor.cs (100%) create mode 100644 CrowIDE/ui/ContextMenu.template rename CrowIDE/ui/{ => editors}/EditPane.template (100%) create mode 100644 CrowIDE/ui/editors/EditPaneItems.template rename CrowIDE/ui/{ => editors}/IMLEdit.itemp (92%) rename CrowIDE/ui/{ => editors}/SourceEditor.crow (97%) rename CrowIDE/ui/{ => editors}/SrcEdit.itemp (100%) rename CrowIDE/ui/{EditPaneItems.template => editors/SvgEdit.itemp} (53%) diff --git a/CrowIDE/CrowIDE.csproj b/CrowIDE/CrowIDE.csproj index 4f48ad0e..399e0d99 100644 --- a/CrowIDE/CrowIDE.csproj +++ b/CrowIDE/CrowIDE.csproj @@ -70,7 +70,6 @@ - @@ -94,36 +93,40 @@ src\InterfaceControler.cs - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + + + + @@ -141,10 +144,6 @@ Crow.TreeExpandable.template - - Crow.Coding.EditPane.template - - @@ -164,8 +163,6 @@ Crow.MenuItem.template - - @@ -255,7 +252,27 @@ - + + Crow.ContextMenu.template + + + Crow.Coding.EditPane.template + + + Crow.Coding.ui.EditPaneItems.template + + + Crow.Coding.ui.IMLEdit.itemp + + + Crow.Coding.ui.SourceEditor.crow + + + Crow.Coding.ui.SrcEdit.itemp + + + Crow.Coding.ui.SvgEdit.itemp + diff --git a/CrowIDE/icons/compile.svg b/CrowIDE/icons/compile.svg index 3f6ed2be..c1a14e77 100644 --- a/CrowIDE/icons/compile.svg +++ b/CrowIDE/icons/compile.svg @@ -2,8 +2,8 @@ - - - - + + + + diff --git a/CrowIDE/src/CrowIDE.cs b/CrowIDE/src/CrowIDE.cs index a5e8c249..588700b8 100644 --- a/CrowIDE/src/CrowIDE.cs +++ b/CrowIDE/src/CrowIDE.cs @@ -38,7 +38,7 @@ namespace Crow.Coding { class CrowIDE : CrowWindow { - public Command CMDNew, CMDOpen, CMDSave, CMDSaveAs, CMDQuit, + public Command CMDNew, CMDOpen, CMDSave, CMDSaveAs, cmdCloseSolution, CMDQuit, CMDUndo, CMDRedo, CMDCut, CMDCopy, CMDPaste, CMDHelp, CMDAbout, CMDOptions, CMDViewGTExp, CMDViewProps, CMDViewProj, CMDViewProjProps, CMDViewErrors, CMDViewSolution, CMDViewEditor, CMDViewProperties, @@ -59,6 +59,8 @@ namespace Crow.Coding CMDHelp = new Command(new Action(() => System.Diagnostics.Debug.WriteLine("help"))) { Caption = "Help", Icon = new SvgPicture("#Crow.Coding.ui.icons.question.svg")}; CMDOptions = new Command(new Action(() => openOptionsDialog())) { Caption = "Editor Options", Icon = new SvgPicture("#Crow.Coding.ui.icons.tools.svg")}; + cmdCloseSolution = new Command(new Action(() => closeSolution())) { Caption = "Close Solution", Icon = new SvgPicture("#Crow.Coding.ui.icons.paste-on-document.svg"), CanExecute = true}; + CMDViewErrors = new Command(new Action(() => loadDockWindow ("#Crow.Coding.ui.DockWindows.winErrors.crow"))) { Caption = "Errors pane"}; CMDViewSolution = new Command(new Action(() => loadDockWindow ("#Crow.Coding.ui.DockWindows.winSolution.crow"))) @@ -70,7 +72,7 @@ namespace Crow.Coding CMDViewToolbox = new Command(new Action(() => loadDockWindow ("#Crow.Coding.ui.DockWindows.winToolbox.crow"))) { Caption = "Toolbox"}; - CMDViewGTExp = new Command(new Action(() => loadWindow ("#Crow.Coding.ui.GTreeExplorer.crow"))) { Caption = "Graphic Tree Explorer"}; + CMDViewGTExp = new Command(new Action(() => loadDockWindow ("#Crow.Coding.ui.GTreeExplorer.crow"))) { Caption = "Graphic Tree Explorer"}; CMDViewProps = new Command(new Action(() => loadWindow ("#Crow.Coding.ui.MemberView.crow"))) { Caption = "Properties View"}; CMDCompile = new Command(new Action(() => compileSolution())) { Caption = "Compile"}; CMDViewProj = new Command(new Action(() => loadWindow ("#Crow.Coding.ui.CSProjExplorer.crow"))) { Caption = "Project Explorer"}; @@ -85,7 +87,11 @@ namespace Crow.Coding void saveFileDialog() {} void undo() {} void redo() {} - + void closeSolution (){ + if (currentSolution != null) + currentSolution.CloseSolution (); + CurrentSolution = null; + } [STAThread] static void Main () @@ -166,7 +172,9 @@ namespace Crow.Coding if (currentSolution == value) return; currentSolution = value; - NotifyValueChanged ("CurrentSolution", currentSolution); + lock (MainIFace) { + NotifyValueChanged ("CurrentSolution", currentSolution); + } } } diff --git a/CrowIDE/src/DesignInterface.cs b/CrowIDE/src/DesignInterface.cs index 3c1abf01..4178e398 100644 --- a/CrowIDE/src/DesignInterface.cs +++ b/CrowIDE/src/DesignInterface.cs @@ -29,6 +29,7 @@ using System.Globalization; using System.Threading; using System.Collections.Generic; using System.Diagnostics; +using System.IO; namespace Crow.Coding { @@ -80,6 +81,16 @@ namespace Crow.Coding System.Diagnostics.Debugger.Break (); return null; } + public override System.IO.Stream GetStreamFromPath (string path) + { + ProjectFile pi; + if (ProjFile.Project.solution.GetProjectFileFromPath (path, out pi)) { + return new FileStream (pi.AbsolutePath, FileMode.Open); + } + + Console.WriteLine ("File not found: {0}", path); + return null; + } public override bool ProcessMouseMove (int x, int y) { int deltaX = x - Mouse.X; @@ -171,7 +182,7 @@ namespace Crow.Coding LayoutingQueueItem lqi; while (LayoutingQueue.Count > 0) { lqi = LayoutingQueue.Dequeue (); - Console.WriteLine (lqi.ToString ()); + //Console.WriteLine (lqi.ToString ()); #if DEBUG_LAYOUTING currentLQI = lqi; curLQIsTries.Add(currentLQI); diff --git a/CrowIDE/src/SourceEditor/CodeBuffer.cs b/CrowIDE/src/Editors/CodeBuffer/CodeBuffer.cs similarity index 100% rename from CrowIDE/src/SourceEditor/CodeBuffer.cs rename to CrowIDE/src/Editors/CodeBuffer/CodeBuffer.cs diff --git a/CrowIDE/src/SourceEditor/CodeBufferEventArgs.cs b/CrowIDE/src/Editors/CodeBuffer/CodeBufferEventArgs.cs similarity index 100% rename from CrowIDE/src/SourceEditor/CodeBufferEventArgs.cs rename to CrowIDE/src/Editors/CodeBuffer/CodeBufferEventArgs.cs diff --git a/CrowIDE/src/SourceEditor/CodeLine.cs b/CrowIDE/src/Editors/CodeBuffer/CodeLine.cs similarity index 100% rename from CrowIDE/src/SourceEditor/CodeLine.cs rename to CrowIDE/src/Editors/CodeBuffer/CodeLine.cs diff --git a/CrowIDE/src/SourceEditor/Node.cs b/CrowIDE/src/Editors/CodeBuffer/Node.cs similarity index 100% rename from CrowIDE/src/SourceEditor/Node.cs rename to CrowIDE/src/Editors/CodeBuffer/Node.cs diff --git a/CrowIDE/src/SourceEditor/SourceEditor.cs b/CrowIDE/src/Editors/CodeBuffer/SourceEditor.cs similarity index 99% rename from CrowIDE/src/SourceEditor/SourceEditor.cs rename to CrowIDE/src/Editors/CodeBuffer/SourceEditor.cs index 14538135..e605dd55 100644 --- a/CrowIDE/src/SourceEditor/SourceEditor.cs +++ b/CrowIDE/src/Editors/CodeBuffer/SourceEditor.cs @@ -850,7 +850,7 @@ namespace Crow.Coding } #endregion - if (PrintedLines != null) { + if (PrintedLines?.Count > 0) { int unfoldedLines = buffer.UnfoldedLines; currentNode = null; CodeLine cl = PrintedLines[0]; diff --git a/CrowIDE/src/SourceEditor/TextFormatting.cs b/CrowIDE/src/Editors/CodeBuffer/TextFormatting.cs similarity index 100% rename from CrowIDE/src/SourceEditor/TextFormatting.cs rename to CrowIDE/src/Editors/CodeBuffer/TextFormatting.cs diff --git a/CrowIDE/src/SourceEditor/Token.cs b/CrowIDE/src/Editors/CodeBuffer/Token.cs similarity index 100% rename from CrowIDE/src/SourceEditor/Token.cs rename to CrowIDE/src/Editors/CodeBuffer/Token.cs diff --git a/CrowIDE/src/EditPane.cs b/CrowIDE/src/Editors/EditPane.cs similarity index 100% rename from CrowIDE/src/EditPane.cs rename to CrowIDE/src/Editors/EditPane.cs diff --git a/CrowIDE/src/Editor.cs b/CrowIDE/src/Editors/Editor.cs similarity index 99% rename from CrowIDE/src/Editor.cs rename to CrowIDE/src/Editors/Editor.cs index 41aa6069..88cab8e9 100644 --- a/CrowIDE/src/Editor.cs +++ b/CrowIDE/src/Editors/Editor.cs @@ -96,7 +96,7 @@ namespace Crow.Coding updateCheckPostProcess (); } } - Thread.Sleep (50); + Thread.Sleep (10); } } } diff --git a/CrowIDE/src/ImlVisualEditor.cs b/CrowIDE/src/Editors/ImlVisualEditor.cs similarity index 96% rename from CrowIDE/src/ImlVisualEditor.cs rename to CrowIDE/src/Editors/ImlVisualEditor.cs index d084904e..1ba6c559 100644 --- a/CrowIDE/src/ImlVisualEditor.cs +++ b/CrowIDE/src/Editors/ImlVisualEditor.cs @@ -177,14 +177,28 @@ namespace Crow.Coding } protected override bool EditorIsDirty { - get { return (bool)imlProjFile.Instance?.design_HasChanged; } + get { return imlProjFile == null ? false : + imlProjFile.Instance == null ? false : imlProjFile.Instance.design_HasChanged; } set { if (GraphicTree [0] != null) GraphicTree [0].design_HasChanged = value; } } protected override bool IsReady { - get { return imlVE != null && imlProjFile != null; } + get { return updateEnabled && imlVE != null && imlProjFile != null; } + } + bool updateEnabled; + /// + /// use to disable update if tab is not the visible one + /// + public bool UpdateEnabled { + get { return updateEnabled; } + set { + if (value == updateEnabled) + return; + updateEnabled = value; + NotifyValueChanged ("UpdateEnabled", updateEnabled); + } } protected override void updateCheckPostProcess () { diff --git a/CrowIDE/src/SourceEditor/BufferParser.cs b/CrowIDE/src/Editors/Parsers/BufferParser.cs similarity index 100% rename from CrowIDE/src/SourceEditor/BufferParser.cs rename to CrowIDE/src/Editors/Parsers/BufferParser.cs diff --git a/CrowIDE/src/SourceEditor/CSharpParser.cs b/CrowIDE/src/Editors/Parsers/CSharpParser.cs similarity index 100% rename from CrowIDE/src/SourceEditor/CSharpParser.cs rename to CrowIDE/src/Editors/Parsers/CSharpParser.cs diff --git a/CrowIDE/src/SourceEditor/StyleParser.cs b/CrowIDE/src/Editors/Parsers/StyleParser.cs similarity index 100% rename from CrowIDE/src/SourceEditor/StyleParser.cs rename to CrowIDE/src/Editors/Parsers/StyleParser.cs diff --git a/CrowIDE/src/SourceEditor/XMLParser.cs b/CrowIDE/src/Editors/Parsers/XMLParser.cs similarity index 100% rename from CrowIDE/src/SourceEditor/XMLParser.cs rename to CrowIDE/src/Editors/Parsers/XMLParser.cs diff --git a/CrowIDE/src/SvgEditor.cs b/CrowIDE/src/Editors/SvgEditor.cs similarity index 100% rename from CrowIDE/src/SvgEditor.cs rename to CrowIDE/src/Editors/SvgEditor.cs diff --git a/CrowIDE/src/Extensions.cs b/CrowIDE/src/Extensions.cs index 0d12fec8..05ef71e4 100644 --- a/CrowIDE/src/Extensions.cs +++ b/CrowIDE/src/Extensions.cs @@ -25,6 +25,9 @@ namespace Crow { public static partial class Extensions { + public static string GetIcon(this GraphicObject go){ + return "#Crow.Coding.icons.toolbox." + go.GetType().FullName + ".svg"; + } public static List GetChildren(this GraphicObject go){ Type goType = go.GetType(); if (typeof (Group).IsAssignableFrom (goType)) diff --git a/CrowIDE/src/GraphicObjectDesignContainer.cs b/CrowIDE/src/GraphicObjectDesignContainer.cs index c8e1a70f..e7776d26 100644 --- a/CrowIDE/src/GraphicObjectDesignContainer.cs +++ b/CrowIDE/src/GraphicObjectDesignContainer.cs @@ -52,7 +52,7 @@ namespace Crow.Coding go.IFace.DragImageHeight = dis; go.IFace.DragImageWidth = dis; SvgPicture pic = new SvgPicture (); - pic.Load (IconPath); + pic.Load (go.IFace, IconPath); ImageSurface img = new ImageSurface (Format.Argb32, dis, dis); using (Context ctx = new Context (img)) { Rectangle r = new Rectangle (0, 0, dis, dis); diff --git a/CrowIDE/src/ProjectNodes.cs b/CrowIDE/src/ProjectNodes.cs index f96ec5cd..1c4c8b26 100644 --- a/CrowIDE/src/ProjectNodes.cs +++ b/CrowIDE/src/ProjectNodes.cs @@ -200,15 +200,15 @@ namespace Crow.Coding : base (pi.Project, pi.node) { cmdSave = new Crow.Command (new Action (() => Save ())) - { Caption = "Save", Icon = new SvgPicture ("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false }; - cmdSave = new Crow.Command (new Action (() => SaveAs ())) - { Caption = "Save As ..", Icon = new SvgPicture ("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false }; + { Caption = "Save", Icon = new SvgPicture ("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false }; + cmdSaveAs = new Crow.Command (new Action (() => SaveAs ())) + { Caption = "Save As ..", Icon = new SvgPicture ("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false }; cmdOpen = new Crow.Command (new Action (() => Open ())) { Caption = "Open", Icon = new SvgPicture ("#Crow.Coding.ui.icons.outbox.svg"), CanExecute = false }; cmdUndo = new Crow.Command (new Action (() => Undo (null))) - { Caption = "Undo", Icon = new SvgPicture ("#Crow.Coding.icons.undo.svg"), CanExecute = false }; + { Caption = "Undo", Icon = new SvgPicture ("#Crow.Coding.icons.undo.svg"), CanExecute = false }; cmdRedo = new Crow.Command (new Action (() => Redo (null))) - { Caption = "Redo", Icon = new SvgPicture ("#Crow.Coding.icons.redo.svg"), CanExecute = false }; + { Caption = "Redo", Icon = new SvgPicture ("#Crow.Coding.icons.redo.svg"), CanExecute = false }; Commands.Insert (0, cmdOpen); Commands.Insert (1, cmdSave); @@ -453,6 +453,14 @@ namespace Crow.Coding NotifyValueChanged ("Instance", instance); } } + + public List GraphicTree { + get { return new List (new GraphicObject[] {instance}); } + } + + void GTView_SelectedItemChanged (object sender, SelectionChangeEventArgs e){ + SelectedItem = e.NewValue; + } } } diff --git a/CrowIDE/src/Solution.cs b/CrowIDE/src/Solution.cs index fb4bcbfa..1b89dc09 100644 --- a/CrowIDE/src/Solution.cs +++ b/CrowIDE/src/Solution.cs @@ -214,6 +214,15 @@ namespace Crow.Coding{ saveOpenedItemsInUserConfig (); } + public void CloseSolution () { + while (openedItems.Count > 0) { + openedItems.RemoveElement (openedItems [0]); + } + while (toolboxItems.Count > 0) { + toolboxItems.RemoveElement (toolboxItems [0]); + } + NotifyValueChanged ("Projects", null); + } /// /// Solution name /// diff --git a/CrowIDE/ui/ContextMenu.template b/CrowIDE/ui/ContextMenu.template new file mode 100644 index 00000000..2b03d1f2 --- /dev/null +++ b/CrowIDE/ui/ContextMenu.template @@ -0,0 +1,42 @@ + + + + + + + + + + diff --git a/CrowIDE/ui/CrowIDE.crow b/CrowIDE/ui/CrowIDE.crow index 02aa6fd8..94a57e71 100644 --- a/CrowIDE/ui/CrowIDE.crow +++ b/CrowIDE/ui/CrowIDE.crow @@ -5,6 +5,7 @@ + diff --git a/CrowIDE/ui/DockWindows/winToolbox.crow b/CrowIDE/ui/DockWindows/winToolbox.crow index d6b1bd4c..9059c7a4 100644 --- a/CrowIDE/ui/DockWindows/winToolbox.crow +++ b/CrowIDE/ui/DockWindows/winToolbox.crow @@ -1,8 +1,8 @@  - + - + diff --git a/CrowIDE/ui/GTreeExpITemp.crow b/CrowIDE/ui/GTreeExpITemp.crow index 4be4f094..d3447366 100644 --- a/CrowIDE/ui/GTreeExpITemp.crow +++ b/CrowIDE/ui/GTreeExpITemp.crow @@ -1,28 +1,29 @@  - + - - + + diff --git a/CrowIDE/ui/GTreeExplorer.crow b/CrowIDE/ui/GTreeExplorer.crow index b62b02a1..a4d5f727 100644 --- a/CrowIDE/ui/GTreeExplorer.crow +++ b/CrowIDE/ui/GTreeExplorer.crow @@ -1,30 +1,18 @@  - - + +