- Welcome, Guest. Please Login or Register
MindFusion  
  We have released initial version of MindFusion.Scheduling library for HTML5 & JavaScript.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
Some troubles migrating form v3.3 to 3.5
Read 103 times

PDM   Offline
Full Member
***
Posts: 230
I love YaBB 1G - SP1!


   
     
 
Some troubles migrating form v3.3 to 3.5
Oct 8th, 2018 at 1:26am
 
Hello!!
Im back, hoppe Stoyo and Slavcho remember to me lol Smiley
Here some troubles:

  protected override InteractionState StartDrawCommon(Point point, MindFusion.Diagramming.Wpf.MouseButton button)
     {
           var state = base.StartDrawCommon(point, button);
                Resizing = state != null &&
                    state.Action == MindFusion.Diagramming.Wpf.Action.Modify && state.AdjustmentHandle < 8;
           return state;
     }

Operator '<' cannot be applied to operands of type 'AdjustmentHandle' and 'int'


private void form_HitTestAdjustmentHandles(object sender, HitTestEventArgs e)
   {


   

       var node = e.Item as DiagramNode;
       var size = new Size(20, 20);

       Rect r = e.Item.GetBounds();
       if (r.Contains(e.MousePosition))
          e.HitResult = 8;   //error here


    

       if (node != null)
       {
           var x = e.MousePosition.X;
           var y = e.MousePosition.Y;
           var location = node.Bounds.Location;
           var diagOffset = new Vector(location.X, location.Y);

           double rotationAngle = node.RotationAngle;
           Point localPoint = RotatePointAt(e.MousePosition, node.GetCenter(), -rotationAngle);

           if (r.Contains(localPoint))
              e.HitResult = 8;   //error here

           localPoint = localPoint - diagOffset;
           for (int i = 0; i < 8; i++)
           {
               var point = CustomHandlePosition(i, node.Bounds, size);
               var rect = new Rect(point, size);
               if (rect.Contains(localPoint))
               {
                   e.HitResult = i;  //error here

                   var std = StdHandlePosition(i, node.Bounds);
                   MyBehavior.MouseDX = std.X - localPoint.X;
                   MyBehavior.MouseDY = std.Y - localPoint.Y;

                   break;
               }
           }
       }
   }

Cannot implicitly convert type 'int' to 'MindFusion.Diagramming.Wpf.AdjustmentHandle'      


I testing with the trial version.
How much cost update?



 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1529
Gender: male
tech.support


   
     
 
Re: Some troubles migrating form v3.3 to 3.5
Reply #1 - Oct 8th, 2018 at 10:29am
 
Pablo, that you? Tongue Adjustment handles are now represented using classes and enums instead of integer values. Try this for the StartDrawCommon override -

Code:
protected override InteractionState StartDrawCommon(Point point, MouseButton button)
{
	var state = base.StartDrawCommon(point, button);
	Resizing =
		state != null && state.Action == Action.Modify &&
		!state.AdjustmentHandle.IsMoveHandle();
	return state;
} 



Code:
e.HitResult = NodeAdjustmentHandle.Move;
//instead of e.HitResult = 8
 



Try replacing the i < 8 loop with this one -
Code:
foreach (NodeHandleType handleType in Enum.GetValues(typeof(NodeHandleType)))

//and then

e.HitResult = new NodeAdjustmentHandle(handleType);
 



Also replace parameters of your CustomHandlePosition and StdHandlePosition functions with NodeHandleType instead of int.

Regards,
Slavcho
 
 
 
IP Logged    
 
     

PDM   Offline
Full Member
***
Posts: 230
I love YaBB 1G - SP1!


   
     
 
Re: Some troubles migrating form v3.3 to 3.5
Reply #2 - Oct 8th, 2018 at 12:00pm
 
Yes its me, and I can prove, Im lost with the loop part and after.  Cheesy

