Merge branch 'master' of https://github.com/MatterHackers/MatterControl
This commit is contained in:
commit
49bc3d8724
5 changed files with 101 additions and 0 deletions
|
|
@ -37,6 +37,7 @@ using MatterHackers.MatterControl.PrintQueue;
|
|||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.VectorMath;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -166,6 +167,9 @@ namespace MatterHackers.MatterControl
|
|||
public static Action LogoutAction;
|
||||
public static Func<string> GetSessionInfo;
|
||||
|
||||
public static Func<string, Task<Dictionary<string, string>>> GetProfileHistory;
|
||||
public static Func<PrinterInfo,string, Task> GetPrinterProfile;
|
||||
|
||||
public SlicePresetsWindow EditMaterialPresetsWindow { get; set; }
|
||||
|
||||
public SlicePresetsWindow EditQualityPresetsWindow { get; set; }
|
||||
|
|
|
|||
|
|
@ -252,6 +252,7 @@
|
|||
<Compile Include="SetupWizard\ImportSettingsPage.cs" />
|
||||
<Compile Include="SetupWizard\ExportSettingsPage.cs" />
|
||||
<Compile Include="SetupWizard\LicenseAgreementPage.cs" />
|
||||
<Compile Include="SetupWizard\PrinterProfileHistoryPage.cs" />
|
||||
<Compile Include="SetupWizard\WizardPage.cs" />
|
||||
<Compile Include="SetupWizard\AndroidSetupOptionsPage.cs" />
|
||||
<Compile Include="SetupWizard\SetupWizardTroubleshooting.cs" />
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ using MatterHackers.Agg.UI;
|
|||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.DataStorage;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.SetupWizard;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
|||
93
SetupWizard/PrinterProfileHistoryPage.cs
Normal file
93
SetupWizard/PrinterProfileHistoryPage.cs
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MatterHackers.MatterControl.SetupWizard
|
||||
{
|
||||
class PrinterProfileHistoryPage : WizardPage
|
||||
{
|
||||
List<RadioButton> radioButtonList = new List<RadioButton>();
|
||||
Dictionary<string, string> printerProfileData = new Dictionary<string, string>();
|
||||
ScrollableWidget scrollWindow;
|
||||
|
||||
public PrinterProfileHistoryPage()
|
||||
{
|
||||
scrollWindow = new ScrollableWidget()
|
||||
{
|
||||
AutoScroll = true,
|
||||
HAnchor = HAnchor.ParentLeftRight,
|
||||
VAnchor = VAnchor.ParentBottomTop,
|
||||
};
|
||||
scrollWindow.ScrollArea.HAnchor = HAnchor.ParentLeftRight;
|
||||
contentRow.FlowDirection = FlowDirection.TopToBottom;
|
||||
contentRow.AddChild(scrollWindow);
|
||||
|
||||
var revertButton = textImageButtonFactory.Generate("Revert");
|
||||
footerRow.AddChild(revertButton);
|
||||
footerRow.AddChild(new HorizontalSpacer());
|
||||
footerRow.AddChild(cancelButton);
|
||||
revertButton.Click += async (s, e) =>
|
||||
{
|
||||
var checkedButton = radioButtonList.Where(r => r.Checked).FirstOrDefault();
|
||||
if (checkedButton != null)
|
||||
{
|
||||
string profileToken = printerProfileData[checkedButton.Text];
|
||||
|
||||
var activeProfile = ProfileManager.Instance.ActiveProfile;
|
||||
|
||||
// Download the specified json profile
|
||||
await ApplicationController.GetPrinterProfile(activeProfile, profileToken);
|
||||
|
||||
// TODO: handle errors...
|
||||
|
||||
// Update the active instance to the newly downloaded item
|
||||
var jsonProfile = ProfileManager.LoadProfile(activeProfile.ID, false);
|
||||
ActiveSliceSettings.RefreshActiveInstance(jsonProfile);
|
||||
UiThread.RunOnIdle(WizardWindow.Close);
|
||||
}
|
||||
};
|
||||
|
||||
LoadHistoryItems();
|
||||
}
|
||||
|
||||
private async void LoadHistoryItems()
|
||||
{
|
||||
TextWidget loadingText = new TextWidget("Retrieving History from Web...");
|
||||
loadingText.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
scrollWindow.AddChild(loadingText);
|
||||
|
||||
|
||||
var results = await ApplicationController.GetProfileHistory(ProfileManager.Instance.ActiveProfile.DeviceToken);
|
||||
printerProfileData = results;
|
||||
if(printerProfileData != null)
|
||||
{
|
||||
FlowLayoutWidget radioButtonLayout = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
loadingText.Visible= false;
|
||||
|
||||
foreach(var printerProfile in results)
|
||||
{
|
||||
var profileVersionButton = new RadioButton(printerProfile.Key.ToString(), textColor: ActiveTheme.Instance.PrimaryTextColor);
|
||||
profileVersionButton.Checked = false;
|
||||
radioButtonLayout.AddChild(profileVersionButton);
|
||||
radioButtonList.Add(profileVersionButton);
|
||||
// show them
|
||||
}
|
||||
scrollWindow.AddChild(radioButtonLayout);
|
||||
}
|
||||
else
|
||||
{
|
||||
loadingText.Text = "Failed To Download History!";
|
||||
loadingText.TextColor = RGBA_Bytes.Red; //CHANGE TO ERROR COLOR
|
||||
}
|
||||
|
||||
//remove loading profile text/icon
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.SetupWizard;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
|
@ -84,6 +85,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
{
|
||||
{ "Import".Localize(), ImportSettingsMenu_Click },
|
||||
{ "Export".Localize(), () => { WizardWindow.Show<ExportSettingsPage>("ExportSettingsPage", "Export Settings"); return true; } },
|
||||
{ "Printer History".Localize(), () => { WizardWindow.Show<PrinterProfileHistoryPage>("somecontext", "Hello world"); return true; } },
|
||||
{ "Reset to defaults".Localize(),() => { UiThread.RunOnIdle(ResetToDefaults); return true; } },
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue