Exemplo n.º 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            int      w = this.BorderWidth > 0 ? this.BorderWidth : 0;
            Graphics g = e.Graphics;

            //缓冲
            //BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current;
            //BufferedGraphics myBuffer = currentContext.Allocate(e.Graphics, e.ClipRectangle);
            //Graphics g = myBuffer.Graphics;

            GDIHelper.InitializeGraphics(g);
            GradientColor  color     = new GradientColor(this._BackBeginColor, this._BackEndColor, null, null);
            Rectangle      rect      = new Rectangle(0, 0, this.Size.Width - 1, this.Size.Height - 1);
            RoundRectangle roundRect = new RoundRectangle(rect, new CornerRadius(this._CornerRadius));

            GDIHelper.FillRectangle(g, roundRect, color);
            if (this._BorderWidth > 0)
            {
                rect.X     += this._BorderWidth - 1; rect.Y += this._BorderWidth - 1;
                rect.Width -= this._BorderWidth - 1; rect.Height -= this._BorderWidth - 1;

                GDIHelper.DrawPathBorder(g, new RoundRectangle(rect, new CornerRadius(this._CornerRadius)), this._BorderColor, this.BorderWidth);
                // 上容器的边框
                Rectangle rectPanel1 = new Rectangle(0, 0, this.Panel1.Width - 1, this.Panel1.Height - 1);
                GDIHelper.DrawPathBorder(g, new RoundRectangle(rectPanel1, new CornerRadius(0)), this._BorderColor, this.BorderWidth);
            }

            //g.SmoothingMode = SmoothingMode.HighQuality;
            //g.PixelOffsetMode = PixelOffsetMode.HighSpeed;
            //myBuffer.Render(e.Graphics);
            //g.Dispose();
            //myBuffer.Dispose();//释放资源
        }
Exemplo n.º 2
0
        public void LayoutTest()
        {
            string image1Path = AppDomain.CurrentDomain.BaseDirectory + @"\UI\demo.jpg";

            Assert.IsNotNull(string.IsNullOrEmpty(image1Path));
            Assert.IsTrue(System.IO.File.Exists(image1Path));
            Image image1 = Image.FromFile(image1Path);

            Assert.IsNotNull(image1);

            Image imageNone    = GDIHelper.Layout(image1, new Size(1000, 1000), System.Windows.Forms.ImageLayout.None);
            Image imageTile    = GDIHelper.Layout(image1, new Size(1000, 1000), System.Windows.Forms.ImageLayout.Tile);
            Image imageCenter  = GDIHelper.Layout(image1, new Size(1000, 1000), System.Windows.Forms.ImageLayout.Center);
            Image imageZoom    = GDIHelper.Layout(image1, new Size(1000, 1000), System.Windows.Forms.ImageLayout.Zoom);
            Image imageStretch = GDIHelper.Layout(image1, new Size(1000, 1000), System.Windows.Forms.ImageLayout.Stretch);

            Image imageTile2    = GDIHelper.Layout(image1, new Size(100, 100), System.Windows.Forms.ImageLayout.Tile);
            Image imageCenter2  = GDIHelper.Layout(image1, new Size(100, 100), System.Windows.Forms.ImageLayout.Center);
            Image imageZoom2    = GDIHelper.Layout(image1, new Size(100, 100), System.Windows.Forms.ImageLayout.Zoom);
            Image imageStretch2 = GDIHelper.Layout(image1, new Size(100, 100), System.Windows.Forms.ImageLayout.Stretch);

            string folderPath = AppDomain.CurrentDomain.BaseDirectory + @"\UI\";

            imageNone.Save(folderPath + "LayoutTest_imageNone.png", System.Drawing.Imaging.ImageFormat.Png);
            imageTile.Save(folderPath + "LayoutTest_imageTile.png", System.Drawing.Imaging.ImageFormat.Png);
            imageCenter.Save(folderPath + "LayoutTest_imageCenter.png", System.Drawing.Imaging.ImageFormat.Png);
            imageZoom.Save(folderPath + "LayoutTest_imageZoom.png", System.Drawing.Imaging.ImageFormat.Png);
            imageStretch.Save(folderPath + "LayoutTest_imageStretch.png", System.Drawing.Imaging.ImageFormat.Png);
            imageTile2.Save(folderPath + "LayoutTest_imageTile2.png", System.Drawing.Imaging.ImageFormat.Png);
            imageCenter2.Save(folderPath + "LayoutTest_imageCenter2.png", System.Drawing.Imaging.ImageFormat.Png);
            imageZoom2.Save(folderPath + "LayoutTest_imageZoom2.png", System.Drawing.Imaging.ImageFormat.Png);
            imageStretch2.Save(folderPath + "LayoutTest_imageStretch2.png", System.Drawing.Imaging.ImageFormat.Png);
        }
