public void Constructor()
		{
			using (Image image = new Bitmap("DefaultIcon.ico"))
			{
#pragma warning disable 0219
				using (OutlookBarButton button = new OutlookBarButton("text", image))
					{}
#pragma warning restore 0219
			}
		}
		public void SetUp()
		{
			_outlookBar = new OutlookBar();
			_tab1 = new OutlookBarButton("tab1", null);
			_tab2 = new OutlookBarButton("tab2", null);
			_tab3 = new OutlookBarButton("tab3", null);
			_tabs = new OutlookBarButtonCollection(_outlookBar);
			_tabs.Add(_tab1);
			_tabs.Add(_tab2);
			_tabs.Add(_tab3);
		}
Example #3
0
        /// <summary>
        /// Create and position a rectangle for a button's icon to be drawn into,
        /// but no bigger than kImageDimensionLarge or kImageDimensionSmall, as appropriate.
        /// </summary>
        private Rectangle GetRectangleForButtonIcon(OutlookBarButton button)
        {
            Rectangle rc = new Rectangle();

            int imageDimension = button.isLarge ? kImageDimensionLarge : kImageDimensionSmall;

            rc.Width  = button.Image.Width;
            rc.Height = button.Image.Height;

            if (button.Image.Width > imageDimension)
            {
                rc.Width = imageDimension;
            }
            if (button.Image.Height > imageDimension)
            {
                rc.Height = imageDimension;
            }

            rc.Y = button.Rectangle.Y +
                   (int)Math.Floor(((decimal)InternalButtonHeight / 2) - ((decimal)imageDimension / 2)) + 1;

            if (button.isLarge)
            {
                rc.X = m_buttonIconMarginFromLeft;
            }
            else
            {
                rc.X = button.Rectangle.X +
                       (int)Math.Floor(((decimal)SmallButtonWidth / 2) - ((decimal)imageDimension / 2));
            }

            // If button icon is smaller than the standard size, then move it down and over a bit to
            // center it.
            if (button.Image.Width < imageDimension)
            {
                rc.X += (imageDimension - button.Image.Width) / 2;
            }
            if (button.Image.Height < imageDimension)
            {
                rc.Y += (imageDimension - button.Image.Height) / 2;
            }

            return(rc);
        }
Example #4
0
        /// <summary></summary>
        protected override void OnMouseClick(MouseEventArgs e)
        {
            m_rightClickedButton = null;
            OutlookBarButton button = Buttons.GetItem(e.X, e.Y);

            if (button == null)
            {
                if (DropDownRectangle.Contains(e.X, e.Y))
                {
                    CreateContextMenu();
                }

                return;
            }

            if (e.Button == MouseButtons.Right)
            {
                m_rightClickedButton = button;
            }
            else if (e.Button == MouseButtons.Left)
            {
                if (button.Enabled)
                {
                    m_selectedButton = button;
                    if (ButtonClicked != null)
                    {
                        ButtonClicked(this, button);
                    }
                }
            }
            else
            {
                return;
            }

            Invalidate();
        }
Example #5
0
        /// <summary>
        /// Draws the icon associated with a button. Draws greyscaled if button is disabled.
        /// </summary>
        private void DrawButtonIcon(Graphics g, OutlookBarButton button, Rectangle rc)
        {
            Image           icon       = button.Image;
            ImageAttributes attributes = null;

            try
            {
                if (!button.Enabled)
                {
                    attributes = new ImageAttributes();
                    ColorMatrix colorToGreyscale = GetGreyscalingColorMatrix();
                    attributes.SetColorMatrix(colorToGreyscale);
                }

                g.DrawImage(icon, rc, 0, 0, icon.Width, icon.Height, GraphicsUnit.Pixel, attributes);
            }
            finally
            {
                if (attributes != null)
                {
                    attributes.Dispose();
                }
            }
        }
Example #6
0
 public void SetUp()
 {
     _button = new OutlookBarButton();
 }
		public void Insert(int index, OutlookBarButton value)
		{
			List.Insert(index, value);
		}
