|
|
/***************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
This code is licensed under the Visual Studio SDK license terms.
THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
***************************************************************************/
//*************************************************************************************************
// MyTestEditorFactory.cs
//
// This file defines the MyTestEditorFactory test.
//
// Copyright(c) Microsoft Corporation, 2005
//*************************************************************************************************
namespace Microsoft.VisualStudio.TestTools.Samples
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Microsoft.VisualStudio;
using VsipConstants = Microsoft.VisualStudio.VSConstants;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.TestTools.Tips.TuipPackage;
using Microsoft.VisualStudio.TestTools.Vsip;
using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
/// <summary>
/// MyTest editor factory implementation.
/// </summary>
[GuidAttribute("3BC80630-6F22-4da0-8D12-61BB2E0C82EB")]
internal class MyTestEditorFactory : EditorFactory
{
#region Constructors
/// <summary>
/// Constructor.
/// </summary>
public MyTestEditorFactory()
{
}
#endregion
#region Properties
/// <summary>
/// Caption to append to any file name. This is shown in the doc well with the filename
/// </summary>
protected override string EditorCaption { get { return " [MyTestSample]"; } }
/// <summary>
/// This GUID is used to allow toolbars etc to be shown when this window is active
/// See VSIP documentation on these CTC file guids
/// </summary>
protected override Guid GuidCmdUI
{
get { return (new Guid("662394CD-430F-436e-9EC8-DB21FFB7BD9A")); }
}
#endregion
#region Operations
/// <summary>
/// Instantiates the editor and hands it back to the framework.
/// This should be some sort of WindowPane.
/// </summary>
/// <param name="monikerDocument"></param>
/// <returns></returns>
protected override WindowPane CreateEditor(string monikerDocument)
{
// Load the control
TuipEditorControl editorForm = new MyTestEditorControl(base.VSServiceProvider);
// Wrap it in a window pane
TuipEditorWindowPane pane = new TuipEditorWindowPane(typeof(MyTestEditorFactory).GUID, editorForm, base.VSServiceProvider);
return pane;
}
#endregion
// These are not implemented and are left for reference
// if the user wishes to implement a custom IVsEditorFactory
#region IVsEditorFactory Members
// Please refer to the VSIP document for the methods below.
/*
/// <summary>
/// Initializes an editor in the environment.
/// </summary>
/// <param name="serviceProvider">Reference to the IServiceProvider interface of the editor being initialized.</param>
public int SetSite(IOleServiceProvider serviceProvider)
{
if (serviceProvider == null)
{
throw new ArgumentNullException("serviceProvider");
}
m_vsServiceProvider = serviceProvider;
return VsipConstants.S_OK;
}
/// <summary>
/// Maps a logical view to a physical view.
/// </summary>
/// <param name="guidLogicalView">Unique identifier of the logical view.</param>
/// <param name="physicalView">The physical view to which the logical view is to be mapped. </param>
public int MapLogicalView(ref Guid guidLogicalView, out string physicalView)
{
// This base class only support 1 phisical view, so return null
physicalView = null;
return VsipConstants.S_OK;
}
/// <summary>
/// Releases all cached interface pointers and unadvises any event sinks.
/// </summary>
public virtual int Close()
{
return VsipConstants.S_OK;
}
/// <summary>
/// Used by the editor factory architecture to create editors that support data/view separation.
/// </summary>
/// <param name="flagCreateDoc">Flags whose values are taken from the VSCREATEEDITORFLAGS enumeration which defines the conditions under which to create the editor. Only open and silent flags are valid.</param>
/// <param name="documentPath">String form of the moniker identifier of the document in the project system. In the case of documents that are files, this is always the path to the file. This parameter can also be used to specify documents that are not files. For example, in a database-oriented project, this parameter could contain a string that refers to records in a table.</param>
/// <param name="physicalView">Name of the physical view.</param>
/// <param name="hierarchy">Pointer to the IVsHierarchy interface</param>
/// <param name="itemId">Item identifier of this editor instance.</param>
/// <param name="docDataExisting">Must be the punkDocData object that is registered in the Running Document Table (RDT). This parameter is used to determine if a document buffer (DocData object) has already been created. When an editor factory is asked to create a secondary view, then this parameter will be non-NULL indicating that there is no document buffer. If the file is open, return VS_E_INCOMPATIBLEDOCDATA and the environment will ask the user to close it.</param>
/// <param name="docView">Pointer to the IUnknown interface for the DocView object. Returns NULL if an external editor exists, otherwise returns the view of the document. </param>
/// <param name="docData">Pointer to the IUnknown interface for the DocData object. Returns the buffer for the document.</param>
/// <param name="editorCaption">Initial caption defined by the document editor for the document window. This is typically a string enclosed in square brackets, such as "[Form]". This value is passed as an input parameter to the IVsUIShell::CreateDocumentWindow method. If the file is [ReadOnly] the caption will be set during load of the file.</param>
/// <param name="guidCmdUI">Returns the Command UI GUID. This GUID is active when this editor is activated. Any UI element that is visible in the editor has to use this GUID. This GUID is used in the .ctc file in the satellite DLL where it indicates which menus and toolbars should be displayed when the document is active.</param>
/// <param name="isCanceled">TRUE if the user pressed Cancel in the UI while creating the editor instance.</param>
public int CreateEditorInstance(
uint flagCreateDoc,
string documentPath,
string physicalView,
IVsHierarchy hierarchy,
uint itemId,
System.IntPtr docDataExisting,
out System.IntPtr docView,
out System.IntPtr docData,
out string editorCaption,
out Guid guidCmdUI,
out int isCanceled)
{
docView = IntPtr.Zero;
docData = IntPtr.Zero;
isCanceled = 0;
editorCaption = null;
guidCmdUI = Guid.Empty;
return VsipConstants.S_OK;
}
#endregion
#region Private data
*/
#endregion
}
}
|