Added a past into command

This commit is contained in:
Lars Brubaker 2022-02-24 12:04:38 -08:00
parent 8f9dd665f5
commit e9a69e9644
4 changed files with 59 additions and 7 deletions

View file

@ -174,6 +174,7 @@ namespace MatterHackers.MatterControl
{
new ActionSeparator(),
workspaceActions["Edit"],
workspaceActions["PasteInto"],
new ActionSeparator(),
new NamedAction()
{
@ -196,7 +197,7 @@ namespace MatterHackers.MatterControl
Icon = StaticData.Instance.LoadIcon("cube_export.png", 16, 16).SetToColor(MenuTheme.TextColor),
Action = () =>
{
ApplicationController.Instance.ExportLibraryItems(
Instance.ExportLibraryItems(
new[] { new InMemoryLibraryItem(selectedItem) },
centerOnBed: false,
printer: printer);
@ -586,9 +587,9 @@ namespace MatterHackers.MatterControl
IsEnabled = () =>
{
if (sceneContext.Printer != null)
{
{
return sceneContext.Printer.PrintButtonEnabled();
}
}
return sceneContext.EditableScene
|| (sceneContext.EditContext.SourceItem is ILibraryAsset libraryAsset
@ -626,6 +627,30 @@ namespace MatterHackers.MatterControl
IsEnabled = () => true,
},
new NamedAction()
{
ID = "PasteInto",
Title = "Paste Into".Localize(),
Action = () => sceneContext.PasteIntoSelection(),
IsEnabled = () =>
{
var selectedItem = sceneContext.Scene.SelectedItem;
var clipboardItem = ApplicationController.ClipboardItem;
// there is an object in the clipboard
if (Clipboard.Instance.ContainsText
&& Clipboard.Instance.GetText() == "!--IObjectSelection--!"
// there is a selected item to paste into
&& selectedItem != null
// the selected item is not a primitve
&& !(selectedItem is PrimitiveObject3D)
&& clipboardItem != null)
{
return true;
}
return false;
}
},
new NamedAction()
{
ID = "Delete",
Icon = StaticData.Instance.LoadIcon("remove.png", 16, 16).SetToColor(theme.TextColor).SetPreMultiply(),

View file

@ -1021,7 +1021,7 @@ namespace MatterHackers.MatterControl
return new SceneOperation("Duplicate")
{
TitleGetter = () => "Duplicate".Localize(),
Action = (sceneContext) => sceneContext.DuplicateItem(5),
Action = (sceneContext) => sceneContext.DuplicateItemAddToScene(5),
HelpTextGetter = () => "At least 1 part must be selected".Localize().Stars(),
IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null,
Icon = (theme) => StaticData.Instance.LoadIcon("duplicate.png", 16, 16).SetPreMultiply(),

View file

@ -144,7 +144,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
}
public static async void DuplicateItem(this ISceneContext sceneContext, double xOffset, IObject3D sourceItem = null)
public static async void DuplicateItemAddToScene(this ISceneContext sceneContext, double xOffset, IObject3D sourceItem = null)
{
var scene = sceneContext.Scene;
if (sourceItem == null)
@ -187,7 +187,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
var clonedItem = sourceItem.Clone();
clonedItem.Translate(xOffset);
// an empty string is used do denote special name processing for some container types
// an empty string is used to denote special name processing for some container types
if (!string.IsNullOrWhiteSpace(sourceItem.Name))
{
// make the name unique
@ -437,13 +437,31 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
if (Clipboard.Instance.GetText() == "!--IObjectSelection--!")
{
sceneContext.DuplicateItem(0, ApplicationController.ClipboardItem);
sceneContext.DuplicateItemAddToScene(0, ApplicationController.ClipboardItem);
// each time we put in the object offset it a bit more
pasteObjectXOffset += 5;
}
}
}
public static void PasteIntoSelection(this ISceneContext sceneContext)
{
var scene = sceneContext.Scene;
var selectedItem = scene.SelectedItem;
var clipboardItem = ApplicationController.ClipboardItem;
if (Clipboard.Instance.ContainsText
&& Clipboard.Instance.GetText() == "!--IObjectSelection--!"
// there is a selected item to paste into
&& selectedItem != null
// the selected item is not a primitve
&& !(selectedItem is PrimitiveObject3D)
&& clipboardItem != null)
{
selectedItem.Children.Add(clipboardItem.Clone());
}
}
public static async void UngroupSelection(this InteractiveScene scene)
{
var selectedItem = scene.SelectedItem;

View file

@ -226,6 +226,9 @@ Translated:Add Note
English:Add Note...
Translated:Add Note...
English:Add System File to Bed
Translated:Add System File to Bed
English:Add to Bed
Translated:Add to Bed
@ -1279,6 +1282,9 @@ Translated:Distance From Object
English:Distance or Loops
Translated:Distance or Loops
English:Documents
Translated:Documents
English:Done
Translated:Done
@ -3286,6 +3292,9 @@ Translated:Password update complete
English:Paste
Translated:Paste
English:Paste Into
Translated:Paste Into
English:Path
Translated:Path