private void ShowMessage(string mtext, string mtitle) { if (!Application.Current.Dispatcher.CheckAccess()) Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new MessageDelegate(ShowMessage), mtext, mtitle); else { Message mes = new Message((this.IsVisible) ? this : Owner); mes.ShowMessage(mtext, mtitle); } }
private void button_Apply_CLI_Click(object sender, RoutedEventArgs e) { try { StringReader sr = new StringReader(textbox_cli.Text); m.vpasses.Clear(); string line = ""; while (true) { line = sr.ReadLine(); if (line == null) break; if (line != "") m.vpasses.Add(line); } if (m.vpasses.Count == 0) m.vpasses.Add(" "); DecodeLine(m); //- Загружаем в массив m.x264 значения, на основе текущего содержимого m.vpasses[x] LoadFromProfile(); //- Загружаем в форму значения, на основе значений массива m.x264 m.vencoding = "Custom x264 CLI"; //- Изменяем название пресета PresetLoader.CreateVProfile(m); //- Перезаписываем файл пресета (m.vpasses[x]) root_window.m = this.m.Clone(); //- Передаем массив в основное окно root_window.LoadProfiles(); //- Обновляем название выбранного пресета в основном окне (Custom x264 CLI) } catch (Exception) { Message mm = new Message(root_window); mm.ShowMessage(Languages.Translate("Attention! Seems like CLI line contains errors!") + "\r\n" + Languages.Translate("Check all keys and theirs values and try again!") + "\r\n\r\n" + Languages.Translate("OK - restore line (recommended)") + "\r\n" + Languages.Translate("Cancel - ignore (not recommended)"),Languages.Translate("Error"),Message.MessageStyle.OkCancel); if (mm.result == Message.Result.Ok) button_Reset_CLI_Click(null, null); } }
private void ErrorException(string message, string info) { Message mes = new Message(this); mes.ShowMessage(message, info, Languages.Translate("Error")); }
private void combo_atracks_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (combo_atracks.IsDropDownOpen || combo_atracks.IsSelectionBoxHighlighted) { m.inaudiostream = combo_atracks.SelectedIndex; //передаём активный трек на выход AudioStream instream = (AudioStream)m.inaudiostreams[m.inaudiostream]; //Требуется извлечение звука if (instream.audiopath == null && instream.decoder == 0 && m.inaudiostream > 0) { //FFMS2 и LSMASH умеют переключать треки, для них их можно не извлекать if (!(m.vdecoder == AviSynthScripting.Decoders.FFmpegSource2 && Settings.FFMS_Enable_Audio || ((m.vdecoder == AviSynthScripting.Decoders.LSMASHVideoSource || m.vdecoder == AviSynthScripting.Decoders.LWLibavVideoSource) && Settings.LSMASH_Enable_Audio))) { string outext = Format.GetValidRAWAudioEXT(instream.codecshort); instream.audiopath = Settings.TempPath + "\\" + m.key + "_" + m.inaudiostream + outext; instream.audiofiles = new string[] { instream.audiopath }; instream = Format.GetValidADecoder(instream); } } textbox_apath.Text = instream.audiopath; //перезабиваем поток на выход AudioStream stream = new AudioStream(); m.outaudiostreams.Clear(); if (Settings.ApplyDelay) stream.delay = instream.delay; m.outaudiostreams.Add(stream); AudioStream outstream = (AudioStream)m.outaudiostreams[m.outaudiostream]; //забиваем аудио настройки outstream.encoding = Settings.GetAEncodingPreset(Settings.FormatOut); outstream.codec = PresetLoader.GetACodec(m.format, outstream.encoding); outstream.passes = PresetLoader.GetACodecPasses(m); m = Format.GetValidSamplerate(m); //определяем битность m = Format.GetValidBits(m); //определяем колличество каналов m = Format.GetValidChannelsConverter(m); m = Format.GetValidChannels(m); //проверяем можно ли копировать данный формат if (outstream.codec == "Copy") { //AudioStream instream = (AudioStream)m.inaudiostreams[m.inaudiostream]; outstream.audiopath = instream.audiopath; outstream.bitrate = instream.bitrate; string CopyProblems = Format.ValidateCopyAudio(m); if (CopyProblems != null) { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("The stream contains parameters incompatible with this format") + " " + Format.EnumToString(m.format) + ": " + CopyProblems + "." + Environment.NewLine + Languages.Translate("(You see this message because audio encoder = Copy)"), Languages.Translate("Warning")); } } else { string aext = Format.GetValidRAWAudioEXT(outstream.codec); outstream.audiopath = Settings.TempPath + "\\" + m.key + aext; } SetAudioOptions(); SetInfo(); } }
private void button_remove_Click(object sender, System.Windows.RoutedEventArgs e) { if (m.outvcodec == "Copy") return; if (combo_profile.Items.Count > 1) { UpdateMassive(); Message mess = new Message(this); mess.ShowMessage(Languages.Translate("Do you realy want to remove profile") + " \"" + m.vencoding + "\"?", Languages.Translate("Question"), Message.MessageStyle.YesNo); if (mess.result == Message.Result.Yes) { int last_num = combo_profile.SelectedIndex; string profile_path = Calculate.StartupPath + "\\presets\\encoding\\" + Format.EnumToString(m.format) + "\\video\\" + m.vencoding + ".txt"; try { File.Delete(profile_path); } catch (Exception ex) { new Message(this).ShowMessage(Languages.Translate("Can`t delete profile") + ": " + ex.Message, Languages.Translate("Error"), Message.MessageStyle.Ok); return; } //загружаем список пресетов combo_profile.Items.Clear(); try { foreach (string file in Calculate.GetSortedFiles(Calculate.StartupPath + "\\presets\\encoding\\" + Format.EnumToString(m.format) + "\\video", "*.txt")) combo_profile.Items.Add(Path.GetFileNameWithoutExtension(file)); } catch { } combo_profile.Items.Add("Copy"); //прописываем текущий пресет кодирования if (last_num == 0) { //Самый первый пресет m.vencoding = combo_profile.Items[0].ToString(); } else { //Предыдущий (перед удалённым) пресет m.vencoding = combo_profile.Items[last_num - 1].ToString(); } combo_profile.SelectedItem = m.vencoding; combo_profile.UpdateLayout(); RefreshCodecProfileWindow(); UpdateOutSize(); UpdateCodecMassive(); LoadProfileToCodec(); //проверяем можно ли копировать данный формат if (m.outvcodec == "Copy") { string CopyProblems = Format.ValidateCopyVideo(m); if (CopyProblems != null) { new Message(this).ShowMessage(Languages.Translate("The stream contains parameters incompatible with this format") + " " + Format.EnumToString(m.format) + ": " + CopyProblems + "." + Environment.NewLine + Languages.Translate("(You see this message because video encoder = Copy)"), Languages.Translate("Warning")); } } } } else { new Message(this).ShowMessage(Languages.Translate("Not allowed removing the last profile!"), Languages.Translate("Warning"), Message.MessageStyle.Ok); } }
private void button_remove_Click(object sender, System.Windows.RoutedEventArgs e) //кнопка "удалить профиль" { if (m.sbc == "Disabled") { return; } if (combo_profile.Items.Count > 1) { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("Do you realy want to remove profile") + " \"" + m.sbc + "\"?", Languages.Translate("Question"), Message.MessageStyle.YesNo); if (mess.result == Message.Result.Yes) { int last_num = combo_profile.SelectedIndex; string profile_path = Calculate.StartupPath + "\\presets\\sbc\\" + m.sbc + ".avs"; try { File.Delete(profile_path); } catch (Exception ex) { new Message(this).ShowMessage(Languages.Translate("Can`t delete profile") + ": " + ex.Message, Languages.Translate("Error"), Message.MessageStyle.Ok); return; } //загружаем список фильтров combo_profile.Items.Clear(); combo_profile.Items.Add("Disabled"); try { foreach (string file in Calculate.GetSortedFiles(Calculate.StartupPath + "\\presets\\sbc", "*.avs")) { combo_profile.Items.Add(Path.GetFileNameWithoutExtension(file)); } } catch { } //прописываем текущий пресет кодирования if (last_num == 0) { m.sbc = combo_profile.Items[0].ToString(); } else { m.sbc = combo_profile.Items[last_num - 1].ToString(); } combo_profile.SelectedItem = m.sbc; combo_profile.UpdateLayout(); DecodeProfile(m); LoadFromProfile(); Refresh(); } } else { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("Not allowed removing the last profile!"), Languages.Translate("Warning"), Message.MessageStyle.Ok); } }
private void ShowMessage(string data) { if (!Application.Current.Dispatcher.CheckAccess()) Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new MessageDelegate(ShowMessage), data); else { Message mes = new Message(this.Owner); mes.ShowMessage(data, Languages.Translate("Error")); } }
private void menu_demux_video_Click(object sender, System.Windows.RoutedEventArgs e) { if (m == null) return; if (!m.isvideo) { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("File doesn`t have video streams!"), Languages.Translate("Error")); } else { string ext = Format.GetValidRAWVideoEXT(m); System.Windows.Forms.SaveFileDialog o = new System.Windows.Forms.SaveFileDialog(); o.Filter = ext.ToUpper() + " " + Languages.Translate("Video").ToLower() + Languages.Translate("files") + "|*." + ext; o.Title = Languages.Translate("Select output file") + ":"; o.FileName = Path.GetFileNameWithoutExtension(m.infilepath) + "." + ext; if (o.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (o.FileName == m.infilepath) { ErrorException(Languages.Translate("Select another name for output file!")); return; } Demuxer dem = new Demuxer(m, Demuxer.DemuxerMode.ExtractVideo, o.FileName); if (dem.IsErrors) { new Message(this).ShowMessage(dem.error_message, Languages.Translate("Error"), Message.MessageStyle.Ok); } } } }
private void menu_detect_interlace_Click(object sender, System.Windows.RoutedEventArgs e) { if (m == null) return; if (!m.isvideo) { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("File doesn`t have video streams!"), Languages.Translate("Error")); } else { if (m.outvcodec == "Copy") { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("Can`t change parameters in COPY mode!"), Languages.Translate("Error")); } else { SourceDetector sd = new SourceDetector(m); if (sd.m != null) { DeinterlaceType olddeint = m.deinterlace; FieldOrder oldfo = m.fieldOrder; SourceType olditype = m.interlace; m = sd.m.Clone(); if (m.deinterlace != olddeint || m.fieldOrder != oldfo || m.interlace != olditype) { m = Format.GetOutInterlace(m); m = AviSynthScripting.CreateAutoAviSynthScript(m); m = Calculate.UpdateOutFrames(m); LoadVideo(MediaLoad.update); UpdateTaskMassive(m); } } } } }
private void menu_demux_Click(object sender, System.Windows.RoutedEventArgs e) { if (m == null) return; if (m.inaudiostreams.Count == 0) { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("File doesn`t have audio streams!"), Languages.Translate("Error")); } else { AudioStream instream = (AudioStream)m.inaudiostreams[m.inaudiostream]; System.Windows.Forms.SaveFileDialog o = new System.Windows.Forms.SaveFileDialog(); o.Filter = instream.codecshort + " " + Languages.Translate("files") + "|*." + instream.codecshort.ToLower(); o.Title = Languages.Translate("Select output file") + ":"; o.FileName = Path.GetFileNameWithoutExtension(m.infilepath) + Format.GetValidRAWAudioEXT(instream.codecshort); if (o.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (o.FileName == m.infilepath) { ErrorException(Languages.Translate("Select another name for output file!")); return; } Demuxer dem = new Demuxer(m, Demuxer.DemuxerMode.ExtractAudio, o.FileName); if (dem.IsErrors) { new Message(this).ShowMessage(dem.error_message, Languages.Translate("Error"), Message.MessageStyle.Ok); } } } }
private void AddExternalTrack(string infilepath) { //получаем медиа информацию MediaInfoWrapper mi = null; FFInfo ff = null; try { AudioStream stream = null; int old_stream = 0; string ext = Path.GetExtension(infilepath).ToLower(); if (ext != ".avs" && ext != ".grf") { mi = new MediaInfoWrapper(); stream = mi.GetAudioInfoFromAFile(infilepath, false); stream.mi_order = mi.ATrackOrder(0); stream.mi_id = mi.ATrackID(0); ff = new FFInfo(); ff.Open(infilepath); //Аналогично тому, как сделано в Informer'е if (ff.AudioStreams().Count > 0) { stream.ff_order = ff.FirstAudioStreamID(); stream.ff_order_filtered = ff.FilteredStreamOrder(stream.ff_order); if (stream.mi_order < 0) { stream.mi_order = stream.ff_order; } if (stream.bitrate == 0) { stream.bitrate = ff.AudioBitrate(stream.ff_order); } if (stream.channels == 0) { stream.channels = ff.StreamChannels(stream.ff_order); } if (stream.samplerate == null) { stream.samplerate = ff.StreamSamplerate(stream.ff_order); } if (stream.language == "Unknown") { stream.language = ff.StreamLanguage(stream.ff_order); } stream.ff_bits = ff.StreamBits(stream.ff_order); //if (stream.bits == 0) stream.bits = stream.ff_bits; stream.ff_codec = ff.StreamCodec(stream.ff_order); if (stream.codec == "A_MS/ACM" || stream.codec == "") { stream.codec = stream.ff_codec; stream.codecshort = ff.StreamCodecShort(stream.ff_order); } } } else { stream = new AudioStream(); stream.audiopath = infilepath; stream.audiofiles = new string[] { stream.audiopath }; stream.codec = stream.codecshort = "PCM"; stream.language = "Unknown"; } //Добавляем этот трек old_stream = m.inaudiostream; stream = Format.GetValidADecoder(stream); m.inaudiostream = m.inaudiostreams.Count; m.inaudiostreams.Add(stream.Clone()); //Оставшаяся инфа + ошибки Caching cach = new Caching(m, true); if (cach.m == null) { //Удаляем этот трек m.inaudiostream = old_stream; m.inaudiostreams.RemoveAt(m.inaudiostreams.Count - 1); return; } m = cach.m.Clone(); textbox_apath.Text = infilepath; //разрешаем формы group_channels.IsEnabled = true; group_delay.IsEnabled = true; group_samplerate.IsEnabled = true; group_volume.IsEnabled = true; //прописываем в список внешний трек ComboBoxItem item = new ComboBoxItem(); stream = (AudioStream)m.inaudiostreams[m.inaudiostream]; //Переопределяем с новыми параметрами item.Content = (combo_atracks.Items.Count + 1).ToString("00") + ". " + stream.language + " " + stream.codecshort + " " + stream.channels + "ch"; item.ToolTip = item.Content + " " + stream.samplerate + "Hz " + stream.bitrate + "kbps " + stream.delay + "ms"; combo_atracks.Items.Add(item); combo_atracks.SelectedIndex = combo_atracks.Items.Count - 1; } catch (Exception ex) { ErrorException("AddExternalTrack: " + ex.Message, ex.StackTrace); return; } finally { if (mi != null) { mi.Close(); mi = null; } if (ff != null) { ff.Close(); ff = null; } } AudioStream newstream = new AudioStream(); m.outaudiostreams.Clear(); m.outaudiostreams.Add(newstream); AudioStream outstream = (AudioStream)m.outaudiostreams[m.outaudiostream]; //забиваем аудио настройки outstream.encoding = Settings.GetAEncodingPreset(Settings.FormatOut); outstream.codec = PresetLoader.GetACodec(m.format, outstream.encoding); outstream.passes = PresetLoader.GetACodecPasses(m); m = Format.GetValidSamplerate(m); //определяем битность m = Format.GetValidBits(m); //определяем колличество каналов m = Format.GetValidChannelsConverter(m); m = Format.GetValidChannels(m); //проверяем можно ли копировать данный формат if (outstream.codec == "Copy") { AudioStream instream = (AudioStream)m.inaudiostreams[m.inaudiostream]; outstream.audiopath = instream.audiopath; outstream.bitrate = instream.bitrate; string CopyProblems = Format.ValidateCopyAudio(m); if (CopyProblems != null) { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("The stream contains parameters incompatible with this format") + " " + Format.EnumToString(m.format) + ": " + CopyProblems + "." + Environment.NewLine + Languages.Translate("(You see this message because audio encoder = Copy)"), Languages.Translate("Warning")); } } else { string aext = Format.GetValidRAWAudioEXT(outstream.codec); outstream.audiopath = Settings.TempPath + "\\" + m.key + aext; } SetAudioOptions(); SetInfo(); }
private void combo_atracks_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (combo_atracks.IsDropDownOpen || combo_atracks.IsSelectionBoxHighlighted) { m.inaudiostream = combo_atracks.SelectedIndex; //передаём активный трек на выход AudioStream instream = (AudioStream)m.inaudiostreams[m.inaudiostream]; //Требуется извлечение звука if (instream.audiopath == null && instream.decoder == 0 && m.inaudiostream > 0) { //FFMS2 и LSMASH умеют переключать треки, для них их можно не извлекать if (!(m.vdecoder == AviSynthScripting.Decoders.FFmpegSource2 && Settings.FFMS_Enable_Audio || ((m.vdecoder == AviSynthScripting.Decoders.LSMASHVideoSource || m.vdecoder == AviSynthScripting.Decoders.LWLibavVideoSource) && Settings.LSMASH_Enable_Audio))) { string outext = Format.GetValidRAWAudioEXT(instream.codecshort); instream.audiopath = Settings.TempPath + "\\" + m.key + "_" + m.inaudiostream + outext; instream.audiofiles = new string[] { instream.audiopath }; instream = Format.GetValidADecoder(instream); } } textbox_apath.Text = instream.audiopath; //перезабиваем поток на выход AudioStream stream = new AudioStream(); m.outaudiostreams.Clear(); if (Settings.ApplyDelay) { stream.delay = instream.delay; } m.outaudiostreams.Add(stream); AudioStream outstream = (AudioStream)m.outaudiostreams[m.outaudiostream]; //забиваем аудио настройки outstream.encoding = Settings.GetAEncodingPreset(Settings.FormatOut); outstream.codec = PresetLoader.GetACodec(m.format, outstream.encoding); outstream.passes = PresetLoader.GetACodecPasses(m); m = Format.GetValidSamplerate(m); //определяем битность m = Format.GetValidBits(m); //определяем колличество каналов m = Format.GetValidChannelsConverter(m); m = Format.GetValidChannels(m); //проверяем можно ли копировать данный формат if (outstream.codec == "Copy") { //AudioStream instream = (AudioStream)m.inaudiostreams[m.inaudiostream]; outstream.audiopath = instream.audiopath; outstream.bitrate = instream.bitrate; string CopyProblems = Format.ValidateCopyAudio(m); if (CopyProblems != null) { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("The stream contains parameters incompatible with this format") + " " + Format.EnumToString(m.format) + ": " + CopyProblems + "." + Environment.NewLine + Languages.Translate("(You see this message because audio encoder = Copy)"), Languages.Translate("Warning")); } } else { string aext = Format.GetValidRAWAudioEXT(outstream.codec); outstream.audiopath = Settings.TempPath + "\\" + m.key + aext; } SetAudioOptions(); SetInfo(); } }
private void button_remove_Click(object sender, System.Windows.RoutedEventArgs e) { if (m.outvcodec == "Copy") { return; } if (combo_profile.Items.Count > 1) { UpdateMassive(); Message mess = new Message(this); mess.ShowMessage(Languages.Translate("Do you realy want to remove profile") + " \"" + m.vencoding + "\"?", Languages.Translate("Question"), Message.MessageStyle.YesNo); if (mess.result == Message.Result.Yes) { int last_num = combo_profile.SelectedIndex; string profile_path = Calculate.StartupPath + "\\presets\\encoding\\" + Format.EnumToString(m.format) + "\\video\\" + m.vencoding + ".txt"; try { File.Delete(profile_path); } catch (Exception ex) { new Message(this).ShowMessage(Languages.Translate("Can`t delete profile") + ": " + ex.Message, Languages.Translate("Error"), Message.MessageStyle.Ok); return; } //загружаем список пресетов combo_profile.Items.Clear(); try { foreach (string file in Calculate.GetSortedFiles(Calculate.StartupPath + "\\presets\\encoding\\" + Format.EnumToString(m.format) + "\\video", "*.txt")) { combo_profile.Items.Add(Path.GetFileNameWithoutExtension(file)); } } catch { } combo_profile.Items.Add("Copy"); //прописываем текущий пресет кодирования if (last_num == 0) { //Самый первый пресет m.vencoding = combo_profile.Items[0].ToString(); } else { //Предыдущий (перед удалённым) пресет m.vencoding = combo_profile.Items[last_num - 1].ToString(); } combo_profile.SelectedItem = m.vencoding; combo_profile.UpdateLayout(); RefreshCodecProfileWindow(); UpdateOutSize(); UpdateCodecMassive(); LoadProfileToCodec(); //проверяем можно ли копировать данный формат if (m.outvcodec == "Copy") { string CopyProblems = Format.ValidateCopyVideo(m); if (CopyProblems != null) { new Message(this).ShowMessage(Languages.Translate("The stream contains parameters incompatible with this format") + " " + Format.EnumToString(m.format) + ": " + CopyProblems + "." + Environment.NewLine + Languages.Translate("(You see this message because video encoder = Copy)"), Languages.Translate("Warning")); } } } } else { new Message(this).ShowMessage(Languages.Translate("Not allowed removing the last profile!"), Languages.Translate("Warning"), Message.MessageStyle.Ok); } }
private void button_start_Click(object sender, RoutedEventArgs e) { if (worker != null && worker.IsBusy) { if (!IsPaused) { locker.Reset(); IsPaused = true; button_start.Content = Languages.Translate("Resume"); Win7Taskbar.SetProgressState(ActiveHandle, TBPF.PAUSED); } else { locker.Set(); IsPaused = false; button_start.Content = Languages.Translate("Pause"); Win7Taskbar.SetProgressState(ActiveHandle, TBPF.NORMAL); } } else { if (textbox_infile.Text != "" && File.Exists(textbox_infile.Text) && textbox_outfile.Text != "") { //запоминаем переменные infile = textbox_infile.Text; outfile = textbox_outfile.Text; command_line = text_cli.Text; if (File.Exists(outfile)) { //Такой файл уже есть! Message mes = new Message(this); mes.ShowMessage(Languages.Translate("File \"file_name\" already exists! Overwrite?").Replace("file_name", Path.GetFileName(outfile)), Languages.Translate("Question"), Message.MessageStyle.YesNo); if (mes.result == Message.Result.Yes) { SafeDelete(outfile); } else { System.Windows.Forms.SaveFileDialog s = new System.Windows.Forms.SaveFileDialog(); s.AddExtension = true; s.SupportMultiDottedExtensions = true; s.Title = Languages.Translate("Select unique name for output file:"); s.FileName = outfile; s.Filter = Path.GetExtension(outfile).ToUpper().Replace(".", "") + " " + Languages.Translate("files") + "|*" + Path.GetExtension(outfile); if (s.ShowDialog() == System.Windows.Forms.DialogResult.OK) { textbox_outfile.Text = outfile = s.FileName; SafeDelete(outfile); } else return; } } //Сброс Finished = -1; textbox_log.Clear(); tabs.SelectedIndex = 1; IsErrors = IsAborted = IsPaused = false; button_play.Visibility = Visibility.Collapsed; button_start.Content = Languages.Translate("Pause"); Win7Taskbar.SetProgressState(ActiveHandle, TBPF.NOPROGRESS); //NORMAL this.IsVisibleChanged += new DependencyPropertyChangedEventHandler(FFRebuilder_IsVisibleChanged); //фоновое кодирование CreateBackgroundWorker(); worker.RunWorkerAsync(); } } }
private void menu_fix_AVCHD_Click(object sender, RoutedEventArgs e) { try { System.Windows.Forms.FolderBrowserDialog f = new System.Windows.Forms.FolderBrowserDialog(); f.Description = Languages.Translate("Select AVCHD folder") + ":"; f.ShowNewFolderButton = false; string rootpath = Settings.AVCHD_PATH; if (rootpath != null && Directory.Exists(rootpath)) f.SelectedPath = rootpath; if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Settings.AVCHD_PATH = f.SelectedPath; int fixedfiles = Calculate.MakeFAT32BluRay(f.SelectedPath); if (fixedfiles != 0) { Message mes = new Message(this); mes.ShowMessage(Languages.Translate("All file names fixed!"), "AVCHD"); } else { Message mes = new Message(this); mes.ShowMessage(Languages.Translate("Can`t find files for fixing!"), Languages.Translate("Error")); } } } catch (Exception ex) { ErrorException(ex.Message); } }
private void ErrorException(string data, string info) { if (!Application.Current.Dispatcher.CheckAccess()) Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new ErrorExceptionDelegate(ErrorException), data, info); else { Message mes = new Message(this.IsLoaded ? this : Owner); mes.ShowMessage(data, info, Languages.Translate("Error"), Message.MessageStyle.Ok); } }
private void menu_interlace_Click(object sender, System.Windows.RoutedEventArgs e) { if (m == null) new Interlace(null, this); else if (m.format == Format.ExportFormats.Audio) { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("File doesn`t have video streams!"), Languages.Translate("Error")); } else { if (m.outvcodec == "Copy") { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("Can`t change parameters in COPY mode!"), Languages.Translate("Error")); } else { Interlace inter = new Interlace(m, this); if (inter.m == null) return; DeinterlaceType olddeint = m.deinterlace; FieldOrder oldfo = m.fieldOrder; SourceType olditype = m.interlace; string oldframerate = m.outframerate; m = inter.m.Clone(); if (m.deinterlace != olddeint || m.fieldOrder != oldfo || m.interlace != olditype || m.outframerate != oldframerate) { m = AviSynthScripting.CreateAutoAviSynthScript(m); m = Calculate.UpdateOutFrames(m); LoadVideo(MediaLoad.update); UpdateTaskMassive(m); } } } }
private void VideoEncodingSettings_Click(object sender, System.Windows.RoutedEventArgs e) { if (m != null && m.format == Format.ExportFormats.Audio) { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("File doesn`t have video streams!"), Languages.Translate("Error")); } else if (!(m == null && Settings.FormatOut == Format.ExportFormats.Audio)) { VideoEncoding enc = new VideoEncoding(m, this); if (m != null) m = enc.m.Clone(); Format.ExportFormats format = enc.m.format; string vencoding = enc.m.vencoding; LoadVideoPresets(); //защита от удаления профиля if (!combo_vencoding.Items.Contains(vencoding)) vencoding = ChooseVideoPreset(format); combo_vencoding.SelectedItem = vencoding; Settings.SetVEncodingPreset(format, vencoding); if (m != null) { //проверка на размер //m.outfilesize = Calculate.GetEncodingSize(m); UpdateTaskMassive(m); ValidateTrimAndCopy(m); } } }
private void menu_savethm_Click(object sender, RoutedEventArgs e) { if (m == null) return; else if (!m.isvideo) { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("File doesn`t have video streams!"), Languages.Translate("Error")); } else { try { System.Windows.Forms.SaveFileDialog s = new System.Windows.Forms.SaveFileDialog(); s.AddExtension = true; //s.SupportMultiDottedExtensions = true; s.Title = Languages.Translate("Select unique name for output file:"); int thm_w = 0, thm_h = 0; bool fix_ar = false; if (m.format == Format.ExportFormats.PmpAvc) { thm_w = 144; thm_h = 80; fix_ar = true; s.Filter = "PNG " + Languages.Translate("files") + "|*.png"; s.FileName = Path.GetFileNameWithoutExtension(m.infilepath) + ".png"; } else if (Formats.GetDefaults(m.format).IsEditable) { string thm_def = Formats.GetDefaults(m.format).THM_Format; string thm_format = Formats.GetSettings(m.format, "THM_Format", thm_def); if (thm_format != "JPG" && thm_format != "PNG" && thm_format != "BMP" && thm_format != "None") thm_format = thm_def; if (thm_format != "None") { s.Filter = thm_format.Replace("JPG", "JPEG") + " " + Languages.Translate("files") + "|*." + thm_format.ToLower(); s.FileName = Path.GetFileNameWithoutExtension(m.infilepath) + "." + thm_format.ToLower(); } else { s.FileName = Path.GetFileNameWithoutExtension(m.infilepath); s.Filter = "PNG " + Languages.Translate("files") + "|*.png" + "|JPEG " + Languages.Translate("files") + "|*.jpg" + "|BMP " + Languages.Translate("files") + "|*.bmp"; } fix_ar = Formats.GetSettings(m.format, "THM_FixAR", Formats.GetDefaults(m.format).THM_FixAR); thm_w = Formats.GetSettings(m.format, "THM_Width", Formats.GetDefaults(m.format).THM_Width); thm_h = Formats.GetSettings(m.format, "THM_Height", Formats.GetDefaults(m.format).THM_Height); if (thm_w == 0) thm_w = m.outresw; if (thm_h == 0) thm_h = m.outresh; } else { thm_w = 0; thm_h = 0; fix_ar = false; s.FileName = Path.GetFileNameWithoutExtension(m.infilepath); s.Filter = "PNG " + Languages.Translate("files") + "|*.png" + "|JPEG " + Languages.Translate("files") + "|*.jpg" + "|BMP " + Languages.Translate("files") + "|*.bmp"; } if (s.ShowDialog() == System.Windows.Forms.DialogResult.OK) { SavePicture(s.FileName, thm_w, thm_h, fix_ar, Convert.ToInt32(Math.Round(Position.TotalSeconds * fps))); } } catch (Exception ex) { ErrorException("SaveTHM: " + ex.Message, ex.StackTrace); } } }
private void AddExternalTrack(string infilepath) { //получаем медиа информацию MediaInfoWrapper mi = null; FFInfo ff = null; try { AudioStream stream = null; int old_stream = 0; string ext = Path.GetExtension(infilepath).ToLower(); if (ext != ".avs" && ext != ".grf") { mi = new MediaInfoWrapper(); stream = mi.GetAudioInfoFromAFile(infilepath, false); stream.mi_order = mi.ATrackOrder(0); stream.mi_id = mi.ATrackID(0); ff = new FFInfo(); ff.Open(infilepath); //Аналогично тому, как сделано в Informer'е if (ff.AudioStreams().Count > 0) { stream.ff_order = ff.FirstAudioStreamID(); stream.ff_order_filtered = ff.FilteredStreamOrder(stream.ff_order); if (stream.mi_order < 0) stream.mi_order = stream.ff_order; if (stream.bitrate == 0) stream.bitrate = ff.AudioBitrate(stream.ff_order); if (stream.channels == 0) stream.channels = ff.StreamChannels(stream.ff_order); if (stream.samplerate == null) stream.samplerate = ff.StreamSamplerate(stream.ff_order); if (stream.language == "Unknown") stream.language = ff.StreamLanguage(stream.ff_order); stream.ff_bits = ff.StreamBits(stream.ff_order); //if (stream.bits == 0) stream.bits = stream.ff_bits; stream.ff_codec = ff.StreamCodec(stream.ff_order); if (stream.codec == "A_MS/ACM" || stream.codec == "") { stream.codec = stream.ff_codec; stream.codecshort = ff.StreamCodecShort(stream.ff_order); } } } else { stream = new AudioStream(); stream.audiopath = infilepath; stream.audiofiles = new string[] { stream.audiopath }; stream.codec = stream.codecshort = "PCM"; stream.language = "Unknown"; } //Добавляем этот трек old_stream = m.inaudiostream; stream = Format.GetValidADecoder(stream); m.inaudiostream = m.inaudiostreams.Count; m.inaudiostreams.Add(stream.Clone()); //Оставшаяся инфа + ошибки Caching cach = new Caching(m, true); if (cach.m == null) { //Удаляем этот трек m.inaudiostream = old_stream; m.inaudiostreams.RemoveAt(m.inaudiostreams.Count - 1); return; } m = cach.m.Clone(); textbox_apath.Text = infilepath; //разрешаем формы group_channels.IsEnabled = true; group_delay.IsEnabled = true; group_samplerate.IsEnabled = true; group_volume.IsEnabled = true; //прописываем в список внешний трек ComboBoxItem item = new ComboBoxItem(); stream = (AudioStream)m.inaudiostreams[m.inaudiostream]; //Переопределяем с новыми параметрами item.Content = (combo_atracks.Items.Count + 1).ToString("00") + ". " + stream.language + " " + stream.codecshort + " " + stream.channels + "ch"; item.ToolTip = item.Content + " " + stream.samplerate + "Hz " + stream.bitrate + "kbps " + stream.delay + "ms"; combo_atracks.Items.Add(item); combo_atracks.SelectedIndex = combo_atracks.Items.Count - 1; } catch (Exception ex) { ErrorException("AddExternalTrack: " + ex.Message, ex.StackTrace); return; } finally { if (mi != null) { mi.Close(); mi = null; } if (ff != null) { ff.Close(); ff = null; } } AudioStream newstream = new AudioStream(); m.outaudiostreams.Clear(); m.outaudiostreams.Add(newstream); AudioStream outstream = (AudioStream)m.outaudiostreams[m.outaudiostream]; //забиваем аудио настройки outstream.encoding = Settings.GetAEncodingPreset(Settings.FormatOut); outstream.codec = PresetLoader.GetACodec(m.format, outstream.encoding); outstream.passes = PresetLoader.GetACodecPasses(m); m = Format.GetValidSamplerate(m); //определяем битность m = Format.GetValidBits(m); //определяем колличество каналов m = Format.GetValidChannelsConverter(m); m = Format.GetValidChannels(m); //проверяем можно ли копировать данный формат if (outstream.codec == "Copy") { AudioStream instream = (AudioStream)m.inaudiostreams[m.inaudiostream]; outstream.audiopath = instream.audiopath; outstream.bitrate = instream.bitrate; string CopyProblems = Format.ValidateCopyAudio(m); if (CopyProblems != null) { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("The stream contains parameters incompatible with this format") + " " + Format.EnumToString(m.format) + ": " + CopyProblems + "." + Environment.NewLine + Languages.Translate("(You see this message because audio encoder = Copy)"), Languages.Translate("Warning")); } } else { string aext = Format.GetValidRAWAudioEXT(outstream.codec); outstream.audiopath = Settings.TempPath + "\\" + m.key + aext; } SetAudioOptions(); SetInfo(); }
private void menu_save_frame_Click(object sender, RoutedEventArgs e) { if (m == null) return; else if (!m.isvideo) { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("File doesn`t have video streams!"), Languages.Translate("Error")); } else { try { System.Windows.Forms.SaveFileDialog s = new System.Windows.Forms.SaveFileDialog(); s.SupportMultiDottedExtensions = true; s.DefaultExt = ".png"; s.AddExtension = true; s.Title = Languages.Translate("Select unique name for output file:"); s.Filter = "PNG " + Languages.Translate("files") + "|*.png" + "|JPEG " + Languages.Translate("files") + "|*.jpg" + "|BMP " + Languages.Translate("files") + "|*.bmp"; int frame = Convert.ToInt32(Math.Round(Position.TotalSeconds * fps)); s.FileName = Path.GetFileNameWithoutExtension(m.infilepath) + " - [" + frame + "]"; if (s.ShowDialog() == System.Windows.Forms.DialogResult.OK) { SavePicture(s.FileName, 0, 0, false, frame); } } catch (Exception ex) { ErrorException("SaveFrame: " + ex.Message, ex.StackTrace); } } }
private void combo_samplerate_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (combo_samplerate.IsDropDownOpen || combo_samplerate.IsSelectionBoxHighlighted) { AudioStream instream = (AudioStream)m.inaudiostreams[m.inaudiostream]; AudioStream outstream = (AudioStream)m.outaudiostreams[m.outaudiostream]; outstream.samplerate = Calculate.GetSplittedString(combo_samplerate.SelectedItem.ToString(), 0); AviSynthScripting.SamplerateModifers oldс = m.sampleratemodifer; m = Format.GetValidSamplerateModifer(m); if (oldс != m.sampleratemodifer) { Message message = new Message(this); message.ShowMessage(Languages.Translate("SSRC can`t convert") + ": " + instream.samplerate + " > " + outstream.samplerate + "!", Languages.Translate("Warning"), Message.MessageStyle.Ok); combo_converter.SelectedValue = m.sampleratemodifer; } SetInfo(); } }
private void mnAddSubtitles_Click(object sender, System.Windows.RoutedEventArgs e) { if (m != null) { if (m.format == Format.ExportFormats.Audio) { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("File doesn`t have video streams!"), Languages.Translate("Error")); } else { string infilepath = null; ArrayList files = OpenDialogs.GetFilesFromConsole("sub"); if (files.Count > 0) infilepath = files[0].ToString(); if (infilepath != null) { m.subtitlepath = infilepath; //создаём новый AviSynth скрипт m = AviSynthScripting.CreateAutoAviSynthScript(m); //загружаем обновлённый скрипт LoadVideo(MediaLoad.update); UpdateTaskMassive(m); } } } }
public static string SaveDialog(Massive m) { //для форматов с выводом в папку if (m.format == Format.ExportFormats.BluRay) { System.Windows.Forms.FolderBrowserDialog folder = new System.Windows.Forms.FolderBrowserDialog(); folder.Description = Languages.Translate("Select folder for BluRay files:"); folder.ShowNewFolderButton = true; if (Settings.BluRayPath != null && Directory.Exists(Settings.BluRayPath)) folder.SelectedPath = Settings.BluRayPath; if (folder.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Settings.BluRayPath = folder.SelectedPath; //проверяем есть ли файлы в папке if (Calculate.GetFolderSize(folder.SelectedPath) != 0) { Message mess = new Message(App.Current.MainWindow); mess.ShowMessage(Languages.Translate("Folder already have files! Do you want replace files ?") , Languages.Translate("Path") + ": " + folder.SelectedPath, Message.MessageStyle.YesNo); if (mess.result == Message.Result.No) return null; } return folder.SelectedPath; } else return null; } //для файловых форматов else { SaveFileDialog s = new SaveFileDialog(); s.AddExtension = true; s.SupportMultiDottedExtensions = true; s.Title = Languages.Translate("Select unique name for output file:"); s.DefaultExt = "." + Format.GetValidExtension(m); s.FileName = m.taskname + Format.GetValidExtension(m); s.Filter = Format.GetValidExtension(m).Replace(".", "").ToUpper() + " " + Languages.Translate("files") + "|*" + Format.GetValidExtension(m); if (s.ShowDialog() == DialogResult.OK) { string ext = Path.GetExtension(s.FileName).ToLower(); if (!s.DefaultExt.StartsWith(".")) s.DefaultExt = "." + s.DefaultExt; if (ext != s.DefaultExt) s.FileName += s.DefaultExt; return s.FileName; } else return null; } }
private void mnRemoveSubtitles_Click(object sender, System.Windows.RoutedEventArgs e) { if (m != null) { if (m.subtitlepath != null) { m.subtitlepath = null; //создаём новый AviSynth скрипт m = AviSynthScripting.CreateAutoAviSynthScript(m); //загружаем обновлённый скрипт LoadVideo(MediaLoad.update); UpdateTaskMassive(m); } else { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("Nothing for remove!"), Languages.Translate("Error")); } } }
public FormatSettings(Format.ExportFormats format, MainWindow parent) { this.InitializeComponent(); this.Owner = parent; //Дефолты this.format = format; this.def = Formats.GetDefaults(format); //Включаем\выключаем редактирование //Video textbox_vcodecs.IsEnabled = def.VCodecs_IsEditable; textbox_framerates.IsEnabled = def.Framerates_IsEditable; combo_MinResolutionW.IsEnabled = combo_MinResolutionH.IsEnabled = combo_MidResolutionW.IsEnabled = combo_MidResolutionH.IsEnabled = combo_MaxResolutionW.IsEnabled = combo_MaxResolutionH.IsEnabled = combo_ValidModW.IsEnabled = combo_ValidModH.IsEnabled = def.Resolution_IsEditable; textbox_aspects.IsEnabled = def.Aspects_IsEditable; combo_fix_ar_method.IsEnabled = (def.LockedAR_Methods.Length > 1); check_anamorphic.IsEnabled = def.Anamorphic_IsEditable; check_interlaced.IsEnabled = def.Interlaced_IsEditable; //Audio textbox_acodecs.IsEnabled = def.ACodecs_IsEditable; textbox_samplerates.IsEnabled = def.Samplerates_IsEditable; check_stereo.IsEnabled = def.LimitedToStereo_IsEditable; //Muxing combo_Muxer.IsEnabled = (def.Muxers.Length > 1); combo_Extension.IsEnabled = (def.Extensions.Length > 1); combo_split.IsEnabled = (def.Splitting != "None"); check_dont_mux.IsEnabled = def.DontMuxStreams_IsEditable; check_direct_encoding.IsEnabled = def.DirectEncoding_IsEditable; check_direct_remux.IsEnabled = def.DirectRemuxing_IsEditable; check_4gb_only.IsEnabled = def.LimitedTo4Gb_IsEditable; //Переводим фокус int active_tab = 0; if (int.TryParse(Settings.GetFormatPreset(format, "ActiveTab"), out active_tab)) { if (active_tab == 2) tab_audio.IsSelected = true; else if (active_tab == 3) tab_muxing.IsSelected = true; } LoadSettings(); TranslateItems(); SetTooltips(); //Предупреждение (один раз для каждого формата) if (format != Format.ExportFormats.Custom && !Convert.ToBoolean(Settings.GetFormatPreset(format, "was_warned"))) { Message mes = new Message(parent); mes.ShowMessage(Languages.Translate("Some options or their combinations may not work as you expect!") + "\r\n" + Languages.Translate("After making any changes the format may become completely broken!"), Languages.Translate("Warning"), Message.MessageStyle.Ok); Settings.SetFormatPreset(format, "was_warned", bool.TrueString); } ShowDialog(); }
private void mnResetSettings_Click(object sender, System.Windows.RoutedEventArgs e) { try { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("Do you realy want to reset all settings") + "?" + Environment.NewLine + Languages.Translate("After that the program will be automatically restarted") + "!", Languages.Translate("Warning") + "!", Message.MessageStyle.OkCancel); if (mess.result == Message.Result.Ok) { string lang = Settings.Language; Settings.ResetAllSettings(this); Settings.Language = lang; //Перезапуск Process.Start(Calculate.StartupPath + "\\apps\\Launcher.exe", " 30 \"" + Calculate.StartupPath + "\""); //"30" - время ожидания завершения первой копии XviD4PSP, после чего лаунчер просто завершит свою работу Close(); } } catch (Exception ex) { ErrorException("ResetSettings: " + ex.Message, ex.StackTrace); Close(); } }
public static string GetEncodingSize(Massive m) { string ssize = Languages.Translate("Unknown"); if (m.encodingmode == Settings.EncodingModes.TwoPassSize || m.encodingmode == Settings.EncodingModes.ThreePassSize || m.encodingmode == Settings.EncodingModes.OnePassSize) { if (m.outaudiostreams.Count > 0) { //Мы не можем знать размер если звук = VBR или Copy, но файл еще не извлечен и битрейт неизвестен AudioStream instream = (AudioStream)m.inaudiostreams[m.inaudiostream]; AudioStream outstream = (AudioStream)m.outaudiostreams[m.outaudiostream]; if (outstream.bitrate == 0 && outstream.codec != "Disabled") { //Если звук будет кодироваться первым, то размер звукового файла уже будет известен к моменту начала //кодирования видео (кроме случая DirectRemux для Copy), и его можно будет учесть if (outstream.codec == "Copy" && !(Settings.EncodeAudioFirst && !Format.IsDirectRemuxingPossible(m)) && !File.Exists(instream.audiopath)) { //Copy return ssize; } else if (outstream.codec != "Copy" && !Settings.EncodeAudioFirst) { //VBR return ssize; } } } if (Format.Is4GBlimitedFormat(m) && m.outvbitrate > 4000) { Message mess = new Message(App.Current.MainWindow); mess.ShowMessage(m.outvbitrate + "Mb - " + Languages.Translate("exceed maximum file size for format") + " " + Format.EnumToString(m.format) + "!", Languages.Translate("Warning"), Message.MessageStyle.Ok); } return m.outvbitrate + " mb"; } else if (m.format == Format.ExportFormats.Audio && m.outaudiostreams.Count > 0) { AudioStream outstream = (AudioStream)m.outaudiostreams[m.outaudiostream]; if (outstream.bitrate == 0) return ssize; //"Unknown" для VBR double outsize = (0.125261 * (double)outstream.bitrate * (double)m.outduration.TotalSeconds) / 1052.0 / 0.994; ssize = Calculate.ConvertDoubleToPointString(outsize, 1) + " mb"; } else { if (m.encodingmode == Settings.EncodingModes.OnePass || m.encodingmode == Settings.EncodingModes.TwoPass || m.encodingmode == Settings.EncodingModes.ThreePass) { double outsize = (0.1258 * (double)m.outvbitrate * (double)m.outduration.TotalSeconds) / 1052.0 / 0.994; if (m.outaudiostreams.Count > 0) { //Мы не можем знать размер если звук = VBR или Copy, но файл еще не извлечен и битрейт неизвестен AudioStream instream = (AudioStream)m.inaudiostreams[m.inaudiostream]; AudioStream outstream = (AudioStream)m.outaudiostreams[m.outaudiostream]; if (outstream.codec == "Copy" && File.Exists(instream.audiopath)) outsize += (new FileInfo(instream.audiopath).Length / 1000) / 1052.0 / 0.994; else if (outstream.bitrate == 0 && outstream.codec != "Disabled") return ssize; else outsize += (0.125261 * (double)outstream.bitrate * (double)m.outduration.TotalSeconds) / 1052.0 / 0.994; } //TS M2TS BluRay packet size if (m.format == Format.ExportFormats.M2TS || m.format == Format.ExportFormats.TS) outsize *= 1.03; if (m.format == Format.ExportFormats.BluRay) outsize *= 1.05; ssize = Calculate.ConvertDoubleToPointString(outsize, 1); if (Format.Is4GBlimitedFormat(m) && outsize > 4000) { Message mess = new Message(App.Current.MainWindow); mess.ShowMessage(ssize + "Mb - " + Languages.Translate("exceed maximum file size for format") + " " + Format.EnumToString(m.format) + "!", Languages.Translate("Warning"), Message.MessageStyle.Ok); } ssize += " mb"; } } return ssize; }
//Для открытия и сохранения группы файлов private void MultiOpen(string[] files_to_open) { try { opened_files = 0; //Обнуляем счетчик успешно открытых файлов int count = files_to_open.Length; //Кол-во файлов для открытия //Вывод первичной инфы об открытии textbox_name.Text = count + " - " + Languages.Translate("total files") + ", " + opened_files + " - " + Languages.Translate("opened files") + ", " + outfiles.Count + " - " + Languages.Translate("in queue"); //Делим строку с валидными расширениями на отдельные строчки string[] goodexts = Settings.GoodFilesExtensions.Split(new string[] { "/" }, StringSplitOptions.None); foreach (string file in files_to_open) { string ext = Path.GetExtension(file).ToLower().Replace(".", ""); //Сравниваем расширение текущего файла со всеми строчками с валидными расширениями, и открываем файл при совпадении foreach (string goodext in goodexts) { if (goodext == ext) { Massive x = new Massive(); x.infilepath = file; x.infileslist = new string[] { file }; if (PauseAfterFirst) //Пакетное открытие с паузой после первого файла { ArrayList newArray = new ArrayList(); //Удаляем этот файл из общего списка foreach (string f in files_to_open) { if (f != file) newArray.Add(f); } batch_files = (string[])newArray.ToArray(typeof(string)); action_open(x); if (m == null) { textbox_name.Text = ""; PauseAfterFirst = false; return; } button_save.Content = button_encode.Content = Languages.Translate("Resume"); textbox_name.Text = Languages.Translate("Press Resume to continue batch opening"); return; } IsBatchOpening = true; action_open(x); IsBatchOpening = false; if (m != null) action_auto_save(m.Clone()); break; } } //Обновляем инфу об открытии textbox_name.Text = count + " - " + Languages.Translate("total files") + ", " + opened_files + " - " + Languages.Translate("opened files") + ", " + outfiles.Count + " - " + Languages.Translate("in queue"); } if (m != null && opened_files >= 1) //Если массив не пуст, и если кол-во открытых файлов больше нуля (чтоб не обновлять превью, если ни одного нового файла не открылось) { LoadVideo(MediaLoad.load); } if (Settings.AutoBatchEncoding) EncodeNextTask(); //Запускаем кодирование Message mess = new Message(this); mess.ShowMessage(count + " - " + Languages.Translate("total files in folder") + Environment.NewLine + opened_files + " - " + Languages.Translate("successfully opened files") + Environment.NewLine + outfiles.Count + " - " + Languages.Translate("total tasks in queue"), Languages.Translate("Complete")); if (m != null) textbox_name.Text = m.taskname; else textbox_name.Text = ""; } catch (Exception ex) { ErrorException("MultiOpen: " + ex.Message, ex.StackTrace); } }
private void button_remove_profile_Click(object sender, RoutedEventArgs e) { if (profile == "Default" || combo_profile.Items.Count <= 1) return; Message mess = new Message(this); mess.ShowMessage(Languages.Translate("Do you realy want to remove profile") + " \"" + profile + "\"?", Languages.Translate("Question"), Message.MessageStyle.YesNo); if (mess.result == Message.Result.Yes) { try { File.Delete(Calculate.StartupPath + "\\presets\\ffrebuilder\\" + profile + ".txt"); Settings.FFRebuilder_Profile = profile = "Default"; } catch (Exception ex) { ErrorException(Languages.Translate("Can`t delete profile") + ": " + ex.Message); } LoadAllProfiles(); LoadFromProfile(); UpdateCombosIsEnabled(); } }
private void RemoveSelectedTask() { if (list_tasks.SelectedItem != null) { Task task = (Task)list_tasks.SelectedItem; if (task.Status == TaskStatus.Encoding) { Message mes = new Message(this); mes.ShowMessage(Languages.Translate("The tasks in encoding process are disabled for removal!"), Languages.Translate("Error")); return; } list_tasks.Items.Remove(list_tasks.SelectedItem); if (outfiles.Contains(task.Mass.outfilepath)) outfiles.Remove(task.Mass.outfilepath); UpdateTasksBackup(); } }
private void button_ok_Click(object sender, System.Windows.RoutedEventArgs e) { //Имя нового профиля string name = textbox_profile.Text.Trim(); //Проверка на недопустимые имена if (name == "") return; if (name.ToLower() == "disabled" && (ptype == ProfileType.SBC || ptype == ProfileType.AEncoding || ptype == ProfileType.VEncoding || ptype == ProfileType.Filtering) || name.ToLower() == "default" && ptype == ProfileType.FFRebuilder) { new Message(this).ShowMessage(Languages.Translate("Profile with same name already exists."), Languages.Translate("Error")); return; } string profile_path = ""; if (ptype == ProfileType.VEncoding) profile_path = Calculate.StartupPath + "\\presets\\encoding\\" + format + "\\video\\" + name + ".txt"; else if (ptype == ProfileType.AEncoding) profile_path = Calculate.StartupPath + "\\presets\\encoding\\" + format + "\\audio\\" + name + ".txt"; else if (ptype == ProfileType.SBC) profile_path = Calculate.StartupPath + "\\presets\\sbc\\" + name + ".avs"; else if (ptype == ProfileType.Filtering) profile_path = Calculate.StartupPath + "\\presets\\filtering\\" + name + ".avs"; else if (ptype == ProfileType.FFRebuilder) profile_path = Calculate.StartupPath + "\\presets\\ffrebuilder\\" + name + ".txt"; if (File.Exists(profile_path)) { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("Profile with same name already exists.") + Environment.NewLine + Languages.Translate("Replace profile?"), Languages.Translate("Question"), Message.MessageStyle.YesNo); if (mess.result == Message.Result.No) return; } profile = name; Close(); }
//Проверка темп-папки на наличие в ней файлов public void TempFolderFiles() { try { if (Directory.Exists(Settings.TempPath) && Directory.GetFiles(Settings.TempPath).Length != 0) { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("Selected temp folder is not empty") + " (" + Settings.TempPath.ToString() + ")." + Environment.NewLine + Languages.Translate("You must delete all unnecessary files before start encoding.") + Environment.NewLine + Environment.NewLine + Languages.Translate("OK - open folder to view files, Cancel - ignore this message."), Languages.Translate("Temp folder is not empty"), Message.MessageStyle.OkCancel); if (mess.result == Message.Result.Ok) System.Diagnostics.Process.Start("explorer.exe", Settings.TempPath); } } catch (Exception ex) { ErrorException("CheckTempFolder: " + ex.Message, ex.StackTrace); } }
private void ErrorException(string data, string info) { if (!Application.Current.Dispatcher.CheckAccess()) Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new ErrorExceptionDelegate(ErrorException), data, info); else { IsError = true; if (worker != null) worker.WorkerReportsProgress = false; if (Handle == IntPtr.Zero) Handle = new WindowInteropHelper(this).Handle; Win7Taskbar.SetProgressTaskComplete(Handle, TBPF.ERROR); Message mes = new Message(this.IsLoaded ? this : Owner); mes.ShowMessage(data, info, Languages.Translate("Error"), Message.MessageStyle.Ok); } }
public static string SaveDialog(Massive m) { //для форматов с выводом в папку if (m.format == Format.ExportFormats.BluRay) { System.Windows.Forms.FolderBrowserDialog folder = new System.Windows.Forms.FolderBrowserDialog(); folder.Description = Languages.Translate("Select folder for BluRay files:"); folder.ShowNewFolderButton = true; if (Settings.BluRayPath != null && Directory.Exists(Settings.BluRayPath)) { folder.SelectedPath = Settings.BluRayPath; } if (folder.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Settings.BluRayPath = folder.SelectedPath; //проверяем есть ли файлы в папке if (Calculate.GetFolderSize(folder.SelectedPath) != 0) { Message mess = new Message(App.Current.MainWindow); mess.ShowMessage(Languages.Translate("Folder already have files! Do you want replace files ?") , Languages.Translate("Path") + ": " + folder.SelectedPath, Message.MessageStyle.YesNo); if (mess.result == Message.Result.No) { return(null); } } return(folder.SelectedPath); } else { return(null); } } //для файловых форматов else { SaveFileDialog s = new SaveFileDialog(); s.AddExtension = true; s.SupportMultiDottedExtensions = true; s.Title = Languages.Translate("Select unique name for output file:"); s.DefaultExt = "." + Format.GetValidExtension(m); s.FileName = m.taskname + Format.GetValidExtension(m); s.Filter = Format.GetValidExtension(m).Replace(".", "").ToUpper() + " " + Languages.Translate("files") + "|*" + Format.GetValidExtension(m); if (s.ShowDialog() == DialogResult.OK) { string ext = Path.GetExtension(s.FileName).ToLower(); if (!s.DefaultExt.StartsWith(".")) { s.DefaultExt = "." + s.DefaultExt; } if (ext != s.DefaultExt) { s.FileName += s.DefaultExt; } return(s.FileName); } else { return(null); } } }