2015-04-08 15:20:10 -07:00
|
|
|
|
using MatterHackers.Agg;
|
2014-12-09 15:16:08 -08:00
|
|
|
|
using MatterHackers.Agg.UI;
|
|
|
|
|
|
using MatterHackers.Localizations;
|
|
|
|
|
|
using MatterHackers.MatterControl.DataStorage;
|
|
|
|
|
|
using MatterHackers.MatterControl.PrinterCommunication;
|
|
|
|
|
|
using MatterHackers.MatterControl.PrinterControls.PrinterConnections;
|
|
|
|
|
|
using MatterHackers.MatterControl.PrintQueue;
|
2015-07-30 10:42:06 -07:00
|
|
|
|
using System.Collections.Generic;
|
2014-12-09 15:16:08 -08:00
|
|
|
|
using MatterHackers.VectorMath;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.IO;
|
2014-12-09 15:16:08 -08:00
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl
|
|
|
|
|
|
{
|
2015-05-20 17:34:55 -07:00
|
|
|
|
public class MenuOptionFile : MenuBase
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
|
|
|
|
|
public MenuOptionFile()
|
2015-05-20 17:34:55 -07:00
|
|
|
|
: base("File".Localize())
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
|
|
|
|
|
}
|
2014-12-09 15:16:08 -08:00
|
|
|
|
|
2015-05-20 17:34:55 -07:00
|
|
|
|
override protected TupleList<string, Func<bool>> GetMenuItems()
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2015-05-20 17:34:55 -07:00
|
|
|
|
return new TupleList<string, Func<bool>>
|
2014-12-09 15:16:08 -08:00
|
|
|
|
{
|
2015-08-03 15:48:36 -07:00
|
|
|
|
{"Add Printer".Localize(), addPrinter_Click},
|
2015-08-03 16:46:57 -07:00
|
|
|
|
{"Add File To Queue".Localize(), importFile_Click},
|
|
|
|
|
|
{"Add Folder To Library".Localize(), addFolderToLibrar_Click},
|
2015-08-03 15:48:36 -07:00
|
|
|
|
{"------------------------", nothing_Click},
|
|
|
|
|
|
{"Exit".Localize(), exit_Click},
|
2014-12-09 15:16:08 -08:00
|
|
|
|
};
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2015-08-03 15:48:36 -07:00
|
|
|
|
private bool nothing_Click()
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-08-03 16:46:57 -07:00
|
|
|
|
private bool addFolderToLibrar_Click()
|
|
|
|
|
|
{
|
|
|
|
|
|
//AddCollectionToLibrary(string collectionName);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
private bool addPrinter_Click()
|
|
|
|
|
|
{
|
2015-06-11 13:53:53 -07:00
|
|
|
|
UiThread.RunOnIdle(ConnectionWindow.Show);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool importFile_Click()
|
|
|
|
|
|
{
|
2015-06-11 12:06:40 -07:00
|
|
|
|
UiThread.RunOnIdle(() =>
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
|
|
|
|
|
FileDialog.OpenFileDialog(
|
|
|
|
|
|
new OpenFileDialogParams(ApplicationSettings.OpenPrintableFileParams)
|
|
|
|
|
|
{
|
|
|
|
|
|
MultiSelect = true,
|
|
|
|
|
|
ActionButtonLabel = "Add to Queue",
|
|
|
|
|
|
Title = "MatterControl: Select A File"
|
|
|
|
|
|
},
|
|
|
|
|
|
(openParams) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (openParams.FileNames != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (string loadedFileName in openParams.FileNames)
|
|
|
|
|
|
{
|
2015-07-30 10:42:06 -07:00
|
|
|
|
if (Path.GetExtension(loadedFileName).ToUpper() == ".ZIP")
|
|
|
|
|
|
{
|
|
|
|
|
|
ProjectFileHandler project = new ProjectFileHandler(null);
|
|
|
|
|
|
List<PrintItem> partFiles = project.ImportFromProjectArchive(loadedFileName);
|
|
|
|
|
|
if (partFiles != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (PrintItem part in partFiles)
|
|
|
|
|
|
{
|
|
|
|
|
|
QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(part.Name, part.FileLocation)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(Path.GetFileNameWithoutExtension(loadedFileName), Path.GetFullPath(loadedFileName))));
|
|
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2014-12-09 15:16:08 -08:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
private string cannotExitWhileActiveMessage = "Oops! You cannot exit while a print is active.".Localize();
|
|
|
|
|
|
private string cannotExitWhileActiveTitle = "Unable to Exit";
|
2014-12-09 15:16:08 -08:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
private bool exit_Click()
|
|
|
|
|
|
{
|
2015-06-11 12:06:40 -07:00
|
|
|
|
UiThread.RunOnIdle(() =>
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
|
|
|
|
|
GuiWidget parent = this;
|
|
|
|
|
|
while (parent as MatterControlApplication == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
parent = parent.Parent;
|
|
|
|
|
|
}
|
2014-12-09 15:16:08 -08:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
if (PrinterConnectionAndCommunication.Instance.PrinterIsPrinting)
|
2014-12-09 15:16:08 -08:00
|
|
|
|
{
|
2015-04-08 15:20:10 -07:00
|
|
|
|
StyledMessageBox.ShowMessageBox(null, cannotExitWhileActiveMessage, cannotExitWhileActiveTitle);
|
2014-12-09 15:16:08 -08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2015-04-08 15:20:10 -07:00
|
|
|
|
MatterControlApplication app = parent as MatterControlApplication;
|
|
|
|
|
|
app.RestartOnClose = false;
|
|
|
|
|
|
app.Close();
|
2014-12-09 15:16:08 -08:00
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
});
|
2014-12-09 15:16:08 -08:00
|
|
|
|
return true;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|