private HRESULT _UpdateProgressState(bool attached) { TaskbarItemProgressState progressState = this.ProgressState; TBPF tbpFlags = TBPF.NOPROGRESS; if (attached) { tbpFlags = progressState switch { TaskbarItemProgressState.None => TBPF.NOPROGRESS, TaskbarItemProgressState.Indeterminate => TBPF.INDETERMINATE, TaskbarItemProgressState.Normal => TBPF.NORMAL, TaskbarItemProgressState.Error => TBPF.ERROR, TaskbarItemProgressState.Paused => TBPF.PAUSED, _ => TBPF.NOPROGRESS }; } HRESULT result = this._taskbarList.SetProgressState(this._hwndSource.Handle, tbpFlags); if (result.Succeeded) { result = this._UpdateProgressValue(attached); } return(result); }
private void SetProgress(TaskbarItemProgressState state, double?percentComplete, int?incompleteTaskCount) { var statusService = ServiceLocator.Current.GetInstance <IStatusService>(); if (statusService != null) { this.ExecuteUIActionAsync(() => { if (percentComplete.HasValue && incompleteTaskCount.HasValue) { var taskCountMessage = incompleteTaskCount.Value.ToCountString("task"); var progressMessage = string.Format(CultureInfo.CurrentCulture, "Executing {0} ({1} complete)", taskCountMessage, percentComplete.Value.ToPercentageString()); statusService.SetMainWindowTitleStatus(progressMessage); statusService.SetMainWindowProgress(state, percentComplete.Value); } else if (incompleteTaskCount.HasValue) { var taskCountMessage = incompleteTaskCount.Value.ToCountString("task"); var progressMessage = string.Format(CultureInfo.CurrentCulture, "Executing {0}", taskCountMessage); statusService.SetMainWindowTitleStatus(progressMessage); statusService.SetMainWindowProgress(state); } else { statusService.ClearMainWindowTitleStatus(); statusService.SetMainWindowProgress(state); } }); } }
private void UpdateProgressCurrent(ProgressInfo info) { if (info == null) { ProgressCopiedCurrent = 0D; RemainingTime = TimeSpan.Zero; ProgressState = TaskbarItemProgressState.None; } else if (info.IsError) { ProgressState = TaskbarItemProgressState.Error; } else { var sizeCopiedLatest = (long)info.CurrentValue; var elapsedTimeLatest = info.ElapsedTime; var sizeCopiedToBeCopiedCurrent = _sizeCopiedCurrent + _sizeToBeCopiedCurrent; if ((sizeCopiedLatest <= 0) || (sizeCopiedToBeCopiedCurrent <= 0)) { return; // For just in case } ProgressCopiedCurrent = (double)(_sizeCopiedCurrent + sizeCopiedLatest) * 100D / (double)sizeCopiedToBeCopiedCurrent; RemainingTime = TimeSpan.FromSeconds((double)(_sizeToBeCopiedCurrent - sizeCopiedLatest) * elapsedTimeLatest.TotalSeconds / (double)sizeCopiedLatest); ProgressState = TaskbarItemProgressState.Normal; //Debug.WriteLine($"ProgressCopiedCurrent: {ProgressCopiedCurrent} RemainingTime: {RemainingTime}"); } }
public static void SetProgressState(TaskbarItemProgressState state) { if (helper != null) { helper.ProgressState = state; } }
/// <summary> /// 设置 [任务栏进度条]的进度和状态 /// (取值范围:0-1) /// </summary> /// <param name="_value">进度条的进度</param> /// <param name="_progressState">进度条的颜色(绿色、红色、黄色)</param> public void SetProgressValueAndState(double _value, TaskbarItemProgressState _progressState = TaskbarItemProgressState.Paused) { // 修改颜色 SetProgressState(_progressState); // 修改进度 SetProgressValue(_value); }
// Token: 0x06000E93 RID: 3731 RVA: 0x00038121 File Offset: 0x00036321 private TaskbarItemProgressState CoerceProgressState(TaskbarItemProgressState value) { if (value > TaskbarItemProgressState.Paused) { value = TaskbarItemProgressState.None; } return(value); }
private static void SetTaskbarItemProgressState(TaskbarItemProgressState state) { // HACK speaking to Application.Current and Application.Current.MainWindow inside a ViewModel is not acceptable, but oh my try { Application.Current.Dispatcher.BeginInvoke((System.Action)(() => Application.Current.MainWindow.TaskbarItemInfo.ProgressState = state)); } catch (Exception e) { _log.ErrorException("Setting TaskbarItemInfo to " + state + " failed", e); } }
public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture) { TaskbarItemProgressState state = (TaskbarItemProgressState)value; return(state == TaskbarItemProgressState.Normal); }
private void button1_Click(object sender, RoutedEventArgs e) { this.taskBarItem.ProgressState = TaskbarItemProgressState.Error; this.taskBarItem.ProgressValue = 1; var answer = MessageBox.Show("Do U want to exit application?", "Exit", MessageBoxButton.YesNo, MessageBoxImage.Question); if (answer == MessageBoxResult.Yes) this.Close(); else this.taskBarItem.ProgressState = TaskbarItemProgressState.None; }
protected void UpdateTaskbar(TaskbarItemProgressState state, double value) { var message = new TaskbarMessage("Window.UpdateTaskbar") { ProgressState = state, ProgressValue = value, }; this.Messenger.RaiseAsync(message).Forget(); }
private void SetState(TaskbarItemProgressState state) { if (_currentState == state) { return; } _currentState = state; UpdateState(); }
public (bool measureDownloadTime, string downloadedFileSize, bool isIndeterminate, TaskbarItemProgressState taskbarItemProgressStateModel, int progressBarPercent, double taskBarProgressValue, bool measureProcessingTime, string standardOutputOut) Extract(string standardOutput, string finishedMessage) { int positionFrom; int positionTo; if (standardOutput.Contains(Localization.Properties.Resources.ThreadPoolWorkerDownload) && standardOutput.Contains(Localization.Properties.Resources.ThreadPoolWorkerEta)) { measureDownloadTime = true; positionFrom = standardOutput.IndexOf(Localization.Properties.Resources.ThreadPoolWorkerOf, StringComparison.InvariantCultureIgnoreCase) + Localization.Properties.Resources.ThreadPoolWorkerOf.Length; positionTo = standardOutput.LastIndexOf(Localization.Properties.Resources.ThreadPoolWorkerAt, StringComparison.InvariantCultureIgnoreCase); if ((positionTo - positionFrom) > 0) { downloadedFileSize = standardOutput.Substring(positionFrom, positionTo - positionFrom); } positionFrom = standardOutput.IndexOf("] ", StringComparison.InvariantCultureIgnoreCase) + "] ".Length; positionTo = standardOutput.LastIndexOf("%", StringComparison.InvariantCultureIgnoreCase); if ((positionTo - positionFrom) > 0) { var percent = standardOutput.Substring(positionFrom, positionTo - positionFrom); if (double.TryParse(percent.Trim(), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var downloadedPercent)) { isIndeterminate = false; taskbarItemProgressStateModel = TaskbarItemProgressState.Normal; progressBarPercent = Convert.ToInt32(Math.Round(downloadedPercent)); taskBarProgressValue = HelpersModel.GetTaskBarProgressValue(100, progressBarPercent); } else { isIndeterminate = true; taskbarItemProgressStateModel = TaskbarItemProgressState.Indeterminate; } } standardOutputOut = standardOutput; } if (standardOutput.Contains("has already been")) { standardOutputOut = standardOutput; downloadedFileSize = Localization.Properties.Resources.FileHasAlreadyBeenDownloaded; measureDownloadTime = false; } if (standardOutput.Contains("[ffmpeg]")) { standardOutputOut = finishedMessage; measureProcessingTime = true; measureDownloadTime = false; } return(measureDownloadTime, downloadedFileSize, isIndeterminate, taskbarItemProgressStateModel, progressBarPercent, taskBarProgressValue, measureProcessingTime, standardOutputOut); }
} // bool used to track if any changes where made to the list #endregion #region Constructor public UserInfoViewModel() { settingsInstance = AppSettings.Instance; IsBusy = false; ChangesToList = false; ListFilter = new UsersFilterViewModel(); sortDirection = ListSortDirection.Ascending; _taskCancellationToken = new CancellationTokenSource(); _usersProgress = new Progress <UsersProgressReportModel>(); _usersProgress.ProgressChanged += UesrsProgress_ProgressChanged; _lock = new object(); _taskInProgress = TaskbarItemProgressState.None; _progressValue = 0; }
private static TaskbarItemProgressState _CoerceProgressState(TaskbarItemProgressState value) { switch (value) { case TaskbarItemProgressState.None: case TaskbarItemProgressState.Indeterminate: case TaskbarItemProgressState.Normal: case TaskbarItemProgressState.Error: case TaskbarItemProgressState.Paused: return(value); } value = TaskbarItemProgressState.None; return(value); }
private HRESULT _UpdateProgressState(bool attached) { TaskbarItemProgressState ps = ProgressState; TBPF tbpf = TBPF.NOPROGRESS; if (attached) { switch (ps) { case TaskbarItemProgressState.Error: tbpf = TBPF.ERROR; break; case TaskbarItemProgressState.Indeterminate: tbpf = TBPF.INDETERMINATE; break; case TaskbarItemProgressState.None: tbpf = TBPF.NOPROGRESS; break; case TaskbarItemProgressState.Normal: tbpf = TBPF.NORMAL; break; case TaskbarItemProgressState.Paused: tbpf = TBPF.PAUSED; break; default: // The coersion should have caught this. Assert.Fail(); tbpf = TBPF.NOPROGRESS; break; } } HRESULT hr = _taskbarList.SetProgressState(_hwndSource.Handle, tbpf); if (hr.Succeeded) { // Explicitly update this in case this property being set // to None or Indeterminate before made the value not update. hr = _UpdateProgressValue(attached); } return(hr); }
/// <summary> /// Updates the progress state. /// </summary> /// <param name="state">The state.</param> /// <param name="progressPercent">The progress percent (0 to 1).</param> /// <param name="info">The extra information.</param> /// <param name="infoType">Type of the information.</param> public void UpdateState(TaskbarItemProgressState state, double progressPercent, string info, StatusType infoType) { Info.Update(info, infoType); State = state; var val = progressPercent * Maximum; if (val < Minimum) { val = Minimum; } else if (val > Maximum) { val = Maximum; } Value = val; RaisePropertyChanged(() => State); RaisePropertyChanged(() => IsIndeterminate); RaisePropertyChanged(() => IsBusy); RaisePropertyChanged(() => Info); RaisePropertyChanged(() => Value); }
private void Update() { try { CreateLogger(); StopAudioDownloader(); DeleteOldFiles(); StartAudioDownloader(); } catch (Exception excetion) { Log.Error(excetion, Localization.Properties.Resources.UpdaterFailedToUpdate); StandardOutput = Localization.Properties.Resources.UpdaterFailedToUpdate; TaskbarItemProgressStateModel = TaskbarItemProgressState.Error; _exceptionOccured = true; } }
private void ChangeProgressStatus() { if (!recorder.Recording) { ProgressState = TaskbarItemProgressState.Paused; } if (recorder.Recording && !FullTimeAchieved()) { ProgressState = TaskbarItemProgressState.Normal; } if (recorder.Recording && FullTimeAchieved()) { ProgressState = TaskbarItemProgressState.Indeterminate; } }
private TaskbarItemProgressState CoerceProgressState(TaskbarItemProgressState value) { switch (value) { case TaskbarItemProgressState.Error: case TaskbarItemProgressState.Indeterminate: case TaskbarItemProgressState.None: case TaskbarItemProgressState.Normal: case TaskbarItemProgressState.Paused: break; default: // Convert bad data into no-progress bar. value = TaskbarItemProgressState.None; break; } return value; }
private void StopAudioDownloader() { StandardOutput = Localization.Properties.Resources.UpdaterUpdatingAudioDownloader; Log.Information(StandardOutput); Thread.Sleep(1000); IsIndeterminate = false; TaskbarItemProgressStateModel = TaskbarItemProgressState.Normal; StandardOutput = Localization.Properties.Resources.UpdaterClosingAudioDownloader; Log.Information(StandardOutput); foreach (var process in Process.GetProcessesByName("AudioDownloader")) { process.Kill(); Log.Information("Killed process: {0}", process.ToString()); } ProgressBarPercent = 33; TaskBarProgressValue = GetTaskBarProgressValue(99, ProgressBarPercent); Thread.Sleep(1000); }
private TaskbarItemProgressState CoerceProgressState(TaskbarItemProgressState value) { switch (value) { case TaskbarItemProgressState.Error: case TaskbarItemProgressState.Indeterminate: case TaskbarItemProgressState.None: case TaskbarItemProgressState.Normal: case TaskbarItemProgressState.Paused: break; default: // Convert bad data into no-progress bar. value = TaskbarItemProgressState.None; break; } return(value); }
private void UpdateProgress() { OverallProgress = Manager.GetOverallProgress(); if (Manager.Transfers.Count > 0) { if (Manager.IsPaused) { State = TaskbarItemProgressState.Paused; } else { State = TaskbarItemProgressState.Normal; } } else { State = TaskbarItemProgressState.None; } }
private HRESULT _UpdateProgressState(bool attached) { TaskbarItemProgressState progressState = this.ProgressState; TBPF tbpFlags = TBPF.NOPROGRESS; if (attached) { switch (progressState) { case TaskbarItemProgressState.None: tbpFlags = TBPF.NOPROGRESS; break; case TaskbarItemProgressState.Indeterminate: tbpFlags = TBPF.INDETERMINATE; break; case TaskbarItemProgressState.Normal: tbpFlags = TBPF.NORMAL; break; case TaskbarItemProgressState.Error: tbpFlags = TBPF.ERROR; break; case TaskbarItemProgressState.Paused: tbpFlags = TBPF.PAUSED; break; default: tbpFlags = TBPF.NOPROGRESS; break; } } HRESULT result = this._taskbarList.SetProgressState(this._hwndSource.Handle, tbpFlags); if (result.Succeeded) { result = this._UpdateProgressValue(attached); } return(result); }
private Standard.HRESULT _UpdateProgressState(bool attached) { Standard.HRESULT hresult; TaskbarItemProgressState progressState = this.ProgressState; Standard.TBPF nOPROGRESS = Standard.TBPF.NOPROGRESS; if (attached) { switch (progressState) { case TaskbarItemProgressState.None: nOPROGRESS = Standard.TBPF.NOPROGRESS; goto Label_0040; case TaskbarItemProgressState.Indeterminate: nOPROGRESS = Standard.TBPF.INDETERMINATE; goto Label_0040; case TaskbarItemProgressState.Normal: nOPROGRESS = Standard.TBPF.NORMAL; goto Label_0040; case TaskbarItemProgressState.Error: nOPROGRESS = Standard.TBPF.ERROR; goto Label_0040; case TaskbarItemProgressState.Paused: nOPROGRESS = Standard.TBPF.PAUSED; goto Label_0040; } nOPROGRESS = Standard.TBPF.NOPROGRESS; } Label_0040: hresult = this._taskbarList.SetProgressState(this._hwndSource.Handle, nOPROGRESS); if (hresult.Succeeded) { hresult = this._UpdateProgressValue(attached); } return(hresult); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { TaskbarItemProgressState state = (TaskbarItemProgressState)value; return(state == TaskbarItemProgressState.None ? Visibility.Collapsed : Visibility.Visible); }
/// <summary> /// Updates the progress state. /// </summary> /// <param name="state">The state.</param> /// <param name="progressPercent">The progress percent (0 to 1).</param> /// <param name="info">The extra information.</param> public void UpdateState(TaskbarItemProgressState state, double progressPercent, string info) { UpdateState(state, progressPercent, info, StatusType.Info); }
/// <summary> /// Updates the progress state. /// </summary> /// <param name="state">The state.</param> /// <param name="progressPercent">The progress percent (0 to 1).</param> /// <param name="info">The extra information.</param> /// <param name="infoType">Type of the information.</param> public void UpdateState(TaskbarItemProgressState state, double progressPercent, string info, StatusType infoType) { Info.Update(info, infoType); State = state; var val = progressPercent * Maximum; if (val < Minimum) { val = Minimum; } else if (val > Maximum) { val = Maximum; } Value = val; RaisePropertyChanged(() => State); RaisePropertyChanged(() => IsIndeterminate); RaisePropertyChanged(() => IsBusy); RaisePropertyChanged(() => Info); RaisePropertyChanged(() => Value); }
private void RemoveButton_Click(object sender, RoutedEventArgs e) { this.taskBarItem.ProgressState = TaskbarItemProgressState.Error; this.taskBarItem.ProgressValue = 1; var answer = MessageBox.Show("Do U really want to delete this contact?", "Deleting", MessageBoxButton.YesNo, MessageBoxImage.Question); if (answer == MessageBoxResult.Yes) Controller.RemoveContact(); else this.taskBarItem.ProgressState = TaskbarItemProgressState.None; }
/// <summary> /// Updates the progress state. /// </summary> /// <param name="state">The state.</param> /// <param name="progressPercent">The progress percent (0 to 1).</param> /// <param name="info">The extra information.</param> public void UpdateState(TaskbarItemProgressState state, double progressPercent, string info) { UpdateState(state, progressPercent, info, StatusType.Info); }
public TaskbarProgressEventArgs(TaskbarItemProgressState state, double value) { this.ProgressState = state; this.ProgressValue = value; }
/// <summary> /// Updates the progress state. /// </summary> /// <param name="state">The state.</param> /// <param name="progressPercent">The progress percent (0 to 1).</param> public void UpdateState(TaskbarItemProgressState state, double progressPercent) { UpdateState(state, progressPercent, null, StatusType.Info); }
private void UpdateProgress(TaskbarItemProgressState state, double value, string status) { if (!DispatcherHelper.UIDispatcher.CheckAccess()) { DispatcherHelper.UIDispatcher.BeginInvoke(new Action<TaskbarItemProgressState, double, string>(UpdateProgress), state, value, status); return; } ProgressState = state; ProgressValue = value; ProgressStatus = status; }
private static void SetTaskbarItemProgressState(TaskbarItemProgressState state) { // HACK speaking to Application.Current and Application.Current.MainWindow inside a ViewModel is not acceptable, but oh my try { Application.Current.Dispatcher.BeginInvoke((System.Action)(() => Application.Current.MainWindow.TaskbarItemInfo.ProgressState = state)); } catch (Exception e) { _log.ErrorException("Setting TaskbarItemInfo to " + state + " failed", e); } }
public void SetMainWindowProgress(TaskbarItemProgressState state, double progressValue) { this.TaskbarItemInfo.ProgressState = state; this.TaskbarItemInfo.ProgressValue = progressValue; }
public TaskbarProgressEventArgs(TaskbarItemProgressState state, double value) { this.ProgressState = state; this.ProgressValue = value; }
public void SetMainWindowProgress(TaskbarItemProgressState state) { this.TaskbarItemInfo.ProgressState = state; }
/// <summary> /// Updates the progress state. /// </summary> /// <param name="state">The state.</param> public void UpdateState(TaskbarItemProgressState state) { UpdateState(state, 0, null, StatusType.Info); }
/// <summary> /// Updates Progress State /// </summary> /// <param name="state">State to set</param> private void UpdateProgressState(TaskbarItemProgressState state) { Dispatcher.BeginInvoke(new Action(() => TaskBarProgress.ProgressState = state)); }
private void TaskbarProgressChanged(TaskbarItemProgressState state) { ProgressState = state; }
/// <summary> /// Updates the progress state. /// </summary> /// <param name="state">The state.</param> public void UpdateState(TaskbarItemProgressState state) { UpdateState(state, 0, null, StatusType.Info); }
protected void UpdateTaskbar(TaskbarItemProgressState state, double value) { var message = new TaskbarMessage("Window.UpdateTaskbar") { ProgressState = state, ProgressValue = value, }; this.Messenger.RaiseAsync(message).Forget(); }
/// <summary> /// Updates the progress state. /// </summary> /// <param name="state">The state.</param> /// <param name="progressPercent">The progress percent (0 to 1).</param> public void UpdateState(TaskbarItemProgressState state, double progressPercent) { UpdateState(state, progressPercent, null, StatusType.Info); }
private void UpdateProgressCurrent(ProgressInfo info) { if (info == null) { ProgressCopiedCurrent = 0D; RemainingTime = TimeSpan.Zero; ProgressState = TaskbarItemProgressState.None; } else if (info.IsError) { ProgressState = TaskbarItemProgressState.Error; } else { var sizeCopiedLatest = (long)info.CurrentValue; var elapsedTimeLatest = info.ElapsedTime; var sizeCopiedToBeCopiedCurrent = _sizeCopiedCurrent + _sizeToBeCopiedCurrent; if ((sizeCopiedLatest <= 0) || (sizeCopiedToBeCopiedCurrent <= 0)) return; // For just in case ProgressCopiedCurrent = (double)(_sizeCopiedCurrent + sizeCopiedLatest) * 100D / (double)sizeCopiedToBeCopiedCurrent; RemainingTime = TimeSpan.FromSeconds((double)(_sizeToBeCopiedCurrent - sizeCopiedLatest) * elapsedTimeLatest.TotalSeconds / (double)sizeCopiedLatest); ProgressState = TaskbarItemProgressState.Normal; //Debug.WriteLine("ProgressCopiedCurrent: {0} RemainingTime: {1}", ProgressCopiedCurrent, RemainingTime); } }