Exemplo n.º 3
0
        public void OverlayImageWithCutEllipseTest()
        {
            string image1Path = AppDomain.CurrentDomain.BaseDirectory + @"\UI\head-frame.png";
            string image2Path = AppDomain.CurrentDomain.BaseDirectory + @"\UI\demo2.jpg";

            Assert.IsNotNull(string.IsNullOrEmpty(image1Path));
            Assert.IsTrue(System.IO.File.Exists(image1Path));
            Image image1 = Image.FromFile(image1Path);

            Assert.IsNotNull(image1);
            image1.Save(image1Path.Replace(".png", "-raw-OverlayImageWithCutEllipseTest.png"), System.Drawing.Imaging.ImageFormat.Png);

            Assert.IsNotNull(string.IsNullOrEmpty(image2Path));
            Assert.IsTrue(System.IO.File.Exists(image2Path));
            Image image2 = Image.FromFile(image2Path);

            Assert.IsNotNull(image2);
            image2.Save(image2Path.Replace(".jpg", "-raw-OverlayImageWithCutEllipseTest.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);

            Image result = GDIHelper.OverlayImageWithCutEllipse(image1, image2, new Rectangle(image2.Width / 50 * 20, image2.Height / 16 * 1, image2.Width / 7, image2.Width / 7),
                                                                1.0F, new Point(image1.Width / 7, image1.Height / 7), new Size(image1.Width / 7 * 5, image1.Height / 7 * 5),
                                                                new Size(image1.Width / 3 * 2, image1.Height / 3 * 2));

            string resultPath = AppDomain.CurrentDomain.BaseDirectory + @"\UI\OverlayImageWithCutEllipseTest-result.png";

            result.Save(resultPath, System.Drawing.Imaging.ImageFormat.Png);
        }
Exemplo n.º 4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            base.OnPaintBackground(e);
            Graphics g = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            Rectangle textRect  = this.GetTextRect(g);
            Color     textColor = this.Enabled ? this._CaptionColor : SkinManager.CurrentSkin.UselessColor;

            switch (this._BorderStyle)
            {
            case EnumBorderStyle.QQStyle:
                this.DrawQQStyleBorder(g, textRect);
                break;

            case EnumBorderStyle.Default:
                this.DrawDefaultBorder(g, textRect);
                break;

            default:
                break;
            }

            TextRenderer.DrawText(g, this.Text, this._CaptionFont, textRect, textColor, TextFormatFlags.Left);
        }
Exemplo n.º 5
0
    public static GDIGraphic Create(int width, int height, HandleRef handle)
    {
        float size_unit = height * 0.08F;

        GDIGraphic graphic = new GDIGraphic();

        graphic.width  = width;
        graphic.height = height;
        graphic.info   = GDIHelper.CreateBitmapinfo(width, height);
        graphic.handle = handle;

        graphic.frame = new int[width * height];
        graphic.depth = new int[width * height];

        graphic.worldViewMatrix = new Matrix3x3(
            size_unit, 0, width / 2,
            0, size_unit, height / 2,
            0, 0, 1);

        graphic.screenViewMatrix = new Matrix3x3(
            width, 0, width / 2,
            0, height, height / 2,
            0, 0, 1);

        init(ref graphic.frame[0], ref graphic.depth[0], width, height);

        return(graphic);
    }
Exemplo n.º 6
0
        public string GetFileUrl(GetFileUrlParameter param)
        {
            var repository = new InfrastructureRepository();
            var pathObj    = repository.QueryFilePath(new QueryFileParameter()
            {
                AppID   = param.AppID,
                FileKey = param.FileKey
            });
            string outFilePath = pathObj.VirtualPath, fileExt;
            var    size = param.ImageThumbnailSize;

            if (size.HasValue && ImageExts.Contains(fileExt = Path.GetExtension(pathObj.PhysicalPath)))
            {
                string filePath = Path.ChangeExtension(pathObj.PhysicalPath, string.Format("{0},{1}", size.Value.Width, size.Value.Height) + fileExt);
                try
                {
                    if (!File.Exists(filePath))
                    {
                        GDIHelper.MakeThumbnailImage(pathObj.PhysicalPath, filePath, size.Value.Width, size.Value.Height, ThumbnailMode.Zoom);
                    }
                    outFilePath = outFilePath.Replace(Path.GetFileName(pathObj.PhysicalPath), Path.GetFileName(filePath));
                }
                catch (Exception ex)
                {
                    App.LogError(ex, "GetFileUrl");
#if DEBUG
                    throw;
#endif
                }
            }
            return(_config.StorageUrl + outFilePath);
        }
Exemplo n.º 7
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);
     }
 }
