Exemplo n.º 1
0
        private void canvas1_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            Point p = e.GetPosition(grid1);

            if (dirtPen && Mouse.LeftButton == MouseButtonState.Pressed)
            {
                BDNode      n  = Environment.Instance.Dirt.Insert(p, new DirtElement(), 0);
                DirtElement de = (DirtElement)n.Value;
                if (de.count == 0)
                {
                    Rectangle r = new Rectangle();
                    r.Stroke = Brushes.Green;
                    r.Fill   = Brushes.Green;
                    r.Width  = 3;
                    r.Height = 3;
                    r.HorizontalAlignment = HorizontalAlignment.Left;
                    r.VerticalAlignment   = VerticalAlignment.Top;
                    r.Margin   = new Thickness(p.X, p.Y, 0, 0);
                    de.element = r;
                    grid1.Children.Add(r);
                }
                de.count++;
            }
            else if (selectedTool != null && selectedTool.Start != null)
            {
                selectedTool.update(p, Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift),
                                    Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl));

                // Remove old snapshot
                foreach (UIElement elem in snapshot)
                {
                    grid1.Children.Remove(elem);
                }

                // Add new
                foreach (Segment s in selectedTool.Segments)
                {
                    snapshot.Add(drawSegment(s, Brushes.Black));
                }
            }
        }
Exemplo n.º 2
0
        private void canvas1_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            Point p = e.GetPosition(grid1);

            if (selectedTool != null && selectedTool.Start != null)
            {
                selectedTool.update(p, Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift),
                                    Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl));

                // Remove old snapshot
                foreach (UIElement elem in snapshot)
                {
                    grid1.Children.Remove(elem);
                }

                // Add new
                foreach (Segment s in selectedTool.Segments)
                {
                    snapshot.Add(drawSegment(s, Brushes.Black));
                }
            }
        }