Disable controls when !EditableScene, add IsEnabled to NamedAction
This commit is contained in:
parent
6be6a91f1f
commit
a76736e9a6
3 changed files with 54 additions and 9 deletions
|
|
@ -345,12 +345,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
Action = async () =>
|
||||
{
|
||||
await this.SaveChanges();
|
||||
}
|
||||
},
|
||||
IsEnabled = () => sceneContext.EditableScene
|
||||
},
|
||||
new NamedAction()
|
||||
{
|
||||
Title = "Save As".Localize(),
|
||||
Action = () => UiThread.RunOnIdle(OpenSaveAsWindow)
|
||||
Action = () => UiThread.RunOnIdle(OpenSaveAsWindow),
|
||||
IsEnabled = () => sceneContext.EditableScene
|
||||
},
|
||||
new NamedAction()
|
||||
{
|
||||
|
|
@ -365,7 +367,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
new FileSystemFileItem(sceneContext.EditContext.PartFilePath)
|
||||
}));
|
||||
});
|
||||
}
|
||||
},
|
||||
IsEnabled = () => sceneContext.EditableScene
|
||||
},
|
||||
new NamedAction()
|
||||
{
|
||||
|
|
@ -373,7 +376,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
Action = () =>
|
||||
{
|
||||
UiThread.RunOnIdle(() => DialogWindow.Show<PublishPartToMatterHackers>());
|
||||
}
|
||||
},
|
||||
IsEnabled = () => sceneContext.EditableScene
|
||||
},
|
||||
new NamedAction()
|
||||
{
|
||||
|
|
@ -381,7 +385,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
Action = () =>
|
||||
{
|
||||
this.Scene.AutoArrangeChildren(this);
|
||||
}
|
||||
},
|
||||
IsEnabled = () => sceneContext.EditableScene
|
||||
},
|
||||
new NamedAction() { Title = "----" },
|
||||
new NamedAction()
|
||||
|
|
@ -404,7 +409,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
new PopupButton(buttonView)
|
||||
{
|
||||
PopDirection = Direction.Up,
|
||||
PopupContent = theme.CreatePopupMenu(bedMenuActions),
|
||||
DynamicPopupContent = () => theme.CreatePopupMenu(bedMenuActions),
|
||||
AlignToRightEdge = true,
|
||||
Margin = buttonSpacing,
|
||||
Name = "Bed Options Menu",
|
||||
|
|
@ -507,10 +512,18 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
this.InteractionLayer.DrawGlOpaqueContent += Draw_GlOpaqueContent;
|
||||
|
||||
this.sceneContext.SceneLoaded += SceneContext_SceneLoaded;
|
||||
|
||||
this.viewControls3D.modelViewButton.Enabled = sceneContext.EditableScene;
|
||||
}
|
||||
|
||||
private void SceneContext_SceneLoaded(object sender, EventArgs e)
|
||||
{
|
||||
if (this.printerTabPage.printerActionsBar?.sliceButton is GuiWidget sliceButton)
|
||||
{
|
||||
sliceButton.Enabled = sceneContext.EditableScene;
|
||||
}
|
||||
|
||||
this.viewControls3D.modelViewButton.Enabled = sceneContext.EditableScene;
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
|
|
@ -814,6 +827,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
public bool DragOperationActive { get; private set; }
|
||||
|
||||
public InsertionGroup DragDropObject { get; private set; }
|
||||
public ILibraryContentStream SceneReplacement { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Provides a View3DWidget specific drag implementation
|
||||
|
|
@ -864,6 +878,18 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
this.DragOperationActive = true;
|
||||
|
||||
if (items.FirstOrDefault() is ILibraryContentStream contentStream
|
||||
&& contentStream.ContentType == "gcode")
|
||||
{
|
||||
DragDropObject = null;
|
||||
this.SceneReplacement = contentStream;
|
||||
|
||||
// TODO: Figure out a mechanism to disable View3DWidget with dark overlay, displaying something like "Switch to xxx.gcode", make disappear on mouseLeaveBounds and dragfinish
|
||||
this.InteractionLayer.BackgroundColor = new Color(Color.Black, 200);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the hitplane to the bed plane
|
||||
CurrentSelectInfo.HitPlane = bedPlane;
|
||||
|
||||
|
|
@ -905,12 +931,29 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
if (this.DragOperationActive)
|
||||
{
|
||||
this.InteractionLayer.BackgroundColor = Color.Transparent;
|
||||
this.DragOperationActive = false;
|
||||
|
||||
if (mouseUpInBounds)
|
||||
{
|
||||
if (this.DragDropObject.ContentAcquired)
|
||||
if (this.DragDropObject == null
|
||||
&& this.SceneReplacement != null)
|
||||
{
|
||||
// Drop handler for special case of GCode or similar (change loaded scene to new context)
|
||||
sceneContext.LoadContent(
|
||||
new EditContext()
|
||||
{
|
||||
SourceItem = this.SceneReplacement,
|
||||
ContentStore = null
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
this.SceneReplacement = null;
|
||||
}
|
||||
else if (this.DragDropObject.ContentAcquired)
|
||||
{
|
||||
|
||||
// Drop handler for InsertionGroup - all normal content
|
||||
this.viewControls3D.modelViewButton.Enabled = true;
|
||||
this.DragDropObject.Collapse();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue