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

лабораторные С#

.pdf
Скачиваний:
38
Добавлен:
12.03.2015
Размер:
778.43 Кб
Скачать

9.% .

10.! " #% ! . *, $ ! % "! ).

3. ! )* #

" ToolTip $* , " " % #. &, # "!0* & # # , " " % , " % # * * # ".

1.WindowsWinAsynchMethod " %.

2.! % " View ToolBox.

3.* ) "% , " % ToolTip.

4.Properties !& ) " , " " ) " * ToolTip on toolTip1. #% (

$ , # # , ":

 

txbA

 

For input integer A

 

 

txbB

 

For input integer B

 

 

btnRun

 

Sum

 

 

btnWork

 

Start work

 

5. %

. *, $ #

% , " %

#.

4. ($

 

 

 

$

!

& # "

$*

* "

" *

*

 

!

#. , ",

 

 

 

& #

#%"! *

 

#

* * ) # %

!.

* %

# 0

#

"!,

!:

#

*

' " # "

! :

""!

# " !$!

), (

" *

) "

 

# & # !.

 

 

 

 

 

 

 

& # % ' "! Windows

#

* !& " * # ! * ! # ) ". ! $ # % # " # * 0 " — " “%” | “* % ” | “6 ! * ! " !” | # “* ! " !”.

, " % ! # #

, "$

%# # *

% !

! # ! # *

% (

* * ).

1.# WindowsWinLanguage.

2.* ) "% % ".

3.#% ( $ Text # , ":" – menu,

" # – command one," # – command two,

51

Close,

# " ) "! – Form.

4. % $ , ! ( ) "%:

this.Close();

5.) "! % % Localizable $ True. /0 ## % " !$ ).

6.Language ! $ English (United States).

7. . %$* ""! ) " " !.

8.Language ! Russian (Russia).

9." Text , ", " " ! % ( " " % ".

10.# # ) "! #$ "

Threading:

using System.Threading;

11. % ) "! # InitializeComponent(); % % * % % * * ) %( % * %:

Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;

12.% . # CLR % ! ! ! # ) " !, % " # "* ! " !" & %" "6 ! * ! " !".

13.2 . # "* % " % # % ! ( ", " (;)") # "* ! " !" & %" "6 !

* !

" !".

 

%

.

*

)

 

#

! *

 

# % "

! ( ",

").

 

 

 

 

 

 

 

 

 

 

 

 

 

14. '

 

# Visual Studio .NET #

%,

& # !

. Solution

Explorer " % (Show All Files) #

" # !&

).

 

)-%

(Form1.

en-US

 

Form1.ru-RU)

# %

! (

$* –

en

ru)

 

(

$* US RU).

 

 

 

 

 

 

 

 

 

 

 

5. + %

 

 

 

 

 

 

 

* ', . .

 

# *

* *

),

& !

#

%(

,

"

 

" (*

!& Visual Studio # '.

 

 

 

 

 

Visual

 

Studio

 

# *

 

* !

 

% * % "!& ) " "$ %

" %,

% ( & # % * %.

 

 

 

 

 

 

 

 

 

* *

)

% * %

#

, " "

 

CultureInfo

 

 

$

 

 

 

 

 

 

 

 

 

 

 

52

 

 

 

 

 

 

 

CulturInfo.CurrentCulture. " # ) ", " "! "-) " % "!" # !", CurrentUICulture# % !, % "! ! ) "! " ! . % * % * * ) %CurrentThread. CurrentUICulture

, " % ! % * * )# ! ! % !.

Windows-(

1.! UsabilityDemo.sln install_folder\Practices\Mod08\Mod08_04\Starter_2008.

2.) UsabilityDemo.cs " %.

3." % Show All Files Solution Explorer.

4." $ ) "! Localizable. % True, $ $ , $ ) " " ! * .

5.) "! Language # $ French(France).# ! " " ! # % ) "!, * !

" * ) '% %. " , $Solution Explorer # ) " UsabilityDemo.cs * * !& ) % (UsabilityDemo.fr.resx UsabilityDemo.fr-FR.resx).

" , $ # ) " ! # 8 " 6 .

6. ) "! Text # $ Démonstration de l'utilisation.

: , & # "! # # ) '% ) "! " * ) UsabilityDemoLocalizedStrings.rtf,install_folder\Practices\Mod08\Mod08_04.

7.Text " Help % " Help #$ Aide.

