Click here to Skip to main content
15,905,913 members
Articles / Programming Languages / C#
Article

Textwizard

Rate me:
Please Sign up or sign in to vote.
3.43/5 (5 votes)
29 Mar 2007CPOL1 min read 27.6K   574   24   2
An article on building an TextWizard simlar Kaspersky anti-viruse in C# with transparency

Image 1

Introduction

In" kaspersky anti_virus 6.0", there is a component witch is the same as my component

that can shows every texts. There are buttons witch names are "next"&"back"that used

for looking in every texts. I called my component "text wizard".

The way of using

Click on "tool box" with right-click & choose the" choose items ".after add the

'Ehsangolkar.dll'. finally you should drag the textWizard component and drop in your form.

Now it available for using.

Screenshot - properties.jpg

White 'Captioncurveradius' property you can change the radius curve. My suggestion for radius curve is '7' default value

In addition, white using 'TextCollectin' you can definite the new items for Textwizard.

TextCollection

How to use :

After clicking on textwizard and adding new item you could change the value items like color, caption box and panel box, caption text caption image, etc.

Screenshot - Textcollection.jpg

How to make:

The class as a kind of public has been definition for making text collection witch has inheritance from

System.Collections.CollectionBase class and use

System.Collections.IList interface

You can see the codes of this class here:

public class TextWizardItemCollection : System.Collections.CollectionBase, System.Collections.IList

{

/// <summary>

/// Raised when a Segment is clicked on the control

/// </summary>

public event CollectionUpdatedEventHandler CollectionUpdated;

 

/// <summary>

/// Return the item at the specified index.

/// </summary>

public TextWizardItems this[int index]

{

get

{

return (TextWizardItems)List[index];

}

}

/// <summary>

/// Adds elements to the list.

/// </summary>

/// <param name="items"></param>

public void AddRange(TextWizardItems[] items)

{

foreach (TextWizardItems item in items)

{

this.List.Add(item);

}

OnCollectionUpdated(new EventArgs());

}

/// <summary>

/// Add one element to the list.

/// </summary>

/// <param name="item"></param>

public void Add(TextWizardItems item)

{

List.Add(item);

OnCollectionUpdated(new EventArgs());

}

/// <summary>

/// Inserts an item at the specified index

/// </summary>

/// <param name="index"></param>

/// <param name="item"></param>

public void Insert(int index, TextWizardItems item)

{

this.List.Insert(index, item);

OnCollectionUpdated(new EventArgs());

}

/// <summary>

/// Copies a range of elements from the ArrayList to a compatible one-dimensional Array, 

/// starting at the specified index of the target array.

/// </summary>

/// <param name="array"></param>

/// <param name="index"></param>

public void CopyTo(TextWizardItems[] array, int index)

{

this.List.CopyTo(array, index);

}

/// <summary>

/// When implemented by a class, determines the index of a specific item in the IList.

/// </summary>

/// <param name="item"></param>

public int IndexOf(TextWizardItems item)

{

return this.List.IndexOf(item);

}

/// <summary>

/// Remove the item from the list

/// </summary>

/// <param name="value"></param>

public void Remove(TextWizardItems value)

{

this.List.Remove(value);

OnCollectionUpdated(new EventArgs());

}

/// <summary>

/// Determine if the list contains the item

/// </summary>

/// <param name="value"></param>

/// <returns></returns>

public bool Contains(TextWizardItems value)

{

return this.List.Contains(value);

}

/// <summary>

/// Handles the OnUpdate event 

/// </summary>

/// <param name="e"></param>

protected virtual void OnCollectionUpdated(EventArgs e)

{

if (CollectionUpdated != null)

{

// Invokes the delegates. 

CollectionUpdated(this, e);

}

}

}

Caption-box

Image 4

To actually draw the caption box:

GraphicsPath myPath = new GraphicsPath();

Pen myPen = new Pen(outlineColor, 1);

// Draw the path to the screen.

myPath.AddArc(this.Width - captionCurveRadius * 2 - 1, Consts.CaptionOffset,

captionCurveRadius * 2, captionCurveRadius * 2, 270, 90);

myPath.AddArc(this.Width - captionCurveRadius * 2 - 1, Consts.CaptionHeight,

captionCurveRadius * 2, captionCurveRadius * 2, 0, 90);

myPath.AddArc(0, Consts.CaptionHeight, captionCurveRadius * 2 - 1,

captionCurveRadius * 2, 90, 90);

myPath.AddArc(0, Consts.CaptionOffset, captionCurveRadius * 2 - 1,

captionCurveRadius * 2, -180, 90);

myPath.AddLine(captionCurveRadius, Consts.CaptionOffset,

this.Width - captionCurveRadius - 1, Consts.CaptionOffset);

e.Graphics.FillPath(b, myPath);

e.Graphics.DrawPath(myPen, myPath);

Panel-box

Image 5

GraphicsPath panelPath = new GraphicsPath();

panelPath.AddArc(0, Consts.CaptionHeight, captionCurveRadius * 2 - 1,

captionCurveRadius * 2, 180, -90);

panelPath.AddLine(captionCurveRadius, Consts.CaptionHeight + captionCurveRadius * 2,

this.Width - captionCurveRadius, Consts.CaptionHeight + captionCurveRadius * 2);

panelPath.AddArc(this.Width - captionCurveRadius * 2 - 1, Consts.CaptionHeight,

captionCurveRadius * 2, captionCurveRadius * 2, 90, -90);

panelPath.AddLine(this.Width - 1, Consts.CaptionHeight + captionCurveRadius, this.Width - 1,

this.Height - captionCurveRadius);

panelPath.AddArc(this.Width - captionCurveRadius * 2 - 1,

this.Height - captionCurveRadius * 2 - 1,captionCurveRadius * 2, captionCurveRadius * 2, 0, 90);

panelPath.AddLine(this.Width - captionCurveRadius, this.Height - 1,

captionCurveRadius, this.Height - 1);

panelPath.AddArc(0, this.Height - captionCurveRadius * 2 - 1, captionCurveRadius * 2,

captionCurveRadius * 2, 90, 90);

panelPath.AddLine(0, this.Height - captionCurveRadius - 1, 0, captionCurveRadius - 1);

e.Graphics.DrawPath(myPen, panelPath);

About me

I am student in Islamic azad university Najafabad branch of Iran.

Thanks to Afshin (my brother) for translating the article.

License

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


Written By
Iran (Islamic Republic of) Iran (Islamic Republic of)
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralCan't open Demo.ZIP Pin
Mc Gwyn29-Mar-07 10:42
Mc Gwyn29-Mar-07 10:42 
Can't open your Demo Zip File.

Greets
Tim
AnswerRe: Can't open Demo.ZIP [modified] Pin
Ehsan Golkar29-Mar-07 23:18
Ehsan Golkar29-Mar-07 23:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.