Beispiel #1
0
        /// <summary>
        /// Changes the currently active band to a given band
        /// </summary>
        /// <param name="band">The band to activate</param>
        public void SetActiveBand(NaviBand newBand)
        {
            NaviBandEventArgs e = new NaviBandEventArgs(newBand);

            OnActiveBandChanging(e);
            if (!e.Canceled)
            {
                if (activeBand != newBand)
                {
                    foreach (NaviBand band in bands)
                    {
                        if ((band != newBand) && (band.Button != null))
                        {
                            band.Button.Active = false;
                        }
                    }
                }
                if ((newBand != null) && (newBand.Button != null))
                {
                    newBand.Button.Active = true;
                }

                activeBand = newBand;
                OnActiveBandChanged(new EventArgs());
                PerformLayout();
                Invalidate();
            }
        }
      /// <summary>
      /// Removes a band from the collection of bands
      /// </summary>
      /// <param name="band">The band to remove</param>
      /// <exception cref="ArgumentNullExceptions">Raised when the band argument is null</exception>
      public void Remove(NaviBand value)
      {
         innerList.Remove(value);
         owner.Controls.Remove(value);

			if (owner.Controls.Contains(value.Button))
				owner.Controls.Remove(value.Button);
      }
      /// <summary>
      /// Adds a new NaviBand the the collection
      /// </summary>
      /// <param name="value">The new NaviBand to add</param>
      /// <exception cref="ArgumentNullExceptions">Raised when the band argument is null</exception>
      public int Add(NaviBand value)
      {
         int result = innerList.Add(value);
         owner.Controls.Add(value);
			owner.Controls.SetChildIndex(value, result);
         value.OriginalOrder = result;
         return result;
      } 
        /// <summary>
        /// Adds a new NaviBand the the collection
        /// </summary>
        /// <param name="value">The new NaviBand to add</param>
        /// <exception cref="ArgumentNullExceptions">Raised when the band argument is null</exception>
        public int Add(NaviBand value)
        {
            int result = innerList.Add(value);

            owner.Controls.Add(value);
            owner.Controls.SetChildIndex(value, result);
            value.OriginalOrder = result;
            return(result);
        }
        /// <summary>
        /// Removes a band from the collection of bands
        /// </summary>
        /// <param name="band">The band to remove</param>
        /// <exception cref="ArgumentNullExceptions">Raised when the band argument is null</exception>
        public void Remove(NaviBand value)
        {
            innerList.Remove(value);
            owner.Controls.Remove(value);

            if (owner.Controls.Contains(value.Button))
            {
                owner.Controls.Remove(value.Button);
            }
        }
      public override void Initialize(System.ComponentModel.IComponent component)
      {
         base.Initialize(component);
			if (component is NaviBand)
			{
				designingComponent = (NaviBand)component;

				EnableDesignMode(designingComponent.ClientArea, "ClientArea");
			}
      }
Beispiel #7
0
        public int Compare(object x, object y)
        {
            if (!(x is NaviBand) || !(y is NaviBand))
            {
                throw new ArgumentException("Both of the argument should be of type NaviBand");
            }

            NaviBand bandx = (NaviBand)x;
            NaviBand bandy = (NaviBand)y;

            return(bandx.Order.CompareTo(bandy.Order));
        }
        /// <summary>
        /// Places the overflow buttons in the correct position
        /// </summary>
        private void LayoutOverflowButtons()
        {
            int compactFlow = (overflowCount * Bar.MinimizedButtonWidth) + 1;

            // This may seem odd but the buttons are positioned from the left to the right.
            // The first overflow button will appear as the first left button.
            if (Bar.ShowMoreOptionsButton)
            {
                compactFlow += optionButtonWidth;
            }

            for (int i = 0; i < overflowCount; i++)
            {
                ienum.MoveNext();
                while (!ienum.Current.Visible)
                {
                    ienum.MoveNext();
                }
                NaviBand band = ienum.Current;

                if (band.Visible)
                {
                    if (!Bar.Collapsed)
                    {
                        // TODO
                        band.Button.Small  = true;
                        band.Button.Height = smallButtonRectangle.Height;
                        band.Button.Width  = Bar.MinimizedButtonWidth;

                        if (Bar.RightToLeft == RightToLeft.Yes)
                        {
                            band.Button.Location = new Point(compactFlow - Bar.MinimizedButtonWidth, smallButtonRectangle.Top);
                        }
                        else
                        {
                            band.Button.Location = new Point(Bar.Width - compactFlow, smallButtonRectangle.Top);
                        }

                        compactFlow -= Bar.MinimizedButtonWidth;
                    }
                    else
                    {
                        // Collapsed, place buttons out of sight
                        band.Button.Location = new Point(0, 0);
                        band.Button.Size     = new Size(0, 0);
                    }
                }
            }
        }
        private void LayoutMenuItems()
        {
            for (int i = 0; i < menuCount; i++)
            {
                ienum.MoveNext();
                while (!ienum.Current.Visible)
                {
                    ienum.MoveNext();
                }

                NaviBand band = (NaviBand)ienum.Current;

                // Collapsed, place buttons out of sight
                band.Button.Location = new Point(0, 0);
                band.Button.Size     = new Size(0, 0);

                ToolStripMenuItem menuitem = new ToolStripMenuItem();

                menuitem.Name   = "";
                menuitem.Size   = new System.Drawing.Size(234, 22);
                menuitem.Text   = band.Text;
                menuitem.Click += new EventHandler(menuitem_Click);

                if (band.SmallImage != null)
                {
                    menuitem.Image = band.SmallImage;
                }
                else if ((band != null) && (band.SmallImageIndex >= 0) && (band.SmallImages != null) &&
                         (band.SmallImageIndex < band.SmallImages.Images.Count))
                {
                    menuitem.Image = band.SmallImages.Images[band.SmallImageIndex];
                }
                menuitem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.ImageAndText;

                if (band == Bar.ActiveBand)
                {
                    menuitem.Checked    = true;
                    menuitem.CheckState = System.Windows.Forms.CheckState.Checked;
                }
                else
                {
                    menuitem.Checked    = false;
                    menuitem.CheckState = System.Windows.Forms.CheckState.Unchecked;
                }

                optionsMenu.Items.Add(menuitem);
            }
        }
