Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

OPI_RGZ_2011

.pdf
Скачиваний:
16
Добавлен:
07.02.2016
Размер:
2.93 Mб
Скачать

51

5 , , TextEditor (Code \ Glava2 \ TextEditor).

2.2.9 FontDialog

' ( 9 Notepad C #. A

( 9 d, . (

frmmain ToolBox

FontDialog. 5 KK

, 9 9 Font K:

private void mnuFont_Click(object sender, System.EventArgs e)

{

blank frm = (blank)this.ActiveMdiChild; frm.MdiParent = this; fontDialog1.ShowColor = true;

fontDialog1.Font = frm.richTextBox1.SelectionFont; fontDialog1.Color = frm.richTextBox1.SelectionColor;

if (fontDialog1.ShowDialog() == DialogResult.OK)

{

frm.richTextBox1.SelectionFont = fontDialog1.Font; frm.richTextBox1.SelectionColor = fontDialog1.Color;

}

frm.Show();

}

' 2.7.

n , Output 'n

( . 2.18).

7 2.18 – 8 – NotepadCSharp.blank.richTextBox1

-

52

( ? ' d blank

RichTextBox Visual Studio.NET

richTextBox1 System.Windows.Forms.RichTextBox

private, o

n :

private System.Windows.Forms.RichTextBox richTextBox1;

public . ' 9 K Font ( K

.

2.2.10 ColorDialog

A FontDialog , ( 9 , 9 (. €d K n (

, ( 9 ( . 2.19):

7 2.19 – A ColorDialog

53

ToolBox n ColorDialog ,

KK , 9 9

Color K frmmain:

private void mnuColor_Click(object sender, System.EventArgs e)

{

blank frm = (blank)this.ActiveMdiChild; frm.MdiParent = this;

colorDialog1.Color = frm.richTextBox1.SelectionColor;

if (colorDialog1.ShowDialog() == DialogResult.OK)

{

frm.richTextBox1.SelectionColor = colorDialog1.Color;

}

frm.Show();

}

, o ColorDialog

(, Color FontDialog. v

: ( 'n ( 9'n – RichTextBox.

2.2.11 StatusBar

s StatusBar n

(, d

. Microsoft Word, , 9 ( n

, , d

. A Notepad C # ,

Kn , o

.

A n blank StatusBar. : n Text. Panels

n (...). : n StatusBarCollectionEditor,

Kn 9 (. 8 ,

K Add,

( K ( d) ( . 2.20

. 2.21):

54

7 2.20 – : sbAmount

7 2.21 – : sbTime

55

9. 2.4.

6 9 2.4 – :

/ ,!% b

&' )

Alignment

: K Text

AutoSize

 

BorderStyle

d – , 9

 

9

Icon

A

Style

8

Text

6, o d n

ToolTipText

8 K – 'n

 

 

Width

Name

5

: , K

StatusBarCollectionEditor, ( K

9.

' d 9 n . : ShowPanels StatusBar Kn

True. 5 9 ( K . : n RichTextBox,

n Kn 9 9 TextChanged:

private void richTextBox1_TextChanged(object sender, System.EventArgs e)

{

sbAmount.Text = "0mount of symbols" + richTextBox1.Text.Length.ToString();

}

: Text ' sbAmount Kn : -

o 9 StatusBarCollectionEditor, TextChanged ' .

K n, 9

. blank n :

56

public blank()

{

InitializeComponent();

sbTime.Text = Convert.ToString(System.DateTime.Now.ToLongTimeString()); sbTime.ToolTipText = Convert.ToString(System.DateTime.Today.ToLongDateString());

}

n . '

d n ( . 2.22), 9

( (

K ( K .

7 2.22 – 7

2.2.12 ,! ) $ -,

' Notepad # n

- " ", "7" " ". €d

( K o " "

. ' 9 K

K Exit. 9 9 n n

private void mnuExit_Click(object sender, System.EventArgs e)

{

this.Close();

}

Close n ( 9 d

– , .

57

2.2.13 CheckBox

~ 9 , 9 n 9- .

K Kn ,

d . A

Notepad C # d , 9

CheckBox. Solution Explorer

n K K d – NotepadCSharp –

K 9 n Add Windows Form. 5 n

FindForm.cs Kn . '

9. 2.5.

6 9 2.5 – 5

FindForm, $ - , !/ ,!% b

&' )

Name

FindForm

FormBorderStyle

FixedToolWindow

Size

328; 112

Text

Find

n TextBox, ChekBox

, . 2.23:

7 2.23 – 2 FindForm (

: Kn

9. 2.6 – 2.10 :

 

58

 

6 9 2.6 – 2 FindForm, TextBox

 

 

 

 

TextBox, !/ ,!% b

&' )

 

Name

txtFind

 

Size

192; 20

 

Text

 

 

6 9 2.7 – 2 FindForm, checkBox1

 

 

 

 

checkBox1, !/ ,!% b

&' )

 

Name

cbMatchCase

 

Text

Match &Case

 

6 9 2.8 – 2 FindForm, checkBox2

 

 

 

 

checkBox2, !/ ,!% b

&' )

 

Name

cbMatchWhole

 

Text

Match &whole word

 

6 9 2.9 – 2 FindForm, button1

 

 

 

 

button1, !/ ,!% b

&' )

 

Name

btnOK

 

DialogResult

OK

 

Text

&OK

 

6 9 2.10 – 2 FindForm, button2

 

 

 

 

button2, !/ ,!% b

&' )

 

Name

btnCancel

 

DialogResult

Cancel

 

Text

&Cancel

 

: 9 d 9 – cbMatchCase – 9 K

d , – cbMatchWhole – d

. DialogResult –

59

9 K , Kn 9 9

9 . .J n ,

K K, – – d;

Cancel n . K frmmain

n K Find Kn

: Name – mnuFind, Shortcut – CtrlF, Text – & Find.

' 9 9 :

private void mnuFind_Click(object sender, System.EventArgs e)

{

FindForm frm = new FindForm(); if(frm.ShowDialog(this) == DialogResult.Cancel) return;

blank form = (blank)this.ActiveMdiChild; form.MdiParent = this;

int start = form.richTextBox1.SelectionStart; form.richTextBox1.Find(frm.FindText, start, frm.FindCondition);

}

. K d 9 Find

RichTextBox. 5 d n d d,

( ( . 2.24):

7 2.24 – ' Find. J K

Intel Sense, 9 n -

FindForm d 9, o ( ( CheckBox:

public RichTextBoxFinds FindCondition

{

get

{

if (cbMatchCase.Checked && cbMatchWhole.Checked)

{

return RichTextBoxFinds.MatchCase| RichTextBoxFinds.WholeWord;

60

}

if (cbMatchCase.Checked )

{

return RichTextBoxFinds.MatchCase;

}

if (cbMatchWhole.Checked )

{

return RichTextBoxFinds.WholeWord;

}

return RichTextBoxFinds.None;

}

}

„ d, Kn FindText, n

d FindForm:

public string FindText

{

get{return txtFind.Text;} set{txtFind.Text = value;}

}

n . : 9 K , ( -

d ( . 2.25):

7 2.25 – ' d

2.2.14 / ,!% b TabIndex '/'-' %! !/% )

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]