/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Positions the toolbars to the positions specified in the xml deffinition file.
		/// This method only gets called when tool bar locations and visibilities cannot be
		/// found in the registry.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void LoadDefaultToolbarLayout()
		{
			List<InitialBarProps> ibpList = new List<InitialBarProps>();

			foreach (ToolStrip bar in m_bars.Values)
			{
				InitialBarProps ibp = new InitialBarProps();
				ibp.Name = bar.Name;
				ibp.Location = bar.Location = m_barLocations[bar];
				ibp.Side = "Top";

				bool isBarDisplayed;
				ibp.Visible = (m_displayedBars.TryGetValue(bar.Name, out isBarDisplayed) ?
					isBarDisplayed : false);

				ibpList.Add(ibp);
			}

			// Sort bars by visibility and location.
			ibpList.Sort(InitialBarPropsComparer);

			// Now add the bars to the top panel, arranging them accordingly.
			int prevRow = 0;
			int dx = 0;
			foreach (InitialBarProps ibp in ibpList)
			{
				ToolStrip bar = m_bars[ibp.Name];
				bar.Visible = ibp.Visible;
				int barRow = bar.Top;

				if (barRow != prevRow)
				{
					prevRow = barRow;
					dx = 0;
				}

				bar.Top = (barRow * bar.Height);
				bar.Left = dx;
				if (m_tsContainer != null)
					m_tsContainer.TopToolStripPanel.Controls.Add(bar);
				else
					m_tsPanel.Controls.Add(bar);

				dx += (bar.Left + bar.Width);
			}
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Compares the locations and visibility of two toolstrip objects.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private int InitialBarPropsComparer(InitialBarProps x, InitialBarProps y)
		{
			if (x.Visible && !y.Visible)
				return -1;

			if (x.Side != y.Side)
				return y.Side.CompareTo(x.Side);

			if (!x.Visible && y.Visible)
				return 1;

			bool barsAreHoriz = (x.Side == "Top" || x.Side == "Bottom");

			if (x.Location.Y != y.Location.Y)
				return (x.Location.Y - y.Location.Y) * (barsAreHoriz ? 1 : -1);

			return (x.Location.X - y.Location.X) * (barsAreHoriz ? 1 : -1);
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Load tool bar settings from the registry, if available.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private bool LoadBarSettings()
		{
			if (m_appsRegKeyPath == null)
				return false;

			List<InitialBarProps> ibpList = new List<InitialBarProps>();

			foreach (ToolStrip bar in m_bars.Values)
			{
				int dx = (int)m_appsRegKeyPath.GetValue(bar.Name + "X", -1);
				if (dx == -1)
					return false;

				InitialBarProps ibp = new InitialBarProps();
				ibp.Name = bar.Name;
				ibp.Side = m_appsRegKeyPath.GetValue(bar.Name + "Side", "Top") as string;
				ibp.Location = new Point(dx,
					(int)m_appsRegKeyPath.GetValue(bar.Name + "Y", bar.Top));

				string strVal = m_appsRegKeyPath.GetValue(bar.Name + "Visible") as string;
				bool visible;
				ibp.Visible = (bool.TryParse(strVal, out visible) ? visible : false);
				m_displayedBars[bar.Name] = ibp.Visible;

				ibpList.Add(ibp);
			}

			// Sort the bar information read from the registry by visibility and location.
			ibpList.Sort(InitialBarPropsComparer);

			foreach (InitialBarProps sbp in ibpList)
			{
				ToolStrip bar = m_bars[sbp.Name];
				bar.Visible = sbp.Visible;
				bar.Location = sbp.Location;

				if (m_tsContainer == null)
					m_tsPanel.Controls.Add(bar);
				else
				{
					switch (sbp.Side)
					{
						case "Bottom": m_tsContainer.BottomToolStripPanel.Controls.Add(bar); break;
						case "Right": m_tsContainer.RightToolStripPanel.Controls.Add(bar); break;
						case "Left": m_tsContainer.LeftToolStripPanel.Controls.Add(bar); break;
						default: m_tsContainer.TopToolStripPanel.Controls.Add(bar); break;
					}
				}
			}

			return true;
		}