private void panTimelineViewer_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { ScrollbarSelected = false; if (ActiveTimelineEvent != null && e.X == MouseEventOld.X && e.Y == MouseEventOld.Y) { int MouseFrame = (e.X - TimelineStartX + ScrollbarStartIndex) / 8; AnimationObjectKeyFrame Move; if (ActiveTimelineEvent.TryGetValue(MouseFrame, out Move)) { OnKeyFrameSelected(Move); } } if (TimelineResizeSide != TimelineResizeSides.None) { TimelineChanged(); } TimelineResizeSide = TimelineResizeSides.None; } else { if (e.X < TimelineStartX) { tsmCreateGroup.Visible = true; tsmDeleteItem.Visible = true; tsmDeleteKeyFrame.Visible = false; tsmInsertKeyFrame.Visible = false; cmsTimelineOptions.Show(this, e.Location); } else if (ActiveTimelineEvent != null) { int MouseFrame = (e.X - TimelineStartX + ScrollbarStartIndex) / 8; AnimationObjectKeyFrame Move; if (ActiveTimelineEvent.TryGetValue(MouseFrame, out Move)) { tsmCreateGroup.Visible = false; tsmDeleteItem.Visible = false; tsmDeleteKeyFrame.Visible = true; tsmInsertKeyFrame.Visible = false; } else { tsmCreateGroup.Visible = false; tsmDeleteItem.Visible = false; tsmDeleteKeyFrame.Visible = false; tsmInsertKeyFrame.Visible = true; } cmsTimelineOptions.Show(this, e.Location); } } }
private void panTimelineViewer_MouseDown(object sender, MouseEventArgs e) { MouseEventOriginal = e; MouseEventOld = e; if (e.X < 0) { return; } #region Left Button if (e.Button == MouseButtons.Left) { if (e.X < TimelineStartX) { TimelineDragDropSelectedItemIndex = -2; int VisibleIndex = 0; for (int i = 0; i < TimelineActiveItems && VisibleIndex < TimelineVisibleItemCount; i++) { ActiveTimelineEvent = GetTimelineEvent(i); //End of TimelineEvent list. if (ActiveTimelineEvent == null) { break; } if (e.Y >= (VisibleIndex + 1) * 20 && e.Y < (VisibleIndex + 2) * 20 && i >= vsbTimeline.Value) { TimelineDragDropSelectedItemIndex = i; } else { if (Control.ModifierKeys != Keys.Shift) { ActiveAnimation.ListSelectedObjects.Remove(ActiveTimelineEvent); GroupTimeline ActiveGroup = ActiveTimelineEvent as GroupTimeline; if (ActiveGroup != null) { SelectTimelineGroup(ActiveGroup, false); } } } if (i >= vsbTimeline.Value) { VisibleIndex++; } } if (TimelineDragDropSelectedItemIndex >= 0) { ActiveTimelineEvent = GetTimelineEvent(TimelineDragDropSelectedItemIndex); GroupTimeline ActiveGroup = ActiveTimelineEvent as GroupTimeline; if (ActiveGroup != null) { //Expend/Collapse the group if (e.X >= 1 + TimelineDragDropSelectedItemIndent * 5 && e.X < 9 + TimelineDragDropSelectedItemIndent * 5) { ActiveGroup.IsOpen = !ActiveGroup.IsOpen; TimelineDragDropSelectedItemIndex = -2; UpdateTimelineVisibleItems(); } else { SelectTimelineGroup(ActiveGroup, true); OnTimelineSelected(ActiveTimelineEvent); } } else { OnTimelineSelected(ActiveTimelineEvent); } } DrawTimeline(); } else if (e.Y <= 20) { OnKeyFrameChange((e.X - TimelineStartX + ScrollbarStartIndex) / 8); PlaybackStartKeyFrame = ActiveKeyFrame; PlaybackEndKeyFrame = -1; DrawTimeline(); } else if (e.Y >= Height - 20) { ScrollbarSelected = true; } else if (ActiveTimelineEvent == null) { int MouseFrameHalf = (e.X - TimelineStartX + ScrollbarStartIndex + 4) / 8; int MouseEventFrame = (e.X - TimelineStartX + ScrollbarStartIndex) / 8; for (int i = vsbTimeline.Value, VisibleIndex = 0; i < TimelineActiveItems && VisibleIndex < TimelineVisibleItemCount; i++, VisibleIndex++) { if (e.Y < (VisibleIndex + 1) * 20 || e.Y >= (VisibleIndex + 2) * 20) { continue; } Timeline ActiveEvent = GetTimelineEvent(i); ActiveTimelineEvent = ActiveEvent; AnimationObjectKeyFrame ActiveAnimationObjectKeyFrame = null; if (MouseEventFrame == ActiveEvent.SpawnFrame) { TimelineResizeSide = TimelineResizeSides.Left; } else if (MouseFrameHalf == ActiveEvent.DeathFrame) { TimelineResizeSide = TimelineResizeSides.Right; } else if (ActiveEvent.TryGetValue(MouseEventFrame, out ActiveAnimationObjectKeyFrame)) { OnKeyFrameSelected(ActiveAnimationObjectKeyFrame); TimelineResizeSide = TimelineResizeSides.MoveKeyFrame; } else if (MouseEventFrame > ActiveEvent.SpawnFrame && MouseEventFrame < ActiveEvent.DeathFrame) { TimelineResizeSide = TimelineResizeSides.All; } } } } #endregion #region Right Button else if (e.Button == MouseButtons.Right) { Timeline ActiveEvent; if (e.X < TimelineStartX) { for (int i = vsbTimeline.Value, VisibleIndex = 0; i < TimelineActiveItems && VisibleIndex < TimelineVisibleItemCount; i++, VisibleIndex++) { ActiveEvent = GetTimelineEvent(i); if (e.Y < (VisibleIndex + 1) * 20 || e.Y >= (VisibleIndex + 2) * 20) { ActiveAnimation.ListSelectedObjects.Remove(ActiveEvent); continue; } ActiveAnimation.ListSelectedObjects.Add(ActiveEvent); ActiveTimelineEvent = ActiveEvent; } DrawTimeline(); } else { ActiveKeyFrame = (e.X - TimelineStartX + ScrollbarStartIndex) / 8; for (int i = vsbTimeline.Value, VisibleIndex = 0; i < TimelineActiveItems && VisibleIndex < TimelineVisibleItemCount; i++, VisibleIndex++) { if (e.Y < (VisibleIndex + 1) * 20 || e.Y >= (VisibleIndex + 2) * 20) { continue; } ActiveEvent = GetTimelineEvent(i); ActiveTimelineEvent = ActiveEvent; } } } #endregion }