 |
|
 |
Hi,
I downloaded DotNetShapeConrol.
Is it allowed to use this for business?
I will not sell it or distribute it.
Could you please advise me?
Thanks,
|
|
|
|
 |
|
 |
...I mean, we have the code, the screenshot, but where's the text? Where are the highlights of your code, interesting snippets, intricacies you ran into etc..? CP is supposed to be a site where I can come and read/write articles, not a place for drive-by code uploads.
---
http://sprdsoft.cmar-net.org - We Sprd You Softly
Our site features contents and several images. All of this is very weird.
In the end, war is not about who's right, it's about who's left.
|
|
|
|
 |
|
 |
Do you have a solution how to resize and relocate shape control?
Thanks,
Jian
|
|
|
|
 |
|
 |
Well in Code it would look something like this.
csShape shp_Shape = new csShape();
shp_Shape.Location = new Point(Left, Top);
shp_Shape.Size = new Size(Width, Height);
Or do you mean If you Dragged and Dropped it on a control and now while in Run mode you want to click on the shape and be able to move it around your screen or Resize it. Moving it is relatively simple, resizing it is a little more complicated(in Run mode). If this is what you want I will Email you a Private message on how to implement that functionality.
|
|
|
|
 |
|
 |
Yes, I am looking forward to your private message.
Thanks,
Jian
|
|
|
|
 |
|
 |
Any questions on the code feel free to ask respectively. If it take a little while for me to get back to you be patient. I do not get on the internet at home.
|
|
|
|
 |
|
 |
could you please show me how to implement the drag and drop and resize the shape control in Run mode also? thank you very much
Jen
|
|
|
|
 |
|
 |
