Add Dual Extrusion Align

- Convert Align button into operation group/drop menu button
- Issue MatterHackers/MCCentral#5664
consider adding a dual align quick button
This commit is contained in:
John Lewin 2019-06-13 08:27:01 -07:00
parent cb6eb43972
commit 24065be0fb
2 changed files with 40 additions and 12 deletions

View file

@ -753,19 +753,46 @@ namespace MatterHackers.MatterControl
Icon = (invertIcon) => AggContext.StaticData.LoadIcon("remove.png").SetPreMultiply(),
},
new SceneSelectionSeparator(),
new SceneSelectionOperation()
new OperationGroup()
{
OperationType = typeof(AlignObject3D),
TitleResolver = () => "Align".Localize(),
Action = (sceneContext) =>
{
var scene = sceneContext.Scene;
var selectedItem = scene.SelectedItem;
var align = new AlignObject3D();
align.AddSelectionAsChildren(scene, selectedItem);
},
Icon = (invertIcon) => AggContext.StaticData.LoadIcon("align_left_dark.png", 16, 16, invertIcon).SetPreMultiply(),
IsEnabled = (scene) => scene.SelectedItem is SelectionGroupObject3D,
Operations = new List<SceneSelectionOperation>()
{
new SceneSelectionOperation()
{
OperationType = typeof(AlignObject3D),
TitleResolver = () => "Align".Localize(),
Action = (sceneContext) =>
{
var scene = sceneContext.Scene;
var selectedItem = scene.SelectedItem;
var align = new AlignObject3D();
align.AddSelectionAsChildren(scene, selectedItem);
},
Icon = (invertIcon) => AggContext.StaticData.LoadIcon("align_left_dark.png", 16, 16, invertIcon).SetPreMultiply(),
IsEnabled = (scene) => scene.SelectedItem is SelectionGroupObject3D,
},
new SceneSelectionOperation()
{
OperationType = typeof(AlignObject3D),
TitleResolver = () => "Dual Extrusion Align".Localize(),
HelpTextResolver = () => "Reset parts to modeled positions".Localize(),
Action = (sceneContext) =>
{
var scene = sceneContext.Scene;
var selectedItem = scene.SelectedItem;
if (selectedItem is SelectionGroupObject3D selectionGroup)
{
foreach (var child in selectionGroup.Children)
{
child.Matrix = Matrix4X4.Identity;
}
}
},
IsEnabled = (scene) => scene.SelectedItem is SelectionGroupObject3D,
}
}
},
new SceneSelectionOperation()
{

View file

@ -518,7 +518,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
else if (namedAction.Icon != null)
{
// add the create support before the align
if (namedAction.OperationType == typeof(AlignObject3D))
if (namedAction is SceneSelectionOperation selectionOperation
&& selectionOperation.OperationType == typeof(AlignObject3D))
{
this.AddChild(CreateWipeTowerButton(theme));
this.AddChild(CreateSupportButton(theme));