コード例 #1
0
        /// <summary>
        /// 移除一个自定义系统按钮
        /// </summary>
        /// <param name="item">要移除的自定义系统按钮</param>
        public void Remove(CmSysButton item)
        {
            int index = this.IndexOf(item);

            if (-1 != index)        //如果存在元素 那么根据索引移除
            {
                this.RemoveAt(index);
            }
        }
コード例 #2
0
        //画窗体按钮
        protected override void OnRenderSkinFormControlBox(
            SkinFormControlBoxRenderEventArgs e)
        {
            CCSkinMain      form        = e.Form;
            Graphics        g           = e.Graphics;
            Rectangle       rect        = e.ClipRectangle;
            ControlBoxState state       = e.ControlBoxtate;
            CmSysButton     cmSysButton = e.CmSysButton;
            bool            active      = e.Active;

            bool minimizeBox = form.ControlBox && form.MinimizeBox;
            bool maximizeBox = form.ControlBox && form.MaximizeBox;

            switch (e.ControlBoxStyle)
            {
            case ControlBoxStyle.Close:
                RenderSkinFormCloseBoxInternal(
                    g,
                    rect,
                    state,
                    active,
                    minimizeBox,
                    maximizeBox,
                    form);
                break;

            case ControlBoxStyle.Maximize:
                RenderSkinFormMaximizeBoxInternal(
                    g,
                    rect,
                    state,
                    active,
                    minimizeBox,
                    form.WindowState == FormWindowState.Maximized,
                    form);
                break;

            case ControlBoxStyle.Minimize:
                RenderSkinFormMinimizeBoxInternal(
                    g,
                    rect,
                    state,
                    active,
                    form);
                break;

            case ControlBoxStyle.CmSysBottom:
                RenderSkinFormCmSysBottomInternal(
                    g,
                    rect,
                    state,
                    active,
                    form,
                    cmSysButton);
                break;
            }
        }
コード例 #3
0
 //确认存储空间
 private void EnsureSpace(int elements)
 {
     if (m_arrItem == null)
     {
         m_arrItem = new CmSysButton[Math.Max(elements, 4)];
     }
     else if (this.count + elements > m_arrItem.Length)
     {
         CmSysButton[] arrTemp = new CmSysButton[Math.Max(this.count + elements, m_arrItem.Length * 2)];
         m_arrItem.CopyTo(arrTemp, 0);
         m_arrItem = arrTemp;
     }
 }
コード例 #4
0
 /// <summary>
 /// 添加一个自定义系统按钮
 /// </summary>
 /// <param name="item">要添加的自定义系统按钮</param>
 public void Add(CmSysButton item)
 {
     if (item == null)       //空引用不添加
     {
         throw new ArgumentNullException("Item cannot be null");
     }
     this.EnsureSpace(1);
     if (-1 == this.IndexOf(item))
     {         //进制添加重复对象
         item.OwnerForm          = this.owner;
         m_arrItem[this.count++] = item;
         this.owner.Invalidate();            //添加进去是 进行重绘
     }
 }
コード例 #5
0
ファイル: CmSysButton.cs プロジェクト: yzwbrian/winform-ui
        /// <summary>
        /// 深拷贝
        /// </summary>
        /// <returns>深度克隆的自定义系统按钮</returns>
        public CmSysButton Clone()
        {
            CmSysButton SysButton = new CmSysButton();

            SysButton.Bounds         = this.Bounds;
            SysButton.Location       = this.Location;
            SysButton.size           = this.Size;
            SysButton.ToolTip        = this.ToolTip;;
            SysButton.SysButtonNorml = this.SysButtonNorml;
            SysButton.SysButtonMouse = this.SysButtonMouse;
            SysButton.SysButtonDown  = this.SysButtonDown;
            SysButton.OwnerForm      = this.OwnerForm;
            SysButton.Name           = this.Name;
            return(SysButton);
        }
コード例 #6
0
 public SkinFormControlBoxRenderEventArgs(
     CCSkinMain form,
     Graphics graphics,
     Rectangle clipRect,
     bool active,
     ControlBoxStyle controlBoxStyle,
     ControlBoxState controlBoxState,
     CmSysButton cmSysbutton = null)
     : base(graphics, clipRect)
 {
     _form            = form;
     _active          = active;
     _controlBoxState = controlBoxState;
     _controlBoxStyle = controlBoxStyle;
     _CmSysbutton     = cmSysbutton;
 }
