2015-08-15 16:38:07 -07:00
|
|
|
|
/*
|
2017-05-26 00:59:47 -07:00
|
|
|
|
Copyright (c) 2017, Lars Brubaker, John Lewin
|
2015-08-15 16:38:07 -07:00
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
|
|
list of conditions and the following disclaimer.
|
|
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
|
and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
|
|
The views and conclusions contained in the software and documentation are those
|
|
|
|
|
|
of the authors and should not be interpreted as representing official policies,
|
|
|
|
|
|
either expressed or implied, of the FreeBSD Project.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
using System;
|
2017-07-07 12:25:31 -07:00
|
|
|
|
using System.Collections.ObjectModel;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
using System.IO;
|
2017-05-24 19:11:51 -07:00
|
|
|
|
using System.Linq;
|
2017-05-26 00:59:47 -07:00
|
|
|
|
using MatterHackers.Agg;
|
|
|
|
|
|
using MatterHackers.Agg.ImageProcessing;
|
2017-08-20 02:34:39 -07:00
|
|
|
|
using MatterHackers.Agg.Platform;
|
2017-05-26 00:59:47 -07:00
|
|
|
|
using MatterHackers.Agg.UI;
|
|
|
|
|
|
using MatterHackers.Localizations;
|
2017-08-14 12:34:44 -07:00
|
|
|
|
using MatterHackers.MatterControl.CustomWidgets;
|
|
|
|
|
|
using MatterHackers.VectorMath;
|
2014-05-25 11:11:11 -07:00
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl.PartPreviewWindow
|
|
|
|
|
|
{
|
2015-05-29 15:13:56 -07:00
|
|
|
|
public enum ViewControls3DButtons
|
|
|
|
|
|
{
|
|
|
|
|
|
Rotate,
|
|
|
|
|
|
Scale,
|
|
|
|
|
|
Translate,
|
|
|
|
|
|
PartSelect
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-19 09:01:07 -07:00
|
|
|
|
public enum PartViewMode
|
|
|
|
|
|
{
|
|
|
|
|
|
Layers2D,
|
|
|
|
|
|
Layers3D,
|
|
|
|
|
|
Model
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class ViewModeChangedEventArgs : EventArgs
|
|
|
|
|
|
{
|
|
|
|
|
|
public PartViewMode ViewMode { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-05-25 17:58:20 -07:00
|
|
|
|
public class TransformStateChangedEventArgs : EventArgs
|
|
|
|
|
|
{
|
|
|
|
|
|
public ViewControls3DButtons TransformMode { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-19 09:01:07 -07:00
|
|
|
|
public class ViewControls3D : FlowLayoutWidget
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2017-05-26 00:59:47 -07:00
|
|
|
|
public event EventHandler ResetView;
|
2017-10-19 09:01:07 -07:00
|
|
|
|
|
2017-07-06 18:15:53 -07:00
|
|
|
|
public event EventHandler<ViewModeChangedEventArgs> ViewModeChanged;
|
|
|
|
|
|
|
2017-05-26 00:59:47 -07:00
|
|
|
|
public event EventHandler<TransformStateChangedEventArgs> TransformStateChanged;
|
|
|
|
|
|
|
2017-10-15 15:50:48 -07:00
|
|
|
|
internal OverflowMenu OverflowMenu;
|
2017-05-26 00:59:47 -07:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
private GuiWidget partSelectSeparator;
|
2015-11-09 12:36:47 -08:00
|
|
|
|
private Button resetViewButton;
|
|
|
|
|
|
|
2015-05-29 15:13:56 -07:00
|
|
|
|
private RadioButton translateButton;
|
|
|
|
|
|
private RadioButton rotateButton;
|
|
|
|
|
|
private RadioButton scaleButton;
|
|
|
|
|
|
private RadioButton partSelectButton;
|
|
|
|
|
|
|
2017-07-10 12:23:02 -07:00
|
|
|
|
public RadioButton Layers2DButton;
|
|
|
|
|
|
|
2017-03-15 16:17:06 -07:00
|
|
|
|
private EventHandler unregisterEvents;
|
|
|
|
|
|
|
2017-05-26 00:59:47 -07:00
|
|
|
|
private ViewControls3DButtons activeTransformState = ViewControls3DButtons.Rotate;
|
2017-10-14 23:18:06 -07:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public bool PartSelectVisible
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return partSelectSeparator.Visible; }
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
2017-07-05 13:55:38 -07:00
|
|
|
|
partSelectSeparator.Visible = false;
|
|
|
|
|
|
partSelectButton.Visible = false;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-05-29 15:13:56 -07:00
|
|
|
|
public ViewControls3DButtons ActiveButton
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return activeTransformState;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
this.activeTransformState = value;
|
2017-05-25 17:58:20 -07:00
|
|
|
|
switch (this.activeTransformState)
|
2015-05-29 15:13:56 -07:00
|
|
|
|
{
|
2017-05-25 17:58:20 -07:00
|
|
|
|
case ViewControls3DButtons.Rotate:
|
2017-07-05 13:55:38 -07:00
|
|
|
|
if (rotateButton != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
rotateButton.Checked = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-05-25 17:58:20 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case ViewControls3DButtons.Translate:
|
2017-07-05 13:55:38 -07:00
|
|
|
|
if (translateButton != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
translateButton.Checked = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-05-25 17:58:20 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case ViewControls3DButtons.Scale:
|
2017-07-05 13:55:38 -07:00
|
|
|
|
if (scaleButton != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
scaleButton.Checked = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-05-25 17:58:20 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case ViewControls3DButtons.PartSelect:
|
|
|
|
|
|
partSelectButton.Checked = true;
|
|
|
|
|
|
break;
|
2015-05-29 15:13:56 -07:00
|
|
|
|
}
|
2017-05-25 17:58:20 -07:00
|
|
|
|
|
|
|
|
|
|
TransformStateChanged?.Invoke(this, new TransformStateChangedEventArgs()
|
|
|
|
|
|
{
|
|
|
|
|
|
TransformMode = activeTransformState
|
|
|
|
|
|
});
|
2015-05-29 15:13:56 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-08-14 12:34:44 -07:00
|
|
|
|
public ViewControls3D(ThemeConfig theme, UndoBuffer undoBuffer)
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2017-03-15 16:17:06 -07:00
|
|
|
|
string iconPath;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
2017-08-14 12:34:44 -07:00
|
|
|
|
var commonMargin = theme.ButtonSpacing;
|
2017-08-10 05:13:45 -07:00
|
|
|
|
|
2017-08-10 07:52:27 -07:00
|
|
|
|
var buttonFactory = theme.RadioButtons;
|
2017-08-10 05:13:45 -07:00
|
|
|
|
|
2017-10-15 00:22:47 -07:00
|
|
|
|
double height = theme.ButtonFactory.Options.FixedHeight;
|
2017-08-14 12:34:44 -07:00
|
|
|
|
|
2017-10-14 23:18:06 -07:00
|
|
|
|
Button undoButton = buttonFactory.GenerateIconButton(AggContext.StaticData.LoadIcon("Undo_grey_16x.png", 16, 16, IconColor.White));
|
2017-08-14 12:34:44 -07:00
|
|
|
|
undoButton.Name = "3D View Undo";
|
|
|
|
|
|
undoButton.ToolTipText = "Undo";
|
|
|
|
|
|
undoButton.Enabled = false;
|
|
|
|
|
|
undoButton.MinimumSize = new Vector2(height, height);
|
|
|
|
|
|
undoButton.Margin = commonMargin;
|
|
|
|
|
|
undoButton.Click += (sender, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
undoBuffer.Undo();
|
|
|
|
|
|
};
|
|
|
|
|
|
this.AddChild(undoButton);
|
|
|
|
|
|
undoButton.VAnchor = VAnchor.Center;
|
|
|
|
|
|
|
2017-10-14 23:18:06 -07:00
|
|
|
|
Button redoButton = buttonFactory.GenerateIconButton(AggContext.StaticData.LoadIcon("Redo_grey_16x.png", 16, 16, IconColor.White));
|
2017-08-14 12:34:44 -07:00
|
|
|
|
redoButton.Name = "3D View Redo";
|
|
|
|
|
|
redoButton.Margin = commonMargin;
|
|
|
|
|
|
redoButton.MinimumSize = new Vector2(height, height);
|
|
|
|
|
|
redoButton.ToolTipText = "Redo";
|
|
|
|
|
|
redoButton.Enabled = false;
|
|
|
|
|
|
redoButton.VAnchor = VAnchor.Center;
|
|
|
|
|
|
redoButton.Click += (sender, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
undoBuffer.Redo();
|
|
|
|
|
|
};
|
|
|
|
|
|
this.AddChild(redoButton);
|
|
|
|
|
|
|
|
|
|
|
|
this.AddChild(new VerticalLine(50)
|
|
|
|
|
|
{
|
|
|
|
|
|
Margin = 4
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
undoBuffer.Changed += (sender, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
undoButton.Enabled = undoBuffer.UndoCount > 0;
|
|
|
|
|
|
redoButton.Enabled = undoBuffer.RedoCount > 0;
|
|
|
|
|
|
};
|
2017-09-30 10:26:39 -07:00
|
|
|
|
|
2017-03-15 16:17:06 -07:00
|
|
|
|
iconPath = Path.Combine("ViewTransformControls", "reset.png");
|
2017-10-14 23:18:06 -07:00
|
|
|
|
resetViewButton = theme.ButtonFactory.GenerateIconButton(AggContext.StaticData.LoadIcon(iconPath, 32, 32, IconColor.White));
|
2015-11-09 12:36:47 -08:00
|
|
|
|
resetViewButton.ToolTipText = "Reset View".Localize();
|
2017-08-10 05:13:45 -07:00
|
|
|
|
resetViewButton.Margin = commonMargin;
|
2017-03-15 16:17:06 -07:00
|
|
|
|
resetViewButton.Click += (s, e) => ResetView?.Invoke(this, null);
|
2017-05-24 19:11:51 -07:00
|
|
|
|
AddChild(resetViewButton);
|
2015-11-09 12:36:47 -08:00
|
|
|
|
|
2017-07-07 12:25:31 -07:00
|
|
|
|
var buttonGroupA = new ObservableCollection<GuiWidget>();
|
|
|
|
|
|
|
2017-07-05 13:55:38 -07:00
|
|
|
|
if (UserSettings.Instance.IsTouchScreen)
|
|
|
|
|
|
{
|
|
|
|
|
|
iconPath = Path.Combine("ViewTransformControls", "rotate.png");
|
2017-10-15 01:24:33 -07:00
|
|
|
|
rotateButton = buttonFactory.GenerateRadioButton("", AggContext.StaticData.LoadIcon(iconPath, 32, 32, IconColor.White));
|
2017-07-07 12:25:31 -07:00
|
|
|
|
rotateButton.SiblingRadioButtonList = buttonGroupA;
|
2017-07-05 13:55:38 -07:00
|
|
|
|
rotateButton.ToolTipText = "Rotate (Alt + Left Mouse)".Localize();
|
2017-08-10 05:13:45 -07:00
|
|
|
|
rotateButton.Margin = commonMargin;
|
2017-07-05 13:55:38 -07:00
|
|
|
|
rotateButton.Click += (s, e) => this.ActiveButton = ViewControls3DButtons.Rotate;
|
2017-07-07 12:25:31 -07:00
|
|
|
|
buttonGroupA.Add(rotateButton);
|
2017-07-05 13:55:38 -07:00
|
|
|
|
AddChild(rotateButton);
|
|
|
|
|
|
|
|
|
|
|
|
iconPath = Path.Combine("ViewTransformControls", "translate.png");
|
2017-10-15 01:24:33 -07:00
|
|
|
|
translateButton = buttonFactory.GenerateRadioButton("", AggContext.StaticData.LoadIcon(iconPath, 32, 32, IconColor.White));
|
2017-07-07 12:25:31 -07:00
|
|
|
|
translateButton.SiblingRadioButtonList = buttonGroupA;
|
2017-07-05 13:55:38 -07:00
|
|
|
|
translateButton.ToolTipText = "Move (Shift + Left Mouse)".Localize();
|
2017-08-10 05:13:45 -07:00
|
|
|
|
translateButton.Margin = commonMargin;
|
2017-07-05 13:55:38 -07:00
|
|
|
|
translateButton.Click += (s, e) => this.ActiveButton = ViewControls3DButtons.Translate;
|
2017-07-07 12:25:31 -07:00
|
|
|
|
buttonGroupA.Add(translateButton);
|
2017-07-05 13:55:38 -07:00
|
|
|
|
AddChild(translateButton);
|
|
|
|
|
|
|
|
|
|
|
|
iconPath = Path.Combine("ViewTransformControls", "scale.png");
|
2017-10-15 01:24:33 -07:00
|
|
|
|
scaleButton = buttonFactory.GenerateRadioButton("", AggContext.StaticData.LoadIcon(iconPath, 32, 32, IconColor.White));
|
2017-07-07 12:25:31 -07:00
|
|
|
|
scaleButton.SiblingRadioButtonList = buttonGroupA;
|
2017-07-05 13:55:38 -07:00
|
|
|
|
scaleButton.ToolTipText = "Zoom (Ctrl + Left Mouse)".Localize();
|
2017-08-10 05:13:45 -07:00
|
|
|
|
scaleButton.Margin = commonMargin;
|
2017-07-05 13:55:38 -07:00
|
|
|
|
scaleButton.Click += (s, e) => this.ActiveButton = ViewControls3DButtons.Scale;
|
2017-07-07 12:25:31 -07:00
|
|
|
|
buttonGroupA.Add(scaleButton);
|
2017-07-05 13:55:38 -07:00
|
|
|
|
AddChild(scaleButton);
|
|
|
|
|
|
|
|
|
|
|
|
rotateButton.Checked = true;
|
|
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
2017-10-20 07:26:14 -07:00
|
|
|
|
partSelectSeparator = new VerticalLine(50)
|
|
|
|
|
|
{
|
|
|
|
|
|
Margin = 3
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
this.AddChild(partSelectSeparator);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
2017-03-15 16:17:06 -07:00
|
|
|
|
iconPath = Path.Combine("ViewTransformControls", "partSelect.png");
|
2017-10-14 23:18:06 -07:00
|
|
|
|
partSelectButton = buttonFactory.GenerateRadioButton("", AggContext.StaticData.LoadIcon(iconPath, 32, 32, IconColor.White));
|
2017-07-07 12:25:31 -07:00
|
|
|
|
partSelectButton.SiblingRadioButtonList = buttonGroupA;
|
2017-05-22 18:17:35 -07:00
|
|
|
|
partSelectButton.ToolTipText = "Select Part".Localize();
|
2017-07-05 13:55:38 -07:00
|
|
|
|
partSelectButton.Visible = false;
|
2017-08-10 05:13:45 -07:00
|
|
|
|
partSelectButton.Margin = commonMargin;
|
2017-03-15 16:17:06 -07:00
|
|
|
|
partSelectButton.Click += (s, e) => this.ActiveButton = ViewControls3DButtons.PartSelect;
|
2017-07-07 12:25:31 -07:00
|
|
|
|
buttonGroupA.Add(partSelectButton);
|
2017-05-24 19:11:51 -07:00
|
|
|
|
AddChild(partSelectButton);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
2017-07-07 12:25:31 -07:00
|
|
|
|
var buttonGroupB = new ObservableCollection<GuiWidget>();
|
|
|
|
|
|
|
2017-07-06 18:15:53 -07:00
|
|
|
|
iconPath = Path.Combine("ViewTransformControls", "model.png");
|
2017-10-14 23:18:06 -07:00
|
|
|
|
var modelViewButton = buttonFactory.GenerateRadioButton("", AggContext.StaticData.LoadIcon(iconPath, 32, 32, IconColor.White));
|
2017-07-07 12:25:31 -07:00
|
|
|
|
modelViewButton.SiblingRadioButtonList = buttonGroupB;
|
2017-07-06 18:15:53 -07:00
|
|
|
|
modelViewButton.Name = "Model View Button";
|
2017-07-07 12:25:31 -07:00
|
|
|
|
modelViewButton.Checked = false;
|
2017-07-06 18:15:53 -07:00
|
|
|
|
modelViewButton.ToolTipText = "Model".Localize();
|
2017-08-10 05:13:45 -07:00
|
|
|
|
modelViewButton.Margin = commonMargin;
|
2017-07-06 18:15:53 -07:00
|
|
|
|
modelViewButton.Click += SwitchModes_Click;
|
2017-07-07 12:25:31 -07:00
|
|
|
|
buttonGroupB.Add(modelViewButton);
|
2017-07-06 18:15:53 -07:00
|
|
|
|
AddChild(modelViewButton);
|
|
|
|
|
|
|
2017-07-07 17:58:23 -07:00
|
|
|
|
iconPath = Path.Combine("ViewTransformControls", "3d.png");
|
2017-10-14 23:18:06 -07:00
|
|
|
|
var layers3DButton = buttonFactory.GenerateRadioButton("", AggContext.StaticData.LoadIcon(iconPath, 32, 32, IconColor.White));
|
2017-07-07 12:25:31 -07:00
|
|
|
|
layers3DButton.SiblingRadioButtonList = buttonGroupB;
|
2017-07-06 18:15:53 -07:00
|
|
|
|
layers3DButton.Name = "Layers3D Button";
|
|
|
|
|
|
layers3DButton.ToolTipText = "3D Layers".Localize();
|
2017-08-10 05:13:45 -07:00
|
|
|
|
layers3DButton.Margin = commonMargin;
|
2017-07-06 18:15:53 -07:00
|
|
|
|
layers3DButton.Click += SwitchModes_Click;
|
2017-07-07 12:25:31 -07:00
|
|
|
|
buttonGroupB.Add(layers3DButton);
|
2017-07-06 18:15:53 -07:00
|
|
|
|
|
|
|
|
|
|
if (!UserSettings.Instance.IsTouchScreen)
|
2017-05-24 19:11:51 -07:00
|
|
|
|
{
|
2017-07-06 18:15:53 -07:00
|
|
|
|
this.AddChild(layers3DButton);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-07-07 17:58:23 -07:00
|
|
|
|
iconPath = Path.Combine("ViewTransformControls", "2d.png");
|
2017-10-14 23:18:06 -07:00
|
|
|
|
Layers2DButton = buttonFactory.GenerateRadioButton("", AggContext.StaticData.LoadIcon(iconPath, 32, 32, IconColor.White));
|
2017-07-10 12:23:02 -07:00
|
|
|
|
Layers2DButton.SiblingRadioButtonList = buttonGroupB;
|
|
|
|
|
|
Layers2DButton.Name = "Layers2D Button";
|
|
|
|
|
|
Layers2DButton.ToolTipText = "2D Layers".Localize();
|
|
|
|
|
|
Layers2DButton.Enabled = false;
|
2017-08-10 05:13:45 -07:00
|
|
|
|
Layers2DButton.Margin = commonMargin;
|
2017-07-10 12:23:02 -07:00
|
|
|
|
Layers2DButton.Click += SwitchModes_Click;
|
|
|
|
|
|
buttonGroupB.Add(Layers2DButton);
|
|
|
|
|
|
this.AddChild(Layers2DButton);
|
2017-05-24 19:11:51 -07:00
|
|
|
|
|
2017-10-20 07:26:14 -07:00
|
|
|
|
this.AddChild(new VerticalLine(50)
|
|
|
|
|
|
{
|
|
|
|
|
|
Margin = 3
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var namedAction in ApplicationController.Instance.RegisteredSceneOperations())
|
|
|
|
|
|
{
|
|
|
|
|
|
var button = buttonFactory.Generate(namedAction.Title.Localize());
|
|
|
|
|
|
button.Margin = theme.ButtonSpacing;
|
|
|
|
|
|
button.Click += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
namedAction.Action.Invoke(ApplicationController.Instance.ActivePrinter.Bed.Scene);
|
|
|
|
|
|
};
|
|
|
|
|
|
this.AddChild(button);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-19 09:01:07 -07:00
|
|
|
|
this.AddChild(new HorizontalSpacer());
|
|
|
|
|
|
|
2017-10-15 15:50:48 -07:00
|
|
|
|
this.AddChild(this.OverflowMenu = new OverflowMenu(IconColor.White)
|
2017-07-03 09:30:30 -07:00
|
|
|
|
{
|
|
|
|
|
|
Name = "View3D Overflow Menu",
|
2017-10-19 09:01:07 -07:00
|
|
|
|
AlignToRightEdge = true,
|
2017-07-03 09:30:30 -07:00
|
|
|
|
Margin = 3
|
2017-10-15 15:50:48 -07:00
|
|
|
|
});
|
2017-07-07 12:25:31 -07:00
|
|
|
|
|
|
|
|
|
|
this.ViewMode = PartViewMode.Model;
|
2017-05-22 18:17:35 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-07-06 18:15:53 -07:00
|
|
|
|
private void SwitchModes_Click(object sender, MouseEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sender is GuiWidget widget)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (widget.Name == "Layers2D Button")
|
|
|
|
|
|
{
|
2017-07-07 06:18:58 -07:00
|
|
|
|
this.ViewMode = PartViewMode.Layers2D;
|
2017-07-06 18:15:53 -07:00
|
|
|
|
}
|
|
|
|
|
|
else if (widget.Name == "Layers3D Button")
|
|
|
|
|
|
{
|
2017-07-07 06:18:58 -07:00
|
|
|
|
this.ViewMode = PartViewMode.Layers3D;
|
2017-07-06 18:15:53 -07:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2017-07-07 06:18:58 -07:00
|
|
|
|
this.ViewMode = PartViewMode.Model;
|
2017-07-06 18:15:53 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ViewModeChanged?.Invoke(this, new ViewModeChangedEventArgs()
|
|
|
|
|
|
{
|
2017-07-07 06:18:58 -07:00
|
|
|
|
ViewMode = this.ViewMode
|
2017-07-06 18:15:53 -07:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-07-07 06:18:58 -07:00
|
|
|
|
private PartViewMode viewMode;
|
|
|
|
|
|
public PartViewMode ViewMode
|
|
|
|
|
|
{
|
|
|
|
|
|
get => viewMode;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (viewMode != value)
|
|
|
|
|
|
{
|
|
|
|
|
|
viewMode = value;
|
|
|
|
|
|
|
|
|
|
|
|
string controlName;
|
|
|
|
|
|
|
|
|
|
|
|
if (viewMode == PartViewMode.Layers2D)
|
|
|
|
|
|
{
|
|
|
|
|
|
controlName = "Layers2D Button";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (viewMode == PartViewMode.Layers3D)
|
|
|
|
|
|
{
|
|
|
|
|
|
controlName = "Layers3D Button";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
controlName = "Model View Button";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var targetChild = Children.Where(c => c.Name == controlName).FirstOrDefault();
|
|
|
|
|
|
if (targetChild != null && targetChild is RadioButton button)
|
|
|
|
|
|
{
|
|
|
|
|
|
button.Checked = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-02-03 13:06:08 -08:00
|
|
|
|
public override void OnClosed(ClosedEventArgs e)
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2017-03-15 16:17:06 -07:00
|
|
|
|
unregisterEvents?.Invoke(this, null);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
base.OnClosed(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|