From c4670ce2840d51d9cb0e8a3ef8403e3b6b72a6a8 Mon Sep 17 00:00:00 2001 From: "Leaf Shi (BEYONDSOFT CONSULTING INC)" Date: Tue, 16 Apr 2024 18:28:54 +0800 Subject: [PATCH 1/6] Port TreeNodeCollectionEditor to core --- .../src/System.Design.Forwards.cs | 1 + .../src/Resources/SR.resx | 3 + .../src/Resources/xlf/SR.cs.xlf | 5 + .../src/Resources/xlf/SR.de.xlf | 5 + .../src/Resources/xlf/SR.es.xlf | 5 + .../src/Resources/xlf/SR.fr.xlf | 5 + .../src/Resources/xlf/SR.it.xlf | 5 + .../src/Resources/xlf/SR.ja.xlf | 5 + .../src/Resources/xlf/SR.ko.xlf | 5 + .../src/Resources/xlf/SR.pl.xlf | 5 + .../src/Resources/xlf/SR.pt-BR.xlf | 5 + .../src/Resources/xlf/SR.ru.xlf | 5 + .../src/Resources/xlf/SR.tr.xlf | 5 + .../src/Resources/xlf/SR.zh-Hans.xlf | 5 + .../src/Resources/xlf/SR.zh-Hant.xlf | 5 + .../Forms/Design/TreeNodeCollectionEditor.cs | 774 ++++++++++++++++++ .../Design/TreeNodeCollectionEditor.resx | 669 +++++++++++++++ .../xlf/TreeNodeCollectionEditor.cs.xlf | 57 ++ .../xlf/TreeNodeCollectionEditor.de.xlf | 57 ++ .../xlf/TreeNodeCollectionEditor.es.xlf | 57 ++ .../xlf/TreeNodeCollectionEditor.fr.xlf | 57 ++ .../xlf/TreeNodeCollectionEditor.it.xlf | 57 ++ .../xlf/TreeNodeCollectionEditor.ja.xlf | 57 ++ .../xlf/TreeNodeCollectionEditor.ko.xlf | 57 ++ .../xlf/TreeNodeCollectionEditor.pl.xlf | 57 ++ .../xlf/TreeNodeCollectionEditor.pt-BR.xlf | 57 ++ .../xlf/TreeNodeCollectionEditor.ru.xlf | 57 ++ .../xlf/TreeNodeCollectionEditor.tr.xlf | 57 ++ .../xlf/TreeNodeCollectionEditor.zh-Hans.xlf | 57 ++ .../xlf/TreeNodeCollectionEditor.zh-Hant.xlf | 57 ++ 30 files changed, 2253 insertions(+) create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeNodeCollectionEditor.cs create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeNodeCollectionEditor.resx create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.cs.xlf create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.de.xlf create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.es.xlf create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.fr.xlf create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.it.xlf create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.ja.xlf create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.ko.xlf create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.pl.xlf create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.pt-BR.xlf create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.ru.xlf create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.tr.xlf create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.zh-Hans.xlf create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.zh-Hant.xlf diff --git a/src/System.Design/src/System.Design.Forwards.cs b/src/System.Design/src/System.Design.Forwards.cs index 87dda003697..a36c7c11be3 100644 --- a/src/System.Design/src/System.Design.Forwards.cs +++ b/src/System.Design/src/System.Design.Forwards.cs @@ -27,6 +27,7 @@ [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.StringArrayEditor))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.StringCollectionEditor))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TabPageCollectionEditor))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TreeNodeCollectionEditor))] // internal serializers [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ControlCodeDomSerializer))] diff --git a/src/System.Windows.Forms.Design/src/Resources/SR.resx b/src/System.Windows.Forms.Design/src/Resources/SR.resx index 84d969f4dd9..cfcc3a31541 100644 --- a/src/System.Windows.Forms.Design/src/Resources/SR.resx +++ b/src/System.Windows.Forms.Design/src/Resources/SR.resx @@ -804,6 +804,9 @@ The service {0} is required but could not be found. If you have removed this service ensure that you provide a replacement. + + Node + The designer loader has already been loaded from another host. You can only have one designer loader for each host. diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.cs.xlf index 36b007a5090..e52dfbed99d 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.cs.xlf @@ -57,6 +57,11 @@ Ovládací prvek ActiveX + + Node + Node + + The designer is already loaded. Návrhář je již zaveden. diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.de.xlf index 43d9529d5e4..283fdad85fa 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.de.xlf @@ -57,6 +57,11 @@ ActiveX-Steuerelement + + Node + Node + + The designer is already loaded. Der Designer ist bereits geladen. diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.es.xlf index 32ca4e83dfe..0b5a281e26d 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.es.xlf @@ -57,6 +57,11 @@ Control ActiveX + + Node + Node + + The designer is already loaded. Ya está cargado el diseñador. diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.fr.xlf index a4d84cd0f0c..6a422f07896 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.fr.xlf @@ -57,6 +57,11 @@ Contrôle ActiveX + + Node + Node + + The designer is already loaded. Le concepteur est déjà chargé. diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.it.xlf index 74cf51b3651..6b7fce8114e 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.it.xlf @@ -57,6 +57,11 @@ Controllo ActiveX + + Node + Node + + The designer is already loaded. Finestra di progettazione già caricata. diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ja.xlf index 09cc5ca5516..eee5b26846c 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ja.xlf @@ -57,6 +57,11 @@ ActiveX コントロール + + Node + Node + + The designer is already loaded. デザイナーは既に読み込まれています。 diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ko.xlf index 8b57b9d17c6..ca636687a63 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ko.xlf @@ -57,6 +57,11 @@ ActiveX 컨트롤 + + Node + Node + + The designer is already loaded. 디자이너가 이미 로드되었습니다. diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pl.xlf index df1e878fed5..0f92aa3e359 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pl.xlf @@ -57,6 +57,11 @@ Formant kontrolki ActiveX + + Node + Node + + The designer is already loaded. Projektant został już załadowany. diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pt-BR.xlf index dd2fac64234..cf5bea4a1da 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pt-BR.xlf @@ -57,6 +57,11 @@ Controle ActiveX + + Node + Node + + The designer is already loaded. O designer já está carregado. diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ru.xlf index 187146ce44a..b81c63f730a 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ru.xlf @@ -57,6 +57,11 @@ Элемент управления ActiveX + + Node + Node + + The designer is already loaded. Конструктор уже загружен. diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.tr.xlf index ccae58760fc..e1ecab7d06d 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.tr.xlf @@ -57,6 +57,11 @@ ActiveX Denetimi + + Node + Node + + The designer is already loaded. Tasarımcı zaten yüklendi. diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hans.xlf index a0f1287b069..0a8754dfe7d 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hans.xlf @@ -57,6 +57,11 @@ ActiveX 控件 + + Node + Node + + The designer is already loaded. 已加载设计器。 diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hant.xlf index 1ddd425caec..81762027404 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hant.xlf @@ -57,6 +57,11 @@ ActiveX 控制項 + + Node + Node + + The designer is already loaded. 已經載入設計工具。 diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeNodeCollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeNodeCollectionEditor.cs new file mode 100644 index 00000000000..657825b4c99 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeNodeCollectionEditor.cs @@ -0,0 +1,774 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#nullable disable + +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Drawing; +using System.Globalization; + +namespace System.Windows.Forms.Design; + +internal class TreeNodeCollectionEditor : CollectionEditor +{ + public TreeNodeCollectionEditor(Type type) : base(type) + { } + + /// + /// Creates a new form to show the current collection. + /// You may inherit from CollectionForm to provide your own form. + /// + /// + protected override CollectionForm CreateCollectionForm() => new TreeNodeCollectionForm(this); + + /// + /// Gets the help topic to display for the dialog help button or pressing F1. + /// Override to display a different help topic. + /// + protected override string HelpTopic => "net.ComponentModel.TreeNodeCollectionEditor"; + + private class TreeNodeCollectionForm : CollectionForm + { + private int _nextNode; + private TreeNode _curNode; + private readonly TreeNodeCollectionEditor _editor; + private Button _okButton; + private Button _btnCancel; + private Button _btnAddChild; + private Button _btnAddRoot; + private Button _btnDelete; + private Button _moveDownButton; + private Button _moveUpButton; + private Label _label1; + private TreeView _treeView1; + private Label _label2; + private VsPropertyGrid _propertyGrid1; + private TableLayoutPanel _okCancelPanel; + private TableLayoutPanel _nodeControlPanel; + private TableLayoutPanel _overarchingTableLayoutPanel; + private TableLayoutPanel _navigationButtonsTableLayoutPanel; + + private static readonly object s_nextNodeKey = new object(); + private readonly int _initialNextNode; + + public TreeNodeCollectionForm(CollectionEditor editor) + : base(editor) + { + editor = (TreeNodeCollectionEditor)editor; + InitializeComponent(); + HookEvents(); + // cache in the initial value before add so that we can put this value back + // if the operation is cancelled. + _initialNextNode = NextNode; + SetButtonsState(); + + // enable explorer tree view style + DesignerUtils.ApplyTreeViewThemeStyles(_treeView1); + + if (_moveDownButton.Image is Bitmap moveDown) + { + _moveDownButton.Image = ScaleHelper.ScaleToDpi(moveDown, ScaleHelper.InitialSystemDpi, disposeBitmap: true); + } + + if (_moveUpButton.Image is Bitmap moveUp) + { + _moveUpButton.Image = ScaleHelper.ScaleToDpi(moveUp, ScaleHelper.InitialSystemDpi, disposeBitmap: true); + } + + if (_btnDelete.Image is Bitmap delete) + { + _btnDelete.Image = ScaleHelper.ScaleToDpi(delete, ScaleHelper.InitialSystemDpi, disposeBitmap: true); + } + } + + private TreeNode LastNode + { + get + { + // Big-O of this loop == #levels in the tree. + TreeNode lastNode = _treeView1.Nodes[_treeView1.Nodes.Count - 1]; + while (lastNode.Nodes.Count > 0) + { + lastNode = lastNode.Nodes[lastNode.Nodes.Count - 1]; + } + + return lastNode; + } + } + + private TreeView TreeView + { + get + { + if (Context is not null && Context.Instance is TreeView view) + { + return view; + } + else + { + Debug.Assert(false, "TreeNodeCollectionEditor couldn't find the TreeView being designed"); + return null; + } + } + } + + private int NextNode + { + get + { + if (TreeView is not null && TreeView.Site is not null) + { + IDictionaryService dictionaryService = (IDictionaryService)TreeView.Site.GetService(typeof(IDictionaryService)); + Debug.Assert(dictionaryService is not null, "TreeNodeCollectionEditor relies on IDictionaryService, which is not available."); + if (dictionaryService is not null) + { + object dictionaryValue = dictionaryService.GetValue(s_nextNodeKey); + if (dictionaryValue is not null) + { + _nextNode = (int)dictionaryValue; + } + else + { + _nextNode = 0; + dictionaryService.SetValue(s_nextNodeKey, 0); + } + } + } + + return _nextNode; + } + set + { + _nextNode = value; + if (TreeView is not null && TreeView.Site is not null) + { + TreeView.Site.TryGetService(out IDictionaryService dictionaryService); + dictionaryService?.SetValue(s_nextNodeKey, _nextNode); + } + } + } + + private void Add(TreeNode parent) + { + TreeNode newNode = null; + string baseNodeName = SR.BaseNodeName; + + if (parent is null) + { + newNode = _treeView1.Nodes.Add(baseNodeName + NextNode++.ToString(CultureInfo.InvariantCulture)); + newNode.Name = newNode.Text; + } + else + { + newNode = parent.Nodes.Add(baseNodeName + NextNode++.ToString(CultureInfo.InvariantCulture)); + newNode.Name = newNode.Text; + + parent.Expand(); + } + + if (parent is not null) + { + _treeView1.SelectedNode = parent; + } + else + { + _treeView1.SelectedNode = newNode; + + // we are adding a Root Node ... at Level 1 + // so show the properties in the PropertyGrid + SetNodeProps(newNode); + } + } + + private void HookEvents() + { + _okButton.Click += new EventHandler(BtnOK_click); + _btnCancel.Click += new EventHandler(BtnCancel_click); + _btnAddChild.Click += new EventHandler(BtnAddChild_click); + _btnAddRoot.Click += new EventHandler(BtnAddRoot_click); + _btnDelete.Click += new EventHandler(BtnDelete_click); + _propertyGrid1.PropertyValueChanged += new PropertyValueChangedEventHandler(PropertyGrid_propertyValueChanged); + _treeView1.AfterSelect += new TreeViewEventHandler(treeView1_afterSelect); + _treeView1.DragEnter += new DragEventHandler(treeView1_DragEnter); + _treeView1.ItemDrag += new ItemDragEventHandler(treeView1_ItemDrag); + _treeView1.DragDrop += new DragEventHandler(treeView1_DragDrop); + _treeView1.DragOver += new DragEventHandler(treeView1_DragOver); + HelpButtonClicked += new CancelEventHandler(TreeNodeCollectionEditor_HelpButtonClicked); + _moveDownButton.Click += new EventHandler(moveDownButton_Click); + _moveUpButton.Click += new EventHandler(moveUpButton_Click); + } + + /// + /// The following code is required by the form designer. + /// It can be modified using the form editor. + /// Do not modify it using the code editor. + /// + private void InitializeComponent() + { + ComponentResourceManager resources = new ComponentResourceManager(typeof(TreeNodeCollectionEditor)); + + _okCancelPanel = new TableLayoutPanel(); + _okButton = new Button(); + _btnCancel = new Button(); + _nodeControlPanel = new TableLayoutPanel(); + _btnAddRoot = new Button(); + _btnAddChild = new Button(); + _btnDelete = new Button(); + _moveDownButton = new Button(); + _moveUpButton = new Button(); + _propertyGrid1 = new VsPropertyGrid(); + _label2 = new Label(); + _treeView1 = new TreeView(); + _label1 = new Label(); + _overarchingTableLayoutPanel = new TableLayoutPanel(); + _navigationButtonsTableLayoutPanel = new TableLayoutPanel(); + _okCancelPanel.SuspendLayout(); + _nodeControlPanel.SuspendLayout(); + _overarchingTableLayoutPanel.SuspendLayout(); + _navigationButtonsTableLayoutPanel.SuspendLayout(); + SuspendLayout(); + + // okCancelPanel + resources.ApplyResources(_okCancelPanel, "okCancelPanel"); + _okCancelPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + _okCancelPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + _okCancelPanel.Controls.Add(_okButton, 0, 0); + _okCancelPanel.Controls.Add(_btnCancel, 1, 0); + _okCancelPanel.Name = "okCancelPanel"; + _okCancelPanel.RowStyles.Add(new RowStyle()); + + // okButton + resources.ApplyResources(_okButton, "okButton"); + _okButton.DialogResult = DialogResult.OK; + _okButton.Name = "okButton"; + + // btnCancel + resources.ApplyResources(_btnCancel, "btnCancel"); + _btnCancel.DialogResult = DialogResult.Cancel; + _btnCancel.Name = "btnCancel"; + + // nodeControlPanel + resources.ApplyResources(_nodeControlPanel, "nodeControlPanel"); + _nodeControlPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + _nodeControlPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + _nodeControlPanel.Controls.Add(_btnAddRoot, 0, 0); + _nodeControlPanel.Controls.Add(_btnAddChild, 1, 0); + _nodeControlPanel.Name = "nodeControlPanel"; + _nodeControlPanel.RowStyles.Add(new RowStyle()); + + // btnAddRoot + resources.ApplyResources(_btnAddRoot, "btnAddRoot"); + _btnAddRoot.Name = "btnAddRoot"; + + // btnAddChild + resources.ApplyResources(_btnAddChild, "btnAddChild"); + _btnAddChild.Name = "btnAddChild"; + + // btnDelete + resources.ApplyResources(_btnDelete, "btnDelete"); + _btnDelete.Name = "btnDelete"; + + // moveDownButton + resources.ApplyResources(_moveDownButton, "moveDownButton"); + _moveDownButton.Name = "moveDownButton"; + + // moveUpButton + resources.ApplyResources(_moveUpButton, "moveUpButton"); + _moveUpButton.Name = "moveUpButton"; + // propertyGrid1 + resources.ApplyResources(_propertyGrid1, "propertyGrid1"); + + // LineColor assigned here is causing issues in the HC mode. Going with runtime default for HC mode. + if (!SystemInformation.HighContrast) + { + _propertyGrid1.LineColor = SystemColors.ScrollBar; + } + + _propertyGrid1.Name = "propertyGrid1"; + _overarchingTableLayoutPanel.SetRowSpan(_propertyGrid1, 2); + // label2 + resources.ApplyResources(_label2, "label2"); + _label2.Name = "label2"; + // treeView1 + _treeView1.AllowDrop = true; + resources.ApplyResources(_treeView1, "treeView1"); + _treeView1.HideSelection = false; + _treeView1.Name = "treeView1"; + // label1 + resources.ApplyResources(_label1, "label1"); + _label1.Name = "label1"; + + // overarchingTableLayoutPanel + resources.ApplyResources(_overarchingTableLayoutPanel, "overarchingTableLayoutPanel"); + _overarchingTableLayoutPanel.ColumnStyles.Add(new ColumnStyle()); + _overarchingTableLayoutPanel.ColumnStyles.Add(new ColumnStyle()); + _overarchingTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + + _overarchingTableLayoutPanel.Name = "overarchingTableLayoutPanel"; + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle()); + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle()); + _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle()); + + // Initializes with primary monitor always. + ResetMarginsOnTheForm(true, 1); + + // navigationButtonsTableLayoutPanel + resources.ApplyResources(_navigationButtonsTableLayoutPanel, "navigationButtonsTableLayoutPanel"); + _navigationButtonsTableLayoutPanel.ColumnStyles.Add(new ColumnStyle()); + _navigationButtonsTableLayoutPanel.Controls.Add(_moveUpButton, 0, 0); + _navigationButtonsTableLayoutPanel.Controls.Add(_btnDelete, 0, 2); + _navigationButtonsTableLayoutPanel.Controls.Add(_moveDownButton, 0, 1); + _navigationButtonsTableLayoutPanel.Name = "navigationButtonsTableLayoutPanel"; + _navigationButtonsTableLayoutPanel.RowStyles.Add(new RowStyle()); + _navigationButtonsTableLayoutPanel.RowStyles.Add(new RowStyle()); + _navigationButtonsTableLayoutPanel.RowStyles.Add(new RowStyle()); + + // TreeNodeCollectionEditor + AcceptButton = _okButton; + resources.ApplyResources(this, "$this"); + AutoScaleMode = AutoScaleMode.Font; + CancelButton = _btnCancel; + Controls.Add(_overarchingTableLayoutPanel); + HelpButton = true; + MaximizeBox = false; + MinimizeBox = false; + Name = "TreeNodeCollectionEditor"; + ShowIcon = false; + ShowInTaskbar = false; + SizeGripStyle = SizeGripStyle.Show; + _okCancelPanel.ResumeLayout(false); + _okCancelPanel.PerformLayout(); + _nodeControlPanel.ResumeLayout(false); + _nodeControlPanel.PerformLayout(); + _overarchingTableLayoutPanel.ResumeLayout(false); + _overarchingTableLayoutPanel.PerformLayout(); + _navigationButtonsTableLayoutPanel.ResumeLayout(false); + ResumeLayout(false); + } + + private void ResetMarginsOnTheForm(bool fromConstructor, double pixelFactor = 0) + { + if (pixelFactor == 0) + { + return; + } + + int PIXEL_3 = 3; + int PIXEL_18 = 18; + + _okCancelPanel.Margin = new Padding(PIXEL_3, PIXEL_3, 0, 0); + _okButton.Margin = new Padding(0, 0, PIXEL_3, 0); + _btnCancel.Margin = new Padding(PIXEL_3, 0, 0, 0); + _nodeControlPanel.Margin = new Padding(0, PIXEL_3, PIXEL_3, PIXEL_3); + _btnAddRoot.Margin = new Padding(0, 0, PIXEL_3, 0); + _btnAddChild.Margin = new Padding(PIXEL_3, 0, 0, 0); + _btnDelete.Margin = new Padding(0, PIXEL_3, 0, 0); + _moveDownButton.Margin = new Padding(0, PIXEL_3, 0, PIXEL_3); + _moveUpButton.Margin = new Padding(0, 0, 0, PIXEL_3); + _propertyGrid1.Margin = new Padding(PIXEL_3, PIXEL_3, 0, PIXEL_3); + _label2.Margin = new Padding(PIXEL_3, PIXEL_3, 0, PIXEL_3); + _treeView1.Margin = new Padding(0, PIXEL_3, PIXEL_3, PIXEL_3); + _label1.Margin = new Padding(0, PIXEL_3, PIXEL_3, PIXEL_3); + _navigationButtonsTableLayoutPanel.Margin = new Padding(PIXEL_3, PIXEL_3, PIXEL_18, PIXEL_3); + if (fromConstructor) + { + _overarchingTableLayoutPanel.Controls.Clear(); + _overarchingTableLayoutPanel.Controls.Add(_label1, 0, 0); + _overarchingTableLayoutPanel.Controls.Add(_treeView1, 0, 1); + _overarchingTableLayoutPanel.Controls.Add(_nodeControlPanel, 0, 2); + _overarchingTableLayoutPanel.Controls.Add(_navigationButtonsTableLayoutPanel, 1, 1); + _overarchingTableLayoutPanel.Controls.Add(_label2, 2, 0); + _overarchingTableLayoutPanel.Controls.Add(_propertyGrid1, 2, 1); + _overarchingTableLayoutPanel.Controls.Add(_okCancelPanel, 2, 3); + } + else + { + // treeView nodes doesn't get font propagation in DPIChanged scenario because it inherits font from parent + // and DpiChanged event handling of the parent happens later and doesn't raise onFontChanges() event when + // the control or its parent tree is derived from Form . We special handled Form class for DpiChanged event + // to avoid double scaling issues. One solution here is, to raise onParentChange() event to get the right font. + + // this is a special handling and may need to revisit + _overarchingTableLayoutPanel.Controls.Remove(_treeView1); + _overarchingTableLayoutPanel.Controls.Add(_treeView1, 0, 1); + } + } + + /// + /// This is called when the value property in the CollectionForm has changed. + /// In it you should update your user interface to reflect the current value. + /// + protected override void OnEditValueChanged() + { + if (EditValue is not null) + { + object[] items = Items; + + _propertyGrid1.Site = new PropertyGridSite(Context, _propertyGrid1); + + TreeNode[] nodes = new TreeNode[items.Length]; + + for (int i = 0; i < items.Length; i++) + { + // We need to copy the nodes into our editor TreeView, not move them. + // We overwrite the passed-in array with the new roots. + // + nodes[i] = (TreeNode)((TreeNode)items[i]).Clone(); + } + + _treeView1.Nodes.Clear(); + _treeView1.Nodes.AddRange(nodes); + + // Update current node related UI + // + _curNode = null; + _btnAddChild.Enabled = false; + _btnDelete.Enabled = false; + + // The image list for the editor TreeView must be updated to be the same + // as the image list for the actual TreeView. + // + TreeView actualTV = TreeView; + if (actualTV is not null) + { + SetImageProps(actualTV); + } + + if (items.Length > 0 && nodes[0] is not null) + { + _treeView1.SelectedNode = nodes[0]; + } + } + } + + /// + /// When something in the properties window changes, we update pertinent text here. + /// + /// + /// + private void PropertyGrid_propertyValueChanged(object sender, PropertyValueChangedEventArgs e) + { + // Update the string above the grid. + _label2.Text = string.Format(SR.CollectionEditorProperties, _treeView1.SelectedNode.Text); + } + + private void SetImageProps(TreeView actualTreeView) + { + if (actualTreeView.ImageList is not null) + { + // Update the treeView image-related properties + _treeView1.ImageList = actualTreeView.ImageList; + _treeView1.ImageIndex = actualTreeView.ImageIndex; + _treeView1.SelectedImageIndex = actualTreeView.SelectedImageIndex; + } + else + { + // Update the treeView image-related properties + _treeView1.ImageList = null; + _treeView1.ImageIndex = -1; + _treeView1.SelectedImageIndex = -1; + } + + if (actualTreeView.StateImageList is not null) + { + _treeView1.StateImageList = actualTreeView.StateImageList; + } + else + { + _treeView1.StateImageList = null; + } + + // also set the CheckBoxes from the actual TreeView + _treeView1.CheckBoxes = actualTreeView.CheckBoxes; + } + + private void SetNodeProps(TreeNode node) + { + if (node is not null) + { + _label2.Text = string.Format(SR.CollectionEditorProperties, node.Name.ToString()); + } + + // no node is selected ... revert back the Text of the label to Properties... VsWhidbey: 338248. + else + { + _label2.Text = string.Format(SR.CollectionEditorPropertiesNone); + } + + _propertyGrid1.SelectedObject = node; + } + + private void treeView1_afterSelect(object sender, TreeViewEventArgs e) + { + _curNode = e.Node; + SetNodeProps(_curNode); + SetButtonsState(); + } + + private void treeView1_ItemDrag(object sender, ItemDragEventArgs e) + { + TreeNode item = (TreeNode)e.Item; + DoDragDrop(item, DragDropEffects.Move); + } + + private void treeView1_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(typeof(TreeNode))) + { + e.Effect = DragDropEffects.Move; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + private void treeView1_DragDrop(object sender, DragEventArgs e) + { + TreeNode dragNode = (TreeNode)e.Data.GetData(typeof(TreeNode)); + Point position = new Point(0, 0) + { + X = e.X, + Y = e.Y + }; + + position = _treeView1.PointToClient(position); + TreeNode dropNode = _treeView1.GetNodeAt(position); + + if (dragNode != dropNode) + { + // Remove this node after finding the new root + // but before re-adding the node to the collection + _treeView1.Nodes.Remove(dragNode); + + if (dropNode is not null && !CheckParent(dropNode, dragNode)) // DROPPED ON LEVEL > 0 + { + dropNode.Nodes.Add(dragNode); + } + else // DROPPED ON LEVEL 0 + { + _treeView1.Nodes.Add(dragNode); + } + } + } + + private static bool CheckParent(TreeNode child, TreeNode parent) + { + while (child is not null) + { + if (parent == child.Parent) + { + return true; + } + + child = child.Parent; + } + + return false; + } + + private void treeView1_DragOver(object sender, DragEventArgs e) + { + Point position = new Point(0, 0) + { + X = e.X, + Y = e.Y + }; + + position = _treeView1.PointToClient(position); + TreeNode currentNode = _treeView1.GetNodeAt(position); + _treeView1.SelectedNode = currentNode; + } + + private void BtnAddChild_click(object sender, EventArgs e) + { + Add(_curNode); + SetButtonsState(); + } + + private void BtnAddRoot_click(object sender, EventArgs e) + { + Add(null); + SetButtonsState(); + } + + private void BtnDelete_click(object sender, EventArgs e) + { + _curNode.Remove(); + if (_treeView1.Nodes.Count == 0) + { + _curNode = null; + SetNodeProps(null); + } + + SetButtonsState(); + } + + private void BtnOK_click(object sender, EventArgs e) + { + object[] values = new object[_treeView1.Nodes.Count]; + for (int i = 0; i < values.Length; i++) + { + values[i] = _treeView1.Nodes[i].Clone(); + } + + Items = values; + + // Now treeView is not required. Dispose it. + _treeView1.Dispose(); + _treeView1 = null; + } + + private void moveDownButton_Click(object sender, EventArgs e) + { + TreeNode tempNode = _curNode; + TreeNode parent = _curNode.Parent; + + if (parent is null) + { + _treeView1.Nodes.RemoveAt(tempNode.Index); + _treeView1.Nodes[tempNode.Index].Nodes.Insert(0, tempNode); + } + else + { + parent.Nodes.RemoveAt(tempNode.Index); + if (tempNode.Index < parent.Nodes.Count) + { + parent.Nodes[tempNode.Index].Nodes.Insert(0, tempNode); + } + else + { + if (parent.Parent is null) + { + _treeView1.Nodes.Insert(parent.Index + 1, tempNode); + } + else + { + parent.Parent.Nodes.Insert(parent.Index + 1, tempNode); + } + } + } + + _treeView1.SelectedNode = tempNode; + _curNode = tempNode; + } + + private void moveUpButton_Click(object sender, EventArgs e) + { + TreeNode tempNode = _curNode; + TreeNode parent = _curNode.Parent; + + if (parent is null) + { + _treeView1.Nodes.RemoveAt(tempNode.Index); + _treeView1.Nodes[tempNode.Index - 1].Nodes.Add(tempNode); + } + else + { + parent.Nodes.RemoveAt(tempNode.Index); + if (tempNode.Index == 0) + { + if (parent.Parent is null) + { + _treeView1.Nodes.Insert(parent.Index, tempNode); + } + else + { + parent.Parent.Nodes.Insert(parent.Index, tempNode); + } + } + else + { + parent.Nodes[tempNode.Index - 1].Nodes.Add(tempNode); + } + } + + _treeView1.SelectedNode = tempNode; + _curNode = tempNode; + } + + private void SetButtonsState() + { + bool nodesExist = _treeView1.Nodes.Count > 0; + + _btnAddChild.Enabled = nodesExist; + _btnDelete.Enabled = nodesExist; + _moveDownButton.Enabled = + nodesExist + && (_curNode != LastNode || _curNode.Level > 0) + && _curNode != _treeView1.Nodes[_treeView1.Nodes.Count - 1]; + _moveUpButton.Enabled = nodesExist && _curNode != _treeView1.Nodes[0]; + } + + private void TreeNodeCollectionEditor_HelpButtonClicked(object sender, CancelEventArgs e) + { + e.Cancel = true; + _editor.ShowHelp(); + } + + private void BtnCancel_click(object sender, EventArgs e) + { + if (NextNode != _initialNextNode) + { + NextNode = _initialNextNode; + } + } + } +} + +internal class PropertyGridSite : ISite +{ + private readonly IServiceProvider _serviceProvider; + private readonly IComponent _component; + private bool _inGetService; + + public PropertyGridSite(IServiceProvider serviceProvider, IComponent component) + { + _serviceProvider = serviceProvider; + _component = component; + } + + /// + /// The component sited by this component site. + /// + public IComponent Component => _component; + + /// + /// The container in which the component is sited. + /// + public IContainer Container => null; + + /// + /// Indicates whether the component is in design mode. + /// + public bool DesignMode => false; + + /// + /// The name of the component. + /// + public string Name + { + get { return null; } + set { } + } + + public object GetService(Type type) + { + if (!_inGetService && _serviceProvider is not null) + { + try + { + _inGetService = true; + return _serviceProvider.GetService(type); + } + finally + { + _inGetService = false; + } + } + + return null; + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeNodeCollectionEditor.resx b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeNodeCollectionEditor.resx new file mode 100644 index 00000000000..d7473b427a0 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeNodeCollectionEditor.resx @@ -0,0 +1,669 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + Right + + + + True + + + 2 + + + Left, Right + + + True + + + NoControl + + + + 97, 3 + + + 75, 23 + + + 1 + + + Cancel + + + btnCancel + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + okCancelPanel + + + 0 + + + Left, Right + + + True + + + NoControl + + + 3, 3 + + + 75, 23 + + + 0 + + + OK + + + okButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + okCancelPanel + + + 1 + + + 485, 310 + + + 1 + + + 156, 29 + + + 6 + + + okCancelPanel + + + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 6 + + + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="btnCancel" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="okButton" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,50,Percent,50" /><Rows Styles="AutoSize,0" /></TableLayoutSettings> + + + Left, Right + + + True + + + 2 + + + Left, Right + + + True + + + MiddleLeft + + + NoControl + + + 3, 3 + + + 131, 23 + + + 0 + + + Add &Root + + + ImageBeforeText + + + btnAddRoot + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + nodeControlPanel + + + 0 + + + Left, Right + + + True + + + MiddleLeft + + + NoControl + + + 140, 3 + + + 131, 23 + + + 1 + + + Add &Child + + + ImageBeforeText + + + btnAddChild + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + nodeControlPanel + + + 1 + + + 3, 275 + + + 1 + + + 274, 29 + + + 2 + + + nodeControlPanel + + + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 5 + + + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="btnAddRoot" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="btnAddChild" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="Percent,50,Percent,50" /><Rows Styles="Percent,50" /></TableLayoutSettings> + + + None + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAHdJREFUOE+tU1sO + wCAI8/434nRbMGPrFGldZsKHWkp5tfbHMbMjTOFz7I27Lv7Q7fU5sEGQBzcSrEgQNwVhJKVzqER5mI7k + jKlmalhtpsLvFJY6K90pWyrXoJJNSZScA7M9A1mHPo+yk6U7s5SXbBZLRVnGriKAJ50T5KPzn8IEAAAA + AElFTkSuQmCC + + + + NoControl + + + 3, 61 + + + 3, 3, 23, 3 + + + 26, 23 + + + 2 + + + ImageBeforeText + + + btnDelete + + + Delete Node + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + navigationButtonsTableLayoutPanel + + + 1 + + + None + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAElJREFUOE9jYBje + 4MCBA/9hmGSfgjQCNcExlE+8OUPUAHRnI4cB0eFByBCiAhOXIURphsUTxbEAMghmCEk2o6cUijQTn+wo + UAkAY/VsRlvaylwAAAAASUVORK5CYII= + + + + 3, 32 + + + 3, 3, 23, 3 + + + 26, 23 + + + 1 + + + moveDownButton + + + Move Down + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + navigationButtonsTableLayoutPanel + + + 2 + + + None + + + Stretch + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAEdJREFUOE9jYBj0 + 4MCBA//JdiRU83+yDIFpBtoOcgFphqBrJskQXJqJMoSQZqIMgYU4RWEAMmQYGADzBsgrZCUkspMv3TUC + AGYzbEaI9u+YAAAAAElFTkSuQmCC + + + + 3, 3 + + + 3, 3, 23, 3 + + + 26, 23 + + + 0 + + + moveUpButton + + + Move Up + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + navigationButtonsTableLayoutPanel + + + 0 + + + Fill + + + 341, 16 + + + Top, Bottom, Left, Right + + + 3 + + + True + + + 1 + + + 283, 16 + + + 3 + + + 52, 87 + + + 3 + + + navigationButtonsTableLayoutPanel + + + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 0 + + + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="moveUpButton" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="btnDelete" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="moveDownButton" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,50" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0" /></TableLayoutSettings> + + + Bottom, Left + + + True + + + NoControl + + + 341, 0 + + + 57, 13 + + + 4 + + + &Properties: + + + label2 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 1 + + + Top, Bottom, Left, Right + + + 19 + + + 3, 16 + + + 274, 253 + + + 1 + + + treeView1 + + + System.Windows.Forms.TreeView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 3 + + + Bottom, Left + + + True + + + NoControl + + + 3, 0 + + + 108, 13 + + + 0 + + + Select a &node to edit: + + + label1 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + overarchingTableLayoutPanel + + + 4 + + + 12, 12 + + + 4 + + + 618, 342 + + + 0 + + + overarchingTableLayoutPanel + + + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="navigationButtonsTableLayoutPanel" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="label2" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="propertyGrid1" Row="1" RowSpan="2" Column="2" ColumnSpan="1" /><Control Name="treeView1" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="nodeControlPanel" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="okCancelPanel" Row="3" RowSpan="1" Column="2" ColumnSpan="1" /></Controls><Columns Styles="Absolute,268,AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0,Percent,100,AutoSize,0,AutoSize,0" /></TableLayoutSettings> + + + 274, 288 + + + 5 + + + propertyGrid1 + + + WindowsApplication1.VsPropertyGrid, WindowsApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + overarchingTableLayoutPanel + + + 2 + + + True + + + 6, 13 + + + 642, 366 + + + 600, 400 + + + CenterParent + + + TreeNode Editor + + + TreeNodeCollectionEditor + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.cs.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.cs.xlf new file mode 100644 index 00000000000..a90ab18a4ed --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.cs.xlf @@ -0,0 +1,57 @@ + + + + + + TreeNode Editor + TreeNode Editor + + + + Add &Child + Add &Child + + + + Add &Root + Add &Root + + + + Cancel + Cancel + + + + Delete Node + Delete Node + + + + Select a &node to edit: + Select a &node to edit: + + + + &Properties: + &Properties: + + + + Move Down + Move Down + + + + Move Up + Move Up + + + + OK + OK + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.de.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.de.xlf new file mode 100644 index 00000000000..e893a95e102 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.de.xlf @@ -0,0 +1,57 @@ + + + + + + TreeNode Editor + TreeNode Editor + + + + Add &Child + Add &Child + + + + Add &Root + Add &Root + + + + Cancel + Cancel + + + + Delete Node + Delete Node + + + + Select a &node to edit: + Select a &node to edit: + + + + &Properties: + &Properties: + + + + Move Down + Move Down + + + + Move Up + Move Up + + + + OK + OK + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.es.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.es.xlf new file mode 100644 index 00000000000..3ca4fbcbdfc --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.es.xlf @@ -0,0 +1,57 @@ + + + + + + TreeNode Editor + TreeNode Editor + + + + Add &Child + Add &Child + + + + Add &Root + Add &Root + + + + Cancel + Cancel + + + + Delete Node + Delete Node + + + + Select a &node to edit: + Select a &node to edit: + + + + &Properties: + &Properties: + + + + Move Down + Move Down + + + + Move Up + Move Up + + + + OK + OK + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.fr.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.fr.xlf new file mode 100644 index 00000000000..c35b1fabf13 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.fr.xlf @@ -0,0 +1,57 @@ + + + + + + TreeNode Editor + TreeNode Editor + + + + Add &Child + Add &Child + + + + Add &Root + Add &Root + + + + Cancel + Cancel + + + + Delete Node + Delete Node + + + + Select a &node to edit: + Select a &node to edit: + + + + &Properties: + &Properties: + + + + Move Down + Move Down + + + + Move Up + Move Up + + + + OK + OK + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.it.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.it.xlf new file mode 100644 index 00000000000..682776d17ee --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.it.xlf @@ -0,0 +1,57 @@ + + + + + + TreeNode Editor + TreeNode Editor + + + + Add &Child + Add &Child + + + + Add &Root + Add &Root + + + + Cancel + Cancel + + + + Delete Node + Delete Node + + + + Select a &node to edit: + Select a &node to edit: + + + + &Properties: + &Properties: + + + + Move Down + Move Down + + + + Move Up + Move Up + + + + OK + OK + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.ja.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.ja.xlf new file mode 100644 index 00000000000..59c9da3fcb3 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.ja.xlf @@ -0,0 +1,57 @@ + + + + + + TreeNode Editor + TreeNode Editor + + + + Add &Child + Add &Child + + + + Add &Root + Add &Root + + + + Cancel + Cancel + + + + Delete Node + Delete Node + + + + Select a &node to edit: + Select a &node to edit: + + + + &Properties: + &Properties: + + + + Move Down + Move Down + + + + Move Up + Move Up + + + + OK + OK + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.ko.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.ko.xlf new file mode 100644 index 00000000000..d2e5e6e486f --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.ko.xlf @@ -0,0 +1,57 @@ + + + + + + TreeNode Editor + TreeNode Editor + + + + Add &Child + Add &Child + + + + Add &Root + Add &Root + + + + Cancel + Cancel + + + + Delete Node + Delete Node + + + + Select a &node to edit: + Select a &node to edit: + + + + &Properties: + &Properties: + + + + Move Down + Move Down + + + + Move Up + Move Up + + + + OK + OK + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.pl.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.pl.xlf new file mode 100644 index 00000000000..061eca70130 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.pl.xlf @@ -0,0 +1,57 @@ + + + + + + TreeNode Editor + TreeNode Editor + + + + Add &Child + Add &Child + + + + Add &Root + Add &Root + + + + Cancel + Cancel + + + + Delete Node + Delete Node + + + + Select a &node to edit: + Select a &node to edit: + + + + &Properties: + &Properties: + + + + Move Down + Move Down + + + + Move Up + Move Up + + + + OK + OK + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.pt-BR.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.pt-BR.xlf new file mode 100644 index 00000000000..135d9e9b946 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.pt-BR.xlf @@ -0,0 +1,57 @@ + + + + + + TreeNode Editor + TreeNode Editor + + + + Add &Child + Add &Child + + + + Add &Root + Add &Root + + + + Cancel + Cancel + + + + Delete Node + Delete Node + + + + Select a &node to edit: + Select a &node to edit: + + + + &Properties: + &Properties: + + + + Move Down + Move Down + + + + Move Up + Move Up + + + + OK + OK + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.ru.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.ru.xlf new file mode 100644 index 00000000000..4a991c4bb48 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.ru.xlf @@ -0,0 +1,57 @@ + + + + + + TreeNode Editor + TreeNode Editor + + + + Add &Child + Add &Child + + + + Add &Root + Add &Root + + + + Cancel + Cancel + + + + Delete Node + Delete Node + + + + Select a &node to edit: + Select a &node to edit: + + + + &Properties: + &Properties: + + + + Move Down + Move Down + + + + Move Up + Move Up + + + + OK + OK + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.tr.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.tr.xlf new file mode 100644 index 00000000000..142748bc26f --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.tr.xlf @@ -0,0 +1,57 @@ + + + + + + TreeNode Editor + TreeNode Editor + + + + Add &Child + Add &Child + + + + Add &Root + Add &Root + + + + Cancel + Cancel + + + + Delete Node + Delete Node + + + + Select a &node to edit: + Select a &node to edit: + + + + &Properties: + &Properties: + + + + Move Down + Move Down + + + + Move Up + Move Up + + + + OK + OK + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.zh-Hans.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.zh-Hans.xlf new file mode 100644 index 00000000000..96ef3a71d95 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.zh-Hans.xlf @@ -0,0 +1,57 @@ + + + + + + TreeNode Editor + TreeNode Editor + + + + Add &Child + Add &Child + + + + Add &Root + Add &Root + + + + Cancel + Cancel + + + + Delete Node + Delete Node + + + + Select a &node to edit: + Select a &node to edit: + + + + &Properties: + &Properties: + + + + Move Down + Move Down + + + + Move Up + Move Up + + + + OK + OK + + + + + \ No newline at end of file diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.zh-Hant.xlf b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.zh-Hant.xlf new file mode 100644 index 00000000000..5349c45b429 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/xlf/TreeNodeCollectionEditor.zh-Hant.xlf @@ -0,0 +1,57 @@ + + + + + + TreeNode Editor + TreeNode Editor + + + + Add &Child + Add &Child + + + + Add &Root + Add &Root + + + + Cancel + Cancel + + + + Delete Node + Delete Node + + + + Select a &node to edit: + Select a &node to edit: + + + + &Properties: + &Properties: + + + + Move Down + Move Down + + + + Move Up + Move Up + + + + OK + OK + + + + + \ No newline at end of file From 6c92b9d747f62f7ec832e192e40f690b7de80dbc Mon Sep 17 00:00:00 2001 From: "Leaf Shi (BEYONDSOFT CONSULTING INC)" Date: Wed, 17 Apr 2024 14:10:24 +0800 Subject: [PATCH 2/6] Update LocProject.json --- eng/Localize/LocProject.json | 8 +++++++- .../Windows/Forms/Design/TreeNodeCollectionEditor.cs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/eng/Localize/LocProject.json b/eng/Localize/LocProject.json index 364399bbe83..711824114ae 100644 --- a/eng/Localize/LocProject.json +++ b/eng/Localize/LocProject.json @@ -167,6 +167,11 @@ "CopyOption": "LangIDOnName", "OutputPath": ".\\src\\System.Windows.Forms.Design\\src\\System\\Windows\\Forms\\Design\\xlf\\" }, + { + "SourceFile": ".\\src\\System.Windows.Forms.Design\\src\\System\\Windows\\Forms\\Design\\xlf\\TreeNodeCollectionEditor.xlf", + "CopyOption": "LangIDOnName", + "OutputPath": ".\\src\\System.Windows.Forms.Design\\src\\Resources\\xlf\\" + }, { "SourceFile": ".\\src\\System.Windows.Forms.Design\\src\\System\\Windows\\Forms\\Design\\xlf\\DataGridViewCellStyleBuilder.xlf", "CopyOption": "LangIDOnName", @@ -187,7 +192,8 @@ "CopyOption": "LangIDOnName", "OutputPath": ".\\src\\System.Windows.Forms.Primitives\\src\\Resources\\xlf\\" } - ], + + ], "LanguageSet": "VS_Main_Languages" }, { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeNodeCollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeNodeCollectionEditor.cs index 657825b4c99..5f1d1d6d792 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeNodeCollectionEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeNodeCollectionEditor.cs @@ -32,7 +32,7 @@ private class TreeNodeCollectionForm : CollectionForm { private int _nextNode; private TreeNode _curNode; - private readonly TreeNodeCollectionEditor _editor; + private readonly TreeNodeCollectionEditor _editor = null!; private Button _okButton; private Button _btnCancel; private Button _btnAddChild; From 4ea404a611c55513821d69d55e5cd55b73c9647e Mon Sep 17 00:00:00 2001 From: "Leaf Shi (BEYONDSOFT CONSULTING INC)" Date: Wed, 17 Apr 2024 16:58:28 +0800 Subject: [PATCH 3/6] Update test cases --- .../System/Windows/Forms/Design/EmbeddedResourceTests.cs | 1 + .../System/Windows/Forms/Design/DesignerAttributeTests.cs | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/EmbeddedResourceTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/EmbeddedResourceTests.cs index 4a3f09a69e6..641f41cb971 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/EmbeddedResourceTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/EmbeddedResourceTests.cs @@ -61,6 +61,7 @@ public class EmbeddedResourceTests System.Windows.Forms.Design.Professional1 System.Windows.Forms.Design.Professional2 System.Windows.Forms.Design.ToolStripTemplateNode + System.Windows.Forms.Design.TreeNodeCollectionEditor.resources System.Windows.Forms.Design.UserControlToolboxItem """; diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/Design/DesignerAttributeTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/Design/DesignerAttributeTests.cs index d784d166293..66e9f681e27 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/Design/DesignerAttributeTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/Design/DesignerAttributeTests.cs @@ -30,7 +30,6 @@ public class DesignerAttributeTests "System.Windows.Forms.Design.DataMemberListEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Windows.Forms.Design.ToolStripCollectionEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Windows.Forms.Design.ToolStripImageIndexEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", - "System.Windows.Forms.Design.TreeNodeCollectionEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", ]; public DesignerAttributeTests(ITestOutputHelper output) From f7d1ccfa0414bda6865f254cb1bcefdfb391a39c Mon Sep 17 00:00:00 2001 From: "Leaf Shi (BEYONDSOFT CONSULTING INC)" Date: Wed, 17 Apr 2024 17:32:39 +0800 Subject: [PATCH 4/6] Update data for test "EmbeddedResource_ResourcesExist_Icon" --- .../System/Windows/Forms/Design/EmbeddedResourceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/EmbeddedResourceTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/EmbeddedResourceTests.cs index 641f41cb971..613920a8653 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/EmbeddedResourceTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/EmbeddedResourceTests.cs @@ -61,7 +61,6 @@ public class EmbeddedResourceTests System.Windows.Forms.Design.Professional1 System.Windows.Forms.Design.Professional2 System.Windows.Forms.Design.ToolStripTemplateNode - System.Windows.Forms.Design.TreeNodeCollectionEditor.resources System.Windows.Forms.Design.UserControlToolboxItem """; @@ -120,6 +119,7 @@ public void EmbeddedResource_ResourcesExist_Bitmap(string resourceName) System.Windows.Forms.Design.FormatControl.resources System.Windows.Forms.Design.LinkAreaEditor.resources System.Windows.Forms.Design.MaskDesignerDialog.resources + System.Windows.Forms.Design.TreeNodeCollectionEditor.resources System.Windows.Forms.Design.ShortcutKeysEditor.resources System.Windows.Forms.Design.StringCollectionEditor.resources System.Windows.Forms.Design.StyleCollectionEditor.resources From fcda65e400edb7e1e79e9cb43a149207f161217c Mon Sep 17 00:00:00 2001 From: "Leaf Shi (BEYONDSOFT CONSULTING INC)" Date: Thu, 18 Apr 2024 14:58:57 +0800 Subject: [PATCH 5/6] Update Comment format --- eng/Localize/LocProject.json | 1 - .../Forms/Design/TreeNodeCollectionEditor.cs | 39 +++++++++---------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/eng/Localize/LocProject.json b/eng/Localize/LocProject.json index 711824114ae..4a47632bea8 100644 --- a/eng/Localize/LocProject.json +++ b/eng/Localize/LocProject.json @@ -192,7 +192,6 @@ "CopyOption": "LangIDOnName", "OutputPath": ".\\src\\System.Windows.Forms.Primitives\\src\\Resources\\xlf\\" } - ], "LanguageSet": "VS_Main_Languages" }, diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeNodeCollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeNodeCollectionEditor.cs index 5f1d1d6d792..76f4f75c513 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeNodeCollectionEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeNodeCollectionEditor.cs @@ -16,15 +16,14 @@ public TreeNodeCollectionEditor(Type type) : base(type) { } /// - /// Creates a new form to show the current collection. - /// You may inherit from CollectionForm to provide your own form. + /// Creates a new form to show the current collection. + /// You may inherit from CollectionForm to provide your own form. /// - /// protected override CollectionForm CreateCollectionForm() => new TreeNodeCollectionForm(this); /// - /// Gets the help topic to display for the dialog help button or pressing F1. - /// Override to display a different help topic. + /// Gets the help topic to display for the dialog help button or pressing F1. + /// Override to display a different help topic. /// protected override string HelpTopic => "net.ComponentModel.TreeNodeCollectionEditor"; @@ -58,12 +57,13 @@ public TreeNodeCollectionForm(CollectionEditor editor) editor = (TreeNodeCollectionEditor)editor; InitializeComponent(); HookEvents(); - // cache in the initial value before add so that we can put this value back + + // Cache in the initial value before add so that we can put this value back // if the operation is cancelled. _initialNextNode = NextNode; SetButtonsState(); - // enable explorer tree view style + // Enable explorer tree view style. DesignerUtils.ApplyTreeViewThemeStyles(_treeView1); if (_moveDownButton.Image is Bitmap moveDown) @@ -175,8 +175,7 @@ private void Add(TreeNode parent) { _treeView1.SelectedNode = newNode; - // we are adding a Root Node ... at Level 1 - // so show the properties in the PropertyGrid + // We are adding a Root Node at Level 1, so show the properties in the PropertyGrid. SetNodeProps(newNode); } } @@ -287,14 +286,17 @@ private void InitializeComponent() _propertyGrid1.Name = "propertyGrid1"; _overarchingTableLayoutPanel.SetRowSpan(_propertyGrid1, 2); + // label2 resources.ApplyResources(_label2, "label2"); _label2.Name = "label2"; + // treeView1 _treeView1.AllowDrop = true; resources.ApplyResources(_treeView1, "treeView1"); _treeView1.HideSelection = false; _treeView1.Name = "treeView1"; + // label1 resources.ApplyResources(_label1, "label1"); _label1.Name = "label1"; @@ -385,12 +387,12 @@ private void ResetMarginsOnTheForm(bool fromConstructor, double pixelFactor = 0) } else { - // treeView nodes doesn't get font propagation in DPIChanged scenario because it inherits font from parent + // TreeView nodes doesn't get font propagation in DPIChanged scenario because it inherits font from parent // and DpiChanged event handling of the parent happens later and doesn't raise onFontChanges() event when // the control or its parent tree is derived from Form . We special handled Form class for DpiChanged event // to avoid double scaling issues. One solution here is, to raise onParentChange() event to get the right font. - // this is a special handling and may need to revisit + // This is a special handling and may need to revisit _overarchingTableLayoutPanel.Controls.Remove(_treeView1); _overarchingTableLayoutPanel.Controls.Add(_treeView1, 0, 1); } @@ -414,7 +416,6 @@ protected override void OnEditValueChanged() { // We need to copy the nodes into our editor TreeView, not move them. // We overwrite the passed-in array with the new roots. - // nodes[i] = (TreeNode)((TreeNode)items[i]).Clone(); } @@ -422,14 +423,12 @@ protected override void OnEditValueChanged() _treeView1.Nodes.AddRange(nodes); // Update current node related UI - // _curNode = null; _btnAddChild.Enabled = false; _btnDelete.Enabled = false; // The image list for the editor TreeView must be updated to be the same // as the image list for the actual TreeView. - // TreeView actualTV = TreeView; if (actualTV is not null) { @@ -446,8 +445,6 @@ protected override void OnEditValueChanged() /// /// When something in the properties window changes, we update pertinent text here. /// - /// - /// private void PropertyGrid_propertyValueChanged(object sender, PropertyValueChangedEventArgs e) { // Update the string above the grid. @@ -458,14 +455,14 @@ private void SetImageProps(TreeView actualTreeView) { if (actualTreeView.ImageList is not null) { - // Update the treeView image-related properties + // Update the treeView image-related properties. _treeView1.ImageList = actualTreeView.ImageList; _treeView1.ImageIndex = actualTreeView.ImageIndex; _treeView1.SelectedImageIndex = actualTreeView.SelectedImageIndex; } else { - // Update the treeView image-related properties + // Update the treeView image-related properties. _treeView1.ImageList = null; _treeView1.ImageIndex = -1; _treeView1.SelectedImageIndex = -1; @@ -480,7 +477,7 @@ private void SetImageProps(TreeView actualTreeView) _treeView1.StateImageList = null; } - // also set the CheckBoxes from the actual TreeView + // Also set the CheckBoxes from the actual TreeView. _treeView1.CheckBoxes = actualTreeView.CheckBoxes; } @@ -491,7 +488,7 @@ private void SetNodeProps(TreeNode node) _label2.Text = string.Format(SR.CollectionEditorProperties, node.Name.ToString()); } - // no node is selected ... revert back the Text of the label to Properties... VsWhidbey: 338248. + // No node is selected. Revert back the Text of the label to Properties. else { _label2.Text = string.Format(SR.CollectionEditorPropertiesNone); @@ -540,7 +537,7 @@ private void treeView1_DragDrop(object sender, DragEventArgs e) if (dragNode != dropNode) { // Remove this node after finding the new root - // but before re-adding the node to the collection + // but before re-adding the node to the collection. _treeView1.Nodes.Remove(dragNode); if (dropNode is not null && !CheckParent(dropNode, dragNode)) // DROPPED ON LEVEL > 0 From 542095e10581dd49e1b12a908c459d213d764202 Mon Sep 17 00:00:00 2001 From: Leaf Shi <132890443+LeafShi1@users.noreply.github.com> Date: Thu, 18 Apr 2024 15:02:47 +0800 Subject: [PATCH 6/6] Update LocProject.json --- eng/Localize/LocProject.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Localize/LocProject.json b/eng/Localize/LocProject.json index 4a47632bea8..c894fcbb108 100644 --- a/eng/Localize/LocProject.json +++ b/eng/Localize/LocProject.json @@ -192,7 +192,7 @@ "CopyOption": "LangIDOnName", "OutputPath": ".\\src\\System.Windows.Forms.Primitives\\src\\Resources\\xlf\\" } - ], + ], "LanguageSet": "VS_Main_Languages" }, {