public override void MouseDrag(object sender, PointF arg, PointF delta, int dragCall) { if (delta.X != 0) { var cmds = new CompoundCommand(); var x = Instance.XDeltaToTime(delta.X); var mouseX = Instance.XPosToTime(arg.X); //move start/end if ((FStart == null) || (FEnd == null)) { if ((FStart != null) && (mouseX < Instance.Model.LoopEnd.Value)) { cmds.Append(Command.Set(FStart, mouseX)); } if ((FEnd != null) && (mouseX > Instance.Model.LoopStart.Value)) { cmds.Append(Command.Set(FEnd, mouseX)); } } else //move region { cmds.Append(Command.Set(FStart, FStart.Value + x)); cmds.Append(Command.Set(FEnd, FEnd.Value + x)); } //execute changes immediately cmds.Execute(); //collect changes for history FMoveCommands.Append(cmds); Instance.Parent.UpdateScene(); } }
public override void MouseDrag(object sender, PointF arg, PointF delta, int callNr) { if (FMoveCommands != null) { var cmds = new CompoundCommand(); var rlr = Instance.Parent.Parent.Ruler; var dx = rlr.XDeltaToTime(delta.X); // in order to do snapping we need to seperate view- and model-time first // var closestKeyframe = Instance.Parent.Parent.Tracks.SelectMany(track => track.KeyframeViews).Except(Enumerable.Repeat(Instance, 1)).OrderBy(kf => kf.Model.Time.Value).Where(kf => Math.Abs(rlr.TimeToXPos(kf.Model.Time.Value) - rlr.TimeToXPos(Instance.Model.Time.Value)) < 3); // if (closestKeyframe.Any()) // dx = Instance.Model.Time.Value - closestKeyframe.First().Model.Time.Value; var i = 0; foreach (var kf in FSelectedKeyframes) { //set time cmds.Append(Command.Set(kf.Model.Time, kf.Model.Time.Value + dx)); //set value if value keyframe if (kf is ValueKeyframeView) { var vkf = kf as ValueKeyframeView; var dy = vkf.Parent.YDeltaToValue(delta.Y); var min = vkf.Parent.Model.Maximum.Value; var max = vkf.Parent.Model.Minimum.Value; FActualValues[i] += dy; if (!FAffectedTracks.Any(x => x.Collapsed)) { cmds.Append(Command.Set(vkf.Model.Value, Math.Min(min, Math.Max(max, FActualValues[i])))); } i++; } } //execute changes immediately cmds.Execute(); //collect changes for history FMoveCommands.Append(cmds); Instance.Parent.Parent.UpdateScene(); } }
public override void MouseSelection(object sender, MouseArg arg, RectangleF rect) { var cmds = new CompoundCommand(); foreach (var track in Instance.Parent.Tracks) { var trackRect = track.ToTrackRect(rect); foreach (var kf in track.KeyframeViews) { var wasSelected = kf.Model.Selected.Value; var isSelected = kf.IsSelectedBy(trackRect); if (arg.AltKey) { if (FPreviouslySelected.Contains(kf)) //only remove from previously selected { cmds.Append(Command.Set(kf.Model.Selected, !isSelected)); } } else if (arg.CtrlKey) { if (!FPreviouslySelected.Contains(kf)) //only add to previously selected { cmds.Append(Command.Set(kf.Model.Selected, isSelected)); } } else if (isSelected != wasSelected) //only send selection change { cmds.Append(Command.Set(kf.Model.Selected, isSelected)); } } } if (cmds.CommandCount > 0) { //execute changes immediately cmds.Execute(); //collect changes for history FSelectionCommands.Append(cmds); } rect = new RectangleF(rect.X, rect.Y - Instance.Parent.FTrackGroup.Transforms[0].Matrix.Elements[5], rect.Width, rect.Height); Instance.Parent.SetSelectionRect(rect); Instance.Parent.UpdateScene(); }