Archive for the ‘.NET’ Category

  1. Hello, Windows Forms(Oxygene) World!

    Posted on 6月 16th, 2012 by cx20

    Windows Forms(Oxygene)

    Windows フォーム(Windows Forms)は .NET Framework におけるユーザーインターフェイス基盤である。Windows アプリケーションにおけるウィンドウやダイアログに対応する。
    以下は Oxygene における Windows フォーム の例となっている。

    ソースコード

    namespace hello;
     
    interface
    uses
        System,
        System.Drawing,
        System.Windows.Forms;
     
    type
        HelloForm = class(System.Windows.Forms.Form)
        public
            constructor;
            class method Main(args: array of String): Integer;
        end;
     
    implementation
     
    constructor HelloForm;
    var
        label1: Label;
    begin
        self.Size := new Size( 640, 480 );
        self.Text := "Hello, World!";
        label1 := new Label();
        label1.Size := new Size( 320, 20 );
        label1.Text := "Hello, Windows Forms(Oxygene) World!";
        self.Controls.Add( label1 );
    end;
     
    [STAThread] 
    class method HelloForm.Main(args: array of String): Integer;
    begin
        using form := new HelloForm do
        Application.Run(form);
    end;
     
    end.

    実行方法

    C:¥> oxygene Hello.pas ^
        -type:winexe ^
        -ref:System.dll;System.Drawing.dll;System.Windows.Forms.dll

    実行結果

    +------------------------------------------+
    |Hello, World!                    [_][~][X]|
    +------------------------------------------+
    |Hello, Windows Forms(Oxygene) World!      |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+
  2. Hello, Windows Forms(Nemerle) World!

    Posted on 6月 15th, 2012 by cx20

    Windows Forms(Nemerle)

    Windows フォーム(Windows Forms)は .NET Framework におけるユーザーインターフェイス基盤である。Windows アプリケーションにおけるウィンドウやダイアログに対応する。
    以下は Nemerle における Windows フォーム の例となっている。

    ソースコード

    using System.Drawing;
    using System.Windows.Forms;
     
    class HelloForm : Form {
       public this() {
           Size = Size( 640, 480 );
           Text = "Hello, World";
           def label1 = Label();
           label1.Size = Size( 320, 20 );
           label1.Text = "Hello, Windows Forms(Nemerle) World!";
           Controls.Add( label1 );
       }
     
       public static Main() : void {
           def form = HelloForm();
           Application.Run( form );
       }
    }

    実行方法

    C:¥> ncc -o hello -target:winexe -r:System.Windows.Forms hello.n

    実行結果

    +------------------------------------------+
    |Hello, World!                    [_][~][X]|
    +------------------------------------------+
    |Hello, Windows Forms(Nemerle) World!      |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+
  3. Hello, Windows Forms(Boo) World!

    Posted on 6月 14th, 2012 by cx20

    Windows Forms(Boo)

    Windows フォーム(Windows Forms)は .NET Framework におけるユーザーインターフェイス基盤である。Windows アプリケーションにおけるウィンドウやダイアログに対応する。
    以下は Boo における Windows フォーム の例となっている。

    ソースコード

    import System
    import System.Drawing
    import System.Windows.Forms
     
    class HelloForm( Form ):
        def constructor():
            super()
            self.Size = Size( 640, 480 )
            self.Text = "Hello, World!"
            label1 = Label()
            label1.Size = Size( 320, 20 )
            label1.Text = "Hello, Windows Forms(Boo) World!"
            self.Controls.Add( label1 )
     
    [STAThread]
    def Main(argv as (string)):
        form = HelloForm()
        Application.Run( form )

    実行方法

    C:¥> booc -target:winexe Hello.boo

    実行結果

    +------------------------------------------+
    |Hello, World!                    [_][~][X]|
    +------------------------------------------+
    |Hello, Windows Forms(Boo) World!          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+
  4. Hello, Windows Forms(Cobra) World!

    Posted on 6月 13th, 2012 by cx20

    Windows Forms(Cobra)

    Windows フォーム(Windows Forms)は .NET Framework におけるユーザーインターフェイス基盤である。Windows アプリケーションにおけるウィンドウやダイアログに対応する。
    以下は Cobra における Windows フォーム の例となっている。

    ソースコード

    use System.Windows.Forms
    use System.Drawing
     
    class HelloForm inherits Form
     
        cue init
            base.init
            .size = Size( 640, 480 )
            .text = "Hello, World"
            label1 = Label()
            label1.size = Size( 320, 20 )
            label1.text = "Hello, Windows Forms(Cobra) World!"
            .controls.add( label1 )
     
    class Program
     
        def main is shared
            has STAThread
            form = HelloForm()
            Application.run( form )

    実行方法

    C:¥> cobra -target:winexe -compile Hello.cobra

    実行結果

    +------------------------------------------+
    |Hello, World!                    [_][~][X]|
    +------------------------------------------+
    |Hello, Windows Forms(Cobra) World!        |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+
  5. Hello, Windows Forms(Phalanger) World!

    Posted on 6月 12th, 2012 by cx20

    Windows Forms(Phalanger)

    Windows フォーム(Windows Forms)は .NET Framework におけるユーザーインターフェイス基盤である。Windows アプリケーションにおけるウィンドウやダイアログに対応する。
    以下は Phalanger における Windows フォーム の例となっている。

    ソースコード

    <?
    use System;
    use SystemWindowsForms;
    use SystemDrawing;
     
    class HelloForm extends SystemWindowsFormsForm
    {
        public function __construct()
        {
            $this->Size = new SystemDrawingSize( 640, 480 );
            $this->Text = 'Hello, World!';
     
            $label1 = new SystemWindowsFormsLabel();
            $label1->Size = new SystemDrawingSize( 320, 20 );
            $label1->Text = 'Hello, Windows Forms(Phalanger) World!';
            $this->Controls->Add( $label1 );
        }
        static function Main()
        {
            FormsApplication::Run(new HelloForm());
        }
    }
    ?>

    ソースコード(アプリケーション設定ファイル)

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <phpNet>
            <classLibrary>
                <add assembly="mscorlib" />
                <add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
                <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
                <add assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
            </classLibrary>
        </phpNet>
    </configuration>

    実行方法

    C:¥> phpc /pure /target:winexe Hello.php

    実行結果

    +------------------------------------------+
    |Hello, World!                    [_][~][X]|
    +------------------------------------------+
    |Hello, Windows Forms(Phalanger) World!    |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+
  6. Hello, Windows Forms(ClojureCLR) World!

    Posted on 6月 11th, 2012 by cx20

    Windows Forms(ClojureCLR)

    Windows フォーム(Windows Forms)は .NET Framework におけるユーザーインターフェイス基盤である。Windows アプリケーションにおけるウィンドウやダイアログに対応する。
    以下は ClojureCLR における Windows フォーム の例となっている。

    ソースコード

    (System.Reflection.Assembly/LoadWithPartialName "System.Windows.Forms")
     
    (import '(System.Windows.Forms Form))
    (import '(System.Windows.Forms Label))
    (import '(System.Windows.Forms Application))
     
    (def form (Form.))
    (doto form
      (.set_Size (new System.Drawing.Size 640 480))
      (.set_Text "Hello, World!")
    )
    (def label1 (Label.))
    (doto label1
      (.set_Size (new System.Drawing.Size 320 20))
      (.set_Text "Hello, Windows Forms(ClojureCLR) World!")
    )
    (doto (.Controls form)
    (.Add label1))
     
    (. Application Run form)

    実行方法

    C:¥> Clojure.Main Hello.clj

    実行結果

    +------------------------------------------+
    |Hello, World!                    [_][~][X]|
    +------------------------------------------+
    |Hello, Windows Forms(ClojureCLR) World!   |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+
  7. Hello, Windows Forms(IronScheme) World!

    Posted on 6月 10th, 2012 by cx20

    Windows Forms(IronScheme)

    Windows フォーム(Windows Forms)は .NET Framework におけるユーザーインターフェイス基盤である。Windows アプリケーションにおけるウィンドウやダイアログに対応する。
    以下は IronScheme における Windows フォーム の例となっている。

    ソースコード

    (import
        (rnrs)
        (ironscheme clr)
    )
     
    (clr-reference System.Windows.Forms)
    (clr-reference System.Drawing)
     
    (clr-using System.Windows.Forms)
    (clr-using System.Drawing)
     
    (begin
        (define form (clr-new Form))
        (clr-prop-set! Form Size form (clr-new Size 640 480))
        (clr-prop-set! Form Text form "Hello, World!")
        (define label1 (clr-new Label))
        (clr-prop-set! Label Size label1 (clr-new Size 320 20))
        (clr-prop-set! Label Text label1 "Hello, Windows Forms(IronScheme) World!")
        (define formControls (clr-prop-get Form Controls form ))
        (clr-call Form+ControlCollection Add formControls label1 )
     
        (clr-static-call Application (Run Form) form)
    )

    実行方法

    C:¥> isc Hello.ss

    実行結果

    +------------------------------------------+
    |Hello, World!                    [_][~][X]|
    +------------------------------------------+
    |Hello, Windows Forms(IronScheme) World!   |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+
  8. Hello, Windows Forms(IronRuby) World!

    Posted on 6月 9th, 2012 by cx20

    Windows Forms(IronRuby)

    Windows フォーム(Windows Forms)は .NET Framework におけるユーザーインターフェイス基盤である。Windows アプリケーションにおけるウィンドウやダイアログに対応する。
    以下は IronRuby における Windows フォーム の例となっている。

    ソースコード

    require 'mscorlib'
    require 'System.Windows.Forms'
    require 'System.Drawing'
    include System::Windows::Forms
    include System::Drawing
     
    class HelloForm < Form
      def initialize
        self.Size = Size.new 640, 480
        self.Text = "Hello, World!"
        label1 = Label.new
        label1.Size = Size.new 320, 20
        label1.Text = "Hello, Windows Form(IronRuby) World!"
        self.Controls.Add( label1 )
      end
    end
     
    form = HelloForm.new
    Application.Run(form)

    実行方法

    C:¥> ir Hello.rb

    実行結果

    +------------------------------------------+
    |Hello, World!                    [_][~][X]|
    +------------------------------------------+
    |Hello, Windows Forms(IronRuby) World!     |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+
  9. Hello, Windows Forms(IronPython) World!

    Posted on 6月 8th, 2012 by cx20

    Windows Forms(IronPython)

    Windows フォーム(Windows Forms)は .NET Framework におけるユーザーインターフェイス基盤である。Windows アプリケーションにおけるウィンドウやダイアログに対応する。
    以下は IronPython における Windows フォーム の例となっている。

    ソースコード

    import clr
    clr.AddReference("System.Windows.Forms")
    clr.AddReference("System.Drawing")
    from System.Windows import Forms
    from System import Drawing
     
    class HelloForm(Forms.Form):
        def __init__(self):
            self.Size = Drawing.Size( 640, 480 )
            self.Text = 'Hello, World!'
            label1 = Forms.Label()
            label1.Size = Drawing.Size( 320, 20 )
            label1.Text = 'Hello, Windows Forms(IronPython) World!'
            self.Controls.Add( label1 )
     
    if __name__ == '__main__':
        form = HelloForm()
        Forms.Application.Run(form)

    実行方法

    C:¥> ipy Hello.py

    実行結果

    +------------------------------------------+
    |Hello, World!                    [_][~][X]|
    +------------------------------------------+
    |Hello, Windows Forms(IronPython) World!   |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+
  10. Hello, Windows Forms(PowerShell) World!

    Posted on 6月 7th, 2012 by cx20

    Windows Forms(PowerShell)

    Windows フォーム(Windows Forms)は .NET Framework におけるユーザーインターフェイス基盤である。Windows アプリケーションにおけるウィンドウやダイアログに対応する。
    以下は PowerShell における Windows フォーム の例となっている。

    ソースコード(PowerShell のみ)

    [void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
    $form = New-Object Windows.Forms.Form
    $form.Size = New-Object Drawing.Size 640,480
    $form.Text = "Hello, World!"
    $label1 = New-Object Windows.Forms.Label
    $label1.Size = New-Object Drawing.Size 320, 20
    $label1.Text = "Hello, Windows Forms(PowerShell) World!"
    $form.Controls.Add( $label1 )
    $form.ShowDialog()

    なお、PowerShell 2.0 から Add-Type コマンドレットを用いることにより C# や VB.NET のコードも呼び出せるようになっている。

    ソースコード(PowerShell + C#)

    $source = @"
    using System;
    using System.Drawing;
    using System.Windows.Forms;
     
    public class HelloForm : Form
    {
        public HelloForm()
        {
            this.Size = new Size( 640, 480 );
            this.Text = "Hello, World!";
     
            Label label1 = new Label();
            label1.Size = new Size( 320, 20 );
            label1.Text = "Hello, Windows Forms(PowerShell) World!";
     
            this.Controls.Add( label1 );
        }
        [STAThread]
        public static void Main()
        {
            HelloForm form = new HelloForm();
            Application.Run(form);
        }
    }
    "@
    Add-Type -Language CSharp -TypeDefinition $source -ReferencedAssemblies ("System.Drawing", "System.Windows.Forms" )
    [HelloForm]::Main()

    ソースコード(PowerShell + VB.NET)

    $source = @"
    Imports System
    Imports System.Drawing
    Imports System.Windows.Forms
     
    Public Class HelloForm
        Inherits Form
     
        Public Sub New()
            Me.Size = New Size( 640, 480 )
            Me.Text = "Hello, World!"
     
            Dim label1 As New Label
            label1.Size = New Size( 320, 20 )
            label1.Text = "Hello, Windows Forms(PowerShell) World!"
     
            Me.Controls.Add( label1 )
        End Sub
     
        <STAThread> _
        Shared Sub Main()
            Dim form As New HelloForm()
            Application.Run(form)
        End Sub
    End Class
    "@
    Add-Type -Language VisualBasic -TypeDefinition $source -ReferencedAssemblies ("System.Drawing", "System.Windows.Forms" )
    [HelloForm]::Main()

    実行方法

    C:¥> PowerShell -File Hello.ps1

    実行結果

    +------------------------------------------+
    |Hello, World!                    [_][~][X]|
    +------------------------------------------+
    |Hello, Windows Forms(PowerShell) World!   |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+