Added font preview to font selector
This commit is contained in:
parent
adcab0fcdd
commit
618d94e063
6 changed files with 215 additions and 75 deletions
162
MatterControl.Winforms/InspectForm.Designer.cs
generated
162
MatterControl.Winforms/InspectForm.Designer.cs
generated
|
|
@ -39,11 +39,12 @@
|
|||
this.btnApply = new System.Windows.Forms.Button();
|
||||
this.themeTreeView = new System.Windows.Forms.TreeView();
|
||||
this.btnSaveTheme = new System.Windows.Forms.Button();
|
||||
this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
|
||||
this.tabPage4 = new System.Windows.Forms.TabPage();
|
||||
this.pipelineTree = new System.Windows.Forms.TreeView();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.textBox1 = new System.Windows.Forms.TextBox();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.pipelineTree = new System.Windows.Forms.TreeView();
|
||||
this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
|
||||
this.debugMenus = new System.Windows.Forms.CheckBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
|
|
@ -59,29 +60,29 @@
|
|||
//
|
||||
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
|
||||
this.splitContainer1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.splitContainer1.Name = "splitContainer1";
|
||||
//
|
||||
// splitContainer1.Panel1
|
||||
//
|
||||
this.splitContainer1.Panel1.Controls.Add(this.debugMenus);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.debugTextWidget);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.tabControl1);
|
||||
//
|
||||
// splitContainer1.Panel2
|
||||
//
|
||||
this.splitContainer1.Panel2.Controls.Add(this.propertyGrid1);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(913, 632);
|
||||
this.splitContainer1.SplitterDistance = 608;
|
||||
this.splitContainer1.SplitterWidth = 3;
|
||||
this.splitContainer1.Size = new System.Drawing.Size(1370, 972);
|
||||
this.splitContainer1.SplitterDistance = 912;
|
||||
this.splitContainer1.TabIndex = 0;
|
||||
//
|
||||
// debugTextWidget
|
||||
//
|
||||
this.debugTextWidget.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.debugTextWidget.AutoSize = true;
|
||||
this.debugTextWidget.Location = new System.Drawing.Point(489, 3);
|
||||
this.debugTextWidget.Location = new System.Drawing.Point(738, 5);
|
||||
this.debugTextWidget.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.debugTextWidget.Name = "debugTextWidget";
|
||||
this.debugTextWidget.Size = new System.Drawing.Size(116, 17);
|
||||
this.debugTextWidget.Size = new System.Drawing.Size(167, 24);
|
||||
this.debugTextWidget.TabIndex = 2;
|
||||
this.debugTextWidget.Text = "Debug TextWidget";
|
||||
this.debugTextWidget.UseVisualStyleBackColor = true;
|
||||
|
|
@ -95,19 +96,21 @@
|
|||
this.tabControl1.Controls.Add(this.tabPage4);
|
||||
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tabControl1.Location = new System.Drawing.Point(0, 0);
|
||||
this.tabControl1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.tabControl1.Name = "tabControl1";
|
||||
this.tabControl1.SelectedIndex = 0;
|
||||
this.tabControl1.Size = new System.Drawing.Size(608, 632);
|
||||
this.tabControl1.Size = new System.Drawing.Size(912, 972);
|
||||
this.tabControl1.TabIndex = 1;
|
||||
this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged);
|
||||
//
|
||||
// tabPage1
|
||||
//
|
||||
this.tabPage1.Controls.Add(this.aggTreeView);
|
||||
this.tabPage1.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage1.Location = new System.Drawing.Point(4, 29);
|
||||
this.tabPage1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.tabPage1.Name = "tabPage1";
|
||||
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage1.Size = new System.Drawing.Size(600, 606);
|
||||
this.tabPage1.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.tabPage1.Size = new System.Drawing.Size(904, 939);
|
||||
this.tabPage1.TabIndex = 0;
|
||||
this.tabPage1.Text = "SystemWindow";
|
||||
this.tabPage1.UseVisualStyleBackColor = true;
|
||||
|
|
@ -118,10 +121,9 @@
|
|||
this.aggTreeView.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawText;
|
||||
this.aggTreeView.FullRowSelect = true;
|
||||
this.aggTreeView.HideSelection = false;
|
||||
this.aggTreeView.Location = new System.Drawing.Point(3, 3);
|
||||
this.aggTreeView.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.aggTreeView.Location = new System.Drawing.Point(4, 5);
|
||||
this.aggTreeView.Name = "aggTreeView";
|
||||
this.aggTreeView.Size = new System.Drawing.Size(594, 600);
|
||||
this.aggTreeView.Size = new System.Drawing.Size(896, 929);
|
||||
this.aggTreeView.TabIndex = 1;
|
||||
this.aggTreeView.DrawNode += new System.Windows.Forms.DrawTreeNodeEventHandler(this.AggTreeView_DrawNode);
|
||||
this.aggTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.AggTreeView_AfterSelect);
|
||||
|
|
@ -129,10 +131,11 @@
|
|||
// tabPage2
|
||||
//
|
||||
this.tabPage2.Controls.Add(this.sceneTreeView);
|
||||
this.tabPage2.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage2.Location = new System.Drawing.Point(4, 29);
|
||||
this.tabPage2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.tabPage2.Name = "tabPage2";
|
||||
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage2.Size = new System.Drawing.Size(600, 606);
|
||||
this.tabPage2.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.tabPage2.Size = new System.Drawing.Size(904, 939);
|
||||
this.tabPage2.TabIndex = 1;
|
||||
this.tabPage2.Text = "Scene";
|
||||
this.tabPage2.UseVisualStyleBackColor = true;
|
||||
|
|
@ -143,10 +146,9 @@
|
|||
this.sceneTreeView.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawText;
|
||||
this.sceneTreeView.FullRowSelect = true;
|
||||
this.sceneTreeView.HideSelection = false;
|
||||
this.sceneTreeView.Location = new System.Drawing.Point(3, 3);
|
||||
this.sceneTreeView.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.sceneTreeView.Location = new System.Drawing.Point(4, 5);
|
||||
this.sceneTreeView.Name = "sceneTreeView";
|
||||
this.sceneTreeView.Size = new System.Drawing.Size(594, 600);
|
||||
this.sceneTreeView.Size = new System.Drawing.Size(896, 929);
|
||||
this.sceneTreeView.TabIndex = 2;
|
||||
this.sceneTreeView.DrawNode += new System.Windows.Forms.DrawTreeNodeEventHandler(this.SceneTreeView_DrawNode);
|
||||
this.sceneTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.SceneTreeView_AfterSelect);
|
||||
|
|
@ -156,19 +158,21 @@
|
|||
this.tabPage3.Controls.Add(this.btnApply);
|
||||
this.tabPage3.Controls.Add(this.themeTreeView);
|
||||
this.tabPage3.Controls.Add(this.btnSaveTheme);
|
||||
this.tabPage3.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage3.Location = new System.Drawing.Point(4, 29);
|
||||
this.tabPage3.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.tabPage3.Name = "tabPage3";
|
||||
this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage3.Size = new System.Drawing.Size(600, 606);
|
||||
this.tabPage3.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.tabPage3.Size = new System.Drawing.Size(904, 939);
|
||||
this.tabPage3.TabIndex = 2;
|
||||
this.tabPage3.Text = "Theme";
|
||||
this.tabPage3.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnApply
|
||||
//
|
||||
this.btnApply.Location = new System.Drawing.Point(438, 322);
|
||||
this.btnApply.Location = new System.Drawing.Point(657, 495);
|
||||
this.btnApply.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.btnApply.Name = "btnApply";
|
||||
this.btnApply.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnApply.Size = new System.Drawing.Size(112, 35);
|
||||
this.btnApply.TabIndex = 3;
|
||||
this.btnApply.Text = "Apply";
|
||||
this.btnApply.UseVisualStyleBackColor = true;
|
||||
|
|
@ -176,89 +180,102 @@
|
|||
//
|
||||
// themeTreeView
|
||||
//
|
||||
this.themeTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.themeTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.themeTreeView.FullRowSelect = true;
|
||||
this.themeTreeView.HideSelection = false;
|
||||
this.themeTreeView.Location = new System.Drawing.Point(3, 3);
|
||||
this.themeTreeView.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.themeTreeView.Location = new System.Drawing.Point(4, 5);
|
||||
this.themeTreeView.Name = "themeTreeView";
|
||||
this.themeTreeView.Size = new System.Drawing.Size(592, 253);
|
||||
this.themeTreeView.Size = new System.Drawing.Size(886, 387);
|
||||
this.themeTreeView.TabIndex = 2;
|
||||
//
|
||||
// btnSaveTheme
|
||||
//
|
||||
this.btnSaveTheme.Location = new System.Drawing.Point(519, 322);
|
||||
this.btnSaveTheme.Location = new System.Drawing.Point(778, 495);
|
||||
this.btnSaveTheme.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.btnSaveTheme.Name = "btnSaveTheme";
|
||||
this.btnSaveTheme.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnSaveTheme.Size = new System.Drawing.Size(112, 35);
|
||||
this.btnSaveTheme.TabIndex = 0;
|
||||
this.btnSaveTheme.Text = "Save Theme";
|
||||
this.btnSaveTheme.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// propertyGrid1
|
||||
//
|
||||
this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.propertyGrid1.LineColor = System.Drawing.SystemColors.ControlDark;
|
||||
this.propertyGrid1.Location = new System.Drawing.Point(0, 0);
|
||||
this.propertyGrid1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.propertyGrid1.Name = "propertyGrid1";
|
||||
this.propertyGrid1.Size = new System.Drawing.Size(302, 632);
|
||||
this.propertyGrid1.TabIndex = 0;
|
||||
this.propertyGrid1.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyGrid1_PropertyValueChanged);
|
||||
//
|
||||
// tabPage4
|
||||
//
|
||||
this.tabPage4.Controls.Add(this.textBox1);
|
||||
this.tabPage4.Controls.Add(this.button1);
|
||||
this.tabPage4.Controls.Add(this.pipelineTree);
|
||||
this.tabPage4.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage4.Location = new System.Drawing.Point(4, 29);
|
||||
this.tabPage4.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.tabPage4.Name = "tabPage4";
|
||||
this.tabPage4.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage4.Size = new System.Drawing.Size(600, 606);
|
||||
this.tabPage4.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.tabPage4.Size = new System.Drawing.Size(904, 939);
|
||||
this.tabPage4.TabIndex = 3;
|
||||
this.tabPage4.Text = "tabPage4";
|
||||
this.tabPage4.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// pipelineTree
|
||||
// textBox1
|
||||
//
|
||||
this.pipelineTree.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.pipelineTree.FullRowSelect = true;
|
||||
this.pipelineTree.HideSelection = false;
|
||||
this.pipelineTree.Location = new System.Drawing.Point(2, 5);
|
||||
this.pipelineTree.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.pipelineTree.Name = "pipelineTree";
|
||||
this.pipelineTree.Size = new System.Drawing.Size(592, 253);
|
||||
this.pipelineTree.TabIndex = 3;
|
||||
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.textBox1.Location = new System.Drawing.Point(26, 449);
|
||||
this.textBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.textBox1.Multiline = true;
|
||||
this.textBox1.Name = "textBox1";
|
||||
this.textBox1.Size = new System.Drawing.Size(848, 406);
|
||||
this.textBox1.TabIndex = 5;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(509, 263);
|
||||
this.button1.Location = new System.Drawing.Point(764, 405);
|
||||
this.button1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||
this.button1.Size = new System.Drawing.Size(112, 35);
|
||||
this.button1.TabIndex = 4;
|
||||
this.button1.Text = "button1";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// textBox1
|
||||
// pipelineTree
|
||||
//
|
||||
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.textBox1.Location = new System.Drawing.Point(17, 292);
|
||||
this.textBox1.Multiline = true;
|
||||
this.textBox1.Name = "textBox1";
|
||||
this.textBox1.Size = new System.Drawing.Size(567, 272);
|
||||
this.textBox1.TabIndex = 5;
|
||||
this.pipelineTree.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.pipelineTree.FullRowSelect = true;
|
||||
this.pipelineTree.HideSelection = false;
|
||||
this.pipelineTree.Location = new System.Drawing.Point(3, 8);
|
||||
this.pipelineTree.Name = "pipelineTree";
|
||||
this.pipelineTree.Size = new System.Drawing.Size(886, 387);
|
||||
this.pipelineTree.TabIndex = 3;
|
||||
//
|
||||
// propertyGrid1
|
||||
//
|
||||
this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.propertyGrid1.LineColor = System.Drawing.SystemColors.ControlDark;
|
||||
this.propertyGrid1.Location = new System.Drawing.Point(0, 0);
|
||||
this.propertyGrid1.Name = "propertyGrid1";
|
||||
this.propertyGrid1.Size = new System.Drawing.Size(454, 972);
|
||||
this.propertyGrid1.TabIndex = 0;
|
||||
this.propertyGrid1.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyGrid1_PropertyValueChanged);
|
||||
//
|
||||
// debugMenus
|
||||
//
|
||||
this.debugMenus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.debugMenus.AutoSize = true;
|
||||
this.debugMenus.Location = new System.Drawing.Point(585, 5);
|
||||
this.debugMenus.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.debugMenus.Name = "debugMenus";
|
||||
this.debugMenus.Size = new System.Drawing.Size(135, 24);
|
||||
this.debugMenus.TabIndex = 3;
|
||||
this.debugMenus.Text = "Debug Menus";
|
||||
this.debugMenus.UseVisualStyleBackColor = true;
|
||||
this.debugMenus.CheckedChanged += new System.EventHandler(this.DebugMenus_CheckedChanged);
|
||||
//
|
||||
// InspectForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(913, 632);
|
||||
this.ClientSize = new System.Drawing.Size(1370, 972);
|
||||
this.Controls.Add(this.splitContainer1);
|
||||
this.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.Name = "InspectForm";
|
||||
this.Text = "InspectForm";
|
||||
this.Load += new System.EventHandler(this.InspectForm_Load);
|
||||
|
|
@ -295,5 +312,6 @@
|
|||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.TreeView pipelineTree;
|
||||
private System.Windows.Forms.TextBox textBox1;
|
||||
private System.Windows.Forms.CheckBox debugMenus;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -298,6 +298,11 @@ namespace MatterHackers.MatterControl
|
|||
this.InspectedWidget = e.Node.Tag as GuiWidget;
|
||||
}
|
||||
|
||||
private void DebugMenus_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
PopupWidget.DebugKeepOpen = debugMenus.Checked;
|
||||
}
|
||||
|
||||
private void SceneTreeView_AfterSelect(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
this.InspectedObject3D = e.Node.Tag as IObject3D;
|
||||
|
|
|
|||
|
|
@ -586,7 +586,14 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
}
|
||||
else
|
||||
{
|
||||
field = new EnumField(property, theme);
|
||||
if (property.PropertyType == typeof(NamedTypeFace))
|
||||
{
|
||||
field = new FontSelectorField(property, theme);
|
||||
}
|
||||
else
|
||||
{
|
||||
field = new EnumField(property, theme);
|
||||
}
|
||||
}
|
||||
|
||||
field.Initialize(0);
|
||||
|
|
|
|||
|
|
@ -283,7 +283,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
// If the focused changed and we've lost focus and no special cases permit, close the menu
|
||||
if (!popup.Widget.ContainsFocus
|
||||
&& !specialChildHasFocus
|
||||
&& !descendantIsHoldingOpen)
|
||||
&& !descendantIsHoldingOpen
|
||||
&& !PopupWidget.DebugKeepOpen)
|
||||
{
|
||||
CloseMenu();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
Copyright (c) 2018, 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 System.Linq;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.DesignTools;
|
||||
|
||||
namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||
{
|
||||
public class FontSelectorField : UIField
|
||||
{
|
||||
private readonly EditableProperty property;
|
||||
private readonly ThemeConfig theme;
|
||||
private DropDownList dropDownList;
|
||||
|
||||
public FontSelectorField(EditableProperty property, ThemeConfig theme)
|
||||
{
|
||||
this.property = property;
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public override void Initialize(int tabIndex)
|
||||
{
|
||||
// Enum keyed on name to friendly name
|
||||
var enumItems = Enum.GetNames(property.PropertyType).Select(enumName =>
|
||||
{
|
||||
var renamedName = enumName;
|
||||
|
||||
var renameAttribute = property.PropertyInfo.GetCustomAttributes(true).OfType<EnumRenameAttribute>().FirstOrDefault();
|
||||
if (renameAttribute != null)
|
||||
{
|
||||
if (renameAttribute.NameMaping.TryGetValue(renamedName, out string value))
|
||||
{
|
||||
renamedName = value;
|
||||
}
|
||||
}
|
||||
|
||||
return new
|
||||
{
|
||||
Key = enumName,
|
||||
Value = renamedName.Replace('_', ' ')
|
||||
};
|
||||
});
|
||||
|
||||
dropDownList = new MHDropDownList("Name".Localize(), theme)
|
||||
{
|
||||
Name = property.DisplayName + " DropDownList"
|
||||
};
|
||||
|
||||
var sortableAttribute = property.PropertyInfo.GetCustomAttributes(true).OfType<SortableAttribute>().FirstOrDefault();
|
||||
var orderedItems = sortableAttribute != null ? enumItems.OrderBy(n => n.Value) : enumItems;
|
||||
|
||||
foreach (var orderItem in orderedItems)
|
||||
{
|
||||
Enum.TryParse<NamedTypeFace>(orderItem.Key, out NamedTypeFace namedTypeFace);
|
||||
var typeFace = ApplicationController.GetTypeFace(namedTypeFace);
|
||||
MenuItem newItem = dropDownList.AddItem(orderItem.Value, orderItem.Key, typeFace);
|
||||
|
||||
var localOrderedItem = orderItem;
|
||||
newItem.Selected += (sender, e) =>
|
||||
{
|
||||
this.SetValue(localOrderedItem.Key, true);
|
||||
};
|
||||
}
|
||||
|
||||
dropDownList.SelectedLabel = property.Value.ToString().Replace('_', ' ');
|
||||
|
||||
this.Content = dropDownList;
|
||||
}
|
||||
|
||||
protected override void OnValueChanged(FieldChangedEventArgs fieldChangedEventArgs)
|
||||
{
|
||||
if (this.Value != dropDownList.SelectedValue)
|
||||
{
|
||||
dropDownList.SelectedValue = this.Value;
|
||||
}
|
||||
|
||||
base.OnValueChanged(fieldChangedEventArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 5e2042fcc4bb1d62c87771d89d40d44c72fbcfca
|
||||
Subproject commit a121b7bf71dd6d59a090b9d4a9484303d064100c
|
||||
Loading…
Add table
Add a link
Reference in a new issue