예제 #1
0
        public void ProgressPatches()
        {
            if (TaskbarManager.IsPlatformSupported)
            {
                mWin7Taskbar.SetProgressState(TaskbarProgressBarState.Normal);
            }
            UpdateProgressbar(0);

            if (mPatches.Count == 0 || mPatchedFiles.Count >= mPatches.Count)
            {
                UpdateProgressbar(100);
                if (TaskbarManager.IsPlatformSupported)
                {
                    mWin7Taskbar.SetProgressState(TaskbarProgressBarState.NoProgress);
                }
                FinalizePatching();
                return;
            }

            if (mRegistry.HasPatch(mPatches[mPatchProgress].ID) == true)
            {
                mPatchedFiles.Add(mPatches[mPatchProgress].ID);
                mPatchProgress++;
                ProgressPatches();
                return;
            }

            mPatches[mPatchProgress].Download(HandlePatchProgress, HandlePatchFinish);
        }
예제 #2
0
 private void frmDownContent_Load(object sender, EventArgs e)
 {
     taskbar.SetProgressState(TaskbarProgressBarState.Indeterminate);
     taskbar.SetProgressValue(0, 0);
     this.dvList.AutoGenerateColumns = false;
     BindData();
 }
예제 #3
0
        private void BackgroundLoading_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (TaskbarManager.IsPlatformSupported)
            {
                mWin7Taskbar.SetProgressValue(100, 100);
                mWin7Taskbar.SetProgressState(TaskbarProgressBarState.NoProgress);
            }

            SetGuiState(true);
            SetInfoState("GRF " + Path.GetFileName(mGrfFilepath) + " successfully opened (" + mGrfFile.Files.Count + " Files)", Resources.check);
            SetGrfInfo();
            lblStatusProgress.Value = 0;

            if (mResname == null && Settings.Default.EnableResnametableSearch)
            {
                if (Settings.Default.ErrorOnResnametable)
                {
                    MessageBox.Show("Failed to load id2resnametable.txt and idnum2itemdisplaynametable.txt!", "File not found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    SetInfoStateTimed("Failed to load id2resnametable.txt and idnum2itemdisplaynametable.txt", Resources.delete);
                }
            }

            // Focus on filter
            txtFilterText.Focus();
            // If we have a previous filter, re-run it
            if (string.IsNullOrEmpty(txtFilterText.Text) == false)
            {
                btnFilter.PerformClick();
            }
        }
예제 #4
0
 private void Main_Form_Shown(object sender, EventArgs e)
 {
     Current_Process.Style = ProgressBarStyle.Marquee;
     taskbar.SetProgressState(TaskbarProgressBarState.Indeterminate);
     Wait.RunWorkerAsync();
     //Size = new System.Drawing.Size(Screen.PrimaryScreen.Bounds.Width / 2, Screen.PrimaryScreen.Bounds.Height / 2);
     //Location = new System.Drawing.Point(Screen.PrimaryScreen.Bounds.Width / 4, Location.Y);
 }
예제 #5
0
 private void EnableServiceStateChangeProgress()
 {
     if (CoreHelpers.RunningOnWin7)
     {
         TaskbarProgressBarState state = TaskbarProgressBarState.Indeterminate;
         windowsTaskbar.SetProgressState(state);
     }
 }
예제 #6
0
 /// <summary>
 /// Set the Task Bar Percentage.
 /// </summary>
 /// <param name="percentage">
 /// The percentage.
 /// </param>
 public void SetTaskBarProgress(int percentage)
 {
     if (!IsWindowsSeven)
     {
         return;
     }
     windowsTaskbar.SetProgressState(TaskbarProgressBarState.Normal);
     windowsTaskbar.SetProgressValue(percentage, 100);
 }
예제 #7
0
 public GlobalProgress Start()
 {
     try
     {
         prog.SetProgressState(TaskbarProgressBarState.Normal);
     }
     catch (Exception) { }
     return(this);
 }
예제 #8
0
        private void mWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (TaskbarManager.IsPlatformSupported)
            {
                mWin7Taskbar.SetProgressState(TaskbarProgressBarState.NoProgress);
            }

            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
예제 #9
0
        private void bgWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            var state = e.UserState as Classes.RenameState;

            toolStripProgressBar1.Value = e.ProgressPercentage;
            prog.SetProgressState(TaskbarProgressBarState.Normal);
            prog.SetProgressValue(e.ProgressPercentage, PROGRESS_BAR_MAX);

            txtResult.Text   += $"{state.OriginalName} 更名為 {state.NewName} => {(state.IsSuccess ? "成功" : "失敗")} {(state.IsSuccess ? "" : state.ErrorMessage)}{Environment.NewLine}";
            lblRemaining.Text = state.Remaining.ToString();
            ScrollTextToEnd();
        }
예제 #10
0
        public static void UpdateProgressUI()
        {
            bool   isTasksWorking  = false;
            double averageProgress = 0;

            IEnumerable <WorkerTask> workingTasks = Tasks.Where(x => x != null && x.Status == TaskStatus.Working && x.Info != null);

            if (workingTasks.Count() > 0)
            {
                isTasksWorking = true;

                workingTasks = workingTasks.Where(x => x.Info.Progress != null);

                if (workingTasks.Count() > 0)
                {
                    averageProgress = workingTasks.Average(x => x.Info.Progress.Percentage);
                }
            }

            if (isTasksWorking)
            {
                Program.MainForm.Text = string.Format("{0} - {1:0.0}%", Program.Title, averageProgress);
                UpdateTrayIcon((int)averageProgress);
                TaskbarManager.SetProgressValue(Program.MainForm, (int)averageProgress);
            }
            else
            {
                Program.MainForm.Text = Program.Title;
                UpdateTrayIcon(-1);
                TaskbarManager.SetProgressState(Program.MainForm, TaskbarProgressBarStatus.NoProgress);
            }
        }
예제 #11
0
 protected override void OnClosing(CancelEventArgs e)
 {
     if (taskbar != null)
     {
         taskbar.SetProgressState(TaskbarProgressBarState.NoProgress);
     }
 }
예제 #12
0
        private ITaskbarItem SetProgressState(TaskbarProgressBarState state)
        {
#if !__MonoCS__
            _taskbarManager.SetProgressState(state, _windowHandle);
#endif
            return(this);
        }
예제 #13
0
        public void SetBusy(ProgressBarState state = ProgressBarState.Normal, string title = null, string message = null,
                            int percent            = -1)
        {
            if (title == null)
            {
                title = GlobalHelper.Get("key_3");
            }
            if (message == null)
            {
                message = GlobalHelper.Get("LongTask");
            }
            BusyIndicator.IsBusy       = state != ProgressBarState.NoProgress;
            BusyIndicator.DisplayAfter = TimeSpan.FromSeconds(1);
            BusyIndicator.BusyContent  = message;



            if (state == ProgressBarState.Normal)
            {
                windowsTaskbar.SetProgressValue(percent, 100, this);
                ProgressBar.Value = percent;
            }
            else
            {
                ProgressBar.IsIndeterminate = state == ProgressBarState.Indeterminate;
                windowsTaskbar.SetProgressState((TaskbarProgressBarState)(state), this);
            }
        }
예제 #14
0
 public static void SetState(Process process, TaskbarProgressBarState state)
 {
     if (process != null && !process.HasExited)
     {
         taskbar.SetProgressState(state, process.MainWindowHandle);
     }
 }
예제 #15
0
        /// <summary>
        /// Show progress on taskbar
        /// </summary>
        /// <param name="i">index</param>
        /// <param name="ii">size</param>
        internal static void Progress(int i, int ii)
        {
            TaskbarManager prog = TaskbarManager.Instance;

            prog.SetProgressState(TaskbarProgressBarState.Normal);
            prog.SetProgressValue(i, ii);
        }
예제 #16
0
 private static void TaskbarSetProgressState(Form form, TaskbarProgressBarState tbps)
 {
     if (form != null && WindowHandle != IntPtr.Zero && TaskbarManager.IsPlatformSupported && WindowsTaskbar != null)
     {
         WindowsTaskbar.SetProgressState(tbps, windowHandle: WindowHandle);
     }
 }
예제 #17
0
        private void BGWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            _notification.Visible = true;
            taskbarInstance.SetProgressValue(100, 100);

            if (e.Error is null)
            {
                taskbarInstance.SetProgressState(TaskbarProgressBarState.Normal);
                _notification.ShowBalloonTip(NotificationDelay, "Blink", "Operation completed successfully", ToolTipIcon.Info);
            }
            else
            {
                taskbarInstance.SetProgressState(TaskbarProgressBarState.Error);
                _notification.ShowBalloonTip(NotificationDelay, e.Error.Source, e.Error.Message, ToolTipIcon.Error);
            }
        }
