SetValue() публичный статический Метод

Sets the value of the progress bar.
public static SetValue ( IntPtr windowHandle, double progressValue, double progressMax ) : void
windowHandle IntPtr The handle of the window.
progressValue double The value of the progress bar.
progressMax double The maximum value of the progress bar.
Результат void
Пример #1
0
        private void S1_Work()
        {
            while (Data.Session.Stage == 1 && Data.Session.Shortcuts.Count >= Data.Session.LastShortcut + 1)
            {
                if (Data.Session.LastShortcut >= Data.Session.Shortcuts.Count)
                {
                    break;
                }

                var item = Data.Session.Shortcuts[Data.Session.LastShortcut++];

                Invoke(new Action(() =>
                {
                    L_Shortcuts_Info.Text = item.Name;
                    TaskbarProgress.SetValue(Handle, 2500d * Data.Session.LastShortcut / Data.Session.Shortcuts.Count, 10000);
                }));

                var error = IconMatcher.Match(item);

                PGB_Shortcuts.Percentage = 100d * Data.Session.LastShortcut / Data.Session.Shortcuts.Count;

                if (error != null)
                {
                    Data.Session.StageErrors[0]++;
#if DEBUG
                    Data.Session.Exceptions.Add(error);
#endif
                }
            }

            if (Data.Session.Stage == 1)
            {
                Stage_2();
            }
        }
Пример #2
0
 public void ProgressFinish()
 {
     toolStripBottomProgressBar.Value = 0;
     TaskbarProgress.SetState(Handle, TaskbarProgress.TaskbarStates.NoProgress);
     TaskbarProgress.SetState(Handle, TaskbarProgress.TaskbarStates.Normal);
     TaskbarProgress.SetValue(Handle, toolStripBottomProgressBar.Value, toolStripBottomProgressBar.Maximum);
 }
Пример #3
0
        private void S2_Work()
        {
            while (Data.Session.Stage == 2 && Data.Session.Folders.Count >= Data.Session.LastFolder + 1)
            {
                if (Data.Session.LastFolder >= Data.Session.Folders.Count)
                {
                    break;
                }

                var item = Data.Session.Folders[Data.Session.LastFolder++];

                Invoke(new Action(() =>
                {
                    L_Folders_Info.Text = item.Name;
                    TaskbarProgress.SetValue(Handle, 2500 + 2500d * Data.Session.LastFolder / Data.Session.Folders.Count, 10000);
                }));

                var error = IconMatcher.Match(item);

                PGB_Folders.Percentage = 100d * Data.Session.LastFolder / Data.Session.Folders.Count;

                if (error != null)
                {
                    Data.Session.StageErrors[2]++;
#if DEBUG
                    Data.Session.Exceptions.Add(error);
#endif
                }
            }

            if (Data.Session.Stage == 2)
            {
                Stage_3();
            }
        }
Пример #4
0
 public void ProgressReset(int max = 0)
 {
     toolStripBottomProgressBar.Value   = 0;
     toolStripBottomProgressBar.Maximum = max;
     TaskbarProgress.SetState(Handle, TaskbarProgress.TaskbarStates.Normal);
     TaskbarProgress.SetValue(Handle, toolStripBottomProgressBar.Value, toolStripBottomProgressBar.Maximum);
 }
Пример #5
0
        private void S3_Work()
        {
            while (Data.Session.Stage == 3 && Data.Session.SecondPassFolders.Count >= Data.Session.LastSecondPass + 1)
            {
                if (Data.Session.LastSecondPass >= Data.Session.SecondPassFolders.Count)
                {
                    break;
                }

                var item = Data.Session.SecondPassFolders[Data.Session.LastSecondPass++];

                Invoke(new Action(() =>
                {
                    L_SecondPass_Info.Text = item.Name;
                    TaskbarProgress.SetValue(Handle, 5000 + 2500d * Data.Session.LastSecondPass / Data.Session.SecondPassFolders.Count, 10000);
                }));

                var error = IconMatcher.ReMatch(item);

                PGB_SecondPass.Percentage = 100d * Data.Session.LastSecondPass / Data.Session.SecondPassFolders.Count;

                if (error != null)
                {
                    Data.Session.StageErrors[3]++;
#if DEBUG
                    Data.Session.Exceptions.Add(error);
#endif
                }
            }

            if (Data.Session.Stage == 3)
            {
                Stage_4();
            }
        }
