Restore the previous bedplate on load

This commit is contained in:
John Lewin 2017-07-28 17:35:04 -07:00
parent 7192bd3e54
commit 0cd2ffd093
6 changed files with 43 additions and 8 deletions

View file

@ -278,14 +278,15 @@ namespace MatterHackers.MatterControl
{
string now = DateTime.Now.ToString("yyyyMMdd-HHmmss");
string platingDirectory = Path.Combine(ApplicationDataStorage.Instance.ApplicationTempDataPath, "Plating");
Directory.CreateDirectory(platingDirectory);
string mcxPath = Path.Combine(platingDirectory, now + ".mcx");
string mcxPath = Path.Combine(ApplicationDataStorage.Instance.PlatingDirectory, now + ".mcx");
ApplicationController.Instance.ActivePrintItem = new PrintItemWrapper(new PrintItem(now, mcxPath));
File.WriteAllText(mcxPath, new Object3D().ToJson());
ApplicationController.Instance.ActiveView3DWidget?.Scene.Load(mcxPath);
ApplicationController.Instance.ActiveView3DWidget?.PartHasBeenChanged();
}
public ThemeConfig Theme { get; set; } = new ThemeConfig();

View file

@ -27,10 +27,14 @@ of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
using System.IO;
using System.Linq;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.MatterControl.DataStorage;
using MatterHackers.MatterControl.PartPreviewWindow;
using MatterHackers.MatterControl.PrintLibrary;
using MatterHackers.MatterControl.PrintQueue;
namespace MatterHackers.MatterControl
{
@ -50,7 +54,12 @@ namespace MatterHackers.MatterControl
// HACK: Long term we need a better solution which does not rely on ActivePrintItem/PrintItemWrapper
if (ApplicationController.Instance.ActivePrintItem == null)
{
ApplicationController.Instance.ClearPlate();
// Find the last used bed plate mcx
var directoryInfo = new DirectoryInfo(ApplicationDataStorage.Instance.PlatingDirectory);
var firstFile = directoryInfo.GetFileSystemInfos("*.mcx").OrderByDescending(fl => fl.CreationTime).FirstOrDefault();
// Set as the current item - should be restored as the Active scene in the MeshViewer
ApplicationController.Instance.ActivePrintItem = new PrintItemWrapper(new PrintItem(firstFile.Name, firstFile.FullName));
}
var library3DViewSplitter = new Splitter()

View file

@ -159,6 +159,17 @@ namespace MatterHackers.MatterControl.DataStorage
}
}
public string PlatingDirectory
{
get
{
string platingDirectory = Path.Combine(ApplicationTempDataPath, "Plating");
Directory.CreateDirectory(platingDirectory);
return platingDirectory;
}
}
public string DownloadsDirectory { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads");
public string CustomLibraryFoldersPath { get; } = Path.Combine(applicationUserDataPath, "LibraryFolders.conf");

View file

@ -31,7 +31,6 @@ using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.ActionBar;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.MatterControl.PrinterCommunication;
namespace MatterHackers.MatterControl.PartPreviewWindow
@ -93,9 +92,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
UiThread.RunOnIdle(() =>
{
//WizardPage.WizardWindow.ChangeToSetupPrinterForm(true);
WizardWindow.ShowPrinterSetup(true);
});
}
};

View file

@ -39,6 +39,7 @@ using MatterHackers.Agg.OpenGlGui;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D;
using MatterHackers.MatterControl;
using MatterHackers.MatterControl.PartPreviewWindow;
using MatterHackers.PolygonMesh;
using MatterHackers.RenderOpenGl;
@ -84,6 +85,14 @@ namespace MatterHackers.MeshVisualizer
{
interactionLayer.Scene = Scene;
var activePrintItem = ApplicationController.Instance.ActivePrintItem;
if (activePrintItem != null
&& File.Exists(activePrintItem.FileLocation))
{
Scene.Load(activePrintItem.FileLocation);
}
this.interactionLayer = interactionLayer;
this.World = interactionLayer.World;

View file

@ -332,6 +332,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
});
};
Button clearPlateButton = smallMarginButtonFactory.Generate("Clear Plate".Localize());
clearPlateButton.Margin = new BorderDouble(right: 10);
clearPlateButton.Click += (sender, e) =>
{
UiThread.RunOnIdle(ApplicationController.Instance.ClearPlate);
};
doEdittingButtonsContainer.AddChild(clearPlateButton);
// put in the save button
AddSaveAndSaveAs(doEdittingButtonsContainer);