饭饭TXT > 学习管理 > 《Visual Studio 2010 高级编程(英文出书版)》作者:Nick Randolph/等【完结】 > [Visual.Studio.2010.高级编程].Professional.Visual.Studio.2010.txt

第 11 页

作者:Nick Randolph/等 当前章节:15398 字 更新时间:2026-6-18 14:51

you can see the top of the Properties window, which has been dragged away from its default

position at the right of the IDE. To begin dragging, you need to make sure the tool window is pinned

and then click either the title area at the top of the tool window or the tab at the bottom of the tool

window and drag the mouse in the direction you want the window to move. If you click in the title

area you’ll see that all tool windows in that section of the IDE will also be moved. Clicking the tab

results in only the corresponding tool window moving.

fiGure 3-8

42 .

chaPter 3 opTionS And cuSTomizATionS

As you drag the tool window around Visual Studio 2010, you’ll see that translucent icons appear

at different locations around the IDE. These icons are a useful guide to help you position the tool

window exactly where you want. In Figure 3-9 the Data Sources tool window has been pinned

against the left side. Now when the Properties window is positioned over the left icon of the center

image, the blue shading again appears on the inside of the existing tool window. This indicates that

the Properties tool window will be pinned to the right of the Data Sources tool window and visible

if this layout is chosen. If the far left icon was selected, the Properties tool window would again be

pinned to the left of the IDE, but this time to the left of the Data Sources window.

fiGure 3-9

Alternatively, if the Properties tool window is dragged over the Data Sources tool window as in

Figure 3-10, the center image will move over the existing tool window. This indicates that the

Properties tool window will be positioned within the existing tool window area. As you drag

the window over the different quadrants, you will see that the blue shading again indicates

where the tool window will be positioned when the mouse is released. In Figure 3-10 it indicates

that the Properties tool window will appear below the Data Sources tool window.

fiGure 3-10

The editor space .

43

It should be noted that if you have a large screen or multiple screens, it is worth

spending time laying out the tool windows you use frequently. With multiple

screens, using floating tool windows means that you can position them away from

the main editor space, maximizing your screen real estate. If you have a small

screen you may find that you continually have to adjust which tool windows are

visible, so becoming familiar with the docking and layout options is essential.

the editor sPace

Like most IDEs, Visual Studio 2010 has been built up around the central code-editing window.

Over time, it has evolved and is now much more than a simple text editor. Though most developers

will spend considerable time writing code in the editor space, an increasing number of designers

are available for performing tasks such as building forms, adjusting project settings, and editing

resources. Regardless of whether you are writing code or doing form design, you are going to spend

a lot of your time within Visual Studio 2010 in the editor space. Because of this, it is important for

you to know how to tweak the layout so you can work more efficiently.

fonts and colors

Some of the first things that presenters change in Visual Studio are the fonts and colors used in

the editor space, in order to make the code more readable. However, it shouldn’t just be presenters

who adjust these settings. Selecting fonts and colors that are easy for you to read and that aren’t

harsh on the eyes will make you more productive and enable you to code for longer without feeling

fatigued. Figure 3-11 shows the Fonts and Colors node of the Options dialog, where you can make

adjustments to the font, size, color, and styling of different display items. One thing to note about

this node in the Options dialog is that it is very slow to load, so try to avoid accidentally clicking it.

fiGure 3-11

44 .

chaPter 3 opTionS And cuSTomizATionS

To adjust the appearance of a particular text item within Visual Studio 2010, you first need to select

the area of the IDE that it applies to. In Figure 3-11 the Text Editor has been selected, and has been

used to determine which items should appear in the Display Items list. Once you have found the

relevant item in this list, you can make adjustments to the font and colors.

Some items in this list, such as Plain Text, are reused by a number of areas

within Visual Studio 2010, which can result in some unpredictable changes when

you tweak fonts and colors.

When choosing a font, remember that proportional fonts are usually not as effective for writing code

as non-proportional fonts (also known as fixed-width fonts). As indicated in Figure 3-11, fixed-width

