Presentation is loading. Please wait.

Presentation is loading. Please wait.

Neal Stublen Practice Solution  Create a new solution  Add a WinForms project  Add a Class Library project  Reference the library.

Similar presentations


Presentation on theme: "Neal Stublen Practice Solution  Create a new solution  Add a WinForms project  Add a Class Library project  Reference the library."— Presentation transcript:

1 Neal Stublen nstublen@jccc.edu

2

3 Practice Solution  Create a new solution  Add a WinForms project  Add a Class Library project  Reference the library from the WinForms project

4 XCopy  Simple file copy  Dependencies must already be installed (e.g..NET Framework)  Won’t install Start menu icons, etc.

5 Using XCopy Deployment  Defaults of bin\Debug, bin\Release within project folder  $(SolutionDir), $(ProjectDir), etc. http://msdn.microsoft.com/en- us/library/c02as0cs.aspx http://msdn.microsoft.com/en- us/library/c02as0cs.aspx  $(SolutionDir)_Output\Debug\$(TargetFileName)  $(SolutionDir)_Output\Release\$(TargetFileName)  C:\Stage\$(SolutionName)\Debug\$(TargetFileName)  C:\Stage\$(SolutionName)\Release\$(TargetFileName)

6 ClickOnce  Install from a link on a web page  Adds Start menu shortcuts, etc.  Adds entry to Programs and Features for changing and uninstalling the application  Automatic updates

7 Setup  Create a setup program to be run from the user’s computer  Install components to the GAC (global assembly cache)  Modify the registry  Create a setup program when ClickOnce is not adequate  Discontinued after VS2010

8 Global Assembly Cache  Machine wide assembly storage  Stores assemblies that are shared by several applications on the computer  %WINDIR%\Microsoft.NET\assembly or %WINDIR%\assembly

9 WiX Toolset  Windows Installer XML Toolset  Alternative to discontinued Setup projects  http://wixtoolset.org http://wixtoolset.org

10

11 When To Use Them?  Create compound controls  Create specialized controls with modified behavior

12 User Control Properties  Override UserControl properties  [Browsable(true)]  [EditorBrowsable(EditorBrowsableState.Always)]  [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]  [Bindable(true)]

13 Code Practice  Create a Label that turns into a TextBox when clicked  Create a User Control Library  Add a Label to the form  Add a TextBox to the form Visible = false  Override Text property of UserControl to update Label  Handle Click event to edit Label Text  Handle Enter key to finish editing

14 Code Practice  Handle Escape key to cancel editing  Handle loss of focus to cancel editing  Create an event to signal a text change  Ensure Text and TextChanged are visible in the designer

15

16 Extend Existing Classes public static class Extensions { public string ToTitleCase(string inText) { } public int WordCount(string inText) { } string title = Extensions.ToTitleCase(title); int count = Extensions.WordCount(title);

17 Extend Existing Classes public static class Extensions { public static string ToTitleCase(this string inText) { } public static int WordCount(this string inText) { } string title = title.ToTitleCase(); int count = title.WordCount();

18

19 Thread Class  Create a new thread to execute some background task Thread t = new Thread(new ThreadStart(ThreadProc_); t.Start(); // Do some other stuff... t.Join(); public static void ThreadProc() { }

20 Code Practice  Create a new project  Create a method that will write the numbers 1 to 10 to the console  Create a secondary thread that will call this method  Start the thread  Call the method on the primary thread  Join the thread

21 Code Practice  Modify the method that writes to the console to update a shared integer value 100 times  Run the program and write the counter value to the console

22 lock Synchronization  The lock statement allows us to guard access to an object

23 Code Practice  Update the previous example to prevent concurrent access to the counter

24 BackgroundWorker  The BackgroundWorker control provides a way to add background functionality to a form  Handler to do work on a background thread  Handlers to report progress and catch completion  IsBusy confirms background process is running  Call RunWorkerAsync() from primary thread

25 BackgroundWorker Progress  Call ReportProgress within DoWork handler

26 Cancel BackgroundWorker  Call CancelAsync () from primary thread  Check CancellationPending property within DoWork handler  Set Cancel property to true in DoWorkEventArgs  Exit DoWork handler

27 Code Practice  Create a BackgroundWorker that just updates a progress bar

28 Async Pattern class Example { // Synchronous method call public bool LongMethod(string param); // Asynchronous method call public void LongMethodAsync(string param); public event LongMethodCompletedEventHandler LongMethodCompleted; }

29

30 Multiple Document Interface  Word can be changed from SDI (all documents appear on taskbar) to MDI (single taskbar icon)  Often replaced by separate top-level Windows or a tabbed interface (e.g. Visual Studio)

31 Using MDI  Set IsMdiContainer to true on parent form  Set MdiParent property on child forms at runtime  Parent’s ActiveMdi property indicates the currently active child form  Parent’s LayoutMdi property can arrange the child forms


Download ppt "Neal Stublen Practice Solution  Create a new solution  Add a WinForms project  Add a Class Library project  Reference the library."

Similar presentations


Ads by Google