Exemplo n.º 1
0
        private void Canvas_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var handle = e.Source as TrackDragHandle;

            if (handle != null)
            {
                this.trackBeingMoved = handle.Parent as TrackElement;

                if (this.trackBeingMoved != null)
                {
                    MoveTracks(this.trackBeingMoved, true);

                    this.trackBeingMovedStartPoint = e.GetPosition(null);
                    this.trackBeingMovedOrigin     = new Point(Canvas.GetLeft(this.trackBeingMoved), Canvas.GetTop(this.trackBeingMoved));
                    Canvas.SetLeft(this.trackBeingMoved, 20);
                    Canvas.SetZIndex(this.trackBeingMoved, 20);

                    // Create insertion point
                    this.insertionPointCanvas       = new InsertionPointCanvas();
                    this.insertionPointCanvas.Width = this.canvas.ActualWidth;
                    Canvas.SetLeft(this.insertionPointCanvas, 0);
                    Canvas.SetTop(this.insertionPointCanvas, Canvas.GetTop(this.trackBeingMoved));
                    Canvas.SetZIndex(this.insertionPointCanvas, 10);

                    this.canvas.Children.Add(this.insertionPointCanvas);
                }
            }
        }
Exemplo n.º 2
0
        private void Canvas_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (this.trackBeingMoved != null)
            {
                Canvas.SetTop(this.trackBeingMoved, Canvas.GetTop(this.insertionPointCanvas));
                Canvas.SetLeft(this.trackBeingMoved, 0);
                Canvas.SetZIndex(this.trackBeingMoved, 0);

                MoveTracks(this.trackBeingMoved, false);

                this.trackBeingMoved = null;
            }

            if (this.insertionPointCanvas != null)
            {
                this.canvas.Children.Remove(this.insertionPointCanvas);
                this.insertionPointCanvas = null;
            }
        }