Add Export button to footer, RunOnIdle durations to ensure refresh
This commit is contained in:
parent
76e50e9f0b
commit
c09ed8b65c
3 changed files with 66 additions and 51 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2014, Lars Brubaker
|
||||
Copyright (c) 2018, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -165,6 +165,13 @@ namespace MatterHackers.MatterControl.EeProm
|
|||
});
|
||||
};
|
||||
this.AddPageAction(buttonSave);
|
||||
|
||||
var exportButton = theme.CreateDialogButton("Export".Localize());
|
||||
exportButton.Click += (s, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(this.ExportSettings, .1);
|
||||
};
|
||||
this.AddPageAction(exportButton);
|
||||
}
|
||||
|
||||
printerConnection.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents);
|
||||
|
|
@ -188,15 +195,15 @@ namespace MatterHackers.MatterControl.EeProm
|
|||
ActionButtonLabel = "Import EEPROM Settings".Localize(),
|
||||
Title = "Import EEPROM".Localize(),
|
||||
},
|
||||
(openParams) =>
|
||||
(openParams) =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(openParams.FileName))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(openParams.FileName))
|
||||
{
|
||||
currentEePromSettings.Import(openParams.FileName);
|
||||
SetUiToPrinterSettings(null, null);
|
||||
}
|
||||
});
|
||||
});
|
||||
currentEePromSettings.Import(openParams.FileName);
|
||||
SetUiToPrinterSettings(null, null);
|
||||
}
|
||||
});
|
||||
}, .1);
|
||||
};
|
||||
|
||||
// put in the export button
|
||||
|
|
@ -204,25 +211,7 @@ namespace MatterHackers.MatterControl.EeProm
|
|||
menuItem.Name = "Export Menu Item";
|
||||
menuItem.Click += (s, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
string defaultFileNameNoPath = "eeprom_settings.ini";
|
||||
AggContext.FileDialogs.SaveFileDialog(
|
||||
new SaveFileDialogParams("EEPROM Settings|*.ini")
|
||||
{
|
||||
ActionButtonLabel = "Export EEPROM Settings".Localize(),
|
||||
Title = "Export EEPROM".Localize(),
|
||||
FileName = defaultFileNameNoPath
|
||||
},
|
||||
(saveParams) =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(saveParams.FileName)
|
||||
&& saveParams.FileName != defaultFileNameNoPath)
|
||||
{
|
||||
currentEePromSettings.Export(saveParams.FileName);
|
||||
}
|
||||
});
|
||||
});
|
||||
UiThread.RunOnIdle(this.ExportSettings, .1);
|
||||
};
|
||||
|
||||
popupMenu.CreateHorizontalLine();
|
||||
|
|
@ -242,6 +231,26 @@ namespace MatterHackers.MatterControl.EeProm
|
|||
}
|
||||
}
|
||||
|
||||
private void ExportSettings()
|
||||
{
|
||||
string defaultFileNameNoPath = "eeprom_settings.ini";
|
||||
AggContext.FileDialogs.SaveFileDialog(
|
||||
new SaveFileDialogParams("EEPROM Settings|*.ini")
|
||||
{
|
||||
ActionButtonLabel = "Export EEPROM Settings".Localize(),
|
||||
Title = "Export EEPROM".Localize(),
|
||||
FileName = defaultFileNameNoPath
|
||||
},
|
||||
(saveParams) =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(saveParams.FileName)
|
||||
&& saveParams.FileName != defaultFileNameNoPath)
|
||||
{
|
||||
currentEePromSettings.Export(saveParams.FileName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private GuiWidget CreateMHNumEdit(ref MHNumberEdit numberEditToCreate)
|
||||
{
|
||||
numberEditToCreate = new MHNumberEdit(0, pixelWidth: 80, allowNegatives: true, allowDecimals: true)
|
||||
|
|
|
|||
|
|
@ -143,37 +143,20 @@ namespace MatterHackers.MatterControl.EeProm
|
|||
RebuildUi();
|
||||
}
|
||||
});
|
||||
});
|
||||
}, .1);
|
||||
};
|
||||
|
||||
menuItem = popupMenu.CreateMenuItem("Export".Localize());
|
||||
menuItem.Name = "Export Menu Item";
|
||||
menuItem.Click += (s, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
AggContext.FileDialogs.SaveFileDialog(
|
||||
new SaveFileDialogParams("EEPROM Settings|*.ini")
|
||||
{
|
||||
ActionButtonLabel = "Export EEPROM Settings".Localize(),
|
||||
Title = "Export EEPROM".Localize(),
|
||||
FileName = "eeprom_settings.ini"
|
||||
},
|
||||
(saveParams) =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(saveParams.FileName))
|
||||
{
|
||||
currentEePromSettings.Export(saveParams.FileName);
|
||||
}
|
||||
});
|
||||
});
|
||||
UiThread.RunOnIdle(this.ExportSettings, .1);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
// put in the save button
|
||||
var buttonSave = theme.CreateDialogButton("Save To EEPROM".Localize());
|
||||
buttonSave.Margin = new BorderDouble(0, 3);
|
||||
buttonSave.Click += (s, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
|
|
@ -185,6 +168,13 @@ namespace MatterHackers.MatterControl.EeProm
|
|||
};
|
||||
this.AddPageAction(buttonSave);
|
||||
|
||||
var exportButton = theme.CreateDialogButton("Export".Localize());
|
||||
exportButton.Click += (s, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(this.ExportSettings, .1);
|
||||
};
|
||||
this.AddPageAction(exportButton);
|
||||
|
||||
currentEePromSettings.Clear();
|
||||
printerConnection.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents);
|
||||
currentEePromSettings.eventAdded += NewSettingReadFromPrinter;
|
||||
|
|
@ -195,6 +185,24 @@ namespace MatterHackers.MatterControl.EeProm
|
|||
#endif
|
||||
}
|
||||
|
||||
private void ExportSettings()
|
||||
{
|
||||
AggContext.FileDialogs.SaveFileDialog(
|
||||
new SaveFileDialogParams("EEPROM Settings|*.ini")
|
||||
{
|
||||
ActionButtonLabel = "Export EEPROM Settings".Localize(),
|
||||
Title = "Export EEPROM".Localize(),
|
||||
FileName = "eeprom_settings.ini"
|
||||
},
|
||||
(saveParams) =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(saveParams.FileName))
|
||||
{
|
||||
currentEePromSettings.Export(saveParams.FileName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#if SIMULATE_CONNECTION
|
||||
int count;
|
||||
void AddSimulatedItems(object state)
|
||||
|
|
@ -296,7 +304,7 @@ namespace MatterHackers.MatterControl.EeProm
|
|||
private GuiWidget AddDescription(string description)
|
||||
{
|
||||
var holder = new GuiWidget(340, 40);
|
||||
holder.AddChild(new TextWidget(description, pointSize: theme.FontSize10, textColor: ActiveTheme.Instance.PrimaryTextColor)
|
||||
holder.AddChild(new TextWidget(description, pointSize: theme.DefaultFontSize, textColor: ActiveTheme.Instance.PrimaryTextColor)
|
||||
{
|
||||
VAnchor = VAnchor.Center
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2017, Lars Brubaker, John Lewin
|
||||
Copyright (c) 2018, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -31,7 +31,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
|
|
@ -42,7 +41,6 @@ using MatterHackers.MatterControl.EeProm;
|
|||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.PrintHistory;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue