private void FFmpegPathButtonClicked(PropertyPage props, int propertyIndex) { var dummy = ""; #if FAMISTUDIO_WINDOWS var ffmpegExeFilter = "FFmpeg Executable (ffmpeg.exe)|ffmpeg.exe"; #else var ffmpegExeFilter = "FFmpeg Executable (ffmpeg)|*.*"; #endif #if FAMISTUDIO_MACOS dialog.TemporarelyHide(); #endif string filename = PlatformUtils.ShowOpenFileDialog("Please select FFmpeg executable", ffmpegExeFilter, ref dummy, dialog); #if FAMISTUDIO_MACOS dialog.TemporarelyShow(); #endif if (filename != null) { props.SetPropertyValue(propertyIndex, filename); // Update settings right away. Settings.FFmpegExecutablePath = filename; Settings.Save(); } }
private void FFmpegPage_PropertyClicked(PropertyPage props, ClickType click, int propIdx, int rowIdx, int colIdx) { if (click == ClickType.Button) { if (propIdx == 1) { var ffmpegExeFilter = PlatformUtils.IsWindows ? "FFmpeg Executable (ffmpeg.exe)|ffmpeg.exe" : "FFmpeg Executable (ffmpeg)|*.*"; var dummy = ""; var filename = PlatformUtils.ShowOpenFileDialog("Please select FFmpeg executable", ffmpegExeFilter, ref dummy, dialog); if (filename != null) { props.SetPropertyValue(propIdx, filename); } } else if (propIdx == 2) { PlatformUtils.OpenUrl("https://famistudio.org/doc/ffmpeg/"); } } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); bool left = e.Button.HasFlag(MouseButtons.Left); bool middle = e.Button.HasFlag(MouseButtons.Middle) || (e.Button.HasFlag(MouseButtons.Left) && ModifierKeys.HasFlag(Keys.Alt)); bool right = e.Button.HasFlag(MouseButtons.Right); var buttonIdx = GetButtonAtCoord(e.X, e.Y, out var subButtonType); if (buttonIdx >= 0) { var button = buttons[buttonIdx]; if (left) { if (button.type == ButtonType.SongHeader) { if (subButtonType == SubButtonType.Add) { App.UndoRedoManager.BeginTransaction(TransactionScope.Project); App.Project.CreateSong(); App.UndoRedoManager.EndTransaction(); RefreshButtons(); ConditionalInvalidate(); } } else if (button.type == ButtonType.Song) { if (button.song != selectedSong) { selectedSong = button.song; SongSelected?.Invoke(selectedSong); ConditionalInvalidate(); } } else if (button.type == ButtonType.InstrumentHeader) { if (subButtonType == SubButtonType.Add) { var instrumentType = Project.ExpansionNone; if (App.Project.NeedsExpansionInstruments) { var expNames = new[] { Project.ExpansionNames[Project.ExpansionNone], App.Project.ExpansionAudioName }; var dlg = new PropertyDialog(PointToScreen(new Point(e.X, e.Y)), 240, true); dlg.Properties.AddStringList("Expansion:", expNames, Project.ExpansionNames[Project.ExpansionNone]); // 0 dlg.Properties.Build(); if (dlg.ShowDialog() == DialogResult.OK) { instrumentType = dlg.Properties.GetPropertyValue <string>(0) == Project.ExpansionNames[Project.ExpansionNone] ? Project.ExpansionNone : App.Project.ExpansionAudio; } else { return; } } App.UndoRedoManager.BeginTransaction(TransactionScope.Project); App.Project.CreateInstrument(instrumentType); App.UndoRedoManager.EndTransaction(); RefreshButtons(); ConditionalInvalidate(); } if (subButtonType == SubButtonType.LoadInstrument) { var filename = PlatformUtils.ShowOpenFileDialog("Open File", "Fami Tracker Instrument (*.fti)|*.fti"); if (filename != null) { App.UndoRedoManager.BeginTransaction(TransactionScope.Project); var instrument = FamitrackerInstrumentFile.CreateFromFile(App.Project, filename); if (instrument == null) { App.UndoRedoManager.AbortTransaction(); } else { App.UndoRedoManager.EndTransaction(); } } RefreshButtons(); ConditionalInvalidate(); } } else if (button.type == ButtonType.Instrument) { selectedInstrument = button.instrument; if (selectedInstrument != null) { instrumentDrag = selectedInstrument; mouseDragY = e.Y; } if (subButtonType == SubButtonType.Volume) { InstrumentEdited?.Invoke(selectedInstrument, Envelope.Volume); envelopeDragIdx = Envelope.Volume; } else if (subButtonType == SubButtonType.Pitch) { InstrumentEdited?.Invoke(selectedInstrument, Envelope.Pitch); envelopeDragIdx = Envelope.Pitch; } else if (subButtonType == SubButtonType.Arpeggio) { InstrumentEdited?.Invoke(selectedInstrument, Envelope.Arpeggio); envelopeDragIdx = Envelope.Arpeggio; } else if (subButtonType == SubButtonType.DPCM) { InstrumentEdited?.Invoke(selectedInstrument, Envelope.Max); } else if (subButtonType == SubButtonType.DutyCycle) { selectedInstrument.DutyCycle = (selectedInstrument.DutyCycle + 1) % selectedInstrument.DutyCycleRange; } InstrumentSelected?.Invoke(selectedInstrument); ConditionalInvalidate(); } } else if (right) { if (button.type == ButtonType.Song && App.Project.Songs.Count > 1) { var song = button.song; if (PlatformUtils.MessageBox($"Are you sure you want to delete '{song.Name}' ?", "Delete song", MessageBoxButtons.YesNo) == DialogResult.Yes) { bool selectNewSong = song == selectedSong; App.Stop(); App.UndoRedoManager.BeginTransaction(TransactionScope.Project); App.Project.DeleteSong(song); if (selectNewSong) { selectedSong = App.Project.Songs[0]; } SongSelected?.Invoke(selectedSong); App.UndoRedoManager.EndTransaction(); RefreshButtons(); ConditionalInvalidate(); } } else if (button.type == ButtonType.Instrument && button.instrument != null) { var instrument = button.instrument; if (subButtonType == SubButtonType.Arpeggio || subButtonType == SubButtonType.Pitch || subButtonType == SubButtonType.Volume) { int envType = Envelope.Volume; switch (subButtonType) { case SubButtonType.Arpeggio: envType = Envelope.Arpeggio; break; case SubButtonType.Pitch: envType = Envelope.Pitch; break; } App.UndoRedoManager.BeginTransaction(TransactionScope.Instrument, instrument.Id); instrument.Envelopes[envType].Length = 0; App.UndoRedoManager.EndTransaction(); ConditionalInvalidate(); } else if (subButtonType == SubButtonType.Max) { if (PlatformUtils.MessageBox($"Are you sure you want to delete '{instrument.Name}' ? All notes using this instrument will be deleted.", "Delete intrument", MessageBoxButtons.YesNo) == DialogResult.Yes) { bool selectNewInstrument = instrument == selectedInstrument; App.StopInstrumentNoteAndWait(); App.UndoRedoManager.BeginTransaction(TransactionScope.Project); App.Project.DeleteInstrument(instrument); if (selectNewInstrument) { selectedInstrument = App.Project.Instruments.Count > 0 ? App.Project.Instruments[0] : null; } SongSelected?.Invoke(selectedSong); InstrumentDeleted?.Invoke(instrument); App.UndoRedoManager.EndTransaction(); RefreshButtons(); ConditionalInvalidate(); } } } } } if (middle) { mouseLastY = e.Y; } }