Example #1
0
        private void worker_ProgressChanged(object sender, System.ComponentModel.ProgressChangedEventArgs e)
        {
            if (((BackgroundWorker)sender).WorkerReportsProgress)
            {
                if (prCurrent.IsIndeterminate)
                {
                    prCurrent.IsIndeterminate = false;
                    text_info.Content         = Languages.Translate("Indexing") + " (FFMS2)...";
                }

                prCurrent.Value = e.ProgressPercentage;
                if (total > 1)
                {
                    Title = e.ProgressPercentage.ToString("0") + "% (" + (current + 1) + " of " + total + ")";
                }
                else
                {
                    Title = "(" + e.ProgressPercentage.ToString("0") + "%)";
                }

                //Прогресс в Taskbar
                //if (Handle == IntPtr.Zero) Handle = new WindowInteropHelper(this).Handle;
                Win7Taskbar.SetProgressValue(Handle, Convert.ToUInt64(e.ProgressPercentage), 100);
            }
        }
 private void Window_ContentRendered(object sender, EventArgs e)
 {
     if (!IsErrors)
     {
         Win7Taskbar.SetProgressIndeterminate(this, ref Handle);
     }
 }
 private void check_use_win7taskbar_Click(object sender, RoutedEventArgs e)
 {
     if (Settings.Win7TaskbarIsEnabled = check_use_win7taskbar.IsChecked.Value)
     {
         if (!Win7Taskbar.InitializeWin7Taskbar())
         {
             ErrorException(Languages.Translate("Failed to initialize Windows 7 taskbar interface.") +
                            " " + Languages.Translate("This feature will be disabled!"));
             check_use_win7taskbar.IsChecked = Settings.Win7TaskbarIsEnabled = false;
         }
     }
     else
     {
         Win7Taskbar.UninitializeWin7Taskbar();
     }
 }
        private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            if (((BackgroundWorker)sender).WorkerReportsProgress)
            {
                if (progress_total.IsIndeterminate)
                {
                    progress_total.IsIndeterminate = false;
                    label_info.Content             = Languages.Translate("Detecting interlace") + "...";
                }

                progress_total.Value = e.ProgressPercentage;
                Title = "(" + e.ProgressPercentage.ToString("0") + "%)";

                //Прогресс в Taskbar
                //if (Handle == IntPtr.Zero) Handle = new WindowInteropHelper(this).Handle;
                Win7Taskbar.SetProgressValue(Handle, Convert.ToUInt64(e.ProgressPercentage), 100);
            }
        }
Example #5
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            bool cancel_closing = false;

            if (worker != null)
            {
                if (worker.IsBusy && num_closes < 5)
                {
                    //Отмена
                    cancel_closing = true;
                    worker.CancelAsync();
                    num_closes += 1;
                    m           = null;
                }
                else
                {
                    worker.Dispose();
                    worker = null;
                }
            }

            CloseIndexer();

            //Отменяем закрытие окна
            if (cancel_closing)
            {
                worker.WorkerReportsProgress = false;
                label_info.Content           = Languages.Translate("Aborting... Please wait...");
                Win7Taskbar.SetProgressState(Handle, TBPF.INDETERMINATE);
                prCurrent.IsIndeterminate = true;
                e.Cancel = true;
            }
            else
            {
                //Удаляем мусор
                SafeFileDelete(filelistpath);

                //Удаление индекс-папки при отмене или ошибке
                if ((num_closes > 0 || m == null) && File.Exists(indexfile))
                {
                    SafeDirDelete(Path.GetDirectoryName(indexfile));
                }
            }
        }
Example #6
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            bool cancel_closing = false;

            if (worker != null)
            {
                if (worker.IsBusy && num_closes < 5)
                {
                    //Отмена
                    cancel_closing = true;
                    worker.CancelAsync();
                    num_closes += 1;
                    m           = null;
                }
                else
                {
                    worker.Dispose();
                    worker = null;
                }
            }

            CloseIndexer();

            //Отменяем закрытие окна
            if (cancel_closing)
            {
                worker.WorkerReportsProgress = false;
                text_info.Content            = Languages.Translate("Aborting... Please wait...");
                Win7Taskbar.SetProgressState(Handle, TBPF.INDETERMINATE);
                prCurrent.IsIndeterminate = true;
                e.Cancel = true;
            }
            else
            {
                //Удаление индекс-файлов при отмене или ошибке
                if (num_closes > 0 || m == null)
                {
                    foreach (string file in index_files)
                    {
                        SafeFileDelete(file);
                    }
                }
            }
        }
