locked
File Extension support, Visual Studio 2010 RRS feed

  • Question

  • I'm attempting to add support for a Order of Precedence Log file. I built the viewer in WPF first, in one window. Now I want to be able to add a Visual Studio Plugin that will read the Forever Log Files (fLog) and use my window. I was hoping to be able to tell VS Extension to open my tool window when some opens a .fLog file (wether from a project or froma outside file) get the file location and then load the tool window.

    I can't seem to find any comprehensive information, any sugestions on where to start. I already have a .net extension and I'm leaving it to be supplied a File Location.


    ~Justin
    Tuesday, July 6, 2010 6:36 PM

Answers

  • For simple file extension registration you could use the new MEF Attributes to associate the content type, but it sounds like thats not what you need. You mentioned writing your own "viewer" so things get a little more complicated. here is a link that discusses file extensions and a little bit about EditorFactory's  http://msdn.microsoft.com/en-us/library/bb165466(VS.80).aspx

    • Proposed as answer by Nancy Shao Wednesday, July 7, 2010 9:55 AM
    • Marked as answer by Nancy Shao Tuesday, July 13, 2010 3:45 AM
    Tuesday, July 6, 2010 7:00 PM

All replies

  • For simple file extension registration you could use the new MEF Attributes to associate the content type, but it sounds like thats not what you need. You mentioned writing your own "viewer" so things get a little more complicated. here is a link that discusses file extensions and a little bit about EditorFactory's  http://msdn.microsoft.com/en-us/library/bb165466(VS.80).aspx

    • Proposed as answer by Nancy Shao Wednesday, July 7, 2010 9:55 AM
    • Marked as answer by Nancy Shao Tuesday, July 13, 2010 3:45 AM
    Tuesday, July 6, 2010 7:00 PM
  • Hi Jkaz,

    It's the best way to register editor file types in your machine as JGreene suggests. If you want to use an Addin to do this, you need to get all Open File events, such as File.OpenFile, View.Open, and compare the file extension which will be opened before these events. If the file extension is .fLog, you can load your toolwindow to open this file, and cancel open file event.

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, July 7, 2010 10:19 AM
  • Ok I'm at a loss... I've added the Editor Factory, but how do I tell it to open my window. The EditorFactory has no commands, no events, and almost no properties. I'm confused. If I'm creating an EditorFactory (in the hopes that this is a handler that can be used to tell it what to do on the event it gets an fLog file) why is their no visible way to work with it. Any suggestions?
    ~Justin
    Wednesday, July 7, 2010 4:46 PM
  • CreateEditorInstance on your registered editor factory gets called to create your editor, if you want a sample implementation you can find one in The IronPython sample.
    Wednesday, July 7, 2010 4:58 PM
  • Oh so its a template object where I must create all the events... oh dear.
    ~Justin
    Wednesday, September 8, 2010 3:27 PM
  • Hi Justin,

    Essentially what is required here, is that you create a custom designer/editor for Visual Studio, and associate it with your particular file type. The easiest way to get started on something like this is to first review a couple of the editor samples that ship with the SDK (or download them if you're using the VS 2010 SDK), and get a feel for the overall architecture of implementing a package, an editor factory, and a custom editor.

    If you are using VS 2010, there is support in the Managed Package Framework, for hosting WPF based editors directly. If you are using VS 2008, you will need to use the ElementHost to bridge the gap between WPF and WinForms.

    The Visual Studio SDK's Package Wizard, gives you a full blown text editor based on an RTF control, and isn't always the best place to start. Especially, if you're looking to implement something more like a designer. Instead, I'd create a basic VsPackage with command support, then add in the editor factory and editor implementations, using the following samples as a guide.

    Example.SvgViewer
    Example.XmlTree

    The following are some useful links to help get you started:

       LearnVSXNow: Creating a simple custom editor - the basics
       Document Designer Editor Sample Deep Dive

    Sincerely,


    Ed Dore
    Wednesday, September 8, 2010 6:22 PM