Building a Windows Application in Powershell (converting C#)

 

C# code

Powershell code

this.button1 = new System.Windows.Forms.Button();

$button1 = new –object System.Windows.Forms.Button;

New

New-object

This.

$

()

Not needed

;

;  can stay or removed

>, <, =, !=…

-gt, -lt, -eq, -ne… (look in the PS reference sheet)

True, false…

$true, $false

this.comboBox1.Items.AddRange(new object[] {"AP Export","Sales Import",

"GL Export","Vendor Import"});

$CbValues1 = "AP Export","Sales Import";

$comboBox1.Items.AddRange($cbValues1);

this.comboBox1.Location = new System.Drawing.Point(131, 83);

$comboBox1.Location = new-object System.Drawing.Point  @(131, 83);

..Point(131,83);  or ..Size(121,21);

..Point  @(131,83);  or ..Size @(121,21);

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

$Form1.AutoScaleDimensions = new-object System.Drawing.SizeF @([double] 6, [double] 13);

..SizeF(6F,13F);

..SizeF @([double] 6, [double] 13);

this.SuspendLayout();

Not needed

this.ResumeLayout(false);

Not needed

this.PerformLayout();

Not needed

 

 

 

Order of building the Powershell Windows Script:

1.       Set-ExecutionPolicy –executionpolicy remotesigned     (might be needed)

2.       Load all General Assemblies Components (GAC’s).

3.       Initialize all Variables and Controls objects

4.       Create all NonFunction/Functions and/or Events ($button.Add_Click, $Combo1.Add_Selec…)

5.       Put together all the Controls objects

6.        Last lines should Activate the form

Advertisements

About maxt2posh

I’m from Puerto Rico, have been working with computers since 1979. Throughout many years, I have worked with SQL Server Technologies, provided support to Windows Servers/Client machines, Microsoft Virtualization Technologies, and build some Visual Studio solutions. I’m a Microsoft PowerShell MVP since 2009 and MVP SAPIEN Technologies since 2010. I speak in most of the SQLSaturday, IT Pro and .NET camps events around the Florida’s State. Also founder of the Florida PowerShell User Group which meeting every 3rd Tuesday evening of the month.
This entry was posted in PowerShell. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s