コード例 #1
0
        //渲染图片核心方法
        private void RenderImageCore(LayoutData layout)
        {
            layout.DoLayout();                                                                                                                                                              //执行布局
            this.CurrentImagePreferredRect = layout.OutImageBounds;                                                                                                                         //保存图片区域矩形
            bool      needRotate  = !(float.IsNaN(this.m_ImageRotateAngle) || this.m_ImageRotateAngle % 360f == 0f);                                                                        //是否需要旋转
            Rectangle imageBounds = needRotate ? RenderEngine.RotateRect(this.m_Graphics, this.CurrentImagePreferredRect, this.m_ImageRotateAngle, false) : this.CurrentImagePreferredRect; //新绘图区域(如果旋转则为旋转后的区域)

            //开始绘制
            if (this.m_State == State.Disabled && this.m_ImageGrayOnDisabled)
            {
                using (Image grayImg = RenderEngine.GetGrayImage(this.CurrentImage))
                {
                    this.m_Graphics.DrawImage(grayImg, imageBounds);
                }
            }
            else
            {
                this.m_Graphics.DrawImage(this.CurrentImage, imageBounds);
            }

            //恢复旋转
            if (needRotate)
            {
                this.m_Graphics.ResetTransform();
            }
        }
コード例 #2
0
        /// <summary>
        /// 渲染九宫格背景图
        /// </summary>
        /// <param name="rect">渲染区域</param>
        public void RenderBackgroundImage9(Rectangle rect)
        {
            this.m_BackgroundImage9Rect = rect;

            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(this.m_BackgroundImage9Rect) || this.CurrentBackgroundImage9 == null)
            {
                return;
            }

            if (this.m_State == State.Disabled && this.m_BackgroundImage9GrayOnDisabled)//灰色图片
            {
                using (Image img = RenderEngine.GetGrayImage(this.CurrentBackgroundImage9))
                {
                    RenderEngine.DrawBackgroundImage9(this.m_Graphics, img, this.CurrentBackgroundImage9Rect, this.m_BackgroundImage9Padding.Left, this.m_BackgroundImage9Padding.Top, this.m_BackgroundImage9Padding.Right, this.m_BackgroundImage9Padding.Bottom, this.m_BackgroundImage9Layout);
                }
            }
            else//原图
            {
                RenderEngine.DrawBackgroundImage9(this.m_Graphics, this.CurrentBackgroundImage9, this.CurrentBackgroundImage9Rect, this.m_BackgroundImage9Padding.Left, this.m_BackgroundImage9Padding.Top, this.m_BackgroundImage9Padding.Right, this.m_BackgroundImage9Padding.Bottom, this.m_BackgroundImage9Layout);
            }
        }
コード例 #3
0
        /// <summary>
        /// 渲染背景图
        /// </summary>
        /// <param name="rect">渲染区域</param>
        public void RenderBackgroundImage(Rectangle rect)
        {
            this.m_BackgroundImageRect = rect;

            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(this.m_BackgroundImageRect) || this.CurrentBackgroundImage == null)
            {
                return;
            }

            if (this.m_State == State.Disabled && this.m_BackgroundImageGrayOnDisabled)//灰色图片
            {
                using (Image img = RenderEngine.GetGrayImage(this.CurrentBackgroundImage))
                {
                    RenderEngine.DrawBackgroundImage(this.m_Graphics, img, this.CurrentBackgroundImageRect, this.m_BackgroundImageLayout);
                }
            }
            else//原图
            {
                RenderEngine.DrawBackgroundImage(this.m_Graphics, this.CurrentBackgroundImage, this.CurrentBackgroundImageRect, this.m_BackgroundImageLayout);
            }
        }