Example #8
0
        /// <summary></summary>
        protected override void OnMouseMove(MouseEventArgs e)
        {
            m_hoveringButton   = null;
            m_dropDownHovering = false;

            if (m_isResizing)
            {
                if (e.Y < -InternalButtonHeight)
                {
                    if (m_canGrow)
                    {
                        Height += InternalButtonHeight;
                    }
                }
                else if (e.Y > InternalButtonHeight)
                {
                    if (m_canShrink)
                    {
                        Height -= InternalButtonHeight;
                    }
                }

                return;
            }

            if (GripRectangle.Contains(e.X, e.Y))
            {
                Cursor = Cursors.SizeNS;
                return;
            }

            if (DropDownRectangle.Contains(e.X, e.Y))
            {
                Cursor             = Cursors.Hand;
                m_dropDownHovering = true;
                Invalidate();

                //adjust Tooltip...
                if ((m_toolTip.Tag != null))
                {
                    if (!m_toolTip.Tag.Equals("Configure"))
                    {
                        m_toolTip.Active = true;
                        m_toolTip.SetToolTip(this, SilSidePane.ConfigureButtons);
                        m_toolTip.Tag = "Configure";
                    }
                }
                else
                {
                    m_toolTip.Active = true;
                    m_toolTip.SetToolTip(this, SilSidePane.ConfigureButtons);
                    m_toolTip.Tag = "Configure";
                }
            }
            else if ((Buttons.GetItem(e.X, e.Y) != null))
            {
                Cursor           = Cursors.Hand;
                m_hoveringButton = Buttons.GetItem(e.X, e.Y);
                Invalidate();

                //adjust tooltip...
                if (!m_hoveringButton.isLarge)
                {
                    if (m_toolTip.Tag == null)
                    {
                        m_toolTip.Active = true;
                        m_toolTip.SetToolTip(this, m_hoveringButton.Text);
                        m_toolTip.Tag = m_hoveringButton;
                    }
                    else
                    {
                        if (!m_toolTip.Tag.Equals(m_hoveringButton))
                        {
                            m_toolTip.Active = true;
                            m_toolTip.SetToolTip(this, m_hoveringButton.Text);
                            m_toolTip.Tag = m_hoveringButton;
                        }
                    }
                }
                else
                {
                    m_toolTip.Active = false;
                }
            }
            else
            {
                Cursor = Cursors.Default;
            }
        }
Example #9
0
 /// <summary></summary>
 protected override void OnMouseUp(MouseEventArgs e)
 {
     m_isResizing        = false;
     m_leftClickedButton = null;
 }
Example #10
0
 public int IndexOf(OutlookBarButton item)
 {
     return(List.IndexOf(item));
 }
 public OutlookBarButton Add(OutlookBarButton item)
 {
     item.Owner = this.Owner;
     int i = List.Add(item);
     return List[i] as OutlookBarButton;
 }
		public bool Contains(OutlookBarButton item)
		{
			return List.Contains(item);
		}
		public void SetUp()
		{
			_button = new OutlookBarButton();
		}
Example #14
0
		/// <summary>
		/// Handles a click on an OutlookBarButton widget representing a tab
		/// </summary>
		private void HandleTabAreaButtonClicked(object sender, OutlookBarButton tabButton)
		{
			Tab tab = GetTabByName(tabButton.Name);
			ShowOnlyCertainItemArea(tab);
			_banner.UseMnemonic = false;
			_banner.Text = tab.Text;
			InvokeTabClicked(tab);

			if (_generateItemEvents)
			{
				// Upon changing tab, the active item is also changed (to an item in the
				// now-current item area). Tell client about this.

				var currentItem = _itemAreas[tab].CurrentItem;

				// If user clicks a tab that doesn't have a previously-selected item,
				// then select the first item in the item area.
				if (currentItem == null)
				{
					var areaItems = _itemAreas[tab].Items;
					if (areaItems.Count > 0 && areaItems[0] != null)
						SelectItem(tab, areaItems[0].Name);
				}
				else
				{
					// User clicked a tab that does have a previously-selected item. Select it.
					InvokeItemClicked(currentItem);
				}
			}
		}
Example #15
0
 public void Add(OutlookBarButton item)
 {
     item.Owner = this.Owner;
     List.Add(item);
 }
		public int IndexOf(OutlookBarButton item)
		{
			return List.IndexOf(item);
		}
		public void Add(OutlookBarButton item)
		{
			item.Owner = this.Owner;
			List.Add(item);
		}
Example #18
0
 public bool Contains(OutlookBarButton item)
 {
     return(List.Contains(item));
 }
Example #19
0
 public void Remove(OutlookBarButton value)
 {
     List.Remove(value);
 }
Example #20
0
 public void Insert(int index, OutlookBarButton value)
 {
     List.Insert(index, value);
 }
Example #21
0
		/// <remarks>Cannot add the same tab more than once. Cannot add a tab with the same name as
		/// an existing tab.</remarks>
		public void AddTab(Tab tab)
		{
			if (tab == null)
				throw new ArgumentNullException("tab");
			if (_itemAreas.Keys.Where(existingTab => existingTab.Name == tab.Name).Count() > 0)
				throw new ArgumentException("cannot add a tab with the same name as an existing tab");

			var tabButton = new OutlookBarButton
				{
			Name = tab.Name,
			Text = tab.Text,
			Image = tab.Icon,
			Enabled = tab.Enabled,
			Tag = tab
				};
			_tabArea.Buttons.Add(tabButton);
			tab.UnderlyingWidget = tabButton;

			IItemArea itemArea;
			switch (ItemAreaStyle)
			{
				case SidePaneItemAreaStyle.StripList:
					itemArea = new StripListItemArea();
					break;

				case SidePaneItemAreaStyle.List:
					itemArea = new ListViewItemArea();
					break;

				case SidePaneItemAreaStyle.Buttons:
				default:
					itemArea = new OutlookButtonPanelItemArea
						{
							Dock = DockStyle.Fill
						};
					break;
			}
			itemArea.ItemClicked += HandleClickFromItemArea;
			_itemAreas.Add(tab, itemArea);
			_itemAreaContainer.Controls.Add(itemArea.AsControl());

			// Expand tab area to show this tab
			_tabArea.ShowAnotherButton();
		}
		public void Remove(OutlookBarButton value)
		{
			List.Remove(value);
		}