예제 #1
0
 public MovePartCommand(UProject project, UPart part, int newPos, int newTrackNo)
 {
     this.project = project;
     this.part = part;
     this.newPos = newPos;
     this.newTrackNo = newTrackNo;
     this.oldPos = part.PosTick;
     this.oldTrackNo = part.TrackNo;
 }
예제 #2
0
        private void BuildVoicePartDone(SequencingSampleProvider source, UPart part, UProject project)
        {
            lock (lockObject)
            {
                trackSources[part.TrackNo].AddSource(
                    source,
                    TimeSpan.FromMilliseconds(project.TickToMillisecond(part.PosTick)));
                pendingParts--;
            }

            if (pendingParts == 0) StartPlayback();
        }
예제 #3
0
        public WavePartElement(UPart part) : base() {
            partImageTrans = new TranslateTransform();
            this.Part = part;

            partBitmap = BitmapFactory.New(
                (int)System.Windows.SystemParameters.VirtualScreenWidth,
                (int)UIConstants.TrackMaxHeight);
            partImage = new PartImage() { RenderTransform = partImageTrans, IsHitTestVisible = false };
            partImage.Arrange(new Rect(0, 0, partBitmap.PixelWidth, partBitmap.PixelHeight));
            partImage.Source = partBitmap;
            this.RemoveVisualChild(partVisual);
            this.AddVisualChild(partImage);

            if (((UWavePart)Part).Peaks == null)
            {
                worker = new BackgroundWorker() { WorkerReportsProgress = true };
                worker.DoWork += BuildPeaksAsync;
                worker.ProgressChanged += BuildPeaksProgressChanged;
                worker.RunWorkerCompleted += BuildPeaksCompleted;
                worker.RunWorkerAsync((UWavePart)Part);
            }
        }
예제 #4
0
 public ResizePartCommand(UProject project, UPart part, int newDur) { this.project = project; this.part = part; this.newDur = newDur; this.oldDur = part.DurTick; }
예제 #5
0
 public RemovePartCommand(UProject project, UPart part) { this.project = project; this.part = part; }
예제 #6
0
        private void trackCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point mousePos = e.GetPosition((UIElement)sender);

            var hit = VisualTreeHelper.HitTest(trackCanvas, mousePos).VisualHit;
            System.Diagnostics.Debug.WriteLine("Mouse hit " + hit.ToString());

            if (Keyboard.Modifiers == ModifierKeys.Control || Keyboard.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift))
            {
                selectionStart = new Point(trackVM.CanvasToQuarter(mousePos.X), trackVM.CanvasToTrack(mousePos.Y));

                if (Keyboard.IsKeyUp(Key.LeftShift) && Keyboard.IsKeyUp(Key.RightShift)) trackVM.DeselectAll();
                
                if (selectionBox == null)
                {
                    selectionBox = new Rectangle()
                    {
                        Stroke = Brushes.Black,
                        StrokeThickness = 2,
                        Fill = ThemeManager.BarNumberBrush,
                        Width = 0,
                        Height = 0,
                        Opacity = 0.5,
                        RadiusX = 8,
                        RadiusY = 8,
                        IsHitTestVisible = false
                    };
                    trackCanvas.Children.Add(selectionBox);
                    Canvas.SetZIndex(selectionBox, 1000);
                    selectionBox.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    selectionBox.Width = 0;
                    selectionBox.Height = 0;
                    Canvas.SetZIndex(selectionBox, 1000);
                    selectionBox.Visibility = System.Windows.Visibility.Visible;
                }
                Mouse.OverrideCursor = Cursors.Cross;
            }
            else if (hit is DrawingVisual)
            {
                PartElement partEl = ((DrawingVisual)hit).Parent as PartElement;
                _hitPartElement = partEl;

                if (!trackVM.SelectedParts.Contains(_hitPartElement.Part)) trackVM.DeselectAll();

                if (e.ClickCount == 2)
                {
                    if (partEl is VoicePartElement) // load part into midi window
                    {
                        if (midiWindow == null) midiWindow = new MidiWindow();
                        DocManager.Inst.ExecuteCmd(new LoadPartNotification(partEl.Part, trackVM.Project));
                        midiWindow.Show();
                        midiWindow.Focus();
                    }
                }
                else if (mousePos.X > partEl.X + partEl.VisualWidth - UIConstants.ResizeMargin && partEl is VoicePartElement) // resize
                {
                    _resizePartElement = true;
                    _resizeMinDurTick = trackVM.GetPartMinDurTick(_hitPartElement.Part);
                    Mouse.OverrideCursor = Cursors.SizeWE;
                    if (trackVM.SelectedParts.Count > 0)
                    {
                        _partResizeShortest = _hitPartElement.Part;
                        foreach (UPart part in trackVM.SelectedParts)
                        {
                            if (part.DurTick - part.GetMinDurTick(trackVM.Project) <
                                _partResizeShortest.DurTick - _partResizeShortest.GetMinDurTick(trackVM.Project))
                                _partResizeShortest = part;
                        }
                        _resizeMinDurTick = _partResizeShortest.GetMinDurTick(trackVM.Project);
                    }
                    DocManager.Inst.StartUndoGroup();
                }
                else // move
                {
                    _movePartElement = true;
                    _partMoveRelativeTick = trackVM.CanvasToSnappedTick(mousePos.X) - _hitPartElement.Part.PosTick;
                    _partMoveStartTick = partEl.Part.PosTick;
                    Mouse.OverrideCursor = Cursors.SizeAll;
                    if (trackVM.SelectedParts.Count > 0)
                    {
                        _partMovePartLeft = _partMovePartMin = _partMovePartMax = _hitPartElement.Part;
                        foreach (UPart part in trackVM.SelectedParts)
                        {
                            if (part.PosTick < _partMovePartLeft.PosTick) _partMovePartLeft = part;
                            if (part.TrackNo < _partMovePartMin.TrackNo) _partMovePartMin = part;
                            if (part.TrackNo > _partMovePartMax.TrackNo) _partMovePartMax = part;
                        }
                    }
                    DocManager.Inst.StartUndoGroup();
                }
            }
            else
            {
                if (trackVM.CanvasToTrack(mousePos.Y) > trackVM.Project.Tracks.Count - 1) return;
                UVoicePart part = new UVoicePart()
                {
                    PosTick = trackVM.CanvasToSnappedTick(mousePos.X),
                    TrackNo = trackVM.CanvasToTrack(mousePos.Y),
                    DurTick = trackVM.Project.Resolution * 4 / trackVM.Project.BeatUnit * trackVM.Project.BeatPerBar
                };
                DocManager.Inst.StartUndoGroup();
                DocManager.Inst.ExecuteCmd(new AddPartCommand(trackVM.Project, part));
                DocManager.Inst.EndUndoGroup();
                // Enable drag
                trackVM.DeselectAll();
                _movePartElement = true;
                _hitPartElement = trackVM.GetPartElement(part);
                _partMoveRelativeTick = 0;
                _partMoveStartTick = part.PosTick;
            }
            ((UIElement)sender).CaptureMouse();
        }
예제 #7
0
 public LoadPartNotification(UPart part, UProject project) { this.part = part; this.project = project; }