Ejemplo n.º 1
0
        /// <summary>
        /// Redraws this instance.
        /// </summary>
        private void Redraw()
        {
            // this.Margin = new Padding(2);
            int      pad  = 2;
            MenuBand band = null;

            //设置宽度同步
            this.Width = this.Parent.Width;
            //这个是菜单项所拥有的高度
            int selectedBandHeight = this.Parent.Height - (this.Bands.Count * (BandHeight + pad));

            Console.WriteLine("the outlookmenu width " + this.Size.Width + " height " + this.Size.Height);
            for (int i = 0; i < this.Bands.Count; i++)
            {
                //这个是band后一个band的垂直定位
                int vPos = (i <= SelectedIndex) ? BandHeight * i : BandHeight * i + selectedBandHeight;
                //这个是
                //int height = SelectedIndex == i ? selectedBandHeight + BandHeight : BandHeight*i;
                // Console.WriteLine("vPos "+vPos+" height "+height);
                band = this.bands[i];
                // band.BackColor = this.SelectedColor;
                if (i == this.SelectedIndex)
                {
                    band.Location = new Point(0, BandHeight * i);
                    band.Size     = new Size(this.Size.Width, selectedBandHeight + this.bandHeight + pad);
                    Console.WriteLine("the band " + band.Caption + " x " + band.Location.X + " y " + band.Location.Y);
                    band.BorderStyle = BorderStyle.FixedSingle;
                    band.Redraw();
                    Console.WriteLine("band.needHeight=" + band.NeedHeight + ",band.size.height=" + band.Height);
                    if (band.NeedHeight > band.Height)
                    {
                        this.scroll.Location = new Point(this.Width - 2);
                        this.scroll.Maximum  = band.NeedHeight - band.Height + band.Margin;
                        this.scroll.Dock     = DockStyle.Right;
                        this.scroll.Visible  = true;
                        this.scroll.Value    = 0;
                    }
                    else
                    {
                        this.scroll.Visible = false;
                    }
                    // band.AutoScroll = true;
                }
                else
                {
                    // band.BackColor = this.BackColor;
                    band.Location = new Point(0, vPos);
                    band.Size     = new Size(this.Size.Width, this.bandHeight + pad);
                    Console.WriteLine("the band " + band.Caption + " x " + band.Location.X + " y " + band.Location.Y);
                    // band.BorderStyle = BorderStyle.FixedSingle;
                    band.RedrawHeader();
                }

                this.Controls.Add(band);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Removes the specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 public void Remove(MenuBand item)
 {
     List.Remove(item);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds the specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 public void Add(MenuBand item)
 {
     List.Add(item);
       //  item.Parent = this.Parent;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Removes the specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 public void Remove(MenuBand item)
 {
     List.Remove(item);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds the specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 public void Add(MenuBand item)
 {
     List.Add(item);
     //  item.Parent = this.Parent;
 }