예제 #18
0
        private void StartGame()
        {
            this.AddTextToList("Das Spiel wird gestartet.\r\n");

            Process proc = new Process();

            proc.StartInfo.FileName        = Config.BinaryName;
            proc.StartInfo.UseShellExecute = false;
            try
            {
                proc.Start();
            }
            catch
            {
                MessageBox.Show(String.Format("Die Datei {0} existiert nicht.", Config.BinaryName), "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            if (this.IsWin7OrHigher())
            {
                TaskbarManager tbmanager = TaskbarManager.Instance;
                tbmanager.SetProgressState(TaskbarProgressBarState.NoProgress);
            }

            BtnPlay.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, new System.Windows.Threading.DispatcherOperationCallback(delegate
            {
                BtnPlay.IsEnabled = true;
                return(null);
            }), null);
        }
예제 #19
0
 private void SetProgress(double multiple = -1)
 {
     Dispatcher.Invoke(() =>
     {
         if (multiple >= 0 && multiple <= 1) // Change
         {
             int percent = Convert.ToInt32(Math.Round(multiple * 100));
             SetTitleSuffix(percent + "%");
             TaskProgressBar.Value = percent;
             TaskbarManager.SetProgressValue(percent, 100);
             TaskbarManager.SetProgressState(TaskbarProgressBarState.Normal);
         }
         else if (multiple == -1) // Reset
         {
             SetTitleSuffix();
             TaskProgressBar.Value = 0;
             TaskbarManager.SetProgressValue(0, 100);
             TaskbarManager.SetProgressState(TaskbarProgressBarState.NoProgress);
         }
         else
         {
             throw new ArgumentException();
         }
     });
 }
예제 #20
0
 private void SetGlobalProgress(int value)
 {
     if (value == 0)
     {
         mTaskbarManager.SetProgressState(TaskbarProgressBarState.NoProgress);
     }
     mTaskbarManager?.SetProgressValue(value, totalProgressBar.Maximum);
 }
예제 #21
0
        /// <summary>
        /// Запуск фонового потока для обработки фотографий
        /// </summary>
        private void btnRun_Click(object sender, EventArgs e)
        {
            //Training
            //https://msdn.microsoft.com/en-us/windows7trainingcourse_win7taskbarmanaged_topic2#_Toc236828995
            //http://rsdn.org/article/dotnet/CSThreading2.xml
            //http://qaru.site/questions/158908/how-to-use-a-backgroundworker
            //проверка состояния, остановить если работает
            //Check if background worker is doing anything and send a cancellation if it is
            if (bw != null)
            {
                if (bw.IsBusy)
                {
                    bw.CancelAsync();
                    return;
                }
            }
            bw = new BackgroundWorker();
            //Получение параметров
            varforbw varforbw1 = new varforbw();

            varforbw1.pathImages       = txtPathFolder.Text;
            varforbw1.pathFileGPS      = txtPathGpsFile.Text;
            varforbw1.overwriteGPSInfo = checkReplaceGPS.Checked;
            varforbw1.addOrRemoveTime  = radioBtnAddTime.Checked;

            varforbw1.addTime = new System.TimeSpan(Convert.ToInt32(numericHour.Value), Convert.ToInt32(numericMin.Value), 0);
            //Запуск фона
            bw.DoWork                    += bw_DoWork;
            bw.ProgressChanged           += bw_ProgressChanged;
            bw.RunWorkerCompleted        += bw_RunWorkerCompleted;
            bw.WorkerReportsProgress      = true;
            bw.WorkerSupportsCancellation = true;
            //
            prog.SetProgressState(Microsoft.WindowsAPICodePack.Taskbar.TaskbarProgressBarState.Normal);
            btnRun.Text = "Остановить";
            //
            //cls
            richtbLog.Clear();
            richtbLog.AppendText("====================" + "\n");
            richtbLog.AppendText("Запуск процесса" + "\n");
            richtbLog.AppendText(DateTime.Now.ToString() + "\n");
            richtbLog.AppendText("====================" + "\n");
            //Запуск фонового процесса
            bw.RunWorkerAsync(varforbw1);
        }
예제 #22
0
        public async Task applyUpdate(ProgressBar progressbar, TaskbarManager taskbar)
        {
            taskbar.SetProgressState(TaskbarProgressBarState.Normal);

            double progress       = 0;
            double targetProgress = updateTasks.Count;

            foreach (UpdateTask task in updateTasks)
            {
                progress++;
                string file = task.file;

                try
                {
                    switch (task.operation)
                    {
                    case (UpdateOperations.create_directory):
                        if (!Directory.Exists(file))
                        {
                            await Task.Run(() => Directory.CreateDirectory(file));
                        }
                        break;

                    case UpdateOperations.remove:
                        if (File.Exists(file))
                        {
                            await Task.Run(() => File.Delete(file));
                        }
                        else if (Directory.Exists(file))
                        {
                            await Task.Run(() => Directory.Delete(file, true));
                        }
                        break;

                    case UpdateOperations.update:
                        await Task.Run(() => webClient.DownloadFile(new Uri(host + file), file + ".download"));

                        if (File.Exists(file))
                        {
                            await Task.Run(() => File.Delete(file));
                        }
                        File.Move(file + ".download", file);
                        break;
                    }
                    progressbar.Value = progress / targetProgress * 100;
                    taskbar.SetProgressValue(Convert.ToInt32(progress), Convert.ToInt32(targetProgress));
                    logPrint($"[{task.operation}] {task.file}");
                }
                catch (Exception error)
                {
                    logPrint($"Ошибка при выполнении операции: {error.Message}");
                }
            }
            logPrint($"Применение обновлений завершено");
            return;
        }
        private void EnableControlsAndManageTaskbar(bool state)
        {
            TabControl.TabPageCollection tabs = tcMain.TabPages;

            foreach (TabPage tab in tabs)
            {
                Control.ControlCollection controls = tab.Controls;

                foreach (Control control in controls)
                {
                    if (control.Tag != null && control.Tag.ToString() == "disable")
                    {
                        control.Enabled = state;
                    }
                }
            }

            tbManager.SetProgressState(!state ? TaskbarProgressBarState.Normal : TaskbarProgressBarState.NoProgress);
        }
예제 #24
0
        private void SetGlobalProgressState(ProgressBarState state)
        {
            switch (state)
            {
            case ProgressBarState.Normal:
                mTaskbarManager?.SetProgressState(TaskbarProgressBarState.Normal);
                break;

            case ProgressBarState.Error:
                mTaskbarManager?.SetProgressState(TaskbarProgressBarState.Error);
                break;

            case ProgressBarState.Warning:
                mTaskbarManager?.SetProgressState(TaskbarProgressBarState.Paused);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(state), state, null);
            }
        }
예제 #25
0
 private void SetTaskbarProgress_Click(object sender, RoutedEventArgs e)
 {
     if (int.TryParse(TaskbarProgressSet.Text, out int result))
     {
         if (result > 0 && 100 > result)
         {
             taskbarInstance.SetProgressState(TaskbarProgressBarState.Normal);
             taskbarInstance.SetProgressValue(result, 100);
         }
     }
 }
예제 #26
0
        private async Task Authenticate(string code)
        {
            try
            {
                TaskbarManager.SetProgressState(TaskbarProgressBarState.Indeterminate);

                var result = await OAuthFlower.MicrosoftCodeToAccessToken(code, CancelToken);

                var xbox_result = await XboxliveAuther.Authenticate(result, CancelToken);

                var mc_result = await McServices.Authenticate(xbox_result, CancelToken);

                var owner_result = await McServices.CheckHaveGameOwnership(mc_result, CancelToken);

                if (owner_result)
                {
                    MicrosoftUser microsoftUser = await McServices.GetProfile(result, mc_result, CancelToken);

                    LoggedInUser = microsoftUser;
                    islogin      = true;
                    LoginChange();
                }
                else
                {
                    islogin      = false;
                    LoggedInUser = null;
                    var res = await this.ShowMessageAsync(App.GetResourceString("String.OauthLogin.NoMinecraft"),
                                                          App.GetResourceString("String.OauthLogin.NoMinecraft1"),
                                                          MessageDialogStyle.AffirmativeAndNegative,
                                                          new MetroDialogSettings()
                    {
                        AffirmativeButtonText = App.GetResourceString("String.OauthLogin.Back"),
                        NegativeButtonText    = App.GetResourceString("String.OauthLogin.Change"),
                        DefaultButtonFocus    = MessageDialogResult.Negative
                    });

                    if (res == MessageDialogResult.Negative)
                    {
                        LoginOut();
                    }
                }
            }
            catch (Exception ex)
            {
                LoggedInUser = null;
                await this.ShowMessageAsync(App.GetResourceString("String.OauthLogin.LoginError"), ex.ToString());
            }
            finally
            {
                TaskbarManager.SetProgressState(TaskbarProgressBarState.NoProgress);
            }
        }
