Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Data;
using System.Drawing;
using System.Drawing.Design;
using System.Data;
using System.Windows.Forms;

namespace BitmapEditorExample
{
public class UserControl1 : System.Windows.Forms.UserControl
{
private System.ComponentModel.Container components = null;
public class UserControl1 : System.Windows.Forms.UserControl
{
private System.ComponentModel.Container components = null;

//<Snippet1>
[EditorAttribute(typeof(System.Drawing.Design.BitmapEditor),
Expand All @@ -31,20 +31,20 @@ public Bitmap testBitmap
private Bitmap testBmp;
//</Snippet1>

public UserControl1()
{
InitializeComponent();
}
public UserControl1()
{
InitializeComponent();
}

#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Data;
using System.Drawing;
using System.Drawing.Design;
using System.Data;
using System.Windows.Forms;

namespace ToolboxCategoryNamesControl
{
public class ToolboxCategoryNamesControl : System.Windows.Forms.UserControl
{
{
private System.Drawing.Design.IToolboxService toolboxService;
private System.Drawing.Design.CategoryNameCollection categoryNames;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace PropertyValueUIServiceExample
// This component obtains the IPropertyValueUIService and adds a
// PropertyValueUIHandler that provides PropertyValueUIItem objects,
// which provide an image, ToolTip, and invoke event handler to
// any properties named HorizontalMargin and VerticalMargin,
// such as the example integer properties on this component.
// any properties named HorizontalMargin and VerticalMargin,
// such as the example integer properties on this component.
public class PropertyUIComponent : System.ComponentModel.Component
{
// Example property for which to provide a PropertyValueUIItem.
Expand All @@ -22,14 +22,10 @@ public class PropertyUIComponent : System.ComponentModel.Component
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int VerticalMargin { get; set; }

// Field storing the value of the VerticalMargin property.
private int vMargin;

// Constructor.
public PropertyUIComponent(System.ComponentModel.IContainer container)
{
if (container != null)
container.Add(this);
container?.Add(this);
HorizontalMargin = 0;
VerticalMargin = 0;
}
Expand All @@ -48,10 +44,10 @@ private void marginPropertyValueUIHandler(
{
// A PropertyValueUIHandler added to the IPropertyValueUIService
// is queried once for each property of a component and passed
// a PropertyDescriptor that represents the characteristics of
// the property when the Properties window is set to a new
// component. A PropertyValueUIHandler can determine whether
// to add a PropertyValueUIItem for the object to its ValueUIItem
// a PropertyDescriptor that represents the characteristics of
// the property when the Properties window is set to a new
// component. A PropertyValueUIHandler can determine whether
// to add a PropertyValueUIItem for the object to its ValueUIItem
// list depending on the values of the PropertyDescriptor.
if (propDesc.DisplayName.Equals("HorizontalMargin"))
{
Expand All @@ -67,15 +63,15 @@ private void marginPropertyValueUIHandler(
}
//</Snippet2>

// Invoke handler associated with the PropertyValueUIItem objects
// Invoke handler associated with the PropertyValueUIItem objects
// provided by the marginPropertyValueUIHandler.
private void marginInvoke(System.ComponentModel.ITypeDescriptorContext context, System.ComponentModel.PropertyDescriptor propDesc, PropertyValueUIItem item)
{
MessageBox.Show("Test invoke message box");
}

// Component.Site override to add the marginPropertyValueUIHandler
// when the component is sited, and to remove it when the site is
// when the component is sited, and to remove it when the site is
// set to null.
public override System.ComponentModel.ISite Site
{
Expand All @@ -89,14 +85,12 @@ public override System.ComponentModel.ISite Site
{
base.Site = value;
IPropertyValueUIService uiService = (IPropertyValueUIService)this.GetService(typeof(IPropertyValueUIService));
if (uiService != null)
uiService.AddPropertyValueUIHandler(new PropertyValueUIHandler(this.marginPropertyValueUIHandler));
uiService?.AddPropertyValueUIHandler(new PropertyValueUIHandler(this.marginPropertyValueUIHandler));
}
else
{
IPropertyValueUIService uiService = (IPropertyValueUIService)this.GetService(typeof(IPropertyValueUIService));
if (uiService != null)
uiService.RemovePropertyValueUIHandler(new PropertyValueUIHandler(this.marginPropertyValueUIHandler));
uiService?.RemovePropertyValueUIHandler(new PropertyValueUIHandler(this.marginPropertyValueUIHandler));
base.Site = value;
}
}
Expand Down
Loading
Loading