Example #1
0
        /// <summary>
        /// Mouse left button pressed event handler.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainCanvas_LeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point mouseClick = Mouse.GetPosition(MainCanvas);

            if (e.OriginalSource is Ellipse)
            {
                draggedPoint            = e.OriginalSource as Ellipse;
                draggedPoint.Fill       = new SolidColorBrush(Colors.Red);
                draggedPoint.Stroke     = new SolidColorBrush(Colors.Red);
                StatusBarTextBlock.Text = "Przenoszenie węzła...";
            }
            else if (e.OriginalSource is Canvas)
            {
                if (activeComponent != null)
                {
                    if (activeComponent is LatexPolyline)
                    {
                        LatexPolyline poly  = activeComponent as LatexPolyline;
                        LatexPoint    point = new LatexPoint(mouseClick.X, mouseClick.Y, MainCanvas);
                        poly.AddPoint(point, MainCanvas);
                        poly.Draw();
                    }
                    else if (activeComponent is LatexPoint)
                    {
                        activeComponent = new LatexPoint(MainCanvas);
                        components.Add(activeComponent);
                        LatexPoint node  = activeComponent as LatexPoint;
                        LatexPoint point = new LatexPoint(mouseClick.X, mouseClick.Y, MainCanvas);
                        node.SetPosition(point);
                        node.Draw();
                    }
                }
            }
        }
Example #2
0
 internal void UpdatePoint(Ellipse draggedPoint, LatexPoint latexPoint)
 {
     foreach (LatexPoint point in pointList)
     {
         if (point.ellipse == draggedPoint)
         {
             point.SetPosition(latexPoint);
             Canvas.SetLeft(point.ellipse, latexPoint.X);
             Canvas.SetTop(point.ellipse, latexPoint.Y);
             break;
         }
     }
 }
Example #3
0
 private void MainCanvas_OnMouseMove(object sender, MouseEventArgs e)
 {
     if (draggedPoint != null)
     {
         activeComponent = FindActiveComponent(draggedPoint); // Select component which contain draggedPoint
         Point mousePosition = Mouse.GetPosition(MainCanvas);
         if (activeComponent is LatexPolyline)
         {
             LatexPolyline poly = activeComponent as LatexPolyline;
             poly.UpdatePoint(draggedPoint, new LatexPoint(mousePosition.X, mousePosition.Y, MainCanvas));
             poly.Draw();
         }
         if (activeComponent is LatexPoint)
         {
             LatexPoint point = activeComponent as LatexPoint;
             point.UpdatePoint(new LatexPoint(mousePosition.X, mousePosition.Y, MainCanvas));
             point.Draw();
         }
     }
 }
Example #4
0
 public void AddPoint(LatexPoint latexPoint, Canvas mainCanvas)
 {
     pointList.Add(latexPoint);
 }
Example #5
0
 public void UpdatePoint(LatexPoint latexPoint)
 {
     SetPosition(latexPoint);
     Canvas.SetLeft(ellipse, latexPoint.X);
     Canvas.SetTop(ellipse, latexPoint.Y);
 }
Example #6
0
 public void SetPosition(LatexPoint point)
 {
     this.X = point.X;
     this.Y = point.Y;
 }