Pass SceneContext instead of Scene to SceneSelectionOperations
- Required to remove ActivePrinter from InsertNewItem - Required to break ActivePrinter dependencies - Issue MatterHackers/MCCentral#4549 Remove ActivePrinter from ApplicationController
This commit is contained in:
parent
fdad2a1774
commit
5489c3b09a
3 changed files with 30 additions and 24 deletions
|
|
@ -547,8 +547,9 @@ namespace MatterHackers.MatterControl
|
|||
OperationType = typeof(GroupObject3D),
|
||||
|
||||
TitleResolver = () => "Group".Localize(),
|
||||
Action = (scene) =>
|
||||
Action = (sceneContext) =>
|
||||
{
|
||||
var scene = sceneContext.Scene;
|
||||
var selectedItem = scene.SelectedItem;
|
||||
scene.SelectedItem = null;
|
||||
|
||||
|
|
@ -584,7 +585,7 @@ namespace MatterHackers.MatterControl
|
|||
new SceneSelectionOperation()
|
||||
{
|
||||
TitleResolver = () => "Ungroup".Localize(),
|
||||
Action = (scene) => scene.UngroupSelection(),
|
||||
Action = (sceneContext) => sceneContext.Scene.UngroupSelection(),
|
||||
IsEnabled = (scene) =>
|
||||
{
|
||||
var selectedItem = scene.SelectedItem;
|
||||
|
|
@ -602,14 +603,14 @@ namespace MatterHackers.MatterControl
|
|||
new SceneSelectionOperation()
|
||||
{
|
||||
TitleResolver = () => "Duplicate".Localize(),
|
||||
Action = (scene) => scene.DuplicateItem(5),
|
||||
Action = (sceneContext) => sceneContext.DuplicateItem(5),
|
||||
IsEnabled = (scene) => scene.SelectedItem != null,
|
||||
Icon = AggContext.StaticData.LoadIcon("duplicate.png").SetPreMultiply(),
|
||||
},
|
||||
new SceneSelectionOperation()
|
||||
{
|
||||
TitleResolver = () => "Remove".Localize(),
|
||||
Action = (scene) => scene.DeleteSelection(),
|
||||
Action = (sceneContext) => sceneContext.DeleteSelection(),
|
||||
IsEnabled = (scene) => scene.SelectedItem != null,
|
||||
Icon = AggContext.StaticData.LoadIcon("remove.png").SetPreMultiply(),
|
||||
},
|
||||
|
|
@ -618,8 +619,9 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
OperationType = typeof(AlignObject3D),
|
||||
TitleResolver = () => "Align".Localize(),
|
||||
Action = (scene) =>
|
||||
Action = (sceneContext) =>
|
||||
{
|
||||
var scene = sceneContext.Scene;
|
||||
var selectedItem = scene.SelectedItem;
|
||||
var align = new AlignObject3D();
|
||||
align.AddSelectionAsChildren(scene, selectedItem);
|
||||
|
|
@ -631,8 +633,9 @@ namespace MatterHackers.MatterControl
|
|||
new SceneSelectionOperation()
|
||||
{
|
||||
TitleResolver = () => "Lay Flat".Localize(),
|
||||
Action = (scene) =>
|
||||
Action = (sceneContext) =>
|
||||
{
|
||||
var scene = sceneContext.Scene;
|
||||
var selectedItem = scene.SelectedItem;
|
||||
if (selectedItem != null)
|
||||
{
|
||||
|
|
@ -645,8 +648,9 @@ namespace MatterHackers.MatterControl
|
|||
new SceneSelectionOperation()
|
||||
{
|
||||
TitleResolver = () => "Make Support".Localize(),
|
||||
Action = (scene) =>
|
||||
Action = (sceneContext) =>
|
||||
{
|
||||
var scene = sceneContext.Scene;
|
||||
if (scene.SelectedItem != null
|
||||
&& !scene.SelectedItem.VisibleMeshes().All(i => i.OutputType == PrintOutputTypes.Support))
|
||||
{
|
||||
|
|
@ -661,7 +665,7 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
OperationType = typeof(CombineObject3D),
|
||||
TitleResolver = () => "Combine".Localize(),
|
||||
Action = (scene) => new CombineObject3D().WrapSelectedItemAndSelect(scene),
|
||||
Action = (sceneContext) => new CombineObject3D().WrapSelectedItemAndSelect(sceneContext.Scene),
|
||||
Icon = AggContext.StaticData.LoadIcon("combine.png").SetPreMultiply(),
|
||||
IsEnabled = (scene) => scene.SelectedItem is SelectionGroupObject3D,
|
||||
},
|
||||
|
|
@ -669,7 +673,7 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
OperationType = typeof(SubtractObject3D),
|
||||
TitleResolver = () => "Subtract".Localize(),
|
||||
Action = (scene) => new SubtractObject3D().WrapSelectedItemAndSelect(scene),
|
||||
Action = (sceneContext) => new SubtractObject3D().WrapSelectedItemAndSelect(sceneContext.Scene),
|
||||
Icon = AggContext.StaticData.LoadIcon("subtract.png").SetPreMultiply(),
|
||||
IsEnabled = (scene) => scene.SelectedItem is SelectionGroupObject3D,
|
||||
},
|
||||
|
|
@ -677,7 +681,7 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
OperationType = typeof(IntersectionObject3D),
|
||||
TitleResolver = () => "Intersect".Localize(),
|
||||
Action = (scene) => new IntersectionObject3D().WrapSelectedItemAndSelect(scene),
|
||||
Action = (sceneContext) => new IntersectionObject3D().WrapSelectedItemAndSelect(sceneContext.Scene),
|
||||
Icon = AggContext.StaticData.LoadIcon("intersect.png"),
|
||||
IsEnabled = (scene) => scene.SelectedItem is SelectionGroupObject3D,
|
||||
},
|
||||
|
|
@ -685,7 +689,7 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
OperationType = typeof(SubtractAndReplaceObject3D),
|
||||
TitleResolver = () => "Subtract & Replace".Localize(),
|
||||
Action = (scene) => new SubtractAndReplaceObject3D().WrapSelectedItemAndSelect(scene),
|
||||
Action = (sceneContext) => new SubtractAndReplaceObject3D().WrapSelectedItemAndSelect(sceneContext.Scene),
|
||||
Icon = AggContext.StaticData.LoadIcon("subtract_and_replace.png").SetPreMultiply(),
|
||||
IsEnabled = (scene) => scene.SelectedItem is SelectionGroupObject3D,
|
||||
},
|
||||
|
|
@ -694,10 +698,10 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
OperationType = typeof(ArrayLinearObject3D),
|
||||
TitleResolver = () => "Linear Array".Localize(),
|
||||
Action = (scene) =>
|
||||
Action = (sceneContext) =>
|
||||
{
|
||||
var array = new ArrayLinearObject3D();
|
||||
array.AddSelectionAsChildren(scene, scene.SelectedItem);
|
||||
array.AddSelectionAsChildren(sceneContext.Scene, sceneContext.Scene.SelectedItem);
|
||||
array.Invalidate(new InvalidateArgs(array, InvalidateType.Properties, null));
|
||||
},
|
||||
Icon = AggContext.StaticData.LoadIcon("array_linear.png").SetPreMultiply(),
|
||||
|
|
@ -707,10 +711,10 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
OperationType = typeof(ArrayRadialObject3D),
|
||||
TitleResolver = () => "Radial Array".Localize(),
|
||||
Action = (scene) =>
|
||||
Action = (sceneContext) =>
|
||||
{
|
||||
var array = new ArrayRadialObject3D();
|
||||
array.AddSelectionAsChildren(scene, scene.SelectedItem);
|
||||
array.AddSelectionAsChildren(sceneContext.Scene, sceneContext.Scene.SelectedItem);
|
||||
array.Invalidate(new InvalidateArgs(array, InvalidateType.Properties, null));
|
||||
},
|
||||
Icon = AggContext.StaticData.LoadIcon("array_radial.png").SetPreMultiply(),
|
||||
|
|
@ -720,10 +724,10 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
OperationType = typeof(ArrayAdvancedObject3D),
|
||||
TitleResolver = () => "Advanced Array".Localize(),
|
||||
Action = (scene) =>
|
||||
Action = (sceneContext) =>
|
||||
{
|
||||
var array = new ArrayAdvancedObject3D();
|
||||
array.AddSelectionAsChildren(scene, scene.SelectedItem);
|
||||
array.AddSelectionAsChildren(sceneContext.Scene, sceneContext.Scene.SelectedItem);
|
||||
array.Invalidate(new InvalidateArgs(array, InvalidateType.Properties, null));
|
||||
},
|
||||
Icon = AggContext.StaticData.LoadIcon("array_advanced.png").SetPreMultiply(),
|
||||
|
|
@ -734,10 +738,10 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
OperationType = typeof(PinchObject3D),
|
||||
TitleResolver = () => "Pinch".Localize(),
|
||||
Action = (scene) =>
|
||||
Action = (sceneContext) =>
|
||||
{
|
||||
var pinch = new PinchObject3D();
|
||||
pinch.WrapSelectedItemAndSelect(scene);
|
||||
pinch.WrapSelectedItemAndSelect(sceneContext.Scene);
|
||||
},
|
||||
Icon = AggContext.StaticData.LoadIcon("pinch.png", 16, 16, theme.InvertIcons),
|
||||
IsEnabled = (scene) => scene.SelectedItem != null,
|
||||
|
|
@ -746,10 +750,10 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
OperationType = typeof(CurveObject3D),
|
||||
TitleResolver = () => "Curve".Localize(),
|
||||
Action = (scene) =>
|
||||
Action = (sceneContext) =>
|
||||
{
|
||||
var curve = new CurveObject3D();
|
||||
curve.WrapSelectedItemAndSelect(scene);
|
||||
curve.WrapSelectedItemAndSelect(sceneContext.Scene);
|
||||
},
|
||||
Icon = AggContext.StaticData.LoadIcon("curve.png", 16, 16, theme.InvertIcons),
|
||||
IsEnabled = (scene) => scene.SelectedItem != null,
|
||||
|
|
@ -758,8 +762,9 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
OperationType = typeof(FitToBoundsObject3D_2),
|
||||
TitleResolver = () => "Fit to Bounds".Localize(),
|
||||
Action = (scene) =>
|
||||
Action = (sceneContext) =>
|
||||
{
|
||||
var scene = sceneContext.Scene;
|
||||
var selectedItem = scene.SelectedItem;
|
||||
scene.SelectedItem = null;
|
||||
var fit = FitToBoundsObject3D_2.Create(selectedItem.Clone());
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.MatterControl;
|
||||
|
||||
namespace MatterHackers.Agg.UI
|
||||
{
|
||||
|
|
@ -64,7 +65,7 @@ namespace MatterHackers.Agg.UI
|
|||
|
||||
public class SceneSelectionOperation : LocalizedAction
|
||||
{
|
||||
public Action<InteractiveScene> Action { get; set; }
|
||||
public Action<BedConfig> Action { get; set; }
|
||||
public Func<InteractiveScene, bool> IsEnabled { get; set; }
|
||||
public Type OperationType { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -487,7 +487,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
namedAction.Action.Invoke(sceneContext.Scene);
|
||||
namedAction.Action.Invoke(sceneContext);
|
||||
var partTab = button.Parents<PartTabPage>().FirstOrDefault();
|
||||
var view3D = partTab.Descendants<View3DWidget>().FirstOrDefault();
|
||||
view3D.InteractionLayer.Focus();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue