void refreshTick(object obj, EventArgs args)
        {
            Program.AssertOnEventThread();

            Timer     timer = (Timer)obj;
            ActionRow row   = (ActionRow)timer.Tag;

            bool redraw = !Disposing && !IsDisposed && !Program.Exiting;
            bool kill   = row.Action == null || row.Action.IsCompleted || !redraw;

            if (redraw)
            {
                // Redraw panel
                CustomHistoryPanel.Invalidate();
                CustomHistoryPanel.Refresh();
            }

            if (kill)
            {
                // Kill timer
                lock (refreshTimersLock)
                {
                    refreshTimers.Remove(timer);
                }
                timer.Stop();
                timer.Dispose();
            }
        }
        private void RowsChanged(CollectionChangeEventArgs e)
        {
            ActionRow row = (ActionRow)e.Element;

            if (e.Action == CollectionChangeAction.Add &&
                !row.Action.IsCompleted)
            {
                Timer refreshTimer = new Timer();
                refreshTimer.Tick    += refreshTick;
                refreshTimer.Interval = 1000;
                refreshTimer.Tag      = row;
                // Add to list to prevent GCing
                lock (refreshTimersLock)
                {
                    refreshTimers.Add(refreshTimer);
                }
                Form f = FindForm();
                Program.Invoke(f ?? Program.MainWindow, refreshTimer.Start);
            }
        }
Exemple #3
0
 protected override void OnMouseClick(MouseEventArgs e)
 {
     Parent.Focus();
     if (e.Button == MouseButtons.Right)
     {
         int       top        = 0;
         ActionRow clickedRow = getRowFromPoint(PointToClient(MousePosition), ref top) as ActionRow;
         if (clickedRow != null)
         {
             ContextMenuStrip  menu     = new ContextMenuStrip();
             ToolStripMenuItem copyItem = new ToolStripMenuItem(Messages.COPY, Properties.Resources.copy_16);
             copyItem.Click += new EventHandler(delegate(object sender, EventArgs eve)
             {
                 Clipboard.SetText(string.Format(Messages.HISTORYPANEL_COPY_FORMAT, Core.PropertyManager.GetFriendlyName("Label-Action.Action"), clickedRow.Title, clickedRow.Description, clickedRow.TimeOccurred));
             });
             menu.Items.Add(copyItem);
             menu.Show(this, PointToClient(MousePosition));
         }
     }
     base.OnMouseClick(e);
 }
Exemple #4
0
        private bool FilterRowVisible(ActionRow row)
        {
            if (!ShowAll && _xenObjects.Find(x => row.AppliesTo.Contains(x.opaque_ref)) == null)
                return false;

            if (!actionsCheckBox.Checked && (row.Type == ActionType.Action || row.Type == ActionType.Meddling))
                return false;

            if (!errorsCheckBox.Checked && (row.Type == ActionType.Error || row.Error))
                return false;

            if (!alertsCheckBox.Checked && row.Type == ActionType.Alert)
                return false;

            if (!informationCheckBox.Checked && row.Type == ActionType.Information)
                return false;

            return true;
        }
Exemple #5
0
        private ActionRow AddRow(ActionBase action)
        {
            ActionRow row = new ActionRow(action);

            Debug.Assert(!string.IsNullOrEmpty(row.Title), "Entries in the logs tab should have a title.");
            Debug.Assert(!row.Title.Contains("{0}"), "Has a string.Format() been forgotten?");

            customHistoryContainer1.CustomHistoryPanel.AddItem(row);
            return row;
        }
 private void AddRow(ActionBase action)
 {
     ActionBase a = action;
         ActionRow row = new ActionRow(action);
         row.ShowCancel = false;
         action.Completed += new EventHandler<EventArgs>(delegate(object o, EventArgs e)
         {
             Program.Invoke(this, delegate()
             {
                 row.Visible = !a.IsCompleted;
                 row.ShowCancel = false;
                 bool canEnd = true;
                 foreach (ActionRow r in customHistoryContainer1.CustomHistoryPanel.Rows)
                 {
                     if (!r.Action.IsCompleted || r.Action.Exception != null)
                     {
                         canEnd = false;
                         break;
                     }
                 }
                 customHistoryContainer1.Refresh();
                 if (canEnd)
                     DialogResult = DialogResult.Ignore;
             });
         });
         action.Changed += new EventHandler<EventArgs>(delegate(object o, EventArgs e)
         {
             Program.Invoke(this, delegate()
             {
                 row.Visible = !a.IsCompleted;
                 row.ShowCancel = false;
                 customHistoryContainer1.Refresh();
             });
         });
         customHistoryContainer1.CustomHistoryPanel.AddItem(row);
 }