Code:
  private void form_HitTestAdjustmentHandles(object sender, HitTestEventArgs e)
   {
       var node = e.Item as DiagramNode;
       var size = new Size(20, 20);

       Rect r = e.Item.GetBounds();
       if (r.Contains(e.MousePosition))
                e.HitResult = NodeAdjustmentHandle.Move;

            if (node != null)
       {
           var x = e.MousePosition.X;
           var y = e.MousePosition.Y;
           var location = node.Bounds.Location;
           var diagOffset = new Vector(location.X, location.Y);

           double rotationAngle = node.RotationAngle;
           Point localPoint = RotatePointAt(e.MousePosition, node.GetCenter(), -rotationAngle);

           if (r.Contains(localPoint))
                    e.HitResult = NodeAdjustmentHandle.Move;

                localPoint = localPoint - diagOffset;
           for (int i = 0; i < 8; i++)
           {
               var point = CustomHandlePosition(i, node.Bounds, size);
               var rect = new Rect(point, size);
               if (rect.Contains(localPoint))
               {
                   e.HitResult = i;

                   var std = StdHandlePosition(i, node.Bounds);
                   MyBehavior.MouseDX = std.X - localPoint.X;
                   MyBehavior.MouseDY = std.Y - localPoint.Y;

                   break;
               }
           }
       }
   }

   Point CustomHandlePosition(int handleId, Rect nodeBounds, Size size)
   {
       if (handleId == 0)
           return new Point(0, 0);

       if (handleId == 4)
           return new Point(nodeBounds.Width / 2 - size.Width / 2, 0);

       if (handleId == 1)
           return new Point(nodeBounds.Width - size.Width, 0);

       if (handleId == 7)
           return new Point(0, nodeBounds.Height / 2 - size.Height / 2);

       if (handleId == 5)
           return new Point(nodeBounds.Width - size.Width, nodeBounds.Height / 2 - size.Height / 2);

       if (handleId == 3)
           return new Point(0, nodeBounds.Height - size.Height);

       if (handleId == 6)
           return new Point(nodeBounds.Width / 2 - size.Width / 2, nodeBounds.Height - size.Height);

       if (handleId == 2)
           return new Point(nodeBounds.Width - size.Width, nodeBounds.Height - size.Height);

       return new Point();
   }

   Point StdHandlePosition(int handleId, Rect nodeBounds)
   {
       if (handleId == 0)
           return new Point(0, 0);

       if (handleId == 4)
           return new Point(nodeBounds.Width / 2, 0);

       if (handleId == 1)
           return new Point(nodeBounds.Width, 0);

       if (handleId == 7)
           return new Point(0, nodeBounds.Height / 2);

       if (handleId == 5)
           return new Point(nodeBounds.Width, nodeBounds.Height / 2);

       if (handleId == 3)
           return new Point(0, nodeBounds.Height);

       if (handleId == 6)
           return new Point(nodeBounds.Width / 2, nodeBounds.Height);

       if (handleId == 2)
           return new Point(nodeBounds.Width, nodeBounds.Height);

       return new Point();
   }


   void form_DrawAdjustmentHandles(object sender, DrawItemEventArgs e)
   {
       var node = e.Item as DiagramNode;
       var size2 = new Size(form.AdjustmentHandlesSize, form.AdjustmentHandlesSize);
       var size = new Size(handlersize, handlersize);


       if (node != null)
       {

           var TopLeft = new Point(0, 0);
           e.Graphics.DrawRectangle(form.SelectedItemHandlesStyle.PatternBrush, form.SelectedItemHandlesStyle.DashPen, new Rect(TopLeft, size));


           var TopMiddle = new Point(node.Bounds.Width / 2 - size.Width / 2, 0);
           e.Graphics.DrawRectangle(form.SelectedItemHandlesStyle.PatternBrush, form.SelectedItemHandlesStyle.DashPen, new Rect(TopMiddle, size));

           var TopRight = new Point(node.Bounds.Width - size.Width, 0);
           e.Graphics.DrawRectangle(form.SelectedItemHandlesStyle.PatternBrush, form.SelectedItemHandlesStyle.DashPen, new Rect(TopRight, size));


           var MiddleTop = new Point(0, node.Bounds.Height / 2 - size.Height / 2);
           e.Graphics.DrawRectangle(form.SelectedItemHandlesStyle.PatternBrush, form.SelectedItemHandlesStyle.DashPen, new Rect(MiddleTop, size));

           var MiddleBott = new Point(node.Bounds.Width - size.Width, node.Bounds.Height / 2 - size.Height / 2);
           e.Graphics.DrawRectangle(form.SelectedItemHandlesStyle.PatternBrush, form.SelectedItemHandlesStyle.DashPen, new Rect(MiddleBott, size));

           var bottomLeft = new Point(0, node.Bounds.Height - size.Height);
           e.Graphics.DrawRectangle(form.SelectedItemHandlesStyle.PatternBrush, form.SelectedItemHandlesStyle.DashPen, new Rect(bottomLeft, size));


           var bottomMiddle = new Point(node.Bounds.Width / 2 - size.Width / 2, node.Bounds.Height - size.Height);
           e.Graphics.DrawRectangle(form.SelectedItemHandlesStyle.PatternBrush, form.SelectedItemHandlesStyle.DashPen, new Rect(bottomMiddle, size));

           var bottomRight = new Point(node.Bounds.Width - size.Width, node.Bounds.Height - size.Height);
           e.Graphics.DrawRectangle(form.SelectedItemHandlesStyle.PatternBrush, form.SelectedItemHandlesStyle.DashPen, new Rect(bottomRight, size));


       }
   }

   Point RotatePointAt(Point point, Point pivot, double angle)
   {

       Matrix rotation = new Matrix();
       rotation.RotateAt(angle, pivot.X, pivot.Y);
       Point res = rotation.Transform(point);
       return res;
   }


 




