C# example?

All about PB Automation and custom integration

Moderator: Moderator Group

C# example?

Postby Phantavision_HvA » Wed Apr 11, 2012 12:45 pm

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?
Phantavision_HvA
 
Posts: 5
Joined: Wed Mar 21, 2012 10:05 am

Re: C# example?

Postby Jan Huewel » Wed Apr 11, 2012 2:41 pm

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
Jan Huewel
 
Posts: 260
Joined: Fri Jul 11, 2008 11:49 am
Location: earth

Re: C# example?

Postby Phantavision_HvA » Wed Apr 18, 2012 11:18 am

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.
Phantavision_HvA
 
Posts: 5
Joined: Wed Mar 21, 2012 10:05 am

Re: C# example?

Postby Daniel Kaminski » Wed Apr 18, 2012 1:33 pm

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
--
Daniel Kaminski
Pandoras Box Expert
User avatar
Daniel Kaminski
 
Posts: 1071
Joined: Tue Jul 22, 2008 10:55 am
Location: Herten, Germany

Re: C# example?

Postby Phantavision_HvA » Wed Apr 18, 2012 3:11 pm

Thnx for the help! We've solved it :).
Phantavision_HvA
 
Posts: 5
Joined: Wed Mar 21, 2012 10:05 am


Return to Integration of 3rd party applications (SDK)

Who is online

Users browsing this forum: No registered users and 1 guest