コード例 #1
0
        /// <summary>
        /// Select all elements that are in the drag selection rectangle.
        /// </summary>
        private void ApplyDragSelectionRect()
        {
            dragSelectionCanvas.Visibility = Visibility.Collapsed;

            double x        = Canvas.GetLeft(dragSelectionBorder);
            double y        = Canvas.GetTop(dragSelectionBorder);
            double width    = dragSelectionBorder.Width;
            double height   = dragSelectionBorder.Height;
            Rect   dragRect = new Rect(x, y, width, height);

            //
            // Inflate the drag selection-rectangle by 1/10 of its size to
            // make sure the intended item is selected.
            //
            dragRect.Inflate(width / 10, height / 10);

            //
            // Clear the current selection.
            //
            listBox.SelectedItems.Clear();

            //
            // Find and select all the list box items.
            //
            foreach (KeyframeViewModel key in keyItems)
            {
                double KeyPosition = CanvasCalculator.GetCanvasOffset(ActualWidth, TimeRangeStart, TimeRangeEnd, key.Time);
                Rect   itemRect    = new Rect(KeyPosition, 2, 8, 20);
                if (dragRect.Contains(itemRect))
                {
                    listBox.SelectedItems.Add(key);
                }
            }
        }
コード例 #2
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            //Index 0 = width
            //Index 1 = TimeRangeStart
            //Index 2 = TimeRangeEnd
            //Index 3 = Time
            double actualWidth    = (double)values[0];
            int    timeRangeStart = (int)values[1];
            int    timeRangeEnd   = (int)values[2];
            int    time           = (int)values[3];

            return(CanvasCalculator.GetCanvasOffset(actualWidth, timeRangeStart, timeRangeEnd, time) - 3);
        }
コード例 #3
0
 //private void InvalidatePositions()
 //{
 //    foreach(KeyframeListItem key in keyItems)
 //    {
 //        key.TimelinePositionX = GetCanvasPosition(key.Time) - 3;
 //    }
 //    //System.Diagnostics.Debug.WriteLine("InvalidatePositions");
 //}
 private double GetCanvasPosition(int time)
 {
     return(CanvasCalculator.GetCanvasOffset(ActualWidth, TimeRangeStart, TimeRangeEnd, time));
 }