Visual Studio 2012 Cookbook

By Richard Banks
  • Instant online access to over 7,500+ books and videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
  1. Discovering Visual Studio 2012

About this book

There’s a new technology wave coming, and for Microsoft this is reflected in Windows 8, HTML5 web development, .NET 4.5 and C++11. Riding that wave is a new version of their flagship development tool, Visual Studio 2012, and "Visual Studio 2012 Cookbook" has you putting the new features into practice from the get-go!

Among the exciting new features of Visual Studio 2012 is support for Windows 8, HTML5 and asynchronous development, as well as Team Foundation Server 2012 integration. “Visual Studio 2012 Cookbook” doesn’t waste time explaining what you already know from prior Visual Studio versions; instead you’ll see targeted and focused recipes on only new features so that you can get up to speed and back to work faster.

“Visual Studio 2012 Cookbook” empowers you to take advantage of all the new features in Visual Studio 2012 so that you can develop applications for the next technology wave.

The task-based recipes in this guide will have you up and running with improvements like support for Windows 8 development, HTML5 and JavaScript, .NET 4.5, asynchronous code and C++11.

And since most people don’t develop alone, you’ll also see how the new team development features of Visual Studio 2012 and Team Foundation Server 2012 can help your whole team work smarter, not harder.

Time is short and you’re in a hurry, so “Visual Studio 2012 Cookbook” will help you discover what’s new by way of a simple recipe format that is quick and easy to digest.

Publication date:
September 2012
Publisher
Packt
Pages
272
ISBN
9781849686525

 

Chapter 1. Discovering Visual Studio 2012

In this chapter, we will cover:

  • Creating a new project

  • Upgrading an existing solution

  • Managing editor windows

  • Finding Visual Studio commands

  • Navigating and searching

  • Searching your code

  • Using the graphics tools

 

Introduction


When you open Visual Studio 2012 for the first time you're going to notice a few changes. We're going to start out by looking at some of the standard activities you will perform with Visual Studio in your normal development activities and in doing so discover a number of new and changed features in this powerful development tool.

These are tasks which are common to all developers regardless of the language they program in or the platform they are targeting.

 

Creating a new project


It might look the same as it did before, but there are a few changes when creating a new project. Let's create a new project and see what has changed.

Getting ready

Just make sure you have installed Visual Studio 2012 and you're all set to go.

How to do it...

  1. Start Visual Studio 2012.

  2. Choose the File | New Project menu option.

  3. Examine the list of project types that are available and choose one that is of interest to you. If you're not sure what to choose, select Visual C# | Class Library.

  4. Ensure that the project is targeting .NET Framework 4.5 as shown in the following screenshot:

  5. Enter a name of your choice for the project. If you feel lacking in creativity, take the default name and then click on OK.

  6. The project is now created and you are ready to start writing code.

How it works...

On its own the project creation process in Visual Studio works exactly as it did in previous versions of Visual Studio, with the only difference being that you can now target .NET Framework 4.5.

There's more...

If that's all there was to it, it would hardly be worth talking about, however there are larger differences to be seen in the project creation area. Let's talk about them.

New project types and your development operating system

It's here that you will notice the first major change from Visual Studio 2010 and where you will see differences between Visual Studio 2012 running on Windows 8 versus a prior version of Windows.

The operating system you are using dictates whether you have access to the new Windows Runtim e (WinRT) or not and thus whether you can write Windows Store Applications or not. On Windows 8 you will see a range of options for creating Windows Store Applications, whereas on Windows 7 and prior you will only see options for creating applications that do not use WinRT.

Portable class libraries

The Portable Class Library project template allows developers to create class library assemblies that can be referenced from not only standard .NET Framework applications, but also from Silverlight, Xbox 360 (XNA), and Windows Phone 7 projects.

This is at its most valuable when sharing service and data contracts or common domain classes between backend web services and frontend clients built using different technologies. For example, if previously you had a Silverlight application that used a set of web services running under ASP.NET then you would have to share code for those services by having separate projects for each runtime that looked exactly the same and used linked files to share the source.

