2014-02-15 18:06:03 -08:00
|
|
|
|
/*
|
2019-03-19 13:10:47 -07:00
|
|
|
|
Copyright (c) 2019, Lars Brubaker, John Lewin
|
2014-02-15 18:06:03 -08:00
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
2015-04-08 15:20:10 -07:00
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
2014-02-15 18:06:03 -08:00
|
|
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
2015-04-08 15:20:10 -07:00
|
|
|
|
list of conditions and the following disclaimer.
|
2014-02-15 18:06:03 -08:00
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
2015-04-08 15:20:10 -07:00
|
|
|
|
and/or other materials provided with the distribution.
|
2014-02-15 18:06:03 -08:00
|
|
|
|
|
|
|
|
|
|
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
|
2015-04-08 15:20:10 -07:00
|
|
|
|
of the authors and should not be interpreted as representing official policies,
|
2014-02-15 18:06:03 -08:00
|
|
|
|
either expressed or implied, of the FreeBSD Project.
|
|
|
|
|
|
*/
|
2016-08-10 15:18:03 -07:00
|
|
|
|
|
2017-07-01 16:47:37 -07:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2020-11-08 07:18:15 -08:00
|
|
|
|
using System.Diagnostics;
|
2017-07-01 16:47:37 -07:00
|
|
|
|
using System.Linq;
|
2018-04-04 08:47:26 -07:00
|
|
|
|
using System.Text.RegularExpressions;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
using MatterHackers.Agg;
|
2014-02-05 17:47:13 -08:00
|
|
|
|
using MatterHackers.Agg.UI;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
using MatterHackers.Localizations;
|
2014-11-03 12:13:03 -08:00
|
|
|
|
using MatterHackers.MatterControl.CustomWidgets;
|
2018-01-08 13:13:32 -08:00
|
|
|
|
using MatterHackers.MatterControl.PartPreviewWindow;
|
2018-01-14 10:36:05 -08:00
|
|
|
|
using MatterHackers.MatterControl.PrintLibrary;
|
2014-02-05 17:47:13 -08:00
|
|
|
|
using MatterHackers.VectorMath;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
2014-02-15 18:06:03 -08:00
|
|
|
|
namespace MatterHackers.MatterControl.SlicerConfiguration
|
2018-04-04 08:47:26 -07:00
|
|
|
|
{
|
2017-10-15 16:24:39 -07:00
|
|
|
|
public class SliceSettingsWidget : FlowLayoutWidget
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2020-06-21 09:34:53 -07:00
|
|
|
|
private readonly PresetsToolbar settingsControlBar;
|
2017-06-08 16:43:30 -07:00
|
|
|
|
|
2020-06-21 09:34:53 -07:00
|
|
|
|
public SettingsContext SettingsContext { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
private readonly PrinterConfig printer;
|
2017-10-31 14:37:28 -07:00
|
|
|
|
|
|
|
|
|
|
public SliceSettingsWidget(PrinterConfig printer, SettingsContext settingsContext, ThemeConfig theme)
|
2020-06-21 09:34:53 -07:00
|
|
|
|
: base(FlowDirection.TopToBottom)
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2017-09-17 01:11:18 -07:00
|
|
|
|
this.printer = printer;
|
2020-06-21 09:34:53 -07:00
|
|
|
|
this.SettingsContext = settingsContext;
|
2016-04-18 11:31:31 -07:00
|
|
|
|
|
2018-04-12 08:42:10 -07:00
|
|
|
|
settingsControlBar = new PresetsToolbar(printer, theme)
|
2016-03-30 18:33:29 -07:00
|
|
|
|
{
|
2017-08-07 15:47:27 -07:00
|
|
|
|
HAnchor = HAnchor.Stretch,
|
2021-06-12 07:59:52 -07:00
|
|
|
|
Padding = new BorderDouble(5)
|
2016-03-30 18:33:29 -07:00
|
|
|
|
};
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
using (this.LayoutLock())
|
|
|
|
|
|
{
|
|
|
|
|
|
this.AddChild(settingsControlBar);
|
|
|
|
|
|
|
2020-12-30 14:44:24 -08:00
|
|
|
|
var settingsSection = PrinterSettings.Layout.SlicingSections[0];
|
2020-12-28 17:50:04 -08:00
|
|
|
|
switch (UserSettings.Instance.get(UserSettingsKey.SliceSettingsViewDetail))
|
|
|
|
|
|
{
|
|
|
|
|
|
case "Simple":
|
2020-12-30 14:44:24 -08:00
|
|
|
|
settingsSection = PrinterSettings.Layout.SlicingSections[0];
|
2020-12-28 17:50:04 -08:00
|
|
|
|
break;
|
|
|
|
|
|
|
2020-12-30 10:35:47 -08:00
|
|
|
|
case "Intermediate":
|
2020-12-30 14:44:24 -08:00
|
|
|
|
settingsSection = PrinterSettings.Layout.SlicingSections[1];
|
2020-12-28 17:50:04 -08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case "Advanced":
|
2020-12-30 14:44:24 -08:00
|
|
|
|
settingsSection = PrinterSettings.Layout.SlicingSections[2];
|
2020-12-28 17:50:04 -08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
this.AddChild(
|
|
|
|
|
|
new SliceSettingsTabView(
|
|
|
|
|
|
settingsContext,
|
|
|
|
|
|
"SliceSettings",
|
|
|
|
|
|
printer,
|
2020-12-28 17:50:04 -08:00
|
|
|
|
settingsSection,
|
2018-06-24 08:54:44 -07:00
|
|
|
|
theme,
|
|
|
|
|
|
isPrimarySettingsView: true,
|
2018-11-27 13:00:42 -08:00
|
|
|
|
justMySettingsTitle: "My Modified Settings".Localize(),
|
2018-09-08 12:52:47 -07:00
|
|
|
|
databaseMRUKey: UserSettingsKey.SliceSettingsWidget_CurrentTab));
|
2018-06-24 08:54:44 -07:00
|
|
|
|
}
|
2018-04-07 22:13:19 -07:00
|
|
|
|
|
|
|
|
|
|
this.AnchorAll();
|
2018-01-14 10:36:05 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-04 23:49:05 +03:00
|
|
|
|
// TODO: This should just proxy to settingsControlBar.Visible. Having local state and pushing values on event listeners seems off
|
2017-01-11 14:27:33 -08:00
|
|
|
|
private bool showControlBar = true;
|
2020-06-21 09:34:53 -07:00
|
|
|
|
|
2017-01-11 14:27:33 -08:00
|
|
|
|
public bool ShowControlBar
|
|
|
|
|
|
{
|
2020-06-21 09:34:53 -07:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return showControlBar;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-01-11 14:27:33 -08:00
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
settingsControlBar.Visible = value;
|
|
|
|
|
|
showControlBar = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-01-14 10:13:42 -08:00
|
|
|
|
}
|
2017-06-08 16:43:30 -07:00
|
|
|
|
|
2018-01-14 10:13:42 -08:00
|
|
|
|
public class SliceSettingsTabView : SimpleTabs
|
|
|
|
|
|
{
|
2018-04-04 08:47:26 -07:00
|
|
|
|
// Sanitize group names for use as keys in db fields
|
2020-06-21 09:34:53 -07:00
|
|
|
|
private static readonly Regex NameSanitizer = new Regex("[^a-zA-Z0-9-]", RegexOptions.Compiled);
|
2018-04-04 08:47:26 -07:00
|
|
|
|
|
2018-01-14 10:13:42 -08:00
|
|
|
|
private int tabIndexForItem = 0;
|
2021-01-05 17:55:52 -08:00
|
|
|
|
private readonly Dictionary<string, UIField> allUiFields = new Dictionary<string, UIField>();
|
2020-06-21 09:34:53 -07:00
|
|
|
|
private readonly ThemeConfig theme;
|
|
|
|
|
|
private readonly PrinterConfig printer;
|
|
|
|
|
|
private readonly SettingsContext settingsContext;
|
|
|
|
|
|
private readonly bool isPrimarySettingsView;
|
2018-01-14 10:13:42 -08:00
|
|
|
|
|
2020-07-18 13:48:38 -07:00
|
|
|
|
private readonly TextEditWithInlineCancel settingsNameEdit;
|
2018-01-14 10:36:05 -08:00
|
|
|
|
private int groupPanelCount = 0;
|
2021-01-05 17:55:52 -08:00
|
|
|
|
private readonly List<(GuiWidget widget, SliceSettingData settingData)> settingsRows;
|
|
|
|
|
|
private readonly TextWidget filteredItemsHeading;
|
2020-06-21 09:34:53 -07:00
|
|
|
|
private readonly Action<PopupMenu> externalExtendMenu;
|
|
|
|
|
|
private readonly string scopeName;
|
2017-11-16 09:56:16 -08:00
|
|
|
|
|
2020-11-08 07:18:15 -08:00
|
|
|
|
public SliceSettingsTabView(SettingsContext settingsContext,
|
|
|
|
|
|
string scopeName,
|
|
|
|
|
|
PrinterConfig printer,
|
|
|
|
|
|
SettingsLayout.SettingsSection settingsSection,
|
|
|
|
|
|
ThemeConfig theme,
|
|
|
|
|
|
bool isPrimarySettingsView,
|
|
|
|
|
|
string databaseMRUKey,
|
|
|
|
|
|
string justMySettingsTitle,
|
|
|
|
|
|
Action<PopupMenu> extendPopupMenu = null)
|
2020-06-21 09:34:53 -07:00
|
|
|
|
: base(theme)
|
2018-01-14 10:36:05 -08:00
|
|
|
|
{
|
2018-06-24 08:54:44 -07:00
|
|
|
|
using (this.LayoutLock())
|
|
|
|
|
|
{
|
|
|
|
|
|
this.VAnchor = VAnchor.Stretch;
|
|
|
|
|
|
this.HAnchor = HAnchor.Stretch;
|
|
|
|
|
|
this.externalExtendMenu = extendPopupMenu;
|
|
|
|
|
|
this.scopeName = scopeName;
|
2018-01-21 21:07:14 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
var overflowBar = this.TabBar as OverflowBar;
|
2020-12-30 10:35:47 -08:00
|
|
|
|
overflowBar.ToolTipText = "Settings View Options".Localize();
|
2018-06-24 08:54:44 -07:00
|
|
|
|
overflowBar.ExtendOverflowMenu = this.ExtendOverflowMenu;
|
2018-01-21 21:07:14 -08:00
|
|
|
|
|
2021-01-05 17:55:52 -08:00
|
|
|
|
this.TabBar.RightAnchorItem.Name = "Slice Settings Overflow Menu";
|
2018-01-14 10:13:42 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
this.TabBar.Padding = this.TabBar.Margin.Clone(right: theme.ToolbarPadding.Right);
|
2018-01-14 10:36:05 -08:00
|
|
|
|
|
2020-07-18 13:48:38 -07:00
|
|
|
|
settingsNameEdit = new TextEditWithInlineCancel(theme, "name".Localize())
|
2018-06-24 08:54:44 -07:00
|
|
|
|
{
|
|
|
|
|
|
Visible = false,
|
|
|
|
|
|
BackgroundColor = theme.TabBarBackground,
|
|
|
|
|
|
MinimumSize = new Vector2(0, this.TabBar.Height)
|
|
|
|
|
|
};
|
2018-01-14 10:36:05 -08:00
|
|
|
|
|
2020-07-18 13:48:38 -07:00
|
|
|
|
settingsNameEdit.TextEditWidget.Margin = new BorderDouble(3, 0);
|
|
|
|
|
|
settingsNameEdit.TextEditWidget.ActualTextEditWidget.EnterPressed += (s, e) =>
|
2018-01-14 10:36:05 -08:00
|
|
|
|
{
|
2020-07-18 13:48:38 -07:00
|
|
|
|
var filter = settingsNameEdit.TextEditWidget.Text.Trim();
|
2018-06-24 08:54:44 -07:00
|
|
|
|
|
2021-01-05 17:55:52 -08:00
|
|
|
|
foreach (var (widget, settingData) in this.settingsRows)
|
2018-06-24 08:54:44 -07:00
|
|
|
|
{
|
2021-01-05 17:55:52 -08:00
|
|
|
|
var metaData = settingData;
|
2018-01-14 10:36:05 -08:00
|
|
|
|
|
2019-03-19 13:10:47 -07:00
|
|
|
|
// Show matching items
|
2021-01-05 17:55:52 -08:00
|
|
|
|
widget.Visible = metaData.SlicerConfigName.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0
|
2018-06-24 08:54:44 -07:00
|
|
|
|
|| metaData.HelpText.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0;
|
|
|
|
|
|
}
|
2018-01-14 10:36:05 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
this.ShowFilteredView();
|
|
|
|
|
|
};
|
2020-07-18 13:48:38 -07:00
|
|
|
|
|
|
|
|
|
|
settingsNameEdit.ResetButton.Click += (s, e) =>
|
2018-06-24 08:54:44 -07:00
|
|
|
|
{
|
2020-07-18 13:48:38 -07:00
|
|
|
|
settingsNameEdit.Visible = false;
|
|
|
|
|
|
settingsNameEdit.TextEditWidget.Text = "";
|
2018-01-14 10:36:05 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
this.ClearFilter();
|
|
|
|
|
|
};
|
2018-01-14 10:36:05 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
// Add heading for My Settings view
|
2020-07-18 13:48:38 -07:00
|
|
|
|
settingsNameEdit.AddChild(filteredItemsHeading = new TextWidget(justMySettingsTitle, pointSize: theme.DefaultFontSize, textColor: theme.TextColor)
|
2018-06-24 08:54:44 -07:00
|
|
|
|
{
|
|
|
|
|
|
Margin = new BorderDouble(left: 10),
|
|
|
|
|
|
HAnchor = HAnchor.Left,
|
|
|
|
|
|
VAnchor = VAnchor.Center,
|
|
|
|
|
|
Visible = false
|
|
|
|
|
|
}, 0);
|
2018-01-14 10:36:05 -08:00
|
|
|
|
|
2020-07-18 13:48:38 -07:00
|
|
|
|
this.AddChild(settingsNameEdit, 0);
|
2018-01-16 15:05:58 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
var scrollable = new ScrollableWidget(true)
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
VAnchor = VAnchor.Stretch,
|
|
|
|
|
|
};
|
|
|
|
|
|
scrollable.ScrollArea.HAnchor = HAnchor.Stretch;
|
2018-01-16 15:05:58 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
var tabContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
|
|
|
|
|
{
|
|
|
|
|
|
VAnchor = VAnchor.Fit,
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
};
|
2018-01-16 15:05:58 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
scrollable.AddChild(tabContainer);
|
2018-01-16 15:05:58 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
this.AddChild(scrollable);
|
2018-01-16 15:05:58 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
// Force TopToBottom flowlayout contained in scrollable as AddChild target
|
|
|
|
|
|
this.TabContainer = tabContainer;
|
2018-01-14 10:13:42 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
this.theme = theme;
|
|
|
|
|
|
this.printer = printer;
|
|
|
|
|
|
this.settingsContext = settingsContext;
|
|
|
|
|
|
this.isPrimarySettingsView = isPrimarySettingsView;
|
2017-07-01 16:47:37 -07:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
this.TabBar.BackgroundColor = theme.TabBarBackground;
|
2018-01-11 12:29:19 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
tabIndexForItem = 0;
|
2018-01-14 10:13:42 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
this.settingsRows = new List<(GuiWidget, SliceSettingData)>();
|
2018-01-18 17:59:24 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
allUiFields = new Dictionary<string, UIField>();
|
2017-06-11 14:29:42 -07:00
|
|
|
|
|
2019-01-28 17:10:12 -08:00
|
|
|
|
var errors = printer.ValidateSettings(settingsContext);
|
2019-01-05 10:38:33 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
// Loop over categories creating a tab for each
|
2019-01-06 10:37:29 -08:00
|
|
|
|
foreach (var category in settingsSection.Categories)
|
2016-07-15 11:52:06 -07:00
|
|
|
|
{
|
2018-06-24 08:54:44 -07:00
|
|
|
|
if (category.Name == "Printer"
|
|
|
|
|
|
&& (settingsContext.ViewFilter == NamedSettingsLayers.Material || settingsContext.ViewFilter == NamedSettingsLayers.Quality))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2018-01-14 10:13:42 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
var categoryPanel = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
|
|
|
|
|
{
|
|
|
|
|
|
VAnchor = VAnchor.Fit,
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
};
|
2018-01-31 15:10:38 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
using (categoryPanel.LayoutLock())
|
2018-01-14 10:13:42 -08:00
|
|
|
|
{
|
2018-06-24 08:54:44 -07:00
|
|
|
|
// Loop over all groups in this tab and add their content
|
|
|
|
|
|
bool hasVisibleSection = false;
|
2018-01-14 10:13:42 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
foreach (var group in category.Groups)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (group.Name == "Connection")
|
|
|
|
|
|
{
|
|
|
|
|
|
categoryPanel.AddChild(
|
|
|
|
|
|
this.CreateOemProfileInfoRow());
|
|
|
|
|
|
}
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
2019-01-05 10:38:33 -08:00
|
|
|
|
var groupSection = this.CreateGroupSection(group, errors);
|
2018-02-08 15:42:07 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
groupSection.Name = group.Name + " Panel";
|
2018-04-04 12:02:25 -07:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
if (groupSection.Descendants<SliceSettingsRow>().Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
categoryPanel.AddChild(groupSection);
|
|
|
|
|
|
}
|
2018-04-04 12:02:25 -07:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
hasVisibleSection = hasVisibleSection || groupSection.Checkbox.Checked;
|
|
|
|
|
|
}
|
2018-01-31 15:10:38 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
if (!hasVisibleSection
|
|
|
|
|
|
&& categoryPanel.Children.OfType<SectionWidget>().FirstOrDefault() is SectionWidget sectionWidget)
|
2018-01-31 15:10:38 -08:00
|
|
|
|
{
|
2018-06-24 08:54:44 -07:00
|
|
|
|
sectionWidget.Checkbox.Checked = true;
|
|
|
|
|
|
}
|
2015-04-16 18:08:43 -07:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
if (categoryPanel.Descendants<SliceSettingsRow>().Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
this.AddTab(
|
|
|
|
|
|
new ToolTab(
|
2018-09-07 14:49:26 -07:00
|
|
|
|
category.Name,
|
2018-06-24 08:54:44 -07:00
|
|
|
|
category.Name.Localize(),
|
|
|
|
|
|
this,
|
|
|
|
|
|
categoryPanel,
|
|
|
|
|
|
theme,
|
|
|
|
|
|
hasClose: false,
|
|
|
|
|
|
pointSize: theme.DefaultFontSize)
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = category.Name + " Tab",
|
|
|
|
|
|
InactiveTabColor = Color.Transparent,
|
2018-11-03 09:50:09 -07:00
|
|
|
|
ActiveTabColor = theme.BackgroundColor
|
2018-06-24 08:54:44 -07:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-01-14 10:36:05 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
categoryPanel.PerformLayout();
|
|
|
|
|
|
}
|
2018-01-14 10:36:05 -08:00
|
|
|
|
|
2021-01-05 17:55:52 -08:00
|
|
|
|
if (settingsSection.Name == "Slice Simple"
|
|
|
|
|
|
&& UserSettings.Instance.get(UserSettingsKey.SliceSettingsMoreClicked) != "true")
|
|
|
|
|
|
{
|
2021-01-06 08:50:36 -08:00
|
|
|
|
var button = new TextButton("More".Localize(), theme, 8)
|
2021-01-05 17:55:52 -08:00
|
|
|
|
{
|
2021-02-25 18:13:49 -08:00
|
|
|
|
VAnchor = VAnchor.Center,
|
2021-01-05 17:55:52 -08:00
|
|
|
|
BackgroundColor = new Color(theme.AccentMimimalOverlay, 50),
|
2021-01-06 08:50:36 -08:00
|
|
|
|
ToolTipText = "Open Settings View Options".Localize()
|
2021-01-05 17:55:52 -08:00
|
|
|
|
};
|
2021-02-25 18:13:49 -08:00
|
|
|
|
theme.MakeRoundedButton(button, theme.PrimaryAccentColor);
|
2021-01-05 17:55:52 -08:00
|
|
|
|
|
2021-01-06 11:55:34 -08:00
|
|
|
|
bool menuWasOpenOnMoreDown = false;
|
|
|
|
|
|
button.MouseDown += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.TabBar.RightAnchorItem is OverflowBar.OverflowMenuButton menuButton)
|
|
|
|
|
|
{
|
|
|
|
|
|
menuWasOpenOnMoreDown = menuButton.MenuVisible;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2021-01-05 17:55:52 -08:00
|
|
|
|
button.Click += (s, e) =>
|
|
|
|
|
|
{
|
2021-01-06 11:55:34 -08:00
|
|
|
|
if (!menuWasOpenOnMoreDown)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.TabBar.RightAnchorItem.InvokeClick();
|
|
|
|
|
|
}
|
2021-01-05 17:55:52 -08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
this.TabBar.AddChild(button);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
this.TabBar.AddChild(new HorizontalSpacer());
|
2018-01-14 10:36:05 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
var searchButton = theme.CreateSearchButton();
|
|
|
|
|
|
searchButton.Click += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
filteredItemsHeading.Visible = false;
|
2020-07-18 13:48:38 -07:00
|
|
|
|
settingsNameEdit.TextEditWidget.Visible = true;
|
2018-01-14 10:36:05 -08:00
|
|
|
|
|
2020-07-18 13:48:38 -07:00
|
|
|
|
settingsNameEdit.Visible = true;
|
|
|
|
|
|
settingsNameEdit.TextEditWidget.Focus();
|
2018-06-24 08:54:44 -07:00
|
|
|
|
this.TabBar.Visible = false;
|
|
|
|
|
|
};
|
2018-01-21 21:07:14 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
this.TabBar.AddChild(searchButton);
|
2018-01-21 21:07:14 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
searchButton.VAnchor = VAnchor.Center;
|
2015-04-16 18:08:43 -07:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
searchButton.VAnchorChanged += (s, e) => Console.WriteLine();
|
|
|
|
|
|
|
|
|
|
|
|
// Restore the last selected tab
|
2020-12-30 10:35:47 -08:00
|
|
|
|
this.SelectedTabKey = UserSettings.Instance.get(databaseMRUKey);
|
2018-01-18 17:59:24 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
// Store the last selected tab on change
|
|
|
|
|
|
this.ActiveTabChanged += (s, e) =>
|
2018-01-18 17:59:24 -08:00
|
|
|
|
{
|
2018-06-24 08:54:44 -07:00
|
|
|
|
if (settingsContext.IsPrimarySettingsView)
|
|
|
|
|
|
{
|
2020-12-30 10:35:47 -08:00
|
|
|
|
UserSettings.Instance.set(databaseMRUKey, this.SelectedTabKey);
|
2018-06-24 08:54:44 -07:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2018-11-16 08:44:56 -08:00
|
|
|
|
// Register listeners
|
2018-11-12 17:20:59 -08:00
|
|
|
|
printer.Settings.SettingChanged += Printer_SettingChanged;
|
2018-06-24 08:54:44 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.PerformLayout();
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
2018-01-21 21:07:14 -08:00
|
|
|
|
private void ExtendOverflowMenu(PopupMenu popupMenu)
|
|
|
|
|
|
{
|
2020-12-30 10:35:47 -08:00
|
|
|
|
var menu = popupMenu.CreateMenuItem("View Just My Settings".Localize());
|
|
|
|
|
|
menu.ToolTipText = "Show all settings that are not the printer default".Localize();
|
|
|
|
|
|
menu.Click += (s, e) =>
|
2018-01-21 21:07:14 -08:00
|
|
|
|
{
|
2020-11-08 07:18:15 -08:00
|
|
|
|
switch (settingsContext.ViewFilter)
|
|
|
|
|
|
{
|
|
|
|
|
|
case NamedSettingsLayers.All:
|
|
|
|
|
|
this.FilterToOverrides(printer.Settings.DefaultLayerCascade);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case NamedSettingsLayers.Material:
|
|
|
|
|
|
this.FilterToOverrides(printer.Settings.MaterialLayerCascade);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case NamedSettingsLayers.Quality:
|
|
|
|
|
|
this.FilterToOverrides(printer.Settings.QualityLayerCascade);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2018-01-21 21:07:14 -08:00
|
|
|
|
};
|
|
|
|
|
|
|
2020-12-30 14:44:24 -08:00
|
|
|
|
if (settingsContext.ViewFilter == NamedSettingsLayers.All)
|
2020-12-30 10:35:47 -08:00
|
|
|
|
{
|
|
|
|
|
|
popupMenu.CreateSeparator();
|
2020-12-28 17:50:04 -08:00
|
|
|
|
|
2021-01-05 17:55:52 -08:00
|
|
|
|
void SetDetail(string level, bool changingTo)
|
2020-12-28 17:50:04 -08:00
|
|
|
|
{
|
2020-12-30 10:35:47 -08:00
|
|
|
|
UiThread.RunOnIdle(() =>
|
2020-12-28 17:50:04 -08:00
|
|
|
|
{
|
2021-01-05 17:55:52 -08:00
|
|
|
|
if (changingTo)
|
2020-12-28 17:50:04 -08:00
|
|
|
|
{
|
2020-12-30 10:35:47 -08:00
|
|
|
|
UserSettings.Instance.set(UserSettingsKey.SliceSettingsViewDetail, level);
|
2020-12-30 14:44:24 -08:00
|
|
|
|
ApplicationController.Instance.ReloadSettings(printer);
|
2021-01-05 17:55:52 -08:00
|
|
|
|
UserSettings.Instance.set(UserSettingsKey.SliceSettingsMoreClicked, "true");
|
2020-12-30 10:35:47 -08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-12-28 17:50:04 -08:00
|
|
|
|
|
2021-01-05 17:55:52 -08:00
|
|
|
|
int GetMenuIndex()
|
|
|
|
|
|
{
|
|
|
|
|
|
switch(UserSettings.Instance.get(UserSettingsKey.SliceSettingsViewDetail))
|
2020-12-31 16:50:45 -08:00
|
|
|
|
{
|
2021-01-05 17:55:52 -08:00
|
|
|
|
case "Simple":
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
case "Intermediate":
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
|
|
case "Advanced":
|
|
|
|
|
|
return 2;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var menuItem = popupMenu.CreateBoolMenuItem("Simple".Localize(),
|
|
|
|
|
|
() => GetMenuIndex() == 0,
|
2020-12-30 10:35:47 -08:00
|
|
|
|
(value) => SetDetail("Simple", value));
|
2020-12-30 14:44:24 -08:00
|
|
|
|
menuItem.ToolTipText = "Show only the most important settings";
|
2020-12-30 10:35:47 -08:00
|
|
|
|
|
2020-12-30 14:44:24 -08:00
|
|
|
|
menuItem = popupMenu.CreateBoolMenuItem("Intermediate".Localize(),
|
2021-01-05 17:55:52 -08:00
|
|
|
|
() => GetMenuIndex() == 1,
|
2020-12-30 10:35:47 -08:00
|
|
|
|
(value) => SetDetail("Intermediate", value));
|
2020-12-30 14:44:24 -08:00
|
|
|
|
menuItem.ToolTipText = "Show commonly changed settings";
|
2020-12-30 10:35:47 -08:00
|
|
|
|
|
2020-12-30 14:44:24 -08:00
|
|
|
|
menuItem = popupMenu.CreateBoolMenuItem("Advanced".Localize(),
|
2021-01-05 17:55:52 -08:00
|
|
|
|
() => GetMenuIndex() == 2,
|
2020-12-30 10:35:47 -08:00
|
|
|
|
(value) => SetDetail("Advanced", value));
|
2020-12-30 14:44:24 -08:00
|
|
|
|
menuItem.ToolTipText = "Show all available settings";
|
2020-12-30 10:35:47 -08:00
|
|
|
|
}
|
2020-12-28 17:50:04 -08:00
|
|
|
|
|
2018-01-21 21:07:14 -08:00
|
|
|
|
externalExtendMenu?.Invoke(popupMenu);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-14 10:13:42 -08:00
|
|
|
|
public Dictionary<string, UIField> UIFields => allUiFields;
|
|
|
|
|
|
|
2019-01-06 13:22:53 -08:00
|
|
|
|
public SectionWidget CreateGroupSection(SettingsLayout.Group group, List<ValidationError> errors)
|
2017-12-27 10:15:35 -08:00
|
|
|
|
{
|
|
|
|
|
|
var groupPanel = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
|
|
|
|
|
{
|
|
|
|
|
|
VAnchor = VAnchor.Fit,
|
2018-01-03 22:25:25 -08:00
|
|
|
|
HAnchor = HAnchor.Stretch,
|
2018-01-14 10:13:42 -08:00
|
|
|
|
Padding = new BorderDouble(6, 4, 6, 0),
|
|
|
|
|
|
Name = "GroupPanel" + groupPanelCount++
|
2017-12-27 10:15:35 -08:00
|
|
|
|
};
|
2018-01-03 22:25:25 -08:00
|
|
|
|
|
2018-04-04 08:47:26 -07:00
|
|
|
|
string userSettingsKey = string.Format(
|
|
|
|
|
|
"{0}_{1}_{2}",
|
|
|
|
|
|
scopeName,
|
2020-06-21 09:34:53 -07:00
|
|
|
|
NameSanitizer.Replace(group.Category.Name, ""),
|
|
|
|
|
|
NameSanitizer.Replace(group.Name, ""));
|
2018-04-04 08:47:26 -07:00
|
|
|
|
|
2018-05-17 18:22:24 -07:00
|
|
|
|
UIField uiField = null;
|
|
|
|
|
|
|
2020-11-12 07:52:34 -08:00
|
|
|
|
var sectionName = group.Name.Localize();
|
|
|
|
|
|
|
2020-12-29 18:10:27 -08:00
|
|
|
|
var sectionWidget = new SectionWidget(sectionName, groupPanel, theme, serializationKey: userSettingsKey, defaultExpansion: true, rightAlignedContent: uiField?.Content);
|
2018-04-14 20:52:35 -07:00
|
|
|
|
theme.ApplyBoxStyle(sectionWidget);
|
2018-02-09 22:51:18 -08:00
|
|
|
|
|
2018-04-13 20:25:49 -07:00
|
|
|
|
bool firstRow = true;
|
2018-04-06 15:01:07 -07:00
|
|
|
|
GuiWidget settingsRow = null;
|
|
|
|
|
|
|
2020-06-21 09:34:53 -07:00
|
|
|
|
var presetsView = settingsContext.ViewFilter == NamedSettingsLayers.Material || settingsContext.ViewFilter == NamedSettingsLayers.Quality;
|
2019-04-15 15:27:25 -07:00
|
|
|
|
var ignoredPresets = new HashSet<string> { SettingsKey.temperature2, SettingsKey.temperature3 };
|
2019-03-19 13:10:47 -07:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
using (groupPanel.LayoutLock())
|
2017-12-27 07:49:43 -08:00
|
|
|
|
{
|
2020-06-21 13:41:37 -07:00
|
|
|
|
// Add SettingRows for subgroup
|
|
|
|
|
|
foreach (SliceSettingData settingData in group.Settings)
|
2017-12-27 07:49:43 -08:00
|
|
|
|
{
|
2020-06-21 13:41:37 -07:00
|
|
|
|
// Note: tab sections may disappear if / when they are empty, as controlled by:
|
|
|
|
|
|
// settingShouldBeShown / addedSettingToSubGroup / needToAddSubGroup
|
|
|
|
|
|
bool settingShouldBeShown = !(presetsView && ignoredPresets.Contains(settingData.SlicerConfigName))
|
|
|
|
|
|
&& CheckIfShouldBeShown(settingData, settingsContext);
|
|
|
|
|
|
|
|
|
|
|
|
if (printer.Settings.IsActive(settingData.SlicerConfigName)
|
|
|
|
|
|
&& settingShouldBeShown)
|
2018-04-11 16:03:22 -07:00
|
|
|
|
{
|
2020-06-21 13:41:37 -07:00
|
|
|
|
settingsRow = CreateItemRow(settingData, errors);
|
2018-04-11 16:03:22 -07:00
|
|
|
|
|
2020-06-21 13:41:37 -07:00
|
|
|
|
if (firstRow)
|
2018-04-14 10:21:47 -07:00
|
|
|
|
{
|
2020-06-21 13:41:37 -07:00
|
|
|
|
// First row needs top and bottom border
|
|
|
|
|
|
settingsRow.Border = new BorderDouble(0, 1);
|
2018-06-24 08:54:44 -07:00
|
|
|
|
|
2020-06-21 13:41:37 -07:00
|
|
|
|
firstRow = false;
|
|
|
|
|
|
}
|
2018-04-11 16:03:22 -07:00
|
|
|
|
|
2020-06-21 13:41:37 -07:00
|
|
|
|
this.settingsRows.Add((settingsRow, settingData));
|
2018-01-14 10:36:05 -08:00
|
|
|
|
|
2020-06-21 13:41:37 -07:00
|
|
|
|
groupPanel.AddChild(settingsRow);
|
2018-04-14 10:21:47 -07:00
|
|
|
|
}
|
2017-12-27 07:49:43 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
groupPanel.PerformLayout();
|
|
|
|
|
|
|
2018-04-06 15:01:07 -07:00
|
|
|
|
// Hide border on last item in group
|
|
|
|
|
|
if (settingsRow != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
settingsRow.BorderColor = Color.Transparent;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-14 10:21:47 -07:00
|
|
|
|
return sectionWidget;
|
2017-12-27 07:49:43 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-11-18 17:43:09 -08:00
|
|
|
|
public override void OnLoad(EventArgs args)
|
|
|
|
|
|
{
|
|
|
|
|
|
systemWindow = this.Parents<SystemWindow>().FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
base.OnLoad(args);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-14 10:13:42 -08:00
|
|
|
|
private static bool CheckIfShouldBeShown(SliceSettingData settingData, SettingsContext settingsContext)
|
2016-08-11 16:09:45 -07:00
|
|
|
|
{
|
2017-08-28 11:27:38 +03:00
|
|
|
|
bool settingShouldBeShown = settingsContext.ParseShowString(settingData.ShowIfSet);
|
2017-09-03 18:28:15 +03:00
|
|
|
|
if (settingsContext.ViewFilter == NamedSettingsLayers.Material || settingsContext.ViewFilter == NamedSettingsLayers.Quality)
|
2016-06-08 09:25:20 -07:00
|
|
|
|
{
|
2016-06-08 11:18:53 -07:00
|
|
|
|
if (!settingData.ShowAsOverride)
|
2016-06-08 09:25:20 -07:00
|
|
|
|
{
|
|
|
|
|
|
settingShouldBeShown = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-20 11:53:08 -07:00
|
|
|
|
return settingShouldBeShown;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-08-28 11:27:38 +03:00
|
|
|
|
// Creates an information row showing the base OEM profile and its create_date value
|
2018-01-14 10:13:42 -08:00
|
|
|
|
public GuiWidget CreateOemProfileInfoRow()
|
2016-07-15 11:52:06 -07:00
|
|
|
|
{
|
|
|
|
|
|
var dataArea = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
|
|
|
|
|
{
|
2017-08-07 15:47:27 -07:00
|
|
|
|
HAnchor = HAnchor.Stretch,
|
2016-07-15 11:52:06 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
2017-08-28 11:27:38 +03:00
|
|
|
|
if (isPrimarySettingsView)
|
2016-07-18 14:59:14 -07:00
|
|
|
|
{
|
2017-02-28 15:56:10 -08:00
|
|
|
|
// OEM_LAYER_DATE:
|
|
|
|
|
|
string lastUpdateTime = "March 1, 2016";
|
2018-10-05 09:24:57 -07:00
|
|
|
|
if (printer.Settings?.OemLayer != null)
|
2016-07-28 16:37:24 -07:00
|
|
|
|
{
|
2018-10-05 09:24:57 -07:00
|
|
|
|
string fromCreatedDate = printer.Settings.OemLayer.ValueOrDefault(SettingsKey.created_date);
|
2017-02-28 15:56:10 -08:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(fromCreatedDate))
|
|
|
|
|
|
{
|
|
|
|
|
|
DateTime time = Convert.ToDateTime(fromCreatedDate).ToLocalTime();
|
|
|
|
|
|
lastUpdateTime = time.ToString("MMMM d, yyyy h:mm tt");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch
|
2016-07-28 16:37:24 -07:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-02-28 15:56:10 -08:00
|
|
|
|
|
|
|
|
|
|
var row = new FlowLayoutWidget()
|
2016-07-28 16:37:24 -07:00
|
|
|
|
{
|
2018-10-13 17:58:54 -07:00
|
|
|
|
BackgroundColor = theme.SlightShade,
|
2017-02-28 15:56:10 -08:00
|
|
|
|
Padding = new BorderDouble(5),
|
|
|
|
|
|
Margin = new BorderDouble(3, 20, 3, 0),
|
2017-09-07 21:04:21 -07:00
|
|
|
|
HAnchor = HAnchor.Stretch,
|
2017-02-28 15:56:10 -08:00
|
|
|
|
};
|
|
|
|
|
|
|
2017-09-17 01:11:18 -07:00
|
|
|
|
string make = settingsContext.GetValue(SettingsKey.make);
|
|
|
|
|
|
string model = settingsContext.GetValue(SettingsKey.model);
|
2017-02-28 15:56:10 -08:00
|
|
|
|
|
|
|
|
|
|
string title = $"{make} {model}";
|
|
|
|
|
|
if (title == "Other Other")
|
2016-07-28 16:37:24 -07:00
|
|
|
|
{
|
2017-02-28 15:56:10 -08:00
|
|
|
|
title = "Custom Profile".Localize();
|
2016-07-28 16:37:24 -07:00
|
|
|
|
}
|
2016-07-18 14:59:14 -07:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
using (row.LayoutLock())
|
2017-02-28 15:56:10 -08:00
|
|
|
|
{
|
2018-06-24 08:54:44 -07:00
|
|
|
|
row.AddChild(new TextWidget(title, pointSize: 9)
|
|
|
|
|
|
{
|
|
|
|
|
|
Margin = new BorderDouble(0, 4, 10, 4),
|
2018-11-03 09:13:07 -07:00
|
|
|
|
TextColor = theme.TextColor,
|
2018-06-24 08:54:44 -07:00
|
|
|
|
});
|
2016-07-28 12:19:30 -07:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
row.AddChild(new HorizontalSpacer());
|
2017-02-28 15:56:10 -08:00
|
|
|
|
|
2018-06-24 08:54:44 -07:00
|
|
|
|
row.AddChild(new TextWidget(lastUpdateTime, pointSize: 9)
|
|
|
|
|
|
{
|
|
|
|
|
|
Margin = new BorderDouble(0, 4, 10, 4),
|
2018-11-03 09:13:07 -07:00
|
|
|
|
TextColor = theme.TextColor,
|
2018-06-24 08:54:44 -07:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
row.PerformLayout();
|
2017-02-28 15:56:10 -08:00
|
|
|
|
|
|
|
|
|
|
dataArea.AddChild(row);
|
|
|
|
|
|
}
|
2016-07-15 11:52:06 -07:00
|
|
|
|
|
|
|
|
|
|
return dataArea;
|
|
|
|
|
|
}
|
2018-01-14 10:13:42 -08:00
|
|
|
|
|
2019-01-05 10:38:33 -08:00
|
|
|
|
internal GuiWidget CreateItemRow(SliceSettingData settingData, List<ValidationError> errors)
|
2017-12-11 22:22:56 -08:00
|
|
|
|
{
|
2019-01-05 10:38:33 -08:00
|
|
|
|
return CreateItemRow(settingData, settingsContext, printer, theme, ref tabIndexForItem, allUiFields, errors);
|
2017-12-11 22:22:56 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-01-05 10:38:33 -08:00
|
|
|
|
public static GuiWidget CreateItemRow(SliceSettingData settingData, SettingsContext settingsContext, PrinterConfig printer, ThemeConfig theme, ref int tabIndexForItem, Dictionary<string, UIField> fieldCache = null, List<ValidationError> errors = null)
|
2016-04-18 11:31:31 -07:00
|
|
|
|
{
|
2017-08-28 11:27:38 +03:00
|
|
|
|
string sliceSettingValue = settingsContext.GetValue(settingData.SlicerConfigName);
|
2016-04-26 17:15:10 -07:00
|
|
|
|
|
2017-09-13 06:59:30 -07:00
|
|
|
|
UIField uiField = null;
|
2016-05-07 21:05:53 -07:00
|
|
|
|
|
2017-09-04 23:49:05 +03:00
|
|
|
|
bool useDefaultSavePattern = true;
|
2017-09-13 06:10:24 -07:00
|
|
|
|
bool placeFieldInDedicatedRow = false;
|
2017-09-04 23:49:05 +03:00
|
|
|
|
|
2018-04-06 09:05:43 -07:00
|
|
|
|
bool fullRowSelect = settingData.DataEditType == SliceSettingData.DataEditTypes.CHECK_BOX;
|
2018-04-12 08:42:10 -07:00
|
|
|
|
var settingsRow = new SliceSettingsRow(printer, settingsContext, settingData, theme, fullRowSelect: fullRowSelect);
|
2017-08-29 14:03:02 +03:00
|
|
|
|
|
2020-09-01 18:07:34 -07:00
|
|
|
|
void UpdateStyle(object s, StringEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.Data == settingData.SlicerConfigName)
|
|
|
|
|
|
{
|
|
|
|
|
|
settingsRow.UpdateStyle();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
printer.Settings.SettingChanged += UpdateStyle;
|
|
|
|
|
|
|
|
|
|
|
|
settingsRow.Closed += (s, e) => printer.Settings.SettingChanged -= UpdateStyle;
|
|
|
|
|
|
|
2018-04-06 14:50:53 -07:00
|
|
|
|
switch (settingData.DataEditType)
|
2016-04-18 11:31:31 -07:00
|
|
|
|
{
|
2018-04-06 14:50:53 -07:00
|
|
|
|
case SliceSettingData.DataEditTypes.INT:
|
2018-01-13 11:38:46 -08:00
|
|
|
|
|
2018-10-14 20:05:37 -07:00
|
|
|
|
var intField = new IntField(theme);
|
2018-04-06 14:50:53 -07:00
|
|
|
|
uiField = intField;
|
2018-01-13 11:38:46 -08:00
|
|
|
|
|
2018-04-06 14:50:53 -07:00
|
|
|
|
if (settingData.SlicerConfigName == "extruder_count")
|
|
|
|
|
|
{
|
|
|
|
|
|
intField.MaxValue = 4;
|
|
|
|
|
|
intField.MinValue = 0;
|
|
|
|
|
|
}
|
2018-01-13 11:38:46 -08:00
|
|
|
|
|
2018-04-06 14:50:53 -07:00
|
|
|
|
break;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
2018-04-06 14:50:53 -07:00
|
|
|
|
case SliceSettingData.DataEditTypes.DOUBLE:
|
|
|
|
|
|
case SliceSettingData.DataEditTypes.OFFSET:
|
2018-10-14 20:05:37 -07:00
|
|
|
|
uiField = new DoubleField(theme);
|
2018-04-06 14:50:53 -07:00
|
|
|
|
break;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
2019-07-01 16:58:17 -07:00
|
|
|
|
case SliceSettingData.DataEditTypes.SLICE_ENGINE:
|
|
|
|
|
|
uiField = new SliceEngineField(printer, theme);
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
2021-01-28 18:06:29 -08:00
|
|
|
|
case SliceSettingData.DataEditTypes.COLOR:
|
|
|
|
|
|
uiField = new ColorField(theme);
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
2018-04-06 14:50:53 -07:00
|
|
|
|
case SliceSettingData.DataEditTypes.POSITIVE_DOUBLE:
|
|
|
|
|
|
if (settingData.SetSettingsOnChange.Count > 0)
|
|
|
|
|
|
{
|
2018-10-14 20:05:37 -07:00
|
|
|
|
uiField = new BoundDoubleField(settingsContext, settingData, theme);
|
2018-04-06 14:50:53 -07:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2018-10-14 20:05:37 -07:00
|
|
|
|
uiField = new PositiveDoubleField(theme);
|
2018-09-07 20:27:09 -07:00
|
|
|
|
}
|
2020-06-21 09:34:53 -07:00
|
|
|
|
|
2018-04-06 14:50:53 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case SliceSettingData.DataEditTypes.DOUBLE_OR_PERCENT:
|
2018-10-14 20:05:37 -07:00
|
|
|
|
uiField = new DoubleOrPercentField(theme);
|
2018-04-06 14:50:53 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case SliceSettingData.DataEditTypes.INT_OR_MM:
|
2018-10-14 20:05:37 -07:00
|
|
|
|
uiField = new IntOrMmField(theme);
|
2018-04-06 14:50:53 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case SliceSettingData.DataEditTypes.CHECK_BOX:
|
2018-04-12 08:42:10 -07:00
|
|
|
|
uiField = new ToggleboxField(theme);
|
2018-04-06 14:50:53 -07:00
|
|
|
|
useDefaultSavePattern = false;
|
|
|
|
|
|
uiField.ValueChanged += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.UserInitiated)
|
2017-09-01 12:25:19 +03:00
|
|
|
|
{
|
2018-04-13 12:38:40 -07:00
|
|
|
|
ICheckbox checkbox = uiField.Content as ICheckbox;
|
2020-06-21 09:34:53 -07:00
|
|
|
|
string checkedKey = checkbox.Checked ? "OnValue" : "OffValue";
|
2018-04-13 12:38:40 -07:00
|
|
|
|
|
2018-04-06 14:50:53 -07:00
|
|
|
|
// Linked settings should be updated in all cases (user clicked checkbox, user clicked clear)
|
|
|
|
|
|
foreach (var setSettingsData in settingData.SetSettingsOnChange)
|
2017-09-01 12:25:19 +03:00
|
|
|
|
{
|
2018-04-13 12:38:40 -07:00
|
|
|
|
if (setSettingsData.TryGetValue(checkedKey, out string targetValue))
|
2018-04-06 14:50:53 -07:00
|
|
|
|
{
|
2018-04-13 12:38:40 -07:00
|
|
|
|
settingsContext.SetValue(setSettingsData["TargetSetting"], targetValue);
|
2017-09-01 12:25:19 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
2018-04-06 14:50:53 -07:00
|
|
|
|
// Store actual field value
|
|
|
|
|
|
settingsContext.SetValue(settingData.SlicerConfigName, uiField.Value);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
2018-07-18 09:40:06 -07:00
|
|
|
|
case SliceSettingData.DataEditTypes.READONLY_STRING:
|
2018-07-18 19:17:11 -07:00
|
|
|
|
uiField = new ReadOnlyTextField(theme);
|
2018-07-18 09:40:06 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
2018-04-06 14:50:53 -07:00
|
|
|
|
case SliceSettingData.DataEditTypes.STRING:
|
|
|
|
|
|
case SliceSettingData.DataEditTypes.WIDE_STRING:
|
2018-10-14 20:05:37 -07:00
|
|
|
|
uiField = new TextField(theme);
|
2018-04-06 14:50:53 -07:00
|
|
|
|
break;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
2018-04-06 14:50:53 -07:00
|
|
|
|
case SliceSettingData.DataEditTypes.MULTI_LINE_TEXT:
|
2018-10-14 20:05:37 -07:00
|
|
|
|
uiField = new MultilineStringField(theme);
|
2018-04-06 14:50:53 -07:00
|
|
|
|
placeFieldInDedicatedRow = true;
|
|
|
|
|
|
break;
|
2017-09-12 15:35:38 -07:00
|
|
|
|
|
2018-07-20 00:11:27 -07:00
|
|
|
|
case SliceSettingData.DataEditTypes.MARKDOWN_TEXT:
|
|
|
|
|
|
uiField = new MarkdownEditField(theme, settingData.PresentationName);
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
2018-04-06 14:50:53 -07:00
|
|
|
|
case SliceSettingData.DataEditTypes.COM_PORT:
|
|
|
|
|
|
useDefaultSavePattern = false;
|
|
|
|
|
|
sliceSettingValue = printer.Settings.Helpers.ComPort();
|
|
|
|
|
|
uiField = new ComPortField(printer, theme);
|
|
|
|
|
|
uiField.ValueChanged += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.UserInitiated)
|
2017-09-04 13:19:20 +03:00
|
|
|
|
{
|
2018-04-06 14:50:53 -07:00
|
|
|
|
printer.Settings.Helpers.SetComPort(uiField.Value);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
break;
|
2016-05-02 16:10:20 -07:00
|
|
|
|
|
2018-04-06 14:50:53 -07:00
|
|
|
|
case SliceSettingData.DataEditTypes.LIST:
|
|
|
|
|
|
{
|
2021-02-20 16:41:45 -08:00
|
|
|
|
var items = settingData.ListValues.Split(',');
|
|
|
|
|
|
ListField listField;
|
|
|
|
|
|
uiField = listField = new ListField(theme);
|
|
|
|
|
|
foreach (var item in items)
|
|
|
|
|
|
{
|
|
|
|
|
|
listField.Items.Add((item, item.Localize()));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case SliceSettingData.DataEditTypes.EXTRUDER_LIST:
|
|
|
|
|
|
{
|
|
|
|
|
|
var extruderCount = printer.Settings.GetValue<int>(SettingsKey.extruder_count);
|
|
|
|
|
|
ListField listField;
|
|
|
|
|
|
uiField = listField = new ListField(theme);
|
|
|
|
|
|
var list = listField.Items;
|
|
|
|
|
|
list.Add(("0", "Default".Localize()));
|
|
|
|
|
|
for (int i = 1; i <= extruderCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
list.Add(($"{i}", "Extruder".Localize() + $" {i}"));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-04-06 14:50:53 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case SliceSettingData.DataEditTypes.HARDWARE_PRESENT:
|
2018-04-12 08:42:10 -07:00
|
|
|
|
uiField = new ToggleboxField(theme);
|
2018-04-06 14:50:53 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case SliceSettingData.DataEditTypes.VECTOR2:
|
2018-10-14 20:05:37 -07:00
|
|
|
|
uiField = new Vector2Field(theme);
|
2018-04-06 14:50:53 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
2018-12-03 14:58:31 -08:00
|
|
|
|
case SliceSettingData.DataEditTypes.VECTOR3:
|
|
|
|
|
|
uiField = new Vector3Field(theme);
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
2019-04-11 15:56:19 -07:00
|
|
|
|
case SliceSettingData.DataEditTypes.VECTOR4:
|
|
|
|
|
|
uiField = new Vector4Field(theme);
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case SliceSettingData.DataEditTypes.BOUNDS:
|
|
|
|
|
|
uiField = new BoundsField(theme);
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
2018-12-03 14:58:31 -08:00
|
|
|
|
case SliceSettingData.DataEditTypes.OFFSET3:
|
2019-04-02 15:17:58 -07:00
|
|
|
|
if (settingData.SlicerConfigName == "extruder_offset")
|
|
|
|
|
|
{
|
|
|
|
|
|
placeFieldInDedicatedRow = true;
|
2020-07-05 11:26:35 -07:00
|
|
|
|
uiField = new ExtruderOffsetField(printer, settingsContext, theme);
|
2019-04-02 15:17:58 -07:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
uiField = new Vector3Field(theme);
|
|
|
|
|
|
}
|
2020-06-21 09:34:53 -07:00
|
|
|
|
|
2018-04-06 14:50:53 -07:00
|
|
|
|
break;
|
2017-12-23 18:49:31 -08:00
|
|
|
|
#if !__ANDROID__
|
2018-04-06 14:50:53 -07:00
|
|
|
|
case SliceSettingData.DataEditTypes.IP_LIST:
|
2018-07-12 09:22:28 -07:00
|
|
|
|
uiField = new IpAddessField(printer, theme);
|
2018-04-06 14:50:53 -07:00
|
|
|
|
break;
|
2017-12-23 18:49:31 -08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
2018-04-06 14:50:53 -07:00
|
|
|
|
default:
|
|
|
|
|
|
// Missing Setting
|
|
|
|
|
|
settingsRow.AddContent(new TextWidget($"Missing the setting for '{settingData.DataEditType}'.")
|
|
|
|
|
|
{
|
2018-11-03 09:13:07 -07:00
|
|
|
|
TextColor = theme.TextColor,
|
2018-04-06 14:50:53 -07:00
|
|
|
|
BackgroundColor = Color.Red
|
|
|
|
|
|
});
|
|
|
|
|
|
break;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
2014-07-26 13:43:55 -07:00
|
|
|
|
|
2017-08-30 00:55:13 -07:00
|
|
|
|
if (uiField != null)
|
|
|
|
|
|
{
|
2017-12-11 22:22:56 -08:00
|
|
|
|
if (fieldCache != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
fieldCache[settingData.SlicerConfigName] = uiField;
|
|
|
|
|
|
}
|
2017-08-30 00:55:13 -07:00
|
|
|
|
|
2017-11-02 12:10:06 -07:00
|
|
|
|
uiField.HelpText = settingData.HelpText;
|
|
|
|
|
|
|
2017-09-14 14:47:08 -07:00
|
|
|
|
uiField.Name = $"{settingData.PresentationName} Field";
|
2017-08-30 00:55:13 -07:00
|
|
|
|
uiField.Initialize(tabIndexForItem++);
|
|
|
|
|
|
|
2018-01-18 17:03:05 -08:00
|
|
|
|
if (settingData.DataEditType == SliceSettingData.DataEditTypes.WIDE_STRING)
|
|
|
|
|
|
{
|
|
|
|
|
|
uiField.Content.HAnchor = HAnchor.Stretch;
|
|
|
|
|
|
placeFieldInDedicatedRow = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-04 23:49:05 +03:00
|
|
|
|
uiField.SetValue(sliceSettingValue, userInitiated: false);
|
2017-08-30 00:55:13 -07:00
|
|
|
|
|
2018-12-12 14:30:26 -08:00
|
|
|
|
// Disable ToolTipText on UIFields in favor of popovers
|
|
|
|
|
|
uiField.Content.ToolTipText = "";
|
|
|
|
|
|
|
2018-07-27 18:05:21 -07:00
|
|
|
|
// make sure the undo data goes back to the initial value after a change
|
2020-07-11 09:19:41 -07:00
|
|
|
|
uiField.ClearUndoHistory();
|
2018-07-27 17:06:19 -07:00
|
|
|
|
|
2017-09-01 12:25:19 +03:00
|
|
|
|
uiField.ValueChanged += (s, e) =>
|
|
|
|
|
|
{
|
2017-09-04 23:49:05 +03:00
|
|
|
|
if (useDefaultSavePattern
|
|
|
|
|
|
&& e.UserInitiated)
|
|
|
|
|
|
{
|
|
|
|
|
|
settingsContext.SetValue(settingData.SlicerConfigName, uiField.Value);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-01 12:25:19 +03:00
|
|
|
|
settingsRow.UpdateStyle();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2017-08-30 00:55:13 -07:00
|
|
|
|
// After initializing the field, wrap with dropmenu if applicable
|
2020-12-16 11:20:13 -08:00
|
|
|
|
if (settingData.QuickMenuSettings.Count > 0)
|
2018-01-31 16:01:16 -08:00
|
|
|
|
{
|
2018-11-11 13:22:32 -08:00
|
|
|
|
var dropMenu = new DropMenuWrappedField(uiField, settingData, theme.TextColor, theme, printer);
|
2018-01-31 16:01:16 -08:00
|
|
|
|
dropMenu.Initialize(tabIndexForItem);
|
|
|
|
|
|
|
|
|
|
|
|
settingsRow.AddContent(dropMenu.Content);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2017-09-13 06:10:24 -07:00
|
|
|
|
{
|
|
|
|
|
|
if (!placeFieldInDedicatedRow)
|
|
|
|
|
|
{
|
|
|
|
|
|
settingsRow.AddContent(uiField.Content);
|
2018-04-06 09:05:43 -07:00
|
|
|
|
settingsRow.ActionWidget = uiField.Content;
|
2017-09-13 06:10:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-08-30 00:55:13 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-01-05 10:38:33 -08:00
|
|
|
|
settingsRow.UIField = uiField;
|
|
|
|
|
|
uiField.Row = settingsRow;
|
|
|
|
|
|
|
|
|
|
|
|
if (errors?.Any() == true)
|
|
|
|
|
|
{
|
|
|
|
|
|
settingsRow.UpdateValidationState(errors);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-18 11:31:31 -07:00
|
|
|
|
// Invoke the UpdateStyle implementation
|
2016-05-07 21:05:53 -07:00
|
|
|
|
settingsRow.UpdateStyle();
|
2016-04-26 17:15:10 -07:00
|
|
|
|
|
2017-11-16 09:56:16 -08:00
|
|
|
|
bool settingEnabled = settingsContext.ParseShowString(settingData.EnableIfSet);
|
|
|
|
|
|
if (settingEnabled
|
2018-01-14 10:13:42 -08:00
|
|
|
|
|| settingsContext.ViewFilter == NamedSettingsLayers.Material
|
2017-11-16 09:56:16 -08:00
|
|
|
|
|| settingsContext.ViewFilter == NamedSettingsLayers.Quality)
|
2017-09-04 10:52:56 +03:00
|
|
|
|
{
|
2017-09-13 06:10:24 -07:00
|
|
|
|
if (placeFieldInDedicatedRow)
|
|
|
|
|
|
{
|
2017-09-13 18:18:11 -07:00
|
|
|
|
var column = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
2017-09-13 06:10:24 -07:00
|
|
|
|
{
|
2017-09-13 18:18:11 -07:00
|
|
|
|
Name = "column",
|
2017-09-13 06:10:24 -07:00
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
VAnchor = VAnchor.Fit
|
|
|
|
|
|
};
|
2017-09-13 18:18:11 -07:00
|
|
|
|
column.AddChild(settingsRow);
|
2017-09-13 06:10:24 -07:00
|
|
|
|
|
2017-09-13 18:18:11 -07:00
|
|
|
|
var row = new FlowLayoutWidget()
|
2017-09-13 06:10:24 -07:00
|
|
|
|
{
|
2017-09-13 18:18:11 -07:00
|
|
|
|
Name = "row",
|
2017-09-13 06:10:24 -07:00
|
|
|
|
VAnchor = VAnchor.Fit,
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
2017-11-17 17:46:58 -08:00
|
|
|
|
MinimumSize = new Vector2(0, 28),
|
2017-11-17 17:07:04 -08:00
|
|
|
|
BackgroundColor = settingsRow.BackgroundColor,
|
2017-11-17 17:46:58 -08:00
|
|
|
|
Border = settingsRow.Border,
|
|
|
|
|
|
Padding = settingsRow.Padding,
|
|
|
|
|
|
Margin = settingsRow.Margin,
|
2017-09-13 06:10:24 -07:00
|
|
|
|
};
|
2017-09-13 18:18:11 -07:00
|
|
|
|
column.AddChild(row);
|
2017-09-13 06:10:24 -07:00
|
|
|
|
|
2017-09-13 18:18:11 -07:00
|
|
|
|
var contentWrapper = new GuiWidget
|
2017-09-13 06:10:24 -07:00
|
|
|
|
{
|
2017-09-13 18:18:11 -07:00
|
|
|
|
Name = "contentWrapper",
|
2017-09-13 06:10:24 -07:00
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
VAnchor = VAnchor.Fit,
|
2018-07-20 00:11:27 -07:00
|
|
|
|
Padding = new BorderDouble(bottom: 10),
|
2017-09-13 06:10:24 -07:00
|
|
|
|
};
|
2017-09-13 18:18:11 -07:00
|
|
|
|
contentWrapper.AddChild(uiField.Content);
|
2017-09-13 06:10:24 -07:00
|
|
|
|
|
2017-09-13 18:18:11 -07:00
|
|
|
|
row.AddChild(contentWrapper);
|
2017-09-13 06:10:24 -07:00
|
|
|
|
|
2017-09-13 18:18:11 -07:00
|
|
|
|
return column;
|
2017-09-13 06:10:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return settingsRow;
|
|
|
|
|
|
}
|
2017-09-04 10:52:56 +03:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2017-08-02 15:19:32 -07:00
|
|
|
|
{
|
2018-01-14 10:36:05 -08:00
|
|
|
|
settingsRow.Enabled = false;
|
|
|
|
|
|
return settingsRow;
|
2017-09-14 08:55:30 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-11-08 07:18:15 -08:00
|
|
|
|
public void FilterToOverrides(IEnumerable<PrinterSettingsLayer> layers)
|
2018-01-14 10:36:05 -08:00
|
|
|
|
{
|
|
|
|
|
|
foreach (var item in this.settingsRows)
|
|
|
|
|
|
{
|
2020-11-08 07:18:15 -08:00
|
|
|
|
item.widget.Visible = printer.Settings.IsOverride(item.settingData.SlicerConfigName, layers);
|
2018-01-14 10:36:05 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
filteredItemsHeading.Visible = true;
|
2020-07-18 13:48:38 -07:00
|
|
|
|
settingsNameEdit.TextEditWidget.Visible = false;
|
2018-01-14 10:36:05 -08:00
|
|
|
|
this.TabBar.Visible = false;
|
2020-07-18 13:48:38 -07:00
|
|
|
|
settingsNameEdit.Visible = true;
|
2018-01-14 10:36:05 -08:00
|
|
|
|
|
|
|
|
|
|
this.ShowFilteredView();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-06-21 09:34:53 -07:00
|
|
|
|
private readonly List<SectionWidget> widgetsThatWereExpanded = new List<SectionWidget>();
|
2018-11-18 17:43:09 -08:00
|
|
|
|
private SystemWindow systemWindow;
|
2018-01-31 15:10:38 -08:00
|
|
|
|
|
2018-12-20 12:38:05 -08:00
|
|
|
|
private void Printer_SettingChanged(object s, StringEventArgs stringEvent)
|
2018-11-16 08:44:56 -08:00
|
|
|
|
{
|
2019-01-28 17:10:12 -08:00
|
|
|
|
var errors = printer.ValidateSettings(settingsContext);
|
2019-01-05 10:38:33 -08:00
|
|
|
|
|
2018-12-20 12:38:05 -08:00
|
|
|
|
if (stringEvent != null)
|
2018-11-16 08:44:56 -08:00
|
|
|
|
{
|
|
|
|
|
|
string settingsKey = stringEvent.Data;
|
|
|
|
|
|
if (this.allUiFields.TryGetValue(settingsKey, out UIField uifield))
|
|
|
|
|
|
{
|
|
|
|
|
|
string currentValue = settingsContext.GetValue(settingsKey);
|
|
|
|
|
|
if (uifield.Value != currentValue
|
|
|
|
|
|
|| settingsKey == "com_port")
|
|
|
|
|
|
{
|
|
|
|
|
|
uifield.SetValue(
|
|
|
|
|
|
currentValue,
|
|
|
|
|
|
userInitiated: false);
|
|
|
|
|
|
}
|
2019-01-05 10:38:33 -08:00
|
|
|
|
|
2019-01-16 09:05:04 -08:00
|
|
|
|
// Some fields are hosted outside of SettingsRows (e.g. Section Headers like Brim) and should skip validation updates
|
|
|
|
|
|
uifield.Row?.UpdateValidationState(errors);
|
2018-11-16 08:44:56 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-14 10:36:05 -08:00
|
|
|
|
private void ShowFilteredView()
|
|
|
|
|
|
{
|
2018-01-31 15:10:38 -08:00
|
|
|
|
widgetsThatWereExpanded.Clear();
|
2019-06-10 11:57:22 -07:00
|
|
|
|
|
2018-01-14 10:36:05 -08:00
|
|
|
|
// Show any section with visible SliceSettingsRows
|
|
|
|
|
|
foreach (var section in this.Descendants<SectionWidget>())
|
|
|
|
|
|
{
|
|
|
|
|
|
// HACK: Include parent visibility in mix as complex fields that return wrapped SliceSettingsRows will be visible and their parent will be hidden
|
|
|
|
|
|
section.Visible = section.Descendants<SliceSettingsRow>().Any(row => row.Visible && row.Parent.Visible);
|
2018-01-31 15:10:38 -08:00
|
|
|
|
if (!section.Checkbox.Checked)
|
|
|
|
|
|
{
|
|
|
|
|
|
widgetsThatWereExpanded.Add(section);
|
|
|
|
|
|
section.Checkbox.Checked = true;
|
|
|
|
|
|
}
|
2018-01-14 10:36:05 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Show all tab containers
|
|
|
|
|
|
foreach (var tab in this.AllTabs)
|
|
|
|
|
|
{
|
|
|
|
|
|
tab.TabContent.Visible = true;
|
|
|
|
|
|
}
|
2019-06-10 11:57:22 -07:00
|
|
|
|
|
|
|
|
|
|
// Pull focus after filter
|
|
|
|
|
|
this.Focus();
|
2018-01-14 10:36:05 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-08-23 16:44:11 -07:00
|
|
|
|
public override void OnClosed(EventArgs e)
|
2018-01-18 17:59:24 -08:00
|
|
|
|
{
|
2018-11-16 08:44:56 -08:00
|
|
|
|
// Unregister listeners
|
|
|
|
|
|
printer.Settings.SettingChanged -= Printer_SettingChanged;
|
|
|
|
|
|
|
2018-01-18 17:59:24 -08:00
|
|
|
|
base.OnClosed(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-14 10:36:05 -08:00
|
|
|
|
public void ClearFilter()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var item in this.settingsRows)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Show matching items
|
|
|
|
|
|
item.widget.Visible = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var tab in this.AllTabs)
|
|
|
|
|
|
{
|
2020-06-21 09:34:53 -07:00
|
|
|
|
tab.TabContent.Visible = tab == this.ActiveTab;
|
2018-01-14 10:36:05 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var section in this.Descendants<SectionWidget>())
|
|
|
|
|
|
{
|
|
|
|
|
|
// HACK: Include parent visibility in mix as complex fields that return wrapped SliceSettingsRows will be visible and their parent will be hidden
|
|
|
|
|
|
section.Visible = section.Descendants<SliceSettingsRow>().Any(row => row.Visible && row.Parent.Visible);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-31 15:10:38 -08:00
|
|
|
|
foreach (var section in widgetsThatWereExpanded)
|
|
|
|
|
|
{
|
|
|
|
|
|
section.Checkbox.Checked = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-14 10:36:05 -08:00
|
|
|
|
this.TabBar.Visible = true;
|
|
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
2016-08-10 15:18:03 -07:00
|
|
|
|
}
|