Hi All,
This gives you the basics for providing selection handles for a GoRectangle. It isn’t clear if your samples above are “zoomed in” or not, but the code below only starts to look like yours when you zoom in (and the dashes show up).
So, you may want to change the PenWidth and DashStyle of the handles, and you may want to play with the width (pw) that I’m offsetting the handles.
// class provides a rectangle with a selection highlight of an inner and outer red dotted line.
<br /> // provided for http://www.nwoods.com/forum/forum_posts.asp?TID=3392
<br /> [Serializable]
<br /> class RectangleSpecialSelection : GoRectangle {
<br />
<br /> public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj) {
<br /> RemoveSelectionHandles(sel);
<br /> if (!CanResize()) {
<br /> Pen p = new System.Drawing.Pen(Color.Red);
<br /> p.DashStyle = DashStyle.Dash;
<br />
<br /> float pw = 1;
<br /> GoShape selectedShape = selectedObj as GoShape;
<br /> if (selectedShape != null) pw = selectedShape.PenWidth;
<br /> if (pw > 2) pw = pw / 2;
<br />
<br /> // Outside selection rect
<br /> IGoHandle h1 = sel.CreateBoundingHandle(this, selectedObj);
<br /> GoShape h1s = h1.GoObject as GoShape;
<br /> if (h1s != null) {
<br /> h1s.Pen = p;
<br /> h1s.Bounds = new RectangleF(selectedObj.Position.X - pw , selectedObj.Position.Y - pw , selectedObj.Width + pw * 2, selectedObj.Height + pw * 2);
<br /> }
<br />
<br /> // Inside selection rect
<br /> IGoHandle h2 = sel.CreateBoundingHandle(this, selectedObj);
<br /> GoShape h2s = h2.GoObject as GoShape;
<br /> if (h2s != null) {
<br /> h2s.Pen = p;
<br /> h2s.Bounds = new RectangleF(selectedObj.Position.X + pw, selectedObj.Position.Y + pw, selectedObj.Width - pw * 2, selectedObj.Height - pw * 2);
<br /> }
<br />
<br /> }
<br /> else {
<br /> base.AddSelectionHandles(sel, selectedObj);
<br /> }
<br /> }
<br /> }
<br />
<br />
Looks like this when zoomed in:
Hi Jake,
The GoGroup is 2 separate GoStrokes?
try this.
<br /> [Serializable]
<br /> class SpecialPathSelection : GoGroup {
<br />
<br /> public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj) {
<br /> Pen p = new System.Drawing.Pen(Color.Red);
<br /> p.DashStyle = DashStyle.Dash;
<br /> p.Width = 8;
<br />
<br /> foreach (GoObject o in this) {
<br /> GoStroke s = o as GoStroke;
<br /> if (s != null) {
<br /> s.SkipsUndoManager = true;
<br /> s.Highlight = true;
<br /> s.HighlightPen = p;
<br /> s.SkipsUndoManager = false;
<br /> }
<br /> }
<br /> }
<br />
<br /> public override void RemoveSelectionHandles(GoSelection sel) {
<br /> foreach (GoObject o in this) {
<br /> GoStroke s = o as GoStroke;
<br /> if (s != null) {
<br /> s.SkipsUndoManager = true;
<br /> s.Highlight = false;
<br /> s.HighlightPen = null;
<br /> s.SkipsUndoManager = false;
<br /> }
<br /> }
<br /> }
<br /> }
<br />
Hi Jake,
Sorry for late reply.
Before I write anymore code you don’t need, maybe you could tell me more about what kind of GoDrawing objects you are using. Can there be a circle? What do you want the selection for that to look like?
Hi Jake,
The object will be of Line shape.It can be a straight line or a group of 2 lines in L shape only.
OK, one approach would be to override CreateBoundingHandle on your Line shape, and create a derived GoHandle that overrides MakePath (see DrawDemo for samples). Also override Paint with
public override void Paint(Graphics g, GoView view) {
PaintPath(g, view, GetPath());
}
(GoHandle also overrides Paint, but not in a way that helps you here.)
And you still need to do “AddSelectionHandles” like the first sample code above, but without setting the Pen and Bounds of the new handle.