Merge pull request #3593 from jlewin/master

Clean up whitespace
This commit is contained in:
Lars Brubaker 2018-08-03 14:26:39 -07:00 committed by GitHub
commit eb0131d16f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 367 additions and 73 deletions

View file

@ -763,7 +763,6 @@ namespace MatterHackers.MatterControl
},
iconCollector: (theme) => AggContext.StaticData.LoadIcon(Path.Combine("ViewTransformControls", "rotate.png"), 16, 16, theme.InvertIcons));
#if DEBUG // when this is working (Component and ComponentPicker work), enable it.
this.Graph.RegisterOperation(
typeof(IObject3D),
typeof(ComponentObject3D),
@ -806,7 +805,33 @@ namespace MatterHackers.MatterControl
&& sceneItem.DescendantsAndSelf().All(d => !(d is ComponentObject3D));
},
iconCollector: (theme) => AggContext.StaticData.LoadIcon("scale_32x32.png", 16, 16, theme.InvertIcons));
#endif
this.Graph.RegisterOperation(
typeof(IObject3D),
typeof(ComponentObject3D),
"Edit Component".Localize(),
(sceneItem, scene) =>
{
if (sceneItem is ComponentObject3D componentObject)
{
// Enable editing mode
componentObject.Finalized = false;
// Force editor rebuild
scene.SelectedItem = null;
scene.SelectedItem = componentObject;
}
return Task.CompletedTask;
},
isVisible: (sceneItem) =>
{
return sceneItem.Parent.Parent == null
&& sceneItem is ComponentObject3D componentObject
&& componentObject.Finalized;
},
iconCollector: (theme) => AggContext.StaticData.LoadIcon("scale_32x32.png", 16, 16, theme.InvertIcons));
this.Graph.RegisterOperation(
typeof(IObject3D),

View file

@ -38,12 +38,12 @@ namespace MatterHackers.MatterControl
public ConfigurePrinterWidget(SettingsContext settingsContext, PrinterConfig printer, ThemeConfig theme)
: base(FlowDirection.TopToBottom)
{
var inlineTitleEdit = new InlineTitleEdit(printer.Settings.GetValue(SettingsKey.printer_name), theme, "Printer Name", boldFont: true);
inlineTitleEdit.TitleChanged += (s, e) =>
var inlineNameEdit = new InlineStringEdit(printer.Settings.GetValue(SettingsKey.printer_name), theme, "Printer Name", boldFont: true);
inlineNameEdit.ValueChanged += (s, e) =>
{
printer.Settings.SetValue(SettingsKey.printer_name, inlineTitleEdit.Text);
printer.Settings.SetValue(SettingsKey.printer_name, inlineNameEdit.Text);
};
this.AddChild(inlineTitleEdit);
this.AddChild(inlineNameEdit);
this.AddChild(
new SliceSettingsTabView(

View file

@ -34,7 +34,7 @@ using MatterHackers.Localizations;
namespace MatterHackers.MatterControl.CustomWidgets
{
public class InlineListItemEdit : InlineTitleEdit
public class InlineListItemEdit : InlineStringEdit
{
public event EventHandler ItemDeleted;

View file

@ -38,9 +38,9 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.CustomWidgets
{
public class InlineTitleEdit : Toolbar
public class InlineStringEdit : Toolbar
{
public event EventHandler TitleChanged;
public event EventHandler ValueChanged;
private TextWidget titleText;
protected FlowLayoutWidget rightPanel;
@ -48,14 +48,14 @@ namespace MatterHackers.MatterControl.CustomWidgets
private GuiWidget saveButton;
private SearchInputBox searchPanel;
public InlineTitleEdit(string title, ThemeConfig theme, string automationName, bool boldFont = false)
public InlineStringEdit(string stringValue, ThemeConfig theme, string automationName, bool boldFont = false)
: base(theme)
{
this.Padding = theme.ToolbarPadding;
this.HAnchor = HAnchor.Stretch;
this.VAnchor = VAnchor.Fit;
titleText = new TextWidget(title, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: theme.DefaultFontSize, bold: boldFont)
titleText = new TextWidget(stringValue, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: theme.DefaultFontSize, bold: boldFont)
{
VAnchor = VAnchor.Center,
AutoExpandBoundsToText = true,
@ -83,7 +83,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
{
this.Text = searchPanel.Text;
this.SetVisibility(showEditPanel: false);
this.TitleChanged?.Invoke(this, null);
this.ValueChanged?.Invoke(this, null);
};
searchPanel.searchInput.Name = automationName + " Field";
@ -105,8 +105,15 @@ namespace MatterHackers.MatterControl.CustomWidgets
};
editButton.Click += (s, e) =>
{
searchPanel.Text = this.Text;
this.SetVisibility(showEditPanel: true);
if (this.EditOverride != null)
{
this.EditOverride.Invoke(this, null);
}
else
{
searchPanel.Text = this.Text;
this.SetVisibility(showEditPanel: true);
}
};
rightPanel.AddChild(editButton);
@ -114,7 +121,6 @@ namespace MatterHackers.MatterControl.CustomWidgets
{
this.Text = searchPanel.Text;
this.SetVisibility(showEditPanel: false);
this.TitleChanged?.Invoke(this, null);
};
rightPanel.AddChild(saveButton);
@ -123,6 +129,8 @@ namespace MatterHackers.MatterControl.CustomWidgets
this.ActionArea.Margin = this.ActionArea.Margin.Clone(right: rightPanel.Width + 5);
}
public event EventHandler EditOverride;
public override string Text
{
get => titleText.Text;
@ -131,6 +139,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
if (titleText.Text != value)
{
titleText.Text = value;
this.ValueChanged?.Invoke(this, null);
}
}
}

View file

@ -45,7 +45,6 @@ namespace MatterHackers.MatterControl.CustomWidgets
: base (FlowDirection.TopToBottom)
{
this.HAnchor = HAnchor.Absolute;
this.Cursor = Cursors.HSplit;
this.SplitterHeight = theme.SplitterWidth;
this.SpliterBarColor = theme.SplitterBackground;
}
@ -80,7 +79,8 @@ namespace MatterHackers.MatterControl.CustomWidgets
public override void OnMouseDown(MouseEventArgs mouseEvent)
{
if (mouseEvent.Position.Y < this.SplitterHeight)
if (mouseEvent.Position.Y <= this.LocalBounds.Bottom + this.SplitterHeight
&& mouseEvent.Position.Y >= this.LocalBounds.Bottom)
{
mouseDownOnBar = true;
mouseDownY = TransformToScreenSpace(mouseEvent.Position).Y;
@ -99,6 +99,26 @@ namespace MatterHackers.MatterControl.CustomWidgets
Height = downHeight + mouseDownY - currentMouseY;
});
}
var currentCursor = this.Cursor;
if (mouseEvent.Position.Y <= this.LocalBounds.Bottom + this.SplitterHeight
&& mouseEvent.Position.Y >= this.LocalBounds.Bottom)
{
this.Cursor = Cursors.HSplit;
}
else
{
this.Cursor = Cursors.Default;
}
if (this.FirstWidgetUnderMouse
&& this.Cursor != currentCursor)
{
this.SetCursor(this.Cursor);
}
base.OnMouseMove(mouseEvent);
}

View file

@ -27,8 +27,6 @@ of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
using MatterHackers.Agg.UI;
using MatterHackers.MatterControl.PluginSystem;
using System;
using System.Collections.Generic;
using System.Text;
@ -77,7 +75,7 @@ namespace MatterHackers.MatterControl.Plugins.BrailleBuilder
{
string numConversion = ("#" + converted);
foreach(TextMapping keyValue in numberMappngs)
foreach (TextMapping keyValue in numberMappngs)
{
numConversion = numConversion.Replace(keyValue.Key, keyValue.Value);
}
@ -93,10 +91,8 @@ namespace MatterHackers.MatterControl.Plugins.BrailleBuilder
}
}
if(converted[0] != '#')
{
if (converted[0] != '#')
{
// put in commas before capitals
converted = Regex.Replace(converted, "([A-Z])", ",$1");
converted = converted.ToLower();
@ -123,12 +119,12 @@ namespace MatterHackers.MatterControl.Plugins.BrailleBuilder
}
// do the replacements that must come after other characters
string tempBeforeLastCharacter = converted.Substring(0,converted.Length-1);
string tempBeforeLastCharacter = converted.Substring(0, converted.Length - 1);
foreach (TextMapping keyValue in beforeTextMappings)
{
if (tempBeforeLastCharacter.Contains(keyValue.Key))
{
converted = tempBeforeLastCharacter.Replace(keyValue.Key, keyValue.Value) + converted[converted.Length-1];
converted = tempBeforeLastCharacter.Replace(keyValue.Key, keyValue.Value) + converted[converted.Length - 1];
tempBeforeLastCharacter = converted.Substring(0, converted.Length - 1);
}
}
@ -150,7 +146,7 @@ namespace MatterHackers.MatterControl.Plugins.BrailleBuilder
{
if (tempMiddleCharacters.Contains(keyValue.Key))
{
converted = converted.Substring(0, 1) + tempMiddleCharacters.Replace(keyValue.Key, keyValue.Value) + converted.Substring(converted.Length-1, 1);
converted = converted.Substring(0, 1) + tempMiddleCharacters.Replace(keyValue.Key, keyValue.Value) + converted.Substring(converted.Length - 1, 1);
}
}
}
@ -171,7 +167,7 @@ namespace MatterHackers.MatterControl.Plugins.BrailleBuilder
}
private static bool compareStringIgnoringPunctuation(string possiblyPunctuatedString, string targetExactMatch)
{
{
string punctuationStrippedString = possiblyPunctuatedString;
if (Char.IsPunctuation(punctuationStrippedString[0]))
@ -184,7 +180,6 @@ namespace MatterHackers.MatterControl.Plugins.BrailleBuilder
punctuationStrippedString = punctuationStrippedString.TrimEnd(punctuationStrippedString[punctuationStrippedString.Length - 1]);
}
return punctuationStrippedString == targetExactMatch;
}
@ -224,7 +219,7 @@ namespace MatterHackers.MatterControl.Plugins.BrailleBuilder
finalString.Append(" ");
skipSpace = false;
}
skipSpace = checkSkipSpace(word, wordIndex != numWords?words[wordIndex]: null);
skipSpace = checkSkipSpace(word, wordIndex != numWords ? words[wordIndex] : null);
finalString.Append(ConvertWord(word, wordIndex == numWords));
first = false;
@ -238,7 +233,7 @@ namespace MatterHackers.MatterControl.Plugins.BrailleBuilder
private static bool checkSkipSpace(string word, string nextWord)
{
bool skipSpace = false;
if(nextWord != null)
if (nextWord != null)
{
foreach (TextMapping keyValue in beforeWordsMappings)
{
@ -248,36 +243,36 @@ namespace MatterHackers.MatterControl.Plugins.BrailleBuilder
}
}
if(skipSpace)//Special Case: The word 'for' only skips if followed by the word 'the'
{
skipSpace = word != "for"|| nextWord == "the";
if (skipSpace)//Special Case: The word 'for' only skips if followed by the word 'the'
{
skipSpace = word != "for" || nextWord == "the";
}
}
}
return skipSpace;
}
private static void ConvertMappingStringToList()
{
string[] conversions = BrailleGrade2Mapping.mappingTable.Split('\n');
string[] conversions = BrailleGrade2Mapping.mappingTable.Split('\n');
foreach(string inLine in conversions)
foreach (string inLine in conversions)
{
string line = inLine.Replace("\r", "").Trim();
if(line != null && line.Length>0)
if (line != null && line.Length > 0)
{
string[] keyConversionPair = line.Split(' ');
if(keyConversionPair.Length == 2 && keyConversionPair[0] != null && keyConversionPair[0].Length > 0 && keyConversionPair[1] != null && keyConversionPair[1].Length >0)
if (keyConversionPair.Length == 2 && keyConversionPair[0] != null && keyConversionPair[0].Length > 0 && keyConversionPair[1] != null && keyConversionPair[1].Length > 0)
{
if(keyConversionPair[0] != "//")
if (keyConversionPair[0] != "//")
{
TextMapping mapping = new TextMapping(keyConversionPair[0],keyConversionPair[1]);
TextMapping mapping = new TextMapping(keyConversionPair[0], keyConversionPair[1]);
if(IsNumeric(mapping.Key))
if (IsNumeric(mapping.Key))
{
numberMappngs.Add(mapping);
}
else if(mapping.Key == mapping.Key.ToUpper())//if in all caps it is an exact match
}
else if (mapping.Key == mapping.Key.ToUpper())//if in all caps it is an exact match
{
mapping.Key = mapping.Key.ToLower();
if (mapping.Key.Contains("*"))
@ -297,26 +292,26 @@ namespace MatterHackers.MatterControl.Plugins.BrailleBuilder
{
exactTextMappings.Add(mapping);
}
}
else if(mapping.Key[0] == '+' && mapping.Key[mapping.Key.Length-1] == '+')//check between
else if (mapping.Key[0] == '+' && mapping.Key[mapping.Key.Length - 1] == '+')//check between
{
mapping.Key = mapping.Key.Trim('+');
betweenTextMappings.Add(mapping);
}
else if (mapping.Key[0] == '+')
else if (mapping.Key[0] == '+')
{
mapping.Key = mapping.Key.Trim('+');
afterTextMappings.Add(mapping);
}
else if(mapping.Key[mapping.Key.Length-1] == '+')
else if (mapping.Key[mapping.Key.Length - 1] == '+')
{
mapping.Key = mapping.Key.Trim('+');
beforeTextMappings.Add(mapping);
}
else if(mapping.Key.Contains("*"))
{
if(mapping.Key[0] == '*')
else if (mapping.Key.Contains("*"))
{
if (mapping.Key[0] == '*')
{
mapping.Key = mapping.Key.Trim('*');
postWordPunctuationMappings.Add(mapping);
@ -326,7 +321,7 @@ namespace MatterHackers.MatterControl.Plugins.BrailleBuilder
mapping.Key = mapping.Key.Trim('*');
beforeWordsMappings.Add(mapping);
}
}
else//if not a special type then it is an anyPositionMapping
{
@ -336,21 +331,19 @@ namespace MatterHackers.MatterControl.Plugins.BrailleBuilder
}
}
}
}
private static bool IsNumeric(string p)
{
{
bool isNumeric = true;
for(int i = 0; i < p.Length && isNumeric; i++)
for (int i = 0; i < p.Length && isNumeric; i++)
{
char current = p[i];
isNumeric = (Char.IsNumber(current) || char.IsPunctuation(current)) && current != '*';
}
return isNumeric;
}
}
}

View file

@ -313,9 +313,12 @@ namespace MatterHackers.MatterControl.DesignTools
rowContainer = CreateSettingsColumn(property, field);
}
#if !__ANDROID__
else if (propertyValue is List<string> stringList)
{
var field = new ListStringField(theme);
var selectedItem = ApplicationController.Instance.DragDropData.SceneContext.Scene.SelectedItem;
var field = new SurfacedEditorsField(theme, selectedItem);
field.Initialize(0);
field.ListValue = stringList;
field.ValueChanged += (s, e) =>
@ -327,6 +330,7 @@ namespace MatterHackers.MatterControl.DesignTools
rowContainer.Descendants<HorizontalSpacer>().FirstOrDefault()?.Close();
}
#endif
else if (propertyValue is Vector3 vector3)
{
var field = new Vector3Field();

View file

@ -86,6 +86,7 @@
<Compile Include="ConfigurationPage\PrintLeveling\LevelingWizard.cs" />
<Compile Include="CustomWidgets\HelpArticleHeader.cs" />
<Compile Include="CustomWidgets\InlineListItemEdit.cs" />
<Compile Include="CustomWidgets\InlineStringEdit.cs" />
<Compile Include="CustomWidgets\LinkLabel.cs" />
<Compile Include="CustomWidgets\ResizeContainer\BottomResizeContainer.cs" />
<Compile Include="CustomWidgets\ResizeContainer\LeftResizeContainer.cs" />
@ -201,7 +202,6 @@
<Compile Include="DesignTools\Attributes\UnlockLinkAttribute.cs" />
<Compile Include="Library\Providers\FileSystem\McxContainer.cs" />
<Compile Include="Library\Providers\GraphConfig.cs" />
<Compile Include="CustomWidgets\InlineTitleEdit.cs" />
<Compile Include="Library\DynamicContentStore.cs" />
<Compile Include="Library\InMemoryLibraryItem.cs" />
<Compile Include="DesignTools\LithophaneObject3D.cs" />
@ -284,6 +284,8 @@
<Compile Include="SlicerConfiguration\UIFields\IconEnumField.cs" />
<Compile Include="SlicerConfiguration\UIFields\IpAddessField.cs" />
<Compile Include="SlicerConfiguration\UIFields\MarkdownEditField.cs" />
<Compile Include="SlicerConfiguration\UIFields\SurfacedEditorPage.cs" />
<Compile Include="SlicerConfiguration\UIFields\SurfacedEditorsField.cs" />
<Compile Include="SlicerConfiguration\UIFields\Vector3Field.cs" />
<Compile Include="Utilities\MarkdigAgg\AggCodeBlockRenderer.cs" />
<Compile Include="Utilities\MarkdigAgg\AggHeadingRenderer.cs" />

View file

@ -82,12 +82,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
contentRow.BackgroundColor = Color.Transparent;
var inlineTitleEdit = new InlineTitleEdit(presetsContext.PersistenceLayer.Name, theme, presetsContext.LayerType.ToString() + " Name", boldFont: true);
inlineTitleEdit.TitleChanged += (s, e) =>
var inlineNameEdit = new InlineStringEdit(presetsContext.PersistenceLayer.Name, theme, presetsContext.LayerType.ToString() + " Name", boldFont: true);
inlineNameEdit.ValueChanged += (s, e) =>
{
printer.Settings.SetValue(SettingsKey.layer_name, inlineTitleEdit.Text, presetsContext.PersistenceLayer);
printer.Settings.SetValue(SettingsKey.layer_name, inlineNameEdit.Text, presetsContext.PersistenceLayer);
};
contentRow.AddChild(inlineTitleEdit);
contentRow.AddChild(inlineNameEdit);
var sliceSettingsWidget = CreateSliceSettingsWidget(printer, presetsContext.PersistenceLayer);
contentRow.AddChild(sliceSettingsWidget);
@ -97,7 +97,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
UiThread.RunOnIdle(() =>
{
string sanitizedName = numberMatch.Replace(inlineTitleEdit.Text, "").Trim();
string sanitizedName = numberMatch.Replace(inlineNameEdit.Text, "").Trim();
string newProfileName = agg_basics.GetNonCollidingName(sanitizedName, presetsContext.PresetLayers.Select(preset => preset.ValueOrDefault(SettingsKey.layer_name)));
var clonedLayer = presetsContext.PersistenceLayer.Clone();
@ -111,7 +111,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
sliceSettingsWidget = CreateSliceSettingsWidget(printer, clonedLayer);
contentRow.AddChild(sliceSettingsWidget);
inlineTitleEdit.Text = newProfileName;
inlineNameEdit.Text = newProfileName;
});
};
this.AddPageAction(duplicateButton);

View file

@ -261,7 +261,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
ActiveSliceSettings.Instance.SetValue("boolean_operations", mergeRules);
var matrixAndMeshArgs = new StringBuilder(); ;
var matrixAndMeshArgs = new StringBuilder();
foreach (var matrixAndFile in stlFileLocations)
{
var matrixString = "";

View file

@ -27,13 +27,12 @@ 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;
using System.Linq;
using MatterHackers.Agg;
using MatterHackers.Agg.Platform;
using MatterHackers.Agg.UI;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.SlicerConfiguration
{
@ -48,15 +47,13 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
public override void Initialize(int tabIndex)
{
var column = new FlowLayoutWidget(FlowDirection.TopToBottom)
this.Content = new FlowLayoutWidget(FlowDirection.TopToBottom)
{
Margin = new BorderDouble(20, 0, 0, 0),
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Fit,
};
this.Content = column;
base.Initialize(tabIndex);
}
@ -72,7 +69,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
}
}
private void Rebuild()
protected virtual void Rebuild()
{
this.Content.CloseAllChildren();
@ -84,7 +81,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
var localIndex = i;
inlineEdit.TitleChanged += (s, e) =>
inlineEdit.ValueChanged += (s, e) =>
{
_list[localIndex] = inlineEdit.Text;
};

View file

@ -0,0 +1,163 @@
/*
Copyright (c) 2018, 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 System.Linq;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.DataConverters3D;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.MatterControl.DesignTools;
using MatterHackers.MatterControl.PartPreviewWindow;
namespace MatterHackers.MatterControl.SlicerConfiguration
{
public class SurfacedEditorPage : DialogPage
{
public event EventHandler ValueChanged;
private MHTextEditWidget editWidget;
public SurfacedEditorPage(IObject3D selectedItem)
{
this.WindowTitle = "MatterControl - " + "Editor Selector".Localize();
this.HeaderText = "Surfaced Editor".Localize();
var tabControl = new SimpleTabs(theme, new GuiWidget())
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Stretch,
};
tabControl.TabBar.BackgroundColor = theme.TabBarBackground;
tabControl.TabBar.Padding = 0;
contentRow.AddChild(tabControl);
contentRow.Padding = 0;
var editContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Stretch,
Padding = theme.DefaultContainerPadding,
BackgroundColor = theme.ActiveTabColor
};
editWidget = new MHTextEditWidget("", multiLine: true)
{
HAnchor = HAnchor.Stretch,
Name = this.Name
};
editWidget.DrawFromHintedCache();
editContainer.AddChild(editWidget);
// add the tree view
var treeView = new TreeView(theme)
{
Margin = new BorderDouble(left: 18),
};
treeView.AfterSelect += (s, e) =>
{
if (treeView.SelectedNode.Tag is IObject3D contextNode)
{
editWidget.Text = "$." + string.Join(".", contextNode.AncestorsAndSelf().TakeWhile(o => !(o is ComponentObject3D)).Select(o => $"Children<{o.GetType().Name.ToString()}>").Reverse().ToArray());
}
};
treeView.ScrollArea.ChildAdded += (s, e) =>
{
if (e is GuiWidgetEventArgs childEventArgs
&& childEventArgs.Child is TreeNode treeNode)
{
treeNode.AlwaysExpandable = true;
}
};
treeView.Click += (s, e) =>
{
if (treeView.IsDoubleClick(e))
{
Console.WriteLine();
}
};
treeView.ScrollArea.CloseAllChildren();
var rootNode = Object3DTreeBuilder.BuildTree(selectedItem, theme);
treeView.AddChild(rootNode);
rootNode.TreeView = treeView;
editContainer.AddChild(treeView);
var dummyWidget = new GuiWidget()
{
BackgroundColor = Color.Red
};
var editTab = new ToolTab("Edit".Localize(), tabControl, editContainer, theme, hasClose: false)
{
Name = "Edit Tab"
};
tabControl.AddTab(editTab);
var previewTab = new ToolTab("Preview".Localize(), tabControl, dummyWidget, theme, hasClose: false)
{
Name = "Preview Tab"
};
tabControl.AddTab(previewTab);
tabControl.ActiveTabChanged += (s, e) =>
{
if (tabControl.SelectedTabIndex == 1)
{
// dummyWidget.Markdown = editWidget.Text;
}
};
tabControl.SelectedTabIndex = 0;
var saveButton = theme.CreateDialogButton("Save".Localize());
saveButton.Click += (s, e) =>
{
this.ValueChanged?.Invoke(this, null);
this.DialogWindow.CloseOnIdle();
};
this.AddPageAction(saveButton);
}
public string EditorString
{
get => editWidget.Text;
set
{
editWidget.Text = value;
}
}
}
}

View file

@ -0,0 +1,75 @@
/*
Copyright (c) 2018, 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;
using MatterHackers.DataConverters3D;
using MatterHackers.MatterControl.CustomWidgets;
namespace MatterHackers.MatterControl.SlicerConfiguration
{
public class SurfacedEditorsField : ListStringField
{
private IObject3D selectedItem;
public SurfacedEditorsField(ThemeConfig theme, IObject3D selectedItem)
: base(theme)
{
this.selectedItem = selectedItem;
}
protected override void Rebuild()
{
base.Rebuild();
foreach(var inlineEdit in this.Content.Children<InlineListItemEdit>())
{
inlineEdit.EditOverride += InlineEdit_EditOverride;
}
}
private void InlineEdit_EditOverride(object sender, EventArgs e)
{
if (sender is InlineStringEdit inlineEdit)
{
var editorPage = new SurfacedEditorPage(selectedItem)
{
EditorString = inlineEdit.Text,
};
editorPage.ValueChanged += (s, e2) =>
{
inlineEdit.Text = editorPage.EditorString;
};
DialogWindow.Show(editorPage);
}
}
}
}

View file

@ -404,6 +404,12 @@ namespace MatterControl.Tests.MatterControl
Assert.Fail();
}
[Test, Ignore("Not Implemented")]
public async Task SurfacedEditorsFieldTest()
{
Assert.Fail();
}
public class ValueMap
{
[DebuggerStepThrough]