ICommandExtension.QueryStatus 方法
實作此選項以定義您的命令是否應該可見且處於啟用狀態。 設定 command.Visible 和 command.Enabled。 不要變更模型的狀態。
命名空間: Microsoft.VisualStudio.Modeling.ExtensionEnablement
組件: Microsoft.VisualStudio.Modeling.Sdk.12.0 (在 Microsoft.VisualStudio.Modeling.Sdk.12.0.dll 中)
語法
'宣告
Sub QueryStatus ( _
command As IMenuCommand _
)
void QueryStatus(
IMenuCommand command
)
參數
- command
類型:Microsoft.VisualStudio.Modeling.ExtensionEnablement.IMenuCommand
如果命令應出現在功能表上,則設定 command.Visible = true。如果使用者可以叫用 command.Set command.Text 來區別功能表標籤,則設定 command.Enabled = true。
備註
宣告匯入的屬性內容就可存取這個圖表和模型:
[Import]
public IDiagramContext Context { get; set; }
public void Execute (IMenuCommand command)
{
command.Enabled = command.Visible =
Context.CurrentDiagram
.GetSelectedShapes<IClassifier>().Count() > 2;
}
如需詳細資訊,請參閱如何:在模型圖表上定義功能表命令。
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。