CP-6267: Restored status strip on the main window.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2013-11-12 12:44:19 +00:00
parent 0d1b7b2b74
commit 9de85b8772
6 changed files with 237 additions and 27 deletions

View File

@ -83,12 +83,16 @@ namespace XenAdmin.Controls.MainWindowControls
[Browsable(true)]
public event Action TreeViewRefreshResumed;
internal event Action<string> DragDropCommandActivated;
#endregion
public NavigationPane()
{
InitializeComponent();
navigationView.DragDropCommandActivated += navigationView_DragDropCommandActivated;
AddNavigationItemPair(buttonInfraBig, buttonInfraSmall);
AddNavigationItemPair(buttonObjectsBig, buttonObjectsSmall);
AddNavigationItemPair(buttonOrganizationBig, buttonOrganizationSmall);
@ -282,6 +286,13 @@ namespace XenAdmin.Controls.MainWindowControls
#region Control Event Handlers
private void navigationView_DragDropCommandActivated(string cmdText)
{
if (DragDropCommandActivated != null)
DragDropCommandActivated(cmdText);
}
private void navigationView_TreeViewSelectionChanged()
{
if (TreeViewSelectionChanged != null)

View File

@ -89,6 +89,8 @@ namespace XenAdmin.Controls.MainWindowControls
[Browsable(true)]
public event Action TreeViewRefreshResumed;
internal event Action<string> DragDropCommandActivated;
#endregion
public NavigationView()
@ -451,6 +453,9 @@ namespace XenAdmin.Controls.MainWindowControls
_highlightedDragTarget.ForeColor = treeView.ForeColor;
_highlightedDragTarget = null;
treeBuilder.HighlightedDragTarget = null;
if (DragDropCommandActivated != null)
DragDropCommandActivated(null);
}
}
@ -697,13 +702,20 @@ namespace XenAdmin.Controls.MainWindowControls
}
VirtualTreeNode targetToHighlight = null;
string statusBarText = null;
foreach (DragDropCommand cmd in GetDragDropCommands(targetNode, e.Data))
{
if (cmd.CanExecute())
targetToHighlight = cmd.HighlightNode;
if (cmd.StatusBarText != null)
statusBarText = cmd.StatusBarText;
}
if (DragDropCommandActivated != null)
DragDropCommandActivated(statusBarText);
if (targetToHighlight != null)
{
if (_highlightedDragTarget != targetToHighlight)

View File

@ -269,6 +269,9 @@ namespace XenAdmin
this.MainMenuBar = new XenAdmin.Controls.MenuStripEx();
this.securityGroupsToolStripMenuItem = new XenAdmin.Commands.CommandToolStripMenuItem();
this.MenuPanel = new System.Windows.Forms.Panel();
this.StatusStrip = new System.Windows.Forms.StatusStrip();
this.statusLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.statusProgressBar = new System.Windows.Forms.ToolStripProgressBar();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
@ -282,6 +285,7 @@ namespace XenAdmin
this.ToolBarContextMenu.SuspendLayout();
this.MainMenuBar.SuspendLayout();
this.MenuPanel.SuspendLayout();
this.StatusStrip.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
@ -1742,6 +1746,28 @@ namespace XenAdmin
resources.ApplyResources(this.MenuPanel, "MenuPanel");
this.MenuPanel.Name = "MenuPanel";
//
// StatusStrip
//
resources.ApplyResources(this.StatusStrip, "StatusStrip");
this.StatusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.statusLabel,
this.statusProgressBar});
this.StatusStrip.Name = "StatusStrip";
//
// statusLabel
//
resources.ApplyResources(this.statusLabel, "statusLabel");
this.statusLabel.Name = "statusLabel";
this.statusLabel.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never;
this.statusLabel.Spring = true;
//
// statusProgressBar
//
resources.ApplyResources(this.statusProgressBar, "statusProgressBar");
this.statusProgressBar.Margin = new System.Windows.Forms.Padding(5);
this.statusProgressBar.Name = "statusProgressBar";
this.statusProgressBar.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never;
//
// MainWindow
//
resources.ApplyResources(this, "$this");
@ -1749,6 +1775,7 @@ namespace XenAdmin
this.Controls.Add(this.splitContainer1);
this.Controls.Add(this.ToolStrip);
this.Controls.Add(this.MenuPanel);
this.Controls.Add(this.StatusStrip);
this.DoubleBuffered = true;
this.KeyPreview = true;
this.MainMenuStrip = this.MainMenuBar;
@ -1775,6 +1802,8 @@ namespace XenAdmin
this.MainMenuBar.ResumeLayout(false);
this.MainMenuBar.PerformLayout();
this.MenuPanel.ResumeLayout(false);
this.StatusStrip.ResumeLayout(false);
this.StatusStrip.PerformLayout();
this.ResumeLayout(false);
}
@ -1989,6 +2018,9 @@ namespace XenAdmin
private ToolStripMenuItem customTemplatesToolStripMenuItem;
private ToolStripMenuItem templatesToolStripMenuItem1;
private ToolStripMenuItem localStorageToolStripMenuItem;
private StatusStrip StatusStrip;
private ToolStripStatusLabel statusLabel;
private ToolStripProgressBar statusProgressBar;
}
}

