Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Can I use FlipX and FlipY to implement mirroring? (Read 2649 times)
chowy
Junior Member
**
Offline


I Love MindFusion!

Posts: 72
Joined: May 8th, 2017
Can I use FlipX and FlipY to implement mirroring?
May 27th, 2017 at 8:33am
Print Post  
In Diagramming for WPF, version V3.4.3, I saw that "Enable the AllowFlip property and the shape flips when an edge is dragged over its opposite edge". but I now need to click directly through the button, and then achieve horizontal flip and vertical flip. Can I use FlipX and FlipY to achieve it?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3148
Joined: Oct 19th, 2005
Re: Can I use FlipX and FlipY to implement mirroring?
Reply #1 - May 28th, 2017 at 9:30am
Print Post  
Setting these properties is all the control does when it detects edge-over-edge drag, so you should be able to implement mirroring as well by setting them from other event handlers -

Code
Select All
void OnObjectFlipHorz(object sender, RoutedEventArgs e)
{
	var shapeNode = diagram.ActiveItem as ShapeNode;
	if (shapeNode != null)
		shapeNode.FlipX = !shapeNode.FlipX;
} 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
chowy
Junior Member
**
Offline


I Love MindFusion!

Posts: 72
Joined: May 8th, 2017
Re: Can I use FlipX and FlipY to implement mirroring?
Reply #2 - May 31st, 2017 at 3:39am
Print Post  
Slavcho wrote on May 28th, 2017 at 9:30am:
Setting these properties is all the control does when it detects edge-over-edge drag, so you should be able to implement mirroring as well by setting them from other event handlers -

Code
Select All
void OnObjectFlipHorz(object sender, RoutedEventArgs e)
{
	var shapeNode = diagram.ActiveItem as ShapeNode;
	if (shapeNode != null)
		shapeNode.FlipX = !shapeNode.FlipX;
} 



Regards,
Slavcho

In the button's click event,I wrote the code
Code
Select All
var shape = view.ActiveItem as ShapeNode;
If (shapeNode! = Null)
ShapeNode.FlipX =! ShapeNode.FlipX;
 


but it does not work, my node is derived from the shapenode,and I override from the draw method. Is there a problem with my draw method? For example, I have a straight draw method:
Code
Select All
public override void Draw(DrawingContext graphics, MindFusion.Diagramming.Wpf.RenderOptions options)
        {
            base.Draw(graphics, options);
            TranslateTransform translate = new TranslateTransform(-Bounds.X, -Bounds.Y);
            graphics.PushTransform(translate);
            if (this.IsMove)
            {
                Point oldPoint = translate.Transform(OldBounds.Location);
                TranslateTransform tanslate = new TranslateTransform(-oldPoint.X, -oldPoint.Y);
                StartPoint = tanslate.Transform(StartPoint);
                EndPoint = tanslate.Transform(EndPoint);
                StartPoint = PubTools.SnapPointConvert(StartPoint);
                EndPoint = PubTools.SnapPointConvert(EndPoint);
                Bounds = new Rect(PubTools.SnapPointConvert(Bounds.Location),
                    PubTools.SnapPointConvert(new Point(Bounds.Location.X + Bounds.Width, Bounds.Y + Bounds.Height)));
                OldBounds = Bounds;
                SetDisplayProperty();
            }
            if (IsStartCreate || IsComplete)
            {
                if (EndPoint == new Point(-1, -1) || StartPoint == new Point(-1, -1))
                {
                    return;
                }

                Point start_Point = StartPoint;
                Point end_Point = EndPoint;

                graphics.DrawLine(new Pen(Stroke, StrokeThickness), start_Point, end_Point);
            }
            graphics.Pop();

        }
 

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3148
Joined: Oct 19th, 2005
Re: Can I use FlipX and FlipY to implement mirroring?
Reply #3 - May 31st, 2017 at 5:15am
Print Post  
var shape = view.ActiveItem as ShapeNode;
If (shapeNode! = Null)

looks like you are comparing with a different variable than the one you assign selection to if that's your literal code (shape vs shapeNode). Also are you sure your base class is ShapeNode?

Regards,
Slavcho
  
Back to top
 
IP Logged
 
chowy
Junior Member
**
Offline


I Love MindFusion!

Posts: 72
Joined: May 8th, 2017
Re: Can I use FlipX and FlipY to implement mirroring?
Reply #4 - May 31st, 2017 at 5:53am
Print Post  
Slavcho wrote on May 31st, 2017 at 5:15am:
var shape = view.ActiveItem as ShapeNode;
If (shapeNode! = Null)

looks like you are comparing with a different variable than the one you assign selection to if that's your literal code (shape vs shapeNode). Also are you sure your base class is ShapeNode?

Regards,
Slavcho

Yes,I'm sure.But in my example startpoint and endpoint are not calculated by bounds.But in my example start point and end point, not calculated by bounds. They are derived from the StartCreate and CompleteCreate methods.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3148
Joined: Oct 19th, 2005
Re: Can I use FlipX and FlipY to implement mirroring?
Reply #5 - May 31st, 2017 at 6:25am
Print Post  
FlipX/Y only flip the shape's geometry, and not contained image and text if that's what you expect; you will see their effect only if the shape is not symmetric.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint