From 393db7ba79ebe5ad853265becf0a64cfd39e6588 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Tue, 5 Sep 2017 07:01:37 -0700 Subject: [PATCH] Remove ISettingsField type --- MatterControl.csproj | 3 +- SlicerConfiguration/SliceSettingsWidget.cs | 32 +-------- .../{ISettingsField.cs => IUIField.cs} | 10 --- SlicerConfiguration/UIFields/StringField.cs | 65 ------------------- 4 files changed, 4 insertions(+), 106 deletions(-) rename SlicerConfiguration/UIFields/{ISettingsField.cs => IUIField.cs} (89%) delete mode 100644 SlicerConfiguration/UIFields/StringField.cs diff --git a/MatterControl.csproj b/MatterControl.csproj index 67505a558..e362e551b 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -302,11 +302,10 @@ - - + diff --git a/SlicerConfiguration/SliceSettingsWidget.cs b/SlicerConfiguration/SliceSettingsWidget.cs index b9c8b6902..a16ce6a6b 100644 --- a/SlicerConfiguration/SliceSettingsWidget.cs +++ b/SlicerConfiguration/SliceSettingsWidget.cs @@ -75,7 +75,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration private SettingsContext settingsContext; - PrinterConnection printerConnection; + private PrinterConnection printerConnection; + + private Dictionary allUiFields = new Dictionary(); private EventHandler unregisterEvents; @@ -121,18 +123,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration if (e is StringEventArgs stringEvent) { string settingsKey = stringEvent.Data; - if (allFields.TryGetValue(settingsKey, out ISettingsField field)) - { - string currentValue = settingsContext.GetValue(settingsKey); - if (field.Value != currentValue - || settingsKey == "com_port") - { - field.Value = currentValue; - field.OnValueChanged(currentValue); - field.UpdateStyle(); - } - } - if (allUiFields.TryGetValue(settingsKey, out IUIField field2)) { string currentValue = settingsContext.GetValue(settingsKey); @@ -855,9 +845,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration ref tabIndex); } - Dictionary allFields = new Dictionary(); - Dictionary allUiFields = new Dictionary(); - private GuiWidget CreateSettingInfoUIControls( PrinterConnection printerConnection, SliceSettingData settingData, @@ -867,7 +854,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { string sliceSettingValue = settingsContext.GetValue(settingData.SlicerConfigName); - ISettingsField OLDFIELDXXXXX = null; IUIField uiField = null; bool useDefaultSavePattern = true; @@ -1017,18 +1003,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } } - if (OLDFIELDXXXXX != null) - { - allFields[settingData.SlicerConfigName] = OLDFIELDXXXXX; - - OLDFIELDXXXXX.Value = sliceSettingValue; - - settingsRow.AddContent( - OLDFIELDXXXXX.Create(settingsContext, settingData, tabIndexForItem++)); - - OLDFIELDXXXXX.UpdateStyle = settingsRow.UpdateStyle; - } - if (uiField != null) { allUiFields[settingData.SlicerConfigName] = uiField; diff --git a/SlicerConfiguration/UIFields/ISettingsField.cs b/SlicerConfiguration/UIFields/IUIField.cs similarity index 89% rename from SlicerConfiguration/UIFields/ISettingsField.cs rename to SlicerConfiguration/UIFields/IUIField.cs index 19520adcd..3894afd63 100644 --- a/SlicerConfiguration/UIFields/ISettingsField.cs +++ b/SlicerConfiguration/UIFields/IUIField.cs @@ -55,14 +55,4 @@ namespace MatterHackers.MatterControl.SlicerConfiguration GuiWidget Content { get; } } - public interface ISettingsField - { - void OnValueChanged(string text); - - Action UpdateStyle { get; set; } - - string Value { get; set; } - - GuiWidget Create(SettingsContext settingsContext, SliceSettingData settingData, int tabIndex); - } } diff --git a/SlicerConfiguration/UIFields/StringField.cs b/SlicerConfiguration/UIFields/StringField.cs deleted file mode 100644 index 95fba53a6..000000000 --- a/SlicerConfiguration/UIFields/StringField.cs +++ /dev/null @@ -1,65 +0,0 @@ -/* -Copyright (c) 2017, Lars Brubaker, John Lewin -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 MatterHackers.Agg.UI; - -namespace MatterHackers.MatterControl.SlicerConfiguration -{ - public class StringField : ISettingsField - { - private MHTextEditWidget editWidget; - - public Action UpdateStyle { get; set; } - - public string Value { get; set; } - - public GuiWidget Create(SettingsContext settingsContext, SliceSettingData settingData, int tabIndex) - { - editWidget = new MHTextEditWidget(this.Value, pixelWidth: settingData.ShowAsOverride ? 120 : 200, tabIndex: tabIndex) - { - Name = settingData.PresentationName + " Edit", - }; - editWidget.ToolTipText = settingData.HelpText; - - editWidget.ActualTextEditWidget.EditComplete += (sender, e) => - { - settingsContext.SetValue(settingData.SlicerConfigName, ((TextEditWidget)sender).Text); - this.UpdateStyle(); - }; - - return editWidget; - } - - public void OnValueChanged(string text) - { - editWidget.Text = text; - } - } -}