Changes

Jump to: navigation, search

Drawing Graphics using PowerShell 1.0 and GDI+

39 bytes added, 19:55, 27 October 2016
m
Text replacement - "<table border="0" cellspacing="0">" to "<table border="0" cellspacing="0" width="100%">"
<googlehtmlet>BUY_WPSpowershell</googlehtmlet>
== An Overview of GDI+ ==
<googlehtmlet>ADSDAQBOX_FLOWadsdaqbox_flow</googlehtmlet>
GDI+ is part of the .NET framwork and is the standard Windows API for working with display hardware to draw graphics on Windows XP, Windows Server 2003 and later Microsoft operating systems. The ''GDI'' in ''GDI+'' is an abbreviation for ''Graphics Display Interface''. In terms of using GDI+ within Windows PowerShell it is used in conjunction with WinForms, whereby WinForms provides dialogs, controls and the Form canvas on which the drawing takes place. For more information in WinForms in the context of Windows PowerShell, refer to the chapter entitled [[Creating GUIs in Windows PowerShell 1.0 with WinForms]].
== Loading the GDI+ and WinForms .NET Assemblies ==
As previously mentionmentioned, Windows PowerShell GDI+ development is typically performed in conjunction with WinForms. Neither the GDI+, nor the WinForms .NET assemblies are loaded into the Windows PowerShell environment by default. It is necessary, therefore, to load these assemblies before beginning the development process. GDI+ and Winforms reside in the [Windows.Drawing] and [Windows.Windows.Forms] assemblies respectively. These can be loaded using the following commands:
<pre>
Applications with graphical user interfaces are primarily ''event driven''. This means that event handlers must be written to define what actions are to be performed when certain activities occur with regard to the user interface. When a user clicks a button, for example, an event handler performs the necessary tasks associated with that button being pressed (if the button was a Close button, the event handler would be responsible for exiting the application).
In terms of graphics drawing, when a form is displayed a ''paint'' event is triggered. Similarly, when a form needs to be repainted (for example because all or part of the form was obscured and then uncovered by another window), the paint event is also triggered. it It is, therefore, the job of the ''paint handler'' to perform the graphics drawing tasks. A paint event handler is declared in Windows PowerShell via a call to ''add_paint()'':
<pre>
[[Image:windows_powershell_gdi_example.jpg|A Windows PowerShell/GDI+ Example]]
 
 
<google>BUY_WPS_BOTTOM</google>

Navigation menu