Exemplo n.º 8
0
 protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
 {
     try
     {
         base.OnDrawColumnHeader(e);
         string key = this.Columns[e.ColumnIndex].ImageKey;
         if (!string.IsNullOrEmpty(key))
         {
             Rectangle rect      = e.Bounds;
             int       offset    = 3;
             Size      arrowSize = new System.Drawing.Size(8, 6);
             Rectangle sortRect  = new Rectangle(rect.Right - offset - arrowSize.Width,
                                                 rect.Y + (rect.Height - arrowSize.Height) / 2,
                                                 arrowSize.Width, arrowSize.Height);
             Graphics g = e.Graphics;
             GDIHelper.InitializeGraphics(g);
             Color c = Color.FromArgb(46, 117, 35);
             if (key == "up")
             {
                 GDIHelper.DrawArrow(g, ArrowDirection.Up, sortRect, arrowSize, 1.5f, c);
             }
             else
             {
                 GDIHelper.DrawArrow(g, ArrowDirection.Down, sortRect, arrowSize, 1.5f, c);
             }
         }
     }catch {}
 }
Exemplo n.º 9
0
        /// <summary>
        /// 绘制背景和边框等
        /// </summary>
        /// <param name="g">The Graphics.</param>
        /// User:Ryan  CreateTime:2011-08-01 16:47.
        private void DrawBackGround(Graphics g)
        {
            GDIHelper.InitializeGraphics(g);
            Rectangle      rect      = new Rectangle(1, 1, this.Width - 3, this.Height - 3);
            RoundRectangle roundRect = new RoundRectangle(rect, new Model.CornerRadius(this._CornerRadius));

            switch (this._ControlState)
            {
            case EnumControlState.Default:
                if (this.FlatStyle != FlatStyle.Flat)
                {
                    GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.DefaultControlColor);
                    GDIHelper.DrawPathBorder(g, roundRect);
                }
                break;

            case EnumControlState.HeightLight:
                GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.HeightLightControlColor);
                GDIHelper.DrawPathBorder(g, roundRect);
                break;

            case EnumControlState.Focused:
                GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.FocusedControlColor);
                GDIHelper.DrawPathBorder(g, roundRect);
                GDIHelper.DrawPathInnerBorder(g, roundRect);
                break;
            }
        }
Exemplo n.º 10
0
        internal void RenderButton(
            Graphics g,
            Rectangle rect,
            Color baseColor,
            Color borderColor,
            Color arrowColor,
            ArrowDirection direction)
        {
            CornerRadius cr = new CornerRadius();

            switch (direction)
            {
            case ArrowDirection.Left:
                cr = new CornerRadius(2, 0, 2, 0);
                break;

            case ArrowDirection.Right:
                cr = new CornerRadius(0, 2, 0, 2);
                break;
            }

            RoundRectangle roundRect = new RoundRectangle(rect, cr);

            GDIHelper.FillPath(g, roundRect, baseColor, baseColor);
            GDIHelper.DrawPathBorder(g, roundRect);
            using (SolidBrush brush = new SolidBrush(arrowColor))
            {
                RenderArrowInternal(
                    g,
                    rect,
                    direction,
                    brush);
            }
        }
Exemplo n.º 11
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //Graphics g = e.Graphics;
            //GDIHelper.InitializeGraphics(g);
            //this.DrawFormBackGround(g);
            //this.DrawCaption(g);
            //this.DrawFormBorder(g);


            BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current;
            BufferedGraphics        myBuffer       = currentContext.Allocate(e.Graphics, e.ClipRectangle);
            Graphics g = myBuffer.Graphics;

            GDIHelper.InitializeGraphics(g);
            this.DrawFormBackGround(g);
            this.DrawCaption(g);
            this.DrawFormBorder(g);

            g.SmoothingMode   = SmoothingMode.HighQuality;
            g.PixelOffsetMode = PixelOffsetMode.HighSpeed;
            // g.Clear(this.BackColor);
            myBuffer.Render(e.Graphics);
            g.Dispose();
            myBuffer.Dispose();//释放资源
        }
