Chronos Plugins 5.9.0
This documentation covers the plugin interfaces definitions and an example implementation.
Loading...
Searching...
No Matches
ConnectionEditor.cs
Go to the documentation of this file.
1using System;
2using System.ComponentModel;
3using System.Drawing.Design;
4using System.Windows.Forms;
5using System.Windows.Forms.Design;
6
7// ReSharper disable LocalizableElement
8
9namespace MockPlugin.Device
10{
14 public class ConnectionEditor : UITypeEditor
15 {
16 #region Overrides of UITypeEditor
17
23 public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
24 {
25 return UITypeEditorEditStyle.Modal;
26 }
27
38 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
39 {
40 var editService = provider?.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
41 var myEditor = new ConnectionStringEditor {TheConnectionEdit = {Text = value?.ToString()}};
42 myEditor.Text = $"{myEditor.Text} for {context?.Instance?.GetType().Name}";
43 myEditor.EditLabel.Text = $"Editor for {context?.PropertyDescriptor?.Name}";
44 var res = editService?.ShowDialog(myEditor) ?? DialogResult.Cancel;
45 return res == DialogResult.OK ? myEditor.TheConnectionEdit.Text : value;
46 }
47
48 #endregion
49 }
50}
A fake device. This namespace contains the fake device driver and auxiliary classes for settings,...
Just a primitive UI Type Editor to demonstrate how you can add an editor of your own for connection s...
override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
Create your editor form, initialize it from the given value, return if the user accepted the new valu...
override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
We want to show a modal dialog box.
Just a form with a TextBox. Nothing to see here.