Example #1
0
        public void Canvas_OnLeftMouseDown(object sender, MouseEventArgs e)
        {
            if (isDrawing)
            {
                //Reset drawing
                isDrawing = false;
                canvasMain.Children.Remove(previewLine);
            }
            else
            {
                isDrawing = true;
                Point thePoint = e.GetPosition(sender as IInputElement);

                //Create projected line
                previewLine = new ProjectedLine();
                previewLine.Fill = Brushes.Black;
                previewLine.StrokeThickness = 2;
                previewLine.Stroke = Brushes.Black;

                //Set initial position for the line
                previewLine.X1 = canvasMain.ActualWidth / 2;
                previewLine.Y1 = canvasMain.ActualHeight / 2;
                previewLine.X2 = thePoint.X;
                previewLine.Y2 = thePoint.Y;

                //Add to canvas
                canvasMain.Children.Add(previewLine);

                AddMeasurementAdorner(previewLine);
            }
        }
Example #2
0
        public MeasurementAdorner(UIElement adornedElement)
            : base(adornedElement)
        {
            _visualChildren = new VisualCollection(this);

            _element = (ProjectedLine)adornedElement;

            _element.PointChanged += new EventHandler(_element_PointChanged);
            _lengthTextBlock = new TextBlock();
            _visualChildren.Add(_lengthTextBlock);
        }
Example #3
0
 private void AddMeasurementAdorner(ProjectedLine line)
 {
     AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(line);
     MeasurementAdorner pla = new MeasurementAdorner(line);
     adornerLayer.Add(pla);
 }