ホーム » .NET » フォームへの描画

2013年7月
 123456
78910111213
14151617181920
21222324252627
28293031  

カテゴリー

アーカイブ

ブログ統計情報

  • 79,970 アクセス



フォームへの描画

フォームに,左上から右下へグラデーションで表示する動作を幾つかの言語で書いてみた.


C#
//…
using System.Drawing.Drawing2D;
//…
namespace WinApCS
{
   public partial class FormCS : Form
   {
     public FormCS()
     {
       InitializeComponent();
     }
     private void Form1_Paint(object sender, PaintEventArgs e)
     {
       LinearGradientBrush brush = new LinearGradientBrush
            (ClientRectangle,Color.Green,Color.White,LinearGradientMode.ForwardDiagonal);
       e.Graphics.FillRectangle(brush,ClientRectangle);
     }
     protected override void OnResize(System.EventArgs e)
     {
       Invalidate();
     }
   }
}


VB
Imports System.Drawing.Drawing2D
Public Class FormVB
   Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
     Dim brush As New LinearGradientBrush
            (ClientRectangle, Color.Blue, Color.White, LinearGradientMode.ForwardDiagonal)
     e.Graphics.FillRectangle(brush, ClientRectangle)
   End Sub
   Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
     Invalidate()
   End Sub
End Class


J#
//…
import System.Drawing.Drawing2D.*;
//…
public class FormJS extends System.Windows.Forms.Form
{
   //…
   private void Form1_Paint(Object sender, PaintEventArgs e)
   {
     LinearGradientBrush brush = new LinearGradientBrush
         (get_ClientRectangle(),Color.get_Red(),Color.get_White(),LinearGradientMode.ForwardDiagonal) ;
     e.get_Graphics().FillRectangle(brush,get_ClientRectangle()) ;
   }
   protected void OnResize(System.EventArgs e)
   {
     this.Invalidate();
   }
}


C++/CLI
//…
namespace WFmCpClr {
   //…
   using namespace System::Drawing::Drawing2D;
   //…
   public ref class FormVC : public System::Windows::Forms::Form
   {
     //…
     private: System::Void FormVC_Paint
            (System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
       LinearGradientBrush^ brush = gcnew LinearGradientBrush
            (ClientRectangle,Color::Olive,Color::White,LinearGradientMode::ForwardDiagonal) ;
       e->Graphics->FillRectangle(brush,ClientRectangle) ;
     }
     private: System::Void FormVC_Resize(System::Object^ sender, System::EventArgs^ e) {
       Invalidate();
     }
   };
}

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

コメントする

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

%d人のブロガーが「いいね」をつけました。