Ejemplo n.º 1
0
        public void UpdateProgress()
        {
            TaskbarState State    = TaskbarState.NoProgress;
            float        Progress = -1.0f;

            for (int Idx = 0; Idx < TabControl.GetTabCount(); Idx++)
            {
                IMainWindowTabPanel TabPanel = (IMainWindowTabPanel)TabControl.GetTabData(Idx);

                Tuple <TaskbarState, float> DesiredTaskbarState = TabPanel.DesiredTaskbarState;
                if (DesiredTaskbarState.Item1 == TaskbarState.Error)
                {
                    State = TaskbarState.Error;
                    TabControl.SetHighlight(Idx, Tuple.Create(Color.FromArgb(204, 64, 64), 1.0f));
                }
                else if (DesiredTaskbarState.Item1 == TaskbarState.Paused && State != TaskbarState.Error)
                {
                    State = TaskbarState.Paused;
                    TabControl.SetHighlight(Idx, Tuple.Create(Color.FromArgb(255, 242, 0), 1.0f));
                }
                else if (DesiredTaskbarState.Item1 == TaskbarState.Normal && State != TaskbarState.Error && State != TaskbarState.Paused)
                {
                    State    = TaskbarState.Normal;
                    Progress = Math.Max(Progress, DesiredTaskbarState.Item2);
                    TabControl.SetHighlight(Idx, Tuple.Create(Color.FromArgb(28, 180, 64), DesiredTaskbarState.Item2));
                }
                else
                {
                    TabControl.SetHighlight(Idx, null);
                }
            }

            if (IsHandleCreated)
            {
                if (State == TaskbarState.Normal)
                {
                    Taskbar.SetState(Handle, TaskbarState.Normal);
                    Taskbar.SetProgress(Handle, (ulong)(Progress * 1000.0f), 1000);
                }
                else
                {
                    Taskbar.SetState(Handle, State);
                }
            }
        }