コード例 #7
0
 /// <summary>
 /// 根据索引位置插入一个自定义系统按钮
 /// </summary>
 /// <param name="index">索引位置</param>
 /// <param name="item">要插入的自定义系统按钮</param>
 public void Insert(int index, CmSysButton item)
 {
     if (index < 0 || index >= this.count)
     {
         throw new IndexOutOfRangeException("Index was outside the bounds of the array");
     }
     if (item == null)
     {
         throw new ArgumentNullException("Item cannot be null");
     }
     this.EnsureSpace(1);
     for (int i = this.count; i > index; i--)
     {
         m_arrItem[i] = m_arrItem[i - 1];
     }
     item.OwnerForm   = this.owner;
     m_arrItem[index] = item;
     this.count++;
     this.owner.Invalidate();
 }
コード例 #8
0
 /// <summary>
 /// 获取自定义系统按钮所在的索引位置
 /// </summary>
 /// <param name="item">要获取的自定义系统按钮</param>
 /// <returns>索引位置</returns>
 public int IndexOf(CmSysButton item)
 {
     return(Array.IndexOf <CmSysButton>(m_arrItem, item));
 }
コード例 #9
0
 /// <summary>
 /// 判断一个自定义系统按钮是否在集合内
 /// </summary>
 /// <param name="item">要判断的自定义系统按钮</param>
 /// <returns>是否在自定义系统按钮集合内</returns>
 public bool Contains(CmSysButton item)
 {
     return(this.IndexOf(item) != -1);
 }
コード例 #10
0
 /// <summary>
 /// 移除一个自定义系统按钮
 /// </summary>
 /// <param name="item">要移除的自定义系统按钮</param>
 public void Remove(CmSysButton item)
 {
     int index = this.IndexOf(item);
     if (-1 != index)        //如果存在元素 那么根据索引移除
         this.RemoveAt(index);
 }
コード例 #11
0
 /// <summary>
 /// 根据索引位置插入一个自定义系统按钮
 /// </summary>
 /// <param name="index">索引位置</param>
 /// <param name="item">要插入的自定义系统按钮</param>
 public void Insert(int index, CmSysButton item)
 {
     if (index < 0 || index >= this.count)
         throw new IndexOutOfRangeException("Index was outside the bounds of the array");
     if (item == null)
         throw new ArgumentNullException("Item cannot be null");
     this.EnsureSpace(1);
     for (int i = this.count; i > index; i--)
         m_arrItem[i] = m_arrItem[i - 1];
     item.OwnerForm = this.owner;
     m_arrItem[index] = item;
     this.count++;
     this.owner.Invalidate();
 }
コード例 #12
0
 /// <summary>
 /// 获取自定义系统按钮所在的索引位置
 /// </summary>
 /// <param name="item">要获取的自定义系统按钮</param>
 /// <returns>索引位置</returns>
 public int IndexOf(CmSysButton item)
 {
     return Array.IndexOf<CmSysButton>(m_arrItem, item);
 }
コード例 #13
0
 /// <summary>
 /// 判断一个自定义系统按钮是否在集合内
 /// </summary>
 /// <param name="item">要判断的自定义系统按钮</param>
 /// <returns>是否在自定义系统按钮集合内</returns>
 public bool Contains(CmSysButton item)
 {
     return this.IndexOf(item) != -1;
 }
コード例 #14
0
 /// <summary>
 /// 添加一个列表项的自定义系统按钮
 /// </summary>
 /// <param name="items">要添加的自定义系统按钮的数组</param>
 public void AddRange(CmSysButton[] items)
 {
     if (items == null)
         throw new ArgumentNullException("Items cannot be null");
     this.EnsureSpace(items.Length);
     try
     {
         foreach (CmSysButton item in items)
         {
             if (item == null)
                 throw new ArgumentNullException("Item cannot be null");
             if (-1 == this.IndexOf(item))
             {     //重复数据不添加
                 item.OwnerForm = this.owner;
                 m_arrItem[this.count++] = item;
             }
         }
     }
     finally
     {
         this.owner.Invalidate();
     }
 }
コード例 #15
0
 /// <summary>
 /// 添加一个自定义系统按钮
 /// </summary>
 /// <param name="item">要添加的自定义系统按钮</param>
 public void Add(CmSysButton item)
 {
     if (item == null)       //空引用不添加
         throw new ArgumentNullException("Item cannot be null");
     this.EnsureSpace(1);
     if (-1 == this.IndexOf(item))
     {         //进制添加重复对象
         item.OwnerForm = this.owner;
         m_arrItem[this.count++] = item;
         this.owner.Invalidate();            //添加进去是 进行重绘
     }
 }
