다음을 통해 공유


IUIService 인터페이스

디자이너를 호스팅하고 있는 개발 환경 개체의 사용자 인터페이스와의 상호 작용을 가능하게 합니다.

네임스페이스: System.Windows.Forms.Design
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
<GuidAttribute("06A9C74B-5E32-4561-BE73-381B37869F4F")> _
Public Interface IUIService
‘사용 방법
Dim instance As IUIService
[GuidAttribute("06A9C74B-5E32-4561-BE73-381B37869F4F")] 
public interface IUIService
[GuidAttribute(L"06A9C74B-5E32-4561-BE73-381B37869F4F")] 
public interface class IUIService
/** @attribute GuidAttribute("06A9C74B-5E32-4561-BE73-381B37869F4F") */ 
public interface IUIService
GuidAttribute("06A9C74B-5E32-4561-BE73-381B37869F4F") 
public interface IUIService

설명

IUIServiceStyles 사전 속성을 통해 오류 메시지와 대화 상자를 표시할 수 있으며 대화 상자용 글꼴과 색 구성표와 같은 호스트의 앰비언트 속성을 가져올 수 있습니다.

예제

다음 코드 예제에서는 IUIService의 메서드를 호출하는 디자이너 동사 메뉴 명령을 제공하는 디자이너를 만듭니다. 이 예제를 사용하려면 샘플 코드를 어셈블리에 컴파일하고 Windows Forms 응용 프로그램에 이 어셈블리에 대한 참조를 추가해야 합니다. Visual Studio를 사용하는 경우에는 IUIServiceExampleControl도구 상자에 자동으로 추가됩니다. IUIServiceExampleControl의 인스턴스를 Form에 추가하십시오. IUIService 메서드를 호출하는 디자이너 동사 명령에 액세스하려면 컨트롤 표면을 마우스 오른쪽 단추로 클릭하거나, 컨트롤의 스마트 태그 문자 모양을 클릭한 다음 스마트 태그 패널에서 항목을 선택하십시오.

Imports System
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Windows.Forms.Design

' This designer provides a set of designer verb shortcut menu commands
' that call methods of the IUIService.
Public Class IUIServiceTestDesigner
   Inherits System.Windows.Forms.Design.ControlDesigner
   
   Public Sub New()
    End Sub

    ' Provides a set of designer verb menu commands that call 
    ' IUIService methods.
    Public Overrides ReadOnly Property Verbs() As System.ComponentModel.Design.DesignerVerbCollection
        Get
            Return New DesignerVerbCollection(New DesignerVerb() { _
                New DesignerVerb("Show a test message box using the IUIService", _
                New EventHandler(AddressOf Me.showTestMessage)), _
                New DesignerVerb("Show a test error message using the IUIService", _
                New EventHandler(AddressOf Me.showErrorMessage)), _
                New DesignerVerb("Show an example Form using the IUIService", _
                New EventHandler(AddressOf Me.showDialog)), _
                New DesignerVerb("Show the Task List tool window using the IUIService", _
                New EventHandler(AddressOf Me.showToolWindow))})
        End Get
    End Property

    ' Displays a message box with message text, caption text 
    ' and buttons of a particular MessageBoxButtons style.
    Private Sub showTestMessage(ByVal sender As Object, ByVal e As EventArgs)
        Dim UIservice As IUIService = CType(Me.GetService( _
            GetType(System.Windows.Forms.Design.IUIService)), IUIService)
        If Not (UIservice Is Nothing) Then
            UIservice.ShowMessage("Test message", "Test caption", _
                System.Windows.Forms.MessageBoxButtons.AbortRetryIgnore)
        End If
    End Sub

    ' Displays an error message box that displays the message
    ' contained within a specified exception.
    Private Sub showErrorMessage(ByVal sender As Object, ByVal e As EventArgs)
        Dim UIservice As IUIService = CType(Me.GetService( _
            GetType(System.Windows.Forms.Design.IUIService)), IUIService)
        If Not (UIservice Is Nothing) Then
            UIservice.ShowError(New Exception( _
                "This is a message in a test exception, displayed by the IUIService", _
                New ArgumentException("Test inner exception")))
        End If
    End Sub

    ' Displays an example Windows Form using the 
    ' IUIService.ShowDialog method.
    Private Sub showDialog(ByVal sender As Object, ByVal e As EventArgs)
        Dim UIservice As IUIService = CType(Me.GetService( _
            GetType(System.Windows.Forms.Design.IUIService)), IUIService)
        If Not (UIservice Is Nothing) Then
            UIservice.ShowDialog(New ExampleForm())
        End If
    End Sub

    ' Displays a standard tool window using the 
    ' IUIService.ShowToolWindow method.
    Private Sub showToolWindow(ByVal sender As Object, ByVal e As EventArgs)
        Dim UIservice As IUIService = CType(Me.GetService( _
            GetType(System.Windows.Forms.Design.IUIService)), IUIService)
        If Not (UIservice Is Nothing) Then
            UIservice.ShowToolWindow(StandardToolWindows.TaskList)
        End If
    End Sub

End Class

' Provides an example Form class used by the 
' IUIServiceTestDesigner.showDialog method.
Friend Class ExampleForm
    Inherits System.Windows.Forms.Form

    Public Sub New()
        Me.Text = "Example Form"
        Dim okButton As New System.Windows.Forms.Button()
        okButton.Location = New Point(Me.Width - 70, Me.Height - 70)
        okButton.Size = New Size(50, 20)
        okButton.Anchor = AnchorStyles.Right Or AnchorStyles.Bottom
        okButton.DialogResult = System.Windows.Forms.DialogResult.OK
        okButton.Text = "OK"
        Me.Controls.Add(okButton)
    End Sub
End Class

' This control is associated with the IUIServiceTestDesigner, 
' and can be sited in design mode to use the sample.
<DesignerAttribute(GetType(IUIServiceTestDesigner), GetType(IDesigner))> _
Public Class IUIServiceExampleControl
    Inherits UserControl

    Public Sub New()
        Me.BackColor = Color.Beige
        Me.Width = 255
        Me.Height = 60
    End Sub

    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        If Me.DesignMode Then
            e.Graphics.DrawString("Right-click this control to display a list of the", _
                New Font("Arial", 9), Brushes.Black, 5, 6)
            e.Graphics.DrawString("designer verb menu commands provided", _
                New Font("Arial", 9), Brushes.Black, 5, 20)
            e.Graphics.DrawString("by the IUIServiceTestDesigner.", _
                New Font("Arial", 9), Brushes.Black, 5, 34)
        End If
    End Sub
End Class
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.Design;

// This designer provides a set of designer verb shortcut menu commands
// that call methods of the IUIService.
public class IUIServiceTestDesigner : System.Windows.Forms.Design.ControlDesigner
{
    public IUIServiceTestDesigner()
    {
    }

    // Provides a set of designer verb menu commands that call 
    // IUIService methods.
    public override System.ComponentModel.Design.DesignerVerbCollection Verbs
    {
        get
        {
            return new DesignerVerbCollection( new DesignerVerb[] 
            {
                new DesignerVerb( 
                    "Show a test message box using the IUIService", 
                     new EventHandler(this.showTestMessage)),
                new DesignerVerb( 
                    "Show a test error message using the IUIService", 
                     new EventHandler(this.showErrorMessage)),
                new DesignerVerb( 
                    "Show an example Form using the IUIService", 
                     new EventHandler(this.showDialog)),
                new DesignerVerb( 
                     "Show the Task List tool window using the IUIService", 
                     new EventHandler(this.showToolWindow)) 
            });
        }
    }

    // Displays a message box with message text, caption text 
    // and buttons of a particular MessageBoxButtons style.
    private void showTestMessage(object sender, EventArgs e)
    {
        IUIService UIservice = (IUIService)this.GetService( 
            typeof( System.Windows.Forms.Design.IUIService ) );
        if( UIservice != null )            
            UIservice.ShowMessage("Test message", "Test caption", 
                System.Windows.Forms.MessageBoxButtons.AbortRetryIgnore);
    }

    // Displays an error message box that displays the message
    // contained in a specified exception.
    private void showErrorMessage(object sender, EventArgs e)
    {       
        IUIService UIservice = (IUIService)this.GetService( 
            typeof( System.Windows.Forms.Design.IUIService ) );
        if( UIservice != null )            
            UIservice.ShowError( new Exception(
                "This is a message in a test exception, " + 
                "displayed by the IUIService", 
                 new ArgumentException("Test inner exception")));
    }

    // Displays an example Windows Form using the 
    // IUIService.ShowDialog method.
    private void showDialog(object sender, EventArgs e)
    {
        IUIService UIservice = (IUIService)this.GetService( 
            typeof( System.Windows.Forms.Design.IUIService ) );
        if( UIservice != null )            
            UIservice.ShowDialog(new ExampleForm());
    }

    // Displays a standard tool window using the 
    // IUIService.ShowToolWindow method.
    private void showToolWindow(object sender, EventArgs e)
    {
        IUIService UIservice = (IUIService)this.GetService( 
            typeof( System.Windows.Forms.Design.IUIService ) );
        if( UIservice != null )            
            UIservice.ShowToolWindow(StandardToolWindows.TaskList);
    }
}

// Provides an example Form class used by the 
// IUIServiceTestDesigner.showDialog method.
internal class ExampleForm : System.Windows.Forms.Form
{
    public ExampleForm()
    {
        this.Text = "Example Form";
        System.Windows.Forms.Button okButton = new System.Windows.Forms.Button();
        okButton.Location = new Point(this.Width-70, this.Height-70);
        okButton.Size = new Size(50, 20);
        okButton.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
        okButton.DialogResult = DialogResult.OK;
        okButton.Text = "OK";
        this.Controls.Add( okButton );
    }
}

// This control is associated with the IUIServiceTestDesigner, 
// and can be sited in design mode to use the sample.
[DesignerAttribute(typeof(IUIServiceTestDesigner), typeof(IDesigner))]
public class IUIServiceExampleControl : UserControl
{
    public IUIServiceExampleControl()
    {
        this.BackColor = Color.Beige;
        this.Width = 255;
        this.Height = 60;
    }

    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        if( this.DesignMode )
        {
            e.Graphics.DrawString(
                "Right-click this control to display a list of the", 
                 new Font("Arial", 9), Brushes.Black, 5, 6);
            e.Graphics.DrawString(
                "designer verb menu commands provided", 
                 new Font("Arial", 9), Brushes.Black, 5, 20);
            e.Graphics.DrawString( 
                "by the IUIServiceTestDesigner.", 
                 new Font("Arial", 9), Brushes.Black, 5, 34);
        }
    }
}
#using <System.dll>
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>
#using <System.Design.dll>

using namespace System;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace System::Windows::Forms::Design;

// Provides an example Form class used by the
// IUIServiceTestDesigner::showDialog method.
ref class ExampleForm: public System::Windows::Forms::Form
{
public:
   ExampleForm()
   {
      this->Text = "Example Form";
      System::Windows::Forms::Button^ okButton = gcnew System::Windows::Forms::Button;
      okButton->Location = Point(this->Width - 70,this->Height - 70);
      okButton->Size = System::Drawing::Size( 50, 20 );
      okButton->Anchor = static_cast<AnchorStyles>(AnchorStyles::Right | AnchorStyles::Bottom);
      okButton->DialogResult = ::DialogResult::OK;
      okButton->Text = "OK";
      this->Controls->Add( okButton );
   }
};

// This designer provides a set of designer verb shortcut menu commands
// that call methods of the IUIService.
public ref class IUIServiceTestDesigner: public System::Windows::Forms::Design::ControlDesigner
{
public:
   IUIServiceTestDesigner(){}

   property System::ComponentModel::Design::DesignerVerbCollection^ Verbs 
   {
      // Provides a set of designer verb menu commands that call IUIService methods.
      virtual System::ComponentModel::Design::DesignerVerbCollection^ get() override
      {
         array<DesignerVerb^>^temp0 = {gcnew DesignerVerb( "Show a test message box using the IUIService",gcnew EventHandler( this, &IUIServiceTestDesigner::showTestMessage ) ),gcnew DesignerVerb( "Show a test error message using the IUIService",gcnew EventHandler( this, &IUIServiceTestDesigner::showErrorMessage ) ),gcnew DesignerVerb( "Show an example Form using the IUIService",gcnew EventHandler( this, &IUIServiceTestDesigner::showDialog ) ),gcnew DesignerVerb( "Show the Task List tool window using the IUIService",gcnew EventHandler( this, &IUIServiceTestDesigner::showToolWindow ) )};
         return gcnew DesignerVerbCollection( temp0 );
      }
   }

private:

   // Displays a message box with message text, caption text
   // and buttons of a particular MessageBoxButtons style.
   void showTestMessage( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      IUIService^ UIservice = dynamic_cast<IUIService^>(this->GetService( System::Windows::Forms::Design::IUIService::typeid ));
      if ( UIservice != nullptr )
            UIservice->ShowMessage( "Test message", "Test caption", System::Windows::Forms::MessageBoxButtons::AbortRetryIgnore );
   }


   // Displays an error message box that displays the message
   // contained within a specified exception.
   void showErrorMessage( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      IUIService^ UIservice = dynamic_cast<IUIService^>(this->GetService( System::Windows::Forms::Design::IUIService::typeid ));
      if ( UIservice != nullptr )
            UIservice->ShowError( gcnew Exception( "This is a message in a test exception, displayed by the IUIService",gcnew ArgumentException( "Test inner exception" ) ) );
   }

   // Displays an example Windows Form using the
   // IUIService::ShowDialog method.
   void showDialog( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      IUIService^ UIservice = dynamic_cast<IUIService^>(this->GetService( System::Windows::Forms::Design::IUIService::typeid ));
      if ( UIservice != nullptr )
            UIservice->ShowDialog( gcnew ExampleForm );
   }

   // Displays a standard tool window window using the
   // IUIService::ShowToolWindow method.
   void showToolWindow( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      IUIService^ UIservice = dynamic_cast<IUIService^>(this->GetService( System::Windows::Forms::Design::IUIService::typeid ));
      if ( UIservice != nullptr )
            UIservice->ShowToolWindow( StandardToolWindows::TaskList );
   }
};

// This control is associated with the IUIServiceTestDesigner,
// and can be sited in design mode to use the sample.

[DesignerAttribute(IUIServiceTestDesigner::typeid,IDesigner::typeid)]
ref class IUIServiceExampleControl: public UserControl
{
public:
   IUIServiceExampleControl()
   {
      this->BackColor = Color::Beige;
      this->Width = 255;
      this->Height = 60;
   }

protected:
   virtual void OnPaint( System::Windows::Forms::PaintEventArgs^ e ) override
   {
      if ( this->DesignMode )
      {
         e->Graphics->DrawString( "Right-click this control to display a list of the", gcnew System::Drawing::Font( "Arial",9 ), Brushes::Black, 5, 6 );
         e->Graphics->DrawString( "designer verb menu commands provided", gcnew System::Drawing::Font( "Arial",9 ), Brushes::Black, 5, 20 );
         e->Graphics->DrawString( "by the IUIServiceTestDesigner.", gcnew System::Drawing::Font( "Arial",9 ), Brushes::Black, 5, 34 );
      }
   }
};
import System.*;
import System.ComponentModel.*;
import System.ComponentModel.Design.*;
import System.Drawing.*;
import System.Windows.Forms.*;
import System.Windows.Forms.Design.*;

// This designer provides a set of designer verb shortcut menu commands
// that call methods of the IUIService.
public class IUIServiceTestDesigner
extends System.Windows.Forms.Design.ControlDesigner 
{
    public IUIServiceTestDesigner() 
    {
    } //IUIServiceTestDesigner
   
    // Provides a set of designer verb menu commands that call 
    // IUIService methods.
   
    /** @property 
     */
    public System.ComponentModel.Design.DesignerVerbCollection get_Verbs()
    {
        return new DesignerVerbCollection(new DesignerVerb[]{
            new DesignerVerb("Show a test message box using the IUIService",
            new EventHandler(this.ShowTestMessage)),new DesignerVerb("Show" 
            + " a test error message using the IUIService", new EventHandler(
            this.ShowErrorMessage)), new DesignerVerb("Show an example Form "
            + " using the IUIService", new EventHandler(this.ShowDialog)),
            new DesignerVerb("Show the" + " Task List tool window using the" 
            + " IUIService", new EventHandler(this.ShowToolWindow))}) ;
    } // get_Verbs
      
    // Displays a message box with message text, caption text 
    // and buttons of a particular MessageBoxButtons style.
    private void ShowTestMessage(Object sender, EventArgs e) 
    {
        IUIService uiService = (IUIService)this.GetService(System.Windows.
            Forms.Design.IUIService.class.ToType());
        if (uiService != null) {
            uiService.ShowMessage("Test message", "Test caption", System.
                Windows.Forms.MessageBoxButtons.AbortRetryIgnore);
        }
   } //ShowTestMessage   
    
    // Displays an error message box that displays the message
    // contained in a specified exception.
    private void ShowErrorMessage (Object sender, EventArgs e) 
    {
        IUIService uiService = (IUIService)this.GetService(System.Windows.
            Forms.Design.IUIService.class.ToType());
        if (uiService != null) {
            uiService.ShowError(new System.Exception("This is a message in a" 
                + " test exception, displayed by the IUIService",
                new ArgumentException("Test inner exception")));
        }
    } //ShowErrorMessage   
    
    // Displays an example Windows Form using the 
    // IUIService.ShowDialog method.
    private void ShowDialog(Object sender, EventArgs e) 
    {
        IUIService uiService = (IUIService)this.GetService(System.Windows.
            Forms.Design.IUIService.class.ToType());
        if (uiService != null) {
            uiService.ShowDialog(new ExampleForm());
        }
    } //ShowDialog
       
    // Displays a standard tool window using the 
    // IUIService.ShowToolWindow method.
    private void ShowToolWindow(Object sender, EventArgs e)
    {
        IUIService uiService = (IUIService)this.GetService(System.Windows.
            Forms.Design.IUIService.class.ToType());
        if (uiService != null) {
            uiService.ShowToolWindow(StandardToolWindows.TaskList);
        }
    } // ShowToolWindow
} // IUIServiceTestDesigner

// Provides an example Form class used by the 
// IUIServiceTestDesigner.showDialog method.
class ExampleForm extends System.Windows.Forms.Form
{
    public ExampleForm() 
    {
        this.set_Text("Example Form");
        System.Windows.Forms.Button okButton =
            new System.Windows.Forms.Button();
        okButton.set_Location(new Point(this.get_Width() - 70,
            this.get_Height() - 70));
        okButton.set_Size(new Size(50, 20));
        okButton.set_Anchor(AnchorStyles.Right | AnchorStyles.Bottom);
        okButton.set_DialogResult(get_DialogResult().OK);
        okButton.set_Text("OK");
        this.get_Controls().Add(okButton);
    } // ExampleForm
} // ExampleForm

// This control is associated with the IUIServiceTestDesigner, 
// and can be sited in design mode to use the sample.
/** @attribute DesignerAttribute(IUIServiceTestDesigner.class,
    IDesigner.class)
 */
public class IUIServiceExampleControl extends UserControl 
{
    public IUIServiceExampleControl()
    {
        this.set_BackColor(Color.get_Beige());
        this.set_Width(255);
        this.set_Height(60);
    } //IUIServiceExampleControl

    protected void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        if (this.get_DesignMode()){
            e.get_Graphics().DrawString("Right-click this control to " 
                + "display a list of the", new Font("Arial", 9),
                Brushes.get_Black(), 5, 6);
            e.get_Graphics().DrawString("designer verb menu commands provided",
                new Font("Arial", 9), Brushes.get_Black(), 5, 20);
            e.get_Graphics().DrawString("by the IUIServiceTestDesigner.",
                new Font("Arial", 9), Brushes.get_Black(), 5, 34);
        }
    } //OnPaint
} //IUIServiceExampleControl

플랫폼

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

IUIService 멤버
System.Windows.Forms.Design 네임스페이스