Here is some code from my own implementation of a shape. It should not be too hard to adapt this for this control.
protected Vector2d m_MouseOverflowRightDown;
protected Vector2d m_MouseOverflowLeftTop;
protected Vector2d m_MouseOverflowRightTop;
protected Vector2d m_MouseOverflowLeftBottom;
protected RectangleF m_LeftGrabPoint;
protected RectangleF m_TopGrabPoint;
protected RectangleF m_RightGrabPoint;
protected RectangleF m_BottomGrabPoint;
protected RectangleF m_LeftTopGrabPoint;
protected RectangleF m_RightTopGrabPoint;
protected RectangleF m_RightBottomGrabPoint;
protected RectangleF m_LeftBottomGrabPoint;
protected ResizeDirection m_ResizeDirection = ResizeDirection.None;
#region Start resizing
if (m_LeftGrabPoint.Contains(e.Location))
{
Cursor.Current = Cursors.SizeWE;
m_ResizeDirection = ResizeDirection.Left;
}
else if (m_LeftTopGrabPoint.Contains(e.Location))
{
Cursor.Current = Cursors.SizeNWSE;
m_ResizeDirection = ResizeDirection.LeftTop;
}
else if (m_TopGrabPoint.Contains(e.Location))
{
Cursor.Current = Cursors.SizeNS;
m_ResizeDirection = ResizeDirection.Top;
}
else if (m_RightTopGrabPoint.Contains(e.Location))
{
Cursor.Current = Cursors.SizeNESW;
m_ResizeDirection = ResizeDirection.RightTop;
}
else if (m_RightGrabPoint.Contains(e.Location))
{
Cursor.Current = Cursors.SizeWE;
m_ResizeDirection = ResizeDirection.Right;
}
else if (m_RightBottomGrabPoint.Contains(e.Location))
{
Cursor.Current = Cursors.SizeNWSE;
m_ResizeDirection = ResizeDirection.RightBottom;
}
else if (m_BottomGrabPoint.Contains(e.Location))
{
Cursor.Current = Cursors.SizeNS;
m_ResizeDirection = ResizeDirection.Bottom;
}
else if (m_LeftBottomGrabPoint.Contains(e.Location))
{
Cursor.Current = Cursors.SizeNESW;
m_ResizeDirection = ResizeDirection.LeftBottom;
}
else
{
Cursor.Current = Cursors.Default;
m_ResizeDirection = ResizeDirection.None;
}
#endregion
if (m_MouseDown &&
e.Button == MouseButtons.Left &&
m_ResizeDirection != ResizeDirection.None)
{
Resize(m_ResizeDirection, delta);
}
else if (Selected && m_ResizeDirection == ResizeDirection.None)
{
#region Indicate a possible resize
if (m_LeftGrabPoint.Contains(e.Location))
{
Cursor.Current = Cursors.SizeWE;
}
else if (m_LeftTopGrabPoint.Contains(e.Location))
{
Cursor.Current = Cursors.SizeNWSE;
}
else if (m_TopGrabPoint.Contains(e.Location))
{
Cursor.Current = Cursors.SizeNS;
}
else if (m_RightTopGrabPoint.Contains(e.Location))
{
Cursor.Current = Cursors.SizeNESW;
}
else if (m_RightGrabPoint.Contains(e.Location))
{
Cursor.Current = Cursors.SizeWE;
}
else if (m_RightBottomGrabPoint.Contains(e.Location))
{
Cursor.Current = Cursors.SizeNWSE;
}
else if (m_BottomGrabPoint.Contains(e.Location))
{
Cursor.Current = Cursors.SizeNS;
}
else if (m_LeftBottomGrabPoint.Contains(e.Location))
{
Cursor.Current = Cursors.SizeNESW;
}
else
{
Cursor.Current = Cursors.Default;
}
#endregion
}
m_ResizeDirection = ResizeDirection.None;
protected virtual void Resize(ResizeDirection direction, Vector2d delta)
{
RectangleF currentBounds = BorderBounds;
RectangleF newBounds = new RectangleF();
#region Resize
switch (direction)
{
case ResizeDirection.Left:
newBounds.X = currentBounds.X + (int)delta.X;
newBounds.Y = currentBounds.Y;
newBounds.Width = currentBounds.Width + (int)delta.X * (-1);
newBounds.Height = currentBounds.Height;
break;
case ResizeDirection.Top:
newBounds.X = currentBounds.X;
newBounds.Y = currentBounds.Y + (int)delta.Y;
newBounds.Width = currentBounds.Width;
newBounds.Height = currentBounds.Height + (int)delta.Y * (-1);
break;
case ResizeDirection.Right:
newBounds.X = currentBounds.X;
newBounds.Y = currentBounds.Y;
newBounds.Width = currentBounds.Width + (int)delta.X;
newBounds.Height = currentBounds.Height;
break;
case ResizeDirection.Bottom:
newBounds.X = currentBounds.X;
newBounds.Y = currentBounds.Y;
newBounds.Width = currentBounds.Width;
newBounds.Height = currentBounds.Height + (int)delta.Y;
break;
case ResizeDirection.LeftTop:
newBounds.X = currentBounds.X + (int)delta.X;
newBounds.Y = currentBounds.Y;
newBounds.Width = currentBounds.Width + (int)delta.X * (-1);
newBounds.Height = currentBounds.Height;
newBounds.X = newBounds.X;
newBounds.Y = newBounds.Y + (int)delta.Y;
newBounds.Width = newBounds.Width;
newBounds.Height = newBounds.Height + (int)delta.Y * (-1);
break;
case ResizeDirection.RightTop:
newBounds.X = currentBounds.X;
newBounds.Y = currentBounds.Y;
newBounds.Width = currentBounds.Width + (int)delta.X;
newBounds.Height = currentBounds.Height;
newBounds.X = newBounds.X;
newBounds.Y = newBounds.Y + (int)delta.Y;
newBounds.Width = newBounds.Width;
newBounds.Height = newBounds.Height + (int)delta.Y * (-1);
break;
case ResizeDirection.RightBottom:
newBounds.X = currentBounds.X;
newBounds.Y = currentBounds.Y;
newBounds.Width = currentBounds.Width + (int)delta.X;
newBounds.Height = currentBounds.Height;
newBounds.X = newBounds.X;
newBounds.Y = newBounds.Y;
newBounds.Width = newBounds.Width;
newBounds.Height = newBounds.Height + (int)delta.Y;
break;
case ResizeDirection.LeftBottom:
newBounds.X = currentBounds.X + (int)delta.X;
newBounds.Y = currentBounds.Y;
newBounds.Width = currentBounds.Width + (int)delta.X * (-1);
newBounds.Height = currentBounds.Height;
newBounds.X = newBounds.X;
newBounds.Y = newBounds.Y;
newBounds.Width = newBounds.Width;
newBounds.Height = newBounds.Height + (int)delta.Y;
break;
case ResizeDirection.None:
default:
break;
}
#endregion
#region Handle mouse overflow
float x = BorderBounds.X;
float y = BorderBounds.Y;
float w = BorderBounds.Width;
float h = BorderBounds.Height;
if (m_ResizeDirection == ResizeDirection.Right ||
m_ResizeDirection == ResizeDirection.Bottom ||
m_ResizeDirection == ResizeDirection.RightBottom)
{
if (newBounds.Size.Width >= MinSize.Width && m_MouseOverflowRightDown.X >= 0)
w = newBounds.Width;
else
m_MouseOverflowRightDown.X += delta.X;
if (newBounds.Size.Height >= MinSize.Height && m_MouseOverflowRightDown.Y >= 0)
h = newBounds.Height;
else
m_MouseOverflowRightDown.Y += delta.Y;
}
if (m_ResizeDirection == ResizeDirection.Left ||
m_ResizeDirection == ResizeDirection.Top ||
m_ResizeDirection == ResizeDirection.LeftTop)
{
if (newBounds.Size.Width >= MinSize.Width && m_MouseOverflowLeftTop.X <= 0)
{
x = newBounds.X;
w = newBounds.Width;
}
else
m_MouseOverflowLeftTop.X += delta.X;
if (newBounds.Size.Height >= MinSize.Height && m_MouseOverflowLeftTop.Y <= 0)
{
y = newBounds.Y;
h = newBounds.Height;
}
else
m_MouseOverflowLeftTop.Y += delta.Y;
}
if (m_ResizeDirection == ResizeDirection.LeftBottom)
{
if (newBounds.Size.Width >= MinSize.Width && m_MouseOverflowLeftBottom.X <= 0)
{
x = newBounds.X;
w = newBounds.Width;
}
else
m_MouseOverflowLeftBottom.X += delta.X;
if (newBounds.Size.Height >= MinSize.Height && m_MouseOverflowLeftBottom.Y >= 0)
{
y = newBounds.Y;
h = newBounds.Height;
}
else
m_MouseOverflowLeftBottom.Y += delta.Y;
}
if (m_ResizeDirection == ResizeDirection.RightTop)
{
if (newBounds.Size.Width >= MinSize.Width && m_MouseOverflowRightTop.X >= 0)
{
w = newBounds.Width;
}
else
m_MouseOverflowRightTop.X += delta.X;
if (newBounds.Size.Height >= MinSize.Height && m_MouseOverflowRightTop.Y <= 0)
{
y = newBounds.Y;
h = newBounds.Height;
}
else
m_MouseOverflowRightTop.Y += delta.Y;
}
#endregion
}
[Flags()]
public enum ResizeDirection : byte
{
The vector class is not really nessecary in this case but i was too lazy to replace it with Point-structures for example.
|
|
|
|
 |
|
 |
Hi,
What is the rectangle got rotated?
Thanks
Daniel
|
|
|
|
 |
|
 |
If I need to add a connector between 2 shapes, what's your solution?
Thanks,
Jian
|
|
|
|
 |
|
 |
Exactly what do you mean by Add a Connector between two shapes.
|
|
|
|
 |
|
 |
For instance, I use shapes to make a flowchart or workflow. The two shapes are required to make a connection. How do I build a shape as connection or connector?
Thanks,
Jian
|
|
|
|
 |
|
 |
I think that I get the gist of your question. As in you want to be able to click on two different shapes and that make a connection and possible draw a line between the two. That can get pretty in depth. I am currently working on a patented application tha implements that functionality now. Only using drag and drop objects to write a code sequence. Flow chart functionality implemented. Like I said if that is what you mean that can get in depth with changes to both the shape control and the screen in which you are dropping the control. If this is what you mean let me know and I will tell you how I did it. Might now be the best way to do it, but it works like a charm for me.
|
|
|
|
 |
|
 |
Plus I have revamped the Shape control to implement this functionality. So giving you some hints will be no problem.
|
|
|
|
 |
|
 |
Actually a connector is a line in the simplest case. Sometimes it is multi-line depending on the location and space.
Thanks,
Jian
|
|
|
|
 |
|
 |
Well connector I think same like drawing line.
But I have question how to select two shape so it can be drag and drop at same time????
This make me confuse....
Thanks...
|
|
|
|
 |
|
 |
First you need to set a mode, letting your app know that you are in selection mode. Then you need to select eact object. When the second object is selected, you would automatically connect objects
for instance Seudo code for Control_MouseDown event.
if Connect mode is on
if first object is not selected
select first object
else
select second object
create connection object between selected objects
deselect objects so we can make more selections
else
highlight selected object
"All of us who served in one war or another know very well that all wars are the glory and the agony of the young."
Gerald Ford
|
|
|
|
 |