Скачать книгу

you compress the project, remove the bin, obj, and .vs directories to save space.

Step-by-Step

      ● Find and bookmark useful web resources.

      1. Open your favorite web browser.

      2. Create a new bookmark folder named C#. (See the browser's documentation if you don't know how to make a bookmark folder.)

      3. Go to the following websites and bookmark the ones you like (feel free to search for others, too):

      ● My C# Helper website (www.CSharpHelper.com)

      ● This book's web page (www.CSharpHelper.com/24hour.html)

      ● This book's Wrox web page (go to www.wrox.com and search for C# 24-Hour Trainer, Second Edition)

      ● Visual C# Express Edition MSDN forum (social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/threads)

      ● Visual C# IDE MSDN forum (social.msdn.microsoft.com/Forums/en-US/csharpide/threads)

      ● Visual C# Language MSDN forum (social.msdn.microsoft.com/Forums/en-US/csharplanguage/threads)

      ● Visual C# General MSDN forum (social.msdn.microsoft.com/Forums/en-US/csharpgeneral/threads)

      ● MSDN (msdn.microsoft.com)

      ● Stack Overflow (www.stackoverflow.com)

      ● Code Project (www.codeproject.com)

      ● Launch Visual Studio and start a new Visual C# project.

      1. If you don't have a desktop or taskbar icon for Visual Studio, create one. For example, in Windows 8, follow these steps:

      a. Open the Charms area, click Search, and type VS Express (or part of the name of the version you installed). If Visual Studio isn't in the result list, make sure the search box's dropdown list has Everywhere selected.

      b. In the search results, right-click the program and select Pin to Start or Pin to Taskbar.

      2. Launch Visual Studio by clicking the tile you just pinned to the start screen or the icon you just pinned to the taskbar.

      3. Create a new project.

      a. Press Ctrl+Shift+N or open the IDE's File menu, expand the New submenu, and select Project.

      b. Expand the Visual C# project types folder and select the Windows Forms Application template.

      c. Enter a project name and a good, easy-to-find location like the desktop or a folder named C# Projects on the desktop.

      d. Uncheck the Create Directory for Solution box.

      e. Click OK.

      ● Experiment with the IDE's layout by displaying the Debug toolbar, pinning the Toolbox, and displaying the Output window.

      1. Open the Tools menu and select Customize. On the Customize dialog, select the Toolbars tab and check the box next to the Debug toolbar. Experiment with the other toolbars if you like. Close the dialog when you're done.

      2. If the Toolbox is auto-hiding (it should be after you first install Visual Studio), float the mouse over it until it expands. Click the thumbtack to pin it.

      3. To display the Output window, open the View menu and select Output. Grab the Output window's title bar and drag it around. Move it over some drop targets to see where it lands. When you're finished, drop it at the bottom of the IDE as shown in Figure 1.7.

      ● Run the program.

      1. Press F5 or open the Debug menu and select Start Debugging.

      2. Try out the form's minimize, maximize, and close buttons and the commands in the form's system menu. Move the form around and resize it. Marvel at the fact that you didn't need to write any code!

      ● Find the program's executable, copy it to the desktop, and run it there.

      1. Start File Explorer and navigate to the location that you specified when you created the new program.

      2. There you should find a folder named after the program. Open that folder and examine the files inside. Notice the .sln file that you can double-click to reopen the solution in Visual Studio. Notice also the bin, obj, and .vs directories.

      3. Enter the bin directory and move into its Debug subdirectory. It contains several files including the executable, named after the program but with the .exe extension. Right-click the executable and select Copy.

      4. Right-click the desktop and select Paste to copy the executable to the desktop.

      5. Double-click the copy of the executable on the desktop.

      ● Copy the project folder to a new location and make changes to the copy.

      1. In File Explorer, go to the directory that contains the project folder.

      2. Right-click the project's folder and select Copy.

      3. Right-click the desktop and select Paste to copy the project folder.

      4. Open the copied project folder and double-click the .sln file to open the copied project in Visual Studio. If the form doesn't open in the Form Designer (#4 in Figure 1.7), look in Solution Explorer and double-click the file Form1.cs.

      5. In the Form Designer, grab the handle on the form's lower-right corner and resize the form to make it tall and skinny.

      6. Run the modified program. Then go back to the original project (which should still be running in another instance of Visual Studio) and run it. Notice that the two versions display forms of different sizes.

      ● Compress the project folder to make a backup.

      1. In Visual Studio, close the project. (Or close Visual Studio.)

      2. In File Explorer, return to the project's folder and delete the bin, obj, and .vs directories. (Note that you can't delete the bin directory if Visual Studio has the project open.)

      3. Move up one level to the directory that contains the project folder. Right-click the folder, expand the Send To submenu, and select Compressed (Zipped) Folder.

      4. E-mail copies of your first project to all of your friends and relatives. I'm sure they'll thank you!

      Exercises

      1. Build a solution that contains two projects. (Create a project named Project1. Check the Create Directory for Solution box and name the solution TwoProjects. Then open the File menu, expand the Add submenu, and select New Project to add a new project named Project2.)

      2. This lesson explains only a tiny fraction of the ways you can customize Visual Studio. Try another one by making your own toolbar. Select the Tools menu's Customize command. On the Toolbars tab, click the New button, and name the new toolbar MyTools. On the Commands tab, select the Toolbar radio button and then select the new toolbar from the dropdown list. Now use the Add Commands button to add some commands to the toolbar.

      3. This lesson also describes only a few of the windows Visual Studio offers. Use the menus to find and display the Output, Immediate, Error List, and Task List windows. Put them all in tabs at the bottom of Visual Studio (#8 in Figure 1.7).

      4. Some tools are available only when

Скачать книгу