Esempio n. 1
0
 /// <summary>
 /// 绘制窗体Logo图标
 /// </summary>
 /// <param name="g">The g.</param>
 /// User:Ryan  CreateTime:2012-8-3 22:22.
 protected void DrawCaptionLogo(Graphics g)
 {
     if (base.ShowIcon && this.CapitionLogo != null)
     {
         GDIHelper.DrawImage(g, this.LogoRect, this._CapitionLogo, this.LogoSize);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 创建临时背景图片
        /// </summary>
        /// <returns>Return a data(or instance) of Bitmap.</returns>
        /// User:Ryan  CreateTime:2012-8-5 16:21.
        private Bitmap CreateBacgroundImage()
        {
            Rectangle rect = this.WorkRectangle;
            int       w    = rect.Width;
            int       h    = rect.Height;
            Point     p1   = new Point(this.Location.X + this.Padding.Left,
                                       this.Location.Y + this.CaptionHeight + this.Padding.Top);
            Point  p       = this.Parent == null ? p1 : this.PointToScreen(p1);
            Bitmap TempImg = new Bitmap(w, h);

            try
            {
                Bitmap img = new Bitmap(w, h);
                using (Graphics g = Graphics.FromImage(TempImg))
                {
                    g.CopyFromScreen(p, new Point(0, 0), new Size(w, h));
                }

                using (Graphics g = Graphics.FromImage(img))
                {
                    GDIHelper.DrawImage(g, new Rectangle(0, 0, w, h), TempImg, 0.36F);
                }

                return(img);
            }
            catch
            {
                return(null);
            }
            finally
            {
                TempImg.Dispose();
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 绘制皮肤按钮
 /// </summary>
 /// <param name="g">The g.</param>
 /// User:Ryan  CreateTime:2012-8-4 13:37.
 private void DrawSkinControlBox(Graphics g)
 {
     if (!this.SkinBoxRect.IsEmpty)
     {
         base.ControlBoxRender.DrawControlBox(g, this.SkinBoxRect, this._SkinBtnState);
         GDIHelper.DrawImage(g, this.SkinBoxRect, Properties.Resources.skin, this._SkinBoxSize);
     }
 }
Esempio n. 4
0
        /// <summary>
        ///  绘制按钮
        /// </summary>
        /// <param name="g">The Graphics.</param>
        /// User:Ryan  CreateTime:2011-08-02 14:23.
        private void DrawButton(Graphics g)
        {
            GDIHelper.InitializeGraphics(g);
            RoundRectangle btnRoundRect = new RoundRectangle(this.ButtonRect, 0);
            Color          c            = this.Enabled ? this._BackColor : SystemColors.Control;
            Size           btnSize      = new Size(20, 20);

            GDIHelper.FillRectangle(g, btnRoundRect, c);
            GDIHelper.DrawImage(g, this.ButtonRect, Properties.Resources.calendar, btnSize);
        }
Esempio n. 5
0
        /// <summary>
        /// 绘制窗体背景
        /// </summary>
        /// <param name="g">The g.</param>
        /// User:Ryan  CreateTime:2012-8-3 22:22.
        public void DrawFormBackGround(Graphics g)
        {
            Rectangle rect = new Rectangle(0, 0, this.Width - 2, this.Height - 2);

            if (SkinManager.CurrentSkin.BackGroundImageEnable)
            {
                GDIHelper.DrawImage(g, rect, SkinManager.CurrentSkin.BackGroundImage, SkinManager.CurrentSkin.BackGroundImageOpacity);
                //GDIHelper.DrawImage(g, rect, SkinManager.CurrentSkin.BackGroundImage);
            }
            else
            {
                GDIHelper.FillRectangle(g, rect, SkinManager.CurrentSkin.ThemeColor);
            }
        }
Esempio n. 6
0
        protected virtual void OnDrawFirstSubItem(DrawListViewSubItemEventArgs e, Graphics g)
        {
            TextFormatFlags flags        = GetFormatFlags(e.Header.TextAlign);
            Rectangle       rect         = e.Bounds;
            Image           img          = null;
            Size            imgSize      = Size.Empty;
            Rectangle       checkBoxRect = new Rectangle(rect.X, rect.Y, 0, 0);
            Rectangle       imgRect      = checkBoxRect;
            Rectangle       textRect     = rect;
            int             offset       = 2;

            if (e.Item.ListView.CheckBoxes)
            {
                checkBoxRect.X     += offset * 2;
                checkBoxRect.Y      = rect.Top + (rect.Height - this._CheckBoxSize.Height) / 2;
                checkBoxRect.Width  = this._CheckBoxSize.Width;
                checkBoxRect.Height = this._CheckBoxSize.Height;
                imgRect.X           = checkBoxRect.Right;
                textRect.X          = checkBoxRect.Right;
                textRect.Width     -= this._CheckBoxSize.Width - offset * 2;
                GDIHelper.DrawCheckBox(g, new RoundRectangle(checkBoxRect, 1));
                if (e.Item.Checked)
                {
                    GDIHelper.DrawCheckedStateByImage(g, checkBoxRect);
                }
            }

            if (e.Item.ImageList != null && e.Item.ImageIndex >= 0)
            {
                img        = e.Item.ImageList.Images[e.Item.ImageIndex];
                imgSize    = e.Item.ImageList.ImageSize;
                imgRect.X += offset * 3;
                imgRect.Y  = rect.Y + offset;
                int width = rect.Height - offset * 2;
                imgRect.Width   = width;
                imgRect.Height  = width;
                textRect.X      = imgRect.Right;
                textRect.Width -= width - offset * 2;
                GDIHelper.DrawImage(g, imgRect, img, imgSize);
            }

            textRect.X     += offset;
            textRect.Width -= offset * 2;
            Color c = (e.ItemState & ListViewItemStates.Selected) == ListViewItemStates.Selected ?
                      Color.White : e.SubItem.ForeColor;

            TextRenderer.DrawText(g, e.SubItem.Text, this._Font, textRect, c, flags);
        }
Esempio n. 7
0
        /// <summary>
        /// 绘制水晶按钮
        /// </summary>
        /// <param name="g">The g.</param>
        /// User:Ryan  CreateTime:2012-8-5 14:13.
        protected void DrawRibbonBtn(Graphics g)
        {
            Rectangle exRect = new Rectangle(0, base.CaptionHeight, this.Width, this.Height - base.CaptionHeight + 1);

            g.SetClip(exRect, CombineMode.Exclude);
            GDIHelper.InitializeGraphics(g);
            Rectangle rect = this.RibbonBtnRect;

            rect.Inflate(-1, -1);
            GDIHelper.FillEllipse(g, rect, Color.White);
            Color c1 = Color.Empty, c2 = Color.Empty, c3 = Color.FromArgb(232, 246, 250);
            Blend blend = new Blend();

            blend.Positions = new float[] { 0f, 0.3f, 0.5f, 0.8f, 1f };
            blend.Factors   = new float[] { 0.15f, 0.55f, 0.7f, 0.8f, 0.95f };
            switch (this._RibbonBtnState)
            {
            case EnumControlState.HeightLight:
                c1 = Color.FromArgb(225, 179, 27);
                c2 = Color.FromArgb(255, 251, 232);
                break;

            case EnumControlState.Focused:
                c1 = Color.FromArgb(191, 113, 5);
                c2 = Color.FromArgb(248, 227, 222);
                break;

            default:
                c1 = Color.FromArgb(239, 246, 249);
                c2 = Color.FromArgb(224, 221, 231);
                blend.Positions = new float[] { 0f, 0.3f, 0.5f, 0.85f, 1f };
                blend.Factors   = new float[] { 0.95f, 0.70f, 0.45f, 0.3f, 0.15f };
                break;
            }

            GDIHelper.DrawCrystalButton(g, rect, c1, c2, c3, blend);
            Color borderColor = Color.FromArgb(65, 177, 199);

            GDIHelper.DrawEllipseBorder(g, rect, borderColor, 1);
            Size imgSize = new System.Drawing.Size(20, 20);

            GDIHelper.DrawImage(g, rect, Properties.Resources.naruto, imgSize);
            g.ResetClip();
        }
        /// <summary>
        /// 创建临时背景图片
        /// </summary>
        /// <returns>Return a data(or instance) of Bitmap.</returns>
        private Bitmap CreateBacgroundImage()
        {
            Rectangle rect = Control.ClientRectangle;
            //100%的时候,DPI是96;这条语句的作用时获取放大比例
            int w = (int)(rect.Width * PrimaryScreen.ScaleX);
            int h = (int)(rect.Height * PrimaryScreen.ScaleY);

            Point p1 = Control.PointToScreen(new Point(0, 0));
            Point p  = new Point((int)(p1.X * PrimaryScreen.ScaleX), (int)(p1.Y * PrimaryScreen.ScaleY));

            Bitmap TempImg = new Bitmap(w, h);

            try
            {
                Bitmap img = new Bitmap(w, h);
                using (Graphics g = Graphics.FromImage(TempImg))
                {
                    g.CopyFromScreen(p, new Point(0, 0), new Size(w, h));
                }

                using (Graphics g = Graphics.FromImage(img))
                {
                    GDIHelper.DrawImage(g, new Rectangle(0, 0, w, h), TempImg, _alpha);
                }

                return(img);
            }
            catch
            {
                return(null);
            }
            finally
            {
                TempImg.Dispose();
            }
        }