Getting Bookmarks Programmatically in Visual Studio - visual-studio-2010

I am using VS 2010 and I want to do something quite simple. Write a Macro / Add-in which will
Save the bookmarks to a file (e.g. "myfile.bookmarks")
Load bookmarks from a file.
I just cannot find any API within DTE (when writing a macro) nor can I find anything within the Microsoft.VisualStudio namespace when creating an addin.
Can someone please help?
(The one thing I want to avoid is re-creating bookmarks functionality, although I can use code from Numbered Bookmarks extension).

Related

Rename form and all instances of form in Visual Studio 2010

I'm working on a project in Visual Studio 2010 and want to rename a form and all instances of a form via the Solution Explorer. Here is what my screen looks like:
Any ideas? I just need a quick way to rename them all at once. I know I can rename them individually but I'm trying to find an easier way so I can do it faster.
In VS, renaming the form.cs file should also rename the form's resource and designer definition file automatically. If it is not doing that then you might have changes something manually.

How to preview a VB6 .frm file?

I have an old VB6 project that is still alive and needs some attention at the moment, but I don't know anything about VB6 and I am just wondering how to preview a .frm file from the project.
I also have the .vbp file if that could be of any help.
I know I can open the files in a text editor (e.g. Notepad++) but is there a way to actually preview the form (like the designer in Visual Studio for WinForms)?
EDIT: Is there a way to make changes to a form?
As you say, you can view .frm and .vbp files in a text editor. These include most of the information about the from.
As far as I know however the only way to actually view and edit the forms is with the Visual Basic 6 IDE. I'm not entirley sure how to best go about acquring a copy howvever.
Re: Edit. You can change the .frm files using any text editor. But that's not going to do you any good without the IDE to compile the changed source.

How to keep several files in a tree in Visual Studio?

When you add (for example) WPF window to your project VS creates .xaml and .xaml.cs files. However they are not displayed in a flat list in VS Explorer, rather .xaml.cs is a child file (in terms of the tree) of .xaml file.
How to organize several "custom" files into such tree? For example I have Trainer.cs file and Trainer.Builder.cs file. I would like Builder to be displayed as a child of Trainer.cs file. How to do it?
Please note: I know about folder with files, but I don't want to use it, because in such case even the "main" file is hidden and I have to unfold folder to get it.
Update
While searching for difference between VS2008 and VS2010, I found out, that my entire question is a duplicate of SO question -- there you find how to fix a fix for VS2008 to work with VS2010 :-)
Visual Studio 2010 related file nesting
This can be done by editing the registry. A guide to doing this for Visual Studio 2008 can be found here: http://blog.dotnetwise.com/2009/09/visual-studio-2008-custom-nested-files.html
You can also do this through a Visual Studio Extension, but unless this is part of a larger project this is probably overkill. There is a guide to implementing this behavior here: http://pieterderycke.wordpress.com/2011/03/10/adding-support-for-nested-files-in-custom-visual-studio-project-types-with-mpf/

Can Visual Studio 2010 do ".inc" file syntax highlighting?

Can Visual Studio 2010 be configured to do syntax highlighting on ".inc" files? We have numerous large projects with tons of these ".inc" files (asp files) and so changing the file extension to ".asp" is not an option. All I want Visual Studio 2010 to do is treat these ".inc" files just like ".asp" files when it comes to syntax highlighting.
I've tried "Open With..." and selected the HTML Editor, which is the ".asp" default, but that did not work. I tried about every other editor in the list and none of them worked.
I know Notepad++ (among others) can do this, but I would prefer this be done in Visual Studio 2010 - using another IDE or text editor is not the answer I'm looking for here.
In Visual Studio...go to Options -> Text Editor -> File Extension. Type in 'inc' as extension and editor as 'Web Form Editor'. You may need to close then re-open your currently open .Inc pages...Hope this helps
I found both the 'Web Form Editor' and 'HTML Editor' to be less than ideal for me. Both of them appeared to highlight the syntax of the HTML ok, but the VBScript keywords were left in standard black text along with everything else.
While not ideal, I followed the instructions from the other answers, but substitude Visual Basic as the editor type and that worked much more to my liking (as they were include files, there is little HTML in them).
Options -> Text Editor -> File
Extension. Type in 'inc' as extension and set editor as 'Visual Basic'.
Close and re-open any '.inc' files and highlighting should be visible.
Antonio's solution worked for me. I did have to close and reopen files, but after I re-opened them the highlighting was visible. Thanks!
Options -> Text Editor -> File Extension.
Type in 'inc' as extension and set editor as 'Web Form Editor'.
Close and re-open any '.inc' files and highlighting should be visible.
Incidentally, this also works in Visual Studio 2005.
Use the File Extension, Text Editor, Options Dialog Box.
http://msdn.microsoft.com/en-us/library/4k7w5e5s.aspx
-update-
I see the same behavior :-( Will let you know if I find anything.
As a workaround, could you rename all your .inc files to .asp?
This has the added advantage that if a request is made for the inc file directly (highly unlikely but possible; and assuming you have the incs in the web directory), your code will be exposed unlike .asp where it is processed and rendered.
I really wanted to add a comment, because this is not a direct answer, but apparently you need 50 reputation for that.
I've found that in Visual Studio 2005 (again, in Tools -> Options -> Text Editor -> File Extension), both "Web Form Editor" and "User Control Editor" highlight both the HTML and the VBScript.
Amadiere mentioned that "Web Form Editor" doesn't highlight the VBScript in 2010, but maybe it's worth trying "User Control Editor", if that's an option in 2010.
In Visual Studio 2010 and 2012 Express it best works for me when I use "Microsoft Visual Basic" with my .inc files. Nevertheless, it's still not the same as with .asp files as there's no Autocomplete nor IntelliSense (Ctrl+Space, Ctrl+Shift+Space etc.) with the .inc files.
It should be made possible defining that .inc files are to be treated just as .asp files.
I agree with Purple Coder:
You should not name the files containing ASP code as .inc. It is a security risk. Anyone who knows/can guess the filename can open it in a browser and view the actual code inside the file.
But, first of all in my case this is an intranet page and therefore not very risky, as most people there would somehow find the files on the server anyway. I'm also not sure where this naming convention came from. It was there before I started. This was started on Visual Studio 6.
But, to avoid this risk there's a simple solution: add .inc in the Application Mapping of the IIS in the same manner as .asp.
You should not name the files containing ASP code as .inc. It is a security risk. Anyone who knows/can guess the filename can open it in a browser and view the actual code inside the file.

Can you add documents and spreadsheets to a Visual Studio Project?

In Eclipse, I often include all project-related material (including documents in PDF, Microsoft, and OpenDocument formats) in the project. Is this possible with Visual Studio, especially to the point where if I attempt to open the file from inside Visual Studio, it will open in the external application?
Yes, just right-click your project in the solution explorer and goto Add > Existing Item...
Though -- I'd recommend making a new folder to keep this in.
Yes, you can make sure that when you open it it opens with the correct application. Just right-click the file once it's added into the solution explorer and select Open With... and make sure you set the default application that way from that point forward you can just double-click your files.
If you have access to use Sharepoint Services with your source control than that would also make life much easier, thanks for reminding me Chris!
I don't want to take away from Chad's answer. However, I will add that TFS has specific areas for project documentation to be stored in sharepoint.

Resources