using
System;
using
System.Drawing;
using
System.Collections;
using
System.ComponentModel;
using
System.Windows.Forms;
namespace
TypeEditorsCS
{
public class
DialogTransEditor : System.Windows.Forms.Form
{
int
_transparency;
public
int Transparency
{
get{return
_transparency;}
set
{
_transparency=value;
this.trackBar1.Value=255-value;
this.label1.Text=((255-value)*100/255).ToString("0.0")+"%";
}
}
private
System.Windows.Forms.TrackBar trackBar1;
private
System.Windows.Forms.Label label1;
private
System.Windows.Forms.Button button1;
///
<summary>
///
Required designer variable.
///
</summary>
private
System.ComponentModel.Container components = null;
public
DialogTransEditor()
{
//
//
Required for Windows Form Designer support
//
InitializeComponent();
this.SetStyle(ControlStyles.AllPaintingInWmPaint
|
ControlStyles.DoubleBuffer
|
ControlStyles.UserPaint,true);
}
///
<summary>
///
Clean up any resources being used.
///
</summary>
protected
override void
Dispose( bool disposing )
{
if(
disposing )
{
if(components
!= null)
{
components.Dispose();
}
}
base.Dispose(
disposing );
}
#region
Windows Form Designer generated code
///
<summary>
///
Required method for Designer support - do not modify
///
the contents of this method with the code editor.
///
</summary>
private
void InitializeComponent()
{
this.trackBar1
= new System.Windows.Forms.TrackBar();
this.label1
= new System.Windows.Forms.Label();
this.button1
= new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
this.SuspendLayout();
//
//
trackBar1
//
this.trackBar1.Location
= new System.Drawing.Point(0, 16);
this.trackBar1.Maximum
= 255;
this.trackBar1.Name
= "trackBar1";
this.trackBar1.Orientation
= System.Windows.Forms.Orientation.Vertical;
this.trackBar1.Size
= new System.Drawing.Size(45, 232);
this.trackBar1.TabIndex
= 0;
this.trackBar1.TickFrequency
= 8;
this.trackBar1.Scroll
+= new System.EventHandler(this.trackBar1_Scroll);
//
//
label1
//
this.label1.Font
= new System.Drawing.Font("Tahoma", 24F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label1.Location
= new System.Drawing.Point(48, 8);
this.label1.Name
= "label1";
this.label1.Size
= new System.Drawing.Size(136, 48);
this.label1.TabIndex
= 1;
//
//
button1
//
this.button1.DialogResult
= System.Windows.Forms.DialogResult.OK;
this.button1.Location
= new System.Drawing.Point(208, 16);
this.button1.Name
= "button1";
this.button1.TabIndex
= 2;
this.button1.Text
= "Ok";
//
//
DialogTransEditor
//
this.AutoScaleBaseSize
= new System.Drawing.Size(5, 13);
this.ClientSize
= new System.Drawing.Size(292, 266);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Controls.Add(this.trackBar1);
this.FormBorderStyle
= System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name
= "DialogTransEditor";
this.Text
= "Edit Transparency";
this.Paint
+= new System.Windows.Forms.PaintEventHandler(this.DialogTransEditor_Paint);
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private
void DialogTransEditor_Paint(object
sender, System.Windows.Forms.PaintEventArgs e)
{
e.Graphics.FillRectangle(Brushes.Black,64,96,192,100);
SolidBrush
sb=new
SolidBrush(Color.FromArgb(_transparency,Color.Red));
e.Graphics.FillRectangle(sb,168,64,88,168);
sb.Dispose();
}
private
void trackBar1_Scroll(object
sender, System.EventArgs e)
{
float
pc=((float)this.trackBar1.Value)/255*100f;
this.label1.Text=pc.ToString("0.0")+"%";
this._transparency=255-this.trackBar1.Value;
this.Invalidate();
}
}
}
Public
Class DialogTransEditor
Inherits System.Windows.Forms.Form
Private _transparency
As Integer
Public Property
Transparency() As
Integer
Get
Return
_transparency
End
Get
Set(ByVal
Value As Integer)
_transparency = Value
Me.trackBar1.Value
= 255 - Value
Me.label1.Text
= ((255 - Value) * 100 / 255).ToString("0.0") & "%"
End
Set
End Property
#Region
" Windows Form Designer generated code "
Public Sub
New()
MyBase.New()
'This
call is required by the Windows Form Designer.
InitializeComponent()
SetStyle(ControlStyles.AllPaintingInWmPaint
Or ControlStyles.DoubleBuffer
Or ControlStyles.UserPaint,
True)
End Sub
'Form overrides dispose to clean up the component
list.
Protected Overloads
Overrides Sub
Dispose(ByVal disposing
As Boolean)
If
disposing Then
If
Not (components Is
Nothing) Then
components.Dispose()
End
If
End
If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As
System.ComponentModel.IContainer
'NOTE: The following procedure is required by the
Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents
button1 As System.Windows.Forms.Button
Friend WithEvents
label1 As System.Windows.Forms.Label
Friend WithEvents
trackBar1 As System.Windows.Forms.TrackBar
<System.Diagnostics.DebuggerStepThrough()> Private
Sub InitializeComponent()
Me.button1
= New System.Windows.Forms.Button
Me.label1
= New System.Windows.Forms.Label
Me.trackBar1
= New System.Windows.Forms.TrackBar
CType(Me.trackBar1,
System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'button1
'
Me.button1.DialogResult
= System.Windows.Forms.DialogResult.OK
Me.button1.Location
= New System.Drawing.Point(213, 21)
Me.button1.Name
= "button1"
Me.button1.TabIndex
= 5
Me.button1.Text
= "Ok"
'
'label1
'
Me.label1.Font
= New System.Drawing.Font("Tahoma", 24.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.label1.Location
= New System.Drawing.Point(53, 13)
Me.label1.Name
= "label1"
Me.label1.Size
= New System.Drawing.Size(136, 48)
Me.label1.TabIndex
= 4
'
'trackBar1
'
Me.trackBar1.Location
= New System.Drawing.Point(5, 21)
Me.trackBar1.Maximum
= 255
Me.trackBar1.Name
= "trackBar1"
Me.trackBar1.Orientation
= System.Windows.Forms.Orientation.Vertical
Me.trackBar1.Size
= New System.Drawing.Size(45, 232)
Me.trackBar1.TabIndex
= 3
Me.trackBar1.TickFrequency
= 8
'
'DialogTransEditor
'
Me.AutoScaleBaseSize
= New System.Drawing.Size(5, 13)
Me.ClientSize
= New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.button1)
Me.Controls.Add(Me.label1)
Me.Controls.Add(Me.trackBar1)
Me.FormBorderStyle
= System.Windows.Forms.FormBorderStyle.FixedDialog
Me.Name
= "DialogTransEditor"
Me.Text
= "DialogTransEditor"
CType(Me.trackBar1,
System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End
Region
Private Sub
DialogTransEditor_Paint(ByVal sender
As Object,
ByVal e As
System.Windows.Forms.PaintEventArgs) Handles
MyBase.Paint
e.Graphics.FillRectangle(Brushes.Black,
64, 96, 192, 100)
Dim
sb As SolidBrush = New
SolidBrush(Color.FromArgb(_transparency, Color.Red))
e.Graphics.FillRectangle(sb,
168, 64, 88, 168)
sb.Dispose()
End Sub
Private Sub
trackBar1_Scroll(ByVal sender
As Object,
ByVal e As
System.EventArgs) Handles trackBar1.ValueChanged
Dim
pc As Single = (CSng(Me.trackBar1.Value))
/ 255 * 100.0F
Me.label1.Text
= pc.ToString("0.0") & "%"
Me._transparency
= 255 - Me.trackBar1.Value
Me.Invalidate()
End Sub
End
Class