Now all you have to do is move your common code into a single portable class library and add a reference to that portable library project from both your Silverlight project and your ASP.NET Web Application project.

Note that Portable Class Libraries are also available for Visual Studio 2010 using the Portable Library Tools extension from the Visual Studio Gallery (http://visualstudiogallery.msdn.microsoft.com/b0e0b5e9-e138-410b-ad10-00cb3caf4981).

Office projects

Visual Studio 2012 only provides project templates for Office 2010 projects. For Office 2007 projects you will need to continue using Visual Studio 2010.

Retired project templates

Visual Studio 2012 no longer has the Crystal Reports project template, nor does it feature Visual Studio Installer projects. If you are using Visual Studio Installer projects at the moment you will need to look at some different approaches. We cover some of the choices for creating installers in the Appendix, Visual Studio Pot Pourri

See also

  • The Creating a Windows Store app recipe in Chapter 2, Getting Started with Windows Store Applications

 

Upgrading an existing solution


It's always nice to start a new project and if you've been working with legacy code for a while there's no better feeling! Unfortunately that feeling is often all too rare and we spend most of our time dealing with existing code with a long history.

All that legacy code is probably what's keeping you employed, so what you really want is to be able to open up that existing code in your shiny new copy of Visual Studio 2012 and bring the power of Visual Studio 2012 to bear on it, making life just that little bit easier for yourself.

One of the big changes in Visual Studio 2012 is that projects opened in Visual Studio 2012 are also backwards compatible with Visual Studio 2010 Service Pack 1 and we will see how that works. This process is called round tripping.

The good news for teams is that round tripping means they can gradually move from Visual Studio 2010 to Visual Studio 2012 as and when they are ready. They won't have the problems of the past where one team member checks in an upgraded solution file to source control, thus forcing the rest of the team to upgrade simply to continue working.

Getting ready

If you don't have any existing code you want to use you can use the sample Visual Studio 2010 solution we've prepared for you.

Note

The solution we will be using throughout this chapter is called VS2010_Web and can be found at Chapter 1/VS2010_Web.

If you are going to use some of your existing code, ensure that the current code is in source control or that you have backed up the code.

In order to see the backwards compatibility in action you will need Visual Studio 2010 with Service Pack 1 installed on your machine.

How to do it...

  1. Using either the Open Project link on the Visual Studio start page or the File | Open | Project/Solution menu select the VS2010_Web solution to start the conversion process.

  2. Visual Studio will automatically migrate the solution and all the projects within it. When the process is complete you will be shown a migration report.

  3. Close the report when you have finished looking at it.

  4. From Solution Explorer open the Default.aspx file in the VS2010_Web project and change the Welcome to ASP.NET! text on the page to Welcome to Visual Studio 2012!.

  5. Build and run the project to see that the application is working as expected.

  6. Close Visual Studio 2012 and open Visual Studio 2010 with Service Pack 1.

  7. Open the VS2010_Web solution and run the application.

  8. You should see the web application appear, showing the updated message from Visual Studio 2012.

How it works...

The Visual Studio team worked with the various language and development product teams to ensure that project file formats would work consistently between Visual Studio 2010 and Visual Studio 2012. The first stage of these changes rolled out publicly with the release of Service Pack 1 for Visual Studio 2010, allowing Visual Studio 2010 to understand the new project formats.

When Visual Studio 2012 opens a Visual Studio 2010 project it will automatically upgrade the project format unless those changes will affect the ability to open the project in Visual Studio 2010. Any compatibility breaking changes will cause a dialog to be shown describing the changes and you can decide what action to take.

Note

Visual Studio 2012 will also upgrade projects created in Visual Studio 2008 and Visual Studio 2005, however round tripping of those projects is not supported. Likewise, the opening of a Visual Studio 2012 upgraded project in Visual Studio 2010 without Service Pack 1 is not supported.

There's more...

Not all project types will work with round tripping.

Visual Studio database projects

Visual Studio database projects aren't supported for round tripping. Visual Studio 2012 obsoleted Visual Studio database projects and replaced them with the new SQL Server Data Tools (SSDT) projects. When you open an old database project in Visual Studio 2012 you can upgrade it to an SSDT project. This project format also supports round tripping. However, if you wish to open an SSDT project in Visual Studio 2010 you will need to install the SQL Server Data Tools separately. You can download the tools from http://msdn.microsoft.com/en-us/data/hh297027.

ASP.NET MVC 2 projects

Visual Studio 2012 ships with support for both ASP.NET MVC 3 and ASP.NET MVC 4 projects. ASP.NET MVC 2 projects are not supported for round tripping in Visual Studio 2012 and therefore you will need to upgrade your MVC 2 projects to MVC 3 projects before opening them in Visual Studio 2012.

To help with the upgrade process you can use the ASP.NET MVC 3 Application Upgrader available from the ASP.NET Codeplex site at http://aspnet.codeplex.com/releases/view/59008.

Silverlight 3 and earlier

In a similar manner to ASP.NET MVC 2 projects, Silverlight 3 projects and prior will not be supported for round tripping with Visual Studio 2012. You will need to upgrade these projects to a later version of Silverlight first.

Visual Studio 2012 supports both Silverlight 4 and Silverlight 5 projects and you will be prompted for the version of Silverlight to use when you create a new project.

See also

  • The Using the new SQL Server Data Tools recipe in Appendix,Visual Studio Pot Pourri

 

Managing editor windows


As you would expect, with a new Visual Studio version there comes a number of changes to how windows are managed. The changes that have been made have been done with the intention of reducing the clutter in your editing workspace and making the development experience one that is more focused on what you are doing.

Getting ready

Open either the VS2010_Web solution we have been using or use a solution of your choice.

Ensure that the Solution Explorer is open.

How to do it...

  1. In Solution Explorer locate the Default.aspx.cs file in the VS2010_Web project and double-click it. The source file will open in the main window area as with previous versions of Visual Studio; however you will now notice that the document tab features a pin icon next to the tab name as you can see in the following screenshot. You'll use that pin in just a few steps.

  2. Using Solution Explorer, open both the About.aspx.cs and the Global.asax.cs files by double-clicking on them. You should now have three documents open with their tabs showing in the tab well.

  3. Click on the Default.aspx.cs tab to select it and then click on the pin. The pin will change to point downwards indicating that the document is now pinned. Visual Studio 2012 will keep pinned tabs visible in the tab well even when you have so many open that Visual Studio starts hiding tabs. The pinned document tab will be moved to the left next to any other pinned documents you may have open.

  4. Right-click the Global.asax.cs document tab and click on Close All But This to close all open documents except for the one currently selected. This will include closing any pinned documents.

  5. Reopen both the Default.aspx.cs and About.aspx.cs files that you closed by double-clicking on them in Solution Explorer.

  6. One of the usability problems with document tabs in Visual Studio 2010 was that you could accidentally float documents by double-clicking a document tab. In Visual Studio 2012 this behavior has changed. Double-click on a document tab of your choice and notice how Visual Studio sets the focus to that tab instead of floating it. Much better!

  7. Press Ctrl+Shift+F to open the Find in Files dialog. Enter Class in the Find what field and ensure Look in is set to Solution, then click on Find All.

  8. In the Find Results 1 window select a result from the ChangePassword.aspx file. The file will open in the preview tab, located on the right-hand side of the tab well.

    Tip

    Downloading the example code

    You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

  9. The preview tab shows the contents of the currently selected document if it is not already open. In the Find Results 1 window select a result from Login.aspx. It will now be opened automatically in the preview tab and the ChangePassword.aspx document will be closed.

  10. Assume you now want to keep Login.aspx open for a while. Either click the Keep Open icon in the tab or change the contents of the file. Any document in the preview tab that is changed is automatically promoted to a normal tab.

    Visual Studio will move the document from the preview tab area into the main tab area. The color of the tab will also be changed from purple to blue indicating that the tab is now a normal document tab.

How it works...

Pinning documents works much like pinning does in any other part of Visual Studio and makes it very handy for keeping those documents you are working on regularly within easy reach, especially when you have many documents open at once.

The preview document tab is a great way to prevent tab clutter and becomes very useful when debugging deeply nested code. For example, say you have a section of code where a result you are expecting from a high-level method call is incorrect, and the source of the error actually is from a much lower-level method called at the end of a chain of four other intermediate methods, each from a different class. The odds are that you aren't really interested in those intermediate classes. Sure, you're happy to see those classes as you step through them on the way to the source of the problem, but you don't want to keep the documents open once you've moved past them. The preview tab means that during debugging, these class files are only opened temporarily, not permanently, helping you focus on just the code you are genuinely interested in and preventing the tab well filling up with documents you just aren't interested in.

There's more...

As always there are ways to customize the behavior of the document tabs in Visual Studio.

Single click preview in Solution Explorer

The preview tab isn't restricted to just the find results window. It can also be used from within Solution Explorer. If you activate the Preview Selected Items button in the Solution Explorer toolbar then every item you click on will be opened in the preview tab automatically.

The Preview Selected Items button is a toggle button. If you want to disable the behavior then you only need to click on the button to deselect it and the preview behavior will be turned off.

Customizing tab and window behavior

Navigating to the Tools | Options menu in Visual Studio will show the following dialog box:

There are a number of options in here that let you control how the tabs behave. With Visual Studio 2010 Productivity Power Tools many developers found different ways to configure their tab well to get the experience they wanted, and while not everything from the power tools came across to the final Visual Studio 2012 product, a number of features most certainly did. Feel free to experiment with the Tabs and Windows settings to get Visual Studio working the way you like it most.

 

Finding Visual Studio commands


Visual Studio has a number of new commands in this release, combined with all the previous Visual Studio commands. Well, that makes for a lot of commands to try and keep in your head at once. Why take those brain cells where you stored all your sci-fi movie quotes and overwrite them with the intricate details of Visual Studio commands, when Visual Studio 2012 gives you an easy way to find the commands you're looking for with nothing more than a quick keystroke and a keyword or two? That's a win-win situation right there!

Let's see how this works.

Getting ready

Start Visual Studio 2012 and either open a project of your choice or the VS2010_Web project we've been using throughout this chapter.

How to do it...

  1. Have a look at the top-right hand side of the Visual Studio editor window and you will see the new Quick Launch search box.

    For maximum speed the fastest developers try to minimize mouse usage and you're going to do the same for this recipe, so instead of clicking in the textbox to activate, press the shortcut key (Ctrl+Q). You will see that the Quick Launch box now activates and is waiting for your input.

  2. Assume you want to open a file but you can't remember what the command is or where it might be hiding amongst all those menus. Yes, there's a really obvious File menu and it is the obvious place to look, but for the sake of the exercise pretend that you had almost no sleep last night, that you've just arrived at work today, that the coffee hasn't taken effect, your brain hasn't yet kicked into motion, and that you've forgotten where the open command lives.

    With the Quick Launch box active, enter the word open without pressing Enter and wait a moment for the search results to appear:

  3. Take a look at the results. You'll see that not only are there the commands you might reasonably expect to see from the File | Open submenu, but also other commands you might not have realized existed, such as Open Developer Account (only if you are working in Windows 8). You can also see that the search results include Visual Studio options, not just the commands that are available.

  4. Remembering that you are going through this recipe using only the keyboard, use the up and down cursor keys to navigate to a result of your choice and press Enter to execute that command.

  5. You now need to open the Default.aspx page using just the Quick Launch tool and only with the keyboard. To do this you need to navigate to the Default.aspx file. Hit the Quick Launch shortcut (Ctrl+Q) and type in nav to see what commands are available:

  6. Press cursor down until the Edit | Navigate To entry is highlighted. Press Enter to activate the command.

  7. In the resulting dialog box type default and wait momentarily for the search results to appear. Press cursor down until Default.aspx is highlighted and then hit Enter.

  8. Now that you have the file open press the Quick Launch shortcut (Ctrl+Q) and type in default. In the search results you will not only see matching Visual Studio options, but also commands that perform different operations on the open Default.aspx file. That's pretty cool!

  9. When there are a large number of results Visual Studio will show you a subset of those results based on what it deems to be the best matches for your search.

  10. Use the Quick Launch control and enter the value debug. You will see a subset of all available results.

  11. To see the full set of results simply press the Quick Launch shortcut again (Ctrl+Q). The expanded results are then shown.

How it works...

The Visual Studio team realized that the growing number of commands in Visual Studio was overwhelming for many people. Those people needed an easy way to quickly locate a command they were after without dredging through their memory cells for where that command might be hiding, or to waste time browsing through the various Visual Studio menus until they found it.

The Quick Launch search box is the recommended interface to find the commands you need, but don't use often enough to remember where they are.

There's more...

If you're a developer looking to improve your skills, be more productive, and maximize your use of the IDE, then knowing how to navigate your way around Visual Studio 2012 with nothing but the keyboard is a great goal to aim for. It minimizes the movement of your hand between the keyboard and the mouse which saves you time as well as gives you a greater sense of mastery over your tools. As a bonus, you'll also be able to impress your colleagues and dazzle them with your awesome Visual Studio skills!

If you find you use a command regularly, take the time to learn its specific shortcut key so you don't have to search for it every time you want to use it. For everything else, as long as you remember the name of the command or something close to it, you can use the Quick Launch control to find and execute that command without wasting time hunting through menus, and you won't have had to move your hands off the keyboard to do it.

 

Navigating and searching


As a code base grows it's important to be able to understand and find things quickly in your solution. The Solution Explorer we were used to in Visual Studio 2010 was good for being able to understand how files were organized into the various projects of a solution, but it didn't do much more than that.

With Visual Studio 2012, Microsoft has revisited Solution Explorer and given it an overhaul. It still contains all the functionality you know from the old Solution Explorer and adds to that a range of new features intended to make navigating and searching within your solution a more powerful, yet simpler experience.

Getting ready

Open the same VS2010_Web solution we have been using for the other recipes in this chapter or choose a solution of your own.

How to do it...

  1. We'll begin with navigating through our solution. Locate the Default.aspx page in the VS2010_Web project and click the arrow next to it so that its contents are displayed. As you would expect there is a code behind file and a designer file.

  2. Look at the Default.aspx.cs file. You can see that there is a small arrow next to it just as there was for the Default.aspx page. Click on the arrow.

  3. Visual Studio 2012 expands the file to show its contents and in the case of a code behind file those contents are the class definitions it contains. Classes have methods and properties in them, so click the arrow next to the _Default class to see the methods inside it. Since the VS2010_Web project is just a shell there is only an empty Page_Load() method as shown in the following screenshot:

  4. Now select the IService1.cs file from the VS2010_Web.Services project and expand it to see its contents. You will see that there is both an interface definition in this file (IService1) and a class definition (CompositeType) as shown in the following screenshot:

  5. Right-click on the IService1 interface and click Derived Types to see what classes implement this interface.

  6. Solution Explorer will change views to show you the types that either implement this interface or inherit from it, as shown in the following screenshot. Click on the back button (showing the blue background) to return to the standard Solution Explorer view.

  7. Right-click on the IService1 interface and choose the Is Used By option to see where the interface is currently being used. As with the Derived Types option you will see Solution Explorer change context to only show the interface and where that interface is used in the solution, including line and column numbers.

  8. Return to the regular Solution Explorer view by clicking on the home button.

  9. At this point you know how to navigate using Solution Explorer and you have already used the existing Navigate To feature from Visual Studio 2010 in the previous recipe (Finding Visual Studio commands) when opening a file. With the enhancements to Solution Explorer you can locate files in much the same way as with the Navigate To command, albeit with a slightly different user experience.

    Click in the Search Solution Explorer textbox at the top of Solution Explorer or use the default shortcut key of Ctrl+; (Ctrl+Semicolon).

  10. Enter serv into the textbox and wait a moment for the search results to display. The results should look similar to the following screenshot. You can see not only the file names that match the search term, but also any matching references, classes, and methods.

How it works...

The Navigate To command from Visual Studio 2010 was a fantastic addition to Visual Studio. It had problems in large projects with many search matches since the location of a match was embedded in the result itself making it hard to locate the specific match you were after.

The new Solution Explorer search tool provides similar results to the Navigate To command, but having the location of a match represented in the tree view makes it very easy to quickly identify the specific match you are interested in.

There's more...

It's worth mentioning a few other things about searching within your solution.

Navigation behavior

Assuming you have the Preview tab enabled for Solution Explorer then as you navigate using Solution Explorer to various classes and methods you may have noticed that the document preview tab was updating and showing exactly where the selected class, method, or property is declared.

This makes it easy to see what the code is doing without the need to specifically open the file or scroll through a source file to see what code is actually inside a method, class, or property.

CSS, HTML, and JavaScript files

Even though it's possible to extract structure from CSS, HTML, and JavaScript files, Solution Explorer doesn't show the internal structure of these files. You can navigate to the source file but not to any of its contents.

See also

  • The Finding Visual Studio commands recipe

 

Searching your code


You now know how to search within your solution for classes and methods and how to drill down into various items, but what if you are looking for a specific variable or piece of text in your code?

The Find tools in Visual Studio 2012 have been significantly revamped. It's time to use them and see what you can find.

Getting ready

Once again, open the same solution we have been using in the other recipes; either the VS2010_Web solution or a solution of your choosing.

How to do it...

  1. Open the IService1.cs file from the VS2010_Web.Services project.

  2. Ensure that focus is set to the code window, not Solution Explorer, and press Ctrl+F. This will trigger the new search tool as shown in the following screenshot. Alternatively you can access this from the menu using Edit | Find and Replace | Quick Find.

  3. Enter the text service into the textbox. As you type you will notice that Visual Studio matches the search term against the code on the fly and all the matches are highlighted as shown in the following screenshot. This makes it very quick and easy to see if you have located the code you are looking for.

  4. Since the search term has been matched multiple times it makes sense that you might want to quickly move between those matches. Press F3 to move to the next match and press Shift+F3 to move to the previous match.

  5. Change the search term to serviceHost. Because there is no match in the current file the color of the border of the search box changes to red.

  6. Given that you don't have a match in the current file it's worth expanding the scope of the search. Click on the expand icon on the left side of the search box and change the scope from Current Document to Current Project. When you do, you will notice that the red outline disappears indicating a match has been located.

  7. Press F3 to find the next match. Note that the next matching file is opened as a normal document tab, not in the preview tab.

How it works...

By making the search dialog appear within the window that currently has focus, the user experience for both find and replace is much improved. It takes up only a small amount of space, it doesn't use a floating window, and the search box goes away when focus moves to a different window or document within Visual Studio, keeping the visual clutter low.

There's more...

When you clicked the button to expand the Quick Search tool window you may have noticed the option to replace text. This works as you would expect. Simply enter the text you want the search term replaced with and instead of pressing Find Next use the Replace Next button.

What happened to the old search dialog?

It's still there! Well, kind of. The changes in making search more context-specific mean that the Quick Find dialog is gone. If you have the focus somewhere other than a document tab and you press Ctrl+F or use the Quick Find command then the Find and Replace dialog will be shown with the Find in Files option selected. This is the same dialog box you will be familiar with from previous Visual Studio versions.

Can I use regular expressions?

This quick search dialog box doesn't support regular expression matches. Only the Find and Replace dialog box (via the Find in Files command) still supports regular expressions.

 

Using the graphics tools


The graphics tools in previous versions of Visual Studio might best be described as mediocre. However, in Visual Studio 2012 they have been revisited to provide some much needed updates.

Visual Studio 2012 in no way replaces a full featured graphics package, however if you just need to tweak an image or make some simple changes then Visual Studio can be very useful.

In this recipe, you'll create an image that you could use in the website project we've been using throughout this chapter.

Getting ready

Open the VS2010_Web project that we've been working with throughout this chapter.

How to do it...

  1. Right-click on the VS2010_Web project and select Add | New Folder. Call the new folder Images.

  2. With the Images folder selected, from the File menu choose New File or press Ctrl+N. From the New File dialog select Graphics | PNG Image (.png) and click on Open.

    The new Visual Studio Graphics Designer will appear.

  3. Save the image to the Images folder of your project using File | Save As with the default name of Image1.png.

  4. In Solution Explorer turn on the Show all files option and locate the image you just saved to the Images folder. Include it in the project by right-clicking it and choosing the Include In Project option.

  5. Back in Graphics Designer you will see two new toolbars. One along the top of the image area and one along the side. For reference we will call these toolbars the top toolbar and the side toolbar.

  6. Select the Brush tool so you can draw on your wonderfully blank picture.

    To set the color of the brush, ensure the Properties panel is open. If it isn't it can be accessed by pressing F4 or choosing View | Properties Window.

  7. To select the brush thickness change the Width property of Appearance to a value of your choice, such as 10.

  8. Now draw on the canvas and start creating your next masterpiece! Experiment with the other options in the toolbar to get a feel for what the graphics tool provides. Just make sure you produce something better than this horrible effort!!

How it works...

The new graphics designer is a DirectX accelerated design surface. You can alter the DirectX rendering output method to use software acceleration if, for example, you are using older hardware and are seeing graphics glitches. To switch, use the side toolbar and select Advanced | Graphics Engines | Render with D3D11WARP.

While the graphics editor is a much better editor that the previous resource editor, and even though DirectX acceleration means that the image editor can now work with very large, and complex images and a multitude of formats, it still isn't a match for a full featured graphics editing program. For advanced graphics needs, use a specialist tool.

There's more...

Visual Studio 2012 doesn't simply provide the same 2D image editing options of the past with a new interface; it now provides for some more advanced techniques specifically designed for those who need to produce visually rich applications such as games or information visualization tools.

MIP mapping support

MIP mapping is a technique used in video games for texture mapping 3D models. A single image file is structured to contain a high resolution texture as well as multiple versions of the same texture at lower levels of resolution. When the game is running, a texture of the appropriate resolution is extracted from the image file and applied to the 3D model based on the distance the model is from the camera. The further away the object, the lower the resolution chosen.

Visual Studio 2012 supports the editing of MIP map images using the new Graphics Designer.

3D Model support

You may have noticed when you were creating the PNG file that you also had the option to create a 3D scene.

Visual Studio 2012 supports the viewing, editing, and creating of AutoDesk FBX files, and also supports the viewing and editing (but not creating) of OBJ and Collada DAE files.

Pixel shaders

Visual Studio now supports the creating of pixel shaders in a visual manner using DGSL (Directed Graph Shader Language) as well as HLSL shaders using C++.

See also

  • The Creating a shader using DGSL recipe in Chapter 7,Unwrapping C++ Development

  • The Creating and displaying a 3D model recipe in Chapter 7,Unwrapping C++ Development

About the Author

  • Richard Banks

    Richard Banks has developed software for the last 20 years for a wide range of industries and development platforms. Over the years he has played many roles including that of a developer, team lead, project manager, and CIO/CTO. He is a Professional Scrum Trainer, runs the Sydney ALT.NET user group and the Talking Shop Down Under podcast. He owns and contributes to a few open source projects, and has spoken at Microsoft TechEd and a number of other events and user groups around Australia. For some strange reason, he gets a real kick out of helping development teams to improve and produce great software. If you want to get in touch, he tweets at @rbanks54 and blogs at http://www.richard-banks.org/. He currently works as a Principal Consultant for Readify and is a Microsoft Visual Studio ALM MVP.

    Browse publications by this author
Book Title
Access this book, plus 7,500 other titles for FREE
Access now