本文整理汇总了C#中System.ComponentModel.Design.IRootDesigner接口的典型用法代码示例。如果您正苦于以下问题:C# IRootDesigner接口的具体用法?C# IRootDesigner怎么用?C# IRootDesigner使用的例子?那么恭喜您, 这里精选的接口代码示例或许可以为您提供帮助。
IRootDesigner接口属于System.ComponentModel.Design命名空间,在下文中一共展示了IRootDesigner接口的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RootViewSampleComponent
//引入命名空间
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace SampleRootDesigner
{
// This sample demonstrates how to provide the root designer view, or
// design mode background view, by overriding IRootDesigner.GetView().
// This sample component inherits from RootDesignedComponent which
// uses the SampleRootDesigner.
public class RootViewSampleComponent : RootDesignedComponent
{
public RootViewSampleComponent()
{
}
}
// The following attribute associates the SampleRootDesigner designer
// with the SampleComponent component.
[Designer(typeof(SampleRootDesigner), typeof(IRootDesigner))]
public class RootDesignedComponent : Component
{
public RootDesignedComponent()
{
}
}
public class SampleRootDesigner : ComponentDesigner, IRootDesigner
{
// Member field of custom type RootDesignerView, a control that
// will be shown in the Forms designer view. This member is
// cached to reduce processing needed to recreate the
// view control on each call to GetView().
private RootDesignerView m_view;
// This method returns an instance of the view for this root
// designer. The "view" is the user interface that is presented
// in a document window for the user to manipulate.
object IRootDesigner.GetView(ViewTechnology technology)
{
if (technology != ViewTechnology.Default)
{
throw new ArgumentException("Not a supported view technology", "technology");
}
if (m_view == null)
{
// Some type of displayable Form or control is required
// for a root designer that overrides GetView(). In this
// example, a Control of type RootDesignerView is used.
// Any class that inherits from Control will work.
m_view = new RootDesignerView(this);
}
return m_view;
}
// IRootDesigner.SupportedTechnologies is a required override for an
// IRootDesigner. Default is the view technology used by this designer.
ViewTechnology[] IRootDesigner.SupportedTechnologies
{
get
{
return new ViewTechnology[] {ViewTechnology.Default};
}
}
// RootDesignerView is a simple control that will be displayed
// in the designer window.
private class RootDesignerView : Control
{
private SampleRootDesigner m_designer;
public RootDesignerView(SampleRootDesigner designer)
{
m_designer = designer;
BackColor = Color.Blue;
Font = new Font(Font.FontFamily.Name, 24.0f);
}
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
// Draws the name of the component in large letters.
pe.Graphics.DrawString(m_designer.Component.Site.Name, Font, Brushes.Yellow, ClientRectangle);
}
}
}
}
开发者ID:.NET开发者,项目名称:System.ComponentModel.Design,代码行数:95,代码来源:IRootDesigner
注:本文中的System.ComponentModel.Design.IRootDesigner接口示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论