From 6ddcd449a085f7fa43d7f1176c47e62a3597c9ef Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Fri, 9 Mar 2018 15:37:09 +0100 Subject: [PATCH] editor abstract base class, svgeditor base --- Default.style | 1 + src/Interface.cs | 13 +++++++++++++ src/ParsingException.cs | 16 +++++++++++++--- src/SvgPicture.cs | 7 +++++++ 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Default.style b/Default.style index ed92e89b..5cb1aad6 100644 --- a/Default.style +++ b/Default.style @@ -128,6 +128,7 @@ DockStack { //EndDrag="{Background=Jet}"; } DockWindow { + Background = "Onyx"; Focusable = "true"; AllowDrag = "true"; Margin="0"; diff --git a/src/Interface.cs b/src/Interface.cs index a3bd9fd4..eb4caefa 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -1133,6 +1133,19 @@ namespace Crow ctxMenuContainer = Load ("#Crow.ContextMenu.template") as MenuItem; } + void CtxMenuContainer_LayoutChanged (object sender, LayoutingEventArgs e) + { + Rectangle r = ctxMenuContainer.ScreenCoordinates (ctxMenuContainer.Slot); + if (e.LayoutType == LayoutingType.Width) { + if (r.Right > this.clientRectangle.Right) + ctxMenuContainer.Left = this.clientRectangle.Right - ctxMenuContainer.Slot.Width; + }else if (e.LayoutType == LayoutingType.Width) { + if (r.Bottom > this.clientRectangle.Bottom) + ctxMenuContainer.Top = this.clientRectangle.Bottom - ctxMenuContainer.Slot.Height; + } + + } + public void ShowContextMenu (GraphicObject go) { lock (UpdateMutex) { diff --git a/src/ParsingException.cs b/src/ParsingException.cs index eb85504d..1b596981 100644 --- a/src/ParsingException.cs +++ b/src/ParsingException.cs @@ -6,15 +6,25 @@ namespace Crow.Coding { public int Line; public int Column; + public string Source; public ParserException(int line, int column, string txt, string source = null) - : base(string.Format("{3}:({0},{1}): {2}", line, column, txt, source)) + : base(txt) { Line = line; Column = column; + Source = source; } public ParserException(int line, int column, string txt, Exception innerException, string source = null) - : base(string.Format("{3}:({0},{1}): {2}", line, column, txt, source), innerException) - {} + : base(txt, innerException) + { + Line = line; + Column = column; + Source = source; + } + public override string ToString () + { + return string.Format("{3}:({0},{1}): {2}", Line, Column, Message, Source); + } } } diff --git a/src/SvgPicture.cs b/src/SvgPicture.cs index 01aaeb5f..ce7fdedf 100644 --- a/src/SvgPicture.cs +++ b/src/SvgPicture.cs @@ -71,6 +71,11 @@ namespace Crow sharedResources [path] = new sharedPicture (hSVG, Dimensions); } + public void LoadSvgFragment (string fragment) { + hSVG = new Rsvg.Handle (System.Text.Encoding.Unicode.GetBytes(fragment)); + Dimensions = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height); + } + #region implemented abstract members of Fill public override void SetAsSource (Context ctx, Rectangle bounds = default(Rectangle)) @@ -112,6 +117,8 @@ namespace Crow /// limit rendering to svg part named 'subPart' public override void Paint (Context gr, Rectangle rect, string subPart = "") { + if (hSVG == null) + return; float widthRatio = 1f; float heightRatio = 1f; -- 2.47.3