Пример #6
0
        private void S4_Work()
        {
            while (Data.Session.Stage == 4 && Data.Session.Files.Count >= Data.Session.LastProccessedFile + 1)
            {
                if (Data.Session.LastProccessedFile >= Data.Session.Files.Count)
                {
                    break;
                }

                var item = Data.Session.Files[Data.Session.LastProccessedFile++];

                Invoke(new Action(() =>
                {
                    L_ApplyChanges_Info.Text = item.Name;
                    TaskbarProgress.SetValue(Handle, 7500 + 2500d * Data.Session.LastProccessedFile / Data.Session.Files.Count, 10000);
                }));

                var error = BackEndWorker.SetIcon(item);

                PGB_ApplyChanges.Percentage = 100d * Data.Session.LastProccessedFile / Data.Session.Files.Count;

                if (error != null)
                {
                    Data.Session.StageErrors[4]++;
#if DEBUG
                    Data.Session.Exceptions.Add(error);
#endif
                }
            }

            if (Data.Session.Stage == 4)
            {
                End();
            }
        }
Пример #7
0
        void InitializeProgressScreen(string progressOf, ProgressBarStyle style = ProgressBarStyle.Marquee)
        {
            menuStrip.Enabled
                                          = lblGameDir.Enabled
                                          = txtGameDir.Enabled
                                          = btnSelectGameDir.Enabled
                                          = splitContainer.Panel1.Enabled
                                          = splitContainer.Panel2.Enabled
                                          = false;
            progressBar.Value             = 0;
            lblProgressCurrentPhase.Text  = progressOf;
            lblProgressCurrentAction.Text = string.Empty;
            progressBar.Style             = style;

            switch (style)
            {
            case ProgressBarStyle.Continuous:
                TaskbarProgress.SetValue(this.Handle, 0, 100);
                TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.Normal);
                break;

            case ProgressBarStyle.Marquee:
                TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.Indeterminate);
                break;
            }

            pnlProgress.Visible = true;
            Update();
        }
Пример #8
0
 void SetProgress(int value, int max)
 {
     if (Disposing)
     {
         return;
     }
     try
     {
         if (InvokeRequired)
         {
             Invoke(new Action <int, int>(SetProgress), new object[] { value, max });
             if (value == max)
             {
                 Thread.Sleep(1000);
             }
             return;
         }
         if (value > max)
         {
             value = max;
         }
         progressBar.Maximum = max;
         progressBar.Value   = value;
         TaskbarProgress.SetState(this, TaskbarProgress.TaskbarStates.Normal);
         TaskbarProgress.SetValue(this, value, max);
     }
     catch { }
 }
Пример #9
0
 protected override void UpdateTaskbarProgress(TaskbarProgress.TaskbarStates state, int?percentComplete)
 {
     _taskbarProgress.SetState(Handle, state);
     if (percentComplete.HasValue)
     {
         _taskbarProgress.SetValue(Handle, percentComplete.Value, 100);
     }
 }
Пример #10
0
        void OnRefreshConflictsProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            progressBar.Value             = e.ProgressPercentage;
            lblProgressCurrentAction.Text = e.UserState as string;

            TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.Normal);
            TaskbarProgress.SetValue(this.Handle, e.ProgressPercentage, 100);
        }
        private void DoWork(List <FileCopyInfo> filesToCopy, IntPtr handle, long bytesToCopy, Label fileCopyLabel, List <string> filesToDelete, string destinationFolder)
        {
            continueCopy = true;
            long bytesCopied = 0;

            filesToDelete.Each((filePathToDelete, i) =>
            {
                UpdateLabel(fileCopyLabel, string.Format("Deleting {0} of {1} files", (i + 1), filesToDelete.Count));

                try
                {
                    File.SetAttributes(filePathToDelete, FileAttributes.Normal);
                    File.Delete(filePathToDelete);
                }
                catch (UnauthorizedAccessException) { }

                return(continueCopy);
            });

            filesToCopy.Each((copyInfo, i) =>
            {
                UpdateLabel(fileCopyLabel, string.Format("Copying {0} of {1} files", (i + 1), filesToCopy.Count));
                string directoryPath = Delimon.Win32.IO.Path.GetDirectoryName(copyInfo.DestinationPath);
                if (!Directory.Exists(directoryPath))
                {
                    Directory.CreateDirectory(directoryPath);
                }

                try
                {
                    try { Delimon.Win32.IO.File.SetAttributes(copyInfo.DestinationPath, Delimon.Win32.IO.FileAttributes.Normal); }
                    catch (System.IO.FileNotFoundException) { }
                    catch (System.Exception e) { if (!e.Message.StartsWith("The system cannot find the file specified"))
                                                 {
                                                     throw;
                                                 }
                    }
                    Delimon.Win32.IO.File.Copy(copyInfo.SourcePath, copyInfo.DestinationPath, true);
                }
                catch (UnauthorizedAccessException) { }

                TaskbarProgress.SetState(handle, TaskbarProgress.TaskbarStates.Normal);
                TaskbarProgress.SetValue(handle, bytesCopied, IfZero(bytesToCopy, 1));
                bytesCopied += copyInfo.FileSizeBytes;
                return(continueCopy);
            });

            DeleteEmptyFolders(destinationFolder);

            TaskbarProgress.SetState(handle, TaskbarProgress.TaskbarStates.Normal);
            TaskbarProgress.SetValue(handle, 1, 1);

            string labelText = continueCopy ? "Copying Completed" : "Copying Stopped";

            UpdateLabel(fileCopyLabel, labelText);
            MessageBox.Show(labelText);
            TaskbarProgress.SetState(handle, TaskbarProgress.TaskbarStates.NoProgress);
        }
