Graphical Text VB Train Object

advertisement
VBTrain.Net Graphical Text Object
Part 2: The Advanced Guide
TUTORIAL BY Dr. med. Cecil Cheah
03 March 2004
Page 1 of 79
Table of Content
GOING DEEPER WITH THE GRAPHICAL TEXT OBJECT
3
Making A New Project
Adding the Graphic Text Object the hard way
Understanding the Code
Adding the Graphic Text Object the easy way
Examine The Code generated
3
4
7
8
12
PROPERTIES OF THE GRAPHICAL TEXT OBJECT
13
Changing the properties of the Graphical Text Object in design time
Text
The General Properties of the Graphical Text Object
FONT
Sizing
Visible Region
Rotation Angle
Scale Horizontal
Scale Vertical
String Format Type
The Effect Properties of the Graphical Text Object
Solid Effect
Linear Gradient Effect with Color1 and Color2
Linear Gradient Effect with Transparency1 and Transparency2
Linear Gradient Effect with Gradient Angle
Path Gradient Arc Effect with Sweep Gradient Angle
Linear Gradient Effect, Path Gradient Rectangle, Path Gradient Ellipse
Texture Effect
Hash Effect
13
14
15
15
16
19
21
22
23
25
26
26
27
29
31
32
35
36
37
Changing The Properties in Runtime
Changing the General properties of the Graphical Text Object in Runtime
Text
FONT
Sizing
Visible Region
Rotation Angle
Scale Horizontal
Scale Vertical
String Format Type
Changing the Effect properties of the Graphical Text Object in Runtime.
Solid Effect
Linear Gradient Effect with Color1 and Color2
Linear Gradient Effect with Transparency1 and Transparency2
Linear Gradient Effect with Gradient Angle
Path Gradient Arc Effect with Sweep Gradient Angle
Linear Gradient Effect, Path Gradient Rectangle, Path Gradient Ellipse
Texture Effect
Hash Effect
39
39
40
41
41
44
46
48
50
52
53
53
54
57
60
64
69
72
74
Calling the Methods of the Graphical Text Object during runtime
StartPaint()
StopPaint()
StartPaintingAll() and StopPaintingAll()
77
77
78
79
HOW TO CONTACT ME
79
Page 2 of 79
Going deeper with the Graphical Text Object
Making A New Project
Now that you have some idea what the Graphical Text Object can do, we will make our own little
programme with the VBTrain Graphical Text Object and at the same time get to know the
Properties, methods associated with the Graphical Text Object.
First open Visual Studio and start a new project by clicking the “New Project” button.
Name the project as “MyGraphicalTextObject”. Choose any location to save your project. Click “OK”.
You will now see an empty form like the following.
As before, you need to add the reference of
the Graphical Text Object to the form. So repeat the step as described above. After adding the
reference, your solution explorer should look like this.
Page 3 of 79
If we look back at the form1, nothing has changed. No
Graphical Text Object has appeared on the form. Where did we go wrong? Try searching the
Toolbox and you still will not find any Graphical Text Object at all to add to the Form1.
Are we stuck?
Adding the Graphic Text Object the hard way.
No. We are not, or you better ask Platte Canyon to refund your money.
Select Form1.vb in the solution explorer and click the “View Code” button above.
The Code Window for Form1 will now open.
Page 4 of 79
Click on the “+” sign to expand the “Windows Form Designer generated code” Code Block.
Page 5 of 79
Scroll down to locate the second last “-“ sign which is included the following green typed code.
'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.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
Me.Text = "Form1"
Now insert the following text just below the green typed text.
Friend WithEvents GraphicalText1 As VBTrain.GraphicalObjects.GraphicalText
So it should look like this:
'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 GraphicalText1 As VBTrain.GraphicalObjects.GraphicalText
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Page 6 of 79
components = New System.ComponentModel.Container()
Me.Text = "Form1"
Next add the following text above the last line of code, i.e. Me.Text = “Form1”
Me.GraphicalText1 = New VBTrain.GraphicalObjects.GraphicalText()
Me.GraphicalText1.Location = New System.Drawing.Point(24, 24)
Me.GraphicalText1.Name = "GraphicalText1"
Me.GraphicalText1.OriginalSize = New System.Drawing.Size(1, 1)
Me.GraphicalText1.Size = New System.Drawing.Size(256, 88)
Me.GraphicalText1.Text = "GraphicalText1"
Me.Controls.AddRange(New System.Windows.Forms.Control(){Me.GraphicalText1})
So it looks like this:
'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 GraphicalText1 As VBTrain.GraphicalObjects.GraphicalText
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
Me.GraphicalText1 = New VBTrain.GraphicalObjects.GraphicalText()
Me.GraphicalText1.Location = New System.Drawing.Point(24, 24)
Me.GraphicalText1.Name = "GraphicalText1"
Me.GraphicalText1.OriginalSize = New System.Drawing.Size(1, 1)
Me.GraphicalText1.Size = New System.Drawing.Size(256, 88)
Me.GraphicalText1.Text = "GraphicalText1"
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.GraphicalText1})
Me.Text = "Form1"
Now switch back to Design View and magically the Graphic Text Object has now appeared on the
form.
Understanding the Code
So what does all those code means?
Friend WithEvents GraphicalText1 As VBTrain.GraphicalObjects.GraphicalText
This adds the VBTrain Graphical Text Object as a Friend Data Member with or without events to the
form and gives it a name called GraphicTxet1.
Me.GraphicalText1 = New VBTrain.GraphicalObjects.GraphicalText()
Page 7 of 79
We use the NEW constructor to create a new instance of the Graphical Text Object and initialize it.
We could actually combine these two lines as follow:
Friend WithEvents GraphicalText1 As VBTrain.GraphicalObjects.GraphicalText = New
VBTrain.GraphicalObjects.GraphicalText()
Now we want to configure our Graphical Text Box:
Me.GraphicalText1.Location = New System.Drawing.Point(24, 24)
Me.GraphicalText1.Name = "GraphicalText1"
Me.GraphicalText1.OriginalSize = New System.Drawing.Size(1, 1)
Me.GraphicalText1.Size = New System.Drawing.Size(256, 88)
Me.GraphicalText1.Text = "GraphicalText1"
Here we set the location, the original Size, the size, and the text and gives the new instance a
name.
It is time to add the Graphical Text control to the Form’s Controls Collection:
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.GraphicalText1})
Adding the Graphic Text Object the easy way.
Oh, did I say we cannot find the Graphic Text Object inside the toolbox? That is not really true.
What is true is we cannot really find the Graphic Text Object inside the Toolbox because we have
not added the Graphic Text Object to the toolbox. So if we have added it to the toolbox, we can
just drag the object to the form instead of writing our own code as above. I like to do things the
hard way and I would like you to learn it the hard way. So if I would have told you this first, would
you have bothered doing the above?
First remove all the text you have just added above.
Anyway to add the Graphic Text Object to the toolbox, right click inside the toolbox and select
“Customize Toolbox…” (or Add / Remove Object if you are using Visual Studio 2003).
This will open the “Customize Toolbox” dialog box. Select the “.NET
Framework Components” tab. Click “Browse” button and search for and locate the
VBTrainGraphicalText.dll file.
Page 8 of 79
Click “Open”.
Page 9 of 79
Now you can see the Graphical Text object inside the list. Make sure it is selected. If it is not
already selected, click the square box to select it ( ).
Click “OK”.
And would you believe it, the Graphical Text Object appears now in the Toolbox. So I did lie.
Page 10 of 79
Now click the Graphical Text Object inside the toolbox once to select
it Then draw an instance of the object on the form.
Page 11 of 79
Now we have added a Graphical Text Object on the form. Much easier than before, right?
Examine The Code generated
Just out of interest, let us examine the code generated by Visual Studio after adding the Graphical
Text Object. Would you believe it, it is very similar to the coded we added ourselves. So we are as
good as Visual Studio can be, and better.
Code generated by Visual Studio:
'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 GraphicalText1 As VBTrain.GraphicalObjects.GraphicalText
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.GraphicalText1 = New VBTrain.GraphicalObjects.GraphicalText()
Me.SuspendLayout()
'
'GraphicalText1
'
Me.GraphicalText1.Font = New System.Drawing.Font("Microsoft Sans Serif",
9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.GraphicalText1.Location = New System.Drawing.Point(48, 56)
Me.GraphicalText1.Name = "GraphicalText1"
Me.GraphicalText1.OriginalSize = New System.Drawing.Size(1, 1)
Me.GraphicalText1.Size = New System.Drawing.Size(208, 48)
Me.GraphicalText1.TabIndex = 0
Me.GraphicalText1.TabStop = False
Me.GraphicalText1.Text = "GraphicalText1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.GraphicalText1})
Page 12 of 79
Properties of the Graphical Text Object.
We can alter the properties of the Graphical Text Object either in design time or in runtime. If you
alter the properties of the Graphical Text Object in design time, you would not be able to change it
in runtime without building some codes. So changing the properties of the Graphical Text Object is
for you to set the initial state of the Graphical Text Object when your application first loaded. To
change the properties of the Graphical Text Object during runtime, we have to behave like a real
Visual Basic Programmer and started acting like a nerd and write some codes like a nerd will.
Changing the properties of the Graphical Text Object in design time.
Underneath the properties window, you will see the blue color underlined “Edit” text. Click it.
This will now open the Graphical Text editor.
Page 13 of 79
To know what each property mean and what it does, what is better than playing with it?
Text
Try changing the text to “Hello”.
And click OK. Do you see what you have done now?
Page 14 of 79
And how does the code change?
Before
Me.GraphicalText1.Text = "GraphicalText1"
After
Me.GraphicalText1.Text = "Hello"
Try and reset the text back to “Graphical Text 1”
The General Properties of the Graphical Text Object
Next we will look at the General Properties of the Graphical Text Object. They are Font, Sizing,
Visible Region, Smoothing, Rotation Angle, Scale Horizontal, Scale Vertical, String Format Type.
FONT
The default Font is Microsoft Sans Serif, Font Style is Regular and Size is 10. Let us change the font
to Arial, style to Bold and size to 18. See what the Font property does?
Code Changes (changes are marked in red):
Page 15 of 79
Before:
Me.GraphicalText1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
After
Me.GraphicalText1.Font = New System.Drawing.Font("Arial", 18.0!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
The font size does not seem to change at all. The reason is the Sizing is set to “Size To Control”.
Let us change the Sizing to Size To Font, No Wrap and font size to 10.
Code Changes:
Me.GraphicalText1.Font = New System.Drawing.Font("Arial", 9.75!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.GraphicalText1.Sizing =
VBTrain.GraphicalObjects.GraphicalText.SizingEnum.SizeToFont_NoWrap
Now change the font size to 18.
Sizing
Page 16 of 79
Change the font size back to 10. Make sure it looks like this.
Change the text to “Graphical Text 1 Graphical
Text 1” and the Sizing property to Size To Font, Wrap
Code Changes:
Before:
Me.GraphicalText1.Sizing =
VBTrain.GraphicalObjects.GraphicalText.SizingEnum.SizeToFont_NoWrap
Me.GraphicalText1.Text = "Graphical Text 1"
After
Me.GraphicalText1.Sizing =
VBTrain.GraphicalObjects.GraphicalText.SizingEnum.SizeToFont_Wrap
Me.GraphicalText1.Text = "Graphical Text 1 Graphical Text 1"
Wow, but where is the extra text I have just added? Do not worry, it is still there but wrapped to
underneath the text. To see the text, try and increase the height value of the Graphical Text Object.
Page 17 of 79
Reset the height of the Graphical Text Object
back to before.
Now change the Sizing Property to “Size To Font,
No Wrap”.
Page 18 of 79
Now you see the extra text back in the same line
unwrapped.
Reset the Graphical Text Control back to “Graphical Text 1”, Font = Microsoft Sans Serif, Font
Style is Regular and Size is 10. Sizing = Size to Control.
Visible Region
Page 19 of 79
Visible Region = Text Rectangle
Code Changes:
Me.GraphicalText1.VisibleRegion =
VBTrain.GraphicalObjects.GraphicalText.VisibleRegionEnum.TextRectangle
Visible Region = Text
Code Changes:
Me.GraphicalText1.VisibleRegion =
VBTrain.GraphicalObjects.GraphicalText.VisibleRegionEnum.Text
Page 20 of 79
Visible Region = Control
Code Changes:
Me.GraphicalText1.VisibleRegion =
VBTrain.GraphicalObjects.GraphicalText.VisibleRegionEnum.Control
Reset Visible Region to Text Rectangle.
Rotation Angle
Rotation Angle = 0 (default)
Code Changes:
Me.GraphicalText1.RotationAngle = 0!
Page 21 of 79
Rotation Angle = 45
Code Changes:
Me.GraphicalText1.RotationAngle = 45.0!
Reset Rotation Angle = 0.
Scale Horizontal
Scale Horizontal = 1.325 (default)
Code Changes:
Me.GraphicalText1.ScaleHorizontal = 1.325!
Page 22 of 79
Scale Horizontal = 1
Code Changes:
Me.GraphicalText1.ScaleHorizontal = 1.0!
Scale Horizontal = 3
Code Changes:
Me.GraphicalText1.ScaleHorizontal = 3.0!
Reset Scale Horizontal = 1.325.
Scale Vertical
Page 23 of 79
Scale Vertical = 1.325 (default)
Code Changes:
Me.GraphicalText1.ScaleVertical = 1.325!
Scale Vertical = 1
Code Changes:
Me.GraphicalText1.ScaleVertical = 1.0!
Page 24 of 79
Scale Vertical = 3
Code Changes:
Me.GraphicalText1.ScaleVertical = 3.0!
Reset Scale Vertical = 1.325.
String Format Type
The String Format Type is the StringFormat to use when drawing the text.
String Format Type = Generic Default (default)
Code Changes:
Me.GraphicalText1.StringFormatType =
VBTrain.GraphicalObjects.GraphicalText.StringFormatEnum.GenericDefault
Page 25 of 79
String Format Type = Generic Typographic
Code Changes:
Me.GraphicalText1.StringFormatType =
VBTrain.GraphicalObjects.GraphicalText.StringFormatEnum.GenericTypographic
Reset String Format Type = Generic Default.
The Effect Properties of the Graphical Text Object
Finally we will look at the various Effect Properties of the Graphical Text Object. These include
Effect, Color1, Color2, Transparency1, Transparency2, Hatch Effect Style, Gradient Angle, Gradient
Sweep Angle and Texture Image
Solid Effect
The various effect options include Solid, Texture, Gradient, Path Gradient Rectangle, Path Gradient
Arc, Path Gradient Ellipse and Hatch
Effect = Solid
Code Changes:
Page 26 of 79
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.Solid
Linear Gradient Effect with Color1 and Color2
Color1 is the primary text color, Color2 is the secondary text color used when the Effect is Hatch,
LinearGradient or one of the PathGradients.
Default value for Color1 is Black. Default value for Color2 is White.
Effect = Linear Gradient with Color1 = Black
and Color2 = White
Code Changes:
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Color1 = System.Drawing.Color.Black
Me.GraphicalText1.Color2 = System.Drawing.Color.White
Effect = Linear Gradient with Color1 = Red and
Color2 = Black
Page 27 of 79
Code Changes:
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Black
It is interesting that you have three different options to change the colour inside the Graphic Text
Editor.: Edit Color with Dialog, Edit Color with RGB or Hex and Set to Color.Transparent
Edit Color(Dialog)
Edit Color (RGB or Hex)
Set to Color.Transparent will give you this effect:
Page 28 of 79
Effect = Linear Gradient with Color1 =
Transparent and Color2 = Black
Code Changes:
Me.GraphicalText1.Color1 = System.Drawing.Color.Transparent
Me.GraphicalText1.Color2 = System.Drawing.Color.Black
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Linear Gradient Effect with Transparency1 and Transparency2
Transparency1 is the transparency of the primary color (Color1). Transparency2 is the
transparency of the secondary color (Color2)
Default setting for Transparency1 and Transparency2 is 255.
Effect = Linear Gradient with Color1 = Red and
Color2 = Lime and Transparency1 = 255 and Transparency2 = 255
Code Changes:
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Page 29 of 79
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Effect = Linear Gradient with Color1 = Red and
Color2 = Lime and Transparency1 = 125 and Transparency2 = 255
Code Changes:
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Transparency1 = 125
Me.GraphicalText1.Transparency2 = 255
Effect = Linear Gradient with Color1 = Red and
Color2 = Lime and Transparency1 = 255 and Transparency2 = 0
Code Changes:
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Page 30 of 79
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 0
Linear Gradient Effect with Gradient Angle
The Gradient Angle is

The gradient orientation when the Effect is LinearGradient.

The start angle of the arc when the Effect is PathGradient_Arc.
Default Gradient Angle Value = 0
Effect = Linear Gradient with Color1 = Red and
Color2 = Lime and Transparency1 = 255 and Transparency2 = 255 and Gradient Angle = 0
Code Changes:
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
Page 31 of 79
Effect = Linear Gradient with Color1 = Red and
Color2 = Lime and Transparency1 = 255 and Transparency2 = 255 and Gradient Angle = 90
Code Changes:
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 90.0!
Path Gradient Arc Effect with Sweep Gradient Angle
The Sweep Gradient Angle is the sweep angle of the arc when the Effect is PathGradient_Arc.
The Default value is 360.
Effect = Path Gradient Arc with Color1 = Red
and Color2 = Lime and Transparency1 = 255 and Transparency2 = 255 and Gradient Angle = 0
and Sweep Gradient Angle = 360
Code Changes:
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Page 32 of 79
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.PathGradient_Arc
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
Me.GraphicalText1.GradientSweepAngle = 360.0!
Effect = Path Gradient Arc with Color1 = Red
and Color2 = Lime and Transparency1 = 255 and Transparency2 = 255 and Gradient Angle = 0
and Sweep Gradient Angle = 180
Code Changes:
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.PathGradient_Arc
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
Me.GraphicalText1.GradientSweepAngle = 180.0!
Page 33 of 79
Effect = Path Gradient Arc with Color1 = Red and
Color2 = Lime and Transparency1 = 255 and Transparency2 = 255 and Gradient Angle = 0 and
Sweep Gradient Angle = 270
Code Changes:
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.PathGradient_Arc
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
Me.GraphicalText1.GradientSweepAngle = 270.0!
Effect = Path Gradient Arc with Color1 = Red
and Color2 = Lime and Transparency1 = 255 and Transparency2 = 255 and Gradient Angle = 90
and Sweep Gradient Angle = 180
Code Changes:
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.PathGradient_Arc
Page 34 of 79
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 90.0!
Me.GraphicalText1.GradientSweepAngle = 180.0!
Linear Gradient Effect, Path Gradient Rectangle, Path Gradient Ellipse
Effect = Linear Gradient with Color1 = Red and
Color2 = Lime and Transparency1 = 255 and Transparency2 = 255 and Gradient Angle = 0
Code Changes:
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
Effect = Path Gradient Rectangle with Color1 =
Red and Color2 = Lime and Transparency1 = 255 and Transparency2 = 255 and Gradient Angle =
0
Code Changes:
Page 35 of 79
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.PathGradient_Rectangle
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
Effect = Path Gradient Ellipse with Color1 = Red
and Color2 = Lime and Transparency1 = 255 and Transparency2 = 255 and Gradient Angle = 0
Code Changes:
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.PathGradient_Ellipse
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
Texture Effect
First set the effect to Texture, then select Choose A Graphic in the Texture Image option.
I have chosen the following image.
You can choose any BMP, GIF, JPG, JPEG, PNG or ICO image file.
Page 36 of 79
Texture Effect.
Code Changes:
Me.GraphicalText1.TextureImage =
CType(resources.GetObject("GraphicalText1.TextureImage"), System.Drawing.Bitmap)
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.Texture
Hash Effect
Hash Effect with Hash Effect Style = Weave
Code Changes:
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.Hatch
Me.GraphicalText1.HatchEffectStyle = System.Drawing.Drawing2D.HatchStyle.Weave
Page 37 of 79
Hash Effect with Hash Effect Style = Sphere
Code Changes:
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.Hatch
Me.GraphicalText1.HatchEffectStyle = System.Drawing.Drawing2D.HatchStyle.Sphere
Hash Effect with Hash Effect Style = Light
Horizontal
Code Changes:
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.Hatch
Me.GraphicalText1.HatchEffectStyle =
System.Drawing.Drawing2D.HatchStyle.LightHorizontal
Now that we have seen how easy it is to change the initial properties of the Graphical Text Object
with the Graphical Text Editor and what it does to the code, it is time we take a look how we can
change the properties in Runtime.
Page 38 of 79
Reset Effect = Solid, Color1 = Black, Color2 = White, Transparency1 = 255, Transparency2 =
255, Gradient Angle = 0Gradient Sweep Angle = 360 and delete the Texture Image.
Changing The Properties in Runtime
Changing the General properties of the Graphical Text Object in Runtime.
First we will add a button to the form and name it btn_DoStuff.
Now we will start doing the things nerd does in their spare time.
If you double click while the button is still selected, the code window will be opened. You will see
the following code added automatically to the Click Event of the btn_DoStuff Button.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
End Sub
Page 39 of 79
Text
Changing the Text Property by code
Add the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Text = "Hello"
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Text = "Hello"
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Page 40 of 79
FONT
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Font = New System.Drawing.Font("Arial", 18.0!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Font = New System.Drawing.Font("Arial", 18.0!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Sizing
Page 41 of 79
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.GraphicalText1.Text = "Graphic Text 1 Graphic Text 1"
Me.GraphicalText1.Sizing =
VBTrain.GraphicalObjects.GraphicalText.SizingEnum.SizeToFont_NoWrap
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.GraphicalText1.Text = "Graphic Text 1 Graphic Text 1"
Me.GraphicalText1.Sizing =
VBTrain.GraphicalObjects.GraphicalText.SizingEnum.SizeToFont_NoWrap
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Page 42 of 79
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.GraphicalText1.Text = "Graphic Text 1 Graphic Text 1"
Me.GraphicalText1.Sizing =
VBTrain.GraphicalObjects.GraphicalText.SizingEnum.SizeToFont_Wrap
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.GraphicalText1.Text = "Graphic Text 1 Graphic Text 1"
Me.GraphicalText1.Sizing =
VBTrain.GraphicalObjects.GraphicalText.SizingEnum.SizeToFont_Wrap
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Page 43 of 79
See the Text has been wrapped to the bottom.
Visible Region
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.VisibleRegion =
VBTrain.GraphicalObjects.GraphicalText.VisibleRegionEnum.TextRectangle
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.VisibleRegion =
VBTrain.GraphicalObjects.GraphicalText.VisibleRegionEnum.TextRectangle
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
There is no change after clicking the button because TextRectangle is the default setting.
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Page 44 of 79
Me.GraphicalText1.VisibleRegion =
VBTrain.GraphicalObjects.GraphicalText.VisibleRegionEnum.Text
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.VisibleRegion =
VBTrain.GraphicalObjects.GraphicalText.VisibleRegionEnum.Text
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
And now change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.VisibleRegion =
VBTrain.GraphicalObjects.GraphicalText.VisibleRegionEnum.Control
Page 45 of 79
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.VisibleRegion =
VBTrain.GraphicalObjects.GraphicalText.VisibleRegionEnum.Control
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Rotation Angle
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.RotationAngle = 45.0!
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.RotationAngle = 45.0!
Page 46 of 79
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.RotationAngle = 180.0!
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.RotationAngle = 180.0!
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
Page 47 of 79
After clicking the button:
Scale Horizontal
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.ScaleHorizontal = 1.0!
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.ScaleHorizontal = 1.0!
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
Page 48 of 79
After clicking the button:
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.ScaleHorizontal = 3.0!
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.ScaleHorizontal = 3.0!
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
Page 49 of 79
After clicking the button:
Scale Vertical
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.ScaleVertical = 1.0!
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.ScaleVertical = 1.0!
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
Page 50 of 79
After clicking the button:
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.ScaleVertical = 3.0!
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.ScaleVertical = 3.0!
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
Page 51 of 79
After clicking the button:
String Format Type
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.StringFormatType =
VBTrain.GraphicalObjects.GraphicalText.StringFormatEnum.GenericTypographic
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.StringFormatType =
VBTrain.GraphicalObjects.GraphicalText.StringFormatEnum.GenericTypographic
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
Page 52 of 79
After clicking the button:
Changing the Effect properties of the Graphical Text Object in Runtime.
Solid Effect
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.Solid
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.Solid
End Sub
Go to Runtime Mode and click the button.
Page 53 of 79
Before clicking the button:
After clicking the button:
It looks the same because the default effect setting is Solid.
Linear Gradient Effect with Color1 and Color2
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Color1 = System.Drawing.Color.Black
Me.GraphicalText1.Color2 = System.Drawing.Color.White
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Color1 = System.Drawing.Color.Black
Me.GraphicalText1.Color2 = System.Drawing.Color.White
End Sub
Page 54 of 79
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Green
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Green
End Sub
Go to Runtime Mode and click the button.
Page 55 of 79
Before clicking the button:
After clicking the button:
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Transparent
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Transparent
End Sub
Go to Runtime Mode and click the button.
Page 56 of 79
Before clicking the button:
After clicking the button:
Linear Gradient Effect with Transparency1 and Transparency2
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Color1 = System.Drawing.Color.Blue
Me.GraphicalText1.Color2 = System.Drawing.Color.Purple
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Color1 = System.Drawing.Color.Blue
Me.GraphicalText1.Color2 = System.Drawing.Color.Purple
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Transparency1 = 255
Page 57 of 79
Me.GraphicalText1.Transparency2 = 255
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Color1 = System.Drawing.Color.Blue
Me.GraphicalText1.Color2 = System.Drawing.Color.Purple
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Transparency1 = 125
Me.GraphicalText1.Transparency2 = 255
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Color1 = System.Drawing.Color.Blue
Me.GraphicalText1.Color2 = System.Drawing.Color.Purple
Page 58 of 79
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Transparency1 = 125
Me.GraphicalText1.Transparency2 = 255
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Color1 = System.Drawing.Color.Blue
Me.GraphicalText1.Color2 = System.Drawing.Color.Purple
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 10
So the whole Click Event will look like this.
Page 59 of 79
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Color1 = System.Drawing.Color.Blue
Me.GraphicalText1.Color2 = System.Drawing.Color.Purple
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 10
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Linear Gradient Effect with Gradient Angle
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Color1 = System.Drawing.Color.Orange
Me.GraphicalText1.Color2 = System.Drawing.Color.Cyan
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Page 60 of 79
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Color1 = System.Drawing.Color.Orange
Me.GraphicalText1.Color2 = System.Drawing.Color.Cyan
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Page 61 of 79
Me.GraphicalText1.Color1 = System.Drawing.Color.Orange
Me.GraphicalText1.Color2 = System.Drawing.Color.Cyan
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 90.0!
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Color1 = System.Drawing.Color.Orange
Me.GraphicalText1.Color2 = System.Drawing.Color.Cyan
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 90.0!
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Page 62 of 79
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Color1 = System.Drawing.Color.Orange
Me.GraphicalText1.Color2 = System.Drawing.Color.Cyan
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 180.0!
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Color1 = System.Drawing.Color.Orange
Me.GraphicalText1.Color2 = System.Drawing.Color.Cyan
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 180.0!
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
Page 63 of 79
After clicking the button:
Path Gradient Arc Effect with Sweep Gradient Angle
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.PathGradient_Arc
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
Me.GraphicalText1.GradientSweepAngle = 360.0!
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.PathGradient_Arc
Page 64 of 79
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
Me.GraphicalText1.GradientSweepAngle = 360.0!
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.PathGradient_Arc
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
Me.GraphicalText1.GradientSweepAngle = 180.0!
So the whole Click Event will look like this.
Page 65 of 79
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.PathGradient_Arc
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
Me.GraphicalText1.GradientSweepAngle = 180.0!
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Page 66 of 79
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.PathGradient_Arc
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
Me.GraphicalText1.GradientSweepAngle = 270.0!
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.PathGradient_Arc
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
Me.GraphicalText1.GradientSweepAngle = 270.0!
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Page 67 of 79
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.PathGradient_Arc
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 90.0!
Me.GraphicalText1.GradientSweepAngle = 270.0!
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Color1 = System.Drawing.Color.Red
Me.GraphicalText1.Color2 = System.Drawing.Color.Lime
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.PathGradient_Arc
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 90.0!
Me.GraphicalText1.GradientSweepAngle = 270.0!
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
Page 68 of 79
After clicking the button:
Linear Gradient Effect, Path Gradient Rectangle, Path Gradient Ellipse
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Color1 = System.Drawing.Color.Cyan
Me.GraphicalText1.Color2 = System.Drawing.Color.Blue
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Color1 = System.Drawing.Color.Cyan
Me.GraphicalText1.Color2 = System.Drawing.Color.Blue
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.LinearGradient
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
Page 69 of 79
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Color1 = System.Drawing.Color.Cyan
Me.GraphicalText1.Color2 = System.Drawing.Color.Blue
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.PathGradient_Rectangle
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Color1 = System.Drawing.Color.Cyan
Me.GraphicalText1.Color2 = System.Drawing.Color.Blue
Page 70 of 79
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.PathGradient_Rectangle
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Color1 = System.Drawing.Color.Cyan
Me.GraphicalText1.Color2 = System.Drawing.Color.Blue
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.PathGradient_Ellipse
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
So the whole Click Event will look like this.
Page 71 of 79
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Color1 = System.Drawing.Color.Cyan
Me.GraphicalText1.Color2 = System.Drawing.Color.Blue
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.PathGradient_Ellipse
Me.GraphicalText1.Transparency1 = 255
Me.GraphicalText1.Transparency2 = 255
Me.GraphicalText1.GradientAngle = 0.0!
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Texture Effect
First of all we have to set tell our programme to load the texture file at run time.
In the code below, I have added the path of the image “Armymen.ico” to the variable i.
Dim i As Image = New Bitmap("M:\Project\Toolbook\VBNet\Graphical
Text\MyGraphicalTextObject\MyGraphicalTextObject\ARMYMEN.ICO")
Page 72 of 79
If I was you, I would not bother with the sample code from the help file. It just does not work
properly. (Jeff Rhodes note: the help file example if for an embedded resource rather than an
external graphic file. It works if you add the graphic as an embedded resource to your project.)
Now add the following code below.
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.Texture
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Dim i As Image = New Bitmap("M:\Project\Toolbook\VBNet\Graphical
Text\MyGraphicalTextObject\MyGraphicalTextObject\ARMYMEN.ICO")
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.Texture
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Page 73 of 79
Hash Effect
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.Hatch
Me.GraphicalText1.HatchEffectStyle = System.Drawing.Drawing2D.HatchStyle.Weave
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.Hatch
Me.GraphicalText1.HatchEffectStyle = System.Drawing.Drawing2D.HatchStyle.Weave
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Page 74 of 79
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.Hatch
Me.GraphicalText1.HatchEffectStyle = System.Drawing.Drawing2D.HatchStyle.Sphere
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.Hatch
Me.GraphicalText1.HatchEffectStyle = System.Drawing.Drawing2D.HatchStyle.Sphere
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Page 75 of 79
Change the following code between the Click Event Subroutine of the btn_DoStuff Button
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.Hatch
Me.GraphicalText1.HatchEffectStyle =
System.Drawing.Drawing2D.HatchStyle.LightHorizontal
So the whole Click Event will look like this.
Private Sub btn_DoStuff_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_DoStuff.Click
Me.GraphicalText1.Effect =
VBTrain.GraphicalObjects.GraphicalText.BrushTypeEnum.Hatch
Me.GraphicalText1.HatchEffectStyle =
System.Drawing.Drawing2D.HatchStyle.LightHorizontal
End Sub
Go to Runtime Mode and click the button.
Before clicking the button:
After clicking the button:
Page 76 of 79
Well, that is all the codes to it to change the properties of the Graphical Text Object during runtime.
Calling the Methods of the Graphical Text Object during runtime.
Now it is time to examine the methods of the Graphical Text Object.
There are a total of 4 Methods associated with the Graphical Text Object: StartPaint, StopPaint,
StartPaintingAll, StopPaintingAll. We will examine all 4 methods in the next section.
First add four buttons as shown below:
and name them accordingly: btn_StartPaint, btn_StopPaint, btn_StartPaintingAll and
btn_StopPaintingAll.
StartPaint()
Change the following code between the Click Event Subroutine of the btn_StartPaint Button
Dim i As Integer
Me.GraphicalText1.StartPaint()
Me.GraphicalText1.RotationAngle = 90
Page 77 of 79
MessageBox.Show("Did it rotate?")
Me.GraphicalText1.RotationAngle = 180
Me.GraphicalText1.StartPaint()
So the whole Click Event will look like this.
Private Sub btn_StartPaint_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_StartPaint.Click
Dim i As Integer
Me.GraphicalText1.StartPaint()
Me.GraphicalText1.RotationAngle = 90
MessageBox.Show("Did it rotate?")
Me.GraphicalText1.RotationAngle = 180
Me.GraphicalText1.StartPaint()
End Sub
So actually happens is when we click the button? First you will see the Graphical Text Object
rotates 90 degrees, then a message box will appear and ask you if the Graphical Text object
rotates. After clicking ok to close the message box, the graphical object will rotate a further 90
degrees.
Nothing special here.
StopPaint()
Change the following code between the Click Event Subroutine of the btn_StopPaint Button
Dim i As Integer
Me.GraphicalText1.StopPaint()
Me.GraphicalText1.RotationAngle = 90
MessageBox.Show("Did it rotate?")
Me.GraphicalText1.RotationAngle = 180
Me.GraphicalText1.StartPaint()
So the whole Click Event will look like this.
Private Sub btn_StopPaint_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_StopPaint.Click
Dim i As Integer
Me.GraphicalText1.StopPaint()
Me.GraphicalText1.RotationAngle = 90
MessageBox.Show("Did it rotate?")
Me.GraphicalText1.RotationAngle = 180
Me.GraphicalText1.StartPaint()
End Sub
Now do you see the difference? When the message box appears, the graphical text object have not
rotated at all (remember in the previous example, the graphical object has rotated 90 degrees
already) even though in our code we ask the graphical text object to rotate 90 degrees. It seems
that our graphical text object has refused to listen to us. Not so, the reason is at the start of the
code, we issue an order to tell the graphical object to stop painting, so it did. When it tells it to
rotate 90 degrees, it has moved, but we cannot see it. And we ask the Graphical Object to start
painting again after rotating another 90 degrees. Now we see the graphical object rotates 180
degrees.
Got it?
Page 78 of 79
StartPaintingAll() and StopPaintingAll()
In the same principle as the StartPaint() and StopPaint() in the previous two examples, these two
methods will ask all the graphical objects in a form to start painting or stop painting. The difference
between these two methods and the previous two is that these two methods will ask ALL the
graphical text objects in a form to start or stop painting instead of writing the same methods for all
the graphical text objects in a form. This will make sense if you have more than 2 graphical objects
in a form.
If you want, you can practice these 2 methods with the other two buttons you have just drawn on
the form ands add some more graphical text objects.
How to contact me
And so this finishes our Tutorial on the Graphical Text Object. If you have any questions or
comments about this tutorial, please go to the following VBTrain.Net Objects Forum in
www.ballardpublishing.com/toolbook/index.php
and discuss it with either Mr. Jeff Rhodes or me directly.
Or you can email me at cecil.cheah@bluewin.ch
Page 79 of 79
Download