allowing socketeer to be disabeld

This commit is contained in:
Lars Brubaker 2020-06-19 11:06:03 -07:00
parent 47f77acbe5
commit fe174269bd
4 changed files with 41 additions and 23 deletions

View file

@ -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;

View file

@ -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(),

View file

@ -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);

@ -1 +1 @@
Subproject commit a474af0f548ce56ba523d33cd77128743acd0103
Subproject commit c1111e0391606ca75ed26a4985a9898f19f10223