diff options
| author | j-p <jp.bruyere@live.be> | 2018-12-11 23:20:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-11 23:20:54 +0100 |
| commit | d7239eebe4b07685aabaf6663bebbc77386286ea (patch) | |
| tree | 836cee695262dc2fc3f1219de385752177893ed2 /CrowIDE/src | |
| parent | f1531e562b4ecd9d568a28c2fffe7ffed06c728a (diff) | |
| parent | 7e831f8ebac4affbb01211b1f6ec3887280fea2b (diff) | |
Merge pull request #44 from jpbruyere/xlib
Xlib
Diffstat (limited to 'CrowIDE/src')
| -rw-r--r-- | CrowIDE/src/CrowIDE.cs | 127 | ||||
| -rw-r--r-- | CrowIDE/src/DesignInterface.cs | 34 | ||||
| -rw-r--r-- | CrowIDE/src/Editors/CodeBuffer/TextEditor.cs | 58 | ||||
| -rw-r--r-- | CrowIDE/src/Editors/Editor.cs | 21 | ||||
| -rw-r--r-- | CrowIDE/src/Editors/ImlVisualEditor.cs | 45 | ||||
| -rw-r--r-- | CrowIDE/src/Editors/SourceEditor.cs | 85 | ||||
| -rw-r--r-- | CrowIDE/src/Editors/SvgEditor.cs | 3 | ||||
| -rw-r--r-- | CrowIDE/src/Extensions.cs | 2 | ||||
| -rw-r--r-- | CrowIDE/src/GraphicObjectDesignContainer.cs | 6 | ||||
| -rw-r--r-- | CrowIDE/src/MemberView/PropertyContainer.cs | 2 | ||||
| -rw-r--r-- | CrowIDE/src/Project.cs | 28 | ||||
| -rw-r--r-- | CrowIDE/src/ProjectTree/ProjectFile.cs | 66 | ||||
| -rw-r--r-- | CrowIDE/src/ProjectTree/ProjectItem.cs | 45 | ||||
| -rw-r--r-- | CrowIDE/src/ProjectTree/ProjectNodes.cs | 25 | ||||
| -rw-r--r-- | CrowIDE/src/Solution.cs | 45 |
15 files changed, 364 insertions, 228 deletions
diff --git a/CrowIDE/src/CrowIDE.cs b/CrowIDE/src/CrowIDE.cs index 46a926e3..9d643a9a 100644 --- a/CrowIDE/src/CrowIDE.cs +++ b/CrowIDE/src/CrowIDE.cs @@ -20,8 +20,6 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. using System; -using OpenTK; -using OpenTK.Graphics.OpenGL; using Crow; using System.Reflection; using System.Collections.Generic; @@ -36,7 +34,7 @@ using System.Threading; namespace Crow.Coding { - class CrowIDE : CrowWindow + class CrowIDE : Interface { public Command CMDNew, CMDOpen, CMDSave, CMDSaveAs, cmdCloseSolution, CMDQuit, CMDUndo, CMDRedo, CMDCut, CMDCopy, CMDPaste, CMDHelp, @@ -46,21 +44,21 @@ namespace Crow.Coding CMDCompile; void initCommands () { - CMDNew = new Command(new Action(() => newFile())) { Caption = "New", Icon = new SvgPicture("#Crow.Coding.ui.icons.blank-file.svg"), CanExecute = true}; - CMDOpen = new Command(new Action(() => openFileDialog())) { Caption = "Open...", Icon = new SvgPicture("#Crow.Coding.ui.icons.outbox.svg")}; - CMDSave = new Command(new Action(() => saveFileDialog())) { Caption = "Save", Icon = new SvgPicture("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false}; - CMDSaveAs = new Command(new Action(() => saveFileDialog())) { Caption = "Save As...", Icon = new SvgPicture("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false}; - CMDQuit = new Command(new Action(() => Quit (null, null))) { Caption = "Quit", Icon = new SvgPicture("#Crow.Coding.ui.icons.sign-out.svg")}; - CMDUndo = new Command(new Action(() => undo())) { Caption = "Undo", Icon = new SvgPicture("#Crow.Coding.icons.undo.svg"), CanExecute = false}; - CMDRedo = new Command(new Action(() => redo())) { Caption = "Redo", Icon = new SvgPicture("#Crow.Coding.icons.redo.svg"), CanExecute = false}; - CMDCut = new Command(new Action(() => Quit (null, null))) { Caption = "Cut", Icon = new SvgPicture("#Crow.Coding.icons.scissors.svg"), CanExecute = false}; - CMDCopy = new Command(new Action(() => Quit (null, null))) { Caption = "Copy", Icon = new SvgPicture("#Crow.Coding.icons.copy-file.svg"), CanExecute = false}; - CMDPaste = new Command(new Action(() => Quit (null, null))) { Caption = "Paste", Icon = new SvgPicture("#Crow.Coding.icons.paste-on-document.svg"), CanExecute = false}; - CMDHelp = new Command(new Action(() => System.Diagnostics.Debug.WriteLine("help"))) { Caption = "Help", Icon = new SvgPicture("#Crow.Coding.icons.question.svg")}; - CMDOptions = new Command(new Action(() => loadWindow("#Crow.Coding.ui.Options.crow"))) { Caption = "Editor Options", Icon = new SvgPicture("#Crow.Coding.icons.tools.svg")}; + CMDNew = new Command(new Action(() => newFile())) { Caption = "New", Icon = new SvgPicture("#icons.blank-file.svg"), CanExecute = true}; + CMDOpen = new Command(new Action(() => openFileDialog())) { Caption = "Open...", Icon = new SvgPicture("#icons.open.svg") }; + CMDSave = new Command(new Action(() => saveFileDialog())) { Caption = "Save", Icon = new SvgPicture("#icons.save.svg"), CanExecute = false}; + CMDSaveAs = new Command(new Action(() => saveFileDialog())) { Caption = "Save As...", Icon = new SvgPicture("#icons.save.svg"), CanExecute = false}; + CMDQuit = new Command(new Action(() => app.running = false)) { Caption = "Quit", Icon = new SvgPicture("#icons.sign-out.svg") }; + CMDUndo = new Command(new Action(() => undo())) { Caption = "Undo", Icon = new SvgPicture("#icons.undo.svg"), CanExecute = false}; + CMDRedo = new Command(new Action(() => redo())) { Caption = "Redo", Icon = new SvgPicture("#icons.redo.svg"), CanExecute = false}; + //CMDCut = new Command(new Action(() => Quit (null, null))) { Caption = "Cut", Icon = new SvgPicture("#icons.scissors.svg"), CanExecute = false}; + //CMDCopy = new Command(new Action(() => Quit (null, null))) { Caption = "Copy", Icon = new SvgPicture("#icons.copy-file.svg"), CanExecute = false}; + //CMDPaste = new Command(new Action(() => Quit (null, null))) { Caption = "Paste", Icon = new SvgPicture("#icons.paste-on-document.svg"), CanExecute = false}; + CMDHelp = new Command(new Action(() => System.Diagnostics.Debug.WriteLine("help"))) { Caption = "Help", Icon = new SvgPicture("#icons.question.svg") }; + CMDOptions = new Command(new Action(() => loadWindow("#Crow.Coding.ui.Options.crow"))) { Caption = "Editor Options", Icon = new SvgPicture("#icons.tools.svg") }; cmdCloseSolution = new Command(new Action(() => closeSolution())) - { Caption = "Close Solution", Icon = new SvgPicture("#Crow.Coding.ui.icons.paste-on-document.svg"), CanExecute = false}; + { Caption = "Close Solution", Icon = new SvgPicture("#icons.paste-on-document.svg"), CanExecute = false}; CMDViewErrors = new Command(new Action(() => loadWindow ("#Crow.Coding.ui.DockWindows.winErrors.crow",this))) { Caption = "Errors pane"}; @@ -103,16 +101,49 @@ namespace Crow.Coding CurrentSolution = null; } + public void saveWinConfigs() { + Configuration.Global.Set ("WinConfigs", mainDock.ExportConfig ()); + Configuration.Global.Save (); + } + public void reloadWinConfigs() { + string conf = Configuration.Global.Get<string>("WinConfigs"); + if (string.IsNullOrEmpty (conf)) + return; + mainDock.ImportConfig (conf, this); + } + + static CrowIDE app; [STAThread] static void Main () { - CrowIDE win = new CrowIDE (); - MainWin = win; - win.Run (30); + using (app = new CrowIDE ()) { + MainIFace = app; + + //app.Keyboard.KeyDown += App_KeyboardKeyDown; + app.initIde (); + + app.reloadWinConfigs (); + + app.Run (); + + app.saveWinConfigs (); + } + } + + static void App_KeyboardKeyDown (object sender, KeyEventArgs e) + { + Console.WriteLine((byte)e.Key); + //#if DEBUG_LOG + /*switch (e.Key) { + case Key.F2: + DebugLog.save (app); + break; + }*/ + //#endif } public CrowIDE () - : base(1024, 800,"UIEditor") + : base(1024, 800) { } @@ -124,21 +155,18 @@ namespace Crow.Coding public static Interface MainIFace; public static CrowIDE MainWin; - protected override void OnLoad (EventArgs e) - { - base.OnLoad (e); + void initIde() { - initCommands (); + foreach (string s in System.Reflection.Assembly.GetEntryAssembly().GetManifestResourceNames()) + { + Console.WriteLine(s); + } - this.KeyDown += CrowIDE_KeyDown; + initCommands (); - //this.CrowInterface.LoadInterface ("#Crow.Coding.ui.imlEditor.crow").DataSource = this; - //GraphicObject go = this.CrowInterface.LoadInterface (@"ui/test.crow"); GraphicObject go = AddWidget (@"#Crow.Coding.ui.CrowIDE.crow"); go.DataSource = this; - MainIFace = ifaceControl[0].CrowInterface; - mainDock = go.FindByName ("mainDock") as DockStack; if (ReopenLastSolution && !string.IsNullOrEmpty (LastOpenSolution)) { @@ -150,7 +178,7 @@ namespace Crow.Coding instFileDlg = Instantiator.CreateFromImlFragment (MainIFace, "<FileDialog Caption='Open File' CurrentDirectory='{²CurrentDirectory}' SearchPattern='*.sln' OkClicked='onFileOpen'/>"); - DockWindow dw = loadWindow ("#Crow.Coding.ui.DockWindows.winEditor.crow", this) as DockWindow; + /*DockWindow dw = loadWindow ("#Crow.Coding.ui.DockWindows.winEditor.crow", this) as DockWindow; dw.DockingPosition = Alignment.Center; dw.Dock (mainDock); dw = loadWindow ("#Crow.Coding.ui.DockWindows.winSolution.crow", this) as DockWindow; @@ -158,8 +186,9 @@ namespace Crow.Coding dw.Dock (mainDock); dw = loadWindow ("#Crow.Coding.ui.DockWindows.winToolbox.crow", this) as DockWindow; dw.DockingPosition = Alignment.Left; - dw.Dock (mainDock); + dw.Dock (mainDock);*/ + //Console.WriteLine (); } void loadProjProps () { @@ -249,40 +278,6 @@ namespace Crow.Coding } } - void CrowIDE_KeyDown (object sender, OpenTK.Input.KeyboardKeyEventArgs e) - { -// if (e.Key == OpenTK.Input.Key.Escape) { -// Quit (null, null); -// } else - if (e.Key == OpenTK.Input.Key.F5) { - try { - CurrentSolution.StartupProject.Compile (); - } catch (Exception ex) { - Console.WriteLine (ex.ToString ()); - } - - }// else if (e.Key == OpenTK.Input.Key.F6) { -// loadWindow ("#Crow.Coding.ui.LQIsExplorer.crow"); -// } else if (e.Key == OpenTK.Input.Key.F7) { -// loadWindow ("#Crow.Coding.ui.CSProjExplorer.crow"); -// } - } -// DockWindow loadDockWindow(string path){ -// lock (MainIFace.UpdateMutex) { -// GraphicObject g = MainIFace.FindByName (path); -// if (g == null){ -// try { -// g = MainIFace.Load (path); -// mainDock.AddChild (g); -// g.Name = path; -// g.DataSource = CurrentSolution; -// } catch (Exception ex) { -// System.Diagnostics.Debug.WriteLine (ex.ToString ()); -// } -// } -// return g as DockWindow; -// } -// } Window loadWindow(string path, object dataSource = null){ try { GraphicObject g = MainIFace.FindByName (path); @@ -293,7 +288,7 @@ namespace Crow.Coding g.DataSource = dataSource; return g as Window; } catch (Exception ex) { - System.Diagnostics.Debug.WriteLine (ex.ToString ()); + Console.WriteLine (ex.ToString ()); } return null; } diff --git a/CrowIDE/src/DesignInterface.cs b/CrowIDE/src/DesignInterface.cs index 04666b11..7d9b8ad8 100644 --- a/CrowIDE/src/DesignInterface.cs +++ b/CrowIDE/src/DesignInterface.cs @@ -30,6 +30,7 @@ using System.Threading; using System.Collections.Generic; using System.Diagnostics; using System.IO; +using Cairo; namespace Crow.Coding { @@ -53,17 +54,44 @@ namespace Crow.Coding } #endregion - public DesignInterface () + public DesignInterface () : base() { } public ProjectFile ProjFile; + + protected override void InitBackend () + { + surf = new ImageSurface(Format.Argb32, 100, 100); + } + public override void ProcessResize (Rectangle bounds) + { + if (bounds == clientRectangle) + return; + lock (UpdateMutex) { + clientRectangle = bounds; + surf.Dispose (); + surf = new ImageSurface(Format.Argb32, clientRectangle.Width, clientRectangle.Height); + + foreach (GraphicObject g in GraphicTree) + g.RegisterForLayouting (LayoutingType.All); + + RegisterClip (clientRectangle); + } + + } public override GraphicObject Load (string path) { ProjectFile pi; - if (ProjFile.Project.solution.GetProjectFileFromPath (path, out pi)) - return CreateITorFromIMLFragment (pi.Source).CreateInstance(); + try { + + if (ProjFile.Project.solution.GetProjectFileFromPath (path, out pi)) + return CreateITorFromIMLFragment (pi.Source).CreateInstance(); + } catch (Exception ex) { + + } + return null; } public override System.IO.Stream GetStreamFromPath (string path) diff --git a/CrowIDE/src/Editors/CodeBuffer/TextEditor.cs b/CrowIDE/src/Editors/CodeBuffer/TextEditor.cs index 6b7234dc..3faa15f1 100644 --- a/CrowIDE/src/Editors/CodeBuffer/TextEditor.cs +++ b/CrowIDE/src/Editors/CodeBuffer/TextEditor.cs @@ -230,7 +230,7 @@ namespace Crow.Text } } } - [DefaultValue("BlueGray")] + [DefaultValue("Blue")] public virtual Color SelectionBackground { get { return selBackground; } set { @@ -524,20 +524,20 @@ namespace Crow.Text #endregion #region Keyboard handling - public override void onKeyDown (object sender, KeyboardKeyEventArgs e) + public override void onKeyDown (object sender, KeyEventArgs e) { //base.onKeyDown (sender, e); Key key = e.Key; - if (e.Control) { + if (IFace.Ctrl) { switch (key) { case Key.S: projFile.Save (); break; case Key.W: editorMutex.EnterWriteLock (); - if (e.Shift) + if (IFace.Shift) projFile.Redo (null); else projFile.Undo (null); @@ -551,7 +551,7 @@ namespace Crow.Text switch (key) { - case Key.Back: + case Key.BackSpace: buffer.Delete (); break; case Key.Clear: @@ -563,8 +563,8 @@ namespace Crow.Text // IFace.Clipboard = buffer.SelectedText; buffer.Delete (); break; - case Key.Enter: - case Key.KeypadEnter: + case Key.ISO_Enter: + case Key.KP_Enter: if (!buffer.SelectionIsEmpty) buffer.Delete (); buffer.InsertLineBreak (); @@ -573,46 +573,46 @@ namespace Crow.Text buffer.ResetSelection (); break; case Key.Home: - if (e.Shift) { + if (IFace.Shift) { if (buffer.SelectionIsEmpty) buffer.SetSelStartPos (); - if (e.Control) + if (IFace.Ctrl) buffer.CurrentLine = 0; buffer.CurrentColumn = 0; buffer.SetSelEndPos (); break; } buffer.ResetSelection (); - if (e.Control) + if (IFace.Ctrl) buffer.CurrentLine = 0; buffer.CurrentColumn = 0; break; case Key.End: - if (e.Shift) { + if (IFace.Shift) { if (buffer.SelectionIsEmpty) buffer.SetSelStartPos (); - if (e.Control) + if (IFace.Ctrl) buffer.CurrentLine = int.MaxValue; buffer.CurrentColumn = int.MaxValue; buffer.SetSelEndPos (); break; } buffer.ResetSelection (); - if (e.Control) + if (IFace.Ctrl) buffer.CurrentLine = int.MaxValue; buffer.CurrentColumn = int.MaxValue; break; case Key.Insert: - if (e.Shift) + if (IFace.Shift) buffer.InsertAt (IFace.Clipboard); - else if (e.Control && !buffer.SelectionIsEmpty) + else if (IFace.Ctrl && !buffer.SelectionIsEmpty) IFace.Clipboard = buffer.SelectedText; break; case Key.Left: - if (e.Shift) { + if (IFace.Shift) { if (buffer.SelectionIsEmpty) buffer.SetSelStartPos (); - if (e.Control) + if (IFace.Ctrl) buffer.GotoWordStart (); else buffer.MoveLeft (); @@ -620,16 +620,16 @@ namespace Crow.Text break; } buffer.ResetSelection (); - if (e.Control) + if (IFace.Ctrl) buffer.GotoWordStart (); else buffer.MoveLeft(); break; case Key.Right: - if (e.Shift) { + if (IFace.Shift) { if (buffer.SelectionIsEmpty) buffer.SetSelStartPos (); - if (e.Control) + if (IFace.Ctrl) buffer.GotoWordEnd (); else buffer.MoveRight (); @@ -637,13 +637,13 @@ namespace Crow.Text break; } buffer.ResetSelection (); - if (e.Control) + if (IFace.Ctrl) buffer.GotoWordEnd (); else buffer.MoveRight (); break; case Key.Up: - if (e.Shift) { + if (IFace.Shift) { if (buffer.SelectionIsEmpty) buffer.SetSelStartPos (); CurrentLine--; @@ -654,7 +654,7 @@ namespace Crow.Text CurrentLine--; break; case Key.Down: - if (e.Shift) { + if (IFace.Shift) { if (buffer.SelectionIsEmpty) buffer.SetSelStartPos (); CurrentLine++; @@ -666,10 +666,10 @@ namespace Crow.Text break; case Key.Menu: break; - case Key.NumLock: + case Key.Num_Lock: break; - case Key.PageDown: - if (e.Shift) { + case Key.Page_Down: + if (IFace.Shift) { if (buffer.SelectionIsEmpty) buffer.SetSelStartPos (); CurrentLine += visibleLines; @@ -679,8 +679,8 @@ namespace Crow.Text buffer.ResetSelection (); CurrentLine += visibleLines; break; - case Key.PageUp: - if (e.Shift) { + case Key.Page_Up: + if (IFace.Shift) { if (buffer.SelectionIsEmpty) buffer.SetSelStartPos (); CurrentLine -= visibleLines; @@ -690,8 +690,6 @@ namespace Crow.Text buffer.ResetSelection (); CurrentLine -= visibleLines; break; - case Key.RWin: - break; case Key.Tab: buffer.InsertAt ("\t"); break; diff --git a/CrowIDE/src/Editors/Editor.cs b/CrowIDE/src/Editors/Editor.cs index 2cd34412..102debb5 100644 --- a/CrowIDE/src/Editors/Editor.cs +++ b/CrowIDE/src/Editors/Editor.cs @@ -84,17 +84,20 @@ namespace Crow.Coding protected void backgroundThreadFunc () { while (true) { - if (IsReady) { - if (!projFile.RegisteredEditors [this]) { - projFile.RegisteredEditors [this] = true; - updateEditorFromProjFile (); - } else if (EditorIsDirty) { - EditorIsDirty = false; - updateProjFileFromEditor (); + if (IsReady) { + if (Monitor.TryEnter (IFace.UpdateMutex)) { + if (!projFile.RegisteredEditors [this]) { + projFile.RegisteredEditors [this] = true; + updateEditorFromProjFile (); + } else if (EditorIsDirty) { + EditorIsDirty = false; + updateProjFileFromEditor (); + } + updateCheckPostProcess (); + Monitor.Exit (IFace.UpdateMutex); } - updateCheckPostProcess (); } - Thread.Sleep (10); + Thread.Sleep (100); } } } diff --git a/CrowIDE/src/Editors/ImlVisualEditor.cs b/CrowIDE/src/Editors/ImlVisualEditor.cs index b1759fbc..225d3ae9 100644 --- a/CrowIDE/src/Editors/ImlVisualEditor.cs +++ b/CrowIDE/src/Editors/ImlVisualEditor.cs @@ -67,18 +67,18 @@ namespace Crow.Coding void initCommands () { cmdDelete = new Crow.Command (new Action (() => deleteObject (SelectedItem))) - { Caption = "Delete", Icon = new SvgPicture ("#Crow.Coding.icons.save.svg"), CanExecute = true }; + { Caption = "Delete", Icon = new SvgPicture ("#icons.save.svg"), CanExecute = true }; Commands = new List<Crow.Command> (new Crow.Command[] { cmdDelete }); } void initIcons () { - icoMove = new SvgPicture (); - icoMove.Load (IFace, "#Crow.Coding.icons.move-arrows.svg"); -// icoStyle = new SvgPicture (); -// icoStyle.Load (IFace, "#Crow.Coding.icons.palette.svg"); - } + icoMove = new SvgPicture ("#icons.move-arrows.svg"); - [DefaultValue(true)] + // icoStyle = new SvgPicture (); + // icoStyle.Load (IFace, "#icons.palette.svg"); + } + + [DefaultValue(true)] public bool DrawGrid { get { return drawGrid; } set { @@ -279,8 +279,6 @@ namespace Crow.Coding SelectedItem = go; } catch (Exception ex) { Error = ex; - if (Monitor.IsEntered(imlVE.UpdateMutex)) - Monitor.Exit (imlVE.UpdateMutex); } } protected override void updateCheckPostProcess () @@ -295,9 +293,9 @@ namespace Crow.Coding lock (imlVE.RenderMutex) isDirty = imlVE.IsDirty; - if (isDirty) { + if (isDirty) { lock (IFace.UpdateMutex) - RegisterForRedraw (); + RegisterForRedraw (); } } #endregion @@ -308,7 +306,11 @@ namespace Crow.Coding base.OnLayoutChanges (layoutType); switch (layoutType) { case LayoutingType.Width: + DesignWidth = Slot.Width * 100 / zoom; + imlVE.ProcessResize (new Size(designWidth,designHeight)); + break; case LayoutingType.Height: + DesignHeight = Slot.Height * 100 / zoom; imlVE.ProcessResize (new Size(designWidth,designHeight)); break; } @@ -323,6 +325,8 @@ namespace Crow.Coding ProcessMouseMove (e.X - scr.X, e.Y - scr.Y); GraphicObject newHW = HoverWidget; + if (newHW == null) + return; if (draggedObj != null) { if (draggedObj.Parent == null) { @@ -354,7 +358,7 @@ namespace Crow.Coding if (oldHW == newHW) return; - RegisterForRedraw (); + //RegisterForRedraw (); } public override void onMouseEnter (object sender, MouseMoveEventArgs e) @@ -388,7 +392,7 @@ namespace Crow.Coding { base.onDraw (gr); - Rectangle cb = new Rectangle (0, 0, designWidth, designHeight);// ClientRectangle; + Rectangle cb = new Rectangle (0, 0, designWidth, designHeight); gr.Save (); @@ -419,14 +423,11 @@ namespace Crow.Coding } lock (imlVE.RenderMutex) { - using (Cairo.Surface surf = new Cairo.ImageSurface (imlVE.bmp, Cairo.Format.Argb32, - imlVE.ClientRectangle.Width, imlVE.ClientRectangle.Height, imlVE.ClientRectangle.Width * 4)) { - gr.SetSourceSurface (surf, cb.Left, cb.Top); - gr.Paint (); - } + gr.SetSourceSurface (imlVE.surf, cb.Left, cb.Top); + gr.Paint (); imlVE.IsDirty = false; } - if (Error == null) { + /*if (Error == null) { gr.SetSourceColor (Color.Black); gr.Rectangle (cb, 1.0 / z); } else { @@ -441,7 +442,7 @@ namespace Crow.Coding } } - gr.Stroke (); + gr.Stroke ();*/ Rectangle hr; @@ -557,7 +558,7 @@ namespace Crow.Coding // hr.Inflate (2); //gr.SetDash (new double[]{ 1.0, 4.0 }, 0.0); - //gr.SetSourceColor (Color.Gray); + //gr.SetSourceColor (Color.Grey); // gr.Rectangle (hr,coteStroke); // gr.Stroke (); gr.Operator = Operator.Over; @@ -886,7 +887,7 @@ namespace Crow.Coding } - public override void onKeyDown (object sender, KeyboardKeyEventArgs e) + public override void onKeyDown (object sender, KeyEventArgs e) { switch (e.Key) { diff --git a/CrowIDE/src/Editors/SourceEditor.cs b/CrowIDE/src/Editors/SourceEditor.cs index 4234a683..0be5cfc6 100644 --- a/CrowIDE/src/Editors/SourceEditor.cs +++ b/CrowIDE/src/Editors/SourceEditor.cs @@ -47,7 +47,7 @@ namespace Crow.Coding #region CTOR public SourceEditor (): base() { - formatting.Add ((int)XMLParser.TokenType.AttributeName, new TextFormatting (Color.DarkSlateGray, Color.Transparent)); + formatting.Add ((int)XMLParser.TokenType.AttributeName, new TextFormatting (Color.DarkSlateGrey, Color.Transparent)); formatting.Add ((int)XMLParser.TokenType.ElementName, new TextFormatting (Color.DarkBlue, Color.Transparent)); formatting.Add ((int)XMLParser.TokenType.ElementStart, new TextFormatting (Color.Black, Color.Transparent)); formatting.Add ((int)XMLParser.TokenType.ElementEnd, new TextFormatting (Color.Black, Color.Transparent)); @@ -58,8 +58,8 @@ namespace Crow.Coding formatting.Add ((int)XMLParser.TokenType.AttributeValue, new TextFormatting (Color.FireBrick, Color.Transparent, false, true)); formatting.Add ((int)XMLParser.TokenType.XMLDecl, new TextFormatting (Color.ForestGreen, Color.Transparent)); - formatting.Add ((int)BufferParser.TokenType.BlockComment, new TextFormatting (Color.Gray, Color.Transparent, false, true)); - formatting.Add ((int)BufferParser.TokenType.LineComment, new TextFormatting (Color.Gray, Color.Transparent, false, true)); + formatting.Add ((int)BufferParser.TokenType.BlockComment, new TextFormatting (Color.Grey, Color.Transparent, false, true)); + formatting.Add ((int)BufferParser.TokenType.LineComment, new TextFormatting (Color.Grey, Color.Transparent, false, true)); formatting.Add ((int)BufferParser.TokenType.OperatorOrPunctuation, new TextFormatting (Color.Black, Color.Transparent)); formatting.Add ((int)BufferParser.TokenType.Keyword, new TextFormatting (Color.Teal, Color.Transparent)); //formatting.Add ((int)BufferParser.TokenType.Keyword, new TextFormatting (Color.DarkCyan, Color.Transparent)); @@ -324,7 +324,7 @@ namespace Crow.Coding } void Buffer_PositionChanged (object sender, EventArgs e) { - Console.WriteLine ("Position changes: ({0},{1})", buffer.CurrentLine, buffer.CurrentColumn); + //Console.WriteLine ("Position changes: ({0},{1})", buffer.CurrentLine, buffer.CurrentColumn); int cc = buffer.CurrentTabulatedColumn; if (cc > visibleColumns + ScrollX) { @@ -554,7 +554,7 @@ namespace Crow.Coding double y = cb.Y + (fe.Ascent+fe.Descent) * i, x = cb.X; //Draw line numbering - Color mgFg = Color.Gray; + Color mgFg = Color.Grey; Color mgBg = Color.White; if (PrintLineNumbers){ Rectangle mgR = new Rectangle ((int)x, (int)y, leftMargin - leftMarginGap, (int)Math.Ceiling((fe.Ascent+fe.Descent))); @@ -563,10 +563,10 @@ namespace Crow.Coding if (buffer.CurrentLine == lineIndex) mgFg = Color.White; else - mgFg = Color.LightGray; + mgFg = Color.LightGrey; }else if (buffer.CurrentLine == lineIndex) { mgFg = Color.Black; - mgBg = Color.DarkGray; + mgBg = Color.DarkGrey; } string strLN = (lineIndex+1).ToString (); gr.SetSourceColor (mgBg); @@ -614,7 +614,7 @@ namespace Crow.Coding closingNode = false; } gr.SetDash (new double[]{ 1.5 },0.0); - gr.SetSourceColor (Color.Gray); + gr.SetSourceColor (Color.Grey); gr.Stroke (); gr.SetDash (new double[]{}, 0.0); @@ -900,9 +900,12 @@ namespace Crow.Coding } } void updateHoverLine () { - int hvl = (int)Math.Max (0, Math.Floor (mouseLocalPos.Y / (fe.Ascent+fe.Descent))); - hvl = Math.Min (PrintedLines.Count, hvl); - HoverLine = buffer.IndexOf (PrintedLines[hvl]); + if (PrintedLines.Count > 0) { + int hvl = (int)Math.Max (0, Math.Floor (mouseLocalPos.Y / (fe.Ascent + fe.Descent))); + hvl = Math.Min (PrintedLines.Count - 1, hvl); + HoverLine = buffer.IndexOf (PrintedLines [hvl]); + } else + HoverLine = 0; } void updateCurrentPosFromMouseLocalPos(){ PrintedCurrentLine = (int)Math.Max (0, Math.Floor (mouseLocalPos.Y / (fe.Ascent+fe.Descent))); @@ -1002,20 +1005,20 @@ namespace Crow.Coding #endregion #region Keyboard handling - public override void onKeyDown (object sender, KeyboardKeyEventArgs e) + public override void onKeyDown (object sender, KeyEventArgs e) { //base.onKeyDown (sender, e); Key key = e.Key; - if (e.Control) { + if (IFace.Ctrl) { switch (key) { case Key.S: projFile.Save (); break; case Key.W: editorMutex.EnterWriteLock (); - if (e.Shift) + if (IFace.Shift) projFile.Redo (null); else projFile.Undo (null); @@ -1029,7 +1032,7 @@ namespace Crow.Coding switch (key) { - case Key.Back: + case Key.BackSpace: buffer.DeleteChar (); break; case Key.Clear: @@ -1037,12 +1040,12 @@ namespace Crow.Coding case Key.Delete: if (buffer.SelectionIsEmpty) MoveRight (); - else if (e.Shift) + else if (IFace.Shift) IFace.Clipboard = buffer.SelectedText; buffer.DeleteChar (); break; - case Key.Enter: - case Key.KeypadEnter: + case Key.Return: + case Key.KP_Enter: if (!buffer.SelectionIsEmpty) buffer.DeleteChar (); buffer.InsertLineBreak (); @@ -1051,46 +1054,46 @@ namespace Crow.Coding buffer.ResetSelection (); break; case Key.Home: - if (e.Shift) { + if (IFace.Shift) { if (buffer.SelectionIsEmpty) buffer.SetSelStartPos (); - if (e.Control) + if (IFace.Ctrl) buffer.CurrentLine = 0; buffer.CurrentColumn = 0; buffer.SetSelEndPos (); break; } buffer.ResetSelection (); - if (e.Control) + if (IFace.Ctrl) buffer.CurrentLine = 0; buffer.CurrentColumn = 0; break; case Key.End: - if (e.Shift) { + if (IFace.Shift) { if (buffer.SelectionIsEmpty) buffer.SetSelStartPos (); - if (e.Control) + if (IFace.Ctrl) buffer.CurrentLine = int.MaxValue; buffer.CurrentColumn = int.MaxValue; buffer.SetSelEndPos (); break; } buffer.ResetSelection (); - if (e.Control) + if (IFace.Ctrl) buffer.CurrentLine = int.MaxValue; buffer.CurrentColumn = int.MaxValue; break; case Key.Insert: - if (e.Shift) + if (IFace.Shift) buffer.Insert (IFace.Clipboard); - else if (e.Control && !buffer.SelectionIsEmpty) + else if (IFace.Ctrl && !buffer.SelectionIsEmpty) IFace.Clipboard = buffer.SelectedText; break; case Key.Left: - if (e.Shift) { + if (IFace.Shift) { if (buffer.SelectionIsEmpty) buffer.SetSelStartPos (); - if (e.Control) + if (IFace.Ctrl) buffer.GotoWordStart (); else MoveLeft (); @@ -1098,16 +1101,16 @@ namespace Crow.Coding break; } buffer.ResetSelection (); - if (e.Control) + if (IFace.Ctrl) buffer.GotoWordStart (); else MoveLeft(); break; case Key.Right: - if (e.Shift) { + if (IFace.Shift) { if (buffer.SelectionIsEmpty) buffer.SetSelStartPos (); - if (e.Control) + if (IFace.Ctrl) buffer.GotoWordEnd (); else MoveRight (); @@ -1115,13 +1118,13 @@ namespace Crow.Coding break; } buffer.ResetSelection (); - if (e.Control) + if (IFace.Ctrl) buffer.GotoWordEnd (); else MoveRight (); break; case Key.Up: - if (e.Shift) { + if (IFace.Shift) { if (buffer.SelectionIsEmpty) buffer.SetSelStartPos (); PrintedCurrentLine--; @@ -1132,7 +1135,7 @@ namespace Crow.Coding PrintedCurrentLine--; break; case Key.Down: - if (e.Shift) { + if (IFace.Shift) { if (buffer.SelectionIsEmpty) buffer.SetSelStartPos (); PrintedCurrentLine++; @@ -1144,10 +1147,10 @@ namespace Crow.Coding break; case Key.Menu: break; - case Key.NumLock: + case Key.Num_Lock: break; - case Key.PageDown: - if (e.Shift) { + case Key.Page_Down: + if (IFace.Shift) { if (buffer.SelectionIsEmpty) buffer.SetSelStartPos (); PrintedCurrentLine += visibleLines; @@ -1157,8 +1160,8 @@ namespace Crow.Coding buffer.ResetSelection (); PrintedCurrentLine += visibleLines; break; - case Key.PageUp: - if (e.Shift) { + case Key.Page_Up: + if (IFace.Shift) { if (buffer.SelectionIsEmpty) buffer.SetSelStartPos (); PrintedCurrentLine -= visibleLines; @@ -1168,10 +1171,8 @@ namespace Crow.Coding buffer.ResetSelection (); PrintedCurrentLine -= visibleLines; break; - case Key.RWin: - break; case Key.Tab: - if (e.Shift) { + if (IFace.Shift) { if (buffer.SelectionIsEmpty || (buffer.SelectionStart.Y == buffer.SelectionEnd.Y)) { //TODO diff --git a/CrowIDE/src/Editors/SvgEditor.cs b/CrowIDE/src/Editors/SvgEditor.cs index 219eea67..163b5ac1 100644 --- a/CrowIDE/src/Editors/SvgEditor.cs +++ b/CrowIDE/src/Editors/SvgEditor.cs @@ -88,6 +88,9 @@ namespace Crow.Coding throw new NotImplementedException (); } } + protected override bool IsReady { + get { return projFile != null; } + } #endregion #region GraphicObject overrides diff --git a/CrowIDE/src/Extensions.cs b/CrowIDE/src/Extensions.cs index 05ef71e4..45873d3e 100644 --- a/CrowIDE/src/Extensions.cs +++ b/CrowIDE/src/Extensions.cs @@ -26,7 +26,7 @@ namespace Crow public static partial class Extensions { public static string GetIcon(this GraphicObject go){ - return "#Crow.Coding.icons.toolbox." + go.GetType().FullName + ".svg"; + return "#icons.toolbox." + go.GetType().FullName + ".svg"; } public static List<GraphicObject> GetChildren(this GraphicObject go){ Type goType = go.GetType(); diff --git a/CrowIDE/src/GraphicObjectDesignContainer.cs b/CrowIDE/src/GraphicObjectDesignContainer.cs index 4540898b..d99b38cb 100644 --- a/CrowIDE/src/GraphicObjectDesignContainer.cs +++ b/CrowIDE/src/GraphicObjectDesignContainer.cs @@ -41,7 +41,7 @@ namespace Crow.Coding public Type CrowType; public string IconPath { - get { return "#Crow.Coding.icons.toolbox." + CrowType.FullName + ".svg"; } + get { return "#icons.toolbox." + CrowType.FullName + ".svg"; } } public string DisplayName { get { return CrowType.Name; } @@ -53,8 +53,8 @@ namespace Crow.Coding lock (go.IFace.UpdateMutex) { go.IFace.DragImageHeight = dragIconSize; go.IFace.DragImageWidth = dragIconSize; - SvgPicture pic = new SvgPicture (); - pic.Load (go.IFace, IconPath); + SvgPicture pic = new SvgPicture (IconPath); + //pic.Load (go.IFace, IconPath); ImageSurface img = new ImageSurface (Format.Argb32, dragIconSize, dragIconSize); using (Context ctx = new Context (img)) { Rectangle r = new Rectangle (0, 0, dragIconSize, dragIconSize); diff --git a/CrowIDE/src/MemberView/PropertyContainer.cs b/CrowIDE/src/MemberView/PropertyContainer.cs index c2dc2899..b4e54f6b 100644 --- a/CrowIDE/src/MemberView/PropertyContainer.cs +++ b/CrowIDE/src/MemberView/PropertyContainer.cs @@ -177,7 +177,7 @@ namespace Crow.Coding public Fill LabForeground { - get { return IsSetByIML ? Color.DarkBlue : HasStyling ? Color.Black : Color.DimGray;} + get { return IsSetByIML ? Color.DarkBlue : HasStyling ? Color.Black : Color.DimGrey;} } /// <summary> diff --git a/CrowIDE/src/Project.cs b/CrowIDE/src/Project.cs index 2c4eda59..0a653498 100644 --- a/CrowIDE/src/Project.cs +++ b/CrowIDE/src/Project.cs @@ -61,18 +61,18 @@ namespace Crow.Coding solution = sol; cmdSave = new Crow.Command (new Action (() => Save ())) - { Caption = "Save", Icon = new SvgPicture ("#Crow.Coding.icons.save.svg"), CanExecute = true }; + { Caption = "Save", Icon = new SvgPicture ("#icons.save.svg"), CanExecute = true }; cmdOpen = new Crow.Command (new Action (() => Load ())) - { Caption = "Open", Icon = new SvgPicture ("#Crow.Coding.icons.open.svg"), CanExecute = false }; + { Caption = "Open", Icon = new SvgPicture ("#icons.open.svg"), CanExecute = false }; cmdCompile = new Crow.Command (new Action (() => Compile ())) { Caption = "Compile", - Icon = "#Crow.Coding.icons.compile.svg" + Icon = "#icons.compile.svg" }; cmdSetAsStartProj = new Crow.Command (new Action (() => setAsStartupProject ())) { Caption = "Set as Startup Project" }; cmdNewFile = new Crow.Command (new Action (() => AddNewFile ())) { - Caption = "Add New File", Icon = new SvgPicture ("#Crow.Coding.icons.blank-file.svg"), CanExecute = true + Caption = "Add New File", Icon = new SvgPicture ("#icons.blank-file.svg"), CanExecute = true }; Commands = new List<Crow.Command> (new Crow.Command[] {cmdOpen,cmdSave,cmdSetAsStartProj,cmdCompile,cmdNewFile}); @@ -464,12 +464,8 @@ namespace Crow.Coding solution.DefaultTemplates [clsName] = pi.Path; } - foreach (ProjectReference pr in flattenNodes.OfType<ProjectReference>()) { - Project p = solution.Projects.FirstOrDefault (pp => pp.ProjectGuid == pr.ProjectGUID); - if (p == null) - throw new Exception ("referenced project not found"); - p.GetDefaultTemplates (); - } + foreach (Project p in ReferencedProjects) + p.GetDefaultTemplates (); } // void searchTemplatesIn(Assembly assembly){ // if (assembly == null) @@ -484,6 +480,18 @@ namespace Crow.Coding // } // } + public List<Project> ReferencedProjects { + get { + List<Project> tmp = new List<Project> (); + foreach (ProjectReference pr in flattenNodes.OfType<ProjectReference>()) { + Project p = solution.Projects.FirstOrDefault (pp => pp.ProjectGuid == pr.ProjectGUID); + if (p != null) + tmp.Add (p); + } + return tmp; + } + } + public void GetStyling () { try { foreach (ProjectFile pi in flattenNodes.OfType<ProjectFile> ().Where (pp=>pp.Type == ItemType.EmbeddedResource && pp.Extension == ".style")) { diff --git a/CrowIDE/src/ProjectTree/ProjectFile.cs b/CrowIDE/src/ProjectTree/ProjectFile.cs index 2fac2f91..2c60c32c 100644 --- a/CrowIDE/src/ProjectTree/ProjectFile.cs +++ b/CrowIDE/src/ProjectTree/ProjectFile.cs @@ -34,7 +34,7 @@ using System.Threading; namespace Crow.Coding { public class ProjectFile : ProjectItem { - protected bool isOpened = false; + bool isOpened = false; DateTime accessTime; string source; string origSource; @@ -47,22 +47,28 @@ namespace Crow.Coding List<String> undoStack = new List<string>(); List<String> redoStack = new List<string>(); - public Crow.Command cmdSave, cmdSaveAs, cmdOpen, cmdUndo, cmdRedo; + public Crow.Command cmdSave, cmdSaveAs, cmdOpen, cmdClose, cmdUndo, cmdRedo; void initCommands (){ cmdSave = new Crow.Command (new Action (() => Save ())) - { Caption = "Save", Icon = new SvgPicture ("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false }; + { Caption = "Save", Icon = new SvgPicture ("#icons.save.svg"), CanExecute = false }; cmdSaveAs = new Crow.Command (new Action (() => SaveAs ())) - { Caption = "Save As ..", Icon = new SvgPicture ("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false }; + { Caption = "Save As ..", Icon = new SvgPicture ("#icons.save.svg"), CanExecute = false }; cmdOpen = new Crow.Command (new Action (() => Open ())) - { Caption = "Open", Icon = new SvgPicture ("#Crow.Coding.ui.icons.outbox.svg"), CanExecute = false }; + { Caption = "Open", Icon = new SvgPicture ("#icons.open.svg"), CanExecute = true }; + cmdClose = new Crow.Command (new Action (() => OnQueryClose (this,null))) + { Caption = "Close", Icon = new SvgPicture ("#icons.open.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 ("#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 ("#icons.redo.svg"), CanExecute = false }; Commands.Insert (0, cmdOpen); - Commands.Insert (1, cmdSave); + Commands.Insert (1, cmdSave); + Commands.Insert (2, cmdSaveAs); + Commands.Insert (3, cmdUndo); + Commands.Insert (4, cmdRedo); + Commands.Add (cmdClose); } public ProjectFile () { initCommands(); @@ -85,6 +91,25 @@ namespace Crow.Coding 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){ @@ -124,9 +149,11 @@ namespace Crow.Coding } public string Source { get { - if (!isOpened) - Open (); - else { + if (!IsOpened) { + using (StreamReader sr = new StreamReader (AbsolutePath)) + source = sr.ReadToEnd (); + + } else { if (DateTime.Compare ( accessTime, System.IO.File.GetLastWriteTime (AbsolutePath)) < 0) @@ -195,13 +222,13 @@ namespace Crow.Coding } } - public void Open () { + public void Open () { accessTime = System.IO.File.GetLastWriteTime (AbsolutePath); using (StreamReader sr = new StreamReader (AbsolutePath)) { source = sr.ReadToEnd (); } - isOpened = true; origSource = source; + IsOpened = true; NotifyValueChanged ("IsDirty", false); } public virtual void Save () { @@ -223,9 +250,8 @@ namespace Crow.Coding NotifyValueChanged ("IsDirty", false); } public void Close () { - origSource = null; - isOpened = false; - Project.solution.CloseItem (this); + origSource = source = null; + IsOpened = false; } public void Undo(object sender){ undo(); @@ -276,7 +302,15 @@ namespace Crow.Coding } + 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, diff --git a/CrowIDE/src/ProjectTree/ProjectItem.cs b/CrowIDE/src/ProjectTree/ProjectItem.cs index 7a30a8e1..89889ca3 100644 --- a/CrowIDE/src/ProjectTree/ProjectItem.cs +++ b/CrowIDE/src/ProjectTree/ProjectItem.cs @@ -43,7 +43,26 @@ namespace Crow.Coding public XmlNode node; - public string Extension { + public override Picture Icon { + get { + Console.WriteLine("extension="+Extension); + + switch (Extension) + { + case ".cs": + return new SvgPicture("#icons.cs-file.svg"); + case ".crow": + Console.WriteLine("loading icons.xml-file"); + return new SvgPicture("#icons.xml-file.svg"); + case ".xml": + return new SvgPicture("#icons.xml-file.svg"); + default: + return base.Icon; + } + } + } + + public string Extension { get { return System.IO.Path.GetExtension (Path); } } public string Path { @@ -71,6 +90,30 @@ namespace Crow.Coding 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/CrowIDE/src/ProjectTree/ProjectNodes.cs b/CrowIDE/src/ProjectTree/ProjectNodes.cs index b9c855f1..5f518ff7 100644 --- a/CrowIDE/src/ProjectTree/ProjectNodes.cs +++ b/CrowIDE/src/ProjectTree/ProjectNodes.cs @@ -79,6 +79,7 @@ namespace Crow.Coding ProjectNode parent; bool isExpanded; + protected bool isSelected; ItemType type; string name; List<ProjectNode> childNodes = new List<ProjectNode>(); @@ -86,6 +87,18 @@ namespace Crow.Coding public Project Project; public List<Crow.Command> 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("#icons.blank-file.svg"); + } + } + } public ProjectNode Parent { get { return parent; } set { parent = value; } @@ -124,7 +137,19 @@ namespace Crow.Coding 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/CrowIDE/src/Solution.cs b/CrowIDE/src/Solution.cs index 68922865..2295c330 100644 --- a/CrowIDE/src/Solution.cs +++ b/CrowIDE/src/Solution.cs @@ -159,7 +159,14 @@ namespace Crow.Coding{ set { if (selectedItem == value) return; + if (SelectedItem != null) + SelectedItem.IsSelected = false; selectedItem = value; + if (SelectedItem != null) + SelectedItem.IsSelected = true; + + UserConfig.Set ("SelectedProjItems", SelectedItem?.AbsolutePath); + NotifyValueChanged ("SelectedItem", selectedItem); } } @@ -230,40 +237,30 @@ namespace Crow.Coding{ foreach (Project p in Projects) { ProjectFile pi; if (p.TryGetProjectFileFromAbsolutePath (f, out pi)) { - OpenedItems.AddElement (pi); - pi.Project.IsExpanded = true; - ProjectNode pn = pi.Parent; - while (pn != null) { - pn.IsExpanded = true; - pn = pn.Parent; - } + pi.Open (); if (pi.AbsolutePath == sel) selItem = pi; break; } } } - SelectedItem = selItem;//BUG: loading in another thread focused last loaded pf + if (selItem == null) + return; + selItem.IsSelected = true; } - void onSelectedItemChanged (object sender, SelectionChangeEventArgs e){ - ProjectItem pi = e.NewValue as ProjectItem; - if (pi != null) { - if (!openedItems.Contains (pi)) { - openedItems.AddElement (pi); - saveOpenedItemsInUserConfig (); - } - } - this.SelectedItem = pi; + /*void onSelectedItemChanged (object sender, SelectionChangeEventArgs e){ + SelectedItem = e.NewValue as ProjectItem; UserConfig.Set ("SelectedProjItems", SelectedItem?.AbsolutePath); + }*/ + + public void OpenItem (ProjectItem pi) { + if (!openedItems.Contains (pi)) { + openedItems.AddElement (pi); + saveOpenedItemsInUserConfig (); + } } - public void OnCloseTab (object sender, MouseButtonEventArgs e){ - Console.WriteLine ("OnCloseTab"); - openedItems.RemoveElement ((sender as GraphicObject).DataSource as ProjectItem); - saveOpenedItemsInUserConfig (); - } - public void CloseItem (ProjectItem pi) { - Console.WriteLine ("CloseItem: " + pi.ToString()); + public void CloseItem (ProjectItem pi) { openedItems.RemoveElement (pi); saveOpenedItemsInUserConfig (); } |