public AudioVisualizer(AudioVisualizerView imageView) { _imageView = imageView; _imageView.OnMouseClicked += (object sender, NSEvent e) => { bool controlDown = (AppKit.NSEventModifierMask.ControlKeyMask & NSEvent.CurrentModifierFlags) > 0; bool altDown = (AppKit.NSEventModifierMask.AlternateKeyMask & NSEvent.CurrentModifierFlags) > 0; bool shiftDown = (AppKit.NSEventModifierMask.ShiftKeyMask & NSEvent.CurrentModifierFlags) > 0; var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView); WaveformMouseClick(sender, new Point((int)Math.Round(pos.X), (int)Math.Round(pos.Y)), true, shiftDown, controlDown, altDown); }; _imageView.OnMouseDoubleClicked += (object sender, NSEvent e) => { var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView); WaveformMouseDoubleClick(sender, new Point((int)Math.Round(pos.X), (int)Math.Round(pos.Y)), true); }; _imageView.OnMouseDown += (object sender, NSEvent e) => { var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView); WaveformMouseDown(sender, new Point((int)Math.Round(pos.X), (int)Math.Round(pos.Y)), true, false); // e.ButtonMask & NSEventButtonMask.); }; _imageView.OnMouseEnter += (object sender, NSEvent e) => { if (_wavePeaks == null) { return; } if (_noClear) { _noClear = false; } else { _imageView.AddCursorRect(_imageView.Bounds, NSCursor.ArrowCursor); //Cursor = Cursors.Default; _mouseDown = false; _mouseDownParagraph = null; _mouseMoveStartX = -1; _mouseMoveEndX = -1; } if (NewSelectionParagraph != null) { _mouseMoveStartX = SecondsToXPosition(NewSelectionParagraph.StartTime.TotalSeconds - StartPositionSeconds); _mouseMoveEndX = SecondsToXPosition(NewSelectionParagraph.EndTime.TotalSeconds - StartPositionSeconds); } }; _imageView.OnMouseLeave += (object sender, NSEvent e) => { _mouseDown = false; }; _imageView.OnMouseMoved += (object sender, NSEvent e) => { if (_wavePeaks == null) { return; } var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView); _mouseMoveLastX = (int)(Math.Round(pos.X)); if (_mouseMoveLastX < 0 || _mouseMoveLastX > Width) { return; } double seconds = RelativeXPositionToSeconds(_mouseMoveLastX); var milliseconds = (int)(seconds * TimeCode.BaseUnit); if (IsParagrapBorderHit(milliseconds, NewSelectionParagraph)) { _imageView.AddCursorRect(_imageView.Bounds, NSCursor.IBeamCursor); // Cursors.VSplit } else if (IsParagrapBorderHit(milliseconds, _selectedParagraph) || IsParagrapBorderHit(milliseconds, _displayableParagraphs)) { _imageView.AddCursorRect(_imageView.Bounds, NSCursor.IBeamCursor); // VSplit; } else { _imageView.AddCursorRect(_imageView.Bounds, NSCursor.ArrowCursor); } }; _imageView.OnMouseDraged += (object sender, NSEvent e) => { var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView); bool onlyAltDown = (AppKit.NSEventModifierMask.AlternateKeyMask == NSEvent.CurrentModifierFlags); WaveformMouseMove(sender, new Point((int)Math.Round(pos.X), (int)Math.Round(pos.Y)), true, onlyAltDown); }; _imageView.OnMouseWheel += (object sender, NSEvent e) => { var delta = e.DeltaY / 3.0f; if (!MouseWheelScrollUpIsForward) { delta = delta * -1; } if (Locked) { FireOnPositonSelected(new ParagraphEventArgs(_currentVideoPositionSeconds + delta, null)); } else { StartPositionSeconds += delta; if (_currentVideoPositionSeconds < StartPositionSeconds || _currentVideoPositionSeconds >= EndPositionSeconds) { FireOnPositonSelected(new ParagraphEventArgs(StartPositionSeconds, null)); } } }; }
public AudioVisualizer(AudioVisualizerView imageView) { _imageView = imageView; _imageView.OnMouseClicked += (object sender, NSEvent e) => { bool controlDown = (AppKit.NSEventModifierMask.ControlKeyMask & NSEvent.CurrentModifierFlags) > 0; bool altDown = (AppKit.NSEventModifierMask.AlternateKeyMask & NSEvent.CurrentModifierFlags) > 0; bool shiftDown = (AppKit.NSEventModifierMask.ShiftKeyMask & NSEvent.CurrentModifierFlags) > 0; var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView); WaveformMouseClick(sender, new Point((int)Math.Round(pos.X), (int)Math.Round(pos.Y)), true, shiftDown, controlDown, altDown); }; _imageView.OnMouseDoubleClicked += (object sender, NSEvent e) => { var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView); WaveformMouseDoubleClick(sender, new Point((int)Math.Round(pos.X), (int)Math.Round(pos.Y)), true); }; _imageView.OnMouseDown += (object sender, NSEvent e) => { var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView); WaveformMouseDown(sender, new Point((int)Math.Round(pos.X), (int)Math.Round(pos.Y)), true, false); // e.ButtonMask & NSEventButtonMask.); }; _imageView.OnMouseEnter += (object sender, NSEvent e) => { if (_wavePeaks == null) return; if (_noClear) { _noClear = false; } else { _imageView.AddCursorRect(_imageView.Bounds, NSCursor.ArrowCursor); //Cursor = Cursors.Default; _mouseDown = false; _mouseDownParagraph = null; _mouseMoveStartX = -1; _mouseMoveEndX = -1; } if (NewSelectionParagraph != null) { _mouseMoveStartX = SecondsToXPosition(NewSelectionParagraph.StartTime.TotalSeconds - StartPositionSeconds); _mouseMoveEndX = SecondsToXPosition(NewSelectionParagraph.EndTime.TotalSeconds - StartPositionSeconds); } }; _imageView.OnMouseLeave += (object sender, NSEvent e) => { _mouseDown = false; }; _imageView.OnMouseMoved += (object sender, NSEvent e) => { if (_wavePeaks == null) { return; } var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView); _mouseMoveLastX = (int)(Math.Round(pos.X)); if (_mouseMoveLastX < 0 || _mouseMoveLastX > Width) { return; } double seconds = RelativeXPositionToSeconds(_mouseMoveLastX); var milliseconds = (int)(seconds * TimeCode.BaseUnit); if (IsParagrapBorderHit(milliseconds, NewSelectionParagraph)) _imageView.AddCursorRect(_imageView.Bounds, NSCursor.IBeamCursor); // Cursors.VSplit else if (IsParagrapBorderHit(milliseconds, _selectedParagraph) || IsParagrapBorderHit(milliseconds, _displayableParagraphs)) { _imageView.AddCursorRect(_imageView.Bounds, NSCursor.IBeamCursor); // VSplit; } else { _imageView.AddCursorRect(_imageView.Bounds, NSCursor.ArrowCursor); } }; _imageView.OnMouseDraged += (object sender, NSEvent e) => { var pos = _imageView.ConvertPointFromView(e.LocationInWindow, _imageView.Window.ContentView); bool onlyAltDown = (AppKit.NSEventModifierMask.AlternateKeyMask == NSEvent.CurrentModifierFlags); WaveformMouseMove(sender, new Point((int)Math.Round(pos.X), (int)Math.Round(pos.Y)), true, onlyAltDown); }; _imageView.OnMouseWheel += (object sender, NSEvent e) => { var delta = e.DeltaY / 3.0f; if (!MouseWheelScrollUpIsForward) delta = delta * -1; if (Locked) { FireOnPositonSelected(new ParagraphEventArgs(_currentVideoPositionSeconds + delta, null)); } else { StartPositionSeconds += delta; if (_currentVideoPositionSeconds < StartPositionSeconds || _currentVideoPositionSeconds >= EndPositionSeconds) FireOnPositonSelected(new ParagraphEventArgs(StartPositionSeconds, null)); } }; }
public override void AwakeFromNib() { base.AwakeFromNib(); this.Title = "Subtitle Edit"; InitializeToolbar(); InitializeSubtitleTable(); subtitleText.Delegate = new SubtitleTextDelegate(WindowController as MainWindowController); _startTimeStepper.MinValue = -10000; _startTimeStepper.MaxValue = 10000; _startTimeStepper.Increment = 100; _startTimeStepper.Activated += (object sender, EventArgs e) => { (WindowController as MainWindowController).UpdateStartAndEndTime(_startTimeStepper.IntValue); _startTimeStepper.IntValue = 0; }; _startTime.Activated += (object sender, EventArgs e) => { var ms = TimeCode.ParseToMilliseconds(_startTime.StringValue); (WindowController as MainWindowController).SetStartTime(ms); }; _durationStepper.MinValue = -10000; _durationStepper.Increment = 100; _durationStepper.Activated += (object sender, EventArgs e) => { (WindowController as MainWindowController).UpdateEndTime(_durationStepper.IntValue); _durationStepper.IntValue = 0; }; _duration.Activated += (object sender, EventArgs e) => { double d; if (double.TryParse(_duration.StringValue, out d)) { (WindowController as MainWindowController).UpdateDuration(d * 1000.0); } }; FixMacButtonTexts(); this.Delegate = new MainWindowDelegate(WindowController as MainWindowController); (WindowController as MainWindowController).InitializeVideoPlayer(); _buttonAddWaveform.Activated += (object sender, EventArgs e) => { (WindowController as MainWindowController).AddAudioVisualization(); }; _audioVisualizerView = new global::UILogic.AudioVisualizerView(); _audioViz.Superview.AddSubview(_audioVisualizerView); _audioVisualizerView.AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable; _audioVisualizerView.SetFrameSize(_audioViz.Superview.Frame.Size); _audioVisualizerView.BecomeFirstResponder(); _audioViz.Hidden = true; if (!Configuration.Settings.General.ShowAudioVisualizer) { ShowHideAudioVisualizer(); } if (!Configuration.Settings.General.ShowVideoPlayer) { ShowHideVideoPlayer(); } }