[DXLog.net - Support] My First C# script

9A5K 9a5k at 9a5k.com
Wed Mar 18 17:39:59 CET 2015


Hi Oliver...

You should move event hook method to Initialize method.. it's called always
when scripts are compiled
(for example when log is opened or script manager screen is closed)..

We did it already for this on following way (also script is now uploaded at
http://dxlog.net/sw/download/script_examples ):



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));
        }
    }
}



On Wed, Mar 18, 2015 at 3:32 PM, Oliver Grossmann <olli at bretzi.de> wrote:

> Hello Chris,
>
> thanks for the information.
>
> I started with the MS Visual Studio 2010 Express C# to write my first
> script.
>
> I do like the possibility to sync speed of PC Keyer and internal radio
> keyer. In my case I want to sync internal K3 Keyer with DXLog.net. The
> script is using the event main._cwKeyer.CWSpeedChange. To activate the
> script I do need to call it on a message or by pressing a assigned key. For
> my script a start at startup would be a great feature, for other scripts a
> start at loading a certain contest could also be a nice.
>
> My Programming skill are limited to C and C++, so the strictly world of
> object oriented programming is quite new to me.
>
> In my script I wasn't able to get access to a CATCommon object from the
> main instance. I resolved this by using a module global variable of type
> FrmMain and used it in my callback for the CWSpeedChange. Is this a
> suitable solution or is there a better way to handle it without an direct
> reference to the FrmMain instance?
>
> As reference I attached my Script.
>
> Thanks a lot for the support and the fantastic script interface,
>
> Olli, DH2WQ
>
> ------------------------------------------------------------------------
> Oliver Grossmann | DH2WQ | oliver.grossmann at bretzi.de
>
> Am 17.03.2015 um 19:11 schrieb 9A5K:
>
>> Hi Oliver...
>>
>> Yep, there are couple of samples available at
>> http://dxlog.net/sw/download/script_examples/
>>
>> You can easily check what objects, properties, events and methods are
>> available with Xamarin Studio (or MS Visual Studio),
>> if you add reference to DXLog.net.exe and dll's.
>>
>>
>>
>> On Tue, Mar 17, 2015 at 7:04 PM, Oliver Grossmann <olli at bretzi.de
>> <mailto:olli at bretzi.de>> wrote:
>>
>>     Hi Chris,
>>     is the API for the C# scripts available?
>>
>>     Thanks,
>>     Olli, DH2WQ
>>
>>     ------------------------------__----------------------------
>> --__------------
>>     Oliver Grossmann | DH2WQ | oliver.grossmann at bretzi.de
>>     <mailto:oliver.grossmann at bretzi.de>
>>
>>     Am 06.02.2015 um 18:29 schrieb 9A5K:
>>
>>         Hi everyone.
>>
>>         Version 2.2.9 is now available in public download folder.
>>
>>         New contest is supported for this weekend, it's XE RTTY contest.
>>
>>         Also, there is a big new feature available: custom C# scripts.
>>         C# scripts are compiled during runtime and can be executed in
>>         couple of
>>         different ways:
>>         1. By assigning a shortcut - when pressed, main method in the
>>         script will
>>         be executed
>>         2. By assigning some name - when found as macro in message, main
>>         method
>>         will be executed
>>         3. By attaching to some event - when event is raised from
>>         DXLog.net, method
>>         defined will be executed
>>
>>         Scripting will need a lot of documentation as this part of the
>>         code has
>>         full access to all objects/classes available in DXLog.
>>         There are couple of samples uploaded in public download
>>         directory, I will
>>         try to expand it during the time with more examples
>>         and finished scripts.
>>         In case you need some help with script, let me now and I'll be
>>         glad to
>>         assist with it.
>>
>>         Enjoy.
>>
>>         73,
>>         Chris - 9A5K
>>
>>         Release notes:
>>         Ver 2.2.9
>>         ------------------------
>>         - Mouse middle button click in digi mode decoder now also adds
>>         call to
>>         partner stack. (TNX N6TV)
>>         - New option added: Tools->Scripts manager.
>>             DXLog.net now supports custom made C# scripts, to enable
>>         additional
>>         functionalities.
>>             Custom scripts are written in C# language and they are
>>         compiled during
>>         runtime.
>>             Script can be assigned to some shortcut and will be executed
>>         when
>>         shortcut key is pressed.
>>             Also, script can be called by name from CW/Digi message as
>>         macro command
>>         prefixed with "$!".
>>             For example, if CW/Digi message contains $!SCRIPT1, it will
>>         execute
>>         script with name SCRIPT1.
>>         - New contest supported: XE RTTY International Contest.
>>         - Added band changes count for Multi/Single category in CQ WPX
>>         RTTY Contest.
>>         - CTRL+SHIFT+F4 on the fly scenario/message editor wasn't
>>         working properly.
>>         Fixed. (TNX IK2NCJ)
>>         _________________________________________________
>>         Support mailing list
>>         Support at dxlog.net <mailto:Support at dxlog.net>
>>         http://www.dxlog.net/mailman/__listinfo/support
>>         <http://www.dxlog.net/mailman/listinfo/support>
>>
>>
>>
> _______________________________________________
> Support mailing list
> Support at dxlog.net
> http://www.dxlog.net/mailman/listinfo/support
>
>


More information about the Support mailing list