Esempio n. 1
0
 private void AsyncWaitDialog_FormClosing(object sender, FormClosingEventArgs e)
 {
     WindowsTaskbar.SetProgressState(Handle, WindowsTaskbar.ProgressBarState.NoProgress);
 }
Esempio n. 2
0
        /// <inheritdoc/>
        public void Report(TaskSnapshot value)
        {
            // Ensure execution on GUI thread
            if (InvokeRequired)
            {
                BeginInvoke(new Action <TaskSnapshot>(Report), value);
                return;
            }

            switch (value.State)
            {
            case TaskState.Ready:
                // When the State is complete the bar should always be empty
                Style = ProgressBarStyle.Continuous;
                Value = 0;

                if (UseTaskbar && ParentHandle != IntPtr.Zero)
                {
                    WindowsTaskbar.SetProgressState(ParentHandle, WindowsTaskbar.ProgressBarState.NoProgress);
                }
                break;

            case TaskState.Started:
            case TaskState.Header:
                Style = ProgressBarStyle.Marquee;
                if (UseTaskbar && ParentHandle != IntPtr.Zero)
                {
                    WindowsTaskbar.SetProgressState(ParentHandle, WindowsTaskbar.ProgressBarState.Indeterminate);
                }
                break;

            case TaskState.Data:
                if (value.UnitsTotal == -1)
                {
                    Style = ProgressBarStyle.Marquee;
                    if (UseTaskbar && ParentHandle != IntPtr.Zero)
                    {
                        WindowsTaskbar.SetProgressState(ParentHandle, WindowsTaskbar.ProgressBarState.Indeterminate);
                    }
                }
                else
                {
                    Style = ProgressBarStyle.Continuous;
                    if (UseTaskbar && ParentHandle != IntPtr.Zero)
                    {
                        WindowsTaskbar.SetProgressState(ParentHandle, WindowsTaskbar.ProgressBarState.Normal);
                    }
                }
                break;

            case TaskState.IOError:
            case TaskState.WebError:
                Style = ProgressBarStyle.Continuous;
                if (UseTaskbar && ParentHandle != IntPtr.Zero)
                {
                    WindowsTaskbar.SetProgressState(ParentHandle, WindowsTaskbar.ProgressBarState.Error);
                }
                break;

            case TaskState.Complete:
                // When the State is complete the bar should always be full
                Style = ProgressBarStyle.Continuous;
                Value = 100;

                if (UseTaskbar && ParentHandle != IntPtr.Zero)
                {
                    WindowsTaskbar.SetProgressState(ParentHandle, WindowsTaskbar.ProgressBarState.NoProgress);
                }
                break;
            }

            var currentValue = (int)(value.Value * 100);

            if (currentValue < 0)
            {
                currentValue = 0;
            }
            else if (currentValue > 100)
            {
                currentValue = 100;
            }

            // When the State is complete the bar should always be full
            if (value.State == TaskState.Complete)
            {
                currentValue = 100;
            }

            Value = currentValue;
            IntPtr formHandle = ParentHandle;

            if (UseTaskbar && formHandle != IntPtr.Zero)
            {
                WindowsTaskbar.SetProgressValue(formHandle, currentValue, 100);
            }
        }
Esempio n. 3
0
 private void AsyncWaitDialog_Shown(object sender, EventArgs e)
 {
     WindowsTaskbar.SetProgressState(Handle, WindowsTaskbar.ProgressBarState.Indeterminate);
 }
Esempio n. 4
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            WindowsTaskbar.SetProgressState(Handle, WindowsTaskbar.ProgressBarState.Indeterminate);

            backgroundWorker.RunWorkerAsync();
        }