Show OpenFileDialog and import settings to new printer

- MatterHackers/MCCentral#2176
Import printer from +tab should create a new printer rather than ask
This commit is contained in:
John Lewin 2017-11-07 14:15:34 -08:00
parent 46c1027466
commit 5699117a61
2 changed files with 40 additions and 23 deletions

View file

@ -27,6 +27,7 @@ of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
using System.IO;
using MatterHackers.Agg;
using MatterHackers.Agg.Platform;
using MatterHackers.Agg.UI;
@ -83,6 +84,28 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
};
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))
{
ImportSettingsPage.ImportFromExisting(result.FileName);
}
});
});
};
createItemsSection.AddChild(importButton);
var existingPrinterSection = CreateSection("Open Existing".Localize() + ":");
var printerSelector = new PrinterSelector()
@ -115,15 +138,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
};
otherItemsSection.AddChild(redeemShareCode);
var importButton = theme.ButtonFactory.Generate("Import".Localize());
importButton.Margin = buttonSpacing;
importButton.HAnchor = HAnchor.Left;
importButton.Click += (s, e) =>
{
UiThread.RunOnIdle(() => WizardWindow.Show<ImportSettingsPage>());
};
otherItemsSection.AddChild(importButton);
if (OemSettings.Instance.ShowShopButton)
{
var shopButton = theme.ButtonFactory.Generate("Buy Materials".Localize(), AggContext.StaticData.LoadIcon("icon_shopping_cart_32x32.png", 24, 24, IconColor.Theme));