Exemplo n.º 1
0
        public TaskDialog(Task task = null)
        {
            InitializeComponent();

            if (task != null)
                WindowUtils.ConnectTask(this, task);
        }
Exemplo n.º 2
0
        public TaskDialog(Task task = null)
        {
            XML gxml = new XML(null, "MultiMC.GTKGUI.TaskDialog.glade",
                "vboxTask", null);
            gxml.Autoconnect(this);

            this.Remove(this.VBox);
            this.Add(vboxTask);

            WidthRequest = 400;
            HeightRequest = 110;

            if (task != null)
                WindowUtils.ConnectTask(this, task);
        }
Exemplo n.º 3
0
        public static void ConnectTask(this ITaskDialog dlg, Task task)
        {
            task.ProgressChange += (o, args) =>
                dlg.Invoke((o2, args2) =>
                    dlg.TaskProgress = args.Progress);

            task.StatusChange += (o, args) =>
                dlg.Invoke((o2, args2) =>
                    dlg.TaskStatus = args.Status);

            task.Completed += (o, args) =>
                dlg.Invoke((o2, args2) =>
                    dlg.Close());

            dlg.TaskStatus = task.Status;
            dlg.TaskProgress = task.Progress;
        }
Exemplo n.º 4
0
 void TaskStatusChange(object sender, Task.TaskStatusEventArgs e)
 {
     Invoke((o, args) =>
         {
             (taskProgBars[e.TaskID].Children[0] as ProgressBar).
                 Text = e.Status;
         });
 }
Exemplo n.º 5
0
        void TaskRemoved(Task task)
        {
            if (!taskProgBars.ContainsKey(task.TaskID))
                return;

            ProgressBar pbar = taskProgBars[task.TaskID].Children[0] as ProgressBar;
            pbar.Fraction = 1;
            pbar.Hide();
            mainVBox.Remove(taskProgBars[task.TaskID]);

            lock (this)
            {
                taskProgBars.Remove(task.TaskID);
            }
        }
Exemplo n.º 6
0
        void TaskProgressChange(object sender, Task.ProgressChangeEventArgs e)
        {
            Invoke((o, args) =>
                {
                    double pbarFraction = (float)e.Progress / 100f;
                    if (pbarFraction > 1.0)
                        pbarFraction = 1;

                    (taskProgBars[e.TaskID].Children[0] as ProgressBar).
                        Fraction = pbarFraction;
                });
        }
Exemplo n.º 7
0
        void TaskAdded(Task task)
        {
            if (taskProgBars.ContainsKey(task.TaskID))
                task.TaskID = GetAvailableTaskID();

            HBox tHBox = new HBox();

            ProgressBar tProgBar = new ProgressBar();
            tProgBar.Text = task.Status;
            tProgBar.HeightRequest = 22;

            tHBox.PackStart(tProgBar, true, true, 0);

            task.StatusChange += TaskStatusChange;
            task.ProgressChange += TaskProgressChange;

            lock (this)
            {
                taskProgBars.Add(task.TaskID, tHBox);
            }
            progBarVBox.PackEnd(tHBox, false, true, 0);
            tHBox.ShowAll();
        }
Exemplo n.º 8
0
 void TaskAdded(Task task)
 {
     if (InvokeRequired)
     {
         Invoke((o, args) => TaskAdded(task));
     }
     else
     {
         if (!task.Running)
         {
             task.Started += (o, args) =>
             {
                 AddTaskStatusBar(task);
             };
         }
         else
             AddTaskStatusBar(task);
         task.Completed += (o, args) =>
         {
             Console.WriteLine("Task {0} completed.", task.TaskID);
             RemoveTaskStatusBar(task);
         };
     }
 }
Exemplo n.º 9
0
        void RemoveTaskStatusBar(Task task)
        {
            if (InvokeRequired)
            {
                Invoke((o, args) => RemoveTaskStatusBar(task));
                return;
            }

            if (toolStripContainer.BottomToolStripPanel.Controls.Contains(statusStrips[task.TaskID]))
                toolStripContainer.BottomToolStripPanel.Controls.Remove(statusStrips[task.TaskID]);
        }
Exemplo n.º 10
0
        void AddTaskStatusBar(Task task)
        {
            if (InvokeRequired)
            {
                Invoke((o, args) => AddTaskStatusBar(task));
                return;
            }

            // Status strip
            StatusStrip taskStatusStrip = new StatusStrip();
            statusStrips[task.TaskID] = taskStatusStrip;
            taskStatusStrip.Anchor = AnchorStyles.Top | AnchorStyles.Left |
                AnchorStyles.Right;
            taskStatusStrip.AutoSize = true;
            taskStatusStrip.LayoutStyle = ToolStripLayoutStyle.HorizontalStackWithOverflow;
            taskStatusStrip.SizingGrip = false;

            // Status label
            ToolStripStatusLabel statusLabel = new ToolStripStatusLabel(task.Status);
            statusLabel.Name = "status";
            statusLabel.AutoSize = true;
            task.StatusChange += (o, args) => UpdateStatusLabel(statusLabel, args.Status);
            statusLabel.Text = task.Status;
            statusLabel.Visible = true;
            taskStatusStrip.Items.Add(statusLabel);

            // Progress bar
            ToolStripProgressBar progBar = new ToolStripProgressBar("progress");
            progBar.Alignment = ToolStripItemAlignment.Right;
            progBar.Size = new Size(100, 16);
            task.ProgressChange += (o, args) => UpdateProgBar(progBar, args.Progress);
            UpdateProgBar(progBar, task.Progress);
            progBar.Visible = true;
            taskStatusStrip.Items.Add(progBar);

            // Add the status bar
            toolStripContainer.BottomToolStripPanel.Controls.Add(taskStatusStrip);
            taskStatusStrip.Visible = true;
        }