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 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 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(); }
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_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(); } }
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 ErrorException(string message, string info) { Message mes = new Message(this); mes.ShowMessage(message, info, Languages.Translate("Error")); }
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); } }
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); } }
public DVDImport(Massive mass, string dvdpath) { this.InitializeComponent(); this.Owner = App.Current.MainWindow; this.m = mass.Clone(); this.dpi = SysInfo.dpi; DDHelper ddh = new DDHelper(this); ddh.GotFiles += new DDEventHandler(DD_GotFiles); //tooltips label_title.Content = Languages.Translate("Select title:"); button_cancel.Content = Languages.Translate("Cancel"); button_ok.Content = Languages.Translate("OK"); button_play.ToolTip = Languages.Translate("Play-Pause"); button_stop.ToolTip = Languages.Translate("Stop"); //events this.Loaded += new RoutedEventHandler(MainWindow_Loaded); this.Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing); this.KeyUp += new KeyEventHandler(MainWindow_KeyUp); //подготавливаем список титлов string[] maintitles = Directory.GetFiles(dvdpath, "VTS_*1.VOB", SearchOption.AllDirectories); int titlescount = maintitles.Length; //если нет ни одного титла if (titlescount == 0) { Message message = new Message(this.Owner); message.ShowMessage(Languages.Translate("Can`t find any VOB file in:") + " \"" + dvdpath + "\"!", Languages.Translate("Error")); m = null; Close(); return; } //сортируем и забиваем вобы в список dvd = new ArrayList(); string[] vobs = new string[] { "" }; for (int n = 0; n < titlescount; n++) { string title = Calculate.GetTitleNum(maintitles[n]); vobs = Directory.GetFiles(dvdpath, "VTS_" + title + "*.VOB", SearchOption.AllDirectories); ArrayList vobs_ar = Calculate.ConvertStringArrayToArrayList(vobs); if (vobs_ar[0].ToString().ToUpper().EndsWith("0.VOB")) vobs_ar.RemoveAt(0); vobs = Calculate.ConvertArrayListToStringArray(vobs_ar); dvd.Add(vobs); } //забиваем и выделяем пустой титл combo_titles.Items.Add(Calculate.GetTimeline(0)); combo_titles.SelectedIndex = 0; Title = "DVD: " + Calculate.GetDVDName(vobs[0]); this.ShowDialog(); }
private void ErrorException(string data, string info) { if (!Application.Current.Dispatcher.CheckAccess()) { MessageBox.Show(data + "\r\n\r\n" + info, Languages.Translate("Error"), MessageBoxButton.OK, MessageBoxImage.Error); } else { Message mes = new Message(this.IsLoaded ? this : Owner); mes.ShowMessage(data, info, Languages.Translate("Error"), Message.MessageStyle.Ok); } }
private void button_remove_Click(object sender, RoutedEventArgs e) { string preset = Settings.Filtering; if (preset == "Disabled") return; if (combo_profile.Items.Count > 1) { Message mess = new Message(this); mess.ShowMessage(Languages.Translate("Do you realy want to remove profile") + " \"" + preset + "\"?", Languages.Translate("Question"), Message.MessageStyle.YesNo); if (mess.result == Message.Result.Yes) { int last_num = combo_profile.SelectedIndex; string profile_path = Calculate.StartupPath + "\\presets\\filtering\\" + preset + ".avs"; try { File.Delete(profile_path); } catch (Exception ex) { ErrorException(Languages.Translate("Can`t delete profile") + ": " + ex.Message, ex.StackTrace); return; } //загружаем список пресетов combo_profile.Items.Clear(); combo_profile.Items.Add("Disabled"); try { foreach (string file in Calculate.GetSortedFiles(Calculate.StartupPath + "\\presets\\filtering", "*.avs")) combo_profile.Items.Add(Path.GetFileNameWithoutExtension(file)); } catch (Exception) { } //прописываем текущий пресет if (last_num == 0) { //Самый первый пресет Settings.Filtering = combo_profile.Items[0].ToString(); } else { //Предыдущий (перед удалённым) пресет Settings.Filtering = combo_profile.Items[last_num - 1].ToString(); } combo_profile.SelectedItem = Settings.Filtering; combo_profile.UpdateLayout(); LoadPreset(); } } else { new Message(this).ShowMessage(Languages.Translate("Not allowed removing the last profile!"), Languages.Translate("Warning"), Message.MessageStyle.Ok); } }
public void Open(string scriptPath) { lock (locker) { try { script = scriptPath; LoadAviSynth(); if (IsError || IsAborted) return; if (HasVideo) { try { //Framework 3.0 с SP1+ CreateInteropBitmap(); } catch (TypeLoadException) { //Framework 3.0 без SP1 CreateWriteableBitmap(); } } if (HasAudio) { SetUpAudioDevice(); } #region ShowPictureViewInfo if (HasVideo && reader.GetVarBoolean("ShowPictureViewInfo", false)) { SpeakerConfiguration conf = 0; SpeakerGeometry geom = 0; if (HasAudio) AudioDevice.GetSpeakerConfiguration(out conf, out geom); Stopwatch sw = Stopwatch.StartNew(); for (int i = 0; i < 100; i++) Thread.Sleep(1); sw.Stop(); Message mes = new Message(Owner); mes.ShowMessage("Video\r\n Resolution: " + reader.Width + "x" + reader.Height + ", FrameRate: " + reader.Framerate + ", Format: " + reader.Clip.OriginalColorspace + ((reader.Clip.OriginalColorspace != AviSynthColorspace.RGB32) ? "->RGB32" : "") + " \r\n Output: " + ((IsInterop) ? "InteropBitmap" : "WriteableBitmap (Install SP1 for .NET Framework 3.0!)") + "\r\n\r\nAudio\r\n" + ((HasAudio) ? " Bits: " + BufferDesc.Format.BitsPerSample + ((reader.Clip.SampleType == AudioSampleType.FLOAT) ? " FLOAT" : "") + ", SampleRate: " + BufferDesc.Format.SampleRate + ", Channels: " + BufferDesc.Format.Channels + ((BufferDesc.Format.Encoding == WaveFormatEncoding.Extensible) ? ", Mask: " + ((WaveFormatExtensible)BufferDesc.Format).ChannelMask + " (" + (int)((WaveFormatExtensible)BufferDesc.Format).ChannelMask + ")" : "") + "\r\n PrimaryBuffers: " + AudioDevice.Capabilities.PrimaryBuffers + ", MixingBuffers: " + AudioDevice.Capabilities.MaxHardwareMixingAllBuffers + " (" + AudioDevice.Capabilities.FreeHardwareMixingAllBuffers + "), 3DBuffers: " + AudioDevice.Capabilities.MaxHardware3DAllBuffers + " (" + AudioDevice.Capabilities.FreeHardware3DAllBuffers + "), MemBytes: " + AudioDevice.Capabilities.TotalHardwareMemBytes + " (" + AudioDevice.Capabilities.FreeHardwareMemBytes + "), SampleRate: " + AudioDevice.Capabilities.MinSecondarySampleRate + " - " + AudioDevice.Capabilities.MaxSecondarySampleRate + (((AudioDevice.Capabilities.Flags & CapabilitiesFlags.ContinousRate) > 0) ? " (continuous)" : "") + "\r\n SpeakerConfiguration: " + conf + ", SpeakerGeometry: " + geom + "\r\n" : " None" + ((!EnableAudio) ? " (disabled)" : "") + "\r\n") + "\r\nTimers\r\n Sleep(100): " + sw.ElapsedMilliseconds + ", HighResolutionStopwatch: " + Stopwatch.IsHighResolution, Languages.Translate("Info")); } #endregion } catch (Exception ex) { SetError(ex); } } }