...
Control Replacement Primer
Upgrading a control has three types of work:
1) upgrading the object model and members in logic
Good news is that this is the same as upgrading a standard (i.e. non-control) API
You will typically name the replacement control in the coClass a the bottom of the IDF. For example:
Code Block |
---|
...
<coclass id="fpText" migName="System.Windows.Forms.RichTextBox" migStatus="External" role="control">
<subclass id="IfpText"/>
<subclass id="_DfpText"/>
</coclass>
<coclass id="fpMask" migName="System.Windows.Forms.MaskedTextBox" migStatus="External" role="control">
<subclass id="IfpMask"/>
<subclass id="_DfpMask"/>
</coclass>
<coclass id="fpDateTime" migName="RadDateTimePicker" role="control">
<subclass id="IfpDateTime"/>
<subclass id="_DfpDateTime"/>
</coclass>
<coclass id="fpDoubleSingle" migName="System.Windows.Forms.NumericUpDown" migStatus="External" role="control">
<subclass id="IfpDoubleSingle"/>
<subclass id="_DfpDoubleSingle"/>
</coclass>
<coclass id="fpLongInteger" migName="System.Windows.Forms.NumericUpDown" migStatus="External" role="control">
<subclass id="IfpLongInteger"/>
<subclass id="_DfpLongInteger"/>
</coclass>
|
Notice that adding role=control is needed to make sure the objects are added to their parent containers
If a control is being migrated to a component, do not use role=control
2) upgrading event handlers
- event arg types
- event name changes
- event handler arguiments -- these are statements added to the event handler to setup the old style event args as local variables in the handler.
Code Block |
---|
<event id="ItemClick" netName="ItemClick" migStatus="mscomctl" role="event"
netHandler="System.Windows.Forms.ListViewItemSelectionChangedEventHandler"
netArgs="ListViewItemSelectionChangedEventArgs" migPattern="ItemSelectionChanged" >
<argument id="item" type="ListItem" status="ByVal" migPattern="%1d = e.Item" />
</event> |
3) Designer code -- property initialization
- these are specifications for what properties to set in teh designer.cs code file adn how to set them
Code Block |
---|
<!--
**********************************************************
* Statusbar Designer Code
**********************************************************
-->
<migClass id="NetControl.StatusBar"
migName="System.Windows.Forms.StatusStrip"
parent="StatusBar"
>
<property id="Font" value="Font" type="FontInfo"
nPram="3"
vbnPattern="New System.Drawing.Font(\s%1d\s, %2d!, %3d, System.Drawing.GraphicsUnit.Point, CType(0,Byte))"
cshPattern="new System.Drawing.Font(\s%1d\s, %2dF, %3d, System.Drawing.GraphicsUnit.Point, (System.Byte)(0))"
/>
<property id="Location"
value="(Left,Top)"
nPram="2"
vbnPattern="New System.Drawing.Point(%1d, %2d)"
cshPattern="new System.Drawing.Point(%1d, %2d)"
/>
<property id="Name" type="string"
value="SYM.name"
/>
<property id="Size"
value="(Width,Height)"
nPram="2"
vbnPattern="New System.Drawing.Size(%1d, %2d)"
cshPattern="new System.Drawing.Size(%1d, %2d)"
/>
<property id="TabIndex" type="Integer"
value="TabIndex"
default="0"
/>
</migClass>
|
Setting a color property in the designer
The following example shows how to map a color in designer code.
Code Block |
---|
<migClass id="NetControl.fpDoubleSingle" migName="NumericUpDown" parent="fpDoubleSingle">
<property id="BackColor" type="OLE_COLOR"
value="IfpDoubleSingle.BackColor"
nPram="3"
migPattern="System.Drawing.Color.FromArgb(%3d, %2d, %1d)"
default="System.Drawing.SystemColors.WindowText"
/> |