Пример #12
0
        private void _RoboCommand_OnCopyProgressChanged(object sender, CopyProgressEventArgs e)
        {
            BeginInvoke((Action)(() =>
            {
                TaskbarProgress.SetValue(Handle, (int)e.CurrentFileProgress, 100);

                CurrentFileProgress.Value = (int)e.CurrentFileProgress;
            }));
        }
Пример #13
0
        public void UpdateProgress(int done, string message)
        {
            var progressPercentage = Total > 0 ? done * 100 / Total : 99;
            var text = $@"{message} {done} / {Total} ({progressPercentage:F2}%)";

            Text = Title + "..." + $@"{done} / {Total} ({progressPercentage:F2}%)";
            Progress.SetProgress((int)progressPercentage, text);
            TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.Normal);
            TaskbarProgress.SetValue(this.Handle, (double)progressPercentage, 100.0);
            Application.DoEvents();
        }
Пример #14
0
 public static void SetPosition(uint position)
 {
     if (position > maxRange)
     {
         EnableItermediate();
     }
     else
     {
         TaskbarProgress.SetValue(position, maxRange);
     }
 }
Пример #15
0
 public void UpdateTaskbarProgress(int?percentComplete)
 {
     if (!percentComplete.HasValue)
     {
         _taskbarProgress.SetState(Handle, TaskbarProgress.TaskbarStates.NoProgress);
     }
     else
     {
         _taskbarProgress.SetState(Handle, TaskbarProgress.TaskbarStates.Normal);
         _taskbarProgress.SetValue(Handle, percentComplete.Value, 100);
     }
 }
Пример #16
0
        public static void Main(string[] args)
        {
            // http://stackoverflow.com/questions/1295890/windows-7-progress-bar-in-taskbar-in-c

            //TaskbarProgress.SetState(Process.GetCurrentProcess().MainWindowHandle
            //    , TaskbarProgress.TaskbarStates.Indeterminate);

            //            or

            TaskbarProgress.SetValue(Process.GetCurrentProcess().MainWindowHandle, 50, 100);
            TaskbarProgress.SetState(Process.GetCurrentProcess().MainWindowHandle, TaskbarProgress.TaskbarStates.Paused);
            TaskbarProgress.SetState(Process.GetCurrentProcess().MainWindowHandle, TaskbarProgress.TaskbarStates.Error);

            RewriteToUltraApplication.AsProgram.Launch(typeof(Application));
        }
Пример #17
0
 private void WorkerForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if ((thread != null) && (e.CloseReason == CloseReason.UserClosing))
     {
         if (MessageBox.Show(this, Resources.DoYouWantCancel, Resources.AreYouSure, MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
             == System.Windows.Forms.DialogResult.No)
         {
             e.Cancel = true;
             return;
         }
         if (thread != null)
         {
             thread.Abort();
         }
         TaskbarProgress.SetState(this, TaskbarProgress.TaskbarStates.NoProgress);
         TaskbarProgress.SetValue(this, 0, 1);
     }
 }
Пример #18
0
        private void ChangeListItem(int ItemIndex, int SubIndex, string str)
        {
            int barMax = Program.totalCount;

            if (Program.scannedCount == barMax)
            {
                button1.Enabled = true;
                TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.NoProgress);
                button2.Enabled = true;
                button3.Enabled = true;
            }
            else
            {
                TaskbarProgress.SetValue(this.Handle, Program.scannedCount, barMax);
            }
            progressBar1.Value = Program.scannedCount;
            listView1.Items[ItemIndex].SubItems[SubIndex].Text = str;
        }
Пример #19
0
 public ITaskerView SetProgress(long value, long maximum)
 {
     if (Tasker.HostForm.Disposing || value < 0 || maximum < 0)
     {
         return(this);
     }
     try
     {
         if (Tasker.HostForm.InvokeRequired)
         {
             return((ITaskerView)Tasker.HostForm.Invoke(new Func <long, long, ITaskerView>(SetProgress), new object[] { value, maximum }));
         }
         if ((new Tasker.State[] { Tasker.State.Running, Tasker.State.Paused, Tasker.State.Error }).Contains(taskState))
         {
             TaskbarProgress.SetValue(Tasker.HostForm, value, maximum);
         }
     }
     catch (InvalidOperationException) { }
     return(this);
 }
Пример #20
0
        private void AddListItem(ListViewItem str)
        {
            this.listView1.Items.Add(str);
            ip ipEnum = new ip();
            //int barMax = Math.Abs(ipEnum.IPToNumber(textBox2.Text) - ipEnum.IPToNumber(textBox1.Text));
            int barMax = Program.totalCount;

            if (Program.scannedCount == barMax)
            {
                button1.Enabled = true;
                TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.NoProgress);
                button2.Enabled = true;
                button3.Enabled = true;
            }
            else
            {
                TaskbarProgress.SetValue(this.Handle, Program.scannedCount, barMax);
            }
            progressBar1.Value = Program.scannedCount;
        }
Пример #21
0
        // Update the progress bar
        void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            // The progress percentage is a property of e
            progressBar1.Value = e.ProgressPercentage;

#if WINDOWS_7_BUILD
            try {
                TaskbarProgress.SetValue(this.Handle, e.ProgressPercentage, 100);

                if (progressStalled == 1)
                {
                    TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.Error);
                }
                else
                {
                    TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.Normal);
                }
            }
            catch (ObjectDisposedException a) {
                Console.WriteLine("Caught: {0}", a.Message);
            }
#endif
        }
Пример #22
0
        void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            if (e.ProgressPercentage < 0)
            {
                toolStripProgressBar_Info.Style = ProgressBarStyle.Marquee;
                TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.Indeterminate);
            }
            else
            {
                toolStripProgressBar_Info.Style = ProgressBarStyle.Blocks;
                toolStripProgressBar_Info.Value = e.ProgressPercentage;
                TaskbarProgress.SetValue(this.Handle, e.ProgressPercentage, 100);
            }

            OwnUserState userState = e.UserState as OwnUserState;

            labelInfo.Text = userState.Status;
            if (userState.UpdateNeeded == true)
            {
                dataGridView_Result.Refresh();
                userState.UpdateNeeded = false;
            }
        }
Пример #23
0
        void AddMessage(float?progress, string message, bool isWarning)
        {
            if (!(bool)Invoke((Func <bool>) delegate
            {
                if (progress.HasValue)
                {
                    pbStato.Value = (int)Math.Round(MathC.Clamp(progress.Value, 0, 100), 0);
                    TaskbarProgress.SetValue(Application.OpenForms[0].Handle, progress.Value, 100);
                }

                if (!string.IsNullOrEmpty(message))
                {
                    lstLog.SelectionBackColor = isWarning ? Color.Yellow.Multiply(Colors.Brightness) : Color.Empty;
                    lstLog.AppendText(message + "\n");
                    lstLog.ScrollToCaret();
                }

                return(!_threadShouldAbort);
            }))
            {
                throw new OperationCanceledException();
            }
        }
Пример #24
0
        private void _RoboCommand_OnCommandCompleted(object sender, RoboCommandCompletedEventArgs e)
        {
            BeginInvoke((Action)(() =>
            {
                _Stopwatch.Stop();

                CurrentFileProgress.Value = 100;

                TaskbarProgress.SetValue(Handle, 100, 100);

                PauseResumeButton.Enabled = false;

                Text = "Finished";

                JobLogger.Log(new Job
                {
                    TotalMillseconds = _Stopwatch.ElapsedMilliseconds,
                    TotalBytes = TotalFileSize,
                    TotalFiles = FileCount
                });

                Activate();
            }));
        }
