2018-11-16 16:12:48 -08:00
|
|
|
|
/*
|
2022-01-24 14:49:29 -08:00
|
|
|
|
Copyright (c) 2022, Lars Brubaker, John Lewin
|
2018-11-16 16:12:48 -08: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.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2018-11-27 12:22:38 -08:00
|
|
|
|
using System.IO;
|
2018-11-16 16:12:48 -08:00
|
|
|
|
using System.Linq;
|
2022-01-25 16:27:22 -08:00
|
|
|
|
using System.Threading;
|
2018-11-16 16:12:48 -08:00
|
|
|
|
using System.Threading.Tasks;
|
2019-06-21 15:35:35 -07:00
|
|
|
|
using MatterControlLib;
|
2018-11-16 16:12:48 -08:00
|
|
|
|
using MatterHackers.Agg;
|
2021-03-10 09:53:41 -08:00
|
|
|
|
using MatterHackers.Agg.Image;
|
2018-11-16 16:12:48 -08:00
|
|
|
|
using MatterHackers.Agg.Platform;
|
|
|
|
|
|
using MatterHackers.Agg.UI;
|
2018-11-27 12:22:38 -08:00
|
|
|
|
using MatterHackers.DataConverters3D;
|
2021-05-21 15:23:25 -07:00
|
|
|
|
using MatterHackers.ImageProcessing;
|
2018-11-16 16:12:48 -08:00
|
|
|
|
using MatterHackers.Localizations;
|
2020-05-30 16:50:36 -07:00
|
|
|
|
using MatterHackers.MatterControl.CustomWidgets;
|
2018-11-27 12:22:38 -08:00
|
|
|
|
using MatterHackers.MatterControl.Library;
|
2018-11-16 16:12:48 -08:00
|
|
|
|
using MatterHackers.MatterControl.PartPreviewWindow.PlusTab;
|
|
|
|
|
|
using MatterHackers.MatterControl.PrintLibrary;
|
|
|
|
|
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
|
|
|
|
|
using MatterHackers.VectorMath;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl.PartPreviewWindow
|
|
|
|
|
|
{
|
|
|
|
|
|
public class MainViewWidget : FlowLayoutWidget
|
|
|
|
|
|
{
|
|
|
|
|
|
private EventHandler unregisterEvents;
|
|
|
|
|
|
private ChromeTabs tabControl;
|
|
|
|
|
|
|
|
|
|
|
|
private int partCount = 0;
|
|
|
|
|
|
private ThemeConfig theme;
|
|
|
|
|
|
private Toolbar statusBar;
|
2021-06-02 17:58:43 -07:00
|
|
|
|
private GuiWidget tasksContainer;
|
2021-06-04 18:09:30 -07:00
|
|
|
|
private GuiWidget statusMessage;
|
2018-11-16 16:12:48 -08:00
|
|
|
|
private GuiWidget stretchStatusPanel;
|
|
|
|
|
|
private LinkLabel updateAvailableButton;
|
|
|
|
|
|
|
|
|
|
|
|
public MainViewWidget(ThemeConfig theme)
|
|
|
|
|
|
: base(FlowDirection.TopToBottom)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.AnchorAll();
|
|
|
|
|
|
this.theme = theme;
|
|
|
|
|
|
this.Name = "PartPreviewContent";
|
|
|
|
|
|
this.BackgroundColor = theme.BackgroundColor;
|
|
|
|
|
|
|
|
|
|
|
|
// Push TouchScreenMode into GuiWidget
|
2022-01-24 11:12:46 -08:00
|
|
|
|
GuiWidget.TouchScreenMode = ApplicationSettings.Instance.IsTouchScreen;
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
2019-12-07 10:25:30 -08:00
|
|
|
|
AddStandardUi(theme);
|
|
|
|
|
|
ApplicationController.Instance.WorkspacesChanged += Workspaces_Changed;
|
|
|
|
|
|
ApplicationController.Instance.Tasks.TasksChanged += Tasks_TasksChanged;
|
2021-06-04 18:09:30 -07:00
|
|
|
|
ApplicationController.Instance.UiHintChanged += Tasks_TasksChanged;
|
2019-12-07 10:25:30 -08:00
|
|
|
|
tabControl.ActiveTabChanged += TabControl_ActiveTabChanged;
|
2019-12-06 10:19:21 -08:00
|
|
|
|
|
|
|
|
|
|
// Register listeners
|
|
|
|
|
|
PrinterSettings.AnyPrinterSettingChanged += Printer_SettingChanged;
|
|
|
|
|
|
|
|
|
|
|
|
ApplicationController.Instance.ShellFileOpened += this.Instance_OpenNewFile;
|
|
|
|
|
|
|
|
|
|
|
|
ApplicationController.Instance.MainView = this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-21 17:37:22 -07:00
|
|
|
|
private async void AddStandardUi(ThemeConfig theme)
|
2019-12-06 10:19:21 -08:00
|
|
|
|
{
|
2018-11-16 16:12:48 -08:00
|
|
|
|
var extensionArea = new LeftClipFlowLayoutWidget()
|
|
|
|
|
|
{
|
|
|
|
|
|
BackgroundColor = theme.TabBarBackground,
|
|
|
|
|
|
VAnchor = VAnchor.Stretch,
|
|
|
|
|
|
Padding = new BorderDouble(left: 8)
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2019-06-18 15:44:36 -07:00
|
|
|
|
SearchPanel searchPanel = null;
|
2019-06-17 18:12:34 -07:00
|
|
|
|
|
2019-06-24 17:01:30 -07:00
|
|
|
|
bool searchPanelOpenOnMouseDown = false;
|
|
|
|
|
|
|
2019-06-18 15:44:36 -07:00
|
|
|
|
var searchButton = theme.CreateSearchButton();
|
2019-06-17 18:12:34 -07:00
|
|
|
|
searchButton.Name = "App Search Button";
|
2019-06-24 17:01:30 -07:00
|
|
|
|
searchButton.MouseDown += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
searchPanelOpenOnMouseDown = searchPanel != null;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2019-06-18 15:44:36 -07:00
|
|
|
|
searchButton.Click += SearchButton_Click;
|
|
|
|
|
|
extensionArea.AddChild(searchButton);
|
|
|
|
|
|
|
2019-06-21 15:35:35 -07:00
|
|
|
|
async void SearchButton_Click(object sender, EventArgs e)
|
2019-06-17 18:12:34 -07:00
|
|
|
|
{
|
2019-06-24 17:01:30 -07:00
|
|
|
|
if (searchPanel == null && !searchPanelOpenOnMouseDown)
|
2019-06-17 18:12:34 -07:00
|
|
|
|
{
|
2019-06-21 15:35:35 -07:00
|
|
|
|
void ShowSearchPanel()
|
|
|
|
|
|
{
|
|
|
|
|
|
searchPanel = new SearchPanel(this.TabControl, searchButton, theme);
|
|
|
|
|
|
searchPanel.Closed += SearchPanel_Closed;
|
|
|
|
|
|
|
|
|
|
|
|
var systemWindow = this.Parents<SystemWindow>().FirstOrDefault();
|
|
|
|
|
|
systemWindow.ShowRightSplitPopup(
|
|
|
|
|
|
new MatePoint(searchButton),
|
|
|
|
|
|
new MatePoint(searchPanel),
|
|
|
|
|
|
borderWidth: 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (HelpIndex.IndexExists)
|
|
|
|
|
|
{
|
|
|
|
|
|
ShowSearchPanel();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
searchButton.Enabled = false;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
// Show popover
|
|
|
|
|
|
var popover = new Popover(ArrowDirection.Up, 7, 5, 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
TagColor = theme.AccentMimimalOverlay
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
popover.AddChild(new TextWidget("Preparing help".Localize() + "...", pointSize: theme.DefaultFontSize - 1, textColor: theme.TextColor));
|
|
|
|
|
|
|
|
|
|
|
|
popover.ArrowOffset = (int)(popover.Width - (searchButton.Width / 2));
|
|
|
|
|
|
|
|
|
|
|
|
this.Parents<SystemWindow>().FirstOrDefault().ShowPopover(
|
|
|
|
|
|
new MatePoint(searchButton)
|
|
|
|
|
|
{
|
|
|
|
|
|
Mate = new MateOptions(MateEdge.Right, MateEdge.Bottom),
|
|
|
|
|
|
AltMate = new MateOptions(MateEdge.Right, MateEdge.Bottom),
|
|
|
|
|
|
Offset = new RectangleDouble(12, 0, 12, 0)
|
|
|
|
|
|
},
|
|
|
|
|
|
new MatePoint(popover)
|
|
|
|
|
|
{
|
|
|
|
|
|
Mate = new MateOptions(MateEdge.Right, MateEdge.Top),
|
|
|
|
|
|
AltMate = new MateOptions(MateEdge.Left, MateEdge.Bottom)
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2019-07-06 08:00:03 -07:00
|
|
|
|
await Task.Run(async () =>
|
2019-06-21 15:35:35 -07:00
|
|
|
|
{
|
|
|
|
|
|
// Start index generation
|
|
|
|
|
|
await HelpIndex.RebuildIndex();
|
|
|
|
|
|
|
2019-07-06 08:00:03 -07:00
|
|
|
|
UiThread.RunOnIdle(() =>
|
2019-06-21 15:35:35 -07:00
|
|
|
|
{
|
|
|
|
|
|
// Close popover
|
|
|
|
|
|
popover.Close();
|
|
|
|
|
|
|
|
|
|
|
|
// Continue to original task
|
|
|
|
|
|
ShowSearchPanel();
|
2019-07-06 08:00:03 -07:00
|
|
|
|
});
|
|
|
|
|
|
});
|
2019-06-21 15:35:35 -07:00
|
|
|
|
}
|
|
|
|
|
|
catch
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
searchButton.Enabled = true;
|
|
|
|
|
|
}
|
2019-06-17 18:12:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2019-07-06 13:24:57 -07:00
|
|
|
|
searchPanel?.CloseOnIdle();
|
2019-06-24 17:01:30 -07:00
|
|
|
|
searchPanelOpenOnMouseDown = false;
|
2019-06-17 18:12:34 -07:00
|
|
|
|
}
|
2019-06-18 15:44:36 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SearchPanel_Closed(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Unregister
|
|
|
|
|
|
searchPanel.Closed -= SearchPanel_Closed;
|
|
|
|
|
|
|
|
|
|
|
|
// Release
|
|
|
|
|
|
searchPanel = null;
|
|
|
|
|
|
}
|
2019-06-17 18:12:34 -07:00
|
|
|
|
|
2018-11-16 16:12:48 -08:00
|
|
|
|
tabControl = new ChromeTabs(extensionArea, theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
VAnchor = VAnchor.Stretch,
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
BackgroundColor = theme.BackgroundColor,
|
|
|
|
|
|
BorderColor = theme.MinimalShade,
|
|
|
|
|
|
Border = new BorderDouble(left: 1),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2018-11-20 16:39:20 -08:00
|
|
|
|
tabControl.PlusClicked += (s, e) => UiThread.RunOnIdle(() =>
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
2022-02-03 15:02:19 -08:00
|
|
|
|
CreateNewDesignTab(true);
|
2018-11-20 16:39:20 -08:00
|
|
|
|
});
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
|
|
|
|
|
// Force the ActionArea to be as high as ButtonHeight
|
|
|
|
|
|
tabControl.TabBar.ActionArea.MinimumSize = new Vector2(0, theme.ButtonHeight);
|
|
|
|
|
|
tabControl.TabBar.BackgroundColor = theme.TabBarBackground;
|
|
|
|
|
|
tabControl.TabBar.BorderColor = theme.BackgroundColor;
|
|
|
|
|
|
|
|
|
|
|
|
// Force common padding into top region
|
|
|
|
|
|
tabControl.TabBar.Padding = theme.TabbarPadding.Clone(top: theme.TabbarPadding.Top * 2, bottom: 0);
|
|
|
|
|
|
|
2019-01-31 09:42:54 -08:00
|
|
|
|
if (Application.EnableNetworkTraffic)
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
2019-01-31 09:42:54 -08:00
|
|
|
|
// add in the update available button
|
|
|
|
|
|
updateAvailableButton = new LinkLabel("Update Available".Localize(), theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
Visible = false,
|
|
|
|
|
|
Name = "Update Available Link",
|
|
|
|
|
|
ToolTipText = "There is a new update available for download".Localize(),
|
|
|
|
|
|
VAnchor = VAnchor.Center,
|
2020-08-11 18:05:35 -07:00
|
|
|
|
Margin = new BorderDouble(10, 0),
|
|
|
|
|
|
TextColor = theme.PrimaryAccentColor
|
2019-01-31 09:42:54 -08:00
|
|
|
|
};
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
2019-01-31 09:42:54 -08:00
|
|
|
|
// Register listeners
|
|
|
|
|
|
UserSettings.Instance.SettingChanged += SetLinkButtonsVisibility;
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
2019-01-31 09:42:54 -08:00
|
|
|
|
SetLinkButtonsVisibility(this, null);
|
2018-11-20 12:33:06 -08:00
|
|
|
|
|
2019-06-29 08:33:24 -07:00
|
|
|
|
updateAvailableButton.Click += (s, e) =>
|
2019-01-31 09:42:54 -08:00
|
|
|
|
{
|
|
|
|
|
|
UpdateControlData.Instance.CheckForUpdate();
|
|
|
|
|
|
DialogWindow.Show<CheckForUpdatesPage>();
|
2019-06-29 08:33:24 -07:00
|
|
|
|
};
|
2019-01-31 09:42:54 -08:00
|
|
|
|
|
|
|
|
|
|
tabControl.TabBar.ActionArea.AddChild(updateAvailableButton);
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
2019-01-31 09:42:54 -08:00
|
|
|
|
UpdateControlData.Instance.UpdateStatusChanged.RegisterEvent((s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
SetLinkButtonsVisibility(s, new StringEventArgs("Unknown"));
|
|
|
|
|
|
}, ref unregisterEvents);
|
|
|
|
|
|
}
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
|
|
|
|
|
this.AddChild(tabControl);
|
|
|
|
|
|
|
|
|
|
|
|
ApplicationController.Instance.NotifyPrintersTabRightElement(extensionArea);
|
|
|
|
|
|
|
2020-07-09 18:10:06 -07:00
|
|
|
|
ChromeTab tab = null;
|
|
|
|
|
|
|
2020-05-13 09:07:22 -07:00
|
|
|
|
// Upgrade tab
|
|
|
|
|
|
if (!ApplicationController.Instance.IsMatterControlPro())
|
|
|
|
|
|
{
|
|
|
|
|
|
tabControl.AddTab(
|
|
|
|
|
|
tab = new ChromeTab("Upgrade", "Upgrade".Localize(), tabControl, new UpgradeToProTabPage(theme), theme, hasClose: false)
|
|
|
|
|
|
{
|
|
|
|
|
|
MinimumSize = new Vector2(0, theme.TabButtonHeight),
|
|
|
|
|
|
Name = "Upgrade",
|
|
|
|
|
|
Padding = new BorderDouble(15, 0),
|
|
|
|
|
|
});
|
2020-08-17 09:21:14 -07:00
|
|
|
|
|
|
|
|
|
|
tab.AfterDraw += (s, e) =>
|
|
|
|
|
|
{
|
2021-11-16 10:40:45 -08:00
|
|
|
|
var textWidget = tab.Descendants<TextWidget>().FirstOrDefault();
|
|
|
|
|
|
e.Graphics2D.Circle(Math.Max(textWidget.Width, tab.LocalBounds.Right - 25 * DeviceScale),
|
2020-08-17 09:21:14 -07:00
|
|
|
|
tab.LocalBounds.Bottom + tab.Height / 2 - 1 * DeviceScale,
|
|
|
|
|
|
5 * DeviceScale,
|
|
|
|
|
|
theme.PrimaryAccentColor);
|
|
|
|
|
|
};
|
2020-05-13 09:07:22 -07:00
|
|
|
|
}
|
2021-11-16 10:40:45 -08:00
|
|
|
|
|
|
|
|
|
|
// Store tab
|
|
|
|
|
|
tabControl.AddTab(
|
2021-11-26 10:16:59 -08:00
|
|
|
|
tab = new ChromeTab("Store", "Resources".Localize(), tabControl, new StoreTabPage(theme), theme, hasClose: false)
|
2021-11-16 10:40:45 -08:00
|
|
|
|
{
|
|
|
|
|
|
MinimumSize = new Vector2(0, theme.TabButtonHeight),
|
|
|
|
|
|
Name = "Store Tab",
|
|
|
|
|
|
Padding = new BorderDouble(15, 0),
|
|
|
|
|
|
});
|
2020-08-17 09:21:14 -07:00
|
|
|
|
|
2020-07-09 18:10:06 -07:00
|
|
|
|
EnableReduceWidth(tab, theme);
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
|
|
|
|
|
// Library tab
|
|
|
|
|
|
var libraryWidget = new LibraryWidget(this, theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
BackgroundColor = theme.BackgroundColor
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
tabControl.AddTab(
|
2020-07-09 18:10:06 -07:00
|
|
|
|
tab = new ChromeTab("Library", "Library".Localize(), tabControl, libraryWidget, theme, hasClose: false)
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
|
|
|
|
|
MinimumSize = new Vector2(0, theme.TabButtonHeight),
|
|
|
|
|
|
Name = "Library Tab",
|
|
|
|
|
|
Padding = new BorderDouble(15, 0),
|
|
|
|
|
|
});
|
2020-07-09 18:10:06 -07:00
|
|
|
|
EnableReduceWidth(tab, theme);
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
|
|
|
|
|
// Hardware tab
|
|
|
|
|
|
tabControl.AddTab(
|
2020-07-09 18:10:06 -07:00
|
|
|
|
tab = new ChromeTab(
|
2018-11-16 16:12:48 -08:00
|
|
|
|
"Hardware",
|
2022-03-11 18:04:32 -08:00
|
|
|
|
"Printers".Localize(),
|
2018-11-16 16:12:48 -08:00
|
|
|
|
tabControl,
|
2022-03-11 18:04:32 -08:00
|
|
|
|
new PrintersTabPage(theme)
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
|
|
|
|
|
BackgroundColor = theme.BackgroundColor
|
|
|
|
|
|
},
|
|
|
|
|
|
theme,
|
|
|
|
|
|
hasClose: false)
|
|
|
|
|
|
{
|
|
|
|
|
|
MinimumSize = new Vector2(0, theme.TabButtonHeight),
|
|
|
|
|
|
Name = "Hardware Tab",
|
|
|
|
|
|
Padding = new BorderDouble(15, 0),
|
|
|
|
|
|
});
|
2020-07-09 18:10:06 -07:00
|
|
|
|
EnableReduceWidth(tab, theme);
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
2019-04-30 22:08:51 -07:00
|
|
|
|
SetInitialTab();
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
|
|
|
|
|
var brandMenu = new BrandMenuButton(theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Fit,
|
|
|
|
|
|
VAnchor = VAnchor.Fit,
|
|
|
|
|
|
BackgroundColor = theme.TabBarBackground,
|
|
|
|
|
|
Padding = theme.TabbarPadding.Clone(right: theme.DefaultContainerPadding)
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
tabControl.TabBar.ActionArea.AddChild(brandMenu, 0);
|
|
|
|
|
|
|
2020-07-19 18:04:02 -07:00
|
|
|
|
tabControl.TabBar.ActionArea.VAnchor = VAnchor.Absolute;
|
|
|
|
|
|
tabControl.TabBar.ActionArea.Height = brandMenu.Height;
|
2021-02-24 07:54:44 -08:00
|
|
|
|
tabControl.FirstMovableTab = tabControl.AllTabs.Count();
|
2020-07-19 18:04:02 -07:00
|
|
|
|
|
2018-12-19 15:05:25 -08:00
|
|
|
|
// Restore active workspace tabs
|
|
|
|
|
|
foreach (var workspace in ApplicationController.Instance.Workspaces)
|
|
|
|
|
|
{
|
2019-04-30 22:08:51 -07:00
|
|
|
|
ChromeTab newTab;
|
|
|
|
|
|
|
2018-12-19 15:05:25 -08:00
|
|
|
|
// Create and switch to new printer tab
|
|
|
|
|
|
if (workspace.Printer?.Settings.PrinterSelected == true)
|
|
|
|
|
|
{
|
2019-04-30 22:08:51 -07:00
|
|
|
|
newTab = this.CreatePrinterTab(workspace, theme);
|
2018-12-19 15:05:25 -08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2022-02-02 17:31:44 -08:00
|
|
|
|
newTab = this.CreateDesignTab(workspace, false);
|
2019-04-30 22:08:51 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (newTab.Key == ApplicationController.Instance.MainTabKey)
|
|
|
|
|
|
{
|
|
|
|
|
|
tabControl.ActiveTab = newTab;
|
2018-12-19 15:05:25 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-30 11:24:21 -07:00
|
|
|
|
statusBar = new Toolbar(theme.TabbarPadding)
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
VAnchor = VAnchor.Absolute,
|
|
|
|
|
|
Padding = 1,
|
2020-07-19 18:04:02 -07:00
|
|
|
|
Height = 22 * GuiWidget.DeviceScale,
|
2018-11-16 16:12:48 -08:00
|
|
|
|
BackgroundColor = theme.BackgroundColor,
|
|
|
|
|
|
Border = new BorderDouble(top: 1),
|
|
|
|
|
|
BorderColor = theme.BorderColor20,
|
|
|
|
|
|
};
|
|
|
|
|
|
this.AddChild(statusBar);
|
|
|
|
|
|
|
|
|
|
|
|
statusBar.ActionArea.VAnchor = VAnchor.Stretch;
|
|
|
|
|
|
|
2021-06-02 17:58:43 -07:00
|
|
|
|
tasksContainer = statusBar.AddChild(new FlowLayoutWidget(FlowDirection.LeftToRight)
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Fit,
|
|
|
|
|
|
VAnchor = VAnchor.Stretch,
|
|
|
|
|
|
BackgroundColor = theme.MinimalShade,
|
|
|
|
|
|
Name = "runningTasksPanel"
|
2021-06-02 17:58:43 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
2021-06-04 18:09:30 -07:00
|
|
|
|
statusMessage = tasksContainer.AddChild(new TextWidget("")
|
2021-06-02 17:58:43 -07:00
|
|
|
|
{
|
2021-06-07 18:01:17 -07:00
|
|
|
|
Margin = new BorderDouble(5, 0, 0, 3),
|
2021-06-04 18:09:30 -07:00
|
|
|
|
TextColor = theme.TextColor,
|
|
|
|
|
|
VAnchor = VAnchor.Center,
|
|
|
|
|
|
PointSize = theme.FontSize9,
|
|
|
|
|
|
Visible = false,
|
|
|
|
|
|
AutoExpandBoundsToText = true,
|
2021-06-02 17:58:43 -07:00
|
|
|
|
});
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
|
|
|
|
|
stretchStatusPanel = new GuiWidget()
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
VAnchor = VAnchor.Stretch,
|
|
|
|
|
|
Padding = new BorderDouble(right: 3),
|
|
|
|
|
|
Margin = new BorderDouble(right: 2, top: 1, bottom: 1),
|
|
|
|
|
|
Border = new BorderDouble(1),
|
|
|
|
|
|
BackgroundColor = theme.MinimalShade.WithAlpha(10),
|
|
|
|
|
|
BorderColor = theme.SlightShade,
|
2020-07-19 18:04:02 -07:00
|
|
|
|
Width = 200 * GuiWidget.DeviceScale
|
2018-11-16 16:12:48 -08:00
|
|
|
|
};
|
2022-02-02 17:31:44 -08:00
|
|
|
|
|
2018-11-16 16:12:48 -08:00
|
|
|
|
statusBar.AddChild(stretchStatusPanel);
|
|
|
|
|
|
|
|
|
|
|
|
var panelBackgroundColor = theme.MinimalShade.WithAlpha(10);
|
|
|
|
|
|
|
2020-07-19 18:04:02 -07:00
|
|
|
|
statusBar.AddChild(this.CreateThemeStatusPanel(theme, panelBackgroundColor));
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
2020-07-19 18:04:02 -07:00
|
|
|
|
statusBar.AddChild(this.CreateNetworkStatusPanel(theme));
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
2018-11-20 16:39:20 -08:00
|
|
|
|
this.RenderRunningTasks(theme, ApplicationController.Instance.Tasks);
|
2018-11-16 16:12:48 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-04-30 22:08:51 -07:00
|
|
|
|
private void SetInitialTab()
|
|
|
|
|
|
{
|
|
|
|
|
|
// Initial tab selection - workspace load will reset if applicable
|
|
|
|
|
|
string tabKey = ApplicationController.Instance.MainTabKey;
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(tabKey)
|
|
|
|
|
|
|| !tabControl.AllTabs.Any(t => t.Key == tabKey))
|
|
|
|
|
|
{
|
|
|
|
|
|
tabKey = "Hardware";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tabControl.SelectedTabKey = tabKey;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-08 17:05:34 -08:00
|
|
|
|
// you can use this code to test the ShellOpenFile code
|
2022-02-10 12:06:48 -08:00
|
|
|
|
#if false
|
2022-02-08 17:05:34 -08:00
|
|
|
|
public override void OnKeyPress(KeyPressEventArgs keyPressEvent)
|
|
|
|
|
|
{
|
2022-02-08 22:16:18 -08:00
|
|
|
|
var files = new string[]
|
|
|
|
|
|
{
|
|
|
|
|
|
@"C:\Users\LarsBrubaker\Downloads\LIGHTSABER-HILT.stl",
|
|
|
|
|
|
@"C:\Users\larsb\Desktop\test 33.mcx",
|
|
|
|
|
|
@"C:\Users\LarsBrubaker\Downloads\CokeCan.mcx",
|
|
|
|
|
|
@"C:\Users\larsb\Downloads\Print Stuff\heart.png",
|
|
|
|
|
|
@"C:\Users\larsb\Downloads\Print Stuff\vat_comb_ver2.stl",
|
|
|
|
|
|
@"C:\Users\larsb\Desktop\PICT0137.JPG"
|
|
|
|
|
|
};
|
2022-02-08 17:05:34 -08:00
|
|
|
|
switch(keyPressEvent.KeyChar)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 's':
|
2022-02-08 22:16:18 -08:00
|
|
|
|
ApplicationController.Instance.ShellOpenFile(files.Where(i => File.Exists(i) && Path.GetExtension(i).ToLower() == ".stl").First());
|
2022-02-08 17:05:34 -08:00
|
|
|
|
break;
|
2018-11-27 12:22:38 -08:00
|
|
|
|
|
2022-02-08 17:05:34 -08:00
|
|
|
|
case 'm':
|
2022-02-08 22:16:18 -08:00
|
|
|
|
ApplicationController.Instance.ShellOpenFile(files.Where(i => File.Exists(i) && Path.GetExtension(i).ToLower() == ".mcx").First());
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 'p':
|
|
|
|
|
|
ApplicationController.Instance.ShellOpenFile(files.Where(i => File.Exists(i) && Path.GetExtension(i).ToLower() == ".png").First());
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 'j':
|
|
|
|
|
|
ApplicationController.Instance.ShellOpenFile(files.Where(i => File.Exists(i) && Path.GetExtension(i).ToLower() == ".jpg").First());
|
2022-02-08 17:05:34 -08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2018-11-27 12:22:38 -08:00
|
|
|
|
|
2022-02-08 17:05:34 -08:00
|
|
|
|
base.OnKeyPress(keyPressEvent);
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
2018-11-27 12:22:38 -08:00
|
|
|
|
|
2022-02-12 18:47:59 -08:00
|
|
|
|
public void OpenFile(string filePath)
|
2022-02-10 16:39:59 -08:00
|
|
|
|
{
|
|
|
|
|
|
Instance_OpenNewFile(this, filePath);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-08 17:05:34 -08:00
|
|
|
|
private async void Instance_OpenNewFile(object sender, string filePath)
|
|
|
|
|
|
{
|
2022-02-12 18:47:59 -08:00
|
|
|
|
if (!string.IsNullOrEmpty(filePath)
|
|
|
|
|
|
&& File.Exists(filePath))
|
2022-02-08 17:05:34 -08:00
|
|
|
|
{
|
|
|
|
|
|
if (Path.GetExtension(filePath).ToLower() == ".mcx")
|
|
|
|
|
|
{
|
2022-02-09 17:12:10 -08:00
|
|
|
|
if (ApplicationController.Instance.SwitchToWorkspaceIfAlreadyOpen(filePath))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var history = ApplicationController.Instance.Library.PlatingHistory;
|
2022-02-08 17:05:34 -08:00
|
|
|
|
var workspace = new PartWorkspace(new BedConfig(history));
|
|
|
|
|
|
// Load the previous content
|
|
|
|
|
|
await workspace.SceneContext.LoadContent(new EditContext()
|
|
|
|
|
|
{
|
|
|
|
|
|
ContentStore = history,
|
|
|
|
|
|
SourceItem = new FileSystemFileItem(filePath)
|
2022-02-20 07:59:28 -08:00
|
|
|
|
}, null);
|
2022-02-08 17:05:34 -08:00
|
|
|
|
|
|
|
|
|
|
ApplicationController.Instance.OpenWorkspace(workspace, WorkspacesChangedEventArgs.OperationType.Add);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var workspace = await CreateNewDesignTab(false);
|
|
|
|
|
|
workspace.SceneContext.AddToPlate(new string[] { filePath }, false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-11-27 12:22:38 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-11-20 16:39:20 -08:00
|
|
|
|
private void TabControl_ActiveTabChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2022-02-02 17:31:44 -08:00
|
|
|
|
if (this.tabControl.ActiveTab?.TabContent is DesignTabPage tabPage)
|
2018-11-20 16:39:20 -08:00
|
|
|
|
{
|
|
|
|
|
|
var dragDropData = ApplicationController.Instance.DragDropData;
|
|
|
|
|
|
|
|
|
|
|
|
// Set reference on tab change
|
|
|
|
|
|
dragDropData.View3DWidget = tabPage.view3DWidget;
|
|
|
|
|
|
dragDropData.SceneContext = tabPage.sceneContext;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ApplicationController.Instance.MainTabKey = tabControl.SelectedTabKey;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Tasks_TasksChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.RenderRunningTasks(theme, ApplicationController.Instance.Tasks);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-08 17:05:34 -08:00
|
|
|
|
public override void OnDraw(Graphics2D graphics2D)
|
2020-05-21 08:38:26 -07:00
|
|
|
|
{
|
|
|
|
|
|
base.OnDraw(graphics2D);
|
|
|
|
|
|
|
2020-05-21 15:11:03 -07:00
|
|
|
|
// AggContext.DefaultFont.ShowDebugInfo(graphics2D);
|
2020-05-21 08:38:26 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-11-20 12:01:04 -08:00
|
|
|
|
private void ShowUpdateAvailableAnimation()
|
|
|
|
|
|
{
|
2018-11-20 14:31:04 -08:00
|
|
|
|
double displayTime = 2;
|
2018-11-20 12:01:04 -08:00
|
|
|
|
double pulseTime = 1;
|
|
|
|
|
|
double totalSeconds = 0;
|
2018-11-20 12:27:22 -08:00
|
|
|
|
|
2018-11-20 12:01:04 -08:00
|
|
|
|
var textWidgets = updateAvailableButton.Descendants<TextWidget>().Where((w) => w.Visible == true).ToArray();
|
2020-08-11 18:05:35 -07:00
|
|
|
|
Color startColor = theme.PrimaryAccentColor;
|
2018-11-20 12:01:04 -08:00
|
|
|
|
|
|
|
|
|
|
// Show a highlight on the button as the user did not click it
|
2019-05-22 16:31:03 -07:00
|
|
|
|
var flashBackground = new Animation()
|
2018-11-20 12:01:04 -08:00
|
|
|
|
{
|
|
|
|
|
|
DrawTarget = updateAvailableButton,
|
|
|
|
|
|
FramesPerSecond = 10,
|
2019-05-22 16:31:03 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
flashBackground.Update += (s1, updateEvent) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
totalSeconds += updateEvent.SecondsPassed;
|
|
|
|
|
|
if (totalSeconds < displayTime)
|
2018-11-20 12:01:04 -08:00
|
|
|
|
{
|
2019-05-22 16:31:03 -07:00
|
|
|
|
double blend = AttentionGetter.GetFadeInOutPulseRatio(totalSeconds, pulseTime);
|
|
|
|
|
|
var color = new Color(startColor, (int)((1 - blend) * 255));
|
|
|
|
|
|
foreach (var textWidget in textWidgets)
|
2018-11-20 12:01:04 -08:00
|
|
|
|
{
|
2019-05-22 16:31:03 -07:00
|
|
|
|
textWidget.TextColor = color;
|
2018-11-20 12:01:04 -08:00
|
|
|
|
}
|
2019-05-22 16:31:03 -07:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var textWidget in textWidgets)
|
2018-11-20 12:01:04 -08:00
|
|
|
|
{
|
2019-05-22 16:31:03 -07:00
|
|
|
|
textWidget.TextColor = startColor;
|
2018-11-20 12:01:04 -08:00
|
|
|
|
}
|
2019-05-22 16:31:03 -07:00
|
|
|
|
|
|
|
|
|
|
flashBackground.Stop();
|
2018-11-20 12:01:04 -08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
flashBackground.Start();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-08-17 09:21:14 -07:00
|
|
|
|
private void SetLinkButtonsVisibility(object s, StringEventArgs e)
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
|
|
|
|
|
if (UpdateControlData.Instance.UpdateStatus == UpdateControlData.UpdateStatusStates.UpdateAvailable)
|
|
|
|
|
|
{
|
2018-11-20 12:27:22 -08:00
|
|
|
|
if (!updateAvailableButton.Visible)
|
|
|
|
|
|
{
|
|
|
|
|
|
updateAvailableButton.Visible = true;
|
|
|
|
|
|
|
2019-06-29 08:33:24 -07:00
|
|
|
|
this.ShowUpdateAvailableAnimation();
|
2018-11-20 12:27:22 -08:00
|
|
|
|
}
|
2018-11-16 16:12:48 -08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
updateAvailableButton.Visible = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-21 15:21:07 -08:00
|
|
|
|
private void Workspaces_Changed(object sender, WorkspacesChangedEventArgs e)
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
2019-04-24 15:10:46 -07:00
|
|
|
|
var workspace = e.Workspace;
|
|
|
|
|
|
var activePrinter = workspace.Printer;
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
2019-04-24 13:23:52 -07:00
|
|
|
|
if (e.Operation == WorkspacesChangedEventArgs.OperationType.Add
|
|
|
|
|
|
|| e.Operation == WorkspacesChangedEventArgs.OperationType.Restore)
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
2019-04-24 15:10:46 -07:00
|
|
|
|
// Create printer or part tab
|
|
|
|
|
|
bool isPrinter = activePrinter?.Settings.PrinterSelected == true;
|
2022-02-02 17:31:44 -08:00
|
|
|
|
ChromeTab newTab = isPrinter ? CreatePrinterTab(workspace, theme) : CreateDesignTab(workspace, false);
|
2019-04-24 15:08:53 -07:00
|
|
|
|
|
2019-04-25 12:33:44 -07:00
|
|
|
|
if (e.Operation == WorkspacesChangedEventArgs.OperationType.Add)
|
|
|
|
|
|
{
|
|
|
|
|
|
ApplicationController.Instance.MainTabKey = newTab.Key;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-04-24 15:08:53 -07:00
|
|
|
|
// Activate tab with previously active key
|
|
|
|
|
|
if (newTab.Key == ApplicationController.Instance.MainTabKey)
|
|
|
|
|
|
{
|
|
|
|
|
|
tabControl.ActiveTab = newTab;
|
|
|
|
|
|
}
|
2018-11-16 16:12:48 -08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
// Close existing printer tabs
|
|
|
|
|
|
if (tabControl.AllTabs.FirstOrDefault(t => t.TabContent is PrinterTabPage printerTab
|
2020-12-30 10:35:47 -08:00
|
|
|
|
&& printerTab.Printer.Settings.ID == activePrinter.Settings.ID) is ITab tab
|
2018-11-16 16:12:48 -08:00
|
|
|
|
&& tab.TabContent is PrinterTabPage printerPage)
|
|
|
|
|
|
{
|
2021-02-24 07:54:44 -08:00
|
|
|
|
tabControl.CloseTab(tab);
|
2018-11-16 16:12:48 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private GuiWidget CreateNetworkStatusPanel(ThemeConfig theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
var networkStatus = new GuiWidget()
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Absolute,
|
|
|
|
|
|
VAnchor = VAnchor.Stretch,
|
|
|
|
|
|
Padding = new BorderDouble(right: 3),
|
|
|
|
|
|
Margin = new BorderDouble(right: 2, top: 1, bottom: 1),
|
|
|
|
|
|
Border = new BorderDouble(1),
|
|
|
|
|
|
BackgroundColor = theme.MinimalShade.WithAlpha(10),
|
|
|
|
|
|
BorderColor = theme.SlightShade,
|
2020-07-19 18:04:02 -07:00
|
|
|
|
Width = 120 * GuiWidget.DeviceScale
|
2018-11-16 16:12:48 -08:00
|
|
|
|
};
|
|
|
|
|
|
if (ApplicationController.ServicesStatusType != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var instance = Activator.CreateInstance(ApplicationController.ServicesStatusType);
|
|
|
|
|
|
if (instance is GuiWidget guiWidget)
|
|
|
|
|
|
{
|
|
|
|
|
|
guiWidget.HAnchor = HAnchor.Stretch;
|
|
|
|
|
|
guiWidget.VAnchor = VAnchor.Stretch;
|
|
|
|
|
|
networkStatus.AddChild(guiWidget);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return networkStatus;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private GuiWidget CreateThemeStatusPanel(ThemeConfig theme, Color panelBackgroundColor)
|
|
|
|
|
|
{
|
|
|
|
|
|
var themePanel = new GuiWidget()
|
|
|
|
|
|
{
|
2018-11-23 18:56:19 -08:00
|
|
|
|
HAnchor = HAnchor.Fit,
|
2018-11-16 16:12:48 -08:00
|
|
|
|
VAnchor = VAnchor.Stretch,
|
|
|
|
|
|
Margin = new BorderDouble(right: 2, top: 1, bottom: 1),
|
|
|
|
|
|
Border = new BorderDouble(1),
|
|
|
|
|
|
BackgroundColor = panelBackgroundColor,
|
|
|
|
|
|
BorderColor = theme.SlightShade,
|
|
|
|
|
|
Cursor = Cursors.Hand,
|
|
|
|
|
|
ToolTipText = "Theme".Localize(),
|
2018-11-29 09:53:48 -08:00
|
|
|
|
Name = "Theme Select Button"
|
2018-11-16 16:12:48 -08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
themePanel.AddChild(
|
2021-05-21 15:23:25 -07:00
|
|
|
|
new ImageWidget(StaticData.Instance.LoadIcon("theme.png", 16, 16), false)
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
2018-11-23 18:56:19 -08:00
|
|
|
|
HAnchor = HAnchor.Center | HAnchor.Absolute,
|
2018-11-16 16:12:48 -08:00
|
|
|
|
VAnchor = VAnchor.Center | VAnchor.Absolute,
|
2018-11-23 18:56:19 -08:00
|
|
|
|
Margin = new BorderDouble(5, 0),
|
2018-11-16 16:12:48 -08:00
|
|
|
|
Selectable = false
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
themePanel.Click += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
themePanel.BackgroundColor = theme.DropList.Open.BackgroundColor;
|
|
|
|
|
|
|
|
|
|
|
|
var menuTheme = AppContext.MenuTheme;
|
|
|
|
|
|
var widget = new GuiWidget()
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Absolute,
|
|
|
|
|
|
VAnchor = VAnchor.Fit,
|
2020-07-19 18:04:02 -07:00
|
|
|
|
Width = 650 * GuiWidget.DeviceScale,
|
2018-11-16 16:12:48 -08:00
|
|
|
|
Border = 1,
|
|
|
|
|
|
BorderColor = theme.DropList.Open.BackgroundColor,
|
|
|
|
|
|
// Padding = theme.DefaultContainerPadding,
|
|
|
|
|
|
BackgroundColor = menuTheme.BackgroundColor
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var section = ApplicationSettingsPage.CreateThemePanel(menuTheme);
|
|
|
|
|
|
widget.AddChild(section);
|
|
|
|
|
|
|
|
|
|
|
|
var systemWindow = this.Parents<SystemWindow>().FirstOrDefault();
|
|
|
|
|
|
systemWindow.ShowPopup(
|
|
|
|
|
|
new MatePoint(themePanel)
|
|
|
|
|
|
{
|
|
|
|
|
|
Mate = new MateOptions(MateEdge.Right, MateEdge.Top),
|
|
|
|
|
|
AltMate = new MateOptions(MateEdge.Right, MateEdge.Top)
|
|
|
|
|
|
},
|
|
|
|
|
|
new MatePoint(widget)
|
|
|
|
|
|
{
|
|
|
|
|
|
Mate = new MateOptions(MateEdge.Right, MateEdge.Bottom),
|
|
|
|
|
|
AltMate = new MateOptions(MateEdge.Right, MateEdge.Bottom)
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
return themePanel;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ChromeTabs TabControl => tabControl;
|
|
|
|
|
|
|
2020-10-03 17:57:53 -07:00
|
|
|
|
private static int debugPrinterTabIndex = 0;
|
|
|
|
|
|
|
2018-12-12 17:12:06 -08:00
|
|
|
|
private ChromeTab CreatePrinterTab(PartWorkspace workspace, ThemeConfig theme)
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
2018-12-12 17:12:06 -08:00
|
|
|
|
var printer = workspace.Printer;
|
2018-11-16 16:12:48 -08:00
|
|
|
|
// Printer page is in fixed position
|
|
|
|
|
|
var tab1 = tabControl.AllTabs.FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
var printerTabPage = tab1?.TabContent as PrinterTabPage;
|
|
|
|
|
|
if (printerTabPage == null
|
2020-12-30 10:35:47 -08:00
|
|
|
|
|| printerTabPage.Printer != printer)
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
|
|
|
|
|
// TODO - call save before remove
|
|
|
|
|
|
// printerTabPage.sceneContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
|
|
if (printerTabPage != null)
|
|
|
|
|
|
{
|
2021-02-24 07:54:44 -08:00
|
|
|
|
tabControl.CloseTab(tab1);
|
2018-11-16 16:12:48 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var printerTab = new ChromeTab(
|
2022-01-27 16:49:46 -08:00
|
|
|
|
printer.PrinterName,
|
|
|
|
|
|
printer.PrinterName,
|
2018-11-16 16:12:48 -08:00
|
|
|
|
tabControl,
|
2018-12-12 17:12:06 -08:00
|
|
|
|
new PrinterTabPage(workspace, theme, "unused_tab_title"),
|
2018-11-16 16:12:48 -08:00
|
|
|
|
theme,
|
|
|
|
|
|
tabImageUrl: ApplicationController.Instance.GetFavIconUrl(oemName: printer.Settings.GetValue(SettingsKey.make)))
|
|
|
|
|
|
{
|
2020-10-03 17:57:53 -07:00
|
|
|
|
Name = $"3D View Tab {debugPrinterTabIndex++}",
|
2018-11-16 16:12:48 -08:00
|
|
|
|
};
|
|
|
|
|
|
|
2020-07-09 07:12:00 -07:00
|
|
|
|
// add a right click menu
|
|
|
|
|
|
printerTab.Click += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.Button == MouseButtons.Right)
|
|
|
|
|
|
{
|
2021-03-25 11:44:52 -07:00
|
|
|
|
AddRightClickTabMenu(tabControl, printerTab, printer, null, e);
|
2020-07-09 07:12:00 -07:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2020-07-09 18:10:06 -07:00
|
|
|
|
EnableReduceWidth(printerTab, theme);
|
|
|
|
|
|
|
2019-05-22 09:18:26 -07:00
|
|
|
|
void Tab_CloseClicked(object sender, EventArgs args)
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
|
|
|
|
|
ApplicationController.Instance.ClosePrinter(printer);
|
2019-05-22 09:18:26 -07:00
|
|
|
|
}
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
2019-05-22 09:18:26 -07:00
|
|
|
|
void Widget_Closed(object sender, EventArgs args)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Unregister listeners
|
|
|
|
|
|
printerTab.CloseClicked -= Tab_CloseClicked;
|
|
|
|
|
|
printerTab.Closed -= Widget_Closed;
|
|
|
|
|
|
printer.Settings.SettingChanged -= Printer_SettingChanged;
|
|
|
|
|
|
}
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
2019-05-22 09:18:26 -07:00
|
|
|
|
// Register listeners
|
|
|
|
|
|
printer.Settings.SettingChanged += Printer_SettingChanged;
|
|
|
|
|
|
printerTab.CloseClicked += Tab_CloseClicked;
|
|
|
|
|
|
printerTab.Closed += Widget_Closed;
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
2018-12-26 14:06:38 -08:00
|
|
|
|
// Add printer tab
|
|
|
|
|
|
tabControl.AddTab(printerTab);
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
|
|
|
|
|
return printerTab;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (tab1 != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
tabControl.ActiveTab = tab1;
|
|
|
|
|
|
return tab1 as ChromeTab;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-25 11:44:52 -07:00
|
|
|
|
private void AddRightClickTabMenu(ChromeTabs tabs, ChromeTab printerTab, PrinterConfig printer, PartWorkspace workspace, MouseEventArgs mouseEvent)
|
2020-07-09 07:12:00 -07:00
|
|
|
|
{
|
|
|
|
|
|
var menuTheme = ApplicationController.Instance.MenuTheme;
|
|
|
|
|
|
var popupMenu = new PopupMenu(menuTheme);
|
2022-01-21 15:21:07 -08:00
|
|
|
|
|
|
|
|
|
|
var renameMenuItem = popupMenu.CreateMenuItem("Rename".Localize());
|
|
|
|
|
|
renameMenuItem.Click += (s, e) =>
|
2021-03-09 15:17:17 -08:00
|
|
|
|
{
|
2022-01-21 15:21:07 -08:00
|
|
|
|
if (workspace != null)
|
2021-03-09 15:17:17 -08:00
|
|
|
|
{
|
2022-01-21 15:21:07 -08:00
|
|
|
|
workspace.SceneContext?.EditContext?.SourceItem?.Rename();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (printer != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DialogWindow.Show(
|
|
|
|
|
|
new InputBoxPage(
|
|
|
|
|
|
"Rename Item".Localize(),
|
|
|
|
|
|
"Name".Localize(),
|
2022-01-27 16:49:46 -08:00
|
|
|
|
printer.PrinterName,
|
2022-01-21 15:21:07 -08:00
|
|
|
|
"Enter New Name Here".Localize(),
|
|
|
|
|
|
"Rename".Localize(),
|
|
|
|
|
|
(newName) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
printer.Settings.SetValue(SettingsKey.printer_name, newName);
|
|
|
|
|
|
}));
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2020-07-09 07:12:00 -07:00
|
|
|
|
|
2021-03-25 11:44:52 -07:00
|
|
|
|
|
2021-03-09 17:15:15 -08:00
|
|
|
|
var moveButtons = new FlowLayoutWidget();
|
|
|
|
|
|
|
|
|
|
|
|
var textWidget = new TextWidget("Move Tab", pointSize: theme.DefaultFontSize, textColor: theme.TextColor)
|
|
|
|
|
|
{
|
2021-03-10 09:53:41 -08:00
|
|
|
|
Margin = PopupMenu.MenuPadding.Clone(PopupMenu.MenuPadding.Left - 5, right: 5),
|
2021-03-09 17:15:15 -08:00
|
|
|
|
VAnchor = VAnchor.Center,
|
|
|
|
|
|
};
|
|
|
|
|
|
moveButtons.AddChild(textWidget);
|
2021-03-10 09:53:41 -08:00
|
|
|
|
var buttonSize = 24 * DeviceScale;
|
2021-05-21 15:23:25 -07:00
|
|
|
|
var moveLeftButton = new IconButton(StaticData.Instance.LoadIcon("fa-angle-right_12.png", 14, 14).SetToColor(theme.TextColor).MirrorX(), theme)
|
2021-03-09 17:15:15 -08:00
|
|
|
|
{
|
2021-03-10 09:53:41 -08:00
|
|
|
|
Width = buttonSize,
|
|
|
|
|
|
Height = buttonSize,
|
|
|
|
|
|
Margin = new BorderDouble(3, 0),
|
|
|
|
|
|
HoverColor = theme.AccentMimimalOverlay,
|
2021-03-09 17:15:15 -08:00
|
|
|
|
VAnchor = VAnchor.Center,
|
2021-03-10 17:34:16 -08:00
|
|
|
|
Enabled = tabs.GetTabIndex(printerTab) > tabs.FirstMovableTab,
|
2021-03-09 17:15:15 -08:00
|
|
|
|
};
|
|
|
|
|
|
moveLeftButton.Click += (s, e) =>
|
2021-02-24 07:54:44 -08:00
|
|
|
|
{
|
|
|
|
|
|
tabs.MoveTabLeft(printerTab);
|
2021-03-09 17:15:15 -08:00
|
|
|
|
popupMenu.Unfocus();
|
2021-02-24 07:54:44 -08:00
|
|
|
|
};
|
2021-03-09 17:15:15 -08:00
|
|
|
|
moveButtons.AddChild(moveLeftButton);
|
2021-02-24 07:54:44 -08:00
|
|
|
|
|
2021-05-21 15:23:25 -07:00
|
|
|
|
var moveRightButton = new IconButton(StaticData.Instance.LoadIcon("fa-angle-right_12.png", 14, 14).SetToColor(theme.TextColor), theme)
|
2021-03-09 17:15:15 -08:00
|
|
|
|
{
|
2021-03-10 09:53:41 -08:00
|
|
|
|
Width = buttonSize,
|
|
|
|
|
|
Height = buttonSize,
|
|
|
|
|
|
Margin = new BorderDouble(3, 0),
|
|
|
|
|
|
HoverColor = theme.AccentMimimalOverlay,
|
2021-03-09 17:15:15 -08:00
|
|
|
|
VAnchor = VAnchor.Center,
|
2021-03-10 17:34:16 -08:00
|
|
|
|
Enabled = printerTab.NextTab != null,
|
2021-03-09 17:15:15 -08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
moveRightButton.Click += (s, e) =>
|
2021-02-24 07:54:44 -08:00
|
|
|
|
{
|
|
|
|
|
|
tabs.MoveTabRight(printerTab);
|
2021-03-09 17:15:15 -08:00
|
|
|
|
popupMenu.Unfocus();
|
2021-02-24 07:54:44 -08:00
|
|
|
|
};
|
2021-03-09 17:15:15 -08:00
|
|
|
|
moveButtons.AddChild(moveRightButton);
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.AddChild(moveButtons);
|
2021-02-24 07:54:44 -08:00
|
|
|
|
|
2020-07-09 07:12:00 -07:00
|
|
|
|
popupMenu.ShowMenu(printerTab, mouseEvent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-08 17:05:34 -08:00
|
|
|
|
public async Task<PartWorkspace> CreateNewDesignTab(bool addPhilToBed)
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
|
|
|
|
|
var history = ApplicationController.Instance.Library.PlatingHistory;
|
|
|
|
|
|
|
2022-01-20 14:52:03 -08:00
|
|
|
|
var workspace = new PartWorkspace(new BedConfig(history));
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
2022-02-20 07:59:28 -08:00
|
|
|
|
await workspace.SceneContext.LoadContent(new EditContext(), null);
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
|
|
|
|
|
ApplicationController.Instance.Workspaces.Add(workspace);
|
|
|
|
|
|
|
2022-02-02 17:31:44 -08:00
|
|
|
|
var newTab = CreateDesignTab(workspace, true);
|
2018-11-16 16:12:48 -08:00
|
|
|
|
tabControl.ActiveTab = newTab;
|
|
|
|
|
|
|
2022-01-20 14:52:03 -08:00
|
|
|
|
if (addPhilToBed)
|
|
|
|
|
|
{
|
|
|
|
|
|
workspace.SceneContext.AddPhilToBed();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ApplicationController.Instance.MainTabKey = workspace.Name;
|
2022-02-08 17:05:34 -08:00
|
|
|
|
|
|
|
|
|
|
return workspace;
|
2018-11-16 16:12:48 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-02 17:31:44 -08:00
|
|
|
|
private static void HookupNameChangeCallback(ChromeTab partTab, PartWorkspace workspace)
|
|
|
|
|
|
{
|
2022-02-03 13:42:27 -08:00
|
|
|
|
var editContext = workspace.SceneContext.EditContext;
|
|
|
|
|
|
ILibraryItem sourceItem = editContext?.SourceItem;
|
2022-02-02 17:31:44 -08:00
|
|
|
|
|
2022-02-03 13:42:27 -08:00
|
|
|
|
void UpdateLinks(object s, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
editContext = workspace.SceneContext.EditContext;
|
|
|
|
|
|
// remove any exisitng delegate
|
|
|
|
|
|
if (sourceItem != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
sourceItem.NameChanged -= UpdateTabName;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// hook up a new delegate
|
|
|
|
|
|
if (editContext != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
sourceItem = editContext.SourceItem;
|
|
|
|
|
|
if (sourceItem != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
sourceItem.NameChanged += UpdateTabName;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UpdateTabName(object s, EventArgs e)
|
2022-02-02 17:31:44 -08:00
|
|
|
|
{
|
2022-02-03 13:42:27 -08:00
|
|
|
|
UpdateLinks(s, e);
|
|
|
|
|
|
if (sourceItem != null)
|
2022-02-02 17:31:44 -08:00
|
|
|
|
{
|
|
|
|
|
|
partTab.Text = sourceItem.Name;
|
2022-02-03 13:42:27 -08:00
|
|
|
|
if (sourceItem is FileSystemFileItem fileSystemFileItem)
|
|
|
|
|
|
{
|
2022-02-02 17:31:44 -08:00
|
|
|
|
partTab.ToolTipText = fileSystemFileItem.FilePath;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-03 13:42:27 -08:00
|
|
|
|
ApplicationController.Instance.PersistOpenTabsLayout();
|
|
|
|
|
|
}
|
2022-02-02 17:31:44 -08:00
|
|
|
|
|
2022-02-03 13:42:27 -08:00
|
|
|
|
if (sourceItem != null)
|
|
|
|
|
|
{
|
2022-02-02 17:31:44 -08:00
|
|
|
|
sourceItem.NameChanged += UpdateTabName;
|
2022-02-03 13:42:27 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (editContext != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
editContext.SourceItemChanged += UpdateTabName;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
workspace.SceneContext.SceneLoaded += UpdateTabName;
|
2022-02-02 17:31:44 -08:00
|
|
|
|
|
2022-02-03 13:42:27 -08:00
|
|
|
|
partTab.Closed += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sourceItem != null)
|
2022-02-02 17:31:44 -08:00
|
|
|
|
{
|
|
|
|
|
|
sourceItem.NameChanged -= UpdateTabName;
|
2022-02-03 13:42:27 -08:00
|
|
|
|
}
|
|
|
|
|
|
editContext.SourceItemChanged -= UpdateTabName;
|
|
|
|
|
|
workspace.SceneContext.SceneLoaded -= UpdateTabName;
|
|
|
|
|
|
};
|
2022-02-02 17:31:44 -08:00
|
|
|
|
|
2022-02-03 13:42:27 -08:00
|
|
|
|
UpdateTabName(null, null);
|
2022-02-02 17:31:44 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ChromeTab CreateDesignTab(PartWorkspace workspace, bool saveLayout)
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
|
|
|
|
|
var partTab = new ChromeTab(
|
|
|
|
|
|
workspace.Name,
|
|
|
|
|
|
workspace.Name,
|
|
|
|
|
|
tabControl,
|
2022-02-02 17:31:44 -08:00
|
|
|
|
new DesignTabPage(workspace, theme, ""),
|
2018-11-16 16:12:48 -08:00
|
|
|
|
theme,
|
2021-05-21 15:23:25 -07:00
|
|
|
|
StaticData.Instance.LoadIcon("cube.png", 16, 16).SetToColor(theme.TextColor))
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
|
|
|
|
|
Name = "newPart" + tabControl.AllTabs.Count(),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2022-01-21 15:21:07 -08:00
|
|
|
|
HookupNameChangeCallback(partTab, workspace);
|
|
|
|
|
|
|
2020-07-09 18:10:06 -07:00
|
|
|
|
EnableReduceWidth(partTab, theme);
|
2020-05-30 16:50:36 -07:00
|
|
|
|
|
2018-11-16 16:12:48 -08:00
|
|
|
|
tabControl.AddTab(partTab);
|
|
|
|
|
|
|
2019-05-22 09:18:26 -07:00
|
|
|
|
void Tab_CloseClicked(object sender, EventArgs args)
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
|
|
|
|
|
ApplicationController.Instance.Workspaces.Remove(workspace);
|
2019-05-22 09:18:26 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-09 15:17:17 -08:00
|
|
|
|
// add a right click menu
|
|
|
|
|
|
partTab.Click += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.Button == MouseButtons.Right)
|
|
|
|
|
|
{
|
2021-03-25 11:44:52 -07:00
|
|
|
|
AddRightClickTabMenu(tabControl, partTab, null, workspace, e);
|
2021-03-09 15:17:17 -08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2019-05-22 09:18:26 -07:00
|
|
|
|
void Widget_Closed(object sender, EventArgs args)
|
|
|
|
|
|
{
|
|
|
|
|
|
partTab.CloseClicked -= Tab_CloseClicked;
|
|
|
|
|
|
partTab.Closed -= Widget_Closed;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
partTab.CloseClicked += Tab_CloseClicked;
|
|
|
|
|
|
partTab.Closed += Widget_Closed;
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
|
|
|
|
|
return partTab;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-07-09 18:10:06 -07:00
|
|
|
|
private static void EnableReduceWidth(ChromeTab partTab, ThemeConfig theme)
|
|
|
|
|
|
{
|
2020-07-12 12:25:18 -07:00
|
|
|
|
var scale = GuiWidget.DeviceScale;
|
2020-08-16 18:43:51 -07:00
|
|
|
|
partTab.MinimumSize = new Vector2(80 * scale, theme.TabButtonHeight);
|
2020-07-09 18:10:06 -07:00
|
|
|
|
|
|
|
|
|
|
var textWidget = partTab.Descendants<TextWidget>().First();
|
|
|
|
|
|
var tabPill = partTab.Descendants<SimpleTab.TabPill>().First();
|
|
|
|
|
|
tabPill.HAnchor = HAnchor.Stretch;
|
|
|
|
|
|
var closeBox = partTab.Descendants<ImageWidget>().FirstOrDefault();
|
|
|
|
|
|
if (closeBox != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var tabPillMarign = tabPill.Margin;
|
|
|
|
|
|
tabPill.Margin = new BorderDouble(tabPillMarign.Left, tabPillMarign.Bottom, tabPillMarign.Right + 10, tabPillMarign.Top);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UpadetMaxWidth();
|
|
|
|
|
|
|
2020-07-09 18:44:04 -07:00
|
|
|
|
// delay this for an update so that the layout of the text widget has happened and its size has been updated.
|
|
|
|
|
|
textWidget.TextChanged += (s, e) => UiThread.RunOnIdle(UpadetMaxWidth);
|
2020-07-09 18:10:06 -07:00
|
|
|
|
|
|
|
|
|
|
void UpadetMaxWidth()
|
|
|
|
|
|
{
|
|
|
|
|
|
// the text
|
|
|
|
|
|
var width = textWidget.Width;
|
|
|
|
|
|
// the tab pill
|
2020-07-12 12:25:18 -07:00
|
|
|
|
width += (tabPill.Margin.Width + tabPill.Padding.Width) * scale;
|
2020-07-09 18:10:06 -07:00
|
|
|
|
if (closeBox != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
// the close box
|
|
|
|
|
|
width += closeBox.Width;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2020-07-12 12:25:18 -07:00
|
|
|
|
width += 32 * scale;
|
2020-07-09 18:10:06 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
partTab.MaximumSize = new Vector2(width, partTab.MaximumSize.Y);
|
2020-07-10 18:18:38 -07:00
|
|
|
|
partTab.Width -= 1;
|
2020-07-09 18:10:06 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
partTab.HAnchor = HAnchor.Stretch;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-11-16 16:12:48 -08:00
|
|
|
|
public override void OnClosed(EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Unregister listeners
|
|
|
|
|
|
PrinterSettings.AnyPrinterSettingChanged -= Printer_SettingChanged;
|
|
|
|
|
|
UserSettings.Instance.SettingChanged -= SetLinkButtonsVisibility;
|
2018-12-07 18:41:32 -08:00
|
|
|
|
ApplicationController.Instance.WorkspacesChanged -= Workspaces_Changed;
|
2018-11-20 16:39:20 -08:00
|
|
|
|
ApplicationController.Instance.Tasks.TasksChanged -= Tasks_TasksChanged;
|
2021-06-04 18:09:30 -07:00
|
|
|
|
ApplicationController.Instance.UiHintChanged -= Tasks_TasksChanged;
|
2018-11-27 12:22:38 -08:00
|
|
|
|
ApplicationController.Instance.ShellFileOpened -= Instance_OpenNewFile;
|
2019-12-06 10:19:21 -08:00
|
|
|
|
if (tabControl != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
tabControl.ActiveTabChanged -= TabControl_ActiveTabChanged;
|
|
|
|
|
|
}
|
2018-11-16 16:12:48 -08:00
|
|
|
|
|
|
|
|
|
|
unregisterEvents?.Invoke(this, null);
|
|
|
|
|
|
base.OnClosed(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-11-20 16:39:20 -08:00
|
|
|
|
#if DEBUG
|
|
|
|
|
|
~MainViewWidget()
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2018-12-20 12:38:05 -08:00
|
|
|
|
private void Printer_SettingChanged(object s, StringEventArgs stringEvent)
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
|
|
|
|
|
if (s is PrinterSettings printerSettings
|
2018-12-20 12:38:05 -08:00
|
|
|
|
&& stringEvent?.Data == SettingsKey.printer_name)
|
2018-11-16 16:12:48 -08:00
|
|
|
|
{
|
|
|
|
|
|
// Try to find a printer tab for the given printer
|
2020-12-30 10:35:47 -08:00
|
|
|
|
var printerTab = tabControl.AllTabs.FirstOrDefault(t => t.TabContent is PrinterTabPage printerPage && printerPage.Printer.Settings.ID == printerSettings.ID) as ChromeTab;
|
2018-11-16 16:12:48 -08:00
|
|
|
|
if (printerTab != null)
|
|
|
|
|
|
{
|
2022-02-02 17:31:44 -08:00
|
|
|
|
printerTab.Text = printerSettings.GetValue(SettingsKey.printer_name);
|
|
|
|
|
|
// printerTab.ToolTipText = printerTab.Text;
|
2018-11-16 16:12:48 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void RenderRunningTasks(ThemeConfig theme, RunningTasksConfig tasks)
|
|
|
|
|
|
{
|
|
|
|
|
|
var rows = tasksContainer.Children.OfType<RunningTaskStatusPanel>().ToList();
|
|
|
|
|
|
var displayedTasks = new HashSet<RunningTaskDetails>(rows.Select(taskRow => taskRow.taskDetails));
|
|
|
|
|
|
var runningTasks = tasks.RunningTasks;
|
|
|
|
|
|
|
|
|
|
|
|
// Remove expired items
|
|
|
|
|
|
foreach (var row in rows)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!runningTasks.Contains(row.taskDetails))
|
|
|
|
|
|
{
|
|
|
|
|
|
row.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var progressBackgroundColor = new Color(theme.AccentMimimalOverlay, 35);
|
|
|
|
|
|
|
|
|
|
|
|
// Add new items
|
|
|
|
|
|
foreach (var taskItem in tasks.RunningTasks.Where(t => !displayedTasks.Contains(t)))
|
|
|
|
|
|
{
|
2019-03-19 17:19:35 -07:00
|
|
|
|
// TODO: find out how we are getting a null task item in the list
|
|
|
|
|
|
if (taskItem == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-11-16 16:12:48 -08:00
|
|
|
|
var runningTaskPanel = new RunningTaskStatusPanel("", taskItem, theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Absolute,
|
|
|
|
|
|
VAnchor = VAnchor.Stretch,
|
|
|
|
|
|
Margin = new BorderDouble(right: 2, top: 1, bottom: 1),
|
|
|
|
|
|
Border = new BorderDouble(1),
|
|
|
|
|
|
BorderColor = theme.SlightShade,
|
|
|
|
|
|
ProgressBackgroundColor = progressBackgroundColor,
|
2020-07-19 18:04:02 -07:00
|
|
|
|
Width = 200 * GuiWidget.DeviceScale
|
2018-11-16 16:12:48 -08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
tasksContainer.AddChild(runningTaskPanel);
|
2021-06-04 18:09:30 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-06-05 11:12:26 -07:00
|
|
|
|
if (!string.IsNullOrEmpty(ApplicationController.Instance.UiHint))
|
2021-06-04 18:09:30 -07:00
|
|
|
|
{
|
|
|
|
|
|
statusMessage.Text = ApplicationController.Instance.UiHint;
|
|
|
|
|
|
statusMessage.Visible = true;
|
2021-06-05 11:12:26 -07:00
|
|
|
|
var parent = statusMessage.Parent;
|
|
|
|
|
|
if (parent.Children.IndexOf(statusMessage) != parent.Children.Count - 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
parent.RemoveChild(statusMessage);
|
|
|
|
|
|
statusMessage.ClearRemovedFlag();
|
|
|
|
|
|
parent.AddChild(statusMessage);
|
|
|
|
|
|
}
|
2021-06-04 18:09:30 -07:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
statusMessage.Visible = false;
|
2018-11-16 16:12:48 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tasksContainer.Invalidate();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|