예제 #27
0
        private void UpdateTaskbarProgress(object sender, PropertyChangedEventArgs e)
        {
            taskbarManager.SetProgressState(model.IsProgressBarVisible.Value
                ? TaskbarProgressBarState.Normal
                : TaskbarProgressBarState.NoProgress);

            Task.Run(() =>
            {
                while (model.IsProgressBarVisible.Value)
                {
                    int currentProgress = (int)model.ElapsedStartupDurationMilliseconds;
                    progressBar1.Value  = currentProgress;
                    taskbarManager.SetProgressValue(currentProgress, FormViewModel.ExpectedStartupDurationMilliseconds);

                    Thread.Sleep(ProgressBarUpdateFrequencyMilliseconds);
                }
            });
        }
예제 #28
0
        private void Form1_Load(object sender, EventArgs e)
        {
            ////初始化进度条
            windowsTaskbar.SetProgressState(TaskbarProgressBarState.Normal, this.Handle);
            windowsTaskbar.SetProgressValue(0, 100, this.Handle);

            if (!File.Exists(@"Tools\ffmpeg.exe"))  //判断程序目录有无ffmpeg.exe
            {
                MessageBox.Show("没有找到Tools\\ffmpeg.exe", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Dispose();
                Application.Exit();
            }
            if (File.Exists(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + "\\M3u8_Downloader_Settings.xml"))  //判断程序目录有无配置文件,并读取文件
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(@System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + "\\M3u8_Downloader_Settings.xml");    //加载Xml文件
                XmlNodeList topM = doc.SelectNodes("Settings");
                foreach (XmlElement element in topM)
                {
                    textBox_DownloadPath.Text = element.GetElementsByTagName("DownPath")[0].InnerText;
                    if (element.GetElementsByTagName("ExtendName")[0].InnerText == "MP4")
                    {
                        radioButton1.Checked = true;
                    }
                    if (element.GetElementsByTagName("ExtendName")[0].InnerText == "MKV")
                    {
                        radioButton2.Checked = true;
                    }
                    if (element.GetElementsByTagName("ExtendName")[0].InnerText == "TS")
                    {
                        radioButton3.Checked = true;
                    }
                    if (element.GetElementsByTagName("ExtendName")[0].InnerText == "FLV")
                    {
                        radioButton4.Checked = true;
                    }
                }
            }
            else  //若无配置文件,获取当前程序运行路径,即为默认下载路径
            {
                string lujing = System.Environment.CurrentDirectory;
                textBox_DownloadPath.Text = lujing;
            }
        }
예제 #29
0
        void progressStart(FFmpeg ff, string name, string extString = "")
        {
            progressBarProc.Value = 0;
            ff.onProc             = per =>
            {
                long  remain = ff.info.format.duration - dfv.timeStrToLong(ff.processTime);
                float speed  = 0;
                try
                {
                    speed = float.Parse(ff.processSpeed.Replace("x", ""));
                }
                catch (Exception)
                {
                }
                if (remain > 0 && speed > 0)
                {
                    remain = (long)(remain / speed);
                }

                this.BeginInvoke(new Action(() =>
                {
                    TaskbarManager.SetProgressState(TaskbarProgressBarState.Normal);
                    TaskbarManager.SetProgressValue(progressBarProc.Value, progressBarProc.Maximum);
                    progressBarProc.Value = per;
                    var info = per + "% ";
                    if (ff.processFPS != "")
                    {
                        info += ff.processFPS + "FPS ";
                    }

                    info += ff.processSpeed;

                    if (remain > 0)
                    {
                        info += " " + dfv.timeToStr(remain);
                    }

                    info          += " " + extString + com.lang.dat.Progressing + "..." + name;
                    labelProc.Text = info;
                }));
            };
            labelProc.Text = extString + com.lang.dat.Progressing + "..." + name;
        }
예제 #30
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //checkbox testing
            testBox1.CheckboxDisabledColor = Colors.Green;

            //init UI color settings
            UISettings.InitUIBrushes();

            //get value from resource dictionary
            bool test = (bool)Application.Current.Resources["ApplyColorSettings"];

            //task bar stuff
            //https://www.fluxbytes.com/csharp/how-to-display-a-progressbar-in-taskbar-in-c/
            if (TaskbarManager.IsPlatformSupported)
            {
                taskbarInstance = TaskbarManager.Instance;
                taskbarInstance.SetProgressState(TaskbarProgressBarState.NoProgress);
            }
        }