Пример #25
0
        private void tPlayerUpdate_Tick(object sender, EventArgs e)
        {
            //Media length in seconds
            var Length = (int)(Player.Length / 1000d);
            //Force position into length
            var Position = Math.Max(0, Math.Min(Length, (int)Math.Floor(Player.Position)));

            //Don't adjust length and position if they're not calculated yet
            if (Length > 0 && Position > 0)
            {
                //Set length if it doesn't matches
                if (pbTime.Maximum != Length)
                {
                    //Reduce current displayed time if it's outside of bounds
                    if (pbTime.Value > Length)
                    {
                        pbTime.Value = pbTime.Minimum;
                    }
                    pbTime.Maximum = Length;
                }
                if (pbTime.Value != Position)
                {
                    pbTime.Value     = Position;
                    pbTime.ForeColor = ColFromPerc(Position * 100d / Length);
                    pbTime.Refresh();
                    using (var G = pbTime.CreateGraphics())
                    {
                        using (var B = new SolidBrush(Color.Green))
                        {
                            G.DrawString(new TimeSpan(0, 0, 0, 0, Position * 1000).ToString(), Fixedsys, B, new Point(pbTime.Width / 2 - 40, 2));
                        }
                    }
                    TaskbarProgress.SetValue(Handle, Position, Length);
                }
            }
        }
Пример #26
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     TaskbarProgress.SetState(formPublisher.Handle, TaskbarProgress.TaskbarStates.Paused);
     TaskbarProgress.SetValue(formPublisher.Handle, 0, pbMain.Maximum);
     backgroundWorker.CancelAsync();
 }
Пример #27
0
 private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     pbMain.Value = e.ProgressPercentage;
     TaskbarProgress.SetState(formPublisher.Handle, TaskbarProgress.TaskbarStates.Indeterminate);
     TaskbarProgress.SetValue(formPublisher.Handle, pbMain.Value, pbMain.Maximum);
 }
Пример #28
0
 private void DisplayProgress(ProgressChangedEventArgs e)
 {
     toolStripProgressBar_Info.Style = ProgressBarStyle.Blocks;
     toolStripProgressBar_Info.Value = e.ProgressPercentage;
     TaskbarProgress.SetValue(this.Handle, e.ProgressPercentage, 100);
 }
Пример #29
0
 public static double window_value(IntPtr Handle, double value, double maxvalue)
 {
     TaskbarProgress.SetValue(Handle, value, maxvalue);
     return(1.0);
 }
Пример #30
0
        private void Tick(Object source, RenderingEventArgs e)
        {
            DateTime time = DateTime.Now;
            double   tick = (time - lastTick_).TotalMilliseconds;

            if (handle_ == IntPtr.Zero)
            {
                handle_ = Process.GetCurrentProcess().MainWindowHandle;
            }
            if (running_)
            {
                TimeSpan elapsed = time - startPoint_;
                TimeSpan total   = endPoint_ - startPoint_;
                if (this.WindowState == WindowState.Minimized)
                {
                    DrawIcon(elapsed.TotalMilliseconds, total.TotalMilliseconds, !working_, cycle_);
                }
                else
                {
                    if (elapsed.TotalMilliseconds >= nextSecond_)
                    {
                        nextSecond_ += 1000.0;
                        ArcTo(nextSecond_ / total.TotalMilliseconds);
                        TaskbarProgress.SetState(handle_, TaskbarProgress.TaskbarStates.Normal);
                        TaskbarProgress.SetValue(handle_, nextSecond_, total.TotalMilliseconds);
                    }
                    DrawCurrentClock();
                }
                // Tell the main thread to update the arc soonish.
                if (time >= endPoint_)
                {
                    if (settings_.Sound)
                    {
                        if (settings_.PauseMusic)
                        {
                            MediaControl.Pause();
                        }
                        resumePlay_ = time + new TimeSpan(0, 0, 0, 0, 500);
                        mediaPlayer_.Play();
                        mediaPlayer_.Position = new TimeSpan(0);
                    }
                    minimise_.ShowBaloon("Time's up!");
                    if (working_)
                    {
                        minimise_.BringToFront();
                    }
                    NextCycle(time);
                }
                if (time >= resumePlay_)
                {
                    if (settings_.PauseMusic)
                    {
                        MediaControl.Play();
                    }
                    resumePlay_ = DateTime.MaxValue;
                }
            }
            else
            {
                Text_Cycle.Content = "(Paused)";
                if (this.WindowState != WindowState.Minimized)
                {
                    TaskbarProgress.SetState(handle_, TaskbarProgress.TaskbarStates.Normal);
                }
            }
            if (!working_ && currentPlugin_ != null)
            {
                if (currentPlugin_.Update(tick) || windowDirty_)
                {
                    currentPlugin_.Render(Canvas_Clock);
                }
            }
            clockParent_.Children.Clear();
            customRenders_.Tick(clockParent_.Children, tick);
            lastTick_    = time;
            windowDirty_ = false;
        }