8.Text Choose a Culture # $

Choisir une langue.

9.Text Show Date/Time # $

Afficher la date/l'heure.

10.Text Show Currency # $

Afficher la devise.

11.Text Show a String # $ Afficher une chaîne.

12.Text Exit # $ Quitter.

# ( -

1.Solution Explorer % UsabilityDemo | Add |

Add New Item.

2.Add New Item ! Assembly Resource File.

3.2 # # ) % " UsabilityDemoText.fr-FR.resx " % Open.

4.% # # Name $ SimpleTextString.

53

5.% # # Value $ Voici du texte.

6.& ) %.

# -

1.) # " UsabilityDemo.cs.

2.Task List "" TODO. ,

! % " View | Show Tasks | All.

3. * # ! using, # " ## ' .

using System.Globalization; using System.Resources; using System.Threading;

4. # # "" TODO. 1 private

" % ResourceManager.

private ResourceManager RM;

5. #

 

#

#% (

""

TODO.

#

, "

 

ResourceManager.

#

#

 

!

%

:

 

 

 

 

 

 

RM = new ResourceManager("UsabilityDemo.UsabilityDemoText",

Assembly.GetExecutingAssembly());

 

 

 

 

6. #

 

#

#% (

""

TODO.

#

, "

 

ResourceManager.

#

#

 

 

%

:

 

 

 

 

 

 

RM = new ResourceManager("UsabilityDemo.UsabilityDemoText", Assembly.GetExecutingAssembly());

7. # # #% ( "" TODO. * #* " # % # %$ ) % " .

OutputTextBox.Text = RM.GetString("SimpleTextString");

8. # # #% ( "" TODO. * # # # " Culture UICulture $ , ! !& * ".

Thread.CurrentThread.CurrentUICulture = new CultureInfo(ChosenCulture, false);

Thread.CurrentThread.CurrentCulture = new CultureInfo(ChosenCulture, false);

9. & .

4 (

1.% .

2." , $ , $ !

" – , ! * !, 0 * % .

3." % Choose a Culture.

4.! # !. 3 ! ! # &, %"$ %# * * English.

5.% OK ) " Culture Chooser , ) "$ ) "! UsabilityDemo, % ! !" ".

54

9. windows (

%$ # # % * !" & ( " %$ ! # # %, # ( & " * * ""! " "%" " % !$ * .

1.

, " % ! % ' ) % # * # # ! % # ! ) CalculatorEngine. ! # # WindowsCalculator, ! ( " % %. " (* ""! ILDASM ! " " # ! # CalculatorEngine.dll WindowsCalculator.exe.

1." # , ! Start |All Programs |

Microsoft Visual Studio .NET | Visual Studio .NET Tools | Visual Studio

.NET Command Prompt.

2." # # # install_folder\Practices\Mod09\Mod09_01\Starter\CalculatorEngine.

3." #% sn –k CalcKey.snk. % ) ' ) # *, % ! " * * #" .

4.Visual Studio .NET CalculatorEngine.sln install_folder\Practices\Mod09\Mod09_01\Starter\CalculatorEngine.

5." "" TODO Task List. ,

! % " View | Show Tasks | All.

6.) AssemblyInfo.cs

7.# ) " % #, "% !" "" " TODO. " " 2.0.1.1 3.0.1.1.

[assembly: AssemblyVersion("3.0.1.1")]

8. # #% ( "% "" TODO. % ) # * ! % # ! ), # ( ' ) % # * # # ".

[assembly: AssemblyKeyFile("CalcKey.snk")]

9.) # " Calculator.cs.

10.# "" TODO. " ) " '

v2.0.1.1 v3.0.1.1.

private static string versionInfo = "Calculator v3.0.1.1";

11.% Visual Studio .NET.

12." # Visual Studio .NET # # install_folder\Practices\Mod09\Mod09_01\Starter\CalculatorEngine\bin\Debug.

13." # % ILDASM #

CalculatorEngine.dll.

55

14.% MANIFEST.

15.", $ # .assembly CalculatorEngine %

.publickey. / % ! , $ CalculatorEngine " .

