Example #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();
            }
        }
Example #2
0
        /// <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);
        }
        private void AddBandVerbClicked(object sender, EventArgs e)
        {
            NaviBand band = host.CreateComponent(typeof(NaviBand)) as NaviBand;

            if (band != null)
            {
                designingControl.Controls.Add(band);
            }
        }
Example #4
0
        /// <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");
            }
        }
        /// <summary>
        /// Creates a new instance of the NaviBar component with design time support
        /// </summary>
        /// <param name="host">The controls host</param>
        /// <returns>The newly created component</returns>
        protected override IComponent[] CreateComponentsCore(IDesignerHost host)
        {
            // Create the control
            NaviBar  naviBarCtrl  = (NaviBar)host.CreateComponent(typeof(NaviBar));
            NaviBand naviBandCtrl = (NaviBand)host.CreateComponent(typeof(NaviBand));

            // Add a new button
            naviBarCtrl.Controls.Add(naviBandCtrl);

            return(new IComponent[] { naviBarCtrl });
        }
Example #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);
            }
        }
Example #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();
            }
Example #11
0
 /// <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);
 }
Example #12
0
 /// <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));
 }
Example #13
0
 /// <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);
 }
 /// <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;
 }