コード例 #1
0
 public static void SetValue(IntPtr windowHandle, double progressValue, double progressMax)
 {
     if (taskbarSupported)
     {
         taskbarInstance.SetProgressValue(windowHandle, (ulong)progressValue, (ulong)progressMax);
     }
 }
コード例 #2
0
 public static void SetProgressValue(IntPtr hwnd, ulong value, ulong max)
 {
     if (IsInitialized)
     {
         taskbar.SetProgressValue(hwnd, value, max);
     }
 }
コード例 #3
0
 public static void SetTaskbarProgress(this IWin32Window window, int maxValue, int value)
 {
     if (Instance != null)
     {
         Marshal.ThrowExceptionForHR(
             Instance.SetProgressValue(window.Handle, (ulong)value, (ulong)maxValue));
     }
 }
コード例 #4
0
ファイル: TaskbarList.cs プロジェクト: wushian/Vanara
 /// <summary>Displays or updates a progress bar hosted in a taskbar button to show the specific percentage completed of the full operation.</summary>
 /// <param name="parent">The window whose associated taskbar button is being used as a progress indicator.</param>
 /// <param name="completed">
 /// An application-defined value that indicates the proportion of the operation that has been completed at the time the method is called.
 /// </param>
 /// <param name="total">An application-defined value that specifies the value ullCompleted will have when the operation is complete.</param>
 public static void SetProgressValue(IWin32Window parent, ulong completed, ulong total)
 {
     Validate7OrLater();
     if (parent == null)
     {
         throw new ArgumentNullException(nameof(parent));
     }
     taskbar4?.SetProgressValue(parent.Handle, completed, total);
 }
コード例 #5
0
        /// <summary>
        /// Displays or updates a progress bar hosted in a taskbar button of the main application window
        /// to show the specific percentage completed of the full operation.
        /// </summary>
        /// <param name="currentValue">An application-defined value that indicates the proportion of the operation that has been completed at the time the method is called.</param>
        /// <param name="maximumValue">An application-defined value that specifies the value currentValue will have when the operation is complete.</param>
        public void SetProgressValue(int currentValue, int maximumValue)
        {
            if (!IsWin7())
            {
                return;
            }

            TaskbarList.SetProgressValue(OwnerHandle, Convert.ToUInt32(currentValue), Convert.ToUInt32(maximumValue));
        }
コード例 #6
0
 public void UpdateProgress(ulong completed, ulong total)
 {
     if (_taskbarList != null)
     {
         MainThread.Post(delegate(object x)
         {
             _taskbarList.SetProgressValue(MainThread.MainWindow.Handle, completed, total);
         });
     }
 }
コード例 #7
0
 private void UpdateProgressBarValue(int i)
 {
     if (i < progressBarMinimum || i > progressBarMaximum)
     {
         throw new ArgumentOutOfRangeException();
     }
     SendMessageHelper(TaskDialogMessage.SetProgressBarPosition, i, 0);
     if (!SupportsTaskbarProgress)
     {
         return;
     }
     taskbarList.SetProgressValue(hWndOwner, Convert.ToUInt32(i), Convert.ToUInt32(progressBarMaximum));
 }
コード例 #8
0
 public static void SetProgressValue(IntPtr handle, int currentValue, int maximumValue)
 {
     if (!WindowsUtils.IsWindows7)
     {
         return;
     }
     try
     {
         lock (_taskbarList)
             _taskbarList.SetProgressValue(handle, Convert.ToUInt32(currentValue), Convert.ToUInt32(maximumValue));
     }
     catch
     {}
 }
コード例 #9
0
        static void Main(string[] args)
        {
            var opts = new Args(args);
            var wnds = FindWindow(opts.Title);

            if (wnds.Length == 0)
            {
                Environment.Exit(2);
            }

            ITaskbarList4 inst = null;

            try
            {
                inst = (ITaskbarList4) new CTaskbarList();
                inst.HrInit();
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to create ITaskbarList4 interface, usually because you are not on Windows 7.");
                Console.WriteLine("");
                Console.WriteLine(e.Message);
                Environment.Exit(3);
            }

            foreach (var wnd in wnds)
            {
                if (opts.Value.HasValue)
                {
                    inst.SetProgressValue(wnd, (ulong)opts.Value.Value, 100);
                }
                if (opts.State.HasValue)
                {
                    inst.SetProgressState(wnd, opts.State.Value);
                }
            }
        }
コード例 #10
0
        private void UpdateTaskbar(object sender, PropertyChangedEventArgs e)
        {
            TBPFLAG newProgressState;

            if (testStatistics.Failed > 0)
            {
                newProgressState = TBPFLAG.TBPF_ERROR; // red
            }
            else if (testStatistics.Skipped > 0)
            {
                newProgressState = TBPFLAG.TBPF_PAUSED; // yellow
            }
            else if (testStatistics.Passed > 0)
            {
                newProgressState = TBPFLAG.TBPF_NORMAL; // green
            }
            else
            {
                newProgressState = TBPFLAG.TBPF_NOPROGRESS;
            }

            if (newProgressState != currentProgressState)
            {
                currentProgressState = newProgressState;
                taskBarList.SetProgressState(windowHandle, newProgressState);
            }

            var completed = testStatistics.Passed + testStatistics.Failed +
                            testStatistics.Skipped + testStatistics.Inconclusive;

            var total = completed > testTreeModel.TestCount ? completed
                : testTreeModel.TestCount;

            taskBarList.SetProgressValue(windowHandle, Convert.ToUInt32(completed),
                                         Convert.ToUInt32(total));
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: odalet/misc
 public void SetProgressValue(int currentValue, int maximumValue) =>
 taskbarList.SetProgressValue(OwnerHandle, (ulong)currentValue, (ulong)maximumValue);
コード例 #12
0
        /// <summary>
        /// Displays or updates a progress bar hosted in a taskbar button of the main application window
        /// to show the specific percentage completed of the full operation.
        /// </summary>
        /// <param name="currentValue">An application-defined value that indicates the proportion of the operation that has been completed at the time the method is called.</param>
        /// <param name="maximumValue">An application-defined value that specifies the value currentValue will have when the operation is complete.</param>
        public void SetProgressValue(int currentValue, int maximumValue)
        {
            CoreHelpers.ThrowIfNotWin7();

            TaskbarList.SetProgressValue(OwnerHandle, Convert.ToUInt32(currentValue), Convert.ToUInt32(maximumValue));
        }