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;
|
2018-01-08 23:34:40 -08:00
|
|
|
|
using System.Collections.Generic;
|
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;
|
2018-10-19 17:43:06 -07:00
|
|
|
|
using System.Threading;
|
2018-01-08 23:34:40 -08:00
|
|
|
|
using System.Threading.Tasks;
|
2017-05-26 00:59:47 -07:00
|
|
|
|
using MatterHackers.Agg;
|
2017-08-20 02:34:39 -07:00
|
|
|
|
using MatterHackers.Agg.Platform;
|
2017-05-26 00:59:47 -07:00
|
|
|
|
using MatterHackers.Agg.UI;
|
2018-01-08 23:34:40 -08:00
|
|
|
|
using MatterHackers.DataConverters3D;
|
2017-05-26 00:59:47 -07:00
|
|
|
|
using MatterHackers.Localizations;
|
2017-08-14 12:34:44 -07:00
|
|
|
|
using MatterHackers.MatterControl.CustomWidgets;
|
2018-01-08 23:34:40 -08:00
|
|
|
|
using MatterHackers.MatterControl.DataStorage;
|
|
|
|
|
|
using MatterHackers.MatterControl.Library;
|
2018-10-16 11:41:30 -07:00
|
|
|
|
using MatterHackers.MatterControl.PrinterControls.PrinterConnections;
|
2018-10-07 11:36:52 -07:00
|
|
|
|
using MatterHackers.MatterControl.PrintLibrary;
|
2018-10-17 17:38:20 -07:00
|
|
|
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
2017-08-14 12:34:44 -07:00
|
|
|
|
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-12-26 09:11:23 -08:00
|
|
|
|
public class ViewControls3D : OverflowBar
|
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-05-26 00:59:47 -07:00
|
|
|
|
public event EventHandler<TransformStateChangedEventArgs> TransformStateChanged;
|
|
|
|
|
|
|
2017-11-09 15:48:05 -08:00
|
|
|
|
private RadioIconButton translateButton;
|
|
|
|
|
|
private RadioIconButton rotateButton;
|
|
|
|
|
|
private RadioIconButton scaleButton;
|
|
|
|
|
|
private RadioIconButton partSelectButton;
|
2015-05-29 15:13:56 -07:00
|
|
|
|
|
2018-01-08 23:34:40 -08:00
|
|
|
|
private View3DWidget view3DWidget;
|
2018-01-17 08:05:12 -08:00
|
|
|
|
private BedConfig sceneContext;
|
2017-11-27 17:36:36 -08:00
|
|
|
|
|
2018-02-02 17:43:54 -08:00
|
|
|
|
private ViewControls3DButtons activeTransformState = ViewControls3DButtons.PartSelect;
|
2018-01-10 11:58:42 -08:00
|
|
|
|
private List<(GuiWidget button, SceneSelectionOperation operation)> operationButtons;
|
|
|
|
|
|
|
2018-08-08 07:08:08 -07:00
|
|
|
|
public NamedAction[] MenuActions { get; private set; }
|
|
|
|
|
|
|
2018-09-10 12:02:20 -07:00
|
|
|
|
internal void NotifyResetView()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ResetView.Invoke(this, null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-11 22:26:05 -08:00
|
|
|
|
public bool IsPrinterMode { get; }
|
2017-10-14 23:18:06 -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:
|
2017-11-29 07:44:42 -08:00
|
|
|
|
if (partSelectButton != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
partSelectButton.Checked = true;
|
|
|
|
|
|
}
|
2017-05-25 17:58:20 -07:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-08 23:34:40 -08:00
|
|
|
|
internal void SetView3DWidget(View3DWidget view3DWidget)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.view3DWidget = view3DWidget;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-10-15 15:13:40 -07:00
|
|
|
|
public ViewControls3D(BedConfig sceneContext, ThemeConfig theme, UndoBuffer undoBuffer, bool isPrinterType, bool showPrintButton)
|
2018-10-07 11:36:52 -07:00
|
|
|
|
: base(theme)
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2018-01-26 17:53:54 -08:00
|
|
|
|
this.ActionArea.Click += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
view3DWidget.InteractionLayer.Focus();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2018-01-11 22:26:05 -08:00
|
|
|
|
this.IsPrinterMode = isPrinterType;
|
2018-01-17 08:05:12 -08:00
|
|
|
|
this.sceneContext = sceneContext;
|
2017-11-29 15:22:18 -08:00
|
|
|
|
|
2017-03-15 16:17:06 -07:00
|
|
|
|
string iconPath;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
2018-10-07 11:36:52 -07:00
|
|
|
|
this.AddChild(CreateAddButton(sceneContext, theme));
|
2018-01-11 22:25:36 -08:00
|
|
|
|
|
2018-05-17 13:52:29 -07:00
|
|
|
|
this.AddChild(new ToolbarSeparator(theme));
|
2018-01-12 23:19:44 -08:00
|
|
|
|
|
2018-10-19 18:17:27 -07:00
|
|
|
|
var optionsButton = new PopupMenuButton(AggContext.StaticData.LoadIcon("bed.png", 16, 16, theme.InvertIcons), theme)
|
2018-10-18 17:25:56 -07:00
|
|
|
|
{
|
|
|
|
|
|
Name = "Bed Options Menu",
|
|
|
|
|
|
//ToolTipText = "Options",
|
|
|
|
|
|
Enabled = true,
|
|
|
|
|
|
Margin = theme.ButtonSpacing,
|
2018-10-19 18:17:27 -07:00
|
|
|
|
VAnchor = VAnchor.Center,
|
|
|
|
|
|
DrawArrow = true
|
2018-10-18 17:25:56 -07:00
|
|
|
|
};
|
|
|
|
|
|
optionsButton.DynamicPopupContent = () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme);
|
|
|
|
|
|
theme.CreateMenuItems(popupMenu, this.BedMenuActions(sceneContext, theme), emptyMenu: false);
|
|
|
|
|
|
|
|
|
|
|
|
return popupMenu;
|
|
|
|
|
|
};
|
|
|
|
|
|
this.AddChild(optionsButton);
|
|
|
|
|
|
|
|
|
|
|
|
this.AddChild(new ToolbarSeparator(theme));
|
|
|
|
|
|
|
2018-04-12 08:42:10 -07:00
|
|
|
|
var undoButton = new IconButton(AggContext.StaticData.LoadIcon("Undo_grey_16x.png", 16, 16, theme.InvertIcons), theme)
|
2017-11-09 12:44:47 -08:00
|
|
|
|
{
|
|
|
|
|
|
Name = "3D View Undo",
|
|
|
|
|
|
ToolTipText = "Undo",
|
|
|
|
|
|
Enabled = false,
|
2018-06-25 08:39:57 -07:00
|
|
|
|
Margin = theme.ButtonSpacing,
|
2017-11-09 12:44:47 -08:00
|
|
|
|
VAnchor = VAnchor.Center
|
|
|
|
|
|
};
|
2017-08-14 12:34:44 -07:00
|
|
|
|
undoButton.Click += (sender, e) =>
|
|
|
|
|
|
{
|
2018-10-21 11:52:05 -07:00
|
|
|
|
var selectedItem = sceneContext.Scene.SelectedItem;
|
2018-02-09 13:50:05 -08:00
|
|
|
|
sceneContext.Scene.SelectedItem = null;
|
2017-08-14 12:34:44 -07:00
|
|
|
|
undoBuffer.Undo();
|
2018-01-26 17:53:54 -08:00
|
|
|
|
view3DWidget.InteractionLayer.Focus();
|
2018-10-21 11:52:05 -07:00
|
|
|
|
// if the item we had selected is still in the scene, re-select it
|
|
|
|
|
|
if(sceneContext.Scene.Children.Contains(selectedItem))
|
|
|
|
|
|
{
|
|
|
|
|
|
sceneContext.Scene.SelectedItem = selectedItem;
|
|
|
|
|
|
}
|
2017-08-14 12:34:44 -07:00
|
|
|
|
};
|
|
|
|
|
|
this.AddChild(undoButton);
|
2017-11-09 12:44:47 -08:00
|
|
|
|
|
2018-04-12 08:42:10 -07:00
|
|
|
|
var redoButton = new IconButton(AggContext.StaticData.LoadIcon("Redo_grey_16x.png", 16, 16, theme.InvertIcons), theme)
|
2017-11-09 12:44:47 -08:00
|
|
|
|
{
|
|
|
|
|
|
Name = "3D View Redo",
|
2018-06-25 08:39:57 -07:00
|
|
|
|
Margin = theme.ButtonSpacing,
|
2017-11-09 12:44:47 -08:00
|
|
|
|
ToolTipText = "Redo",
|
|
|
|
|
|
Enabled = false,
|
|
|
|
|
|
VAnchor = VAnchor.Center
|
|
|
|
|
|
};
|
2017-08-14 12:34:44 -07:00
|
|
|
|
redoButton.Click += (sender, e) =>
|
|
|
|
|
|
{
|
2018-10-21 11:52:05 -07:00
|
|
|
|
var selectedItem = sceneContext.Scene.SelectedItem;
|
|
|
|
|
|
sceneContext.Scene.SelectedItem = null;
|
2017-08-14 12:34:44 -07:00
|
|
|
|
undoBuffer.Redo();
|
2018-01-26 17:53:54 -08:00
|
|
|
|
view3DWidget.InteractionLayer.Focus();
|
2018-10-21 11:52:05 -07:00
|
|
|
|
// if the item we had selected is still in the scene, re-select it
|
|
|
|
|
|
if (sceneContext.Scene.Children.Contains(selectedItem))
|
|
|
|
|
|
{
|
|
|
|
|
|
sceneContext.Scene.SelectedItem = selectedItem;
|
|
|
|
|
|
}
|
2017-08-14 12:34:44 -07:00
|
|
|
|
};
|
|
|
|
|
|
this.AddChild(redoButton);
|
|
|
|
|
|
|
2018-10-07 11:36:52 -07:00
|
|
|
|
this.AddChild(CreateSaveButton(theme));
|
|
|
|
|
|
|
2018-10-15 15:13:40 -07:00
|
|
|
|
if (showPrintButton)
|
|
|
|
|
|
{
|
2018-10-17 14:42:01 -07:00
|
|
|
|
var printButton = new TextButton("Print", theme)
|
|
|
|
|
|
{
|
2018-10-17 17:38:20 -07:00
|
|
|
|
Name = "Print Button",
|
2018-10-17 14:42:01 -07:00
|
|
|
|
BackgroundColor = theme.AccentMimimalOverlay
|
|
|
|
|
|
};
|
2018-10-16 11:41:30 -07:00
|
|
|
|
printButton.Click += (s, e) =>
|
|
|
|
|
|
{
|
2018-10-17 17:38:20 -07:00
|
|
|
|
if (ProfileManager.Instance.Profiles.Count <= 0)
|
2018-10-16 11:41:30 -07:00
|
|
|
|
{
|
2018-10-17 17:38:20 -07:00
|
|
|
|
//Launch window to prompt user to sign in
|
|
|
|
|
|
UiThread.RunOnIdle(() => DialogWindow.Show(new SetupStepMakeModelName()));
|
2018-10-16 11:41:30 -07:00
|
|
|
|
}
|
2018-10-19 17:43:06 -07:00
|
|
|
|
// If no active printer but profiles exist, show select printer
|
|
|
|
|
|
// If printer exists, stash plate with undo operation, then load this scene onto the printer bed
|
|
|
|
|
|
else if (ApplicationController.Instance.ActivePrinter is PrinterConfig printer && printer.Settings.PrinterSelected)
|
|
|
|
|
|
{
|
|
|
|
|
|
Task.Run(async () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
await ApplicationController.Instance.Tasks.Execute("Saving".Localize(), sceneContext.SaveChanges);
|
|
|
|
|
|
|
|
|
|
|
|
// Clear bed to get new MCX on disk for this item
|
|
|
|
|
|
printer.Bed.ClearPlate();
|
|
|
|
|
|
|
|
|
|
|
|
var editContext = sceneContext.EditContext;
|
|
|
|
|
|
|
|
|
|
|
|
await printer.Bed.LoadContent(editContext);
|
|
|
|
|
|
|
|
|
|
|
|
// Switch to printer
|
|
|
|
|
|
ApplicationController.Instance.AppView.TabControl.SelectedTabKey = printer.Settings.GetValue(SettingsKey.printer_name);
|
|
|
|
|
|
|
|
|
|
|
|
// Slice and print
|
|
|
|
|
|
await ApplicationController.Instance.PrintPart(
|
|
|
|
|
|
editContext,
|
|
|
|
|
|
printer,
|
|
|
|
|
|
null,
|
2018-10-19 18:17:27 -07:00
|
|
|
|
CancellationToken.None);
|
2018-10-19 17:43:06 -07:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2018-10-17 17:38:20 -07:00
|
|
|
|
|
2018-10-16 11:41:30 -07:00
|
|
|
|
};
|
2018-10-15 15:13:40 -07:00
|
|
|
|
this.AddChild(printButton);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-05-17 13:52:29 -07:00
|
|
|
|
this.AddChild(new ToolbarSeparator(theme));
|
2017-08-14 12:34:44 -07:00
|
|
|
|
|
|
|
|
|
|
undoBuffer.Changed += (sender, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
undoButton.Enabled = undoBuffer.UndoCount > 0;
|
|
|
|
|
|
redoButton.Enabled = undoBuffer.RedoCount > 0;
|
|
|
|
|
|
};
|
2017-09-30 10:26:39 -07:00
|
|
|
|
|
2018-08-21 12:29:09 -07:00
|
|
|
|
undoButton.Enabled = undoBuffer.UndoCount > 0;
|
|
|
|
|
|
redoButton.Enabled = undoBuffer.RedoCount > 0;
|
|
|
|
|
|
|
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");
|
2018-04-12 08:42:10 -07:00
|
|
|
|
rotateButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 32, 32, theme.InvertIcons), theme)
|
2017-11-09 15:48:05 -08:00
|
|
|
|
{
|
|
|
|
|
|
SiblingRadioButtonList = buttonGroupA,
|
|
|
|
|
|
ToolTipText = "Rotate (Alt + Left Mouse)".Localize(),
|
2018-06-25 08:39:57 -07:00
|
|
|
|
Margin = theme.ButtonSpacing
|
2017-11-09 15:48:05 -08:00
|
|
|
|
};
|
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");
|
2018-04-12 08:42:10 -07:00
|
|
|
|
translateButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 32, 32, theme.InvertIcons), theme)
|
2017-11-09 15:48:05 -08:00
|
|
|
|
{
|
|
|
|
|
|
SiblingRadioButtonList = buttonGroupA,
|
|
|
|
|
|
ToolTipText = "Move (Shift + Left Mouse)".Localize(),
|
2018-06-25 08:39:57 -07:00
|
|
|
|
Margin = theme.ButtonSpacing
|
2017-11-09 15:48:05 -08:00
|
|
|
|
};
|
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");
|
2018-04-12 08:42:10 -07:00
|
|
|
|
scaleButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 32, 32, theme.InvertIcons), theme)
|
2017-11-09 15:48:05 -08:00
|
|
|
|
{
|
|
|
|
|
|
SiblingRadioButtonList = buttonGroupA,
|
|
|
|
|
|
ToolTipText = "Zoom (Ctrl + Left Mouse)".Localize(),
|
2018-06-25 08:39:57 -07:00
|
|
|
|
Margin = theme.ButtonSpacing
|
2017-11-09 15:48:05 -08:00
|
|
|
|
};
|
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
|
|
|
|
|
2018-01-10 11:39:39 -08:00
|
|
|
|
// Add vertical separator
|
2018-05-17 13:52:29 -07:00
|
|
|
|
this.AddChild(new ToolbarSeparator(theme));
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
2017-11-29 07:44:42 -08:00
|
|
|
|
iconPath = Path.Combine("ViewTransformControls", "partSelect.png");
|
2018-04-12 08:42:10 -07:00
|
|
|
|
partSelectButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 32, 32, theme.InvertIcons), theme)
|
2017-11-29 07:44:42 -08:00
|
|
|
|
{
|
|
|
|
|
|
SiblingRadioButtonList = buttonGroupA,
|
|
|
|
|
|
ToolTipText = "Select Part".Localize(),
|
2018-06-25 08:39:57 -07:00
|
|
|
|
Margin = theme.ButtonSpacing
|
2017-11-29 07:44:42 -08:00
|
|
|
|
};
|
|
|
|
|
|
partSelectButton.Click += (s, e) => this.ActiveButton = ViewControls3DButtons.PartSelect;
|
|
|
|
|
|
buttonGroupA.Add(partSelectButton);
|
|
|
|
|
|
AddChild(partSelectButton);
|
|
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
2018-01-10 11:58:42 -08:00
|
|
|
|
operationButtons = new List<(GuiWidget, SceneSelectionOperation)>();
|
|
|
|
|
|
|
2018-01-10 11:39:39 -08:00
|
|
|
|
// Add Selected IObject3D -> Operations to toolbar
|
|
|
|
|
|
foreach (var namedAction in ApplicationController.Instance.RegisteredSceneOperations)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (namedAction is SceneSelectionSeparator)
|
|
|
|
|
|
{
|
2018-05-17 13:52:29 -07:00
|
|
|
|
this.AddChild(new ToolbarSeparator(theme));
|
2018-01-10 11:39:39 -08:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GuiWidget button;
|
|
|
|
|
|
|
|
|
|
|
|
if (namedAction.Icon != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
button = new IconButton(namedAction.Icon, theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = namedAction.Title + " Button",
|
|
|
|
|
|
ToolTipText = namedAction.Title,
|
|
|
|
|
|
Margin = theme.ButtonSpacing,
|
2018-01-16 19:01:09 -08:00
|
|
|
|
BackgroundColor = theme.ToolbarButtonBackground,
|
|
|
|
|
|
HoverColor = theme.ToolbarButtonHover,
|
|
|
|
|
|
MouseDownColor = theme.ToolbarButtonDown,
|
2018-01-10 11:39:39 -08:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
button = new TextButton(namedAction.Title, theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = namedAction.Title + " Button",
|
|
|
|
|
|
Margin = theme.ButtonSpacing,
|
2018-01-16 19:01:09 -08:00
|
|
|
|
BackgroundColor = theme.ToolbarButtonBackground,
|
|
|
|
|
|
HoverColor = theme.ToolbarButtonHover,
|
|
|
|
|
|
MouseDownColor = theme.ToolbarButtonDown,
|
2018-01-10 11:39:39 -08:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-10 11:58:42 -08:00
|
|
|
|
operationButtons.Add((button, namedAction));
|
|
|
|
|
|
|
2018-01-10 11:39:39 -08:00
|
|
|
|
button.Click += (s, e) =>
|
|
|
|
|
|
{
|
2018-05-25 14:52:23 -07:00
|
|
|
|
UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
namedAction.Action.Invoke(sceneContext.Scene);
|
|
|
|
|
|
var partTab = button.Parents<PartTabPage>().FirstOrDefault();
|
|
|
|
|
|
var view3D = partTab.Descendants<View3DWidget>().FirstOrDefault();
|
|
|
|
|
|
view3D.InteractionLayer.Focus();
|
|
|
|
|
|
});
|
2018-01-10 11:39:39 -08:00
|
|
|
|
};
|
|
|
|
|
|
this.AddChild(button);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-17 08:05:12 -08:00
|
|
|
|
sceneContext.Scene.SelectionChanged += Scene_SelectionChanged;
|
|
|
|
|
|
|
|
|
|
|
|
// Run on load
|
|
|
|
|
|
Scene_SelectionChanged(null, null);
|
2018-01-10 11:58:42 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Scene_SelectionChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Set enabled level based on operation rules
|
|
|
|
|
|
foreach(var item in operationButtons)
|
|
|
|
|
|
{
|
2018-01-17 08:05:12 -08:00
|
|
|
|
item.button.Enabled = item.operation.IsEnabled?.Invoke(sceneContext.Scene) ?? false;
|
2018-01-10 11:58:42 -08:00
|
|
|
|
}
|
2017-07-06 18:15:53 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-10-07 11:36:52 -07:00
|
|
|
|
private PartPreviewContent partPreviewContent = null;
|
|
|
|
|
|
|
|
|
|
|
|
private GuiWidget CreateAddButton(BedConfig sceneContext, ThemeConfig theme)
|
2018-01-11 22:25:36 -08:00
|
|
|
|
{
|
2018-01-16 19:01:09 -08:00
|
|
|
|
var buttonView = new TextIconButton(
|
2018-08-31 13:51:24 -07:00
|
|
|
|
"",
|
2018-10-07 11:36:52 -07:00
|
|
|
|
AggContext.StaticData.LoadIcon("cube_add.png", 16, 16, theme.InvertIcons),
|
2018-01-16 19:01:09 -08:00
|
|
|
|
theme);
|
2018-01-11 22:25:36 -08:00
|
|
|
|
|
2018-01-16 19:01:09 -08:00
|
|
|
|
// Remove right Padding for drop style
|
|
|
|
|
|
buttonView.Padding = buttonView.Padding.Clone(right: 0);
|
2018-01-11 22:25:36 -08:00
|
|
|
|
|
2018-04-12 08:42:10 -07:00
|
|
|
|
var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme)
|
2018-01-21 21:07:14 -08:00
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Fit,
|
|
|
|
|
|
VAnchor = VAnchor.Fit,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2018-08-08 07:08:08 -07:00
|
|
|
|
// Construct and store menu actions
|
|
|
|
|
|
this.MenuActions = this.BedMenuActions(sceneContext, ApplicationController.Instance.MenuTheme);
|
|
|
|
|
|
|
2018-10-11 15:04:03 -07:00
|
|
|
|
PopupMenuButton libraryPopup = null;
|
|
|
|
|
|
|
|
|
|
|
|
libraryPopup = new PopupMenuButton(buttonView, theme)
|
2018-01-11 22:25:36 -08:00
|
|
|
|
{
|
2018-10-16 16:23:25 -07:00
|
|
|
|
MakeScrollable = false,
|
2018-10-10 13:33:16 -07:00
|
|
|
|
Name = "Add Content Menu",
|
2018-10-07 11:36:52 -07:00
|
|
|
|
ToolTipText = "Add Content".Localize(),
|
2018-10-11 15:04:03 -07:00
|
|
|
|
AlwaysKeepOpen = true,
|
2018-02-06 13:31:25 -08:00
|
|
|
|
DynamicPopupContent = () =>
|
|
|
|
|
|
{
|
2018-10-07 11:36:52 -07:00
|
|
|
|
if (partPreviewContent == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
partPreviewContent = this.Parents<PartPreviewContent>().FirstOrDefault();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-10-16 16:23:25 -07:00
|
|
|
|
var verticalResizeContainer = new VerticalResizeContainer(theme, GrabBarSide.Right)
|
2018-10-07 11:36:52 -07:00
|
|
|
|
{
|
|
|
|
|
|
BackgroundColor = theme.TabBarBackground,
|
2018-10-16 16:23:25 -07:00
|
|
|
|
Padding = new BorderDouble(theme.DefaultContainerPadding / 2, 0),
|
|
|
|
|
|
MinimumSize = new Vector2(120, 50),
|
|
|
|
|
|
Height = libraryPopup.TransformToScreenSpace(libraryPopup.Position).Y,
|
2018-10-07 11:36:52 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
2018-10-16 16:23:25 -07:00
|
|
|
|
double.TryParse(UserSettings.Instance.get(UserSettingsKey.PopupLibraryWidth), out double controlWidth);
|
|
|
|
|
|
if (controlWidth == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
controlWidth = 400;
|
|
|
|
|
|
}
|
|
|
|
|
|
verticalResizeContainer.Width = controlWidth;
|
|
|
|
|
|
|
|
|
|
|
|
verticalResizeContainer.BoundsChanged += (s2, e2) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UserSettings.Instance.set(UserSettingsKey.PopupLibraryWidth, verticalResizeContainer.Width.ToString());
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-10-11 17:25:01 -07:00
|
|
|
|
var systemWindow = this.Parents<SystemWindow>().FirstOrDefault();
|
2018-02-06 13:31:25 -08:00
|
|
|
|
|
2018-10-11 15:04:03 -07:00
|
|
|
|
var printLibraryWidget = new PrintLibraryWidget(partPreviewContent, theme)
|
2018-10-07 11:36:52 -07:00
|
|
|
|
{
|
2018-10-16 16:23:25 -07:00
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
VAnchor = VAnchor.Absolute,
|
2018-10-11 17:25:01 -07:00
|
|
|
|
Height = libraryPopup.TransformToScreenSpace(libraryPopup.Position).Y,
|
2018-10-16 16:23:25 -07:00
|
|
|
|
Margin = new BorderDouble(left: verticalResizeContainer.SplitterWidth)
|
2018-10-11 17:25:01 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
systemWindow.SizeChanged += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
printLibraryWidget.Height = libraryPopup.TransformToScreenSpace(libraryPopup.Position).Y;
|
2018-10-11 15:04:03 -07:00
|
|
|
|
};
|
2018-10-07 11:36:52 -07:00
|
|
|
|
|
2018-10-16 16:23:25 -07:00
|
|
|
|
verticalResizeContainer.AddChild(printLibraryWidget);
|
2018-10-11 15:04:03 -07:00
|
|
|
|
|
2018-10-16 16:23:25 -07:00
|
|
|
|
systemWindow.MouseDown += systemWindownMouseDown;
|
2018-10-11 15:04:03 -07:00
|
|
|
|
|
2018-10-16 16:23:25 -07:00
|
|
|
|
void systemWindownMouseDown(object s2, MouseEventArgs mouseEvent)
|
2018-10-11 15:04:03 -07:00
|
|
|
|
{
|
|
|
|
|
|
// MouseUp on our SystemWindow outside of our bounds should call close
|
2018-10-16 16:23:25 -07:00
|
|
|
|
var resizeContainerMousePosition = verticalResizeContainer.TransformFromScreenSpace(mouseEvent.Position);
|
|
|
|
|
|
bool mouseUpOnWidget = resizeContainerMousePosition.X >= 0 && resizeContainerMousePosition.X <= verticalResizeContainer.Width
|
|
|
|
|
|
&& resizeContainerMousePosition.Y >= 0 && resizeContainerMousePosition.Y <= verticalResizeContainer.Height;
|
2018-10-07 11:36:52 -07:00
|
|
|
|
|
2018-10-11 15:04:03 -07:00
|
|
|
|
if (!mouseUpOnWidget)
|
|
|
|
|
|
{
|
|
|
|
|
|
libraryPopup.CloseMenu();
|
2018-10-16 16:23:25 -07:00
|
|
|
|
systemWindow.MouseDown -= systemWindownMouseDown;
|
2018-10-11 15:04:03 -07:00
|
|
|
|
}
|
|
|
|
|
|
};
|
2018-10-07 11:36:52 -07:00
|
|
|
|
|
2018-10-16 16:23:25 -07:00
|
|
|
|
return verticalResizeContainer;
|
2018-02-06 13:31:25 -08:00
|
|
|
|
},
|
2018-01-16 19:01:09 -08:00
|
|
|
|
BackgroundColor = theme.ToolbarButtonBackground,
|
|
|
|
|
|
HoverColor = theme.ToolbarButtonHover,
|
|
|
|
|
|
MouseDownColor = theme.ToolbarButtonDown,
|
2018-01-11 22:25:36 -08:00
|
|
|
|
DrawArrow = true,
|
2018-01-12 23:19:44 -08:00
|
|
|
|
Margin = theme.ButtonSpacing,
|
2018-01-11 22:25:36 -08:00
|
|
|
|
};
|
2018-10-11 15:04:03 -07:00
|
|
|
|
|
2018-10-16 16:23:25 -07:00
|
|
|
|
libraryPopup.ConfigurePopup += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
e.HAnchor = HAnchor.Fit;
|
|
|
|
|
|
e.VAnchor = VAnchor.Fit;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2018-10-11 15:04:03 -07:00
|
|
|
|
return libraryPopup;
|
2018-01-11 22:25:36 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-10-07 11:36:52 -07:00
|
|
|
|
private GuiWidget CreateSaveButton(ThemeConfig theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
var iconButton = new IconButton(
|
|
|
|
|
|
AggContext.StaticData.LoadIcon("save_grey_16x.png", 16, 16, theme.InvertIcons),
|
|
|
|
|
|
theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
ToolTipText = "Save".Localize(),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
iconButton.Click += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
ApplicationController.Instance.Tasks.Execute("Saving".Localize(), sceneContext.SaveChanges).ConfigureAwait(false);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Remove right Padding for drop style
|
|
|
|
|
|
iconButton.Padding = iconButton.Padding.Clone(right: 0);
|
|
|
|
|
|
|
|
|
|
|
|
var button = new PopupMenuButton(iconButton, theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "Save SplitButton",
|
|
|
|
|
|
ToolTipText = "Save As".Localize(),
|
|
|
|
|
|
DynamicPopupContent = () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme);
|
|
|
|
|
|
|
|
|
|
|
|
var saveAs = popupMenu.CreateMenuItem("Save As".Localize());
|
|
|
|
|
|
saveAs.Click += (s, e) => UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
2018-10-20 13:06:29 -07:00
|
|
|
|
UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
DialogWindow.Show(
|
|
|
|
|
|
new SaveAsPage(
|
|
|
|
|
|
async (newName, destinationContainer) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
// Save to the destination provider
|
|
|
|
|
|
if (destinationContainer is ILibraryWritableContainer writableContainer)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Wrap stream with ReadOnlyStream library item and add to container
|
|
|
|
|
|
writableContainer.Add(new[]
|
|
|
|
|
|
{
|
|
|
|
|
|
new InMemoryLibraryItem(sceneContext.Scene)
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = newName
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
destinationContainer.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
}));
|
|
|
|
|
|
});
|
2018-10-07 11:36:52 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return popupMenu;
|
|
|
|
|
|
},
|
|
|
|
|
|
BackgroundColor = theme.ToolbarButtonBackground,
|
|
|
|
|
|
HoverColor = theme.ToolbarButtonHover,
|
|
|
|
|
|
MouseDownColor = theme.ToolbarButtonDown,
|
|
|
|
|
|
DrawArrow = true,
|
|
|
|
|
|
Margin = theme.ButtonSpacing,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
iconButton.Selectable = true;
|
|
|
|
|
|
|
|
|
|
|
|
return button;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static async void LoadAndAddPartsToPlate(GuiWidget originatingWidget, string[] filesToLoad, BedConfig sceneContext)
|
2018-01-08 23:34:40 -08:00
|
|
|
|
{
|
|
|
|
|
|
if (filesToLoad != null && filesToLoad.Length > 0)
|
|
|
|
|
|
{
|
2018-10-07 11:36:52 -07:00
|
|
|
|
|
|
|
|
|
|
await Task.Run(() => loadAndAddPartsToPlate(filesToLoad, sceneContext));
|
2018-01-08 23:34:40 -08:00
|
|
|
|
|
2018-10-07 11:36:52 -07:00
|
|
|
|
if (originatingWidget.HasBeenClosed)
|
2018-01-08 23:34:40 -08:00
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-10-07 11:36:52 -07:00
|
|
|
|
var scene = sceneContext.Scene;
|
|
|
|
|
|
|
2018-01-08 23:34:40 -08:00
|
|
|
|
bool addingOnlyOneItem = scene.Children.Count == scene.Children.Count + 1;
|
|
|
|
|
|
|
|
|
|
|
|
if (scene.HasChildren())
|
|
|
|
|
|
{
|
|
|
|
|
|
if (addingOnlyOneItem)
|
|
|
|
|
|
{
|
|
|
|
|
|
// if we are only adding one part to the plate set the selection to it
|
|
|
|
|
|
scene.SelectLastChild();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-20 08:09:35 -07:00
|
|
|
|
scene.Invalidate(new InvalidateArgs(null, InvalidateType.Content, null));
|
2018-01-08 23:34:40 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-10-07 11:36:52 -07:00
|
|
|
|
private static async Task loadAndAddPartsToPlate(string[] filesToLoadIncludingZips, BedConfig sceneContext)
|
2018-01-08 23:34:40 -08:00
|
|
|
|
{
|
|
|
|
|
|
if (filesToLoadIncludingZips?.Any() == true)
|
|
|
|
|
|
{
|
2018-10-07 11:36:52 -07:00
|
|
|
|
var scene = sceneContext.Scene;
|
|
|
|
|
|
|
2018-09-26 15:26:54 -07:00
|
|
|
|
// When a single gcode file is selected, swap the plate to the new GCode content
|
|
|
|
|
|
if (filesToLoadIncludingZips.Count() == 1
|
|
|
|
|
|
&& filesToLoadIncludingZips.FirstOrDefault() is string firstFilePath
|
|
|
|
|
|
&& Path.GetExtension(firstFilePath).ToUpper() == ".GCODE")
|
|
|
|
|
|
{
|
|
|
|
|
|
// Drop handler for special case of GCode or similar (change loaded scene to new context)
|
|
|
|
|
|
await sceneContext.LoadContent(
|
|
|
|
|
|
new EditContext()
|
|
|
|
|
|
{
|
|
|
|
|
|
SourceItem = new FileSystemFileItem(firstFilePath),
|
|
|
|
|
|
// No content store for GCode, otherwise PlatingHistory
|
|
|
|
|
|
ContentStore = sceneContext.EditContext.ContentStore
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-08 23:34:40 -08:00
|
|
|
|
List<string> filesToLoad = new List<string>();
|
|
|
|
|
|
foreach (string loadedFileName in filesToLoadIncludingZips)
|
|
|
|
|
|
{
|
|
|
|
|
|
string extension = Path.GetExtension(loadedFileName).ToUpper();
|
2018-03-27 17:54:38 -07:00
|
|
|
|
if ((extension != ""
|
|
|
|
|
|
&& extension != ".ZIP"
|
2018-09-26 15:26:54 -07:00
|
|
|
|
&& extension != ".GCODE"
|
|
|
|
|
|
&& ApplicationController.Instance.Library.IsContentFileType(loadedFileName))
|
|
|
|
|
|
)
|
2018-01-08 23:34:40 -08:00
|
|
|
|
{
|
|
|
|
|
|
filesToLoad.Add(loadedFileName);
|
2018-10-07 11:36:52 -07:00
|
|
|
|
}
|
2018-01-08 23:34:40 -08:00
|
|
|
|
else if (extension == ".ZIP")
|
|
|
|
|
|
{
|
|
|
|
|
|
List<PrintItem> partFiles = ProjectFileHandler.ImportFromProjectArchive(loadedFileName);
|
|
|
|
|
|
if (partFiles != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (PrintItem part in partFiles)
|
|
|
|
|
|
{
|
2018-09-26 15:26:54 -07:00
|
|
|
|
string itemExtension = Path.GetExtension(part.FileLocation).ToUpper();
|
|
|
|
|
|
if (itemExtension != ".GCODE")
|
|
|
|
|
|
{
|
|
|
|
|
|
filesToLoad.Add(part.FileLocation);
|
|
|
|
|
|
}
|
2018-01-08 23:34:40 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var itemCache = new Dictionary<string, IObject3D>();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (string filePath in filesToLoad)
|
|
|
|
|
|
{
|
|
|
|
|
|
var libraryItem = new FileSystemFileItem(filePath);
|
|
|
|
|
|
|
|
|
|
|
|
IObject3D object3D = null;
|
|
|
|
|
|
|
2018-02-20 18:27:52 -08:00
|
|
|
|
await ApplicationController.Instance.Tasks.Execute("Loading".Localize() + " " + Path.GetFileName(filePath), async (progressReporter, cancellationToken) =>
|
2018-01-08 23:34:40 -08:00
|
|
|
|
{
|
2018-02-20 18:27:52 -08:00
|
|
|
|
var progressStatus = new ProgressStatus();
|
2018-01-08 23:34:40 -08:00
|
|
|
|
|
|
|
|
|
|
progressReporter.Report(progressStatus);
|
|
|
|
|
|
|
|
|
|
|
|
object3D = await libraryItem.CreateContent((double progress0To1, string processingState) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
progressStatus.Progress0To1 = progress0To1;
|
|
|
|
|
|
progressStatus.Status = processingState;
|
|
|
|
|
|
progressReporter.Report(progressStatus);
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (object3D != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
scene.Children.Modify(list => list.Add(object3D));
|
|
|
|
|
|
|
|
|
|
|
|
PlatingHelper.MoveToOpenPositionRelativeGroup(object3D, scene.Children);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-12 11:23:08 -07:00
|
|
|
|
private NamedAction[] BedMenuActions(BedConfig sceneContext, ThemeConfig theme)
|
2018-01-08 23:34:40 -08:00
|
|
|
|
{
|
|
|
|
|
|
return new[]
|
|
|
|
|
|
{
|
2018-02-06 13:31:25 -08:00
|
|
|
|
new NamedAction()
|
|
|
|
|
|
{
|
2018-08-08 07:05:06 -07:00
|
|
|
|
ID = "Cut",
|
2018-02-06 13:31:25 -08:00
|
|
|
|
Title = "Cut".Localize(),
|
|
|
|
|
|
Shortcut = "Ctrl+X",
|
2018-02-06 15:19:57 -08:00
|
|
|
|
Action = () =>
|
2018-02-06 13:31:25 -08:00
|
|
|
|
{
|
|
|
|
|
|
sceneContext.Scene.Cut();
|
|
|
|
|
|
},
|
2018-10-18 17:25:56 -07:00
|
|
|
|
IsEnabled = () => sceneContext.Scene.SelectedItem != null
|
2018-02-06 13:31:25 -08:00
|
|
|
|
},
|
|
|
|
|
|
new NamedAction()
|
|
|
|
|
|
{
|
2018-08-08 07:05:06 -07:00
|
|
|
|
ID = "Copy",
|
2018-02-06 13:31:25 -08:00
|
|
|
|
Title = "Copy".Localize(),
|
|
|
|
|
|
Shortcut = "Ctrl+C",
|
2018-02-06 15:19:57 -08:00
|
|
|
|
Action = () =>
|
2018-02-06 13:31:25 -08:00
|
|
|
|
{
|
|
|
|
|
|
sceneContext.Scene.Copy();
|
|
|
|
|
|
},
|
2018-10-18 17:25:56 -07:00
|
|
|
|
IsEnabled = () => sceneContext.Scene.SelectedItem != null
|
2018-02-06 13:31:25 -08:00
|
|
|
|
},
|
|
|
|
|
|
new NamedAction()
|
|
|
|
|
|
{
|
2018-08-08 07:05:06 -07:00
|
|
|
|
ID = "Paste",
|
2018-02-06 13:31:25 -08:00
|
|
|
|
Title = "Paste".Localize(),
|
|
|
|
|
|
Shortcut = "Ctrl+V",
|
2018-02-06 15:19:57 -08:00
|
|
|
|
Action = () =>
|
2018-02-06 13:31:25 -08:00
|
|
|
|
{
|
|
|
|
|
|
sceneContext.Scene.Paste();
|
|
|
|
|
|
},
|
2018-10-18 17:25:56 -07:00
|
|
|
|
IsEnabled = () => Clipboard.Instance.ContainsImage || Clipboard.Instance.GetText() == "!--IObjectSelection--!"
|
2018-02-06 13:31:25 -08:00
|
|
|
|
},
|
2018-08-08 07:03:37 -07:00
|
|
|
|
new ActionSeparator(),
|
2018-01-08 23:34:40 -08:00
|
|
|
|
new NamedAction()
|
|
|
|
|
|
{
|
2018-08-08 07:05:06 -07:00
|
|
|
|
ID = "Export",
|
2018-01-08 23:34:40 -08:00
|
|
|
|
Title = "Export".Localize(),
|
2018-10-19 18:17:27 -07:00
|
|
|
|
Icon = AggContext.StaticData.LoadIcon("cube_export.png", 16, 16),
|
2018-01-08 23:34:40 -08:00
|
|
|
|
Action = () =>
|
|
|
|
|
|
{
|
2018-03-17 00:07:34 -07:00
|
|
|
|
UiThread.RunOnIdle(async () =>
|
2018-01-08 23:34:40 -08:00
|
|
|
|
{
|
|
|
|
|
|
DialogWindow.Show(
|
|
|
|
|
|
new ExportPrintItemPage(new[]
|
|
|
|
|
|
{
|
2018-04-09 08:15:52 -07:00
|
|
|
|
new InMemoryLibraryItem(sceneContext.Scene)
|
2018-09-07 10:25:29 -07:00
|
|
|
|
}, false));
|
2018-01-08 23:34:40 -08:00
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
IsEnabled = () => sceneContext.EditableScene
|
2018-07-19 15:34:26 -07:00
|
|
|
|
|| (sceneContext.EditContext.SourceItem is ILibraryAsset libraryAsset
|
|
|
|
|
|
&& string.Equals(Path.GetExtension(libraryAsset.FileName) ,".gcode" ,StringComparison.OrdinalIgnoreCase))
|
2018-01-08 23:34:40 -08:00
|
|
|
|
},
|
|
|
|
|
|
new NamedAction()
|
|
|
|
|
|
{
|
2018-08-08 07:05:06 -07:00
|
|
|
|
ID = "ArrangeAll",
|
2018-01-08 23:34:40 -08:00
|
|
|
|
Title = "Arrange All Parts".Localize(),
|
|
|
|
|
|
Action = () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
sceneContext.Scene.AutoArrangeChildren(view3DWidget);
|
|
|
|
|
|
},
|
|
|
|
|
|
IsEnabled = () => sceneContext.EditableScene
|
|
|
|
|
|
},
|
2018-08-08 07:03:37 -07:00
|
|
|
|
new ActionSeparator(),
|
2018-01-08 23:34:40 -08:00
|
|
|
|
new NamedAction()
|
|
|
|
|
|
{
|
2018-08-08 07:05:06 -07:00
|
|
|
|
ID = "ClearBed",
|
2018-01-08 23:34:40 -08:00
|
|
|
|
Title = "Clear Bed".Localize(),
|
|
|
|
|
|
Action = () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
2018-06-22 00:04:03 -07:00
|
|
|
|
view3DWidget.ClearPlate();
|
2018-01-08 23:34:40 -08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2018-04-23 18:48:17 -07:00
|
|
|
|
},
|
2018-07-13 09:02:22 -07:00
|
|
|
|
#if DEBUG && false
|
2018-06-22 16:39:15 -07:00
|
|
|
|
new NamedAction()
|
|
|
|
|
|
{
|
2018-07-13 09:02:22 -07:00
|
|
|
|
Title = "GC.Collect"/* Don't localize debug tool */,
|
2018-06-22 16:39:15 -07:00
|
|
|
|
Action = () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
GC.Collect();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
#endif
|
2018-01-08 23:34:40 -08:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-08-23 16:44:11 -07:00
|
|
|
|
public override void OnClosed(EventArgs e)
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2018-04-12 21:28:55 -07:00
|
|
|
|
sceneContext.Scene.SelectionChanged -= Scene_SelectionChanged;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
base.OnClosed(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|