93 private readonly System.Windows.Forms.ToolTip _toolTip =
new System.Windows.Forms.ToolTip
128 return FormSettings.myForm.FormName;
132 FormSettings.myForm.FormName = value;
136 private FormSettings FormSettings {
get;
set; }
140 FormSettings =
new FormSettings();
141 FormSettings.myForm =
new GPALFormForm()
143 ControlList =
new List<GPALControl>(),
146 FormSettings.myForm.SuspendLayout();
147 FormSettings.myForm.Left = FormSettings.left;
148 FormSettings.myForm.Top = FormSettings.top;
149 FormSettings.myForm.Width = FormSettings.width;
150 FormSettings.myForm.Height = FormSettings.height;
151 FormSettings.myForm.InitialSize =
new Size(FormSettings.width, FormSettings.height);
153 FormSettings.myForm.AutoSize =
true;
155 Size _initialPreferredSize = FormSettings.myForm.Size;
157 FormSettings.TableLayoutPanel =
new TableLayoutPanel()
160 Dock = DockStyle.Fill,
164 FormSettings.myForm.Controls.Add(FormSettings.TableLayoutPanel);
166 System.Windows.Forms.Application.EnableVisualStyles();
170 internal GPALFormForm Form
174 return FormSettings.myForm;
177 internal List<GPALControl> ControlList
181 return FormSettings.myForm.ControlList;
191 FormSettings.width = width;
192 FormSettings.myForm.Width = width;
195 if (FormSettings.left > (Screen.PrimaryScreen.Bounds.Width - width))
196 FormSettings.left = Screen.PrimaryScreen.Bounds.Width - width - 2;
198 FormSettings.myForm.InitialSize =
new Size(FormSettings.myForm.Width, FormSettings.myForm.Height);
209 FormSettings.height = height;
210 FormSettings.myForm.Height = height;
212 if (FormSettings.top > (Screen.PrimaryScreen.Bounds.Height - height))
213 FormSettings.top = Screen.PrimaryScreen.Bounds.Height - height - 2;
215 FormSettings.top = (Screen.PrimaryScreen.Bounds.Height - height) / 2;
217 FormSettings.myForm.InitialSize =
new Size(FormSettings.myForm.Width, FormSettings.myForm.Height);
228 FormSettings.top = top;
229 FormSettings.myForm.Top = top;
239 FormSettings.left = left;
240 FormSettings.myForm.Left = left;
246 public int Left => FormSettings.myForm.Left;
250 public int Top => FormSettings.myForm.Top;
254 public int Width => FormSettings.myForm.Width;
258 public int Height => FormSettings.myForm.Height;
268 FormSettings.myForm.CallAfterFillIn = callAfterFillIn;
271 #endregion <Settings>
272 #region <Forms Actions>
289 return gPALControl
switch
325 FormSettings.myForm.FormTitle = title;
326 FormSettings.myForm.Text = title;
338 FormSettings.myForm.InputDatabase = inputDatabase;
339 DatabaseHelper.TokenizeDatabase(inputDatabase);
340 FormHelper.FillInWithTokens(
this,
new List<IGPALGrid<string>> { inputDatabase.Tokens }, WriteMode.Overwrite);
352 FormSettings.myForm.InputDatabase = inputDatabase;
353 DatabaseHelper.TokenizeDatabase(inputDatabase);
354 FormHelper.FillInWithTokens(
this,
new List<IGPALGrid<string>> { inputDatabase.Tokens }, WriteMode.Append);
366 FormSettings.myForm.InputDatabase = inputDatabase;
367 DatabaseHelper.TokenizeDatabase(inputDatabase);
368 FormHelper.FillInWithTokens(
this,
new List<IGPALGrid<string>> { inputDatabase.Tokens }, WriteMode.Insert);
380 FormSettings.myForm.InputFile = inputFile;
381 if (
false ==
FileHelper.TokenizeFile(inputFile))
383 GPAL.
PublishSimpleEvent(GPALEventType.ERROR, $
"Unable to tokenize file [{inputFile.Filename}]. Continuing.", inputFile, GPALObjectType.GPALFile);
386 FormHelper.FillInWithTokens(
this, ((IGPALFileInternal)inputFile).TokenList, WriteMode.Overwrite);
398 FormSettings.myForm.InputFile = inputFile;
399 if (
false ==
FileHelper.TokenizeFile(inputFile))
401 GPAL.
PublishSimpleEvent(GPALEventType.ERROR, $
"Unable to tokenize file [{inputFile.Filename}]. Continuing.", inputFile, GPALObjectType.GPALFile);
404 FormHelper.FillInWithTokens(
this, ((IGPALFileInternal)inputFile).TokenList, WriteMode.Append);
416 FormSettings.myForm.InputFile = inputFile;
417 if (
false ==
FileHelper.TokenizeFile(inputFile))
419 GPAL.
PublishSimpleEvent(GPALEventType.ERROR, $
"Unable to tokenize file [{inputFile.Filename}]. Continuing.", inputFile, GPALObjectType.GPALFile);
422 FormHelper.FillInWithTokens(
this, ((IGPALFileInternal)inputFile).TokenList, WriteMode.Insert);
434 FormHelper.FillInWithTokens(
this,
new List<IGPALGrid<string>> { inputGrid }, WriteMode.Overwrite);
446 FormHelper.FillInWithTokens(
this,
new List<IGPALGrid<string>> { inputGrid }, WriteMode.Append);
458 FormHelper.FillInWithTokens(
this,
new List<IGPALGrid<string>> { inputGrid }, WriteMode.Insert);
465 private static bool workflowFailureHandled =
false;
467 private void KeepFormAliveOnWorkflowFailure()
469 if (
true == workflowFailureHandled)
return;
471 workflowFailureHandled =
true;
475 System.Windows.Forms.Application.ThreadException += (sender, args) =>
476 GPAL.
PublishSimpleEvent(GPALEventType.EXCEPTION, $
"The form kept going after [{args.Exception?.GetType().Name}]",
null, GPALObjectType.GPALForm, args.Exception);
486 KeepFormAliveOnWorkflowFailure();
488 FormSettings.myForm.ResumeLayout();
489 if (
true == FormSettings.myForm.Visible)
490 FormSettings.myForm.Hide();
491 FormSettings.myForm.ShowDialog();
517 KeepFormAliveOnWorkflowFailure();
519 FormSettings.myForm.ResumeLayout();
520 if (
true == FormSettings.myForm.Visible)
521 FormSettings.myForm.Hide();
522 FormSettings.myForm.Show();
558 FormSettings.myForm.Hide();
561 #endregion <Forms Actions>
568 private void ApplyToolTip(
GPALControl gpalControl, Control winControl)
570 if (!
string.IsNullOrWhiteSpace(gpalControl.ToolTipText))
572 FormSettings.ToolTip.SetToolTip(winControl, gpalControl.ToolTipText);
573 if (gpalControl.ToolTipAutoPopDelayMs != 5000)
574 FormSettings.ToolTip.AutoPopDelay = gpalControl.ToolTipAutoPopDelayMs;
580 private void SizeForm()
584 if (0 == FormSettings.height)
586 foreach (
GPALControl controlEntry
in FormSettings.myForm.ControlList)
590 case FormControlType.TextArea:
591 case FormControlType.RichTextBox:
600 FormSettings.height = tmpHeight;
602 if (0 < FormSettings.width)
603 FormSettings.myForm.Width = FormSettings.width;
604 if (0 < FormSettings.height)
605 FormSettings.myForm.Height = FormSettings.height;
610 if (0 < FormSettings.top)
612 FormSettings.myForm.StartPosition = FormStartPosition.Manual;
613 FormSettings.myForm.Top = FormSettings.top;
615 if (0 < FormSettings.left)
617 FormSettings.myForm.StartPosition = FormStartPosition.Manual;
618 FormSettings.myForm.Left = FormSettings.left;
628 private IAllowFormSettingsAndActions AddButton(GPALButton gPALButton)
630 FormSettings.myForm.ControlList.Add(gPALButton);
631 Button button =
new Button
633 Name = gPALButton.
Name,
634 Text = gPALButton.
Text,
636 Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
638 Height = 10 < gPALButton.Height ? gPALButton.Height : 20,
641 gPALButton.WindowsControl = button;
643 foreach (var (evt, handler) in gPALButton.Callbacks)
645 if (handler ==
null)
continue;
649 case ControlEventType.DoubleClick:
650 button.DoubleClick += (EventHandler)handler;
653 case ControlEventType.Default:
654 case ControlEventType.Click:
655 button.Click += (EventHandler)handler;
661 FormSettings.TableLayoutPanel.Controls.Add(button);
663 if (
true == gPALButton.IsDefault)
665 FormSettings.myForm.AcceptButton = button;
666 button.DialogResult = DialogResult.OK;
670 if (!
string.IsNullOrWhiteSpace(gPALButton.ToolTipText))
671 ApplyToolTip(gPALButton, button);
680 private IAllowFormSettingsAndActions AddChart(GPALChart gPALChart)
682 FormSettings.myForm.ControlList.Add(gPALChart);
683 FormSettings.TableLayoutPanel.Controls.Add((Chart)gPALChart.
WindowsControl);
688 foreach (var (evt, handler) in gPALChart.Callbacks)
690 if (handler ==
null)
continue;
694 case ControlEventType.DragDrop:
695 chart.DragDrop += (DragEventHandler)handler;
698 case ControlEventType.DragEnter:
699 chart.DragEnter += (DragEventHandler)handler;
702 case ControlEventType.DragLeave:
703 chart.DragLeave += (EventHandler)handler;
706 case ControlEventType.DragOver:
707 chart.DragOver += (DragEventHandler)handler;
710 case ControlEventType.DoubleClick:
711 chart.DoubleClick += (EventHandler)handler;
714 case ControlEventType.Default:
715 case ControlEventType.Click:
716 chart.Click += (EventHandler)handler;
722 if (!
string.IsNullOrWhiteSpace(gPALChart.ToolTipText))
723 ApplyToolTip(gPALChart, chart);
732 private IAllowFormSettingsAndActions AddCheckbox(GPALCheckbox gPALCheckbox)
734 FormSettings.myForm.ControlList.Add(gPALCheckbox);
735 CheckBox checkBox =
new CheckBox
737 Name = gPALCheckbox.
Name,
738 Text = gPALCheckbox.
Text,
740 Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
741 Checked = gPALCheckbox.
Checked,
742 Enabled = gPALCheckbox.
Enabled,
743 Height = 10 < gPALCheckbox.Height ? gPALCheckbox.Height : 20,
745 gPALCheckbox.WindowsControl = checkBox;
748 checkBox.CheckedChanged +=
new EventHandler(delegate (Object sender, EventArgs a) { gPALCheckbox.Checked = ((CheckBox)sender).Checked; });
750 foreach (var (evt, handler) in gPALCheckbox.Callbacks)
752 if (handler ==
null)
continue;
756 case ControlEventType.Default:
757 case ControlEventType.CheckedChanged:
758 checkBox.CheckedChanged += (EventHandler)handler;
761 case ControlEventType.DoubleClick:
762 checkBox.DoubleClick += (EventHandler)handler;
765 case ControlEventType.Click:
766 checkBox.Click += (EventHandler)handler;
772 FormSettings.TableLayoutPanel.Controls.Add(checkBox);
774 if (!
string.IsNullOrWhiteSpace(gPALCheckbox.ToolTipText))
775 ApplyToolTip(gPALCheckbox, checkBox);
785 private static int FirstEnabledIndex(ComboBox combo, GPALComboBox gpalCombo)
789 for (
int index = 0; index < combo.Items.Count && -1 == retVal; index++)
790 if (
false == gpalCombo.disabledItems.Contains(combo.Items[index].ToString()))
796 private IAllowFormSettingsAndActions AddComboBox(GPALComboBox gpalCombo)
798 FormSettings.myForm.ControlList.Add(gpalCombo);
800 var combo =
new ComboBox
802 DropDownStyle = ComboBoxStyle.DropDownList,
803 Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
804 Height = 10 < gpalCombo.Height ? gpalCombo.Height : 20,
808 foreach (
string item
in gpalCombo.items)
810 combo.Items.Add(item);
814 if (!
string.IsNullOrEmpty(gpalCombo.selectedItem))
816 int idx = combo.Items.IndexOf(gpalCombo.selectedItem);
817 if (0 <= idx) combo.SelectedIndex = idx;
819 else if (0 <= gpalCombo.selectedIndex && gpalCombo.selectedIndex < combo.Items.Count)
821 combo.SelectedIndex = gpalCombo.selectedIndex;
826 combo.DrawMode = DrawMode.OwnerDrawFixed;
828 combo.DrawItem += (sender, args) =>
830 if (0 > args.Index)
return;
832 string text = combo.Items[args.Index].ToString();
833 bool disabled =
true == gpalCombo.disabledItems.Contains(text);
836 if (
false == disabled)
837 args.DrawBackground();
839 using (SolidBrush background =
new SolidBrush(SystemColors.Window))
840 args.Graphics.FillRectangle(background, args.Bounds);
842 using (SolidBrush foreground =
new SolidBrush(disabled ? SystemColors.GrayText : args.ForeColor))
843 args.Graphics.DrawString(text, args.Font, foreground, args.Bounds);
845 if (
false == disabled) args.DrawFocusRectangle();
850 combo.SelectedIndexChanged += (sender, args) =>
852 if (0 > combo.SelectedIndex)
return;
854 string text = combo.Items[combo.SelectedIndex].ToString();
856 if (
false == gpalCombo.disabledItems.Contains(text))
858 gpalCombo.lastEnabledIndex = combo.SelectedIndex;
862 GPAL.PublishSimpleEvent(Enums.GPALEventType.CAUTION, $
"[{text}] does not apply to what is selected, so it cannot be chosen",
null, Enums.GPALObjectType.GPALForm);
864 combo.SelectedIndex = 0 <= gpalCombo.lastEnabledIndex && gpalCombo.lastEnabledIndex < combo.Items.Count
865 ? gpalCombo.lastEnabledIndex
866 : FirstEnabledIndex(combo, gpalCombo);
869 gpalCombo.lastEnabledIndex = combo.SelectedIndex;
871 gpalCombo.WindowsControl = combo;
873 foreach (var (evt, handler) in gpalCombo.Callbacks)
875 if (handler ==
null)
continue;
879 case ControlEventType.Default:
880 case ControlEventType.SelectedIndexChanged:
881 combo.SelectedIndexChanged += (EventHandler)handler;
884 case ControlEventType.ValueChanged:
885 combo.SelectedValueChanged += (EventHandler)handler;
888 case ControlEventType.Click:
889 combo.Click += (EventHandler)handler;
896 if (
false ==
string.IsNullOrEmpty(gpalCombo.ToolTipText))
897 ApplyToolTip(gpalCombo, combo);
899 FormSettings.TableLayoutPanel.Controls.Add(combo);
908 private IAllowFormSettingsAndActions AddDataGridView(GPALDataGridView gPALDataGridView)
910 FormSettings.myForm.ControlList.Add(gPALDataGridView);
912 DataGridView dgv =
new DataGridView
914 Name = gPALDataGridView.
Name,
915 ReadOnly = gPALDataGridView.ReadOnly,
917 Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right,
918 Enabled = gPALDataGridView.IsEnabled,
919 AllowUserToAddRows =
false,
920 RowHeadersVisible =
false,
922 Height = 10 < gPALDataGridView.Height ? gPALDataGridView.Height : 20,
926 foreach (
string colName
in gPALDataGridView.
ColumnNames)
928 dgv.Columns.Add(colName, colName);
931 gPALDataGridView.WindowsControl = dgv;
934 foreach (var (evt, handler) in gPALDataGridView.Callbacks)
936 if (handler ==
null)
continue;
940 case ControlEventType.Default:
941 case ControlEventType.CellValueChanged:
942 case ControlEventType.Change:
943 dgv.CellValueChanged += (DataGridViewCellEventHandler)handler;
946 case ControlEventType.DoubleClick:
947 dgv.DoubleClick += (EventHandler)handler;
950 case ControlEventType.Click:
951 dgv.Click += (EventHandler)handler;
958 gPALDataGridView.SyncGridToControl();
960 FormSettings.TableLayoutPanel.Controls.Add(dgv);
962 if (!
string.IsNullOrWhiteSpace(gPALDataGridView.ToolTipText))
963 ApplyToolTip(gPALDataGridView, dgv);
972 private IAllowFormSettingsAndActions AddDateTimePicker(GPALDateTimePicker gPALDateTimePicker)
974 FormSettings.myForm.ControlList.Add(gPALDateTimePicker);
976 DateTimePicker dtp =
new DateTimePicker
978 Name = gPALDateTimePicker.
Name,
979 Value = gPALDateTimePicker.
Value,
980 Format = gPALDateTimePicker.
Format,
982 Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
983 Enabled = gPALDateTimePicker.IsEnabled,
984 Height = 10 < gPALDateTimePicker.Height ? gPALDateTimePicker.Height : 10,
987 gPALDateTimePicker.WindowsControl = dtp;
989 foreach (var (evt, handler) in gPALDateTimePicker.Callbacks)
991 if (handler ==
null)
continue;
995 case ControlEventType.Default:
996 case ControlEventType.ValueChanged:
997 case ControlEventType.Change:
998 dtp.ValueChanged += (EventHandler)handler;
1001 case ControlEventType.Click:
1002 dtp.Click += (EventHandler)handler;
1008 FormSettings.TableLayoutPanel.Controls.Add(dtp);
1010 if (!
string.IsNullOrWhiteSpace(gPALDateTimePicker.ToolTipText))
1011 ApplyToolTip(gPALDateTimePicker, dtp);
1020 private IAllowFormSettingsAndActions AddFileSelector(GPALFileSelector gPALFileSelector)
1022 FormSettings.myForm.ControlList.Add(gPALFileSelector);
1024 if (gPALFileSelector._compact)
1025 return AddFileSelectorCompact(gPALFileSelector);
1027 Button browseButton =
new Button
1029 Name = gPALFileSelector.Name +
"_Browse",
1031 Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
1033 Enabled = gPALFileSelector.IsEnabled
1036 TextBox displayBox =
new TextBox
1038 Name = gPALFileSelector.Name +
"_Path",
1040 Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
1041 Text =
"(click Browse to select)",
1042 Enabled = gPALFileSelector.IsEnabled
1045 TableLayoutPanel container =
new TableLayoutPanel
1049 Dock = DockStyle.Top,
1052 Height = Math.Max(displayBox.PreferredHeight, browseButton.Height) + 4,
1053 Margin =
new Padding(0)
1055 container.RowStyles.Add(
new RowStyle(SizeType.Percent, 100));
1056 container.ColumnStyles.Add(
new ColumnStyle(SizeType.Absolute, 90));
1057 container.ColumnStyles.Add(
new ColumnStyle(SizeType.Percent, 100));
1058 container.Controls.Add(browseButton, 0, 0);
1059 container.Controls.Add(displayBox, 1, 0);
1061 gPALFileSelector.WindowsControl = container;
1063 browseButton.Click += (s, e) =>
1065 string[] selected = OpenBrowseDialog(gPALFileSelector);
1066 bool cancelled = selected ==
null || selected.Length == 0;
1067 gPALFileSelector.NotifySelection(cancelled, selected);
1068 displayBox.Text = cancelled ?
"(selection cancelled)" :
string.Join(
"; ", selected);
1071 FormSettings.TableLayoutPanel.Controls.Add(container);
1073 if (!
string.IsNullOrWhiteSpace(gPALFileSelector.ToolTipText))
1074 ApplyToolTip(gPALFileSelector, container);
1079 private IAllowFormSettingsAndActions AddFileSelectorCompact(GPALFileSelector gPALFileSelector)
1081 PlaceholderTextBox textBox =
new PlaceholderTextBox
1083 Name = gPALFileSelector.Name +
"_Path",
1084 Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
1085 Enabled = gPALFileSelector.IsEnabled,
1086 PlaceholderText = gPALFileSelector._placeholder
1089 Button dotButton =
new Button
1091 Name = gPALFileSelector.Name +
"_Browse",
1094 Anchor = AnchorStyles.Top | AnchorStyles.Right,
1095 Enabled = gPALFileSelector.IsEnabled
1098 TableLayoutPanel container =
new TableLayoutPanel
1102 Dock = DockStyle.Top,
1106 Height = Math.Max(textBox.PreferredHeight, dotButton.Height) + 4,
1107 Margin =
new Padding(0)
1109 container.RowStyles.Add(
new RowStyle(SizeType.Percent, 100));
1110 container.ColumnStyles.Add(
new ColumnStyle(SizeType.Percent, 100));
1111 container.ColumnStyles.Add(
new ColumnStyle(SizeType.Absolute, 32));
1112 container.Controls.Add(textBox, 0, 0);
1113 container.Controls.Add(dotButton, 1, 0);
1116 gPALFileSelector.WindowsControl = textBox;
1118 textBox.TextChanged += (s, e) => gPALFileSelector._selectedPath = textBox.Text;
1120 dotButton.Click += (s, e) =>
1122 string[] selected = OpenBrowseDialog(gPALFileSelector);
1123 bool cancelled = selected ==
null || selected.Length == 0;
1125 textBox.Text = selected[0];
1126 gPALFileSelector.NotifySelection(cancelled, selected);
1129 FormSettings.TableLayoutPanel.Controls.Add(container);
1131 if (!
string.IsNullOrWhiteSpace(gPALFileSelector.ToolTipText))
1132 ApplyToolTip(gPALFileSelector, container);
1137 private static string[] OpenBrowseDialog(GPALFileSelector gPALFileSelector)
1139 if (gPALFileSelector._selectFolder)
1141 using (FolderBrowserDialog fbd =
new FolderBrowserDialog())
1143 fbd.Description = gPALFileSelector._title;
1144 fbd.SelectedPath = gPALFileSelector._initialDirectory;
1145 return fbd.ShowDialog() == DialogResult.OK ?
new[] { fbd.SelectedPath } :
null;
1150 using (OpenFileDialog ofd =
new OpenFileDialog())
1152 ofd.Title = gPALFileSelector._title;
1153 ofd.InitialDirectory = gPALFileSelector._initialDirectory;
1154 ofd.Filter = gPALFileSelector._filter;
1155 ofd.Multiselect = gPALFileSelector._multiSelect;
1156 return ofd.ShowDialog() == DialogResult.OK ? ofd.FileNames :
null;
1165 private IAllowFormSettingsAndActions AddInput(GPALInput gPALInput)
1167 FormSettings.myForm.ControlList.Add(gPALInput);
1168 PlaceholderTextBox input =
new PlaceholderTextBox
1170 Name = gPALInput.
Name,
1171 Text = gPALInput.
Text,
1173 Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
1175 Height = 10 < gPALInput.Height ? gPALInput.Height : 20,
1178 if (!
string.IsNullOrEmpty(gPALInput.PlaceHolder))
1179 input.PlaceholderText = gPALInput.PlaceHolder;
1181 if (
true == gPALInput.InputIsPassword)
1182 input.PasswordChar =
'\u25CF';
1184 if (
true == gPALInput.IsReadOnly)
1185 input.ReadOnly =
true;
1187 gPALInput.WindowsControl = input;
1189 input.Text = gPALInput.
Text;
1191 input.TextChanged +=
new EventHandler(delegate (Object sender, EventArgs a) { gPALInput.Text = ((TextBox)sender).Text; });
1193 foreach (var (evt, handler) in gPALInput.Callbacks)
1195 if (handler ==
null)
continue;
1199 case ControlEventType.Default:
1200 case ControlEventType.TextChanged:
1201 input.TextChanged += (EventHandler)handler;
1204 case ControlEventType.DoubleClick:
1205 input.DoubleClick += (EventHandler)handler;
1208 case ControlEventType.Click:
1209 input.Click += (EventHandler)handler;
1212 case ControlEventType.KeyDown:
1213 input.KeyDown += (KeyEventHandler)handler;
1219 FormSettings.TableLayoutPanel.Controls.Add(input);
1221 if (!
string.IsNullOrWhiteSpace(gPALInput.ToolTipText))
1222 ApplyToolTip(gPALInput, input);
1244 private void FitLabelHeight(Label label)
1246 if (0 < label.Width)
1248 Size measured = TextRenderer.MeasureText(label.Text, label.Font,
new Size(label.Width,
int.MaxValue),
1249 TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl);
1251 int wanted = 18 > measured.Height ? 18 : measured.Height;
1253 if (label.Height != wanted)
1254 label.Height = wanted;
1258 private IAllowFormSettingsAndActions AddLabel(GPALLabel gPALLabel)
1260 FormSettings.myForm.ControlList.Add(gPALLabel);
1261 Label label =
new Label
1263 Name = gPALLabel.
Name,
1264 Text = gPALLabel.
Text,
1267 Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
1269 label.Font =
new Font(label.Font.FontFamily, 10f, FontStyle.Bold);
1271 label.AutoSize =
false;
1272 label.Height = 18 < gPALLabel.Height ? gPALLabel.Height : 18;
1277 if (18 >= gPALLabel.
Height)
1278 label.SizeChanged += (sender, args) => FitLabelHeight(label);
1280 gPALLabel.WindowsControl = label;
1282 foreach (var (evt, handler) in gPALLabel.Callbacks)
1284 if (handler ==
null)
continue;
1288 case ControlEventType.DoubleClick:
1289 label.DoubleClick += (EventHandler)handler;
1292 case ControlEventType.Default:
1293 case ControlEventType.Click:
1294 label.Click += (EventHandler)handler;
1300 FormSettings.TableLayoutPanel.Controls.Add(label);
1302 if (!
string.IsNullOrWhiteSpace(gPALLabel.ToolTipText))
1303 ApplyToolTip(gPALLabel, label);
1312 private IAllowFormSettingsAndActions AddListView(GPALListView gPALListView)
1314 FormSettings.myForm.ControlList.Add(gPALListView);
1316 ListView listView =
new ListView
1318 Name = gPALListView.
Name,
1322 CheckBoxes = gPALListView.checkBoxes,
1323 Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right,
1324 Enabled = gPALListView.IsEnabled,
1325 Height = 10 < gPALListView.Height ? gPALListView.
Height: 150,
1329 foreach (
string header
in gPALListView.
Columns)
1331 listView.Columns.Add(header, -2, HorizontalAlignment.Left);
1336 listView.ItemSelectionChanged += (sender, args) =>
1338 if (
true == args.IsSelected && SystemColors.GrayText == args.Item.ForeColor)
1339 args.Item.Selected =
false;
1342 gPALListView.WindowsControl = listView;
1344 foreach (var (evt, handler) in gPALListView.Callbacks)
1346 if (handler ==
null)
continue;
1350 case ControlEventType.Default:
1351 case ControlEventType.SelectedIndexChanged:
1352 case ControlEventType.Change:
1353 listView.SelectedIndexChanged += (EventHandler)handler;
1356 case ControlEventType.DoubleClick:
1357 listView.DoubleClick += (EventHandler)handler;
1360 case ControlEventType.Click:
1361 listView.Click += (EventHandler)handler;
1366 case ControlEventType.ItemChecked:
1367 listView.ItemChecked += (ItemCheckedEventHandler)handler;
1373 FormSettings.TableLayoutPanel.Controls.Add(listView);
1377 var comparer =
new ListViewItemComparer();
1378 listView.ListViewItemSorter = comparer;
1379 listView.ColumnClick += (s, e) =>
1381 if (comparer.Column == e.Column)
1382 comparer.Order = comparer.Order == SortOrder.Ascending
1383 ? SortOrder.Descending : SortOrder.Ascending;
1386 comparer.Column = e.Column;
1387 comparer.Order = SortOrder.Ascending;
1397 foreach (var w
in weights) total += w;
1398 if (total <= 0) total = 1;
1400 void applyWeights(
object s, EventArgs e)
1402 int available = listView.ClientSize.Width - SystemInformation.VerticalScrollBarWidth;
1403 if (available <= 0)
return;
1404 for (
int i = 0; i < weights.Count && i < listView.Columns.Count; i++)
1405 listView.Columns[i].Width = (
int)(available * weights[i] / total);
1408 listView.Resize += applyWeights;
1409 listView.HandleCreated += applyWeights;
1412 if (!
string.IsNullOrWhiteSpace(gPALListView.ToolTipText))
1413 ApplyToolTip(gPALListView, listView);
1422 private IAllowFormSettingsAndActions AddNumericUpDown(GPALNumericUpDown gPALNumericUpDown)
1424 FormSettings.myForm.ControlList.Add(gPALNumericUpDown);
1426 NumericUpDown nud =
new NumericUpDown
1428 Name = gPALNumericUpDown.
Name,
1429 Value = gPALNumericUpDown.
Value,
1430 Minimum = gPALNumericUpDown.
Minimum,
1431 Maximum = gPALNumericUpDown.
Maximum,
1432 Increment = gPALNumericUpDown.
Increment,
1434 Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
1435 Enabled = gPALNumericUpDown.IsEnabled,
1436 Height = 10 < gPALNumericUpDown.Height ? gPALNumericUpDown.Height : 20,
1439 gPALNumericUpDown.WindowsControl = nud;
1441 foreach (var (evt, handler) in gPALNumericUpDown.Callbacks)
1443 if (handler ==
null)
continue;
1447 case ControlEventType.Default:
1448 case ControlEventType.ValueChanged:
1449 case ControlEventType.Change:
1450 nud.ValueChanged += (EventHandler)handler;
1453 case ControlEventType.Click:
1454 nud.Click += (EventHandler)handler;
1460 FormSettings.TableLayoutPanel.Controls.Add(nud);
1462 if (!
string.IsNullOrWhiteSpace(gPALNumericUpDown.ToolTipText))
1463 ApplyToolTip(gPALNumericUpDown, nud);
1472 private IAllowFormSettingsAndActions AddProgressBar(GPALProgressBar gPALProgressBar)
1474 FormSettings.myForm.ControlList.Add(gPALProgressBar);
1476 ProgressBar progressBar =
new ProgressBar
1478 Name = gPALProgressBar.
Name,
1479 Minimum = gPALProgressBar.
Minimum,
1480 Maximum = gPALProgressBar.
Maximum,
1481 Value = gPALProgressBar.
Value,
1482 Style = gPALProgressBar.
Style,
1483 Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
1484 Enabled = gPALProgressBar.IsEnabled,
1485 Height = 10 < gPALProgressBar.Height ? gPALProgressBar.Height : 20,
1488 gPALProgressBar.WindowsControl = progressBar;
1490 foreach (var (evt, handler) in gPALProgressBar.Callbacks)
1492 if (handler ==
null)
continue;
1496 case ControlEventType.Click:
1497 progressBar.Click += (EventHandler)handler;
1504 FormSettings.TableLayoutPanel.Controls.Add(progressBar);
1506 if (!
string.IsNullOrWhiteSpace(gPALProgressBar.ToolTipText))
1507 ApplyToolTip(gPALProgressBar, progressBar);
1517 private IAllowFormSettingsAndActions AddRadioButton(GPALRadioButton gPALRadioButton)
1519 FormSettings.myForm.ControlList.Add(gPALRadioButton);
1520 RadioButton radioButton =
new RadioButton
1522 Name = gPALRadioButton.
Name,
1523 Text = gPALRadioButton.
Text,
1525 Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
1526 Checked = gPALRadioButton.
Checked,
1527 Enabled = gPALRadioButton.
Enabled,
1528 Height = 10 < gPALRadioButton.Height ? gPALRadioButton.Height : 20,
1530 gPALRadioButton.WindowsControl = radioButton;
1531 radioButton.CheckedChanged +=
new EventHandler(delegate (Object sender, EventArgs a) { gPALRadioButton.Checked = ((RadioButton)sender).Checked; });
1533 foreach (var (evt, handler) in gPALRadioButton.Callbacks)
1535 if (handler ==
null)
continue;
1539 case ControlEventType.Default:
1540 case ControlEventType.CheckedChanged:
1541 radioButton.CheckedChanged += (EventHandler)handler;
1544 case ControlEventType.Click:
1545 radioButton.Click += (EventHandler)handler;
1551 FormSettings.TableLayoutPanel.Controls.Add(radioButton);
1553 if (!
string.IsNullOrWhiteSpace(gPALRadioButton.ToolTipText))
1554 ApplyToolTip(gPALRadioButton, radioButton);
1563 private IAllowFormSettingsAndActions AddStatusStrip(GPALStatusStrip gPALStatusStrip)
1565 FormSettings.myForm.ControlList.Add(gPALStatusStrip);
1567 StatusStrip statusStrip =
new StatusStrip
1569 Name = gPALStatusStrip.
Name,
1570 Dock = DockStyle.Bottom,
1572 Enabled = gPALStatusStrip.IsEnabled,
1573 Height = 10 < gPALStatusStrip.Height ? gPALStatusStrip.Height : 20,
1576 ToolStripStatusLabel statusLabel =
new ToolStripStatusLabel
1578 Text = gPALStatusStrip.
Text,
1580 TextAlign = ContentAlignment.MiddleLeft,
1581 Height = 10 < gPALStatusStrip.Height ? gPALStatusStrip.Height : 20,
1584 statusStrip.Items.Add(statusLabel);
1586 gPALStatusStrip.WindowsControl = statusStrip;
1588 foreach (var (evt, handler) in gPALStatusStrip.Callbacks)
1590 if (handler ==
null)
continue;
1594 case ControlEventType.Click:
1595 case ControlEventType.Default:
1596 statusStrip.ItemClicked += (sender, e) => ((EventHandler)handler)(sender, e);
1604 FormSettings.myForm.Controls.Add(statusStrip);
1606 if (!
string.IsNullOrWhiteSpace(gPALStatusStrip.ToolTipText))
1607 ApplyToolTip(gPALStatusStrip, statusStrip);
1616 private IAllowFormSettingsAndActions AddMenuBar(GPALMenuBar gPALMenuBar)
1618 FormSettings.myForm.ControlList.Add(gPALMenuBar);
1620 MenuStrip menuStrip =
new MenuStrip
1622 Name = gPALMenuBar.
Name,
1623 Enabled = gPALMenuBar.IsEnabled,
1626 var topMenus =
new System.Collections.Generic.Dictionary<string, ToolStripMenuItem>();
1627 foreach (var (topMenu, item, isSeparator) in gPALMenuBar.menuEntries)
1629 string menuKey =
string.IsNullOrWhiteSpace(topMenu) ?
"" : topMenu;
1630 if (!topMenus.TryGetValue(menuKey, out ToolStripMenuItem topItem))
1632 topItem =
new ToolStripMenuItem(menuKey);
1633 topMenus[menuKey] = topItem;
1634 menuStrip.Items.Add(topItem);
1639 topItem.DropDownItems.Add(
new ToolStripSeparator());
1643 ToolStripMenuItem menuItem =
new ToolStripMenuItem(item.Text);
1644 if (item.Image !=
null)
1645 menuItem.Image = item.Image;
1646 if (item.ShortCutKey != System.Windows.Forms.Keys.None)
1648 menuItem.ShortcutKeys = item.ShortCutKey;
1649 menuItem.ShowShortcutKeys =
true;
1651 foreach (var (evt, handler) in item.Callbacks)
1652 if (handler is EventHandler clickHandler)
1653 menuItem.Click += clickHandler;
1654 if (!
string.IsNullOrWhiteSpace(item.ToolTipText))
1655 menuItem.ToolTipText = item.ToolTipText;
1658 menuItem.Enabled = item.IsEnabled;
1659 item.WindowsControl = menuItem;
1660 topItem.DropDownItems.Add(menuItem);
1663 gPALMenuBar.WindowsControl = menuStrip;
1666 FormSettings.myForm.Controls.Add(menuStrip);
1667 FormSettings.myForm.MainMenuStrip = menuStrip;
1671 FormSettings.myForm.Controls.SetChildIndex(menuStrip, FormSettings.myForm.Controls.Count - 1);
1681 private IAllowFormSettingsAndActions AddToolbar(GPALToolbar gPALToolbar)
1683 FormSettings.myForm.ControlList.Add(gPALToolbar);
1685 ToolStrip toolStrip =
new ToolStrip
1687 Name = gPALToolbar.
Name,
1688 Enabled = gPALToolbar.IsEnabled,
1691 foreach (var (item, isSeparator) in gPALToolbar.toolbarEntries)
1695 toolStrip.Items.Add(
new ToolStripSeparator());
1699 ToolStripButton button =
new ToolStripButton(item.Text);
1700 if (item.Image !=
null)
1702 button.Image = item.Image;
1703 button.DisplayStyle =
string.IsNullOrWhiteSpace(item.Text)
1704 ? ToolStripItemDisplayStyle.Image
1705 : ToolStripItemDisplayStyle.ImageAndText;
1708 button.DisplayStyle = ToolStripItemDisplayStyle.Text;
1710 foreach (var (evt, handler) in item.Callbacks)
1711 if (handler is EventHandler clickHandler)
1712 button.Click += clickHandler;
1713 if (!
string.IsNullOrWhiteSpace(item.ToolTipText))
1714 button.ToolTipText = item.ToolTipText;
1716 button.Enabled = item.IsEnabled;
1717 item.WindowsControl = button;
1718 toolStrip.Items.Add(button);
1721 gPALToolbar.WindowsControl = toolStrip;
1724 FormSettings.myForm.Controls.Add(toolStrip);
1725 if (FormSettings.myForm.MainMenuStrip !=
null)
1726 FormSettings.myForm.Controls.SetChildIndex(FormSettings.myForm.MainMenuStrip, FormSettings.myForm.Controls.Count - 1);
1735 private IAllowFormSettingsAndActions AddTab(GPALTab gPALTab)
1737 if (
null == FormSettings.TabControl)
1739 FormSettings.TabControl =
new TabControl
1741 Name =
"tabControl",
1744 Dock = DockStyle.Fill,
1751 FormSettings.TabControl.Selecting += (sender, args) =>
1755 if (
null == FormSettings.TabControl.SelectedTab)
return;
1757 if (
null != args.TabPage &&
false == args.TabPage.Enabled) args.Cancel =
true;
1760 FormSettings.TableLayoutPanel.Controls.Add(FormSettings.TabControl);
1763 TabPage tabPage =
new TabPage
1765 Name = gPALTab.
Name,
1766 Text = gPALTab.
Text,
1769 Dock = DockStyle.Fill,
1770 Enabled = gPALTab.Enabled
1773 TableLayoutPanel tmpTableLayoutPanel =
new TableLayoutPanel
1776 Dock = DockStyle.Fill,
1784 gPALTab.WindowsControl = tabPage;
1786 FormSettings.myForm.ControlList.Add(gPALTab);
1788 foreach (var (evt, handler) in gPALTab.Callbacks)
1790 if (handler ==
null)
continue;
1794 case ControlEventType.Scroll:
1795 tabPage.Scroll += (ScrollEventHandler)handler;
1798 case ControlEventType.Click:
1801 tabPage.Click += (EventHandler)handler;
1804 case ControlEventType.Default:
1805 case ControlEventType.SelectedIndexChanged:
1806 case ControlEventType.Change:
1810 FormSettings.TabControl.Selected += (sender, args) =>
1812 if (args.TabPage == tabPage)
1813 ((EventHandler)handler)(gPALTab, args);
1820 tabPage.Controls.Add(tmpTableLayoutPanel);
1821 FormSettings.TabControl.Controls.Add(tabPage);
1822 FormSettings.TableLayoutPanel = tmpTableLayoutPanel;
1824 if (!
string.IsNullOrWhiteSpace(gPALTab.ToolTipText))
1825 ApplyToolTip(gPALTab, tabPage);
1836 private IAllowFormSettingsAndActions AddSplitter(GPALSplitter gPALSplitter)
1838 FormSettings.myForm.ControlList.Add(gPALSplitter);
1840 SplitContainer sc =
new SplitContainer
1843 Orientation =
true == gPALSplitter.IsHorizontalSplit ? Orientation.Vertical : Orientation.Horizontal,
1847 Dock = DockStyle.Top,
1848 Height = 10 < gPALSplitter.Height ? gPALSplitter.Height : 0,
1849 AutoScaleMode = AutoScaleMode.Inherit
1852 if (
true == gPALSplitter.IsPercentage)
1854 double pct = gPALSplitter.Percentage;
1857 sc.SizeChanged += (s, e) =>
1859 int along =
true == gPALSplitter.IsHorizontalSplit ? sc.Width : sc.Height;
1861 if (along > sc.Panel1MinSize + sc.Panel2MinSize + sc.SplitterWidth)
1862 sc.SplitterDistance = (int)(along * pct);
1866 sc.SplitterDistance = gPALSplitter.Dimension;
1868 gPALSplitter.WindowsControl = sc;
1870 TableLayoutPanel firstPane = MakeSplitPaneTlp();
1871 TableLayoutPanel secondPane = MakeSplitPaneTlp();
1873 sc.Panel1.Controls.Add(firstPane);
1874 sc.Panel2.Controls.Add(secondPane);
1875 FormSettings.TableLayoutPanel.Controls.Add(sc);
1877 FillContainer(gPALSplitter.FormControls, firstPane, secondPane, gPALSplitter.
Name);
1882 if (10 >= gPALSplitter.
Height)
1887 Func<TableLayoutPanel, int> contentHeight = pane =>
1889 int total = pane.Padding.Top + pane.Padding.Bottom;
1891 foreach (Control child
in pane.Controls)
1892 total += child.Height + child.Margin.Top + child.Margin.Bottom;
1897 sc.Height =
true == gPALSplitter.IsHorizontalSplit
1898 ? Math.Max(contentHeight(firstPane), contentHeight(secondPane))
1899 : contentHeight(firstPane) + contentHeight(secondPane) + sc.SplitterWidth;
1902 if (!
string.IsNullOrWhiteSpace(gPALSplitter.ToolTipText))
1903 ApplyToolTip(gPALSplitter, sc);
1912 private IAllowFormSettingsAndActions AddGroupBox(GPALGroupBox gPALGroupBox)
1914 FormSettings.myForm.ControlList.Add(gPALGroupBox);
1916 GroupBox gb =
new GroupBox
1918 Name = gPALGroupBox.
Name,
1919 Text = gPALGroupBox.
Text,
1920 Enabled = gPALGroupBox.IsEnabled,
1924 Dock = DockStyle.Top,
1926 AutoSizeMode = AutoSizeMode.GrowAndShrink,
1931 TableLayoutPanel inside =
new TableLayoutPanel
1933 Dock = DockStyle.Top,
1935 AutoSizeMode = AutoSizeMode.GrowAndShrink,
1939 inside.ColumnStyles.Add(
new ColumnStyle(SizeType.Percent, 100f));
1940 gb.Controls.Add(inside);
1941 FormSettings.TableLayoutPanel.Controls.Add(gb);
1943 gPALGroupBox.WindowsControl = gb;
1945 FillContainer(gPALGroupBox.FormControls, inside,
null, gPALGroupBox.
Name);
1947 if (!
string.IsNullOrWhiteSpace(gPALGroupBox.ToolTipText))
1948 ApplyToolTip(gPALGroupBox, gb);
1964 private void FillContainer(List<object> formControls, TableLayoutPanel firstPane, TableLayoutPanel secondPane,
string name)
1966 TableLayoutPanel outerPanel = FormSettings.TableLayoutPanel;
1967 TabControl outerTabControl = FormSettings.TabControl;
1968 TableLayoutPanel current = firstPane;
1969 bool markerSeen =
false;
1971 FormSettings.TabControl =
null;
1973 foreach (
object formControl
in formControls)
1975 if (formControl is GPALSpliter)
1977 if (
null == secondPane)
1978 GPAL.PublishSimpleEvent(GPALEventType.WARNING, $
"[{name}] has no second pane, so the pane marker does nothing. Everything added stays in the one panel.");
1979 else if (
true == markerSeen)
1980 GPAL.PublishSimpleEvent(GPALEventType.WARNING, $
"[{name}] has more than one pane marker and a splitter has only two panes, so everything after the first marker stays in the second.");
1983 current = secondPane;
1990 FormSettings.TableLayoutPanel = current;
1991 FormSettings.TabControl =
null;
1995 FormSettings.TableLayoutPanel = outerPanel;
1996 FormSettings.TabControl = outerTabControl;
1999 private TableLayoutPanel MakeSplitPaneTlp()
2001 var tlp =
new TableLayoutPanel
2003 Dock = DockStyle.Fill,
2007 tlp.ColumnStyles.Add(
new ColumnStyle(SizeType.Percent, 100f));
2016 private IAllowFormSettingsAndActions AddTableLayoutPanel(GPALTableLayoutPanel gPALTableLayoutPanel)
2018 FormSettings.myForm.ControlList.Add(gPALTableLayoutPanel);
2019 TableLayoutPanel tableLayoutPanel =
new TableLayoutPanel
2021 Name = gPALTableLayoutPanel.
Name,
2022 GrowStyle = gPALTableLayoutPanel.
GrowStyle,
2025 RowCount = gPALTableLayoutPanel.RowCount
2029 if (!
string.IsNullOrWhiteSpace(gPALTableLayoutPanel.ToolTipText))
2030 ApplyToolTip(gPALTableLayoutPanel, tableLayoutPanel);
2040 private IAllowFormSettingsAndActions AddTextArea(GPALTextArea gPALTextArea)
2042 FormSettings.myForm.ControlList.Add(gPALTextArea);
2043 PlaceholderTextBox textBox =
new PlaceholderTextBox
2045 Name = gPALTextArea.
Name,
2046 Text = gPALTextArea.
Text,
2049 ScrollBars = ScrollBars.Both,
2050 Height = 10 < gPALTextArea.Height ? gPALTextArea.Height : 150,
2051 Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right,
2052 Enabled = gPALTextArea.Enabled
2054 if (
true == gPALTextArea.IsReadOnly)
2055 textBox.ReadOnly =
true;
2057 if (!
string.IsNullOrEmpty(gPALTextArea.PlaceHolder))
2058 textBox.PlaceholderText = gPALTextArea.PlaceHolder;
2060 gPALTextArea.WindowsControl = textBox;
2061 textBox.Text = gPALTextArea.
Text;
2063 textBox.TextChanged +=
new EventHandler(delegate (Object sender, EventArgs a) { gPALTextArea.Text = ((TextBox)sender).Text; });
2065 foreach (var (evt, handler) in gPALTextArea.Callbacks)
2067 if (handler ==
null)
continue;
2071 case ControlEventType.Default:
2072 case ControlEventType.TextChanged:
2073 textBox.TextChanged += (EventHandler)handler;
2076 case ControlEventType.Click:
2077 textBox.Click += (EventHandler)handler;
2083 FormSettings.TableLayoutPanel.Controls.Add(textBox);
2085 if (!
string.IsNullOrWhiteSpace(gPALTextArea.ToolTipText))
2086 ApplyToolTip(gPALTextArea, textBox);
2096 private IAllowFormSettingsAndActions AddRichTextBox(GPALRichTextBox gPALRichTextBox)
2098 FormSettings.myForm.ControlList.Add(gPALRichTextBox);
2099 RichTextBox richTextBox =
new RichTextBox
2101 Name = gPALRichTextBox.
Name,
2104 ReadOnly = gPALRichTextBox.IsReadOnly,
2105 ScrollBars = RichTextBoxScrollBars.Both,
2106 Height = 10 < gPALRichTextBox.Height ? gPALRichTextBox.Height : 150,
2107 Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right,
2108 Enabled = gPALRichTextBox.Enabled
2110 gPALRichTextBox.WindowsControl = richTextBox;
2111 GPALRichTextBox.RenderMarkdown(richTextBox, gPALRichTextBox.
Text);
2113 FormSettings.TableLayoutPanel.Controls.Add(richTextBox);
2115 if (!
string.IsNullOrWhiteSpace(gPALRichTextBox.ToolTipText))
2116 ApplyToolTip(gPALRichTextBox, richTextBox);
2125 private IAllowFormSettingsAndActions AddTreeView(GPALTreeView gPALTreeView)
2127 FormSettings.myForm.ControlList.Add(gPALTreeView);
2129 TreeView tv =
new TreeView
2131 Name = gPALTreeView.
Name,
2135 Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right,
2136 Enabled = gPALTreeView.IsEnabled,
2137 Height = 10 < gPALTreeView.Height ? gPALTreeView.Height : 150,
2141 tv.BeforeSelect += (sender, args) =>
2143 if (
null != args.Node && SystemColors.GrayText == args.Node.ForeColor) args.Cancel =
true;
2146 gPALTreeView.WindowsControl = tv;
2148 foreach (var (evt, handler) in gPALTreeView.Callbacks)
2150 if (handler ==
null)
continue;
2154 case ControlEventType.Default:
2155 case ControlEventType.AfterSelect:
2156 case ControlEventType.Change:
2157 tv.AfterSelect += (TreeViewEventHandler)handler;
2160 case ControlEventType.DoubleClick:
2161 tv.DoubleClick += (EventHandler)handler;
2164 case ControlEventType.Click:
2165 tv.Click += (EventHandler)handler;
2171 FormSettings.TableLayoutPanel.Controls.Add(tv);
2173 if (!
string.IsNullOrWhiteSpace(gPALTreeView.ToolTipText))
2174 ApplyToolTip(gPALTreeView, tv);
2178 #endregion <private>