Posts Tagged ‘Windows Forms’

  1. Hello, Windows Forms(Tcl/CSharp) World!

    Posted on 3月 31st, 2013 by cx20

    Windows Forms(Tcl/CSharp)

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

    ソースコード

    package require java
     
    java::load -gac System.Windows.Forms.dll
    java::import -package System.Windows.Forms Form Application Label
    set form [java::new Form]
    java::prop $form Text "Hello, World!"
    java::prop $form Size [java::new System.Drawing.Size 640 480]
    set label1 [java::new Label]
    java::prop $label1 Text "Hallo, Tcl/CSharp World!"
    java::prop $label1 Size [java::new System.Drawing.Size 320 20]
    [java::prop $form Controls] Add $label1
     
    java::call Application Run $form

    コンパイル方法

    C:¥> tclsh Hello.tcl

    実行結果

    +------------------------------------------+
    |Hello, World!                    [_][~][X]|
    +------------------------------------------+
    |Hello, Windows Forms(Tcl/CSharp) World!   |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+
  2. Hello, Windows Forms(UWSC) World!

    Posted on 6月 17th, 2012 by cx20

    Windows Forms(UWSC)

    Windows フォーム(Windows Forms)は .NET Framework におけるユーザーインターフェイス基盤である。Windows アプリケーションにおけるウィンドウやダイアログに対応する。
    以下は UWSC における Windows フォーム の例となっている。
    UWSC 自体は .NET 対応言語ではないが、v4.6b より追加された PowerShell() 関数により、PowerShell 経由で Windows フォームが利用できるようになっている。

    ソースコード(UWSC + PowerShell)

    Option Explicit
     
    Main()
     
    Procedure Main()
        PowerShell( helloBlock, True, True )
    FEnd
     
    TextBlock helloBlock
        [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(UWSC) World!"
        $form.Controls.Add( $label1 )
        $form.ShowDialog()
    EndTextBlock

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

    Option Explicit
     
    Main()
     
    Procedure Main()
        PowerShell( helloBlock, True, True )
    FEnd
     
    TextBlock helloBlock
        $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(UWSC) 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()
    EndTextBlock

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

    Option Explicit
     
    Main()
     
    Procedure Main()
        PowerShell( helloBlock, True, True )
    FEnd
     
    TextBlock helloBlock
        $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(UWSC) 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()
    EndTextBlock

    実行方法

    C:¥> uwsc /K hello.uws

    実行結果

    +------------------------------------------+
    |Hello, World!                    [_][~][X]|
    +------------------------------------------+
    |Hello, Windows Forms(UWSC) World!         |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+
  3. 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!      |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+
  4. 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!      |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+
  5. 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!          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+
  6. 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!        |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+
  7. 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!    |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+
  8. 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!   |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+
  9. 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!   |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+
  10. 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!     |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    +------------------------------------------+