View File

@ -99,6 +99,9 @@ namespace XenAdmin
internal readonly VMStoragePage VMStoragePage = new VMStoragePage();
internal readonly AdPage AdPage = new AdPage();
private ActionBase statusBarAction = null;
public ActionBase StatusBarAction { get { return statusBarAction; } }
private bool IgnoreTabChanges = false;
private bool ToolbarsEnabled;
@ -165,6 +168,7 @@ namespace XenAdmin
AddTabContents(SearchPage, TabPageSearch);
TheTabControl.SelectedIndexChanged += TheTabControl_SelectedIndexChanged;
navigationPane.DragDropCommandActivated += navigationPane_DragDropCommandActivated;
PoolCollectionChangedWithInvoke = Program.ProgramInvokeHandler(CollectionChanged<Pool>);
MessageCollectionChangedWithInvoke = Program.ProgramInvokeHandler(MessageCollectionChanged);
@ -184,7 +188,6 @@ namespace XenAdmin
contextMenuBuilder = new ContextMenuBuilder(pluginManager, commandInterface);
SearchPage.SearchChanged += SearchPanel_SearchChanged;
Alert.XenCenterAlerts.CollectionChanged += XenCenterAlerts_CollectionChanged;
FormFontFixer.Fix(this);
@ -197,6 +200,8 @@ namespace XenAdmin
TitleLabel.ForeColor = Program.TitleBarForeColor;
loggedInLabel1.SetTextColor(Program.TitleBarForeColor);
statusProgressBar.Visible = false;
SelectionManager.BindTo(MainMenuBar.Items, commandInterface);
SelectionManager.BindTo(ToolStrip.Items, commandInterface);
Properties.Settings.Default.SettingChanging += Default_SettingChanging;
@ -362,6 +367,17 @@ namespace XenAdmin
if (action == null)
return;
var meddlingAction = action as MeddlingAction;
if (meddlingAction == null)
{
SetStatusBar(null, null);
if (statusBarAction != null)
{
statusBarAction.Changed -= actionChanged;
statusBarAction.Completed -= actionChanged;
}
statusBarAction = action;
}
action.Changed += actionChanged;
action.Completed += actionChanged;
actionChanged(action);
@ -378,15 +394,26 @@ namespace XenAdmin
void actionChanged_(ActionBase action)
{
var meddlingAction = action as MeddlingAction;
if (meddlingAction == null)
statusProgressBar.Visible = action.ShowProgress && !action.IsCompleted;
// Be defensive against CA-8517.
if (action.PercentComplete < 0 || action.PercentComplete > 100)
{
log.ErrorFormat("PercentComplete is erroneously {0}", action.PercentComplete);
}
else if (meddlingAction == null)
{
statusProgressBar.Value = action.PercentComplete;
}
// Don't show cancelled exception
if (action.Exception != null && !(action.Exception is CancelledException))
{
if (meddlingAction == null)
SetStatusBar(XenAdmin.Properties.Resources._000_error_h32bit_16, action.Exception.Message);
IXenObject model =
(IXenObject)action.VM ??
(IXenObject)action.Host ??
@ -397,6 +424,31 @@ namespace XenAdmin
RequestRefreshTreeView();
}
else if (meddlingAction == null)
{
SetStatusBar(null,
action.IsCompleted ? null :
!string.IsNullOrEmpty(action.Description) ? action.Description :
!string.IsNullOrEmpty(action.Title) ? action.Title :
null);
}
}
public void SetStatusBar(Image image, string message)
{
if ((statusLabel.Text != null && statusLabel.Text.Equals(message))
|| (statusLabel.Image != null && statusLabel.Equals(image)))
return;
statusLabel.Image = image;
statusLabel.Text = Helpers.FirstLine(message);
statusToolTip.SetToolTip(StatusStrip, message);
}
public void SetProgressBar(bool visible, int progress)
{
statusProgressBar.Visible = visible;
statusProgressBar.Value = progress;
}
private void MainWindow_Shown(object sender, EventArgs e)
@ -2512,6 +2564,11 @@ namespace XenAdmin
return name;
}
void navigationPane_DragDropCommandActivated(string cmdText)
{
SetStatusBar(null, cmdText);
}
private void navigationPane_TreeViewSelectionChanged()
{
UpdateToolbars();

View File

@ -135,7 +135,7 @@
<value>0, 0</value>
</data>
<data name="navigationPane.Size" type="System.Drawing.Size, System.Drawing">
<value>243, 675</value>
<value>243, 648</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="navigationPane.TabIndex" type="System.Int32, mscorlib">
@ -187,7 +187,7 @@
<value>0, 0, 0, 0</value>
</data>
<data name="TabPageHome.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="TabPageHome.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
@ -217,7 +217,7 @@
<value>0, 0, 0, 0</value>
</data>
<data name="TabPageGeneral.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="TabPageGeneral.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
@ -244,7 +244,7 @@
<value>4, 22</value>
</data>
<data name="TabPageBallooning.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="TabPageBallooning.TabIndex" type="System.Int32, mscorlib">
<value>14</value>
@ -268,7 +268,7 @@
<value>4, 22</value>
</data>
<data name="TabPageBallooningUpsell.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="TabPageBallooningUpsell.TabIndex" type="System.Int32, mscorlib">
<value>19</value>
@ -298,7 +298,7 @@
<value>0, 0, 0, 0</value>
</data>
<data name="TabPageConsole.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="TabPageConsole.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
@ -328,7 +328,7 @@
<value>0, 0, 0, 0</value>
</data>
<data name="TabPageStorage.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="TabPageStorage.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
@ -358,7 +358,7 @@
<value>3, 3, 3, 3</value>
</data>
<data name="TabPagePhysicalStorage.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="TabPagePhysicalStorage.TabIndex" type="System.Int32, mscorlib">
<value>12</value>
@ -388,7 +388,7 @@
<value>0, 0, 0, 0</value>
</data>
<data name="TabPageSR.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="TabPageSR.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
@ -418,7 +418,7 @@
<value>0, 0, 0, 0</value>
</data>
<data name="TabPageNetwork.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="TabPageNetwork.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
@ -448,7 +448,7 @@
<value>0, 0, 0, 0</value>
</data>
<data name="TabPageNICs.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="TabPageNICs.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
@ -481,7 +481,7 @@
<value>0, 0, 0, 0</value>
</data>
<data name="TabPagePeformance.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="TabPagePeformance.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
@ -508,7 +508,7 @@
<value>3, 3, 3, 3</value>
</data>
<data name="TabPageHA.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="TabPageHA.TabIndex" type="System.Int32, mscorlib">
<value>10</value>
@ -535,7 +535,7 @@
<value>3, 3, 3, 3</value>
</data>
<data name="TabPageHAUpsell.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="TabPageHAUpsell.TabIndex" type="System.Int32, mscorlib">
<value>15</value>
@ -568,7 +568,7 @@
<value>0, 0, 0, 0</value>
</data>
<data name="snapshotPage.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="snapshotPage.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -592,7 +592,7 @@
<value>0, 0, 0, 0</value>
</data>
<data name="TabPageSnapshots.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="TabPageSnapshots.TabIndex" type="System.Int32, mscorlib">
<value>17</value>
@ -616,7 +616,7 @@
<value>4, 22</value>
</data>
<data name="TabPageWLB.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="TabPageWLB.TabIndex" type="System.Int32, mscorlib">
<value>14</value>
@ -640,7 +640,7 @@
<value>4, 22</value>
</data>
<data name="TabPageWLBUpsell.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="TabPageWLBUpsell.TabIndex" type="System.Int32, mscorlib">
<value>16</value>
@ -664,7 +664,7 @@
<value>4, 22</value>
</data>
<data name="TabPageAD.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="TabPageAD.TabIndex" type="System.Int32, mscorlib">
<value>18</value>
@ -694,7 +694,7 @@
<value>0, 0, 0, 0</value>
</data>
<data name="TabPageSearch.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 619</value>
<value>753, 592</value>
</data>
<data name="TabPageSearch.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -724,7 +724,7 @@
<value>0, 0</value>
</data>
<data name="TheTabControl.Size" type="System.Drawing.Size, System.Drawing">
<value>761, 645</value>
<value>761, 618</value>
</data>
<data name="TheTabControl.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -754,7 +754,7 @@
<value>12, 12, 12, 12</value>
</data>
<data name="alertPage.Size" type="System.Drawing.Size, System.Drawing">
<value>761, 645</value>
<value>761, 618</value>
</data>
<data name="alertPage.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -784,7 +784,7 @@
<value>12, 12, 12, 12</value>
</data>
<data name="updatesPage.Size" type="System.Drawing.Size, System.Drawing">
<value>761, 645</value>
<value>761, 618</value>
</data>
<data name="updatesPage.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -814,7 +814,7 @@
<value>12, 12, 12, 12</value>
</data>
<data name="eventsPage.Size" type="System.Drawing.Size, System.Drawing">
<value>761, 645</value>
<value>761, 618</value>
</data>
<data name="eventsPage.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
@ -1027,7 +1027,7 @@
<value>100</value>
</data>
<data name="splitContainer1.Size" type="System.Drawing.Size, System.Drawing">
<value>1008, 675</value>
<value>1008, 648</value>
</data>
<data name="splitContainer1.SplitterDistance" type="System.Int32, mscorlib">
<value>243</value>
@ -2453,6 +2453,51 @@
<data name="&gt;&gt;MenuPanel.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<metadata name="StatusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>0, 703</value>
</metadata>
<data name="StatusStrip.AutoSize" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="statusLabel.ImageAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleLeft</value>
</data>
<data name="statusLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>852, 22</value>
</data>
<data name="statusLabel.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleLeft</value>
</data>
<data name="statusProgressBar.AutoSize" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="statusProgressBar.Size" type="System.Drawing.Size, System.Drawing">
<value>100, 17</value>
</data>
<data name="StatusStrip.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 703</value>
</data>
<data name="StatusStrip.Size" type="System.Drawing.Size, System.Drawing">
<value>1008, 27</value>
</data>
<data name="StatusStrip.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="StatusStrip.Text" xml:space="preserve">
<value>statusStrip1</value>
</data>
<data name="&gt;&gt;StatusStrip.Name" xml:space="preserve">
<value>StatusStrip</value>
</data>
<data name="&gt;&gt;StatusStrip.Type" xml:space="preserve">
<value>System.Windows.Forms.StatusStrip, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;StatusStrip.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;StatusStrip.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -3500,6 +3545,18 @@
<data name="&gt;&gt;securityGroupsToolStripMenuItem.Type" xml:space="preserve">
<value>XenAdmin.Commands.CommandToolStripMenuItem, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;statusLabel.Name" xml:space="preserve">
<value>statusLabel</value>
</data>
<data name="&gt;&gt;statusLabel.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;statusProgressBar.Name" xml:space="preserve">
<value>statusProgressBar</value>
</data>
<data name="&gt;&gt;statusProgressBar.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripProgressBar, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>MainWindow</value>
</data>

View File

@ -42,7 +42,9 @@ using System.Windows.Forms;
using System.Xml;
using XenAdmin.Core;
using XenAdmin.Network;
using XenAdmin.XenSearch;
using XenAPI;
using XenAdmin.Actions;
namespace XenAdmin.Plugins
@ -112,6 +114,8 @@ namespace XenAdmin.Plugins
private WebBrowser2 Browser;
private bool UrlIsLoaded;
private ActionBase MainWindowActionAtNavigateTime = null;
/// <summary>
/// If true, this indicates that the most recent Navigation was an error.
/// </summary>
@ -195,6 +199,7 @@ namespace XenAdmin.Plugins
Browser = new WebBrowser2();
Browser.Dock = DockStyle.Fill;
Browser.IsWebBrowserContextMenuEnabled = ContextEnabled;
Browser.ProgressChanged += Browser_ProgressChanged;
Browser.DocumentCompleted += Browser_DocumentCompleted;
Browser.Navigating += Browser_Navigating;
Browser.Navigated += Browser_Navigated;
@ -301,6 +306,17 @@ namespace XenAdmin.Plugins
{
Program.AssertOnEventThread();
if (tabControl != null && tabControl.SelectedTab != null && tabControl.SelectedTab.Tag == this)
{
if (Program.MainWindow.StatusBarAction == null
|| Program.MainWindow.StatusBarAction.IsCompleted && MainWindowActionAtNavigateTime.Equals(Program.MainWindow.StatusBarAction))
{
// we still have 'control' of the status bar
Program.MainWindow.SetProgressBar(false, 0);
Program.MainWindow.SetStatusBar(null, null);
}
}
if (!XenCenterOnly && lastBrowserState != null)
{
log.DebugFormat("url for '{0}' set to '{1}'", Helpers.GetName(lastBrowserState.Obj), e.Url);
@ -308,6 +324,31 @@ namespace XenAdmin.Plugins
}
}
private void Browser_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
{
Program.AssertOnEventThread();
if (tabControl != null && tabControl.SelectedTab != null && tabControl.SelectedTab.Tag == this)
{
if (e.MaximumProgress != 0)
{
if (Program.MainWindow.StatusBarAction == null || Program.MainWindow.StatusBarAction.IsCompleted)
{
MainWindowActionAtNavigateTime = Program.MainWindow.StatusBarAction;
int progr = Convert.ToInt32((e.CurrentProgress * 100L) / (e.MaximumProgress));
Program.MainWindow.SetProgressBar(true, progr);
}
if (Browser.Url != null)
{
string text = e.CurrentProgress >= e.MaximumProgress
? ""
: string.Format(Messages.LOADING, Browser.Url.ToString().Ellipsise(50));
Program.MainWindow.SetStatusBar(null, text);
}
}
}
}
[DllImport("wininet.dll", SetLastError = true)]
private static extern long DeleteUrlCacheEntry(string url);