-1

( ) をVisual Studio 2013使用するためのカスタム プロジェクト ソリューションを作成しています。プロジェクトファイルノードのカスタムノードタイプを正常に作成し、 customを公開しました。Managed Package FrameworkMPFFileNodeProperties

MPF では、プロジェクトの実行中にSolution ExplorerFileNodePropertiesでファイル ノードを選択すると、プロパティ ウィンドウ[...]このボタンをクリックすると、標準のコレクション エディタダイアログが表示されます。

[ComVisible(true)]
[CLSCompliant(false)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("x-x-x-x-x")] // obfuscated
internal class ModelFileNodeProperties : FileNodeProperties
{
...
[LocDisplayName("Things")] 
public List <int>Things { get; set; }
...
}

私の質問は:

[...]をクリックすると表示される独自のフォーム/エディターを作成して、より複雑なプロパティ タイプ、つまり VS がクエリを実行するフォームを作成できますか? 標準のプロパティ エディターに表示されるものよりもリッチな UI が必要です。プロパティの[...]WinFormクリックすると s が何をするか考えてみてください。またはフォームにアイテムをドロップして、 Pathプロパティをクリックします。FontMessageQueue

たとえば、この例では、プロパティを編集するときに、よりリッチな編集エクスペリエンスが必要です

[LocDisplayName("SomethingComplex")]
public SomethingComplexWithLotsOfConfig SomethingComplex { get; set; } 

私はオンラインで検索し、さまざまなMPFサイトを検索しました

...しかし、残念ながら役に立ちませんでした。どこかに適用するために行ったのは、COM管理のインターフェイスだと思いますか?

4

1 に答える 1

0

私自身の質問に答える - 多くの実験の後; プロジェクトソース コードのMPF の検査。そしていくつかのグーグル。Editor属性を持つプロパティとして公開されているクラスを装飾し、UITypeEditorから派生したカスタム エディターを作成する必要があることがわかりました。通常WinForms、カスタム プロジェクト システムを含む他の場所で使用することができます。

例 これは、プロジェクト システムの「モデル」ファイルを表すファイル ノードです。(ここでは重要ではありませんが、一部のコードは省略されています)。下のPluginsプロパティは、[...]ボタンが欲しいプロパティです。

[ComVisible(true)]
[CLSCompliant(false)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("xx-xx-xx-xx-xx")]
internal class ModelFileNodeProperties : MbtFileNodeProperties
{
    #region Constructor

    /// <summary>
    ///     Initializes a new instance of the <see cref="ModelFileNodeProperties" /> class.
    /// </summary>
    /// <param name="node">The node.</param>
    public ModelFileNodeProperties(HierarchyNode node) : base(node)
    {
        Plugins = new Plugins(node); // Our "model" node has a concept of "plug-ins"
    }

    #endregion

    #region Properties

    [LocDisplayName("Plugins")]
    public Plugins Plugins { get; set; } // <----- I wan't a [...] button for this property 
    ...
}

...そして、モデル ファイルの「プラグイン」を表すクラスを次に示します。Editor次の属性に注意してください。

[Editor(typeof (PluginsEditor), typeof (UITypeEditor))]  // <---- MPF will spot this and expose the editor to Visual Studio
internal class Plugins 
{
    #region Fields

    private readonly HierarchyNode _node;

    public Plugins(HierarchyNode node) { _node = node; }

    // this prevents the object type being displayed in the Property window
    public override string ToString() { return "No plug-ins installed"; }

    public string Something { get; set; }

    public string OrOther { get; set; }

    [Microsoft.VisualStudio.Project.LocDisplayName("Things")]
    public List<int> Things { get; set; }

    #endregion

    ...
}

Pluginsこれは、タイプの表示と変更に使用されるエディターです。

internal class PluginsEditor : UITypeEditor
{
    public PluginsEditor()
    {

    }

    #region Methods

    /// <summary>
    ///     Edits the specified object's value using the editor style indicated by the
    ///     <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle" /> method.
    /// </summary>
    /// <returns>
    ///     The new value of the object. If the value of the object has not changed, this should return the same object it was
    ///     passed.
    /// </returns>
    /// <param name="context">
    ///     An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that can be used to gain
    ///     additional context information.
    /// </param>
    /// <param name="provider">An <see cref="T:System.IServiceProvider" /> that this editor can use to obtain services. </param>
    /// <param name="value">The object to edit. </param>
    public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
    {
        var form = new PluginsForm();
        form.ShowDialog();  // we want to show a modal dialog

        return value;
    }

    /// <summary>
    ///     Gets the editor style used by the
    ///     <see cref="M:System.Drawing.Design.UITypeEditor.EditValue(System.IServiceProvider,System.Object)" /> method.
    /// </summary>
    /// <returns>
    ///     A <see cref="T:System.Drawing.Design.UITypeEditorEditStyle" /> value that indicates the style of editor used by the
    ///     <see cref="M:System.Drawing.Design.UITypeEditor.EditValue(System.IServiceProvider,System.Object)" /> method. If the
    ///     <see cref="T:System.Drawing.Design.UITypeEditor" /> does not support this method, then
    ///     <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle" /> will return
    ///     <see cref="F:System.Drawing.Design.UITypeEditorEditStyle.None" />.
    /// </returns>
    /// <param name="context">
    ///     An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that can be used to gain
    ///     additional context information.
    /// </param>
    public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
    {
        return UITypeEditorEditStyle.Modal; // we don't want a drop-down but rather a modal dialog
    }


    #endregion
}
于 2014-11-01T01:43:19.123 に答える