| Plugin Development Extend the functionality of Centrafuse by developing plugins |
 |
|
March 13th, 2008, 12:19 PM
|
#1 (permalink)
|
|
10 Farad - Flux Capacity
Join Date: Nov 2004
Location: Munich, Germany
Vehicle: Audi A3
Posts: 1,024
|
CFInjector - Tool for Plugin Developers
Hi Guys,
as you may have seen in the Phidgets plugin, I've realized to "inject" stuff on the Main screen of CF.
I thought this could be a nice tool to have, so I made an Assembly out of it and I'm sharing this with you.
How to use it:
1. Download CFInjector and unzip the files.
2. Add a reference to the assembly in your VS2003 project file.
3. Add these lines of code:
Somewhere in your class add these members:
Code:
private XmlDocument skinXml = new XmlDocument();
private InjectorTools injector = new InjectorTools();
Somewhere in CF_localskinsetup add this code:
Code:
//---------------------------------------------------------------------
// load the main skin
//---------------------------------------------------------------------
try
{
skinXml.Load(MainPathSkins + currentSkin +@"\skin.xml");
injector.ClearCachedControls();
injector.SkinXml = skinXml;
injector.MainForm = this.MainForm as Form;
injector.SkinRatio = new PointF((float)SkinReader.widthratio, (float)SkinReader.heightratio);
}
catch ( Exception ex )
{
Debug.WriteLine("Main skin not loaded. " + ex.ToString());
}
Whereas MainPathSkins is a constant pointing to the "Skins" folder.
Red marked lines apply to version 2.2.0.0, which allows resizing the injected controls as skins get streched because of an higher or lower resolution.
Somewhere in your plugin code add:
Code:
injector.InjectText("LABEL1", "Some text");
to inject text only or
Code:
Image image = Image.FromFile( "path and filename of the image to inject" );
if(image != null)
injector.InjectImage("LABEL1", image);
to inject an image from a file.
To have the injections updated, you may have to set up a timer which will refresh the injected controls frequently. So your timer event will need this line to refresh the injections:
Code:
injector.DrawInjectedControls();
That's all that has to be done in your code.
Beside, you have to modify the Skin.xml from the according Skin folder where you want to inject something in this way:
1. Add a section to
Code:
<SKIN>
<SCREENS>
<MAIN>
and name it <INJECT></INJECT>.
2. Add one or more standard CF Label controls to it, such as in:
Code:
<INJECT>
<LABEL1>
<WORDWRAP>False</WORDWRAP>
<FONTCOLOR>#696969</FONTCOLOR>
<FONTNAME>You Rook Marbelous</FONTNAME>
<FONTSIZE>14</FONTSIZE>
<FONTSTYLE>Bold</FONTSTYLE>
<Y>48</Y>
<X>518</X>
<WIDTH>70</WIDTH>
<HEIGHT>30</HEIGHT>
<ALIGN>Left</ALIGN>
</LABEL>
</INJECT>
In the sample above we now have a Label with the ID LABEL1.
3. Save the skin file and run your plugin. The rest will CFInjector do for you.
If you're using VD2, you can speed things up by adding label controls to the main skin panel and adding a prefix called INJECT:: to the Id property, such as:
INJECT::LABEL1
When exporting the skin, VD2 will create the section for you and put all labels into it (see also the Id property of the MAINPAGEBUTTONS if this is unclear).
__________________
Skinning to go... VD2
My Plugins: BluetoothControl, Contacts, Scribble, MWConn, Phidgets, Skype, PluginBrowser, LogoDashboard, SkinBrowser
My Tools: CFInjector
My Skins: Street WS, Gizmo, Cyclone, Drive
Last edited by Zorro; March 29th, 2009 at 09:51 AM.
|
|
|
March 18th, 2008, 12:34 PM
|
#2 (permalink)
|
|
5 Farad - High Capacity
Join Date: Mar 2008
Location: Gloucester, UK
Posts: 59
|
What is the best way to determine the following:
Quote:
|
MainPathSkins + currentSkin +@"\skin.xml"
|
Can you tell me where the variable in bold comes from?
Last edited by VorTechS; March 18th, 2008 at 12:37 PM.
|
|
|
March 18th, 2008, 12:49 PM
|
#3 (permalink)
|
|
5 Farad - High Capacity
Join Date: Mar 2008
Location: Gloucester, UK
Posts: 59
|
Ah, in a skin exported to VB.NET from Visual Designer 2, it's a variable called 'path' which can be found in 'CF_localskinsetup'
|
|
|
March 18th, 2008, 01:16 PM
|
#4 (permalink)
|
|
Admin
Join Date: Oct 2004
Location: Atlanta, GA
Vehicle: 2002 Jetta 1.8T
Posts: 1,273
|
This is very sweet
I've been thinking of something similar to this for some time. This is great work Zoran! Brilliant!
|
|
|
March 19th, 2008, 06:24 AM
|
#5 (permalink)
|
|
5 Farad - High Capacity
Join Date: Mar 2008
Location: Gloucester, UK
Posts: 59
|
I tried this with no luck. As soon as I add the INJECT section under:
the Aura skin breaks and you can't use the software.
I'm not having a good Centrafuse day today!
|
|
|
March 19th, 2008, 01:33 PM
|
#6 (permalink)
|
|
10 Farad - Flux Capacity
Join Date: Nov 2004
Location: Munich, Germany
Vehicle: Audi A3
Posts: 1,024
|
Quote:
Originally Posted by VorTechS
I tried this with no luck. As soon as I add the INJECT section under:
the Aura skin breaks and you can't use the software.
I'm not having a good Centrafuse day today! 
|
You don't have to mess with the stock skins, you can place the xml into another file which is being loaded instead of the main skin file. This will also ensure that your plugin will work with every skin.
If you download and install the latest Phidgets plugin, you'll find a Inject.xml file in the plugins folder. You may copy this file and load it as proposed above. It contains 3 labels and 5 indicator images, which should be good for almost anything.
__________________
Skinning to go... VD2
My Plugins: BluetoothControl, Contacts, Scribble, MWConn, Phidgets, Skype, PluginBrowser, LogoDashboard, SkinBrowser
My Tools: CFInjector
My Skins: Street WS, Gizmo, Cyclone, Drive
|
|
|
March 19th, 2008, 02:24 PM
|
#7 (permalink)
|
|
0.5 Farad - Min. Capacity
Join Date: Mar 2008
Posts: 7
|
is it posible to make it show current speed, direction (N,S,E,W), time of arrivel and so on?
|
|
|
March 22nd, 2008, 10:35 AM
|
#8 (permalink)
|
|
10 Farad - Flux Capacity
Join Date: Nov 2004
Location: Munich, Germany
Vehicle: Audi A3
Posts: 1,024
|
Quote:
Originally Posted by slagteren
is it posible to make it show current speed, direction (N,S,E,W), time of arrivel and so on?
|
You can display whatever you want as long as you program it.
Please don't see this as a tool for end users - it's as the caption says only for developers.
__________________
Skinning to go... VD2
My Plugins: BluetoothControl, Contacts, Scribble, MWConn, Phidgets, Skype, PluginBrowser, LogoDashboard, SkinBrowser
My Tools: CFInjector
My Skins: Street WS, Gizmo, Cyclone, Drive
|
|
|
March 22nd, 2008, 10:36 AM
|
#9 (permalink)
|
|
10 Farad - Flux Capacity
Join Date: Nov 2004
Location: Munich, Germany
Vehicle: Audi A3
Posts: 1,024
|
Quote:
Originally Posted by Reagan
I've been thinking of something similar to this for some time. This is great work Zoran! Brilliant!
|
Thx Reagan.
__________________
Skinning to go... VD2
My Plugins: BluetoothControl, Contacts, Scribble, MWConn, Phidgets, Skype, PluginBrowser, LogoDashboard, SkinBrowser
My Tools: CFInjector
My Skins: Street WS, Gizmo, Cyclone, Drive
|
|
|
April 3rd, 2008, 11:51 PM
|
#10 (permalink)
|
|
Newbie - Zero Capacity
Join Date: Apr 2008
Posts: 3
|
catch label events
Hello Zorro, I have 2 questions about CFInjector. First of all, is there any way to catch events from injected labels. I need to catch clicks on that labels somehow. If CFInjector don't have such api, maybe you can point me to some winapi way ? And the second question, how can I change already injected label text in runtime ? call InjectText again for exsting label id and then call DrawInjectedControls ? Or am I missing something ?
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|