I sent a private message later Smiley
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1529
Gender: male
tech.support


   
     
 
Re: Some troubles migrating form v3.3 to 3.5
Reply #3 - Oct 9th, 2018 at 11:47am
 
So change your methods to

Code:
Point CustomHandlePosition(NodeHandleType handleId, Rect nodeBounds, Size size)
{
	if (handleId == NodeHandleType.ResizeTopLeft)
		return new Point(0, 0);

	if (handleId == NodeHandleType.ResizeTopCenter)
		return new Point(nodeBounds.Width / 2 - size.Width / 2, 0);

	if (handleId == NodeHandleType.ResizeTopRight)
		return new Point(nodeBounds.Width - size.Width, 0);

	if (handleId == NodeHandleType.ResizeMiddleLeft)
		return new Point(0, nodeBounds.Height / 2 - size.Height / 2);

	if (handleId == NodeHandleType.ResizeMiddleRight)
		return new Point(nodeBounds.Width - size.Width, nodeBounds.Height / 2 - size.Height / 2);

	if (handleId == NodeHandleType.ResizeBottomLeft)
		return new Point(0, nodeBounds.Height - size.Height);

	if (handleId == NodeHandleType.ResizeBottomCenter)
		return new Point(nodeBounds.Width / 2 - size.Width / 2, nodeBounds.Height - size.Height);

	if (handleId == NodeHandleType.ResizeBottomRight)
		return new Point(nodeBounds.Width - size.Width, nodeBounds.Height - size.Height);

	return new Point();
}

Point StdHandlePosition(NodeHandleType handleId, Rect nodeBounds)
{
	if (handleId == NodeHandleType.ResizeTopLeft)
		return new Point(0, 0);

	if (handleId == NodeHandleType.ResizeTopCenter)
		return new Point(nodeBounds.Width / 2, 0);

	if (handleId == NodeHandleType.ResizeTopRight)
		return new Point(nodeBounds.Width, 0);

	if (handleId == NodeHandleType.ResizeMiddleLeft)
		return new Point(0, nodeBounds.Height / 2);

	if (handleId == NodeHandleType.ResizeMiddleRight)
		return new Point(nodeBounds.Width, nodeBounds.Height / 2);

	if (handleId == NodeHandleType.ResizeBottomLeft)
		return new Point(0, nodeBounds.Height);

	if (handleId == NodeHandleType.ResizeBottomCenter)
		return new Point(nodeBounds.Width / 2, nodeBounds.Height);

	if (handleId == NodeHandleType.ResizeBottomRight)
		return new Point(nodeBounds.Width, nodeBounds.Height);

	return new Point();
} 



and the loop becomes

Code:
foreach (NodeHandleType handleType in Enum.GetValues(typeof(NodeHandleType)))
{
	var point = CustomHandlePosition(handleType, node.Bounds, size);
	var rect = new Rect(point, size);
	if (rect.Contains(localPoint))
	{
		e.HitResult = new NodeAdjustmentHandle(handleType);

		var std = StdHandlePosition(handleType, node.Bounds);
		MyBehavior.MouseDX = std.X - localPoint.X;
		MyBehavior.MouseDY = std.Y - localPoint.Y;

		break;
	}
} 



Regards,
Slavcho
 
 
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print