Difference between revisions of "Scripting"
(Created page with "==Introduction to C#== DXLog.net has been written in a way so that bespoke C# scripts can be written by the end user and will be compiled into DXLog.net at runtime. This makes ...") |
(→Introduction to C#) |
||
Line 1: | Line 1: | ||
==Introduction to C#== | ==Introduction to C#== | ||
− | DXLog.net has been written in a way | + | DXLog.net has been written in such a way that bespoke C# scripts can be written by the end user and will be compiled into DXLog.net at runtime. |
This makes DXLog.net very versatile and with a little C# knowledge a very powerful contest logging tool. | This makes DXLog.net very versatile and with a little C# knowledge a very powerful contest logging tool. | ||
− | To learn the basics about C# there are is lots of free | + | To learn the basics about C# there are is lots of free on-line help like http://www.homeandlearn.co.uk/csharp/csharp.html |
+ | |||
+ | Microsoft have a free fully functional version of Visual Studio called Community 2013, available from https://www.visualstudio.com/en-us/products/visual-studio-community-vs | ||
+ | |||
+ | |||
+ | ==Example_Scripts== | ||
+ | |||
+ | There are example scripts in the download directory http://dxlog.net/sw/download/script_examples/ | ||
+ | |||
+ | The following script is an example of a C# script which keeps the Elecraft K3 keyer speed in sync with the CW speed set in DXLog.net<br> | ||
+ | |||
+ | //INCLUDE_ASSEMBLY System.dll | ||
+ | //INCLUDE_ASSEMBLY System.Windows.Forms.dll | ||
+ | //INCLUDE_ASSEMBLY CWKeyer.dll | ||
+ | |||
+ | using System; | ||
+ | using System.Windows.Forms; | ||
+ | using CWKeyer; | ||
+ | |||
+ | namespace DXLog.net | ||
+ | { | ||
+ | public class Script : ScriptClass | ||
+ | { | ||
+ | FrmMain mainForm; | ||
+ | public void Initialize(FrmMain main) | ||
+ | { | ||
+ | mainForm = main; | ||
+ | if (mainForm._cwKeyer != null) | ||
+ | mainForm._cwKeyer.CWSpeedChange += new CWKey.CWSpeedChangeDelegate(handleCWSpeedChange); | ||
+ | } | ||
+ | public void Deinitialize() | ||
+ | { | ||
+ | if (mainForm._cwKeyer != null) | ||
+ | mainForm._cwKeyer.CWSpeedChange -= handleCWSpeedChange; | ||
+ | } | ||
+ | |||
+ | public void Main(FrmMain main, ContestData cdata, COMMain comMain) | ||
+ | { | ||
+ | } | ||
+ | |||
+ | private void handleCWSpeedChange(int radioNumber, int newSpeed) | ||
+ | { | ||
+ | CATCommon radioObject = mainForm.COMMainProvider.RadioObject(radioNumber); | ||
+ | if (radioObject == null) | ||
+ | { | ||
+ | mainForm.SetMainStatusText(String.Format("CAT object for radio {0} isn't available!", radioNumber)); | ||
+ | return; | ||
+ | } | ||
+ | radioObject.SendCustomCommand(String.Format("ks0{0};", newSpeed)); | ||
+ | mainForm.SetMainStatusText(String.Format("Radio {0} CW speed changed to {1} wpm!", radioNumber, newSpeed)); | ||
+ | } | ||
+ | } | ||
+ | } |
Revision as of 07:07, 12 April 2015
Introduction to C#
DXLog.net has been written in such a way that bespoke C# scripts can be written by the end user and will be compiled into DXLog.net at runtime.
This makes DXLog.net very versatile and with a little C# knowledge a very powerful contest logging tool.
To learn the basics about C# there are is lots of free on-line help like http://www.homeandlearn.co.uk/csharp/csharp.html
Microsoft have a free fully functional version of Visual Studio called Community 2013, available from https://www.visualstudio.com/en-us/products/visual-studio-community-vs
Example_Scripts
There are example scripts in the download directory http://dxlog.net/sw/download/script_examples/
The following script is an example of a C# script which keeps the Elecraft K3 keyer speed in sync with the CW speed set in DXLog.net
//INCLUDE_ASSEMBLY System.dll //INCLUDE_ASSEMBLY System.Windows.Forms.dll //INCLUDE_ASSEMBLY CWKeyer.dll using System; using System.Windows.Forms; using CWKeyer; namespace DXLog.net { public class Script : ScriptClass { FrmMain mainForm; public void Initialize(FrmMain main) { mainForm = main; if (mainForm._cwKeyer != null) mainForm._cwKeyer.CWSpeedChange += new CWKey.CWSpeedChangeDelegate(handleCWSpeedChange); } public void Deinitialize() { if (mainForm._cwKeyer != null) mainForm._cwKeyer.CWSpeedChange -= handleCWSpeedChange; } public void Main(FrmMain main, ContestData cdata, COMMain comMain) { } private void handleCWSpeedChange(int radioNumber, int newSpeed) { CATCommon radioObject = mainForm.COMMainProvider.RadioObject(radioNumber); if (radioObject == null) { mainForm.SetMainStatusText(String.Format("CAT object for radio {0} isn't available!", radioNumber)); return; } radioObject.SendCustomCommand(String.Format("ks0{0};", newSpeed)); mainForm.SetMainStatusText(String.Format("Radio {0} CW speed changed to {1} wpm!", radioNumber, newSpeed)); } } }