From fe174269bdd1d1c459e18ffa17c939730b6d52bd Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Fri, 19 Jun 2020 11:06:03 -0700 Subject: [PATCH] allowing socketeer to be disabeld --- .../ApplicationView/ApplicationController.cs | 55 +++++++++++-------- .../ApplicationSettingsPage.cs | 6 ++ .../SettingsManagement/UserSettings.cs | 1 + Submodules/agg-sharp | 2 +- 4 files changed, 41 insertions(+), 23 deletions(-) diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index 79ccb7870..488717fc6 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -813,7 +813,13 @@ namespace MatterHackers.MatterControl var selectedItem = scene.SelectedItem; if (selectedItem != null) { - scene.MakeLowestFaceFlat(selectedItem); + try + { + scene.MakeLowestFaceFlat(selectedItem); + } + catch + { + } } }, IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null, @@ -2107,40 +2113,45 @@ namespace MatterHackers.MatterControl [NamedTypeFace.Liberation_Mono] = TypeFace.LoadFrom(AggContext.StaticData.ReadAllText(Path.Combine("Fonts", "LiberationMono.svg"))) }; + static object locker = new object(); + public static TypeFace GetTypeFace(NamedTypeFace namedTypeFace) { - if (!TypeFaceCache.ContainsKey(namedTypeFace)) + lock (locker) { - TypeFace typeFace = new TypeFace(); - var path = Path.Combine("Fonts", $"{namedTypeFace}.ttf"); - var exists = AggContext.StaticData.FileExists(path); - var stream = exists ? AggContext.StaticData.OpenStream(path) : null; - if (stream != null - && typeFace.LoadTTF(stream)) + if (!TypeFaceCache.ContainsKey(namedTypeFace)) { - TypeFaceCache.Add(namedTypeFace, typeFace); - } - else - { - // try the svg - path = Path.Combine("Fonts", $"{namedTypeFace}.svg"); - exists = AggContext.StaticData.FileExists(path); - typeFace = exists ? TypeFace.LoadFrom(AggContext.StaticData.ReadAllText(path)) : null; - if (typeFace != null) + TypeFace typeFace = new TypeFace(); + var path = Path.Combine("Fonts", $"{namedTypeFace}.ttf"); + var exists = AggContext.StaticData.FileExists(path); + var stream = exists ? AggContext.StaticData.OpenStream(path) : null; + if (stream != null + && typeFace.LoadTTF(stream)) { TypeFaceCache.Add(namedTypeFace, typeFace); } else { - // assign it to the default - TypeFaceCache.Add(namedTypeFace, TypeFaceCache[NamedTypeFace.Liberation_Sans]); + // try the svg + path = Path.Combine("Fonts", $"{namedTypeFace}.svg"); + exists = AggContext.StaticData.FileExists(path); + typeFace = exists ? TypeFace.LoadFrom(AggContext.StaticData.ReadAllText(path)) : null; + if (typeFace != null) + { + TypeFaceCache.Add(namedTypeFace, typeFace); + } + else + { + // assign it to the default + TypeFaceCache.Add(namedTypeFace, TypeFaceCache[NamedTypeFace.Liberation_Sans]); + } } + + stream?.Dispose(); } - stream?.Dispose(); + return TypeFaceCache[namedTypeFace]; } - - return TypeFaceCache[namedTypeFace]; } private static TypeFace titilliumTypeFace = null; diff --git a/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs b/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs index 9dba7f1d9..582dbaea2 100644 --- a/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs +++ b/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs @@ -387,6 +387,12 @@ namespace MatterHackers.MatterControl true, false); + AddUserBoolToggle(advancedPanel, + "Enable Socketeer Client".Localize(), + UserSettingsKey.ApplicationUseSocketeer, + true, + false); + var openCacheButton = new IconButton(AggContext.StaticData.LoadIcon("fa-link_16.png", 16, 16, theme.InvertIcons), theme) { ToolTipText = "Open Folder".Localize(), diff --git a/MatterControlLib/SettingsManagement/UserSettings.cs b/MatterControlLib/SettingsManagement/UserSettings.cs index d7d04300a..c85ab902b 100644 --- a/MatterControlLib/SettingsManagement/UserSettings.cs +++ b/MatterControlLib/SettingsManagement/UserSettings.cs @@ -18,6 +18,7 @@ namespace MatterHackers.MatterControl public const string AfterPrintFinishedSendTextMessage = nameof(AfterPrintFinishedSendTextMessage); public const string ApplicationDisplayMode = nameof(ApplicationDisplayMode); public const string ApplicationUseHeigResDisplays = nameof(ApplicationUseHeigResDisplays); + public const string ApplicationUseSocketeer = nameof(ApplicationUseSocketeer); public const string ApplicationTextSize = nameof(ApplicationTextSize); public const string ColorPanelExpanded = nameof(ColorPanelExpanded); public const string ConfigurePrinter_CurrentTab = nameof(ConfigurePrinter_CurrentTab); diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index a474af0f5..c1111e039 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit a474af0f548ce56ba523d33cd77128743acd0103 +Subproject commit c1111e0391606ca75ed26a4985a9898f19f10223