From 2d5dfc5b99cc3abfdafad69c19ce8ea05e9e8af4 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bruyère Date: Sat, 24 Feb 2018 11:51:12 +0100 Subject: change namespace of CrowIDE to Crow.Coding, move editor source inside, crowIde wip --- src/GraphicObjects/TabItem.cs | 2 +- src/Instantiator.cs | 2 +- src/Interface.cs | 24 ++++++++++++++---------- src/StyleReader.cs | 10 +++++----- 4 files changed, 21 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/GraphicObjects/TabItem.cs b/src/GraphicObjects/TabItem.cs index eab0cb0d..676904b5 100644 --- a/src/GraphicObjects/TabItem.cs +++ b/src/GraphicObjects/TabItem.cs @@ -217,7 +217,7 @@ namespace Crow //if tab is used as a templated item root in a templatedGroup, local datasource //is not null, in this case, removing the data entries will delete automatically the item if (localDataSourceIsNull) - (Parent as TabView).DeleteChild (this); + (Parent as TabView)?.DeleteChild (this); } #endregion diff --git a/src/Instantiator.cs b/src/Instantiator.cs index 2481206a..82797a60 100644 --- a/src/Instantiator.cs +++ b/src/Instantiator.cs @@ -134,7 +134,7 @@ namespace Crow.IML return new Instantiator (_iface, s); } } catch (Exception ex) { - throw new Exception ("Error loading IML fragment:\n" + fragment + "\n", ex); + throw new Exception ("IML Error: " + ex.Message); } } #endregion diff --git a/src/Interface.cs b/src/Interface.cs index 5174e37e..5d7f7720 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -97,14 +97,17 @@ namespace Crow FontRenderingOptions.SubpixelOrder = SubpixelOrder.Rgb; } public Interface(){ - CurrentInterface = this; CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture; + } + #endregion + + public void Init () { + CurrentInterface = this; loadStyling (); findAvailableTemplates (); initTooltip (); initContextMenus (); } - #endregion #region Static and constants /// @@ -125,7 +128,7 @@ namespace Crow public static int DeviceRepeatInterval = 40; /// Tabulation size in Text controls public static int TabSize = 4; - public static string LineBreak = "\r\n"; + public static string LineBreak = "\n"; /// Allow rendering of interface in development environment public static bool DesignerMode = false; /// Disable caching for a widget if this threshold is reached @@ -254,7 +257,7 @@ namespace Crow .GetManifestResourceNames () .Where (r => r.EndsWith (".style", StringComparison.OrdinalIgnoreCase))) { using (Stream stream = assembly.GetManifestResourceStream (s)) { - new StyleReader (this, stream, s); + new StyleReader (this.Styling, stream, s); } } @@ -278,9 +281,10 @@ namespace Crow /// Resource ID must be 'fullClassName.template' (not case sensitive) /// Those found in application assembly have priority to the default Crow's one /// - public Dictionary DefaultTemplates = new Dictionary(); + public Dictionary DefaultTemplates; /// Finds available default templates at startup void findAvailableTemplates(){ + DefaultTemplates = new Dictionary(); searchTemplatesOnDisk ("./"); string defTemplatePath = System.IO.Path.Combine (CrowConfigRoot, "defaultTemplates"); searchTemplatesOnDisk (defTemplatePath); @@ -375,7 +379,7 @@ namespace Crow /// /// new instance of graphic object created /// path of the iml file to load - public GraphicObject Load (string path) + public virtual GraphicObject Load (string path) { //try { return GetInstantiator (path).CreateInstance (); @@ -388,7 +392,7 @@ namespace Crow /// /// new Instantiator /// path of the iml file to load - public Instantiator GetInstantiator(string path){ + public virtual Instantiator GetInstantiator(string path){ if (!Instantiators.ContainsKey(path)) Instantiators [path] = new Instantiator(this, path); return Instantiators [path]; @@ -397,7 +401,7 @@ namespace Crow /// try to fetch the requested one in the cache or create it. /// They have additional properties for recursivity and /// custom display per item type - public ItemTemplate GetItemTemplate(string path){ + public virtual ItemTemplate GetItemTemplate(string path){ if (!Instantiators.ContainsKey(path)) Instantiators [path] = new ItemTemplate(this, path); return Instantiators [path] as ItemTemplate; @@ -1052,7 +1056,7 @@ namespace Crow GraphicObject ToolTipContainer = null; volatile bool tooltipVisible = false; - void initTooltip () { + protected void initTooltip () { ToolTipContainer = Load ("#Crow.Tooltip.template"); Thread t = new Thread (toolTipThreadFunc); t.IsBackground = true; @@ -1093,7 +1097,7 @@ namespace Crow #region Contextual menu MenuItem ctxMenuContainer; - void initContextMenus (){ + protected void initContextMenus (){ ctxMenuContainer = Load ("#Crow.ContextMenu.template") as MenuItem; } diff --git a/src/StyleReader.cs b/src/StyleReader.cs index 26037091..5a00a594 100644 --- a/src/StyleReader.cs +++ b/src/StyleReader.cs @@ -43,7 +43,7 @@ namespace Crow int column = 1; int line = 1; - public StyleReader (Interface iface, Stream stream, string resId) + public StyleReader (Dictionary styling, Stream stream, string resId) : base(stream) { resourceId = resId; @@ -137,11 +137,11 @@ namespace Crow string expression = token.Trim (); foreach (string tc in targetsClasses) { - if (!iface.Styling.ContainsKey (tc)) - iface.Styling [tc] = new Style (); - else if (iface.Styling [tc].ContainsKey (currentProperty)) + if (!styling.ContainsKey (tc)) + styling [tc] = new Style (); + else if (styling [tc].ContainsKey (currentProperty)) continue; - iface.Styling [tc] [currentProperty] = expression; + styling [tc] [currentProperty] = expression; } token = ""; } -- cgit v1.3.1-4-g156e