Exemplo n.º 12
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();
            }
        }
Exemplo n.º 13
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);
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// 绘制窗体标题栏
        /// </summary>
        /// <param name="g">The g.</param>
        /// User:Ryan  CreateTime:2012-8-3 22:22.
        private void DrawCaptionBackGround(Graphics g)
        {
            Rectangle rect   = new Rectangle(0, 0, this.Width, this.CaptionHeight);
            Rectangle exRect = new Rectangle(rect.Left, rect.Bottom, rect.Width, 1);

            g.SetClip(exRect, CombineMode.Exclude);
            GDIHelper.FillRectangle(g, rect, SkinManager.CurrentSkin.CaptionColor);
            g.ResetClip();
        }
Exemplo n.º 15
0
        public void Draw(RendererContext context)
        {
            if (!isInitialized)
            {
                return;
            }

            GDIHelper.SetDIBitsToDevice(handle, 0, 0, width, height, 0, 0, 0, height, ref context.Buffer[0], ref info, 0);
        }
Exemplo n.º 16
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            this.DrawFormBackGround(g);
            this.DrawCaption(g);
            this.DrawFormBorder(g);
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
0
        public static MemoryStream DrawImage(Stream imgStream, Image waterMarkImage, ContentAlignment alignment, int margin)
        {
            var stream = new MemoryStream();

            using (var img = Image.FromStream(imgStream))
            {
                GDIHelper.MakeWaterMark(img, waterMarkImage, alignment, margin);
                img.Save(stream, img.RawFormat);
            }
            return(stream);
        }
Exemplo n.º 19
0
        public static MemoryStream DrawImage(Stream imgStream, string text, Font textFont, Color textColor, ContentAlignment alignment, float margin)
        {
            var stream = new MemoryStream();

            using (var img = Image.FromStream(imgStream))
            {
                GDIHelper.MakeWaterMark(img, text, textFont, textColor, alignment, margin);
                img.Save(stream, img.RawFormat);
            }
            return(stream);
        }
Exemplo n.º 20
0
        protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
        {
            Size     arrowSize = new Size(8, 8);
            Graphics g         = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            Rectangle rect = e.ArrowRectangle;

            rect.X -= 2;
            GDIHelper.DrawArrow(g, e.Direction, rect, arrowSize);
        }
Exemplo n.º 21
0
        /// <summary>
        /// 绘制下拉框区域.
        /// </summary>
        /// <param name="g">The Graphics.</param>
        /// User:Ryan  CreateTime:2011-07-29 15:44.
        private void DrawComboBoxBorder(Graphics g)
        {
            GDIHelper.InitializeGraphics(g);
            Rectangle rect = new Rectangle(Point.Empty, this.Size);

            rect.Width--;
            rect.Height--;
            using (Pen pen = new Pen(SkinManager.CurrentSkin.BorderColor, 1))
            {
                g.DrawRectangle(pen, rect);
            }
        }
Exemplo n.º 22
0
    public void EndRenderer()
    {
        for (int index = 0; index < Gizmos.currentPrimitive; index++)
        {
            Gizmos.primitives[index].Draw(worldViewMatrix, width, height, ref frame);
        }

        Gizmos.currentPrimitive = 0;

        GDIHelper.SetDIBitsToDevice(handle, 0, 0, width, height, 0, 0, 0, height, ref frame[0], ref info, 0);

        clear();
    }
Exemplo n.º 23
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics  g    = e.Graphics;
            Rectangle rect = new Rectangle(0, 0, this.Width - 1, this.Height - 1);

            rect.Inflate(-1, -1);
            GDIHelper.InitializeGraphics(g);
            GDIHelper.DrawPathBorder(g, new RoundRectangle(rect, this._CornerRadius), this._BorderColor);
            if (this._ControlState == EnumControlState.HeightLight)
            {
                GDIHelper.DrawPathOuterBorder(g, new RoundRectangle(rect, this._CornerRadius), this._HeightLightBolorColor);
            }
        }
