Migrate Theme support to Agg.UI
This commit is contained in:
parent
77d3df1d01
commit
e5a63b052e
41 changed files with 155 additions and 473 deletions
|
|
@ -64,7 +64,7 @@ namespace MatterHackers.MatterControl
|
|||
customInfoTopToBottom.VAnchor = VAnchor.Max_FitToChildren_ParentHeight;
|
||||
customInfoTopToBottom.Padding = new BorderDouble(5, 10, 5, 0);
|
||||
|
||||
if (ActiveTheme.Instance.IsTouchScreen)
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
customInfoTopToBottom.AddChild(new UpdateControlView());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ namespace MatterHackers.MatterControl.ContactForm
|
|||
|
||||
private void AddHandlers()
|
||||
{
|
||||
ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
contactFormWidget.Closed += (sender, e) => { Close(); };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace MatterHackers.MatterControl
|
|||
this.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;
|
||||
|
||||
// Add Child Elements
|
||||
if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Responsive)
|
||||
if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Responsive)
|
||||
{
|
||||
this.AddChild(new ActionBar.PrinterActionRow());
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ namespace MatterHackers.MatterControl
|
|||
this.Padding = new BorderDouble(bottom: 6);
|
||||
|
||||
// Add Handlers
|
||||
ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
public void ThemeChanged(object sender, EventArgs e)
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
cancelConnectButton.Click += (sender, e) => { UiThread.RunOnIdle(CancelPrinting); };
|
||||
reprintButton.Click += onReprintButton_Click;
|
||||
doneWithCurrentPartButton.Click += onDoneWithCurrentPartButton_Click;
|
||||
ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
protected void DisableActiveButtons()
|
||||
|
|
@ -274,7 +274,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
if (!PrinterConnectionAndCommunication.Instance.PrinterIsConnected
|
||||
&& PrinterConnectionAndCommunication.Instance.CommunicationState != PrinterConnectionAndCommunication.CommunicationStates.AttemptingToConnect)
|
||||
{
|
||||
if (ActiveTheme.Instance.IsTouchScreen)
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
this.activePrintButtons.Add(connectButton);
|
||||
}
|
||||
|
|
@ -335,7 +335,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
this.activePrintButtons.Add(pauseButton);
|
||||
this.activePrintButtons.Add(cancelButton);
|
||||
}
|
||||
else if (ActiveTheme.Instance.IsTouchScreen)
|
||||
else if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
this.activePrintButtons.Add(resetConnectionButton);
|
||||
}
|
||||
|
|
@ -363,7 +363,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
if (PrinterConnectionAndCommunication.Instance.PrinterIsConnected
|
||||
&& ActiveSliceSettings.Instance.ShowResetConnection()
|
||||
&& ActiveTheme.Instance.IsTouchScreen)
|
||||
&& UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
this.activePrintButtons.Add(resetConnectionButton);
|
||||
ShowActiveButtons();
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
public static GuiWidget Create(QueueDataView queueDataView)
|
||||
{
|
||||
if (ActiveTheme.Instance.IsTouchScreen)
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
return new TouchScreenPrintStatusRow(queueDataView);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
this.AddChild(currentTempIndicator);
|
||||
this.AddChild(buttonContainer);
|
||||
|
||||
ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
|
||||
this.MouseEnterBounds += onEnterBounds;
|
||||
this.MouseLeaveBounds += onLeaveBounds;
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ namespace MatterHackers.MatterControl
|
|||
public ApplicationController()
|
||||
{
|
||||
//Name = "MainSlidePanel";
|
||||
ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
public void ThemeChanged(object sender, EventArgs e)
|
||||
|
|
@ -246,7 +246,7 @@ namespace MatterHackers.MatterControl
|
|||
//using (new PerformanceTimer("Startup", "AppController Instance"))
|
||||
{
|
||||
globalInstance = new ApplicationController();
|
||||
if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen)
|
||||
if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen)
|
||||
{
|
||||
globalInstance.MainView = new TouchscreenView();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
|||
mainContainer.AddChild(new HorizontalLine(separatorLineColor));
|
||||
|
||||
#endif
|
||||
if (ActiveTheme.Instance.IsTouchScreen)
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
mainContainer.AddChild(GetUpdateControl());
|
||||
mainContainer.AddChild(new HorizontalLine(separatorLineColor));
|
||||
|
|
@ -85,7 +85,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
|||
mainContainer.AddChild(new HorizontalLine(separatorLineColor));
|
||||
|
||||
#endif
|
||||
if (ActiveTheme.Instance.IsTouchScreen)
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
mainContainer.AddChild(GetModeControl());
|
||||
mainContainer.AddChild(new HorizontalLine(separatorLineColor));
|
||||
|
|
@ -541,7 +541,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
|||
{
|
||||
UserSettings.Instance.Fields.IsSimpleMode = false;
|
||||
}
|
||||
ActiveTheme.Instance.ReloadThemeSettings();
|
||||
}
|
||||
|
||||
private void ReleaseOptionsDropList_SelectionChanged(object sender, EventArgs e)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace MatterHackers.MatterControl
|
|||
public InstructionsPage(string pageDescription, string instructionsText)
|
||||
: base(pageDescription)
|
||||
{
|
||||
if (ActiveTheme.Instance.IsTouchScreen)
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
extraTextScaling = 1.33333;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace MatterHackers.MatterControl
|
|||
public StyledMessageBox(Action<bool> callback, String message, string windowTitle, MessageType messageType, GuiWidget[] extraWidgetsToAdd, double width, double height, string yesOk, string no)
|
||||
: base(width, height)
|
||||
{
|
||||
if (ActiveTheme.Instance.IsTouchScreen)
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
extraTextScaling = 1.33333;
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ namespace MatterHackers.MatterControl
|
|||
unwrappedMessage = message;
|
||||
FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
topToBottom.AnchorAll();
|
||||
if (ActiveTheme.Instance.IsTouchScreen)
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
topToBottom.Padding = new BorderDouble(12, 12, 13, 8);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,385 +0,0 @@
|
|||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.MatterControl.SettingsManagement;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
/*
|
||||
Copyright (c) 2014, Kevin Pope
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
public class ActiveTheme
|
||||
{
|
||||
private static ActiveTheme globalInstance;
|
||||
private Theme loadedTheme;
|
||||
private List<Theme> availableThemes;
|
||||
private int defaultThemeIndex = 1;
|
||||
private int activeThemeIndex = -1;
|
||||
|
||||
public RootedObjectEventHandler ThemeChanged = new RootedObjectEventHandler();
|
||||
|
||||
public enum ApplicationDisplayType { Responsive, Touchscreen } ;
|
||||
|
||||
public ApplicationDisplayType DisplayMode
|
||||
{
|
||||
get
|
||||
{
|
||||
string displayMode = UserSettings.Instance.get("ApplicationDisplayMode");
|
||||
if (displayMode == "touchscreen")
|
||||
{
|
||||
return ApplicationDisplayType.Touchscreen;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ApplicationDisplayType.Responsive;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<Theme> AvailableThemes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.availableThemes == null)
|
||||
{
|
||||
this.availableThemes = GetAvailableThemes();
|
||||
}
|
||||
return availableThemes;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsDarkTheme
|
||||
{
|
||||
get
|
||||
{
|
||||
return loadedTheme.DarkTheme;
|
||||
}
|
||||
}
|
||||
|
||||
public RGBA_Bytes Transparent
|
||||
{
|
||||
get
|
||||
{
|
||||
return new RGBA_Bytes(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public RGBA_Bytes TransparentDarkOverlay
|
||||
{
|
||||
get
|
||||
{
|
||||
return new RGBA_Bytes(0, 0, 0, 50);
|
||||
}
|
||||
}
|
||||
|
||||
public RGBA_Bytes TransparentLightOverlay
|
||||
{
|
||||
get
|
||||
{
|
||||
return new RGBA_Bytes(255, 255, 255, 50);
|
||||
}
|
||||
}
|
||||
|
||||
public RGBA_Bytes TabLabelSelected
|
||||
{
|
||||
get
|
||||
{
|
||||
return loadedTheme.tabLabelSelectedColor;
|
||||
}
|
||||
}
|
||||
|
||||
public RGBA_Bytes TabLabelUnselected
|
||||
{
|
||||
get
|
||||
{
|
||||
return loadedTheme.tabLabelUnselectedColor;
|
||||
}
|
||||
}
|
||||
|
||||
public RGBA_Bytes SecondaryTextColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return loadedTheme.secondaryTextColor;
|
||||
}
|
||||
}
|
||||
|
||||
public RGBA_Bytes PrimaryBackgroundColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return loadedTheme.primaryBackgroundColor;
|
||||
}
|
||||
}
|
||||
|
||||
public RGBA_Bytes SecondaryBackgroundColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return loadedTheme.secondaryBackgroundColor;
|
||||
}
|
||||
}
|
||||
|
||||
public RGBA_Bytes TertiaryBackgroundColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return loadedTheme.tertiaryBackgroundColor;
|
||||
}
|
||||
}
|
||||
|
||||
public RGBA_Bytes PrimaryTextColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return loadedTheme.primaryTextColor;
|
||||
}
|
||||
}
|
||||
|
||||
public RGBA_Bytes PrimaryAccentColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return loadedTheme.primaryAccentColor;
|
||||
}
|
||||
}
|
||||
|
||||
public RGBA_Bytes SecondaryAccentColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return loadedTheme.secondaryAccentColor;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnThemeChanged(EventArgs e)
|
||||
{
|
||||
ThemeChanged.CallEvents(this, e);
|
||||
}
|
||||
|
||||
public ActiveTheme()
|
||||
{
|
||||
|
||||
//Load the default theme by index
|
||||
if (string.IsNullOrEmpty(ActiveSliceSettings.Instance.ActiveValue("MatterControl.ActiveThemeIndex")))
|
||||
{
|
||||
bool foundOemColor = false;
|
||||
for (int i = 0; i < AvailableThemes.Count; i++)
|
||||
{
|
||||
Theme current = AvailableThemes[i];
|
||||
if (current.Name == OemSettings.Instance.ThemeColor)
|
||||
{
|
||||
ActiveSliceSettings.Instance.SetActiveValue("MatterControl.ActiveThemeIndex", i.ToString());
|
||||
foundOemColor = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundOemColor)
|
||||
{
|
||||
ActiveSliceSettings.Instance.SetActiveValue("MatterControl.ActiveThemeIndex", defaultThemeIndex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
int themeIndex;
|
||||
try
|
||||
{
|
||||
themeIndex = Convert.ToInt32(ActiveSliceSettings.Instance.ActiveValue("MatterControl.ActiveThemeIndex"));
|
||||
}
|
||||
catch
|
||||
{
|
||||
GuiWidget.BreakInDebugger();
|
||||
themeIndex = defaultThemeIndex;
|
||||
}
|
||||
|
||||
LoadThemeSettings(themeIndex);
|
||||
}
|
||||
|
||||
public static ActiveTheme Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (globalInstance == null)
|
||||
{
|
||||
globalInstance = new ActiveTheme();
|
||||
}
|
||||
return globalInstance;
|
||||
}
|
||||
}
|
||||
|
||||
public void ReloadThemeSettings()
|
||||
{
|
||||
//Reload the current theme
|
||||
OnThemeChanged(null);
|
||||
}
|
||||
|
||||
public void LoadThemeSettings(int index, bool supressReloadEvent = false)
|
||||
{
|
||||
//Validate new theme selection and change theme
|
||||
if (index > -1 && index < AvailableThemes.Count)
|
||||
{
|
||||
if (activeThemeIndex != index)
|
||||
{
|
||||
this.loadedTheme = this.AvailableThemes[index];
|
||||
this.activeThemeIndex = index;
|
||||
|
||||
if (!supressReloadEvent)
|
||||
{
|
||||
OnThemeChanged(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid theme selection");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Switches to the ActivePrinter theme without firing the ThemeChanged event. This is useful when changing printers and
|
||||
/// allows the theme state to be updated before the ActivePrinterChanged event fires, resulting in a single ReloadAll
|
||||
/// occurring rather than two
|
||||
/// </summary>
|
||||
public void SwitchToPrinterThemeWithoutReloadEvent()
|
||||
{
|
||||
string activeThemeIndex = ActiveSliceSettings.Instance.ActiveValue("MatterControl.ActiveThemeIndex");
|
||||
|
||||
int themeIndex;
|
||||
if (string.IsNullOrEmpty(activeThemeIndex) || !int.TryParse(activeThemeIndex, out themeIndex))
|
||||
{
|
||||
// Fall back to default theme if user settings are missing or invalid
|
||||
themeIndex = defaultThemeIndex;
|
||||
}
|
||||
|
||||
LoadThemeSettings(themeIndex, supressReloadEvent: true);
|
||||
}
|
||||
|
||||
private List<Theme> GetAvailableThemes()
|
||||
{
|
||||
//Generate a list of available theme definitions
|
||||
List<Theme> themeList = new List<Theme>();
|
||||
|
||||
//Dark themes
|
||||
themeList.Add(new Theme("Blue - Dark", new RGBA_Bytes(0, 75, 139), new RGBA_Bytes(0, 103, 190)));
|
||||
themeList.Add(new Theme("Teal - Dark", new RGBA_Bytes(0, 130, 153), new RGBA_Bytes(0, 173, 204)));
|
||||
themeList.Add(new Theme("Green - Dark", new RGBA_Bytes(0, 138, 23), new RGBA_Bytes(0, 189, 32)));
|
||||
themeList.Add(new Theme("Light Blue - Dark", new RGBA_Bytes(93, 178, 255), new RGBA_Bytes(144, 202, 255)));
|
||||
themeList.Add(new Theme("Orange - Dark", new RGBA_Bytes(255, 129, 25), new RGBA_Bytes(255, 157, 76)));
|
||||
themeList.Add(new Theme("Purple - Dark", new RGBA_Bytes(70, 23, 180), new RGBA_Bytes(104, 51, 229)));
|
||||
themeList.Add(new Theme("Red - Dark", new RGBA_Bytes(172, 25, 61), new RGBA_Bytes(217, 31, 77)));
|
||||
themeList.Add(new Theme("Pink - Dark", new RGBA_Bytes(220, 79, 173), new RGBA_Bytes(233, 143, 203)));
|
||||
themeList.Add(new Theme("Grey - Dark", new RGBA_Bytes(88, 88, 88), new RGBA_Bytes(114, 114, 114)));
|
||||
themeList.Add(new Theme("Pink - Dark", new RGBA_Bytes(140, 0, 149), new RGBA_Bytes(188, 0, 200)));
|
||||
|
||||
//Light themes
|
||||
themeList.Add(new Theme("Blue - Light", new RGBA_Bytes(0, 75, 139), new RGBA_Bytes(0, 103, 190), false));
|
||||
themeList.Add(new Theme("Teal - Light", new RGBA_Bytes(0, 130, 153), new RGBA_Bytes(0, 173, 204), false));
|
||||
themeList.Add(new Theme("Green - Light", new RGBA_Bytes(0, 138, 23), new RGBA_Bytes(0, 189, 32), false));
|
||||
themeList.Add(new Theme("Light Blue - Light", new RGBA_Bytes(93, 178, 255), new RGBA_Bytes(144, 202, 255), false));
|
||||
themeList.Add(new Theme("Orange - Light", new RGBA_Bytes(255, 129, 25), new RGBA_Bytes(255, 157, 76), false));
|
||||
themeList.Add(new Theme("Purple - Light", new RGBA_Bytes(70, 23, 180), new RGBA_Bytes(104, 51, 229), false));
|
||||
themeList.Add(new Theme("Red - Light", new RGBA_Bytes(172, 25, 61), new RGBA_Bytes(217, 31, 77), false));
|
||||
themeList.Add(new Theme("Pink - Light", new RGBA_Bytes(220, 79, 173), new RGBA_Bytes(233, 143, 203), false));
|
||||
themeList.Add(new Theme("Grey - Light", new RGBA_Bytes(88, 88, 88), new RGBA_Bytes(114, 114, 114), false));
|
||||
themeList.Add(new Theme("Pink - Light", new RGBA_Bytes(140, 0, 149), new RGBA_Bytes(188, 0, 200), false));
|
||||
|
||||
return themeList;
|
||||
}
|
||||
|
||||
public bool IsTouchScreen
|
||||
{
|
||||
get
|
||||
{
|
||||
return UserSettings.Instance.get("ApplicationDisplayMode") == "touchscreen";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Theme
|
||||
{
|
||||
public RGBA_Bytes primaryAccentColor;
|
||||
public RGBA_Bytes secondaryAccentColor;
|
||||
public RGBA_Bytes primaryTextColor;
|
||||
public RGBA_Bytes secondaryTextColor;
|
||||
public RGBA_Bytes primaryBackgroundColor;
|
||||
public RGBA_Bytes secondaryBackgroundColor;
|
||||
public RGBA_Bytes tabLabelSelectedColor;
|
||||
public RGBA_Bytes tabLabelUnselectedColor;
|
||||
|
||||
public RGBA_Bytes tertiaryBackgroundColor;
|
||||
public RGBA_Bytes tertiaryBackgroundColorDisabled;
|
||||
|
||||
private string name;
|
||||
|
||||
public string Name { get { return name; } }
|
||||
|
||||
private bool darkTheme;
|
||||
|
||||
public bool DarkTheme { get { return darkTheme; } }
|
||||
|
||||
public Theme(string name, RGBA_Bytes primary, RGBA_Bytes secondary, bool darkTheme = true)
|
||||
{
|
||||
this.darkTheme = darkTheme;
|
||||
this.name = name;
|
||||
|
||||
if (darkTheme)
|
||||
{
|
||||
this.primaryAccentColor = primary;
|
||||
this.secondaryAccentColor = secondary;
|
||||
|
||||
this.primaryBackgroundColor = new RGBA_Bytes(68, 68, 68);
|
||||
this.secondaryBackgroundColor = new RGBA_Bytes(51, 51, 51);
|
||||
|
||||
this.tabLabelSelectedColor = new RGBA_Bytes(255, 255, 255);
|
||||
this.tabLabelUnselectedColor = new RGBA_Bytes(180, 180, 180);
|
||||
this.primaryTextColor = new RGBA_Bytes(255, 255, 255);
|
||||
this.secondaryTextColor = new RGBA_Bytes(200, 200, 200);
|
||||
|
||||
this.tertiaryBackgroundColor = new RGBA_Bytes(62, 62, 62);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.primaryAccentColor = secondary;
|
||||
this.secondaryAccentColor = primary;
|
||||
|
||||
this.primaryBackgroundColor = new RGBA_Bytes(208, 208, 208);
|
||||
this.secondaryBackgroundColor = new RGBA_Bytes(185, 185, 185);
|
||||
this.tabLabelSelectedColor = new RGBA_Bytes(51, 51, 51);
|
||||
this.tabLabelUnselectedColor = new RGBA_Bytes(102, 102, 102);
|
||||
this.primaryTextColor = new RGBA_Bytes(34, 34, 34);
|
||||
this.secondaryTextColor = new RGBA_Bytes(51, 51, 51);
|
||||
|
||||
this.tertiaryBackgroundColor = new RGBA_Bytes(190, 190, 190);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ namespace MatterHackers.MatterControl.CustomWidgets.LibrarySelector
|
|||
this.AddChild(separator);
|
||||
|
||||
Button searchResultsButton = null;
|
||||
if (ActiveTheme.Instance.IsTouchScreen)
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
searchResultsButton = navigationButtonFactory.Generate("Search Results".Localize(), "icon_search_32x32.png");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ namespace MatterHackers.MatterControl.CustomWidgets.LibrarySelector
|
|||
PrintItemCollection localPrintItemCollection = printItemCollection;
|
||||
clickThumbnail.Click += (sender, e) =>
|
||||
{
|
||||
if (ActiveTheme.Instance.IsTouchScreen)
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
if (parentProvider == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ namespace MatterHackers.MatterControl
|
|||
this.Click += DoOnMouseClick;
|
||||
this.MouseEnterBounds += onEnter;
|
||||
this.MouseLeaveBounds += onExit;
|
||||
ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
private void DoOnMouseClick(object sender, EventArgs e)
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ namespace MatterHackers.MatterControl.CreatorPlugins
|
|||
|
||||
protected void AddHandlers()
|
||||
{
|
||||
ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
public void ThemeChanged(object sender, EventArgs e)
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
AddChild(container);
|
||||
|
||||
if (ActiveTheme.Instance.IsTouchScreen)
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
upImageBuffer = StaticData.Instance.LoadIcon("TouchScreen/arrow_up_32x24.png");
|
||||
downImageBuffer = StaticData.Instance.LoadIcon("TouchScreen/arrow_down_32x24.png");
|
||||
|
|
@ -133,7 +133,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
PrinterConnectionAndCommunication.Instance.ActivePrintItemChanged.RegisterEvent(Instance_PrintItemChanged, ref unregisterEvents);
|
||||
PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(Instance_PrintItemChanged, ref unregisterEvents);
|
||||
ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
|
||||
SetThemedColors();
|
||||
UpdatePrintStatus();
|
||||
|
|
|
|||
|
|
@ -43,65 +43,61 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
this.Padding = new BorderDouble(2, 0);
|
||||
this.colorToChangeTo = colorToChangeTo;
|
||||
int themeCount = ActiveTheme.Instance.AvailableThemes.Count;
|
||||
int themeCount = ActiveTheme.AvailableThemes.Count;
|
||||
|
||||
var allThemes = ActiveTheme.AvailableThemes;
|
||||
|
||||
int index = 0;
|
||||
for (int x = 0; x < themeCount / 2; x++)
|
||||
{
|
||||
FlowLayoutWidget columnContainer = new FlowLayoutWidget(Agg.UI.FlowDirection.TopToBottom);
|
||||
columnContainer.Width = containerHeight;
|
||||
var columnContainer = new FlowLayoutWidget(Agg.UI.FlowDirection.TopToBottom)
|
||||
{
|
||||
Width = containerHeight
|
||||
};
|
||||
columnContainer.AddChild(CreateThemeButton(allThemes[index], index));
|
||||
|
||||
Button buttonOne = getThemeButton(index);
|
||||
Button buttonTwo = getThemeButton(index + themeCount / 2);
|
||||
|
||||
columnContainer.AddChild(buttonTwo);
|
||||
columnContainer.AddChild(buttonOne);
|
||||
int secondRowIndex = index + themeCount / 2;
|
||||
columnContainer.AddChild(CreateThemeButton(allThemes[secondRowIndex], secondRowIndex));
|
||||
|
||||
this.AddChild(columnContainer);
|
||||
|
||||
index++;
|
||||
}
|
||||
this.BackgroundColor = RGBA_Bytes.White;
|
||||
this.Width = containerHeight * (themeCount / 2);
|
||||
}
|
||||
|
||||
public Button getThemeButton(int index)
|
||||
public Button CreateThemeButton(IThemeColors theme, int index)
|
||||
{
|
||||
GuiWidget normal = new GuiWidget(colorSelectSize, colorSelectSize);
|
||||
normal.BackgroundColor = ActiveTheme.Instance.AvailableThemes[index].primaryAccentColor;
|
||||
GuiWidget hover = new GuiWidget(colorSelectSize, colorSelectSize);
|
||||
hover.BackgroundColor = ActiveTheme.Instance.AvailableThemes[index].secondaryAccentColor;
|
||||
GuiWidget pressed = new GuiWidget(colorSelectSize, colorSelectSize);
|
||||
pressed.BackgroundColor = ActiveTheme.Instance.AvailableThemes[index].secondaryAccentColor;
|
||||
GuiWidget disabled = new GuiWidget(colorSelectSize, colorSelectSize);
|
||||
var normal = new GuiWidget(colorSelectSize, colorSelectSize);
|
||||
normal.BackgroundColor = theme.PrimaryAccentColor;
|
||||
|
||||
Button colorButton = new Button(0, 0, new ButtonViewStates(normal, hover, pressed, disabled));
|
||||
colorButton.Name = index.ToString();
|
||||
colorButton.Click += (sender, mouseEvent) =>
|
||||
var hover = new GuiWidget(colorSelectSize, colorSelectSize);
|
||||
hover.BackgroundColor = theme.SecondaryAccentColor;
|
||||
|
||||
var pressed = new GuiWidget(colorSelectSize, colorSelectSize);
|
||||
pressed.BackgroundColor = theme.SecondaryAccentColor;
|
||||
|
||||
var disabled = new GuiWidget(colorSelectSize, colorSelectSize);
|
||||
|
||||
var colorButton = new Button(0, 0, new ButtonViewStates(normal, hover, pressed, disabled));
|
||||
colorButton.Click += (s, e) =>
|
||||
{
|
||||
string themeIndex = ((GuiWidget)sender).Name;
|
||||
ActiveSliceSettings.Instance.SetActiveValue("MatterControl.ActiveThemeIndex", themeIndex);
|
||||
ActiveTheme.Instance.LoadThemeSettings(int.Parse(themeIndex));
|
||||
UserSettings.Instance.set("ActiveThemeIndex", index.ToString());
|
||||
ActiveTheme.Instance = theme;
|
||||
};
|
||||
|
||||
colorButton.MouseEnterBounds += (sender, mouseEvent) =>
|
||||
colorButton.MouseEnterBounds += (s, e) =>
|
||||
{
|
||||
colorToChangeTo.BackgroundColor = ActiveTheme.Instance.AvailableThemes[index].primaryAccentColor;
|
||||
colorToChangeTo.BackgroundColor = theme.PrimaryAccentColor;
|
||||
};
|
||||
|
||||
colorButton.MouseLeaveBounds += (sender, mouseEvent) =>
|
||||
colorButton.MouseLeaveBounds += (s, e) =>
|
||||
{
|
||||
colorToChangeTo.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;
|
||||
};
|
||||
|
||||
return colorButton;
|
||||
}
|
||||
|
||||
public override void OnDraw(Graphics2D graphics2D)
|
||||
{
|
||||
base.OnDraw(graphics2D);
|
||||
RectangleDouble border = LocalBounds;
|
||||
border.Deflate(new BorderDouble(1));
|
||||
//graphics2D.Rectangle(border, ActiveTheme.Instance.SecondaryBackgroundColor, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public WizardControl()
|
||||
{
|
||||
if (ActiveTheme.Instance.IsTouchScreen)
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
extraTextScaling = 1.33333;
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ namespace MatterHackers.MatterControl
|
|||
FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
topToBottom.AnchorAll();
|
||||
|
||||
if (ActiveTheme.Instance.IsTouchScreen)
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
topToBottom.Padding = new BorderDouble(12);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ namespace MatterHackers.MatterControl.PrintHistory
|
|||
|
||||
private void AddHandlers()
|
||||
{
|
||||
ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
MouseEnterBounds += new EventHandler(HistoryItem_MouseEnterBounds);
|
||||
MouseLeaveBounds += new EventHandler(HistoryItem_MouseLeaveBounds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
|
||||
clickThumbnail.Click += (sender, e) =>
|
||||
{
|
||||
if (ActiveTheme.Instance.IsTouchScreen)
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
if (parentProvider == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
|
||||
private void AddHandlers()
|
||||
{
|
||||
//ActiveTheme.Instance.ThemeChanged.RegisterEvent(onThemeChanged, ref unregisterEvents);
|
||||
//ActiveTheme.ThemeChanged.RegisterEvent(onThemeChanged, ref unregisterEvents);
|
||||
GestureFling += (object sender, FlingEventArgs eventArgs) =>
|
||||
{
|
||||
if (!this.libraryDataView.EditMode)
|
||||
|
|
@ -373,7 +373,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
{
|
||||
//this.VAnchor = Agg.UI.VAnchor.FitToChildren;
|
||||
this.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
|
||||
if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen)
|
||||
if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen)
|
||||
{
|
||||
this.Height = 65;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -469,7 +469,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
{
|
||||
//this.VAnchor = Agg.UI.VAnchor.FitToChildren;
|
||||
this.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
|
||||
if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen)
|
||||
if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen)
|
||||
{
|
||||
this.Height = 65;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -309,7 +309,6 @@
|
|||
<Compile Include="CustomWidgets\SlidePanelWidget.cs" />
|
||||
<Compile Include="CustomWidgets\StyledDropDownList.cs" />
|
||||
<Compile Include="ControlElements\StyledMessageBoxWindow.cs" />
|
||||
<Compile Include="ControlElements\ThemeFactory.cs" />
|
||||
<Compile Include="CustomWidgets\WizardControl.cs" />
|
||||
<Compile Include="DataStorage\SQLiteCommon.cs" />
|
||||
<Compile Include="DataStorage\SQLiteWin32.cs" />
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
GuiWidget.DefaultEnforceIntegerBounds = true;
|
||||
|
||||
if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen)
|
||||
if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen)
|
||||
{
|
||||
GuiWidget.DeviceScale = 1.3;
|
||||
}
|
||||
|
|
@ -394,6 +394,7 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
if (instance == null)
|
||||
{
|
||||
LoadUITheme();
|
||||
instance = CreateInstance();
|
||||
instance.ShowAsSystemWindow();
|
||||
}
|
||||
|
|
@ -402,6 +403,36 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
public static void LoadUITheme()
|
||||
{
|
||||
//Load the default theme by index
|
||||
if (string.IsNullOrEmpty(UserSettings.Instance.get("ActiveThemeIndex")))
|
||||
{
|
||||
for (int i = 0; i < ActiveTheme.AvailableThemes.Count; i++)
|
||||
{
|
||||
IThemeColors current = ActiveTheme.AvailableThemes[i];
|
||||
if (current.Name == OemSettings.Instance.ThemeColor)
|
||||
{
|
||||
UserSettings.Instance.set("ActiveThemeIndex", i.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int themeIndex;
|
||||
if (int.TryParse(UserSettings.Instance.get("ActiveThemeIndex"), out themeIndex) && themeIndex < ActiveTheme.AvailableThemes.Count)
|
||||
{
|
||||
try
|
||||
{
|
||||
ActiveTheme.Instance = ActiveTheme.AvailableThemes[themeIndex];
|
||||
}
|
||||
catch
|
||||
{
|
||||
GuiWidget.BreakInDebugger();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static MatterControlApplication CreateInstance()
|
||||
{
|
||||
// try and open our window matching the last size that we had for it.
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
protected static SolidSlider InsertUiForSlider(FlowLayoutWidget wordOptionContainer, string header, double min = 0, double max = .5)
|
||||
{
|
||||
double scrollBarWidth = 10;
|
||||
if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen)
|
||||
if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen)
|
||||
{
|
||||
scrollBarWidth = 20;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public PartPreviewWidget()
|
||||
{
|
||||
if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen)
|
||||
if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen)
|
||||
{
|
||||
SideBarButtonWidth = 180;
|
||||
ShortButtonHeight = 40;
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
tabControl.TabBar.Padding = new BorderDouble(top: 6);
|
||||
|
||||
RGBA_Bytes selectedTabColor;
|
||||
if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Responsive)
|
||||
if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Responsive)
|
||||
{
|
||||
tabControl.TabBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||
selectedTabColor = ActiveTheme.Instance.TabLabelSelected;
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
private void AddHandlers()
|
||||
{
|
||||
ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
public void ThemeChanged(object sender, EventArgs e)
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ namespace MatterHackers.MatterControl
|
|||
if (firstDraw)
|
||||
{
|
||||
if (textToAddWidget != null
|
||||
&& !ActiveTheme.Instance.IsTouchScreen)
|
||||
&& !UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
UiThread.RunOnIdle(textToAddWidget.Focus);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -435,7 +435,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
}
|
||||
|
||||
ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
|
||||
meshViewerWidget.interactionVolumes.Add(new UpArrow3D(this));
|
||||
meshViewerWidget.interactionVolumes.Add(new SelectionShadow(this));
|
||||
|
|
@ -1344,7 +1344,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
string renderTypeString = UserSettings.Instance.get("defaultRenderSetting");
|
||||
if (renderTypeString == null)
|
||||
{
|
||||
if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen)
|
||||
if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen)
|
||||
{
|
||||
renderTypeString = "Shaded";
|
||||
}
|
||||
|
|
@ -1512,7 +1512,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
viewOptionContainer.AddChild(showBuildVolumeCheckBox);
|
||||
}
|
||||
|
||||
if (ActiveTheme.Instance.IsTouchScreen)
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
UserSettings.Instance.set("defaultRenderSetting", RenderTypes.Shaded.ToString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public ViewControlsBase()
|
||||
{
|
||||
if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen)
|
||||
if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen)
|
||||
{
|
||||
buttonHeight = 40;
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public ViewControls2D()
|
||||
{
|
||||
if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen)
|
||||
if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen)
|
||||
{
|
||||
buttonHeight = 40;
|
||||
}
|
||||
|
|
@ -137,7 +137,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
threeDimensionButton = iconTextImageButtonFactory.GenerateRadioButton("", select3dIconPath);
|
||||
threeDimensionButton.Margin = new BorderDouble(3);
|
||||
|
||||
if (ActiveTheme.Instance.DisplayMode != ActiveTheme.ApplicationDisplayType.Touchscreen)
|
||||
if (UserSettings.Instance.DisplayMode != ApplicationDisplayType.Touchscreen)
|
||||
{
|
||||
AddChild(threeDimensionButton);
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public ViewControls3D(MeshViewerWidget meshViewerWidget)
|
||||
{
|
||||
if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen)
|
||||
if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen)
|
||||
{
|
||||
buttonHeight = 40;
|
||||
}
|
||||
|
|
@ -198,7 +198,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
SetMeshViewerDisplayTheme();
|
||||
partSelectButton.CheckedStateChanged += SetMeshViewerDisplayTheme;
|
||||
|
||||
ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
private event EventHandler unregisterEvents;
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
this.windowMode = windowMode;
|
||||
this.printItem = printItem;
|
||||
|
||||
if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen)
|
||||
if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen)
|
||||
{
|
||||
sliderWidth = 20;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
|
||||
double sliderWidth = 300 * GuiWidget.DeviceScale;
|
||||
double sliderThumbWidth = 10 * GuiWidget.DeviceScale;
|
||||
if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen)
|
||||
if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen)
|
||||
{
|
||||
sliderThumbWidth = 15 * GuiWidget.DeviceScale;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
};
|
||||
}
|
||||
|
||||
bool touchScreenMode = ActiveTheme.Instance.IsTouchScreen;
|
||||
bool touchScreenMode = UserSettings.Instance.IsTouchScreen;
|
||||
|
||||
if (OemSettings.Instance.ShowShopButton)
|
||||
{
|
||||
|
|
@ -704,7 +704,7 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
{
|
||||
menuItems = new List<PrintItemAction>();
|
||||
|
||||
if (ActiveTheme.Instance.IsTouchScreen)
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
menuItems.Add(new PrintItemAction()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -389,7 +389,7 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
|
||||
private void AddHandlers()
|
||||
{
|
||||
ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
PrintItemWrapper.SlicingOutputMessage += PrintItem_SlicingOutputMessage;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ using System.Linq;
|
|||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
public enum ApplicationDisplayType { Responsive, Touchscreen };
|
||||
|
||||
public class UserSettings
|
||||
{
|
||||
private static UserSettings globalInstance = null;
|
||||
|
|
@ -89,5 +91,22 @@ namespace MatterHackers.MatterControl
|
|||
setting.Value = value;
|
||||
setting.Commit();
|
||||
}
|
||||
|
||||
public ApplicationDisplayType DisplayMode
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.get("ApplicationDisplayMode") == "touchscreen")
|
||||
{
|
||||
return ApplicationDisplayType.Touchscreen;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ApplicationDisplayType.Responsive;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsTouchScreen => this.get("ApplicationDisplayMode") == "touchscreen";
|
||||
}
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
mainContainer.AddChild(buttonContainer);
|
||||
|
||||
if (ActiveTheme.Instance.IsTouchScreen)
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
// the redeem design code button
|
||||
{
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
this.AnchorAll();
|
||||
|
||||
ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
|
||||
|
||||
cancelButton = textImageButtonFactory.Generate(unlocalizedTextForCancelButton.Localize());
|
||||
cancelButton.Name = unlocalizedTextForCancelButton;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
BedSettings.SetMakeAndModel(activeInstance.Make, activeInstance.Model);
|
||||
}
|
||||
|
||||
ActiveTheme.Instance.SwitchToPrinterThemeWithoutReloadEvent();
|
||||
SwitchToPrinterThemeWithoutReloadEvent();
|
||||
|
||||
if (!MatterControlApplication.IsLoading)
|
||||
{
|
||||
|
|
@ -85,6 +85,29 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Switches to the ActivePrinter theme without firing the ThemeChanged event. This is useful when changing printers and
|
||||
/// allows the theme state to be updated before the ActivePrinterChanged event fires, resulting in a single ReloadAll
|
||||
/// occurring rather than two
|
||||
/// </summary>
|
||||
public static void SwitchToPrinterThemeWithoutReloadEvent()
|
||||
{
|
||||
if (ActiveSliceSettings.Instance != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
int themeIndex = Convert.ToInt32(ActiveSliceSettings.Instance.ActiveValue("MatterControl.ActiveThemeIndex"));
|
||||
|
||||
ActiveTheme.SuspendEvents();
|
||||
ActiveTheme.Instance = ActiveTheme.AvailableThemes[themeIndex];
|
||||
ActiveTheme.ResumeEvents();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static ActiveSliceSettings()
|
||||
{
|
||||
// Ensure the profiles directory exists
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 935cac90bbc3c426e4ddcdcb693c193284bca1de
|
||||
Subproject commit 48146f6266d90835c98a10df1533650e78cf47c5
|
||||
Loading…
Add table
Add a link
Reference in a new issue