ThinkGeo.com    |     Documentation    |     Premium Support

Change style of control points for draggable, resizable and rotatable shapes

I've
downloaded the Dragged Point Style example. This sample contains the following
lines:


            dragInteractiveOverlay.CanAddVertex
= false;


            dragInteractiveOverlay.CanDrag = false;


           
dragInteractiveOverlay.CanRemoveVertex = false;


            dragInteractiveOverlay.CanResize = false;


            dragInteractiveOverlay.CanRotate = false;


 


I've
removed these, because in my case the user needs to be able to do all that. As
far as I can see everything is fine when it comes to adding and removing
vertices. However, removing the other three creates undesired behavior.


First of
all, the icons that normally indicate that the feature is draggable, resizable
and rotatable are no longer drawn. So my first question is:


How can I make sure that the relevant draggable,
resizable and rotatable icons are drawn?


Even though
the icons are not there, the functionality remains. However, if I drag, resize
or rotate a feature, the control points are not redrawn until the mouse button
is released. Every now and then this behavior also occurs when I drag a single
control point, rather than an entire feature. This last behavior does not occur
when the above given lines are in place.


So the
second question is:


How can I make sure that the control points are
drawn while I'm dragging, resizing, or rotating? 


Your help
will be much appreciated. 



Hi F5K 
  
 I think this issue expressed that there are not some control points style on sample’s “DragInteractiveOverlay”, this sample is a simple sample which is teach how to override a custom’s EditInteractiveOverlay, if you want to get a entire “EditInteractiveOverlay”, you should add some necessary “InMemoryFeatureLayer” to show control points such as resize, draggable, etc. 
 I advise to use “EditOverlay” on desktop map as following statements: 
  
 winformsMap1.TrackOverlay.TrackMode = TrackMode.None; 
 foreach (Feature feature in winformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures) 
 { 
 winformsMap1.EditOverlay.EditShapesLayer.InternalFeatures.Add(feature); 
 } 
 winformsMap1.EditOverlay.CalculateAllControlPoints(); 
 winformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures.Clear(); 
  
 winformsMap1.Refresh(new Overlay[] { winformsMap1.EditOverlay, winformsMap1.TrackOverlay }); 
  
 Thanks, 
  
 Summer 


I guess I should have been clearer. I want the full EditInteractiveOVerlay functionality, but in addition I want to override the appearance of some of the control points (depending on values in the feature’s ColumnValues). That’s why I used the Dragged Point Style example in the first place. 

Hi F5K, 
  
 Thanks for your further information, following code should be able to help you out, would you please try it?: 
  
         public DragInteractiveOverlay() 
         { 
             SetCustomStyle(); 
         } 
  
         private void SetCustomStyle() 
         {  
             DragControlPointsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = …; 
             RotateControlPointsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = …; 
             ResizeControlPointsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = …; 
         } 
 Thanks, 
  
 Summer

That's not
the solution I'm looking for, but it was helpful. Thank you for your efforts so
far.


My problem
with the DraggedPointStyle example is not that the DragControlPoints,
RotateControlPoints and ResizeControlPoints didn't look like I wanted them to
look, but that they weren't drawn, even though the functionality remained. 


Since you
pointed out the relevant layers to these ControlPoints I've added the following
to DrawCore.:


DragControlPointsLayer.Open();


DragControlPointsLayer.Draw(canvas,
labelsInAllLayers);


RotateControlPointsLayer.Open();


RotateControlPointsLayer.Draw(canvas,
labelsInAllLayers);


ResizeControlPointsLayer.Open();


ResizeControlPointsLayer.Draw(canvas,
labelsInAllLayers);


 


This solved
this first part of my question. 


But the
second problem still remains. If the user resizes, rotates or drags the feature
the ControlPoints of the ExistingControlPointsLayer are not redrawn until the
mouse button is released. I've included code for the DraggedPointStyle example
with my adjustments in place. 


If you replace the code in the relevant original files of the
example with the code included to this reply and run it, you will see that when
you drag a feature, the white squares don't properly follow the feature, until you
release the mouse button. 


How can I get rid of this ugly behavior?



DragInteractiveOverlay.cs (2.4 KB)

Hi F5K, 
  
 Thanks for your post, would you please add following code in your drawcore: 
  
 CalculateAllControlPoints(); 
 ExistingControlPointsLayer.IsVisible = true; 
  
 Now it should work. 
  
 Summer

It works! Thank you!

Hi F5K, 
  
 Great to hear it helped, if you have any more question, please feel free to let us know. 
  
 Best Regards 
  
 Summer

Thanks everyone for the help and the described solutions are still working (version 9.0).

But I have one more question:
Is it possbile to show the controls for resizing, rotating and dragging during the changing of the feature?

Currently - during the changing - the shape is drawn, the controls points are drawn (with a certain - awful looking - lag) but the controls are not visible.

Regards,
Peter

Hi Peter,

If the feature is changing, that means you are drag one control point and keep move, how could you operate other control points during this process?

Could you please give us more detail description about the scenario.

Regards,

Don

What I meant is, that while I’m moving, rotating or resizing a feature the shape itself and the control points are drawn, but the controls for resizing, rotating or moving are not visible. They reappear only after the end of the operation, i.e. the resizing.

Regards,
Peter

Hi Peter,

You can implement that like this:

Override the MouseMove event, call CalculateAllControlPoints(), then set these items:

DragControlPointsLayer.IsVisible = true;
RotateControlPointsLayer.IsVisible = true;
ResizeControlPointsLayer.IsVisible = true;
ExistingControlPointsLayer.IsVisible = true;

Wish that’s helpful.

Regards,

Don