Exemplo n.º 24
0
        protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
        {
            base.OnDrawSubItem(e);
            if (View != View.Details || e.ItemIndex == -1)
            {
                return;
            }

            Rectangle          bounds    = e.Bounds;
            ListViewItemStates itemState = e.ItemState;
            Graphics           g         = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            Blend blen = new Blend();

            blen.Positions = new float[] { 0f, 0.4f, 0.7f, 1f };
            blen.Factors   = new float[] { 0f, 0.3f, 0.8f, 0.2f };
            Color c1, c2;

            if ((itemState & ListViewItemStates.Selected) == ListViewItemStates.Selected)
            {
                c1 = this._SelectedBeginColor;
                c2 = this._SelectedEndColor;
                //使用全局皮肤色彩,注意选择文字需要反色处理
                c1             = SkinManager.CurrentSkin.HeightLightControlColor.First;
                c2             = SkinManager.CurrentSkin.HeightLightControlColor.Second;
                blen.Factors   = SkinManager.CurrentSkin.HeightLightControlColor.Factors;
                blen.Positions = SkinManager.CurrentSkin.HeightLightControlColor.Positions;
                GDIHelper.FillPath(g, new RoundRectangle(bounds, 0), c1, c2, blen);
            }
            else
            {
                if (e.ColumnIndex == 0)
                {
                    bounds.Inflate(0, -1);
                }
                c1 = e.ItemIndex % 2 == 0 ? this._RowBackColor1 : this._RowBackColor2;
                c2 = c1;
                GDIHelper.FillPath(g, new RoundRectangle(bounds, 0), c1, c2, blen);
            }

            if (e.ColumnIndex == 0)
            {
                this.OnDrawFirstSubItem(e, g);
            }
            else
            {
                this.DrawNormalSubItem(e, g);
            }
        }
Exemplo n.º 25
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);
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// 绘制默认边框
        /// </summary>
        /// User:K.Anding  CreateTime:2011-7-30 22:30.
        private void DrawDefaultBorder(Graphics g, Rectangle textRect)
        {
            Rectangle rect = new Rectangle();

            rect.X      = 0;
            rect.Y      = textRect.Height / 2;
            rect.Height = this.Height - textRect.Height / 2 - 1;
            rect.Width  = this.Width - 1;
            RoundRectangle roundRect = new RoundRectangle(rect, new CornerRadius(this._CornerRadius));

            g.SetClip(textRect, CombineMode.Exclude);
            GDIHelper.DrawPathBorder(g, roundRect, this._BorderColor, this._BorderWidth);
            g.ResetClip();
        }
Exemplo n.º 27
0
        protected override void OnRenderOverflowButtonBackground(ToolStripItemRenderEventArgs e)
        {
            base.OnRenderOverflowButtonBackground(e);
            Graphics g = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            ToolStripItem item = e.Item;
            Rectangle     rect = item.Bounds;

            rect = new Rectangle(0, 0, rect.Width, rect.Height);
            Size arrowSize = new Size(8, 8);

            GDIHelper.DrawArrow(g, ArrowDirection.Down, rect, arrowSize);
        }
Exemplo n.º 28
0
        protected override void OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripItem item = e.Item;
            Graphics      g    = e.Graphics;

            GDIHelper.InitializeGraphics(g);
            Rectangle      rect      = new Rectangle(0, 0, item.Width - 1, item.Height - 1);
            RoundRectangle roundRect = new RoundRectangle(rect, this.ItemCornerRadius);

            if (item.Selected || item.Pressed)
            {
                GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.HeightLightControlColor);
                GDIHelper.DrawPathBorder(g, roundRect);
            }
        }
Exemplo n.º 29
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);
        }
Exemplo n.º 30
0
        /// <summary>
        /// 绘制下拉框区域.
        /// </summary>
        /// <param name="g">The Graphics.</param>
        /// User:Ryan  CreateTime:2011-07-29 15:44.
        private void DrawComboBox(Graphics g)
        {
            GDIHelper.InitializeGraphics(g);
            Rectangle rect = new Rectangle(Point.Empty, this.Size);

            rect.Width--; rect.Height--;
            ////背景
            RoundRectangle roundRect = new RoundRectangle(rect, 0);
            Color          backColor = this.Enabled ? this._BackColor : SystemColors.Control;

            g.SetClip(this.EditRect, CombineMode.Exclude);
            GDIHelper.FillRectangle(g, roundRect, backColor);
            g.ResetClip();
            this.DrawButton(g);
            GDIHelper.DrawPathBorder(g, roundRect);
        }