Collapse PlusTabPage sidebar into content area
This commit is contained in:
parent
a17c49dbe8
commit
300d58f9d0
4 changed files with 152 additions and 145 deletions
|
|
@ -41,155 +41,15 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
|||
{
|
||||
public PlusTabPage(PartPreviewContent partPreviewContent, SimpleTabs simpleTabs, ThemeConfig theme)
|
||||
{
|
||||
Name = "PlusTabPage";
|
||||
var leftContent = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
VAnchor = VAnchor.Stretch,
|
||||
Padding = 15
|
||||
};
|
||||
this.AddChild(leftContent);
|
||||
this.Name = "PlusTabPage";
|
||||
|
||||
if (OemSettings.Instance.ShowShopButton)
|
||||
{
|
||||
this.AddChild(new ExplorePanel(theme));
|
||||
this.AddChild(new ExplorePanel(partPreviewContent, simpleTabs, theme));
|
||||
}
|
||||
|
||||
this.HAnchor = HAnchor.Stretch;
|
||||
this.VAnchor = VAnchor.Stretch;
|
||||
|
||||
BorderDouble buttonSpacing = 3;
|
||||
|
||||
// put in the add new design stuff
|
||||
var createItemsSection = CreateSection(leftContent, "Create New".Localize() + ":");
|
||||
|
||||
var createPart = theme.ButtonFactory.Generate("Create Part".Localize());
|
||||
createPart.Margin = buttonSpacing;
|
||||
createPart.HAnchor = HAnchor.Left;
|
||||
createItemsSection.AddChild(createPart);
|
||||
createPart.Click += (s, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
BedConfig bed;
|
||||
simpleTabs.RemoveTab(simpleTabs.ActiveTab);
|
||||
partPreviewContent.CreatePartTab(
|
||||
"New Part",
|
||||
bed = new BedConfig(),
|
||||
theme);
|
||||
|
||||
bed.LoadContent(
|
||||
new EditContext()
|
||||
{
|
||||
ContentStore = ApplicationController.Instance.Library.PlatingHistory,
|
||||
SourceItem = BedConfig.NewPlatingItem()
|
||||
}).ConfigureAwait(false);
|
||||
});
|
||||
};
|
||||
|
||||
var createPrinter = theme.ButtonFactory.Generate("Create Printer".Localize());
|
||||
createPrinter.Name = "Create Printer";
|
||||
createPrinter.Margin = buttonSpacing;
|
||||
createPrinter.HAnchor = HAnchor.Left;
|
||||
createPrinter.Click += (s, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
simpleTabs.RemoveTab(simpleTabs.ActiveTab);
|
||||
|
||||
if (ApplicationController.Instance.ActivePrinter.Connection.PrinterIsPrinting
|
||||
|| ApplicationController.Instance.ActivePrinter.Connection.PrinterIsPaused)
|
||||
{
|
||||
StyledMessageBox.ShowMessageBox("Please wait until the print has finished and try again.".Localize(), "Can't add printers while printing".Localize());
|
||||
}
|
||||
else
|
||||
{
|
||||
DialogWindow.Show(PrinterSetup.GetBestStartPage(PrinterSetup.StartPageOptions.ShowMakeModel));
|
||||
}
|
||||
});
|
||||
};
|
||||
createItemsSection.AddChild(createPrinter);
|
||||
|
||||
var importButton = theme.ButtonFactory.Generate("Import Printer".Localize());
|
||||
importButton.Margin = buttonSpacing;
|
||||
importButton.HAnchor = HAnchor.Left;
|
||||
importButton.Click += (s, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
AggContext.FileDialogs.OpenFileDialog(
|
||||
new OpenFileDialogParams(
|
||||
"settings files|*.ini;*.printer;*.slice"),
|
||||
(result) =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(result.FileName)
|
||||
&& File.Exists(result.FileName))
|
||||
{
|
||||
simpleTabs.RemoveTab(simpleTabs.ActiveTab);
|
||||
ImportSettingsPage.ImportFromExisting(result.FileName);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
createItemsSection.AddChild(importButton);
|
||||
|
||||
var existingPrinterSection = CreateSection(leftContent, "Open Existing".Localize() + ":");
|
||||
|
||||
var printerSelector = new PrinterSelector(theme)
|
||||
{
|
||||
Margin = new BorderDouble(left: 15)
|
||||
};
|
||||
existingPrinterSection.AddChild(printerSelector);
|
||||
|
||||
var otherItemsSection = CreateSection(leftContent, "Other".Localize() + ":");
|
||||
|
||||
var redeemDesignCode = theme.ButtonFactory.Generate("Redeem Design Code".Localize());
|
||||
redeemDesignCode.Name = "Redeem Design Code Button";
|
||||
redeemDesignCode.Margin = buttonSpacing;
|
||||
redeemDesignCode.HAnchor = HAnchor.Left;
|
||||
redeemDesignCode.Click += (s, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
simpleTabs.RemoveTab(simpleTabs.ActiveTab);
|
||||
// Implementation already does RunOnIdle
|
||||
ApplicationController.Instance.RedeemDesignCode?.Invoke();
|
||||
});
|
||||
};
|
||||
otherItemsSection.AddChild(redeemDesignCode);
|
||||
|
||||
var redeemShareCode = theme.ButtonFactory.Generate("Enter Share Code".Localize());
|
||||
redeemShareCode.Name = "Enter Share Code Button";
|
||||
redeemShareCode.Margin = buttonSpacing;
|
||||
redeemShareCode.HAnchor = HAnchor.Left;
|
||||
redeemShareCode.Click += (s, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
simpleTabs.RemoveTab(simpleTabs.ActiveTab);
|
||||
|
||||
// Implementation already does RunOnIdle
|
||||
ApplicationController.Instance.EnterShareCode?.Invoke();
|
||||
});
|
||||
};
|
||||
otherItemsSection.AddChild(redeemShareCode);
|
||||
}
|
||||
|
||||
private FlowLayoutWidget CreateSection(GuiWidget parent, string headingText)
|
||||
{
|
||||
// Add heading
|
||||
parent.AddChild(new TextWidget(headingText, textColor: ActiveTheme.Instance.PrimaryTextColor)
|
||||
{
|
||||
HAnchor = HAnchor.Left
|
||||
});
|
||||
|
||||
// Add container
|
||||
var container = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
Margin = new BorderDouble(10, 10, 10, 8),
|
||||
};
|
||||
parent.AddChild(container);
|
||||
|
||||
return container;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue