Esta documentación está archivada y no tiene mantenimiento.

IUIService (Interfaz)

Actualización: noviembre 2007

Habilita la interacción con la interfaz de usuario del objeto del entorno de desarrollo que aloja el diseñador.

Espacio de nombres:  System.Windows.Forms.Design
Ensamblado:  System.Windows.Forms (en System.Windows.Forms.dll)

[GuidAttribute("06A9C74B-5E32-4561-BE73-381B37869F4F")]
public interface IUIService
/** @attribute GuidAttribute("06A9C74B-5E32-4561-BE73-381B37869F4F") */
public interface IUIService
public interface IUIService

IUIService puede mostrar mensajes de error y cuadros de diálogo, y obtener las propiedades de ambiente del host, como la fuente de los cuadros de diálogo y las combinaciones de colores, mediante la propiedad de diccionario Styles.

En el siguiente ejemplo de código se crea un diseñador que proporciona comandos de verbo del diseñador que llaman a los métodos de IUIService. Para utilizar el ejemplo, compile el código de ejemplo en un ensamblado y agregue una referencia al ensamblado en una aplicación de formularios Windows Forms. Si está utilizando Visual Studio, IUIServiceExampleControl se agrega automáticamente al Cuadro de herramientas. Agregue una instancia de IUIServiceExampleControl a Form. Para tener acceso a los comandos de verbos del diseñador que invocan métodos IUIService, haga clic con el botón secundario del mouse (ratón) en la superficie del control o haga clic en el glifo de la etiqueta inteligente del control y seleccione un elemento del panel de etiquetas inteligentes.

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);
        }
    }
}


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 Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

.NET Framework

Compatible con: 3.5, 3.0, 2.0, 1.1, 1.0
Mostrar: