public void SetProgress(TaskbarProgressState state, float progress) { switch (state) { case TaskbarProgressState.Indeterminate: SetProgressBar(true, true); break; case TaskbarProgressState.Progress: SetProgressBar(true, false, progress); if (progress >= 1f) { NSApplication.SharedApplication.RequestUserAttention(NSRequestUserAttentionType.InformationalRequest); } break; case TaskbarProgressState.Error: SetProgressBar(progress > 0, false, progress); NSApplication.SharedApplication.RequestUserAttention(NSRequestUserAttentionType.CriticalRequest); break; case TaskbarProgressState.Paused: SetProgressBar(true, false, progress); break; case TaskbarProgressState.None: SetProgressBar(false); break; } }
public void SetProgress(TaskbarProgressState state, float progress) { if (!supported) { return; } var winhandle = Process.GetCurrentProcess().MainWindowHandle; var taskstate = 0; switch (state) { case TaskbarProgressState.Indeterminate: taskstate = 0x1; break; case TaskbarProgressState.Progress: taskstate = 0x2; break; case TaskbarProgressState.Error: taskstate = 0x4; break; case TaskbarProgressState.Paused: taskstate = 0x8; break; } instance.SetProgressState(winhandle, taskstate); instance.SetProgressValue(winhandle, (ulong)(progress * 1000), 1000); }
/// <summary> /// Sets the type and state of the progress indicator displayed on a taskbar button. /// </summary> /// <param name="newState">New progress state.</param> /// <exception cref="System.InvalidOperationException">Default owner must be set before calling this method -or- Native error..</exception> /// <exception cref="System.NotImplementedException">Operation is only supported on Windows 7 and above.</exception> /// <exception cref="System.ComponentModel.Win32Exception">Native error.</exception> public static void SetState(TaskbarProgressState newState) { if (DefaultOwner == null) { throw new InvalidOperationException("Default owner must be set before calling this method."); } SetState(DefaultOwner, newState); }
/// <summary> /// Sets the state and progress of the application. /// </summary> /// <param name="state">Taskbar button state.</param> /// <param name="progress">Progress in range from 0.0f to 1.0f.</param> public static void SetProgress(TaskbarProgressState state, float progress = 0f) { if (progress < 0.0f || progress > 1.0f) { throw new ArgumentOutOfRangeException(nameof(progress), "Progress needs to be in 0.0f to 1.0f range."); } var handler = Platform.Instance.CreateShared <IHandler>(); handler?.SetProgress(state, progress); }
public static void SetProgressState(TaskbarProgressState state) { try { if (TaskbarManager.IsPlatformSupported) { TaskbarManager.Instance.SetProgressState((TaskbarProgressBarState)((Int32)state)); } } catch { } }
/// <summary> /// Set progress bar state (error, normal, paused...) /// </summary> public void SetProgressState(TaskbarProgressState state) { _progress.State = state; if (_progress.State == TaskbarProgressState.NoProgress) { _progress.Value = -1; } Invalidate(); }
protected override void SetProgressState(TaskbarProgressState state) { int flags = state switch { TaskbarProgressState.None => 0, TaskbarProgressState.Indeterminate => 0x1, TaskbarProgressState.Normal => 0x2, TaskbarProgressState.Error => 0x4, TaskbarProgressState.Paused => 0x8, _ => throw new ArgumentOutOfRangeException(nameof(state)) }; _comObject !.SetProgressState(_windowHandle, flags); }
internal void SetState(TaskbarProgressState taskbarState) { //if (_taskbarItems.Count > 0) { _taskbarState = taskbarState; for (int i = 0; i < _taskbarItems.Count; i++) { if (_taskbarItems[i] != null) { try { Player.TaskbarInstance.SetProgressState(_taskbarItems[i].Handle, taskbarState); } catch { _taskbarItems[i] = null; } } } } }
public static void SetProgressState(IntPtr hwnd, TaskbarProgressState state) { OperatingSystem os = Environment.OSVersion; if (os.Platform == PlatformID.Win32NT && (os.Version.Major > 6 || (os.Version.Major == 6 && os.Version.Minor >= 1))) { try { TaskbarList.SetProgressState(hwnd, (TBPFLAG)state); } catch (Exception) { } } }
public void SetProgress(TaskbarProgressState state, float progress) { if (_handle == IntPtr.Zero) { return; } unity_launcher_entry_set_progress_visible(_handle, state != TaskbarProgressState.None); switch (state) { case TaskbarProgressState.None: unity_launcher_entry_set_urgent(_handle, false); unity_launcher_entry_set_progress(_handle, 0f); break; case TaskbarProgressState.Progress: unity_launcher_entry_set_urgent(_handle, (int)progress == 1); unity_launcher_entry_set_progress(_handle, progress); break; case TaskbarProgressState.Paused: unity_launcher_entry_set_urgent(_handle, false); unity_launcher_entry_set_progress(_handle, progress); break; case TaskbarProgressState.Indeterminate: unity_launcher_entry_set_urgent(_handle, false); if (state == TaskbarProgressState.Indeterminate && _state != TaskbarProgressState.Indeterminate) { _state = state; Task.Run(AnimateIndeterminate); } break; case TaskbarProgressState.Error: unity_launcher_entry_set_urgent(_handle, true); unity_launcher_entry_set_progress(_handle, progress); break; } _state = state; }
/// <summary> /// Sets the type and state of the progress indicator displayed on a taskbar button. /// </summary> /// <param name="owner">The window in which the progress of an operation is being shown. This window's associated taskbar button will display the progress bar. If owner is null, default owner is used.</param> /// <param name="newState">New progress state.</param> /// <exception cref="System.ArgumentNullException">Owner cannot be null.</exception> /// <exception cref="System.NotImplementedException">Operation is only supported on Windows 7 and above.</exception> /// <exception cref="System.ComponentModel.Win32Exception">Native error.</exception> public static void SetState(IWin32Window owner, TaskbarProgressState newState) { if (owner == null) { throw new ArgumentNullException("owner", "Owner cannot be null."); } if (TaskbarProgress.IsRunningOnMono) { return; } //Mono has troubles with accessing COM. if (System.Environment.OSVersion.Version.Build < 7000) { if (DoNotThrowNotImplementedException) { return; } else { throw new NotImplementedException("Operation is only supported on Windows 7 and above."); } } Init(); try { if (_taskbarList != null) { var res = _taskbarList.SetProgressState(owner.Handle, newState); if (res != NativeMethods.S_OK) { throw new Win32Exception(string.Format(CultureInfo.InvariantCulture, "Native error {0:x8}.", res)); } } } catch (NotImplementedException) { if (DoNotThrowNotImplementedException == false) { throw; } } }
public static void SetProgressState(IntPtr hwnd, TaskbarProgressState state) { OperatingSystem os = Environment.OSVersion; if (os.Platform == PlatformID.Win32NT && (os.Version.Major > 6 || (os.Version.Major == 6 && os.Version.Minor >= 1))) try { TaskbarList.SetProgressState(hwnd, (TBPFLAG)state); } catch (Exception) { } }
protected override void SetProgressState(TaskbarProgressState state) { throw new PlatformNotSupportedException(); }
private void PlatformSetProgressState(TaskbarProgressState state) { }