Click here to Skip to main content
15,886,519 members
Articles / Desktop Programming / Windows Forms

Shape Control for .NET

Rate me:
Please Sign up or sign in to vote.
4.84/5 (170 votes)
23 Mar 2017CPOL10 min read 379.5K   21.7K   301  
Implementing shape control that supports transparency, custom design-time editors and simple animation
Partial Class Form4
	''' <summary>
	''' Required designer variable.
	''' </summary>
	Private components As System.ComponentModel.IContainer = Nothing

	''' <summary>
	''' Clean up any resources being used.
	''' </summary>
	''' <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
	Protected Overrides Sub Dispose(disposing As Boolean)
		If disposing AndAlso (components IsNot Nothing) Then
			components.Dispose()
		End If
		MyBase.Dispose(disposing)
	End Sub

	#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 Sub InitializeComponent()
		Me.components = New System.ComponentModel.Container()
		Me.timer1 = New System.Windows.Forms.Timer(Me.components)
		Me.timer2 = New System.Windows.Forms.Timer(Me.components)
		Me.panel1 = New System.Windows.Forms.Panel()
		Me.line2 = New ShapeControl.CustomControl1()
		Me.line1 = New ShapeControl.CustomControl1()
		Me.shape1 = New ShapeControl.CustomControl1()
		Me.panel1.SuspendLayout()
		Me.SuspendLayout()
		' 
		' timer1
		' 
		Me.timer1.Interval = 1
		AddHandler Me.timer1.Tick, New System.EventHandler(AddressOf Me.timer1_Tick)
		' 
		' timer2
		' 
		Me.timer2.Interval = 1
		AddHandler Me.timer2.Tick, New System.EventHandler(AddressOf Me.timer2_Tick)
		' 
		' panel1
		' 
		Me.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom
		Me.panel1.Controls.Add(Me.line2)
		Me.panel1.Controls.Add(Me.line1)
		Me.panel1.Controls.Add(Me.shape1)
		Me.panel1.Location = New System.Drawing.Point(0, 0)
		Me.panel1.Name = "panel1"
		Me.panel1.Size = New System.Drawing.Size(584, 496)
		Me.panel1.TabIndex = 13
		' 
		' line2
		' 
		Me.line2.AnimateBorder = False
		Me.line2.BackColor = System.Drawing.Color.FromArgb(CInt(CByte(0)), CInt(CByte(255)), CInt(CByte(255)), CInt(CByte(255)))
		Me.line2.Blink = False
		Me.line2.BorderColor = System.Drawing.Color.FromArgb(CInt(CByte(57)), CInt(CByte(255)), CInt(CByte(0)), CInt(CByte(0)))
		Me.line2.BorderStyle = System.Drawing.Drawing2D.DashStyle.Solid
		Me.line2.BorderWidth = 41
		Me.line2.CenterColor = System.Drawing.Color.FromArgb(CInt(CByte(100)), CInt(CByte(255)), CInt(CByte(0)), CInt(CByte(0)))
		Me.line2.Connector = ShapeControl.ConnecterType.Center
		Me.line2.Direction = ShapeControl.LineDirection.None
		Me.line2.Font = New System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold)
		Me.line2.ForeColor = System.Drawing.Color.FromArgb(CInt(CByte(0)), CInt(CByte(255)), CInt(CByte(255)), CInt(CByte(255)))
		Me.line2.Location = New System.Drawing.Point(100, 199)
		Me.line2.Name = "line2"
		Me.line2.Shape = ShapeControl.ShapeType.LineHorizontal
		Me.line2.ShapeImage = Nothing
		Me.line2.Size = New System.Drawing.Size(270, 86)
		Me.line2.SurroundColor = System.Drawing.Color.FromArgb(CInt(CByte(100)), CInt(CByte(0)), CInt(CByte(255)), CInt(CByte(255)))
		Me.line2.TabIndex = 14
		Me.line2.Tag2 = ""
		Me.line2.Text = "customControl11"
		Me.line2.UseGradient = False
		Me.line2.Vibrate = False
		' 
		' line1
		' 
		Me.line1.AnimateBorder = False
		Me.line1.BackColor = System.Drawing.Color.FromArgb(CInt(CByte(0)), CInt(CByte(255)), CInt(CByte(255)), CInt(CByte(255)))
		Me.line1.Blink = False
		Me.line1.BorderColor = System.Drawing.Color.FromArgb(CInt(CByte(61)), CInt(CByte(0)), CInt(CByte(255)), CInt(CByte(0)))
		Me.line1.BorderStyle = System.Drawing.Drawing2D.DashStyle.Solid
		Me.line1.BorderWidth = 41
		Me.line1.CenterColor = System.Drawing.Color.FromArgb(CInt(CByte(100)), CInt(CByte(255)), CInt(CByte(0)), CInt(CByte(0)))
		Me.line1.Connector = ShapeControl.ConnecterType.Center
		Me.line1.Direction = ShapeControl.LineDirection.LeftUp
		Me.line1.Font = New System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold)
		Me.line1.ForeColor = System.Drawing.Color.FromArgb(CInt(CByte(0)), CInt(CByte(255)), CInt(CByte(255)), CInt(CByte(255)))
		Me.line1.Location = New System.Drawing.Point(25, 213)
		Me.line1.Name = "line1"
		Me.line1.Shape = ShapeControl.ShapeType.LineHorizontal
		Me.line1.ShapeImage = Nothing
		Me.line1.Size = New System.Drawing.Size(270, 86)
		Me.line1.SurroundColor = System.Drawing.Color.FromArgb(CInt(CByte(100)), CInt(CByte(0)), CInt(CByte(255)), CInt(CByte(255)))
		Me.line1.TabIndex = 15
		Me.line1.Tag2 = ""
		Me.line1.Text = "line1"
		Me.line1.UseGradient = False
		Me.line1.Vibrate = False
		' 
		' shape1
		' 
		Me.shape1.AnimateBorder = False
		Me.shape1.BackColor = System.Drawing.Color.FromArgb(CInt(CByte(221)), CInt(CByte(255)), CInt(CByte(255)), CInt(CByte(255)))
		Me.shape1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom
		Me.shape1.Blink = False
		Me.shape1.BorderColor = System.Drawing.Color.FromArgb(CInt(CByte(91)), CInt(CByte(0)), CInt(CByte(0)), CInt(CByte(0)))
		Me.shape1.BorderStyle = System.Drawing.Drawing2D.DashStyle.Solid
		Me.shape1.BorderWidth = 23
		Me.shape1.CenterColor = System.Drawing.Color.FromArgb(CInt(CByte(221)), CInt(CByte(0)), CInt(CByte(255)), CInt(CByte(0)))
		Me.shape1.Connector = ShapeControl.ConnecterType.Center
		Me.shape1.Direction = ShapeControl.LineDirection.None
		Me.shape1.Font = New System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CByte(0))
		Me.shape1.ForeColor = System.Drawing.Color.FromArgb(CInt(CByte(150)), CInt(CByte(0)), CInt(CByte(0)), CInt(CByte(0)))
		Me.shape1.Location = New System.Drawing.Point(0, 0)
		Me.shape1.Name = "shape1"
		Me.shape1.Shape = ShapeControl.ShapeType.Ellipse
		Me.shape1.ShapeImage = Nothing
		Me.shape1.Size = New System.Drawing.Size(570, 485)
		Me.shape1.SurroundColor = System.Drawing.Color.FromArgb(CInt(CByte(247)), CInt(CByte(141)), CInt(CByte(171)), CInt(CByte(255)))
		Me.shape1.TabIndex = 16
		Me.shape1.Tag2 = ""
		Me.shape1.UseGradient = True
		Me.shape1.Vibrate = False
        AddHandler Me.shape1.MouseDoubleClick, New System.Windows.Forms.MouseEventHandler(AddressOf Me.shape1_MouseDoubleClick)
        AddHandler Me.shape1.MouseDown, New System.Windows.Forms.MouseEventHandler(AddressOf Me.shape1_MouseDown)
		' 
		' Form4
		' 
		Me.AutoScaleDimensions = New System.Drawing.SizeF(6F, 13F)
		Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
		Me.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom
		Me.ClientSize = New System.Drawing.Size(611, 525)
		Me.Controls.Add(Me.panel1)
		Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
		Me.MaximizeBox = False
		Me.MinimizeBox = False
		Me.Name = "Form4"
		Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
		Me.Text = "Test Line"
		Me.panel1.ResumeLayout(False)
		Me.ResumeLayout(False)

	End Sub

	#End Region

	Private timer1 As System.Windows.Forms.Timer
	Private timer2 As System.Windows.Forms.Timer
	Private panel1 As System.Windows.Forms.Panel
	Private line1 As ShapeControl.CustomControl1
	Private line2 As ShapeControl.CustomControl1
	Private shape1 As ShapeControl.CustomControl1

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Singapore Singapore
Coder. Hacker. Fixer.

Comments and Discussions