Esempio n. 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();
                    }
                }
            }
        }
Esempio n. 2
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();
         }
     }
 }