diff --git a/XenAdmin/Actions/GUIActions/MeddlingAction.cs b/XenAdmin/Actions/GUIActions/MeddlingAction.cs index f85ecd501..c0bf18e22 100644 --- a/XenAdmin/Actions/GUIActions/MeddlingAction.cs +++ b/XenAdmin/Actions/GUIActions/MeddlingAction.cs @@ -47,7 +47,7 @@ namespace XenAdmin.Actions.GUIActions private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); public MeddlingAction(Task task) - : base(ActionType.Meddling, task.MeddlingActionTitle ?? task.Title, task.Description, false, false) + : base(task.MeddlingActionTitle ?? task.Title, task.Description, false, false) { RelatedTask = new XenRef(task.opaque_ref); Started = (task.created + task.Connection.ServerTimeOffset).ToLocalTime(); diff --git a/XenAdmin/Commands/DisconnectCommand.cs b/XenAdmin/Commands/DisconnectCommand.cs index b1d5767c1..84daae0de 100644 --- a/XenAdmin/Commands/DisconnectCommand.cs +++ b/XenAdmin/Commands/DisconnectCommand.cs @@ -142,7 +142,7 @@ namespace XenAdmin.Commands { string msg = string.Format(Messages.CONNECTION_CLOSED_NOTICE_TEXT, connection.Hostname); log.Warn(msg); - ActionBase notice = new ActionBase(ActionType.Information, msg, msg, false); + ActionBase notice = new ActionBase(msg, msg, false, true); notice.Pool = Helpers.GetPoolOfOne(connection); notice.Host = Helpers.GetMaster(connection); diff --git a/XenAdmin/Commands/RemoveHostCommand.cs b/XenAdmin/Commands/RemoveHostCommand.cs index 277a443c9..429012c85 100644 --- a/XenAdmin/Commands/RemoveHostCommand.cs +++ b/XenAdmin/Commands/RemoveHostCommand.cs @@ -73,7 +73,7 @@ namespace XenAdmin.Commands { string msg = string.Format(Messages.MAINWINDOW_LOG_REMOVECONNECTION, host.Connection.Hostname); log.Info(msg); - new ActionBase(ActionType.Information, msg, msg, false); + new ActionBase(msg, msg, false, true); MainWindowCommandInterface.CloseActiveWizards(host.Connection); host.Connection.EndConnect(); MainWindowCommandInterface.RemoveConnection(host.Connection); diff --git a/XenAdmin/Controls/CustomHistoryPanel/ActionRow.cs b/XenAdmin/Controls/CustomHistoryPanel/ActionRow.cs index 75752ec21..4ce1b750a 100644 --- a/XenAdmin/Controls/CustomHistoryPanel/ActionRow.cs +++ b/XenAdmin/Controls/CustomHistoryPanel/ActionRow.cs @@ -47,7 +47,6 @@ namespace XenAdmin.Controls /// public ActionBase Action; public List AppliesTo = new List(); - public ActionType Type; private DateTime finished = DateTime.MinValue; @@ -72,7 +71,6 @@ namespace XenAdmin.Controls public ActionRow(ActionBase action) { - Type = action.Type; AppliesTo = action.AppliesTo; Action = action; this.Image = getImage(); @@ -153,11 +151,11 @@ namespace XenAdmin.Controls this.Title = Action.Title; } - Error = (Action.Exception != null || Action.Type == ActionType.Error) && !(Action.Exception is CancelledException); + Error = (Action.Exception != null) && !(Action.Exception is CancelledException); Image = getImage(); - ShowTime = Action.Type == ActionType.Action || Action.Type == ActionType.Meddling || Action.Type == ActionType.Error; + ShowTime = Action.Finished - Action.Started >= TimeSpan.FromSeconds(1); if (Action.Exception == null) { @@ -182,7 +180,6 @@ namespace XenAdmin.Controls if (Action.IsCompleted) { - Type = Action.Type; finished = Action.Finished; if (ParentPanel != null) { @@ -203,18 +200,31 @@ namespace XenAdmin.Controls private Image getImage() { - switch (Action.Type) - { - case ActionType.Information: - return Properties.Resources._000_Info3_h32bit_16; - case ActionType.Action: - case ActionType.Meddling: - return Properties.Resources.commands_16; - case ActionType.Error: - return Properties.Resources._000_error_h32bit_16; - default: - throw new InvalidEnumArgumentException(); - } + if (Action.IsCompleted) + return Action.Succeeded + ? Properties.Resources._000_Tick_h32bit_16 + : Properties.Resources._000_error_h32bit_16; + + if (Action.PercentComplete < 10) + return Properties.Resources.usagebar_0; + if (Action.PercentComplete < 20) + return Properties.Resources.usagebar_1; + if (Action.PercentComplete < 30) + return Properties.Resources.usagebar_2; + if (Action.PercentComplete < 40) + return Properties.Resources.usagebar_3; + if (Action.PercentComplete < 50) + return Properties.Resources.usagebar_4; + if (Action.PercentComplete < 60) + return Properties.Resources.usagebar_5; + if (Action.PercentComplete < 70) + return Properties.Resources.usagebar_6; + if (Action.PercentComplete < 80) + return Properties.Resources.usagebar_7; + if (Action.PercentComplete < 90) + return Properties.Resources.usagebar_8; + + return Properties.Resources.usagebar_9; } } } diff --git a/XenAdmin/Controls/CustomHistoryPanel/CustomHistoryPanel.cs b/XenAdmin/Controls/CustomHistoryPanel/CustomHistoryPanel.cs index d3f0921e0..b20eacc51 100644 --- a/XenAdmin/Controls/CustomHistoryPanel/CustomHistoryPanel.cs +++ b/XenAdmin/Controls/CustomHistoryPanel/CustomHistoryPanel.cs @@ -46,12 +46,8 @@ namespace XenAdmin.Controls { public readonly ChangeableList Rows = new ChangeableList(); - internal const int col1 = 35; internal int col2 = -1; - private int col4; - - internal int col3; - + internal int col4; public bool SuspendDraw = false; public int ScrollTop = 0; @@ -79,8 +75,6 @@ namespace XenAdmin.Controls col4 = 10 + (int)Drawing.MeasureText(g, HelpersGUI.DateTimeToString(new DateTime(9999, 12, 30, 20, 58, 58), Messages.DATEFORMAT_DMY_HMS, true), Font).Width; } - col3 = Width - (6 + col1 + col2 + col4); - g.FillRectangle(Application.RenderWithVisualStyles ? SystemBrushes.ControlLightLight : SystemBrushes.Control, Bounds); int top = 0; @@ -182,7 +176,7 @@ namespace XenAdmin.Controls 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(string.Format("Label-Action.{0}", clickedRow.Type.ToString())), clickedRow.Title, clickedRow.Description, clickedRow.TimeOccurred)); + 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)); diff --git a/XenAdmin/Controls/CustomHistoryPanel/CustomHistoryRow.cs b/XenAdmin/Controls/CustomHistoryPanel/CustomHistoryRow.cs index 34adf7d9b..c855ed032 100644 --- a/XenAdmin/Controls/CustomHistoryPanel/CustomHistoryRow.cs +++ b/XenAdmin/Controls/CustomHistoryPanel/CustomHistoryRow.cs @@ -45,6 +45,20 @@ namespace XenAdmin.Controls { public static readonly Padding Margin = new Padding(3); + private int col1 + { + get { return Image == null ? 89 : Image.Width + 19; } + } + private int col3 + { + get + { + return ParentPanel == null + ? 0 + : ParentPanel.Width - (6 + col1 + ParentPanel.col2 + ParentPanel.col4); + } + } + private static readonly string DescriptionLabel = Messages.HISTORYROW_DETAILS; private static readonly string ErrorLabel = Messages.HISTORYROW_ERROR; private static readonly string TimeLabel = Messages.HISTORYROW_TIME; @@ -66,7 +80,7 @@ namespace XenAdmin.Controls public string Title; public string Description; public string TimeOccurred; - public CustomHistoryPanel ParentPanel = null; + public CustomHistoryPanel ParentPanel; public bool ButtonPressed = false; public bool Visible = true; public bool ShowCancel = true; @@ -104,18 +118,18 @@ namespace XenAdmin.Controls int top = Bounds.Top + ItemPadding.Top + InternalPadding.Top; int left = Bounds.Left + InternalPadding.Left; - int rowheight1 = HeightRow1() + ItemPadding.Vertical; - int rowheight2 = HeightRow2() + ItemPadding.Vertical; - int rowheight3 = ShowTime ? HeightRow3() + ItemPadding.Vertical : 0; + int rowheight1 = HeightOf(Title, TitleFont, ParentPanel.col2 + col3) + ItemPadding.Vertical; + int rowheight2 = HeightOf(Description, Font, col3) + ItemPadding.Vertical; + int rowheight3 = ShowTime ? HeightOf(TimeTaken, Font, col3) + ItemPadding.Vertical : 0; int rowheight4 = ShowProgress ? 17 + ItemPadding.Vertical : 0; RowHeight = rowheight1 + rowheight2 + rowheight3 + rowheight4 + InternalPadding.Vertical; RowWidth = Bounds.Width; if (g != null && Bounds.Top < visibleBottom && Bounds.Top + RowHeight > visibleTop && Bounds.Top + RowHeight <= Int16.MaxValue) { - int left1 = left + CustomHistoryPanel.col1; + int left1 = left + col1; int left2 = left1 + ParentPanel.col2; - int left3 = left2 + ParentPanel.col3; + int left3 = left2 + col3; int top1 = top + rowheight1; int top2 = top1 + rowheight2; int top3 = top2 + rowheight3; @@ -133,15 +147,15 @@ namespace XenAdmin.Controls g.DrawLine(ErrorPenThick, Bounds.Left, Bounds.Top, Bounds.Left, Bounds.Top + RowHeight + 1); } - g.DrawImage(Image, left + ((CustomHistoryPanel.col1 - Image.Width) / 2), top, Image.Width, Image.Height); - Drawing.DrawText(g, Title, TitleFont, new Rectangle(left1, top, ParentPanel.col2 + ParentPanel.col3, rowheight1), TitleColor, TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl); + g.DrawImage(Image, left + ((col1 - Image.Width) / 2), top, Image.Width, Image.Height); + Drawing.DrawText(g, Title, TitleFont, new Rectangle(left1, top, ParentPanel.col2 + col3, rowheight1), TitleColor, TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl); Drawing.DrawText(g, TimeOccurred, Font, new Point(left3, top), TextColor); if(!Error) Drawing.DrawText(g, DescriptionLabel, Font, new Point(left1, top1), TextColor); else Drawing.DrawText(g, ErrorLabel, Font, new Point(left1, top1), ErrorColor); - Drawing.DrawText(g, Description, Font, new Rectangle(left2, top1, ParentPanel.col3, rowheight2), TextColor, TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl); + Drawing.DrawText(g, Description, Font, new Rectangle(left2, top1, col3, rowheight2), TextColor, TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl); if (ShowCancel) { @@ -185,7 +199,7 @@ namespace XenAdmin.Controls if (ShowTime) { Drawing.DrawText(g, TimeLabel, Font, new Point(left1, top2), TextColor); - Drawing.DrawText(g, TimeTaken, Font, new Rectangle(left2, top2, ParentPanel.col3, rowheight3), TextColor, TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl); + Drawing.DrawText(g, TimeTaken, Font, new Rectangle(left2, top2, col3, rowheight3), TextColor, TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl); } if (ShowProgress) @@ -193,16 +207,16 @@ namespace XenAdmin.Controls if (Application.RenderWithVisualStyles) { Drawing.DrawText(g, ProgressLabel, Font, new Point(left1, top3), TextColor); - ProgressBarRenderer.DrawHorizontalBar(g, new Rectangle(left2, top3, ParentPanel.col3, 17)); - ProgressBarRenderer.DrawHorizontalChunks(g, new Rectangle(left2 + 4, top3 + 3, (Progress * (ParentPanel.col3 - 8) / 100), 12)); + ProgressBarRenderer.DrawHorizontalBar(g, new Rectangle(left2, top3, col3, 17)); + ProgressBarRenderer.DrawHorizontalChunks(g, new Rectangle(left2 + 4, top3 + 3, (Progress * (col3 - 8) / 100), 12)); } else { Drawing.DrawText(g, ProgressLabel, Font, new Point(left1, top3), TextColor); - g.FillRectangle(SystemBrushes.ButtonShadow, new Rectangle(left2, top3, ParentPanel.col3, 17)); - g.FillRectangle(SystemBrushes.ButtonHighlight, new Rectangle(left2 + 1, top3 + 1, ParentPanel.col3 - 1, 16)); - g.FillRectangle(SystemBrushes.ButtonFace, new Rectangle(left2 + 1, top3 + 1, ParentPanel.col3 - 2, 15)); - int barwidth = (Progress * (ParentPanel.col3 - 4) / 100); + g.FillRectangle(SystemBrushes.ButtonShadow, new Rectangle(left2, top3, col3, 17)); + g.FillRectangle(SystemBrushes.ButtonHighlight, new Rectangle(left2 + 1, top3 + 1, col3 - 1, 16)); + g.FillRectangle(SystemBrushes.ButtonFace, new Rectangle(left2 + 1, top3 + 1, col3 - 2, 15)); + int barwidth = (Progress * (col3 - 4) / 100); int chunkwidth = 7; int chunkgap = 2; int progleft = 0; @@ -218,21 +232,6 @@ namespace XenAdmin.Controls } g.FillRectangle(SystemBrushes.ActiveCaption, new Rectangle(left2 + 2 + progleft, top3 + 2, chunkwidth - progleft, 13)); } - /*int barwidth = (Progress * (ParentPanel.col3 - 8) / 100); - int chunkwidth = 7; - int chunkgap = 1; - int progleft = 0; - while (true) - { - if (progleft + chunkwidth + chunkgap < barwidth) - { - ChunkRenderer.DrawBackground(g, new Rectangle(left2 + 4 + progleft, t + rowheight2 + rowheight3 + 3, chunkwidth, 12)); - progleft += chunkwidth + chunkgap; - } - else - break; - } - ChunkRenderer.DrawBackground(g, new Rectangle(left2 + 4 + progleft, t + rowheight2 + rowheight3 + 3, chunkwidth - progleft, 12));*/ } } @@ -245,21 +244,6 @@ namespace XenAdmin.Controls return h > 0 ? h : 12; } - private int HeightRow3() - { - return HeightOf(TimeTaken, Font, ParentPanel.col3); - } - - private int HeightRow2() - { - return HeightOf(Description, Font, ParentPanel.col3); - } - - private int HeightRow1() - { - return HeightOf(Title, TitleFont, ParentPanel.col2 + ParentPanel.col3); - } - internal void Click(Point p, MouseButtons button) { if (button == MouseButtons.Left && ShowCancel && CancelEnabled) @@ -290,8 +274,8 @@ namespace XenAdmin.Controls private Rectangle CancelButtonRect() { - return new Rectangle(Margin.Left + InternalPadding.Left + CustomHistoryPanel.col1 + ParentPanel.col2 + ParentPanel.col3, - Margin.Left + InternalPadding.Top + ItemPadding.Top + ItemPadding.Vertical + HeightRow1(), 75, 23); + return new Rectangle(Margin.Left + InternalPadding.Left + col1 + ParentPanel.col2 + col3, + Margin.Left + InternalPadding.Top + ItemPadding.Top + ItemPadding.Vertical + HeightOf(Title, TitleFont, ParentPanel.col2 + col3), 75, 23); } } } diff --git a/XenAdmin/Dialogs/OptionsPages/SaveAndRestoreOptionsPage.cs b/XenAdmin/Dialogs/OptionsPages/SaveAndRestoreOptionsPage.cs index 75c0f956d..2879d6aeb 100644 --- a/XenAdmin/Dialogs/OptionsPages/SaveAndRestoreOptionsPage.cs +++ b/XenAdmin/Dialogs/OptionsPages/SaveAndRestoreOptionsPage.cs @@ -101,7 +101,8 @@ namespace XenAdmin.Dialogs.OptionsPages // set password Program.MasterPassword = TemporaryMasterPassword; - new ActionBase(ActionType.Information, Messages.CHANGED_MASTER_PASSWORD, Messages.CHANGED_MASTER_PASSWORD_LONG, false, true); + new ActionBase(Messages.CHANGED_MASTER_PASSWORD, + Messages.CHANGED_MASTER_PASSWORD_LONG, false, true); } if (SaveAllAfter) Settings.SaveServerList(); diff --git a/XenAdmin/Dialogs/WarningDialogs/CloseXenCenterWarningDialog.cs b/XenAdmin/Dialogs/WarningDialogs/CloseXenCenterWarningDialog.cs index 0174bcf92..e1168e089 100644 --- a/XenAdmin/Dialogs/WarningDialogs/CloseXenCenterWarningDialog.cs +++ b/XenAdmin/Dialogs/WarningDialogs/CloseXenCenterWarningDialog.cs @@ -71,7 +71,7 @@ namespace XenAdmin.Dialogs.WarningDialogs foreach (ActionBase action in ConnectionsManager.History) { AsyncAction a = action as AsyncAction; - if (action.Type == ActionType.Action && !action.IsCompleted && (a == null || !a.Cancelling)) + if (!action.IsCompleted && (a == null || !a.Cancelling)) { IXenObject xo = (action.Pool as IXenObject) ?? (action.Host as IXenObject) ?? (action.VM as IXenObject) ?? (action.SR as IXenObject); if (xo == null || xo.Connection != connection) @@ -86,7 +86,7 @@ namespace XenAdmin.Dialogs.WarningDialogs { foreach (ActionBase action in ConnectionsManager.History) { - if (action.Type == ActionType.Action && !action.IsCompleted) + if (!action.IsCompleted) { AddRow(action); } diff --git a/XenAdmin/MainWindow.cs b/XenAdmin/MainWindow.cs index 45029b3b8..92074da7f 100644 --- a/XenAdmin/MainWindow.cs +++ b/XenAdmin/MainWindow.cs @@ -380,19 +380,15 @@ namespace XenAdmin if (Program.Exiting) return; - //Program.AssertOnEventThread(); Program.BeginInvoke(Program.MainWindow, () => { ActionBase action = (ActionBase)e.Element; if (action == null) return; - if (action.Type == ActionType.Action) - { - action.Changed += actionChanged; - action.Completed += actionChanged; - actionChanged(action); - } + action.Changed += actionChanged; + action.Completed += actionChanged; + actionChanged(action); }); } @@ -803,10 +799,7 @@ namespace XenAdmin new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Error, message, linkStart, linkLength, linkUrl, Messages.CONNECTION_REFUSED_TITLE)).ShowDialog(this); - ActionBase failedAction = new ActionBase(ActionType.Error, Messages.CONNECTION_REFUSED, message, false, false); - failedAction.IsCompleted = true; - failedAction.PercentComplete = 100; - failedAction.Finished = DateTime.Now; + new ActionBase(Messages.CONNECTION_REFUSED, message, false, true, Messages.CONNECTION_REFUSED_TITLE); }); return; } @@ -2877,7 +2870,7 @@ namespace XenAdmin bool currentTasks = false; foreach (ActionBase a in ConnectionsManager.History) { - if (a.Type == ActionType.Action && !a.IsCompleted) + if (!a.IsCompleted) { currentTasks = true; break; diff --git a/XenAdmin/TabPages/HistoryPage.Designer.cs b/XenAdmin/TabPages/HistoryPage.Designer.cs index 5111fd3d2..38f379c93 100644 --- a/XenAdmin/TabPages/HistoryPage.Designer.cs +++ b/XenAdmin/TabPages/HistoryPage.Designer.cs @@ -35,9 +35,6 @@ namespace XenAdmin.TabPages this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.button1 = new System.Windows.Forms.Button(); this.gradientPanel1 = new XenAdmin.Controls.GradientPanel.GradientPanel(); - this.errorsCheckBox = new System.Windows.Forms.CheckBox(); - this.informationCheckBox = new System.Windows.Forms.CheckBox(); - this.actionsCheckBox = new System.Windows.Forms.CheckBox(); this.label1 = new System.Windows.Forms.Label(); this.customHistoryContainer1 = new XenAdmin.Controls.CustomHistoryContainer(); this.gradientPanel1.SuspendLayout(); @@ -55,49 +52,10 @@ namespace XenAdmin.TabPages // resources.ApplyResources(this.gradientPanel1, "gradientPanel1"); this.gradientPanel1.Controls.Add(this.button1); - this.gradientPanel1.Controls.Add(this.errorsCheckBox); - this.gradientPanel1.Controls.Add(this.informationCheckBox); - this.gradientPanel1.Controls.Add(this.actionsCheckBox); this.gradientPanel1.Controls.Add(this.label1); this.gradientPanel1.Name = "gradientPanel1"; this.gradientPanel1.Scheme = XenAdmin.Controls.GradientPanel.GradientPanel.Schemes.Tab; // - // errorsCheckBox - // - resources.ApplyResources(this.errorsCheckBox, "errorsCheckBox"); - this.errorsCheckBox.BackColor = System.Drawing.Color.Transparent; - this.errorsCheckBox.Checked = true; - this.errorsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; - this.errorsCheckBox.ForeColor = System.Drawing.Color.White; - this.errorsCheckBox.Image = global::XenAdmin.Properties.Resources._000_error_h32bit_16; - this.errorsCheckBox.Name = "errorsCheckBox"; - this.errorsCheckBox.UseVisualStyleBackColor = false; - this.errorsCheckBox.CheckedChanged += new System.EventHandler(this.errorsCheckBox_CheckedChanged); - // - // informationCheckBox - // - resources.ApplyResources(this.informationCheckBox, "informationCheckBox"); - this.informationCheckBox.BackColor = System.Drawing.Color.Transparent; - this.informationCheckBox.Checked = true; - this.informationCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; - this.informationCheckBox.ForeColor = System.Drawing.Color.White; - this.informationCheckBox.Image = global::XenAdmin.Properties.Resources._000_Info3_h32bit_16; - this.informationCheckBox.Name = "informationCheckBox"; - this.informationCheckBox.UseVisualStyleBackColor = false; - this.informationCheckBox.CheckedChanged += new System.EventHandler(this.informationCheckBox_CheckedChanged); - // - // actionsCheckBox - // - resources.ApplyResources(this.actionsCheckBox, "actionsCheckBox"); - this.actionsCheckBox.BackColor = System.Drawing.Color.Transparent; - this.actionsCheckBox.Checked = true; - this.actionsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; - this.actionsCheckBox.ForeColor = System.Drawing.Color.White; - this.actionsCheckBox.Image = global::XenAdmin.Properties.Resources.commands_16; - this.actionsCheckBox.Name = "actionsCheckBox"; - this.actionsCheckBox.UseVisualStyleBackColor = false; - this.actionsCheckBox.CheckedChanged += new System.EventHandler(this.actionsCheckBox_CheckedChanged); - // // label1 // this.label1.BackColor = System.Drawing.Color.Transparent; @@ -127,9 +85,6 @@ namespace XenAdmin.TabPages #endregion - private System.Windows.Forms.CheckBox informationCheckBox; - private System.Windows.Forms.CheckBox actionsCheckBox; - private System.Windows.Forms.CheckBox errorsCheckBox; private XenAdmin.Controls.CustomHistoryContainer customHistoryContainer1; private System.Windows.Forms.Button button1; private System.Windows.Forms.ToolTip toolTip1; diff --git a/XenAdmin/TabPages/HistoryPage.cs b/XenAdmin/TabPages/HistoryPage.cs index f43a16a67..ed0c2da99 100644 --- a/XenAdmin/TabPages/HistoryPage.cs +++ b/XenAdmin/TabPages/HistoryPage.cs @@ -61,10 +61,6 @@ namespace XenAdmin.TabPages label1.ForeColor = Program.HeaderGradientForeColor; label1.Font = Program.HeaderGradientFont; - - actionsCheckBox.ForeColor = Program.HeaderGradientForeColor; - errorsCheckBox.ForeColor = Program.HeaderGradientForeColor; - informationCheckBox.ForeColor = Program.HeaderGradientForeColor; } public void SetXenObjects(IEnumerable xenObjects) @@ -181,38 +177,9 @@ namespace XenAdmin.TabPages 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 (!informationCheckBox.Checked && row.Type == ActionType.Information) - return false; - return true; } - private void actionsCheckBox_CheckedChanged(object sender, EventArgs e) - { - BuildRowList(); - } - - private void alertsCheckBox_CheckedChanged(object sender, EventArgs e) - { - BuildRowList(); - } - - private void informationCheckBox_CheckedChanged(object sender, EventArgs e) - { - BuildRowList(); - } - - private void errorsCheckBox_CheckedChanged(object sender, EventArgs e) - { - BuildRowList(); - } - private void action_Changed(ActionBase sender) { Program.Invoke(this, delegate diff --git a/XenAdmin/TabPages/HistoryPage.resx b/XenAdmin/TabPages/HistoryPage.resx index 13e6a01fd..28ccc6c87 100644 --- a/XenAdmin/TabPages/HistoryPage.resx +++ b/XenAdmin/TabPages/HistoryPage.resx @@ -165,105 +165,6 @@ Top, Left, Right - - Top, Right - - - NoControl - - - 379, 5 - - - 72, 26 - - - 1 - - - &Errors - - - ImageBeforeText - - - errorsCheckBox - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gradientPanel1 - - - 1 - - - Top, Right - - - NoControl - - - 549, 5 - - - 113, 26 - - - 4 - - - &Information - - - ImageBeforeText - - - informationCheckBox - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gradientPanel1 - - - 2 - - - Top, Right - - - NoControl - - - 457, 5 - - - 86, 26 - - - 3 - - - Actio&ns - - - ImageBeforeText - - - actionsCheckBox - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gradientPanel1 - - - 3 - Fill @@ -301,7 +202,7 @@ gradientPanel1 - 4 + 1 0, 0 diff --git a/XenAdminTests/FolderTests/FolderTest.cs b/XenAdminTests/FolderTests/FolderTest.cs index 98d9dbf30..0c65a314b 100644 --- a/XenAdminTests/FolderTests/FolderTest.cs +++ b/XenAdminTests/FolderTests/FolderTest.cs @@ -93,7 +93,7 @@ namespace XenAdminTests.FolderTests { foreach (XenAdmin.Actions.ActionBase a in ConnectionsManager.History) { - if (a.Type == ActionType.Action && !a.IsCompleted) + if (!a.IsCompleted) return true; } return false; diff --git a/XenModel/Actions/Action.cs b/XenModel/Actions/Action.cs index a49e46b47..092c76a24 100644 --- a/XenModel/Actions/Action.cs +++ b/XenModel/Actions/Action.cs @@ -38,13 +38,10 @@ using XenAdmin.Core; namespace XenAdmin.Actions { - public enum ActionType { Error, Information, Action, Meddling }; - public class ActionBase { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - public ActionType Type; public string Title; /// @@ -265,27 +262,32 @@ namespace XenAdmin.Actions public const int MAX_HISTORY_ITEM = 1000; - public ActionBase(ActionType type, string title, string description, bool SuppressHistory) - : this(type, title, description, SuppressHistory, true) + public ActionBase(string title, string description, bool suppressHistory) + : this(title, description, suppressHistory, false) { } - public ActionBase(ActionType type, string title, string description, bool SuppressHistory, bool non_action_completed) + public ActionBase(string title, string description, bool suppressHistory, bool completeImmediately) + : this(title, description, suppressHistory, completeImmediately, null) + {} + + public ActionBase(string title, string description, bool suppressHistory, bool completeImmediately, string error) { - Type = type; Title = title; _description = description; log.Debug(_description); - if (type != ActionType.Action && non_action_completed) + if (completeImmediately) { + if (!string.IsNullOrEmpty(error)) + _exception = new Exception(error); + Finished = DateTime.Now; _percentComplete = 100; _isCompleted = true; } - if (NewAction != null && !SuppressHistory) + if (NewAction != null && !suppressHistory) NewAction(this); - } public string Description @@ -344,11 +346,6 @@ namespace XenAdmin.Actions get { return _exception; } protected set { - if (!(value is CancelledException)) - { - // Only set to error if not cancelled by user - this.Type = ActionType.Error; - } _exception = value; OnChanged(); } @@ -431,7 +428,7 @@ namespace XenAdmin.Actions MarkCompletedCore(); } - protected void MarkCompletedCore() + private void MarkCompletedCore() { Finished = DateTime.Now; PercentComplete = 100; diff --git a/XenModel/Actions/AsyncAction.cs b/XenModel/Actions/AsyncAction.cs index 64df1f1d8..70869454d 100644 --- a/XenModel/Actions/AsyncAction.cs +++ b/XenModel/Actions/AsyncAction.cs @@ -51,8 +51,8 @@ namespace XenAdmin.Actions private string _result; - protected AsyncAction(IXenConnection connection, string title, string description, bool SuppressHistory) - : base(ActionType.Action, title, description, SuppressHistory) + protected AsyncAction(IXenConnection connection, string title, string description, bool suppressHistory) + : base(title, description, suppressHistory) { this.Connection = connection; } @@ -370,7 +370,7 @@ namespace XenAdmin.Actions continue; AsyncAction a = action as AsyncAction; - if (action.Type == ActionType.Action && !action.IsCompleted && (a == null || !a.Cancelling)) + if (!action.IsCompleted && (a == null || !a.Cancelling)) { return false; } diff --git a/XenModel/Actions/CancellingAction.cs b/XenModel/Actions/CancellingAction.cs index f849d03af..a258453e3 100644 --- a/XenModel/Actions/CancellingAction.cs +++ b/XenModel/Actions/CancellingAction.cs @@ -59,13 +59,13 @@ namespace XenAdmin.Actions /// private volatile bool cancelled = false; - public CancellingAction(ActionType type, string title, string description, bool SuppressHistory) - : base(type, title, description, SuppressHistory) + public CancellingAction(string title, string description, bool suppressHistory) + : base(title, description, suppressHistory) { } - public CancellingAction(ActionType type, string title, string description, bool SuppressHistory, bool non_action_completed) - : base(type, title, description, SuppressHistory, non_action_completed) + public CancellingAction(string title, string description, bool suppressHistory, bool completeImmediately) + : base(title, description, suppressHistory, completeImmediately) { } diff --git a/XenModel/Network/ConnectionsManager.cs b/XenModel/Network/ConnectionsManager.cs index a2675fb73..f1f221edb 100644 --- a/XenModel/Network/ConnectionsManager.cs +++ b/XenModel/Network/ConnectionsManager.cs @@ -123,7 +123,7 @@ namespace XenAdmin if (xo == null || xo.Connection != connection) continue; - if (action.Type == ActionType.Action && !action.IsCompleted) + if (!action.IsCompleted) { return false; } @@ -139,7 +139,7 @@ namespace XenAdmin if (xo == null || xo.Connection != connection) continue; - if (action.Type == ActionType.Action && !action.IsCompleted) + if (!action.IsCompleted) { action.Cancel(); } diff --git a/XenModel/Network/XenConnection.cs b/XenModel/Network/XenConnection.cs index 5a8eb545b..10972ca28 100644 --- a/XenModel/Network/XenConnection.cs +++ b/XenModel/Network/XenConnection.cs @@ -1000,7 +1000,7 @@ namespace XenAdmin.Network string msg = string.Format(Messages.CONNECTING_NOTICE_TEXT, name); log.Info(msg); - ConnectAction = new ActionBase(ActionType.Information, title, msg, false, false); + ConnectAction = new ActionBase(title, msg, false, false); ExpectPasswordIsCorrect = true; OnConnectionResult(true, null, null); @@ -1479,8 +1479,9 @@ namespace XenAdmin.Network string msg = string.Format(Messages.CONNECTION_RESTRICTED_MESSAGE, e.HostName, e.ExistingHostName); log.Info(msg); // Add an informational log message saying why the connection attempt failed - ActionBase action = new ActionBase(ActionType.Error, - string.Format(Messages.CONNECTION_RESTRICTED_NOTICE_TITLE, e.HostName), msg, false); + ActionBase action = new ActionBase( + string.Format(Messages.CONNECTION_RESTRICTED_NOTICE_TITLE, e.HostName), + msg, false, true, Messages.CONNECTION_RESTRICTED_NOTICE_TITLE); SetPoolAndHostInAction(action, pool, PoolOpaqueRef); OnConnectionResult(false, Messages.CONNECTION_RESTRICTED_MESSAGE, error); @@ -1509,7 +1510,8 @@ namespace XenAdmin.Network log.WarnFormat("IXenConnection: failed to connect to {0}: {1}", this.HostnameWithPort, reason); // Create a new log message to say the connection attempt failed - ActionBase n = new ActionBase(ActionType.Information, string.Format(Messages.CONNECTION_FAILED_TITLE, HostnameWithPort), reason, false); + string title = string.Format(Messages.CONNECTION_FAILED_TITLE, HostnameWithPort); + ActionBase n = new ActionBase(title, reason, false, true, title); SetPoolAndHostInAction(n, pool, PoolOpaqueRef); Failure f = error as Failure; @@ -1654,10 +1656,10 @@ namespace XenAdmin.Network description = string.Format(Messages.CONNECTION_LOST_RECONNECT_IN_X_SECONDS, LastConnectionFullName, ReconnectHostTimeoutMs / 1000); } - ActionBase n = new ActionBase(ActionType.Information, string.Format(Messages.CONNECTION_LOST_NOTICE_TITLE, LastConnectionFullName), - description, false); + string title = string.Format(Messages.CONNECTION_LOST_NOTICE_TITLE, + LastConnectionFullName); + ActionBase n = new ActionBase(title, description, false, true, title); SetPoolAndHostInAction(n, pool, poolopaqueref); - OnConnectionLost(); } @@ -1808,8 +1810,10 @@ namespace XenAdmin.Network private void ReconnectMaster() { // Add an informational entry to the log - ActionBase action = new ActionBase(ActionType.Information, string.Format(Messages.CONNECTION_FINDING_MASTER_TITLE, LastConnectionFullName), - string.Format(Messages.CONNECTION_FINDING_MASTER_DESCRIPTION, LastConnectionFullName, Hostname), false); + ActionBase action = new ActionBase( + string.Format(Messages.CONNECTION_FINDING_MASTER_TITLE, LastConnectionFullName), + string.Format(Messages.CONNECTION_FINDING_MASTER_DESCRIPTION, LastConnectionFullName, Hostname), + false, true); SetPoolAndHostInAction(action, null, PoolOpaqueRef); log.DebugFormat("Looking for master for {0} on {1}...", LastConnectionFullName, Hostname);