コード例 #16
0
ファイル: CmSysButton.cs プロジェクト: panshuiqing/winform-ui
 /// <summary>
 /// 深拷贝
 /// </summary>
 /// <returns>深度克隆的自定义系统按钮</returns>
 public CmSysButton Clone()
 {
     CmSysButton SysButton = new CmSysButton();
     SysButton.Bounds = this.Bounds;
     SysButton.Location = this.Location;
     SysButton.size = this.Size;
     SysButton.ToolTip = this.ToolTip; ;
     SysButton.SysButtonNorml = this.SysButtonNorml;
     SysButton.SysButtonMouse = this.SysButtonMouse;
     SysButton.SysButtonDown = this.SysButtonDown;
     SysButton.OwnerForm = this.OwnerForm;
     SysButton.Name = this.Name;
     return SysButton;
 }
コード例 #17
0
 //确认存储空间
 private void EnsureSpace(int elements)
 {
     if (m_arrItem == null)
         m_arrItem = new CmSysButton[Math.Max(elements, 4)];
     else if (this.count + elements > m_arrItem.Length)
     {
         CmSysButton[] arrTemp = new CmSysButton[Math.Max(this.count + elements, m_arrItem.Length * 2)];
         m_arrItem.CopyTo(arrTemp, 0);
         m_arrItem = arrTemp;
     }
 }
コード例 #18
0
        //画自定义系统按钮集合
        private void RenderSkinFormCmSysBottomInternal(Graphics g, Rectangle rect, ControlBoxState state, bool active, CCSkinMain form, CmSysButton cmSysButton)
        {
            Bitmap btm       = null;
            Color  baseColor = ColorTable.ControlBoxActive;

            if (cmSysButton.BoxState == ControlBoxState.Pressed)
            {
                btm       = (Bitmap)cmSysButton.SysButtonDown;
                baseColor = ColorTable.ControlBoxPressed;
            }
            else if (state == ControlBoxState.Hover)
            {
                btm       = (Bitmap)cmSysButton.SysButtonMouse;
                baseColor = ColorTable.ControlBoxHover;
            }
            else
            {
                btm       = (Bitmap)cmSysButton.SysButtonNorml;
                baseColor = active ?
                            ColorTable.ControlBoxActive :
                            ColorTable.ControlBoxDeactive;
            }

            //绘制图片样式
            if (btm != null)
            {
                g.DrawImage(btm, rect);
            }
            else //绘制默认样式
            {
                RoundStyle roundStyle = RoundStyle.BottomLeft;
                using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g))
                {
                    RenderHelper.RenderBackgroundInternal(
                        g,
                        rect,
                        baseColor,
                        baseColor,
                        ColorTable.ControlBoxInnerBorder,
                        roundStyle,
                        6,
                        .38F,
                        true,
                        false,
                        LinearGradientMode.Vertical);

                    using (Pen pen = new Pen(ColorTable.Border))
                    {
                        g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y);
                    }
                }
            }
        }
コード例 #19
0
        //画自定义系统按钮集合
        private void RenderSkinFormCmSysBottomInternal(Graphics g, Rectangle rect, ControlBoxState state, bool active, CCSkinMain form, CmSysButton cmSysButton)
        {
            Bitmap btm = null;
            Color baseColor = ColorTable.ControlBoxActive;

            if (cmSysButton.BoxState == ControlBoxState.Pressed)
            {
                btm = (Bitmap)cmSysButton.SysButtonDown;
                baseColor = ColorTable.ControlBoxPressed;
            }
            else if (state == ControlBoxState.Hover)
            {
                btm = (Bitmap)cmSysButton.SysButtonMouse;
                baseColor = ColorTable.ControlBoxHover;
            }
            else
            {
                btm = (Bitmap)cmSysButton.SysButtonNorml;
                baseColor = active ?
                    ColorTable.ControlBoxActive :
                    ColorTable.ControlBoxDeactive;
            }

            //绘制图片样式
            if (btm != null)
            {
                g.DrawImage(btm, rect);
            }
            else //绘制默认样式
            {
                RoundStyle roundStyle = RoundStyle.BottomLeft;
                using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g))
                {
                    RenderHelper.RenderBackgroundInternal(
                        g,
                        rect,
                        baseColor,
                        baseColor,
                        ColorTable.ControlBoxInnerBorder,
                        roundStyle,
                        6,
                        .38F,
                        true,
                        false,
                        LinearGradientMode.Vertical);

                    using (Pen pen = new Pen(ColorTable.Border))
                    {
                        g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y);
                    }
                }
            }
        }