當前位置: 首頁>>代碼示例>>C#>>正文


C# ComponentDesigner.GetService方法代碼示例

本文整理匯總了C#中System.ComponentModel.Design.ComponentDesigner.GetService方法的典型用法代碼示例。如果您正苦於以下問題:C# ComponentDesigner.GetService方法的具體用法?C# ComponentDesigner.GetService怎麽用?C# ComponentDesigner.GetService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.ComponentModel.Design.ComponentDesigner的用法示例。


在下文中一共展示了ComponentDesigner.GetService方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: InitializeServices

// This utility method connects the designer to various
// services it will use. 
private void InitializeServices()
{
    // Acquire a reference to DesignerActionService.
    this.actionService =
        GetService(typeof(DesignerActionService))
        as DesignerActionService;

    // Acquire a reference to DesignerActionUIService.
    this.actionUiService =
        GetService(typeof(DesignerActionUIService))
        as DesignerActionUIService;

    // Acquire a reference to IComponentChangeService.
    this.changeService =
        GetService(typeof(IComponentChangeService))
        as IComponentChangeService;

    // Hook the IComponentChangeService events.
    if (this.changeService != null)
    {
        this.changeService.ComponentChanged +=
            new ComponentChangedEventHandler(
            ChangeService_ComponentChanged);

        this.changeService.ComponentAdded +=
            new ComponentEventHandler(
            ChangeService_ComponentAdded);

        this.changeService.ComponentRemoved +=
            new ComponentEventHandler(
            changeService_ComponentRemoved);
    }

    // Acquire a reference to ISelectionService.
    this.selectionService =
        GetService(typeof(ISelectionService))
        as ISelectionService;

    // Hook the SelectionChanged event.
    if (this.selectionService != null)
    {
        this.selectionService.SelectionChanged +=
            new EventHandler(selectionService_SelectionChanged);
    }

    // Acquire a reference to IDesignerEventService.
    this.eventService =
        GetService(typeof(IDesignerEventService))
        as IDesignerEventService;

    if (this.eventService != null)
    {
        this.eventService.ActiveDesignerChanged +=
            new ActiveDesignerEventHandler(
            eventService_ActiveDesignerChanged);
    }

    // Acquire a reference to IDesignerHost.
    this.host =
        GetService(typeof(IDesignerHost))
        as IDesignerHost;

    // Acquire a reference to IDesignerOptionService.
    this.optionService =
        GetService(typeof(IDesignerOptionService))
        as IDesignerOptionService;

    // Acquire a reference to IEventBindingService.
    this.eventBindingService =
        GetService(typeof(IEventBindingService))
        as IEventBindingService;

    // Acquire a reference to IExtenderListService.
    this.listService =
        GetService(typeof(IExtenderListService))
        as IExtenderListService;

    // Acquire a reference to IReferenceService.
    this.referenceService =
        GetService(typeof(IReferenceService))
        as IReferenceService;

    // Acquire a reference to ITypeResolutionService.
    this.typeResService =
        GetService(typeof(ITypeResolutionService))
        as ITypeResolutionService;

    // Acquire a reference to IComponentDiscoveryService.
    this.componentDiscoveryService =
        GetService(typeof(IComponentDiscoveryService))
        as IComponentDiscoveryService;

    // Acquire a reference to IToolboxService.
    this.toolboxService =
        GetService(typeof(IToolboxService))
        as IToolboxService;

    // Acquire a reference to UndoEngine.
    this.undoEng =
        GetService(typeof(UndoEngine))
        as UndoEngine;

    if (this.undoEng != null)
    {
        MessageBox.Show("UndoEngine");
    }
}
開發者ID:.NET開發者,項目名稱:System.ComponentModel.Design,代碼行數:109,代碼來源:ComponentDesigner.GetService


注:本文中的System.ComponentModel.Design.ComponentDesigner.GetService方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。