Beispiel #1
0
        /// <summary>
        /// Event handler for the TimelineControl.MouseDownPicked event</summary>
        /// <param name="sender">The TimelineControl that we are attached to</param>
        /// <param name="e">HitEventArgs</param>
        protected virtual void Owner_MouseDownPicked(object sender, HitEventArgs e)
        {
            HitRecord    hitRecord = e.HitRecord;
            TimelinePath hitObject = hitRecord.HitPath;

            if (hitObject != null)
            {
                Keys modifiers = Control.ModifierKeys;

                if (e.MouseEvent.Button == MouseButtons.Left)
                {
                    if (modifiers == Keys.None && SelectionContext != null &&
                        SelectionContext.SelectionContains(hitObject))
                    {
                        // The hit object is already selected. Wait until the mouse up to see if there was
                        //  a drag or not. If no drag, then set the selection set to be this one object.
                        m_mouseDownHitRecord = hitRecord;
                        m_mouseDownPos       = e.MouseEvent.Location;
                    }
                    else if (modifiers == Keys.Control)
                    {
                        // Either this object is not already selected or Shift key is being held down.
                        //  to be consistent with the Windows interface.
                        m_mouseDownHitRecord = hitRecord;
                        m_mouseDownPos       = e.MouseEvent.Location;
                    }
                    else if ((modifiers & Keys.Alt) == 0)
                    {
                        // The 'Alt' key might mean something different. If no Alt key, we can update the
                        //  selection immediately.
                        UpdateSelection(hitRecord, modifiers);
                    }
                }
                else if (e.MouseEvent.Button == MouseButtons.Right)
                {
                    if (modifiers == Keys.None && SelectionContext != null &&
                        !SelectionContext.SelectionContains(hitObject))
                    {
                        // The hit object is not already selected and a right-click landed on it. Select it.
                        UpdateSelection(hitRecord, modifiers);
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Updates the selection set, given the hit object and the modifier keys</summary>
        /// <param name="hitRecord">HitRecord</param>
        /// <param name="modifiers">Modifier keys</param>
        private void UpdateSelection(HitRecord hitRecord, Keys modifiers)
        {
            TimelinePath hitObject        = hitRecord.HitPath;
            bool         hitIsValidAnchor = true;

            switch (hitRecord.Type)
            {
            case HitType.GroupMove:
                SelectGroups(hitObject);
                break;

            case HitType.TrackMove:
                SelectTracks(hitObject);
                break;

            case HitType.Interval:
            case HitType.Key:
            case HitType.Marker:
                SelectEvents(hitObject);
                Owner.Constrain = (modifiers & Owner.ConstrainModifierKeys) != 0;
                break;

            default:
                Anchor           = null;
                hitIsValidAnchor = false;
                break;
            }

            if (hitIsValidAnchor)
            {
                // If the Shift key is not held down or the current Anchor is null, or the user
                //  has switched between track and group, or the user has picked an event, then
                //  update the Anchor. IEvents are always additive with the shift key.
                if ((modifiers & Keys.Shift) == 0 ||
                    Anchor == null ||
                    (Anchor.Last is IGroup && hitObject.Last is ITrack) ||
                    (Anchor.Last is ITrack && hitObject.Last is IGroup) ||
                    (Anchor.Last is IEvent && hitObject.Last is IEvent))
                {
                    Anchor = hitObject;
                }
            }
        }
Beispiel #3
0
        private void owner_MouseMovePicked(object sender, HitEventArgs e)
        {
            if (e.MouseEvent.Button == MouseButtons.None &&
                !m_owner.IsUsingMouse)
            {
                HitRecord hitRecord = e.HitRecord;
                if (m_owner.IsEditable(hitRecord.HitPath))
                {
                    switch (hitRecord.Type)
                    {
                    case HitType.Interval:
                    case HitType.Key:
                    case HitType.Marker:
                        m_owner.Cursor = Cursors.SizeAll;
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Beispiel #4
0
 /// <summary>
 /// Constructs a hit event argument</summary>
 /// <param name="hitRecord">Hit record. Can be null if raising a Picking event.</param>
 /// <param name="pickRectangle">Picking rectangle in Windows client coordinates</param>
 /// <param name="mouseEvent">The mouse event, if any, associated with this pick action</param>
 public HitEventArgs(HitRecord hitRecord, RectangleF pickRectangle, MouseEventArgs mouseEvent)
 {
     m_hitRecord = hitRecord;
     PickRectangle = pickRectangle;
     MouseEvent = mouseEvent;
 }
Beispiel #5
0
 /// <summary>
 /// Comparer for sorting HitRecords by their HitType enum. Lower-valued enums come first.</summary>
 private int CompareHits(HitRecord x, HitRecord y)
 {
     return x.Type.CompareTo(y.Type);
 }
 /// <summary>
 /// Constructs a hit event argument</summary>
 /// <param name="hitRecord">Hit record. Can be null if raising a Picking event.</param>
 /// <param name="pickRectangle">Picking rectangle in Windows client coordinates</param>
 /// <param name="mouseEvent">The mouse event, if any, associated with this pick action</param>
 public HitEventArgs(HitRecord hitRecord, RectangleF pickRectangle, MouseEventArgs mouseEvent)
 {
     m_hitRecord   = hitRecord;
     PickRectangle = pickRectangle;
     MouseEvent    = mouseEvent;
 }
        /// <summary>
        /// Updates the selection set, given the hit object and the modifier keys</summary>
        /// <param name="hitRecord">HitRecord</param>
        /// <param name="modifiers">Modifier keys</param>
        private void UpdateSelection(HitRecord hitRecord, Keys modifiers)
        {
            TimelinePath hitObject = hitRecord.HitPath;
            bool hitIsValidAnchor = true;

            switch (hitRecord.Type)
            {
                case HitType.GroupMove:
                    SelectGroups(hitObject);
                    break;

                case HitType.TrackMove:
                    SelectTracks(hitObject);
                    break;

                case HitType.Interval:
                case HitType.Key:
                case HitType.Marker:
                    SelectEvents(hitObject);
                    Owner.Constrain = (modifiers & Owner.ConstrainModifierKeys) != 0;
                    break;
                
                default:
                    Anchor = null;
                    hitIsValidAnchor = false;
                    break;
            }

            if (hitIsValidAnchor)
            {
                // If the Shift key is not held down or the current Anchor is null, or the user
                //  has switched between track and group, or the user has picked an event, then
                //  update the Anchor. IEvents are always additive with the shift key.
                if ((modifiers & Keys.Shift) == 0 ||
                    Anchor == null ||
                    (Anchor.Last is IGroup && hitObject.Last is ITrack) ||
                    (Anchor.Last is ITrack && hitObject.Last is IGroup) ||
                    (Anchor.Last is IEvent && hitObject.Last is IEvent))
                {
                    Anchor = hitObject;
                }
            }
        }