(, '* '

1. WindowsCalculator.sln install_folder\Practices\Mod09\Mod09_01\Starter. .

2.2 % " , $ "3.0.1.1. / " CalculatorEngine.dll.

3." # Visual Studio .NET # # install_folder\Practices\Mod09\Mod09_01\Starter\bin\Debug.

4.2 % ILDASM # WindowsCalculator.exe, #% (% " #%:

ildasm WindowsCalculator.exe

5. % MANIFEST. ", $ # .assembly extern CalculatorEngine % ! " 3:0:1:1 .publickeytoken.

/ % ! , $ ! 0 " % %.

2. &

, " % ! # * ! ,0 (GAC)

%

CalculatorEngine.

2 "

!

 

 

WindowsCalculator. # % "

 

! %# * !

CalculatorEngine.dll. $ ! % # * % 0 " %

 

WindowsCalculator, . . "% %#

% *

% %

CalculatorEngine * " ,0 .

 

 

 

:

' ! " * * % %

GACUtil.exe #

#

* ! ,0 ,

. /

"" * %

#

%#

#

* *

! production- . , "

%$ & # " # * * ! ,0

" (*

Windows Installer .NET Framework configuration tool Mscorcfg.msc.

" CalculatorEngine

 

 

1.

 

 

CalculatorEngine.dll

 

 

install_folder\Practices\Mod09\Mod09_02\Starter\ CalculatorEngine.

 

2. "

"" TODO

 

Task

List. ,

!

% " View | Show Tasks | All.

 

 

 

 

3.) AssemblyInfo.cs

4.# ) " % #, "% !" "" " TODO. " " 3.0.1.1 4.0.1.1.

[assembly: AssemblyVersion("4.0.1.1")]

5. ) # " Calculator.cs.

56

6.# "" TODO. " ) " '

v3.0.1.1 v4.0.1.1.

private static string versionInfo = "Calculator v4.0.1.1";

7. % Visual Studio .NET.

# )! ,

GACUtils

1." # , ! Start | All Programs |

Microsoft Visual Studio.NET | Visual Studio .NET Tools | Visual Studio

.NET Command Prompt.

2." # # # install_folder\Practices\Mod09\Mod09_02\Starter\CalculatorEngine\bin\Debug.

3.* % CalculatorEngine * ! ,0 " (* #% ( " #!:

gacutil –i CalculatorEngine.dll

4.! # ! %$* ( Assembly successfully added to the

cache.

5." # " * ,0 " (* #% ( " #!:

gacutil –l

6. # CalculatorEngine. 2 * # * #% (% ) " ': “CalculatorEngine, Version=4.0.1.1, Cultureneutral, PublicKeyToken=***, Custom=null”.

" (, '* '

, '* ' )!

1. WindowsCalculator.dll install_folder\Practices\Mod09\Mod09_02\Starter.

2.Solution Explorer % References.

3.! References | Add Reference.

4.Add Reference " % Browse # % install_folder\Practices\Mod09\Mod09_02\Starter\CalculatorEngine\bin\Debug,

# CalculatorEngine.dll. " % Open, "% OK.

5.) # " CalcUI.cs.

6." "" TODO Task List. ,

! % " View | Show Tasks | All.

7. # ) " % #, "% "" " TODO. * # % using # # % Calculator.

using Calculator;

8.WindowsCalculator.

9.Windows Explorer " % * !

CalculatorEngine.dll OLD_Calculator.dll. / install_folder\Practices\Mod09\Mod09_02\Starter\bin\Debug, install_folder\Practices\Mod09\Mod09_02\Starter\CalculatorEngine\bin\Debug

install_folder\Practices\Mod09\Mod09_02\Starter\CalculatorEngine\obj\Debug.

57

10.

 

 

Windows

Explorer

#

 

%

install_folder\Practices\Mod09\Mod09_02\Starter\bin\Debug.

 

 

 

11.

2 %

 

WindowsCalculator.exe.

 

" , $

WindowsCalculator % 0 % ,

"

 

, $

*

CalculatorEngine.dll

#. /

& #

"%, $ # !

& # % %

% * " & ( % .

 

 

 

3.

%

 

 

 

 

 

 

 

 

 

, " % ! # * ! ,0 %

CalculatorEngine. !

) ) % '

 

#

 

WindowsCalculator,

(

! *

% CalculatorEngine. "

#

*

WindowsCalculator #

, $!

* % CalculatorEngine.

 

 

 

# CalculatorEngine

)!

1." # .

2." # # # install_folder\Practices\Mod09\Mod09_03\Starter.

3.# CalculatorEngine.dll. / 4.0.1.1, % # ! " " ! WindowsCalculator.