fonts are distinguished in the list from the variable-width types so they are easy to locate.

Visual Guides

When you are editing a file, Visual Studio 2010 automatically color-codes the code based on the

type of file. For example, VB code highlights keywords in blue, variable names and class references

are in black, and string literals are in red. In Figure 3-12 you can see that there is a line running up

the left side of the code. This is used to indicate where the code blocks are. You can click the minus

sign to condense the btnSayHello_Click method or the entire Form1 code block.

Various points about visual guides are illustrated in Figures 3-12 to 3-14. Those readers familiar

with VB.NET will realize that Figure 3-12 is missing the end of the line where the method is set

to handle the Click event of the btnSayHello button. This is because the rest of the line is being

obscured by the edge of the code window. To see what is at the end of the line, the developer has

to either scroll the window to the right or use the keyboard to navigate the cursor to the end of the

line. In Figure 3-13, word wrap has been enabled via the Options dialog (see the Text . Editor .

All

Languages . General node).

fiGure 3-12

fiGure 3-13

fiGure 3-14

The editor space .

45

Unfortunately, enabling word wrapping can make it hard to work out which lines have been

wrapped. Luckily, Visual Studio 2010 has an option (immediately below the checkbox to enable

word wrapping in the Options dialog) that can display visual glyphs at the end of each line that will

indicate a line has been wrapped to the next line, as you can see in Figure 3-14. In this figure you

can also see two other visual guides. On the left, outside the code block markers, are line numbers.

These can be enabled via the Line Numbers checkbox below both the Word Wrap and Visual

Glyphs checkboxes. The other guide is the dots that represent space in the code. Unlike the other

visual guides, this one can be enabled via the Edit . Advanced . View White Space menu item

when the code editor space has focus.

full- screen Mode

If you have a number of tool windows and multiple toolbars visible, you will have noticed that you

quickly run out of space for actually writing code. For this reason, Visual Studio 2010 has a

full-screen mode that you can access via the View . Full Screen menu item. Alternatively, you can press

Shift+Alt+Enter to toggle in and out of full-screen mode. Figure 3-15 shows the top of Visual Studio

2010 in full-screen mode. As you can see, no toolbars or tool windows are visible and the window is

completely maximized, even to the exclusion of the normal Minimize, Restore, and Close buttons.

fiGure 3-15

If you are using multiple screens, full-screen mode can be particularly useful.

Undock the tool windows and place them on the second monitor. When the

editor window is in full-screen mode you still have access to the tool windows,

without having to toggle back and forth. If you undock a code window this will

not be set to full screen.

46 .

chaPter 3 opTionS And cuSTomizATionS

tracking changes

To enhance the experience of editing, Visual Studio 2010 uses line-level tracking to indicate which

lines of code you have modified during an editing session. When you open a file to begin editing

there will be no line coloring. However, when you begin to edit you will notice that a yellow mark

appears next to the lines that have been modified. In Figure 3-16 you can see that the MessageBox

line has been modified since this file was last saved.

fiGure 3-16

When the file is saved, the modified lines will change to having a green mark next to them. In

Figure 3-17 the first MessageBox line has changed since the file was opened, but those changes have

been saved to disk. However, the second MessageBox line has not yet been saved.

fiGure 3-17

If you don’t find tracking changes to be useful, you can disable this feature by

unchecking the Text Editor . General . Track Change item in the Options

dialog.

other oPtions

Many options that we haven’t yet touched on can be used to tweak the way Visual Studio operates.

Through the remainder of this chapter you will see some of the more useful options that can help you

be more productive.

keyboard shortcuts

Visual Studio 2010 ships with many ways to perform the same action. Menus, toolbars, and various

tool windows provide direct access to many commands, but despite the huge number available,

many more are not accessible through the graphical interface. Instead, these commands are accessed

(along with most of those in the menus and toolbars) via keyboard shortcuts.

other options .

47

These shortcuts range from the familiar Ctrl+Shift+S to save all changes, to the obscure Ctrl+Alt+E

to display the Exceptions dialog window. As you might have guessed, you can set your own

