110,561
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Windows.Forms;
namespace eWhereThink.Workflow.Design
{
[Designer(typeof(DesignPanelDesigner), typeof(IRootDesigner))]
[Designer(typeof(ComponentDesigner))]
[ToolboxItem(false)]
public class DesignPanel : Component
{
public DesignPanel()
{
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel.Design;
using System.Drawing.Design;
using System.ComponentModel;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace eWhereThink.Workflow.Design
{
public class DesignPanelDesigner : ComponentDocumentDesigner, IRootDesigner
{
DesignControl _rootViewControl;
public DesignPanelDesigner()
{
}
public object GetView(ViewTechnology technology)
{
_rootViewControl = new DesignControl(this);
return _rootViewControl;
}
public ViewTechnology[] SupportedTechnologies
{
get
{
return new ViewTechnology[] { ViewTechnology.Default };
}
}
protected override bool GetToolSupported(ToolboxItem tool)
{
MessageBox.Show(tool.TypeName);
return true;
}
public void ToolPicked(ToolboxItem tool)
{
MessageBox.Show(tool.TypeName + " ToolPicked");
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
namespace eWhereThink.Workflow.Design
{
[ToolboxItem(false)]
public class DesignControl : ScrollableControl
{
private DesignPanelDesigner _rootDesigner;
private IContainer components;
private Hashtable _componentInfoTable;
public DesignControl(DesignPanelDesigner rootDesigner)
{
InitializeComponent();
_rootDesigner = rootDesigner;
_componentInfoTable = new Hashtable();
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.ResizeRedraw, true);
this.Invalidate();
}
private void InitializeComponent()
{
this.SuspendLayout();
//
// DesignControl
//
this.Paint += new System.Windows.Forms.PaintEventHandler(this.DesignControl_Paint);
this.ResumeLayout(false);
}
private void DesignControl_Paint(object sender, PaintEventArgs e)
{
float fZoom = 1F;
Size size = new Size();
size.Width = Math.Max(this.Width, this.AutoScrollMinSize.Width);
size.Height = Math.Max(this.Height, this.AutoScrollMinSize.Height);
Bitmap bmp = new Bitmap(size.Width, size.Height);
Graphics g = Graphics.FromImage(bmp);
Color selectColor = Color.FromArgb(102, 102, 255);
Brush selectBrush = new SolidBrush(selectColor);
try
{
g.SmoothingMode = SmoothingMode.HighQuality; //高质量
g.PixelOffsetMode = PixelOffsetMode.HighQuality; //高像素偏移质量
//画点
for (int iX = (int)(10 * fZoom); iX < bmp.Width; iX += (int)(10 * fZoom))
{
for (int iY = (int)(10 * fZoom); iY < bmp.Height; iY += (int)(10 * fZoom))
{
bmp.SetPixel(iX, iY, Color.Black);
}
}
e.Graphics.DrawImage(bmp, 0 - this.HorizontalScroll.Value, 0 - this.VerticalScroll.Value);
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
finally
{
selectBrush.Dispose();
g.Dispose();
bmp.Dispose();
}
}
}
}
DesignControl _rootViewControl;
IMenuCommandService mcs;
public DesignPanelDesigner()
{
_rootViewControl = new DesignControl(this);
_rootViewControl.MouseUp += new MouseEventHandler(_rootViewControl_MouseUp);
}
void _rootViewControl_MouseUp(object sender, MouseEventArgs e)
{
mcs = (IMenuCommandService)this.GetService(typeof(IMenuCommandService));
if (mcs != null)
{
Point screenCoordinates = this._rootViewControl.PointToScreen(e.Location);
mcs.ShowContextMenu(new CommandID(new Guid("94c4438f-fe64-47d6-a0d9-fdf468448fac"), 0x0001), screenCoordinates.X, screenCoordinates.Y);
}
}
<?xml version="1.0" encoding="utf-8"?>
<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" >
<Extern href="stdidcmd.h"/>
<Extern href="vsshlids.h"/>
<Extern href="msobtnid.h"/>
<Extern href="virtkeys.h"/>
<Commands package="guideWhereThink_Workflow_VS2008Pkg" >
<Menus>
<Menu guid="guideWhereThink_Workflow_VS2008CmdSet" id="IDM_CONTEXT" priority="0x0000" type="Context">
<Parent guid="guideWhereThink_Workflow_VS2008CmdSet" id="0"/>
<Strings>
<ButtonText>Workflow Designer</ButtonText>
<CommandName>Workflow Designer</CommandName>
</Strings>
</Menu>
</Menus>
<Groups>
<Group guid="guideWhereThink_Workflow_VS2008CmdSet" id="IDG_VIEWCODE" priority="0x0100">
<Parent guid="guideWhereThink_Workflow_VS2008CmdSet" id="IDM_CONTEXT"/>
</Group>
<Group guid="guideWhereThink_Workflow_VS2008CmdSet" id="IDG_CLIPBOARD" priority="0x0200">
<Parent guid="guideWhereThink_Workflow_VS2008CmdSet" id="IDM_CONTEXT"/>
</Group>
<Group guid="guideWhereThink_Workflow_VS2008CmdSet" id="IDG_PROPERTY" priority="0x0300">
<Parent guid="guideWhereThink_Workflow_VS2008CmdSet" id="IDM_CONTEXT"/>
</Group>
</Groups>
</Commands>
<CommandPlacements>
<CommandPlacement guid="guidVSStd97" id="cmdidViewCode" priority="0x0001">
<Parent guid="guidSHLMainMenu" id="IDG_VS_CODEWIN_LANGUAGE"/>
</CommandPlacement>
<CommandPlacement guid="guidVSStd97" id="cmdidViewCode" priority="0x0000">
<Parent guid="guideWhereThink_Workflow_VS2008CmdSet" id="IDG_VIEWCODE"/>
</CommandPlacement>
<CommandPlacement guid="guidVSStd97" id="cmdidCut" priority="0x0001">
<Parent guid="guideWhereThink_Workflow_VS2008CmdSet" id="IDG_CLIPBOARD"/>
</CommandPlacement>
<CommandPlacement guid="guidVSStd97" id="cmdidCopy" priority="0x0010">
<Parent guid="guideWhereThink_Workflow_VS2008CmdSet" id="IDG_CLIPBOARD"/>
</CommandPlacement>
<CommandPlacement guid="guidVSStd97" id="cmdidPaste" priority="0x0020">
<Parent guid="guideWhereThink_Workflow_VS2008CmdSet" id="IDG_CLIPBOARD"/>
</CommandPlacement>
<CommandPlacement guid="guidVSStd97" id="cmdidDelete" priority="0x0030">
<Parent guid="guideWhereThink_Workflow_VS2008CmdSet" id="IDG_CLIPBOARD"/>
</CommandPlacement>
<CommandPlacement guid="guidVSStd97" id="cmdidPropSheetOrProperties" priority="0x0001">
<Parent guid="guideWhereThink_Workflow_VS2008CmdSet" id="IDG_PROPERTY"/>
</CommandPlacement>
</CommandPlacements>
<UsedCommands>
<!-- CMDUSED_SECTION -->
<UsedCommand guid="guidVSStd97" id="cmdidCut"/>
<UsedCommand guid="guidVSStd97" id="cmdidCopy"/>
<UsedCommand guid="guidVSStd97" id="cmdidPaste"/>
<UsedCommand guid="guidVSStd97" id="cmdidDelete"/>
<UsedCommand guid="guidVSStd97" id="cmdidPropSheetOrProperties"/>
</UsedCommands>
<Symbols>
<GuidSymbol name="guideWhereThink_Workflow_VS2008Pkg" value="{9afe836b-48b9-4201-a7ab-7569bda7917b}"></GuidSymbol>
<GuidSymbol name="guideWhereThink_Workflow_VS2008CmdSet" value="{94c4438f-fe64-47d6-a0d9-fdf468448fac}">
<IDSymbol name="IDM_CONTEXT" value="0x0001"/>
<IDSymbol name="IDG_VIEWCODE" value="0x1000"/>
<IDSymbol name="IDG_CLIPBOARD" value="0x1001"/>
<IDSymbol name="IDG_PROPERTY" value="0x1002"/>
</GuidSymbol>
</Symbols>
</CommandTable>