Chronos Plugins 5.9.0
This documentation covers the plugin interfaces definitions and an example implementation.
Loading...
Searching...
No Matches
MockPlugin.Device.ConnectionEditor Class Reference

Just a primitive UI Type Editor to demonstrate how you can add an editor of your own for connection strings. More...

+ Inheritance diagram for MockPlugin.Device.ConnectionEditor:
+ Collaboration diagram for MockPlugin.Device.ConnectionEditor:

Public Member Functions

override UITypeEditorEditStyle GetEditStyle (ITypeDescriptorContext context)
 We want to show a modal dialog box.
 
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 value.
 

Detailed Description

Just a primitive UI Type Editor to demonstrate how you can add an editor of your own for connection strings.

Definition at line 14 of file ConnectionEditor.cs.

Member Function Documentation

◆ EditValue()

override object MockPlugin.Device.ConnectionEditor.EditValue ( ITypeDescriptorContext context,
IServiceProvider provider,
object value )

Create your editor form, initialize it from the given value, return if the user accepted the new value.

Parameters
contextThe context.Instance is the device. If the configuration has not been saved, this could be a disposed temporary object, but you can still get its type. This can be helpful if you want to reuse the same editor with minor runtime modifications for different device types.
provider
value
Returns

Definition at line 38 of file ConnectionEditor.cs.

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 }

◆ GetEditStyle()

override UITypeEditorEditStyle MockPlugin.Device.ConnectionEditor.GetEditStyle ( ITypeDescriptorContext context)

We want to show a modal dialog box.

Parameters
context
Returns

Definition at line 23 of file ConnectionEditor.cs.

24 {
25 return UITypeEditorEditStyle.Modal;
26 }

The documentation for this class was generated from the following file: