Get the starting color set correctly
Made the android printer select window fix its colors on change
This commit is contained in:
parent
71b5e30bba
commit
9896346610
7 changed files with 92 additions and 36 deletions
|
|
@ -87,7 +87,6 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
// Rebuild the droplist any time the Profiles list changes
|
||||
ProfileManager.ProfilesListChanged.RegisterEvent((s, e) => Rebuild(), ref unregisterEvents);
|
||||
ApplicationController.Instance.ReloadAllRequested.RegisterEvent((s, e) => Rebuild(), ref unregisterEvents);
|
||||
}
|
||||
|
||||
public void Rebuild()
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public abstract class ApplicationView : GuiWidget
|
||||
{
|
||||
public abstract void AddElements();
|
||||
public abstract void CreateAndAddChildren();
|
||||
}
|
||||
|
||||
public class TouchscreenView : ApplicationView
|
||||
|
|
@ -82,7 +82,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public TouchscreenView()
|
||||
{
|
||||
AddElements();
|
||||
CreateAndAddChildren();
|
||||
this.AnchorAll();
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ namespace MatterHackers.MatterControl
|
|||
this.TopContainer.Visible = !this.TopContainer.Visible;
|
||||
}
|
||||
|
||||
public override void AddElements()
|
||||
public override void CreateAndAddChildren()
|
||||
{
|
||||
topIsHidden = false;
|
||||
this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||
|
|
@ -141,11 +141,11 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public DesktopView()
|
||||
{
|
||||
AddElements();
|
||||
CreateAndAddChildren();
|
||||
this.AnchorAll();
|
||||
}
|
||||
|
||||
public override void AddElements()
|
||||
public override void CreateAndAddChildren()
|
||||
{
|
||||
this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||
|
||||
|
|
@ -185,7 +185,6 @@ namespace MatterHackers.MatterControl
|
|||
private static ApplicationController globalInstance;
|
||||
public RootedObjectEventHandler AdvancedControlsPanelReloading = new RootedObjectEventHandler();
|
||||
public RootedObjectEventHandler CloudSyncStatusChanged = new RootedObjectEventHandler();
|
||||
public RootedObjectEventHandler ReloadAllRequested = new RootedObjectEventHandler();
|
||||
public RootedObjectEventHandler DoneReloadingAll = new RootedObjectEventHandler();
|
||||
public RootedObjectEventHandler PluginsLoaded = new RootedObjectEventHandler();
|
||||
|
||||
|
|
@ -400,17 +399,14 @@ namespace MatterHackers.MatterControl
|
|||
&& MainView != null)
|
||||
{
|
||||
pendingReloadRequest = true;
|
||||
MainView.AfterDraw += DoReloadAll;
|
||||
MainView.Invalidate();
|
||||
DoReloadAll();
|
||||
}
|
||||
|
||||
ReloadAllRequested?.CallEvents(null, null);
|
||||
}
|
||||
|
||||
static int reloadCount = 0;
|
||||
private void DoReloadAll(GuiWidget drawingWidget, DrawEventArgs e)
|
||||
private void DoReloadAll()
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
UiThread.RunOnIdle((Action)(() =>
|
||||
{
|
||||
if (MainView != null)
|
||||
{
|
||||
|
|
@ -422,16 +418,15 @@ namespace MatterHackers.MatterControl
|
|||
MainView?.CloseAllChildren();
|
||||
using (new QuickTimer("ReloadAll_AddElements"))
|
||||
{
|
||||
MainView?.AddElements();
|
||||
MainView?.CreateAndAddChildren();
|
||||
}
|
||||
PopOutManager.SaveIfClosed = true;
|
||||
DoneReloadingAll?.CallEvents(null, null);
|
||||
this.DoneReloadingAll?.CallEvents((object)null, (EventArgs)null);
|
||||
}
|
||||
|
||||
MainView.AfterDraw -= DoReloadAll;
|
||||
pendingReloadRequest = false;
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
public void OnApplicationClosed()
|
||||
|
|
@ -441,6 +436,19 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
static void LoadUITheme()
|
||||
{
|
||||
// if the user setting has a theme color assume it is correct and use it right away
|
||||
if (UserSettings.Instance != null)
|
||||
{
|
||||
var themeName = UserSettings.Instance.get(UserSettingsKey.ActiveThemeName);
|
||||
if (!string.IsNullOrEmpty(themeName))
|
||||
{
|
||||
ActiveTheme.Instance = ActiveTheme.GetThemeColors(themeName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// if not check for the oem color and use it if set
|
||||
// else default to "Blue - Light"
|
||||
string oemColor = OemSettings.Instance.ThemeColor;
|
||||
if (string.IsNullOrEmpty(oemColor))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,35 @@
|
|||
using MatterHackers.Agg;
|
||||
/*
|
||||
Copyright (c) 2016, Lars Brubaker
|
||||
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 MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
|
|
@ -104,21 +134,5 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDraw(Graphics2D graphics2D)
|
||||
{
|
||||
RectangleDouble localBounds = LocalBounds;
|
||||
//// bottom
|
||||
//graphics2D.Line(localBounds.Left + lineInset, localBounds.Bottom + lineInset, localBounds.Left + Width - lineInset, localBounds.Bottom + lineInset, this.borderColor);
|
||||
//// left
|
||||
//graphics2D.Line(localBounds.Left + lineInset, localBounds.Bottom + lineInset, localBounds.Left + lineInset, localBounds.Bottom + Height - lineInset, this.borderColor);
|
||||
//// right
|
||||
//graphics2D.Line(localBounds.Left + Width - lineInset, localBounds.Bottom + lineInset, localBounds.Left + Width - lineInset, localBounds.Bottom + Height - lineInset, this.borderColor);
|
||||
//// top
|
||||
//graphics2D.Line(localBounds.Left + lineInset, localBounds.Bottom + Height - lineInset, groupBoxLabel.BoundsRelativeToParent.Left - 2, localBounds.Bottom + Height - lineInset, this.borderColor);
|
||||
//graphics2D.Line(groupBoxLabel.BoundsRelativeToParent.Right + 2, localBounds.Bottom + Height - lineInset, localBounds.Left + Width - lineInset, localBounds.Bottom + Height - lineInset, this.borderColor);
|
||||
|
||||
base.OnDraw(graphics2D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -39,6 +39,8 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
public class SetupOptionsPage : WizardPage
|
||||
{
|
||||
private event EventHandler unregisterEvents;
|
||||
|
||||
public SetupOptionsPage()
|
||||
: base("Done")
|
||||
{
|
||||
|
|
@ -127,6 +129,12 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
public override void OnClosed(EventArgs e)
|
||||
{
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
base.OnClosed(e);
|
||||
}
|
||||
}
|
||||
|
||||
public class SetupAccountView : SetupViewBase
|
||||
|
|
@ -248,7 +256,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
mainContainer.AddChild(buttonContainer);
|
||||
|
||||
ApplicationController.Instance.ReloadAllRequested.RegisterEvent(RemoveAndNewControl, ref unregisterEvents);
|
||||
ApplicationController.Instance.DoneReloadingAll.RegisterEvent(RemoveAndNewControl, ref unregisterEvents);
|
||||
}
|
||||
|
||||
private void RemoveAndNewControl(object sender, EventArgs e)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
public class WizardWindow : SystemWindow
|
||||
{
|
||||
private event EventHandler unregisterEvents;
|
||||
public static Func<bool> ShouldShowAuthPanel { get; set; }
|
||||
public static Action ShowAuthDialog;
|
||||
public static Action ChangeToAccountCreate;
|
||||
|
|
@ -114,6 +115,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public override void OnClosed(EventArgs e)
|
||||
{
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
|
|
@ -173,7 +175,25 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
internal void ChangeToPage<PanelType>() where PanelType : WizardPage, new()
|
||||
{
|
||||
ChangeToPage(new PanelType());
|
||||
PanelType panel = new PanelType();
|
||||
ChangeToPage(panel);
|
||||
|
||||
// in the event of a reload all make sure we rebuild the contents correctly
|
||||
ApplicationController.Instance.DoneReloadingAll.RegisterEvent((s,e) =>
|
||||
{
|
||||
// fix the main window background color if needed
|
||||
BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||
|
||||
// find out where the contents we put in last time are
|
||||
int thisIndex = GetChildIndex(panel);
|
||||
RemoveChild(panel);
|
||||
// make new content with the possibly changed theme
|
||||
PanelType newPanel = new PanelType();
|
||||
AddChild(newPanel, thisIndex);
|
||||
panel.CloseOnIdle();
|
||||
// remember the new content
|
||||
panel = newPanel;
|
||||
}, ref unregisterEvents);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -143,6 +143,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
ActiveTheme.SuspendEvents();
|
||||
}
|
||||
ActiveTheme.Instance = ActiveTheme.GetThemeColors(activeThemeName);
|
||||
|
||||
// Save the theme so we can load it first thing on startup before a profile is loaded.
|
||||
UserSettings.Instance.set(UserSettingsKey.ActiveThemeName, ActiveTheme.Instance.Name);
|
||||
|
||||
ActiveTheme.ResumeEvents();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5650,3 +5650,6 @@ Translated:Actions
|
|||
English:Show In Action Menu
|
||||
Translated:Show In Action Menu
|
||||
|
||||
English:Unable to Connect
|
||||
Translated:Unable to Connect
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue