private void TimeLine_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { pressedkeyindex = KeyIndex(e.X); presseditemindex = ItemIndex(e.Y); } else { if ((ModifierKeys & Keys.Control) == Keys.Control) { keyopmode = KeyOperationMode.FixMove; } else { keyopmode = KeyOperationMode.Move; } var itemindex = ItemIndex(e.Y); if (e.Y >= TimeLineAreaHeight && itemindex >= 0 && itemindex < EffectManager.Effects.Count) { mousedown = true; MainForm.PropertyDock.IsRatioMakerAvailable = false; SelectedManager.Effect = EffectManager.Effects[itemindex]; FindKey(itemindex, e.X); } else if (e.Y >= 0 && e.Y <= TimeLineAreaHeight) { var keyindex = KeyIndex(e.X); if (keyindex < 0) { keyindex = 0; } CurrentFrame = keyindex; movetimeline = true; } else { mousedown = false; } } }
private void TimeLine_MouseMove(object sender, MouseEventArgs e) { if (movetimeline) { var keyindex = KeyIndex(e.X); if (keyindex < 0) { keyindex = 0; } CurrentFrame = keyindex; } if (SelectedManager.Set != null && mousedown) { if (SelectedManager.Set.StartState == SelectedManager.State && SelectedManager.Set.StartFrame == 0) { return; } var keyindex = KeyIndex(e.X); switch (keyopmode) { case KeyOperationMode.Move: if (keyindex < 0) { keyindex = 0; } if (SelectedManager.Set.StartState == SelectedManager.State) { if (keyindex >= SelectedManager.Set.EndFrame) { keyindex = SelectedManager.Set.EndFrame - 1; } SelectedManager.Set.StartFrame = keyindex; newframe = keyindex; } else { if (keyindex <= SelectedManager.Set.StartFrame) { keyindex = SelectedManager.Set.StartFrame + 1; } var selectedindex = SelectedManager.Effect.Sets.IndexOfValue(SelectedManager.Set); if (selectedindex >= 0 && selectedindex < SelectedManager.Effect.Sets.Count - 1) { if (keyindex >= SelectedManager.Effect.Sets.Values[selectedindex + 1].EndFrame) { keyindex = SelectedManager.Effect.Sets.Values[selectedindex + 1].EndFrame - 1; } EffectStateRatioSet temp = SelectedManager.Effect.Sets.Values[selectedindex + 1]; temp.StartFrame = keyindex; SelectedManager.Effect.Sets.RemoveAt(selectedindex + 1); SelectedManager.Effect.Sets.Add(temp.StartFrame, temp); } SelectedManager.Set.EndFrame = keyindex; newframe = keyindex; } SelectedManager.Effect.CheckFrameLength(); AdjustHScrollBar(); if (keyindex - hScrollBar1.Value < 0) { GainHScroll(-1); } else if (keyindex - hScrollBar1.Value > MaxVisibleFrameCount) { GainHScroll(1); } DrawAndRefresh(); break; case KeyOperationMode.FixMove: if (keyindex < 0) { keyindex = 0; } if (SelectedManager.Set.StartState == SelectedManager.State) { keyopmode = KeyOperationMode.RightMoveOnly; } else { keyopmode = KeyOperationMode.LeftMoveOnly; } break; case KeyOperationMode.LeftMoveOnly: if (keyindex <= SelectedManager.Set.StartFrame) { keyindex = SelectedManager.Set.StartFrame + 1; } newframe = keyindex; int diff = keyindex - SelectedManager.Set.EndFrame; if (diff != 0) { SelectedManager.Set.EndFrame += diff; var pool = new List <EffectStateRatioSet>(); var removekey = new List <int>(); bool found = false; foreach (KeyValuePair <int, EffectStateRatioSet> pair in SelectedManager.Effect.Sets) { if (found) { pair.Value.StartFrame += diff; pair.Value.EndFrame += diff; pool.Add(pair.Value); removekey.Add(pair.Key); } found |= pair.Value == SelectedManager.Set; } foreach (int val in removekey) { SelectedManager.Effect.Sets.Remove(val); } foreach (EffectStateRatioSet set in pool) { SelectedManager.Effect.Sets.Add(set.StartFrame, set); } SelectedManager.Effect.CheckFrameLength(); AdjustHScrollBar(); DrawAndRefresh(); } break; case KeyOperationMode.RightMoveOnly: if (keyindex < 0) { keyindex = 0; } newframe = keyindex; diff = keyindex - SelectedManager.Set.StartFrame; if (diff != 0) { var pool = new List <EffectStateRatioSet>(SelectedManager.Effect.Sets.Values); SelectedManager.Effect.Sets.Clear(); foreach (EffectStateRatioSet set in pool) { set.StartFrame += diff; set.EndFrame += diff; } foreach (EffectStateRatioSet set in pool) { SelectedManager.Effect.Sets.Add(set.StartFrame, set); } SelectedManager.Effect.CheckFrameLength(); AdjustHScrollBar(); DrawAndRefresh(); } break; } } }