keyboard shortcuts and even change the existing ones. Even better, you can filter the shortcuts to

operate only in certain contexts, meaning you can use the same shortcut differently depending on

what you’re doing.

Figure 3-18 shows the Keyboard node in the Environment section of the Options dialog with the

default keyboard mapping scheme selected. If you want to change to use a different keyboard

mapping scheme, simply select it from the drop-down and hit the Reset button.

fiGure 3-18

The keyboard mapping schemes are stored as VSK files at C:\Program Files\

Microsoft Visual Studio 10.0\Common7\IDE. This is the keyboard mapping

file format used in versions of Visual Studio prior to Visual Studio 2005. To

import keyboard mappings from Visual Studio 2005, use the import settings

feature (see the end of this chapter); for earlier versions, copy the appropriate

VSK file into the aforementioned folder, and you will be able to select it from

the mapping scheme drop-down the next time you open the Options dialog.

The listbox in the middle of Figure 3-18 lists every command that is available in Visual Studio

2010. Unfortunately, this list is quite extensive and the Options dialog is not resizable, which makes

navigating this list difficult. To make it easier to search for commands, you can filter the command

list using the Show Commands Containing textbox. In Figure 3-18 the word Build has been used

to filter the list down to all the commands starting with or containing that word. From this list the

Build.BuildSolution command has been selected. Because there is already a keyboard shortcut

assigned to this command, the Shortcuts for Selected Command drop-down and the Remove

button have been enabled. It is possible to have multiple shortcuts for the same command, so the

drop-down enables you to remove individual assigned shortcuts.

48 . chaPter 3 opTionS And cuSTomizATionS

Having multiple shortcuts is useful if you want to keep a default shortcut — so

that other developers feel at home using your setup — but also add your own

personal one.

The remainder of this dialog enables you to assign a new shortcut to the command you have

selected. Simply move to the Press Shortcut Keys textbox and, as the label suggests, press the

appropriate keys. In Figure 3 - 18 the keyboard chord Ctrl+Alt+B has been entered, but this shortcut

is already being used by another command, as shown at the bottom of the dialog window. If you

click the Assign button, this keyboard shortcut will be remapped to the Build.BuildSolution

command.

To restrict a shortcut ’ s use to only one contextual area of Visual Studio 2010, select the context

from the Use New Shortcut In drop - down list. The Global option indicates that the shortcut should

be applied across the entire environment, but we want this new shortcut to work only in the editor

window, so the Text Editor item has been selected in Figure 3 - 18.

Chapter 52 deals with macros that you can create and maintain to make your

coding experience easier. These macros can also be assigned to keyboard shortcuts.

Projects and solutions

Several options relate to projects and solutions. The fi rst of these is perhaps the most helpful — the

default locations of your projects. By default, Visual Studio 2010 uses the standard Documents and

Settings path common to many applications (see Figure 3 - 19), but this might not be where you ’ ll

want to keep your development work.

fiGure 3 - 19

other options .

49

You can also change the location of template files at this point. If your organization uses a common

network location for corporate project templates, you can change the default location in Visual

Studio 2010 to point to this remote address rather than map the network drive.

You can adjust a number of other options to change how projects and solutions are managed in

Visual Studio 2010. One of particular interest is Track Active Item in Solution Explorer. With this

option enabled, the layout of the Solution Explorer changes as you switch among items to ensure

the current item is in focus. This includes expanding (but not collapsing again) projects and folders,

which can be frustrating on a large solution because you are continually having to collapse projects

so that you can navigate.

Another option that relates to solutions, but doesn’t appear

in Figure 3-19, is to list miscellaneous files in the Solution

Explorer. Say you are working on a solution and you have

to inspect an XML document that isn’t contained in the

目录
设置
设置
阅读主题
字体风格
雅黑 宋体 楷书 卡通
字体大小
适中 偏大 超大
保存设置
恢复默认
手机
手机阅读
扫码获取链接,使用浏览器打开
书架同步,随时随地,手机阅读
首 页 < 上一章 章节列表 下一章 > 尾 页