Example #7
0
        private void worker_ProgressChanged(object sender, System.ComponentModel.ProgressChangedEventArgs e)
        {
            if (((BackgroundWorker)sender).WorkerReportsProgress)
            {
                if (prCurrent.IsIndeterminate)
                {
                    prCurrent.IsIndeterminate = false;
                    text_info.Content         = Languages.Translate("Volume gain detecting...");
                }

                //получаем текущий фрейм
                double cf = prCurrent.Value = e.ProgressPercentage;

                //вычисляем проценты прогресса
                double pr = (cf / vtrim) * 100.0;
                Title = "(" + pr.ToString("0") + "%)";

                //Прогресс в Taskbar
                //if (Handle == IntPtr.Zero) Handle = new WindowInteropHelper(this).Handle;
                Win7Taskbar.SetProgressValue(Handle, Convert.ToUInt64(e.ProgressPercentage), Convert.ToUInt64(vtrim));
            }
        }
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            bool cancel_closing = false;

            if (worker != null)
            {
                if (worker.IsBusy && num_closes < 5)
                {
                    //Отмена
                    IsAborted      = true;
                    cancel_closing = true;
                    worker.CancelAsync();
                    num_closes += 1;
                    m           = null;
                }
                else
                {
                    worker.Dispose();
                    worker = null;
                }
            }

            //Отменяем закрытие окна
            if (cancel_closing)
            {
                //CloseReader(false);

                worker.WorkerReportsProgress = false;
                label_info.Content           = Languages.Translate("Aborting... Please wait...");
                Win7Taskbar.SetProgressState(Handle, TBPF.INDETERMINATE);
                progress_total.IsIndeterminate = true;
                e.Cancel = true;
            }
            else
            {
                CloseReader(true);
            }
        }
        private void ErrorException(string data, string info)
        {
            if (!Application.Current.Dispatcher.CheckAccess())
            {
                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new ErrorExceptionDelegate(ErrorException), data, info);
            }
            else
            {
                IsErrors = 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);
            }
        }
Example #10
0
        private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                ErrorException("ScriptRunner (Unhandled): " + ((Exception)e.Error).Message, ((Exception)e.Error).StackTrace);
                Close();
            }
            else if (e.Result != null)
            {
                //Добавляем скрипт в StackTrace
                string stacktrace = ((Exception)e.Result).StackTrace;
                if (!string.IsNullOrEmpty(script))
                {
                    stacktrace += Calculate.WrapScript(script, 150);
                }

                ErrorException("ScriptRunner: " + ((Exception)e.Result).Message, stacktrace);
                Close();
            }
            else if (IsAborted || Settings.CloseScriptRunner)
            {
                Close();
            }
            else
            {
                Title = Languages.Translate("Complete");
                if (progress_total.IsIndeterminate)
                {
                    //Прогресс еще не выводился
                    progress_total.IsIndeterminate = false;
                    progress_total.Value           = progress_total.Maximum;
                    label_info.Content             = label.Replace("XX", total.ToString()).Replace("YY", total.ToString());
                    Win7Taskbar.SetProgressTaskComplete(Handle, TBPF.NORMAL);
                }
            }
        }
Example #11
0
        private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            if (((BackgroundWorker)sender).WorkerReportsProgress)
            {
                if (progress_total.IsIndeterminate)
                {
                    label = label.Replace("YY", total.ToString());
                    progress_total.IsIndeterminate = false;
                    progress_total.Maximum         = total;
                }

                Title = "(" + ((e.ProgressPercentage * 100) / total).ToString("0") + "%)";
                label_info.Content   = label.Replace("XX", e.ProgressPercentage.ToString());
                progress_total.Value = e.ProgressPercentage;

                TimeSpan time = ((DateTime)e.UserState) - start;
                label_fps.Content = elapsed + (new DateTime(time.Ticks).ToString("HH:mm:ss.ff")) + "   avg fps: " +
                                    (e.ProgressPercentage / time.TotalSeconds).ToString("0.00", CultureInfo.InvariantCulture);

                //Прогресс в Taskbar
                //if (Handle == IntPtr.Zero) Handle = new WindowInteropHelper(this).Handle;
                Win7Taskbar.SetProgressValue(Handle, Convert.ToUInt64(e.ProgressPercentage), Convert.ToUInt64(total));
            }
        }