Move MatterControl source code into a subdirectory
This commit is contained in:
parent
2c6e34243a
commit
70af2d9ae8
2007 changed files with 13 additions and 8 deletions
76
original/Plugins/MatterControl.PartSheet/PartSheetPlugin.cs
Normal file
76
original/Plugins/MatterControl.PartSheet/PartSheetPlugin.cs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
Copyright (c) 2019, Kevin Pope, John Lewin
|
||||
All rights reserved.
|
||||
*/
|
||||
|
||||
using System.Linq;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.Extensibility;
|
||||
using MatterHackers.MatterControl.Library;
|
||||
using MatterHackers.MatterControl.PrintQueue;
|
||||
|
||||
namespace MatterHackers.MatterControl.Plugins
|
||||
{
|
||||
public class PartSheetPlugin : IApplicationPlugin
|
||||
{
|
||||
public void Initialize()
|
||||
{
|
||||
// PDF export is limited to Windows
|
||||
if (AggContext.OperatingSystem != OSType.Windows)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Needed for PDFSharp on .NET core.
|
||||
// https://stackoverflow.com/questions/50858209/system-notsupportedexception-no-data-is-available-for-encoding-1252
|
||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||
|
||||
ApplicationController.Instance.Library.MenuExtensions.Add(
|
||||
new LibraryAction(ActionScope.ListItem)
|
||||
{
|
||||
Title = "Create Part Sheet".Localize(),
|
||||
Action = (selectedLibraryItems, listView) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
var printItems = selectedLibraryItems.OfType<ILibraryAssetStream>();
|
||||
if (printItems.Any())
|
||||
{
|
||||
AggContext.FileDialogs.SaveFileDialog(
|
||||
new SaveFileDialogParams("Save Parts Sheet|*.pdf")
|
||||
{
|
||||
ActionButtonLabel = "Save Parts Sheet".Localize(),
|
||||
Title = ApplicationController.Instance.ProductName + " - " + "Save".Localize()
|
||||
},
|
||||
(saveParams) =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(saveParams.FileName))
|
||||
{
|
||||
var currentPartsInQueue = new PartsSheet(printItems, saveParams.FileName);
|
||||
currentPartsInQueue.SaveSheets().ConfigureAwait(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
IsEnabled = (selectedListItems, listView) =>
|
||||
{
|
||||
// Multiselect - disallow containers
|
||||
return listView.SelectedItems.Any()
|
||||
&& listView.SelectedItems.All(i => !(i.Model is ILibraryContainerLink));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public PluginInfo MetaData { get; } = new PluginInfo()
|
||||
{
|
||||
Name = "Part Sheets",
|
||||
UUID = "580D8EF3-885C-4DD3-903A-4DB136AFD84B",
|
||||
About = "A part sheet plugin",
|
||||
Developer = "MatterHackers, Inc.",
|
||||
Url = "https://www.matterhackers.com"
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue