コード例 #1
0
        private void DrawInBuffer()
        {
            if (Width <= 0 || Height <= 0)
            {
                return;
            }

            try
            {
                if (buffer == null)
                {
                    buffer = new Bitmap(Width, Height);
                }
                else
                {
                    if (buffer.Width != Width || buffer.Height != Height)
                    {
                        buffer.Dispose();
                        buffer = new Bitmap(Width, Height);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("DrawInBuffer - ошибка выделения памяти", ex);
                throw new Exception("Ошибка выделения памяти (рисование)");
            }

            try
            {
                using (var g = Graphics.FromImage(buffer))
                {
                    g.Clear(BackColor);
                    //var container = g.BeginContainer();
                    //g.SetClip(ClientRect);
                    //g.TranslateTransform(ClientRect.Left, ClientRect.Top);
                    //Rectangle rectangle = Conversion.ParentToChild(new Rectangle(0, 0, Width - 1, Height - 1), ClientRect);
                    var rectangle = new Rectangle(0, 0, Width, Height);
                    try
                    {
                        Panes.Draw(g, rectangle);
                    }
                    catch (Exception ex)
                    {
                        logNoFlood.LogMessageFormatCheckFlood(LogEntryType.Error,
                                                              LogMsgDrawError, 1000 * 60 * 5,
                                                              "ChartControl.DrawInBuffer error: {0}", ex);
                    }
                    //g.EndContainer(container);
                }
            }
            catch (Exception ex)
            {
                Logger.ErrorFormat("ChartControl.DrawInBuffer error: width={0}, height={1}, {2}", Width, Height, ex);
            }
        }
コード例 #2
0
        private void Draw(Graphics g, Rectangle clipRectangle)
        {
            buffer = null;

            g.Clear(BackColor);
            //GraphicsContainer container = g.BeginContainer();
            //g.SetClip(ClientRect);
            //g.TranslateTransform(ClientRect.Left, ClientRect.Top);
            //Rectangle rectangle = Conversion.ParentToChild(clipRectangle, ClientRect);
            Panes.Draw(g, clipRectangle);
            //g.EndContainer(container);
        }