Beispiel #1
0
        public void TestBug6614()
        {
            MockShowAnglesTool mockOwnerTool = new MockShowAnglesTool();

            using (MockPresentationImage image = new MockPresentationImage(1000, 1000))
            {
                ShowAnglesTool.ShowAnglesToolCompositeGraphic composite = new ShowAnglesTool.ShowAnglesToolCompositeGraphic(mockOwnerTool);
                image.OverlayGraphics.Add(composite);

                PolylineGraphic line1 = new PolylineGraphic();
                line1.Points.Add(new PointF(274.983246f, 483.976f));
                line1.Points.Add(new PointF(674.3086f, 490.196f));
                VerticesControlGraphic control1 = new VerticesControlGraphic(line1);
                image.OverlayGraphics.Add(control1);
                composite.Select(control1);
                composite.OnDrawing();

                using (IPresentationImage clone = image.Clone())
                {
                    var cloneComposite = FindShowAnglesToolComposite(clone);
                    var cloneAngles    = FindShowAnglesTool(cloneComposite.Graphics);

                    if (cloneAngles != null)
                    {
                        foreach (ICalloutGraphic calloutGraphic in cloneAngles.Graphics.Where(IsOfType <ICalloutGraphic>))
                        {
                            if (calloutGraphic.Visible)
                            {
                                Assert.AreNotEqual(string.Format(SR.ToolsMeasurementFormatDegrees, 0), calloutGraphic.Text, "ShowAnglesToolGraphic should not have spurious 0.0 degree callout with only one line.");
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public void TestCloningShowAnglesToolCompositeGraphicVisibility()
        {
            MockShowAnglesTool mockOwnerTool = new MockShowAnglesTool();

            using (MockPresentationImage image = new MockPresentationImage(100, 100))
            {
                ShowAnglesTool.ShowAnglesToolCompositeGraphic composite = new ShowAnglesTool.ShowAnglesToolCompositeGraphic(mockOwnerTool);
                image.OverlayGraphics.Add(composite);

                PolylineGraphic line1 = new PolylineGraphic();
                line1.Points.Add(new PointF(0, 0));
                line1.Points.Add(new PointF(10, 10));
                VerticesControlGraphic control1 = new VerticesControlGraphic(line1);
                image.OverlayGraphics.Add(control1);
                composite.Select(control1);
                composite.OnDrawing();

                PolylineGraphic line2 = new PolylineGraphic();
                line2.Points.Add(new PointF(0, 10));
                line2.Points.Add(new PointF(10, 0));
                VerticesControlGraphic control2 = new VerticesControlGraphic(line2);
                image.OverlayGraphics.Add(control2);
                composite.Select(control2);
                composite.OnDrawing();

                mockOwnerTool.ShowAngles = true;
                composite.OnDrawing();

                using (IPresentationImage clone = image.Clone())
                {
                    var cloneComposite = FindShowAnglesToolComposite(clone);
                    Assert.IsTrue(cloneComposite.Visible, "Cloned ShowAnglesToolCompositeGraphic should retain visibility state when captured (true).");
                    mockOwnerTool.ShowAngles = false;
                    composite.OnDrawing();
                    Assert.IsTrue(cloneComposite.Visible, "Cloned ShowAnglesToolCompositeGraphic should retain visibility state when captured (true) even when the original changes.");
                }

                mockOwnerTool.ShowAngles = false;
                composite.OnDrawing();

                using (IPresentationImage clone = image.Clone())
                {
                    var cloneComposite = FindShowAnglesToolComposite(clone);
                    Assert.IsFalse(cloneComposite.Visible, "Cloned ShowAnglesToolCompositeGraphic should retain visibility state when captured (false).");
                    mockOwnerTool.ShowAngles = true;
                    composite.OnDrawing();
                    Assert.IsFalse(cloneComposite.Visible, "Cloned ShowAnglesToolCompositeGraphic should retain visibility state when captured (false) even when the original changes.");
                }
            }
        }
Beispiel #3
0
        public void TestCloningShowAnglesToolCompositeGraphicLineSelection()
        {
            MockShowAnglesTool mockOwnerTool = new MockShowAnglesTool();

            using (MockPresentationImage image = new MockPresentationImage(100, 100))
            {
                ShowAnglesTool.ShowAnglesToolCompositeGraphic composite = new ShowAnglesTool.ShowAnglesToolCompositeGraphic(mockOwnerTool);
                image.OverlayGraphics.Add(composite);

                using (IPresentationImage clone = image.Clone())
                {
                    var cloneComposite = FindShowAnglesToolComposite(clone);
                    Assert.IsNotNull(cloneComposite, "ShowAnglesToolCompositeGraphic should be cloneable.");
                }

                PolylineGraphic line1 = new PolylineGraphic();
                line1.Points.Add(new PointF(0, 0));
                line1.Points.Add(new PointF(10, 10));
                VerticesControlGraphic control1 = new VerticesControlGraphic(line1);
                image.OverlayGraphics.Add(control1);
                composite.Select(control1);
                composite.OnDrawing();

                using (IPresentationImage clone = image.Clone())
                {
                    var cloneComposite = FindShowAnglesToolComposite(clone);

                    cloneComposite.CoordinateSystem = line1.CoordinateSystem;
                    try
                    {
                        Assert.IsNotNull(cloneComposite.SelectedLine, "Cloned ShowAnglesToolCompositeGraphic should retain line graphic selection.");
                        Assert.AreEqual(line1.Points[0], cloneComposite.SelectedLine.Points[0], "Cloned ShowAnglesToolCompositeGraphic should retain line graphic selection (X).");
                        Assert.AreEqual(line1.Points[1], cloneComposite.SelectedLine.Points[1], "Cloned ShowAnglesToolCompositeGraphic should retain line graphic selection (Y).");
                    }
                    finally
                    {
                        cloneComposite.ResetCoordinateSystem();
                    }
                }

                PolylineGraphic line2 = new PolylineGraphic();
                line2.Points.Add(new PointF(0, 10));
                line2.Points.Add(new PointF(10, 0));
                VerticesControlGraphic control2 = new VerticesControlGraphic(line2);
                image.OverlayGraphics.Add(control2);
                composite.Select(control2);
                composite.OnDrawing();

                using (IPresentationImage clone = image.Clone())
                {
                    var cloneComposite = FindShowAnglesToolComposite(clone);

                    cloneComposite.CoordinateSystem = line2.CoordinateSystem;
                    try
                    {
                        Assert.IsNotNull(cloneComposite.SelectedLine, "Cloned ShowAnglesToolCompositeGraphic should retain line graphic selection (2).");
                        Assert.AreEqual(line2.Points[0], cloneComposite.SelectedLine.Points[0], "Cloned ShowAnglesToolCompositeGraphic should retain line graphic selection (X2).");
                        Assert.AreEqual(line2.Points[1], cloneComposite.SelectedLine.Points[1], "Cloned ShowAnglesToolCompositeGraphic should retain line graphic selection (Y2).");
                    }
                    finally
                    {
                        cloneComposite.ResetCoordinateSystem();
                    }
                }
            }
        }