Page 1 of 1

C# example?

PostPosted: Wed Apr 11, 2012 12:45 pm
by Phantavision_HvA
Well im just wondering since i see alot of visual basic examples but no c# examples, could u guys send me an example or tutorial about how to write a custom C# application for coolux?

Re: C# example?

PostPosted: Wed Apr 11, 2012 2:41 pm
by Jan Huewel
Hi there,

as C# and VB .net are very similar languages the samples are all provided in the "easier" language VB net

However the main thing you will need to do is convert the dll declarations to C#

On more thing on Win7 64bit please make sure to set the build platform target to x86

Please see example code below

public partial class Form1 : Form
{
[System.Runtime.InteropServices.DllImport("PandorasAutomation.dll", EntryPoint = "AutoUnInitialize", ExactSpelling = false, CharSet = System.Runtime.InteropServices.CharSet.Ansi, SetLastError = true)]
public static extern void AutoUnInitialize();

[System.Runtime.InteropServices.DllImport("PandorasAutomation.dll", EntryPoint = "AutoInitialize", ExactSpelling = false, CharSet = System.Runtime.InteropServices.CharSet.Ansi, SetLastError = true)]
public static extern void AutoInitialize(string IP, Int32 Domain);

[System.Runtime.InteropServices.DllImport("PandorasAutomation.dll", EntryPoint = "AutoSetParamDouble", ExactSpelling = false, CharSet = System.Runtime.InteropServices.CharSet.Ansi, SetLastError = true)]
public static extern Boolean AutoSetParamDouble(Int32 SiteNum, Int32 DeviceNum, String ParamName, Double Value);


//(ByVal siteNum As Integer, ByVal deviceNum As Integer, ByVal ParamName As String, ByVal value As Double) As Boolean

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
AutoInitialize("127.0.0.1", 0);
}

private void trackBar1_ValueChanged(object sender, EventArgs e)
{
AutoSetParamDouble(2,1,"Opacity",trackBar1.Value) ;
}
}

Best regards

Jan Huewel

Re: C# example?

PostPosted: Wed Apr 18, 2012 11:18 am
by Phantavision_HvA
Hi Jan,

thnx for the reply! We have some other issues regarding changing the values of a layers in PB.
For example: When we want to change the opacity, we change the value of "AutoSetParamDouble(2,1,"Opacity",trackBar1.Value) ;".
Sadly, this does not cope entirely when we try to change the "X pos" value. When we change to value to "32000" the "X pos" sets to "-6.000". It doesn't make any sense to us how these values relate to each other.

With kind regards.

Re: C# example?

PostPosted: Wed Apr 18, 2012 1:33 pm
by Daniel Kaminski
Hi there,

The funktion AutoSetParamDouble sends 1:1 values.
X Pos has a Value Range from -999.999 to 999.999.

So if you send a Value of 32000 it is way out of range.

What happens if you send 1:1 Values? Does that work?

Daniel

Re: C# example?

PostPosted: Wed Apr 18, 2012 3:11 pm
by Phantavision_HvA
Thnx for the help! We've solved it :).