4.% CalculatorEngine.dll.v5011 CalculatorEngine.dll.

5. * % CalculatorEngine * ! ,0 ,* % #% (% " #%:

gacutil –i CalculatorEngine.dll

6.! # ! %$* ( Assembly successfully added to the cache.

7." # " * ,0 " (* #% ( " #!:

gacutil –l

8. # CalculatorEngine. # ! * #CalculatorEngine: 4.0.1.1 5.0.1.1.

( (

WindowsCalculator

1.2 % .NET Framework configuration tool (Mscorcfg.msc).

2.% Applications.

3.! Add an Application to Configure.

4.Configure an Application ! Other # % " & # .

5.# %

install_folder\Practices\Mod09\Mod09_03\Starter, !

WindowsCalculator.exe " Open.

58

6.Mscorcfg.msc # Applications %

WindowsCalculator.exe ! Configured Assemblies.

7.( ! Configure an Assembly.

8.Configure an Assembly ! Choose an assembly from the assembly cache.

9." % Choose Assembly.

10.Choose Assembly from Assembly Cache, # %

CalculatorEngine 5.0.1.1. ! CalculatorEngine "% Select.

11." % Finish.

12.CalculatorEngine Properties.

13.! # % Binding Policy.

14.' Requested Version 4.0.1.1

15.' New Version 5.0.1.1

16." % Apply, " % OK.

17." (* ""! Notepad ) install_folder\Practices\Mod09\Mod09_03\Starter\WindowsCalculator.exe.conf ig " # ". " ,

<bindingRedirect>. 2 Notepad.

18.2 % WindowsCalculator.exe. # * ", $ * % % CalculatorEngine. " %# 5.0.1.1.

4. Windows Installer Setup Project

, " % ! # # % Windows Installer Setup Project # WindowsCalculator. 2 " ! % * % ! .

setup-

1.2 % Visual Studio .NET. ' !

New Project.

2.New Project Project Type ! Setup and Deployment Projects.

3.

# " Setup Project.

 

4.

"

 

 

 

 

install_folder\Practices\Mod09\Mod09_04\Starter.

 

 

 

5.

2 # " WinCalc " OK.

 

 

 

6.

# File System % !

#

,

!

$ ". * % #

&

,

 

!

#

 

* ! 0

. " File System on Target Machine, #

Add Special Folder | Global Assembly Cache Folder.

7. " Global Assembly Cache Folder

| Add | File…

59

8.

 

 

 

Add

Files

#

 

%

install_folder\Practices\Mod09\Mod09_04\Starter

 

# *

%

CalculatorEngine.dll.

 

 

 

 

 

 

 

9.

*

 

%

Application

Folder

 

WindowsCalculator.exe: " " Application Folder ! Add | File. Add Files % WindowsCalculator.exe "

Open.

 

 

 

 

10.

* % Application Folder ) KEYS03.ico.

 

11.

 

Properties #

Application Folder #

 

DefaultLocation

#

$

[ProgramFilesFolder]\[ProductName].

AlwaysCreate #

$ True.

 

 

 

12.Solution Explorer Detected Dependencies.

Detected Dependencies " "

CalculatorEngine.dll ! Exclude.

13.

#

! $" * :

 

o

!

Application

Folder

 

(

 

 

WindowsCalculator.exe.

 

 

 

 

o" " ! " #% Create ShortCut to WindowsCalculator.exe. " % Windows

Calculator.

oProperties % # *, $ # Target #$ WindowsCalculator.

oIcon ! Browse.

oIcon ! Browse.

o! # ( Look In ! Application Folder | OK ( KEYS03.ico.

o" OK, " ( $ Icon.

o( ! Application Folder % User’s Desktop.

14.# ! " Program #!#%( 0, # ! " " ". ( ! % User’s

Program Menu

15. Properties #

WinCalc #

#% (

$ #

% !& .

 

 

 

 

 

 

 

 

 

 

 

Author

 

 

 

I’m

 

 

 

Manufacturer

 

 

LIMTU

 

 

ProductName

 

 

WinCalc

 

 

Title

 

 

 

Windows Calculator

 

 

16. &

setup- .

 

 

 

, (

 

 

 

1.

 

Windows

Explorer

#

 

%

install_folder\Practices\Mod09\Mod09_04\Starter\WinCalc\Debug.

 

 

 

 

 

60