Exemplo n.º 1
0
 public StatusBarPanel this[int index]
 {
     get
     {
         return((StatusBarPanel)(list[index]));
     }
     set
     {
         StatusBarPanel old = (StatusBarPanel)(list[index]);
         if (old == value)
         {
             return;
         }
         CheckAdd(value);
         list[index]  = value;
         old.parent   = null;
         value.parent = owner;
         owner.Invalidate();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        ///  Sets all the properties for this panel.
        /// </summary>
        internal void Realize()
        {
            if (Created)
            {
                string text;
                string sendText;
                int    border = 0;

                if (this.text == null)
                {
                    text = string.Empty;
                }
                else
                {
                    text = this.text;
                }

                HorizontalAlignment align = alignment;
                // Translate the alignment for Rtl apps
                //
                if (parent.RightToLeft == RightToLeft.Yes)
                {
                    switch (align)
                    {
                    case HorizontalAlignment.Left:
                        align = HorizontalAlignment.Right;
                        break;

                    case HorizontalAlignment.Right:
                        align = HorizontalAlignment.Left;
                        break;
                    }
                }

                switch (align)
                {
                case HorizontalAlignment.Center:
                    sendText = "\t" + text;
                    break;

                case HorizontalAlignment.Right:
                    sendText = "\t\t" + text;
                    break;

                default:
                    sendText = text;
                    break;
                }
                switch (borderStyle)
                {
                case StatusBarPanelBorderStyle.None:
                    border |= NativeMethods.SBT_NOBORDERS;
                    break;

                case StatusBarPanelBorderStyle.Sunken:
                    break;

                case StatusBarPanelBorderStyle.Raised:
                    border |= NativeMethods.SBT_POPOUT;
                    break;
                }
                switch (style)
                {
                case StatusBarPanelStyle.Text:
                    break;

                case StatusBarPanelStyle.OwnerDraw:
                    border |= NativeMethods.SBT_OWNERDRAW;
                    break;
                }

                int wparam = GetIndex() | border;
                if (parent.RightToLeft == RightToLeft.Yes)
                {
                    wparam |= NativeMethods.SBT_RTLREADING;
                }

                int result = (int)UnsafeNativeMethods.SendMessage(new HandleRef(parent, parent.Handle), NativeMethods.SB_SETTEXT, (IntPtr)wparam, sendText);

                if (result == 0)
                {
                    throw new InvalidOperationException(SR.UnableToSetPanelText);
                }

                if (icon != null && style != StatusBarPanelStyle.OwnerDraw)
                {
                    parent.SendMessage(NativeMethods.SB_SETICON, (IntPtr)GetIndex(), icon.Handle);
                }
                else
                {
                    parent.SendMessage(NativeMethods.SB_SETICON, (IntPtr)GetIndex(), IntPtr.Zero);
                }

                if (style == StatusBarPanelStyle.OwnerDraw)
                {
                    Interop.RECT rect = new Interop.RECT();
                    result = (int)UnsafeNativeMethods.SendMessage(new HandleRef(parent, parent.Handle), NativeMethods.SB_GETRECT, (IntPtr)GetIndex(), ref rect);

                    if (result != 0)
                    {
                        parent.Invalidate(Rectangle.FromLTRB(rect.left, rect.top, rect.right, rect.bottom));
                    }
                }
            }
        }
Exemplo n.º 3
0
 private void MainForm_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     board.Click(e);
     statusBar.Invalidate();
 }