Made the settings history be disabled when not signed in.

MatterHackers/MCCentral#330
Settings History menu should be disabled when not signed in
This commit is contained in:
Lars Brubaker 2016-08-31 13:09:06 -07:00
parent b6dcacdef9
commit db24db1cf2
2 changed files with 21 additions and 46 deletions

View file

@ -136,9 +136,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
ActiveTheme.SuspendEvents(); ActiveTheme.SuspendEvents();
} }
} }
else
{
}
ActiveTheme.Instance = ActiveTheme.GetThemeColors(activeThemeName); ActiveTheme.Instance = ActiveTheme.GetThemeColors(activeThemeName);
ActiveTheme.ResumeEvents(); ActiveTheme.ResumeEvents();
} }

View file

@ -12,7 +12,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{ {
public class SliceSettingsDetailControl : FlowLayoutWidget public class SliceSettingsDetailControl : FlowLayoutWidget
{ {
public DropDownMenu sliceOptionsMenuDropList;
private const string SliceSettingsLevelEntry = "SliceSettingsLevel"; private const string SliceSettingsLevelEntry = "SliceSettingsLevel";
private const string SliceSettingsShowHelpEntry = "SliceSettingsShowHelp"; private const string SliceSettingsShowHelpEntry = "SliceSettingsShowHelp";
private DropDownList settingsDetailSelector; private DropDownList settingsDetailSelector;
@ -92,40 +91,32 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
public string SelectedValue => settingsDetailSelector.SelectedValue; public string SelectedValue => settingsDetailSelector.SelectedValue;
public bool ShowingHelp => showHelpBox.Checked; public bool ShowingHelp => showHelpBox.Checked;
private DropDownMenu GetSliceOptionsMenuDropList() private DropDownMenu GetSliceOptionsMenuDropList()
{ {
if (sliceOptionsMenuDropList == null) DropDownMenu sliceOptionsMenuDropList;
sliceOptionsMenuDropList = new DropDownMenu("Options".Localize() + "... ")
{ {
sliceOptionsMenuDropList = new DropDownMenu("Options".Localize() + "... ") HoverColor = new RGBA_Bytes(0, 0, 0, 50),
{ NormalColor = new RGBA_Bytes(0, 0, 0, 0),
HoverColor = new RGBA_Bytes(0, 0, 0, 50), BorderColor = new RGBA_Bytes(ActiveTheme.Instance.SecondaryTextColor, 100),
NormalColor = new RGBA_Bytes(0, 0, 0, 0), BackgroundColor = new RGBA_Bytes(0, 0, 0, 0),
BorderColor = new RGBA_Bytes(ActiveTheme.Instance.SecondaryTextColor, 100), BorderWidth = 1,
BackgroundColor = new RGBA_Bytes(0, 0, 0, 0), MenuAsWideAsItems = false,
BorderWidth = 1, AlignToRightEdge = true,
MenuAsWideAsItems = false, };
AlignToRightEdge = true, sliceOptionsMenuDropList.VAnchor |= VAnchor.ParentCenter;
};
sliceOptionsMenuDropList.VAnchor |= VAnchor.ParentCenter;
sliceOptionsMenuDropList.SelectionChanged += new EventHandler(MenuDropList_SelectionChanged);
//Set the name and callback function of the menu items sliceOptionsMenuDropList.AddItem("Import".Localize()).Selected += (s, e) => { ImportSettingsMenu_Click(); };
slicerOptionsMenuItems = new TupleList<string, Func<bool>> sliceOptionsMenuDropList.AddItem("Export".Localize()).Selected += (s, e) => { WizardWindow.Show<ExportSettingsPage>("ExportSettingsPage", "Export Settings"); };
{
{ "Import".Localize(), ImportSettingsMenu_Click },
{ "Export".Localize(), () => { WizardWindow.Show<ExportSettingsPage>("ExportSettingsPage", "Export Settings"); return true; } },
{ "Settings History".Localize(), () => { WizardWindow.Show<PrinterProfileHistoryPage>("PrinterProfileHistory", "Profile History"); return true; } },
{ "Reset to defaults".Localize(),() => { UiThread.RunOnIdle(ResetToDefaults); return true; } },
};
//Add the menu items to the menu itself MenuItem settingsHistory = sliceOptionsMenuDropList.AddItem("Settings History".Localize());
foreach (Tuple<string, Func<bool>> item in slicerOptionsMenuItems) settingsHistory.Selected += (s, e) => { WizardWindow.Show<PrinterProfileHistoryPage>("PrinterProfileHistory", "Profile History"); };
{
sliceOptionsMenuDropList.AddItem(item.Item1); settingsHistory.Enabled = ApplicationController.Instance.GetSessionUsername() != null;
}
} sliceOptionsMenuDropList.AddItem("Reset to defaults".Localize()).Selected += (s, e) => { UiThread.RunOnIdle(ResetToDefaults); };
return sliceOptionsMenuDropList; return sliceOptionsMenuDropList;
} }
@ -136,20 +127,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
return true; return true;
} }
private void MenuDropList_SelectionChanged(object sender, EventArgs e)
{
string menuSelection = ((DropDownMenu)sender).SelectedValue;
foreach (Tuple<string, Func<bool>> item in slicerOptionsMenuItems)
{
// if the menu we select is this one
if (item.Item1 == menuSelection)
{
// call its function
item.Item2();
}
}
}
private void RebuildSlicerSettings(object sender, EventArgs e) private void RebuildSlicerSettings(object sender, EventArgs e)
{ {
UserSettings.Instance.set(SliceSettingsLevelEntry, settingsDetailSelector.SelectedValue); UserSettings.Instance.set(SliceSettingsLevelEntry, settingsDetailSelector.SelectedValue);