Beispiel #10
0
            /// <summary>
            /// Overloaded. Adds a new control to the collection
            /// </summary>
            /// <param name="value">The control to add</param>
            public override void Add(System.Windows.Forms.Control value)
            {
                Owner.SuspendLayout();

                base.Add(value);

                if (value is NaviBand)
                {
                    NaviBand newBand = value as NaviBand;

                    if (!ownerBar.bands.Contains(newBand))
                    {
                        ownerBar.Bands.AddInternal(newBand);
                    }

                    newBand.OwnerBar          = ownerBar;
                    ownerBar.BandInitRequired = true;
                }

                Owner.ResumeLayout();
            }
 /// <summary>
 /// Infrastructure. Adds a band to the collection
 /// </summary>
 /// <param name="value">The band to add</param>
 internal void AddInternal(NaviBand value)
 {
     innerList.Add(value);
 }
 /// <summary>
 /// Determines whether the list contains a specific value
 /// </summary>
 /// <param name="band">The value</param>
 /// <returns>Returns true if the list contains the item; false otherwise</returns>
 public bool Contains(NaviBand value)
 {
     return(innerList.Contains(value));
 }
 /// <summary>
 /// Determines whether the list contains a specific value
 /// </summary>
 /// <param name="band">The value</param>
 /// <returns>Returns true if the list contains the item; false otherwise</returns>
 public bool Contains(NaviBand value)
 {
    return innerList.Contains(value);
 }
 /// <summary>
 /// Infrastructure. Removes a band from the collection
 /// </summary>
 /// <param name="value">The band to remove</param>
 internal void RemoveInternal(NaviBand value)
 {
    innerList.Remove(value);
 }
      private void ButtonAddBand_Click(object sender, EventArgs e)
      {
         naviBar1.SuspendLayout();
         NaviBand band = new NaviBand();

         band.Text = "NaviBand" + (naviBar1.Bands.Count + 1).ToString();
         band.Name = "NaviBand" + (naviBar1.Bands.Count + 1).ToString();
         band.LargeImageIndex = 2;
         band.SmallImageIndex = 2;

         naviBar1.Controls.Add(band);
         naviBar1.ResumeLayout();
         naviBar1.PerformLayout();
      }
Beispiel #16
0
      /// <summary>
      /// Changes the currently active band to a given band
      /// </summary>
      /// <param name="band">The band to activate</param>
      public void SetActiveBand(NaviBand newBand)
      {
         NaviBandEventArgs e = new NaviBandEventArgs(newBand);
         OnActiveBandChanging(e);
         if (!e.Canceled)
         {
            if (activeBand != newBand)
            {
               foreach (NaviBand band in bands)
               {
                  if ((band != newBand) && (band.Button != null))
                  {
                     band.Button.Active = false;
                  }
               }
            }
            if ((newBand != null) && (newBand.Button != null))
            {
               newBand.Button.Active = true;
            }

            activeBand = newBand;
            OnActiveBandChanged(new EventArgs());
            PerformLayout();
            Invalidate();
         }
      }
 /// <summary>
 /// Initializes a new instance of the NaviBandEventArgs class
 /// </summary>
 /// <param name="newActiveButton">The new active band</param>
 public NaviBandEventArgs(NaviBand newActiveBand)
    : base()
 {
    this.newActiveBand = newActiveBand;
 }
 /// <summary>
 /// Infrastructure. Adds a band to the collection
 /// </summary>
 /// <param name="value">The band to add</param>
 internal void AddInternal(NaviBand value)
 {
    innerList.Add(value);
 }
 /// <summary>
 /// Initializes a new instance of the NaviBandEventArgs class
 /// </summary>
 /// <param name="newActiveButton">The new active band</param>
 public NaviBandEventArgs(NaviBand newActiveBand)
     : base()
 {
     this.newActiveBand = newActiveBand;
 }
 /// <summary>
 /// Infrastructure. Removes a band from the collection
 /// </summary>
 /// <param name="value">The band to remove</param>
 internal void RemoveInternal(NaviBand value)
 {
     innerList.Remove(value);
 }