예제 #1
0
파일: Canvas.cs 프로젝트: uvbs/FullSource
        /// <summary>
        /// 刷新缩略图绘图板
        /// </summary>
        public void RefreshAbbreviateCanvas()
        {
            if (abbreviateCanvas != null && abbreviateCanvas.Visible && refreshAbbreviateBitmap) // 需要刷新缩略图
            {
                abbreviateCanvas.PaintCanvas = false;                                            // 避免使用释放的缩略图片资源的问题
                AbbreviateCanvas tempAbbreviateCanvas = abbreviateCanvas;
                abbreviateCanvas = null;

                if (canvasAbbreviateBitmap != null)
                {
                    canvasAbbreviateBitmap.Dispose(); // 释放图片资源
                }
                canvasAbbreviateBitmap = new Bitmap(background.CanvasSize.Width, background.CanvasSize.Height);
                Graphics g = Graphics.FromImage(canvasAbbreviateBitmap);
                g.Clear(Color.White);

                // 绘制图元
                foreach (GraphElement graphElement in graphElementList)
                {
                    graphElement.AbbreviativePaint(g);
                }

                refreshAbbreviateBitmap = false;
                g.Dispose(); // 释放绘图资源
                tempAbbreviateCanvas.AbbreciateImage = canvasAbbreviateBitmap;
                tempAbbreviateCanvas.Invalidate();
                abbreviateCanvas             = tempAbbreviateCanvas;
                abbreviateCanvas.PaintCanvas = true; // 避免使用释放的缩略图片资源的问题
            }
        }
예제 #2
0
파일: Canvas.cs 프로젝트: viticm/pap2
        /// <summary>
        /// 刷新缩略图绘图板
        /// </summary>
        public void RefreshAbbreviateCanvas()
        {
            if(abbreviateCanvas != null && abbreviateCanvas.Visible && refreshAbbreviateBitmap) // 需要刷新缩略图
            {
                abbreviateCanvas.PaintCanvas = false; // 避免使用释放的缩略图片资源的问题
                AbbreviateCanvas tempAbbreviateCanvas = abbreviateCanvas;
                abbreviateCanvas = null;

                if (canvasAbbreviateBitmap != null)
                {
                    canvasAbbreviateBitmap.Dispose(); // 释放图片资源
                }
                canvasAbbreviateBitmap = new Bitmap(background.CanvasSize.Width, background.CanvasSize.Height);
                Graphics g = Graphics.FromImage(canvasAbbreviateBitmap);
                g.Clear(Color.White);

                // 绘制图元
                foreach (GraphElement graphElement in graphElementList)
                {
                    graphElement.AbbreviativePaint(g);
                }

                refreshAbbreviateBitmap = false;
                g.Dispose(); // 释放绘图资源
                tempAbbreviateCanvas.AbbreciateImage = canvasAbbreviateBitmap;
                tempAbbreviateCanvas.Invalidate();
                abbreviateCanvas = tempAbbreviateCanvas;
                abbreviateCanvas.PaintCanvas = true; // 避免使用释放的缩略图片资源的问题
            }
        }