예제 #1
0
        public static System.Drawing.Bitmap DrawDigital(System.Drawing.Rectangle destRect, string DisplayedDigitalNumber, System.Drawing.Color thisColor, System.Drawing.Font thisFont)
        {
            System.Drawing.Bitmap m_Bitmap = new System.Drawing.Bitmap(destRect.Width, destRect.Height);

            System.Drawing.Graphics tmpg = System.Drawing.Graphics.FromImage(m_Bitmap);

            tmpg.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;

            tmpg.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;

            tmpg.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            LEDDisplay ssd = new LEDDisplay(tmpg);

            System.Drawing.Drawing2D.GraphicsState gs = tmpg.Save();

            tmpg.TranslateTransform(destRect.X, destRect.Y);

            System.Drawing.SizeF sizef = ssd.SizeDesign(DisplayedDigitalNumber, thisFont);

            float fScale = Math.Min(destRect.Width / sizef.Width, destRect.Height / sizef.Height);

            System.Drawing.Font font = new System.Drawing.Font(thisFont.FontFamily, fScale * thisFont.SizeInPoints);

            sizef = ssd.SizeDesign(DisplayedDigitalNumber, font);

            ssd.DrawString(DisplayedDigitalNumber, font, new System.Drawing.SolidBrush(thisColor), (destRect.Width - sizef.Width) / 2, (destRect.Height - sizef.Height) / 2);

            tmpg.Restore(gs);

            return(m_Bitmap);
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            int w = 1;

            if (_items != null && _items.Count > 0)
            {
                int gap = 0;
                for (int i = 0; i < _items.Count; i++)
                {
                    int x = w + gap;
                    int y = 1;
                    System.Drawing.Drawing2D.GraphicsState gt = e.Graphics.Save();
                    e.Graphics.TranslateTransform(x, y);
                    w = w + _items[i].Paint(e.Graphics);
                    e.Graphics.Restore(gt);
                    gap += Gap;
                }
            }
            if (w == 1)
            {
                string s = this.Name;
                if (this.Site != null && !string.IsNullOrEmpty(this.Site.Name))
                {
                    s = this.Site.Name;
                }
                e.Graphics.DrawString(s, this.Font, Brushes.Black, (float)1, (float)1);
            }
        }
예제 #3
0
        void RenderPage(Graphics graphics, int pageIndex)
        {
            if (pdfFile != null && pageIndex >= 0 && pageIndex < pdfFile.PageCount)
            {
                System.Drawing.Drawing2D.GraphicsState state = graphics.Save();

                graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                //graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
                //graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default;
                //graphics.PageUnit = GraphicsUnit.Millimeter;
                //graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                //graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

                double scale = this.Pages[pageIndex].Width / this.Pages[pageIndex].PdfWidth;
                graphics.ScaleTransform((float)scale, (float)scale);

                Bitmap bmp = GetCachedBmp(pageIndex);

                graphics.DrawImage(bmp, new Point(0, 0));
                //pdfFile.RenderPage(pageIndex, graphics);

                graphics.Restore(state);
            }
            else
            {
                graphics.Clear(Color.White);
            }
        }
예제 #4
0
        private void Form1_DragDrop(object sender, DragEventArgs e)
        {
            string[] filename = new string[] { };
            string[] f        = e.Data.GetFormats();
            Image    s        = null;

            try
            {
                if (e.Data.GetDataPresent(System.Windows.Forms.DataFormats.FileDrop))
                {
                    filename  = (string[])e.Data.GetData(DataFormats.FileDrop);
                    this.Text = Path.GetFileName(filename[0]);
                    s         = Image.FromFile(filename[0]);
                }
            }
            catch (Exception x) { MessageBox.Show(x.Message); }

            if (s != null)
            {
                try
                {
                    pictureBox1.Image = s;
                    p.Image           = pictureBox1.Image;
                }
                catch (Exception x) { }
            }
        }
        /*
         * Histogramm in die PictureBox des Fensters zeichnen auf Grundlage der Histogramm daten
         */
        public void draw_histogram(System.Windows.Forms.PictureBox statistik_pic, Config.histogram_canal canal)
        {
            const int width  = 256;
            const int height = 100;

            Bitmap   bb         = new Bitmap(width, height);
            Graphics objGraphic = Graphics.FromImage(bb);
            Pen      pen        = new Pen(Color.Black);

            pen.Width = 5;

            objGraphic.DrawLine(pen, 0, height, width - 1, height);

            int peak  = 0;
            int c     = (int)canal;
            int value = 0;

            for (int x = 1; x < width; x++)
            {
                value = histo[c, x];
                // Höchstwert des Kanal Wertes berechnen <- normalisiert
                peak = (value == 0) ? 0 : (value * height) / this.peak[(int)canal];
                objGraphic.DrawLine(pen, x, height, x, height - peak);

                System.Drawing.Drawing2D.GraphicsState graph = objGraphic.Save();
                objGraphic.Restore(graph);
            }

            statistik_pic.Image = bb;
            statistik_pic.Refresh();
        }
예제 #6
0
            protected override void OnDraw(DevAge.Drawing.GraphicsCache graphics, RectangleF area)
            {
                System.Drawing.Drawing2D.GraphicsState state = graphics.Graphics.Save();
                try
                {
                    float width2  = area.Width / 2;
                    float height2 = area.Height / 2;

                    //For a better drawing use the clear type rendering
                    graphics.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;

                    //Move the origin to the center of the cell (for a more easy rotation)
                    graphics.Graphics.TranslateTransform(area.X + width2, area.Y + height2);

                    graphics.Graphics.RotateTransform(Angle);
                    graphics.Graphics.TranslateTransform(-height2, 0); //-(area.Y + height2));

                    StringFormat.Alignment     = StringAlignment.Near;
                    StringFormat.LineAlignment = StringAlignment.Center;
                    graphics.Graphics.DrawString(Value, Font, graphics.BrushsCache.GetBrush(ForeColor), 0, 0, StringFormat);
                }
                finally
                {
                    graphics.Graphics.Restore(state);
                }
            }
예제 #7
0
        public static void DrawLine(Graphics g, float width, Vector2 a, Vector2 b, Color c)
        {
            System.Drawing.Drawing2D.GraphicsState s = g.Save();

            //g.DrawLine(Pens.DarkGreen, a, b);

            float angle = (float)(180.0f / Math.PI * Math.Atan2(b.Y - a.Y, b.X - a.X));
            Font  f     = new Font(FontFamily.GenericSansSerif, 80, FontStyle.Bold);

            g.TranslateTransform(a.X, a.Y);
            g.RotateTransform(angle);
            float length = LineMath.Length(a, b);

            Color transparent = Color.FromArgb(200, c.R, c.G, c.B);

            //Brush br = new System.Drawing.Drawing2D.HatchBrush (System.Drawing.Drawing2D.HatchStyle.Sphere, Color.FromArgb(128, 100, 50, 25), Color.FromArgb(0, 0, 0, 0));
            Brush br = new SolidBrush(transparent);

            g.FillRectangle(br, new RectangleF(0, -width / 2, length, width));

            //g.DrawArc(Pens.Black, new RectangleF(-width / 2, -width / 2, width, width), 90, 180);
            g.FillEllipse(Brushes.White, new RectangleF(-width / 2, -width / 2, width, width));
            g.DrawEllipse(Pens.Black, new RectangleF(-width / 2, -width / 2, width, width));
            //g.DrawLine(Pens.Orange, new PointF(0, width / 2.0f), new PointF(length, width / 2.0f));
            //g.DrawLine(Pens.Orange, new PointF(0, -width / 2.0f), new PointF(length, -width / 2.0f));
            //g.TranslateTransform(p2.X - p1.X, p2.Y - p1.Y);

            g.TranslateTransform(length, 0);
            //g.DrawArc(Pens.Black, new RectangleF(-width / 2, -width / 2, width, width), 270, 180);
            g.FillEllipse(Brushes.White, new RectangleF(-width / 2, -width / 2, width, width));
            g.DrawEllipse(Pens.Black, new RectangleF(-width / 2, -width / 2, width, width));

            g.Restore(s);
        }
예제 #8
0
        public void DrawString(System.Drawing.Graphics g, System.Drawing.PointF pt, String _label)
        {
            // Save the GraphicsState.
            System.Drawing.Drawing2D.GraphicsState gs = g.Save();

            // Set the PageUnit to Inch because all of our measurements are in inches.
            g.PageUnit = System.Drawing.GraphicsUnit.Inch;

            // Set the PageScale to 1, so an inch will represent a true inch.
            g.PageScale = 1;


            System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

            float xPosition = pt.X;
            float xStart    = pt.X;
            float yStart    = pt.Y;


            System.Drawing.Font font = new System.Drawing.Font("Arial", 10);



            float yPosition = yStart;

            // Draw Product Type.
            g.DrawString(_label, font, brush, new System.Drawing.PointF(xPosition, yPosition));

            // Restore the GraphicsState.
            g.Restore(gs);
        }
예제 #9
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);
            Bitmap   bmp     = new Bitmap(altimeter.Width, altimeter.Height);
            Graphics g       = Graphics.FromImage(bmp);
            float    altitud = _altitude - _calibration;

            g.Clear(BackColor);
            g.DrawImage(altimeter, 0, 0);

            g.TranslateTransform(128, 128);

            System.Drawing.Drawing2D.GraphicsState saved = g.Save();

            g.RotateTransform(altitud * 360 / 10000);
            g.DrawImage(needle1k, -needle1k.Width / 2, -needle1k.Height / 2 - 16);

            g.Restore(saved);

            g.RotateTransform(altitud * 360 / 1000);
            g.DrawImage(needle, -needle.Width / 2, -needle.Height / 2 - 26);

            g.Dispose();
            e.Graphics.DrawImage(bmp, 0, 0, this.Width, this.Height);
        }
예제 #10
0
 /// <summary>
 /// Called just after rendering the object.
 /// </summary>
 /// <param name="g">Specifies the Graphics used to render.</param>
 protected void postrender(Graphics g)
 {
     if (m_gstate != null)
     {
         g.Restore(m_gstate);
         m_gstate = null;
     }
 }
예제 #11
0
파일: Turtle.cs 프로젝트: isindicic/slogo
        public void DrawText(string txt)
        {
            System.Drawing.Drawing2D.GraphicsState canvasState = canvas.Save();
            canvas.TranslateTransform((float)currentX, (float)currentY);
            canvas.RotateTransform((float)(90 - direction));
            canvas.DrawString(txt, font, new SolidBrush(foreground), (float)0, (float)0);

            canvas.Restore(canvasState);
        }
예제 #12
0
 internal void drawOn(Graphics canvas)
 {
     System.Drawing.Drawing2D.GraphicsState transState = canvas.Save();
     foreach (Printable p in labelItems)
     {
         p.draw(canvas);
     }
     canvas.Restore(transState);
 }
예제 #13
0
        /// <inheritdoc/>
        protected override void ExportPageBegin(ReportPage page)
        {
            base.ExportPageBegin(page);
            zoomX  = ResolutionX / 96f;
            zoomY  = ResolutionY / 96f;
            width  = (int)(ExportUtils.GetPageWidth(page) * Units.Millimeters * zoomX);
            height = (int)(ExportUtils.GetPageHeight(page) * Units.Millimeters * zoomY);
            int suffixDigits = Pages[Pages.Length - 1].ToString().Length;

            fileSuffix = firstPage ? "" : (pageNumber + 1).ToString("".PadLeft(suffixDigits, '0'));
            if (SeparateFiles || IsMultiFrameTiff)
            {
                image = CreateImage(width, height, fileSuffix);
                if (IsMultiFrameTiff && masterTiffImage == null)
                {
                    masterTiffImage = image;
                }
            }
            else
            {
                image = bigImage;
            }

            if (bigGraphics != null)
            {
                g = bigGraphics;
            }
            else
            {
                g = Graphics.FromImage(image);
            }

            state = g.Save();
            g.FillRegion(Brushes.White, new Region(new RectangleF(0, curOriginY, width, height)));

            if (image == bigImage)
            {
                g.TranslateTransform(image.Width / 2 - width / 2 + page.LeftMargin * Units.Millimeters * zoomX,
                                     curOriginY + paddingNonSeparatePages + page.TopMargin * Units.Millimeters * zoomY);
            }
            else
            {
                g.TranslateTransform(page.LeftMargin * Units.Millimeters * zoomX, page.TopMargin * Units.Millimeters * zoomY);
            }

            g.ScaleTransform(1, zoomY / zoomX);

            // export bottom watermark
            if (page.Watermark.Enabled && !page.Watermark.ShowImageOnTop)
            {
                AddImageWatermark(page);
            }
            if (page.Watermark.Enabled && !page.Watermark.ShowTextOnTop)
            {
                AddTextWatermark(page);
            }
        }
예제 #14
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //    base.OnPaint(e);
            Bitmap   bmp   = new Bitmap(background.Width, background.Height);
            Graphics g     = Graphics.FromImage(bmp);
            float    roll  = _roll;
            float    pitch = _pitch;

            while (roll < 0)
            {
                roll += 360.0f;
            }
            while (roll > 360)
            {
                roll -= 360.0f;
            }

            /*
             * while (pitch < -180.0f)
             *  pitch += 360.0f;
             * while (pitch > 180.0f)
             *  pitch -= 360.0f;
             */

            if (pitch > 45.0f)
            {
                pitch = 45.0f;
            }
            else if (pitch < -45.0f)
            {
                pitch = -45.0f;
            }

            float oy = 45 * (float)Math.Sin(pitch * Math.PI / 180.0f);

            g.Clear(BackColor);

            System.Drawing.Drawing2D.GraphicsState saved = g.Save();

            g.TranslateTransform(bmp.Width / 2, bmp.Height / 2);
            g.RotateTransform(-roll);

            g.TranslateTransform(-bmp.Width / 2, -bmp.Height / 2);
            g.DrawImage(gyro_color, 0, 0);

            g.DrawImage(pitch_color, 0, oy);

            g.DrawImage(gyro_back, 0, 0);

            g.Restore(saved);
            g.DrawImage(extra, 64, 112);
            g.DrawImage(background, 0, 0);
            g.Dispose();
            //e.Graphics.DrawImageUnscaled(bmp, 0, 0);
            e.Graphics.DrawImage(bmp, 0, 0, this.Width, this.Height);
        }
예제 #15
0
        private void DrawHourlyFooter(TimeColumnInfo columnInfo, DevExpress.XtraGrid.Views.Grid.FooterCellCustomDrawEventArgs e)
        {
            int        value         = (m_dailyView != null) ? m_dailyView.GetTotals(columnInfo.FromTime, CurrentView) : 0;
            RectangleF oldClipBounds = e.Graphics.ClipBounds;
            Rectangle  newClipBounds = Rectangle.Round(oldClipBounds);

            newClipBounds.Height = e.Bounds.Height * 2 + 1;

            DevExpress.Utils.Paint.Clipping        clip   = null;
            System.Drawing.Drawing2D.GraphicsState GState = null;
            bool bClipping = false;

            try
            {
                if (newClipBounds.Height > oldClipBounds.Height)// if need change clip region
                {
                    GState          = e.Graphics.Save();
                    e.Graphics.Clip = new System.Drawing.Region(newClipBounds);
                    clip            = new DevExpress.Utils.Paint.Clipping();
                    clip.SetClipAPI(new GraphicsInfoArgs(e.Cache, newClipBounds), newClipBounds);
                    bClipping = true;
                }

                e.Info.Appearance.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
                e.Info.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;

                e.Info.DisplayText = DateTimeHelper.IntTimeToStr(value);
                e.Painter.DrawObject(e.Info);


                Rectangle oldBounds = e.Info.Bounds;
                string    oldText   = e.Info.DisplayText;
                e.Info.Bounds      = new Rectangle(e.Info.Bounds.Left, e.Info.Bounds.Bottom + 1, e.Info.Bounds.Width, e.Info.Bounds.Height);
                e.Info.DisplayText = FooterHoursAsString(value);


                e.Painter.DrawObject(e.Info);
                e.Info.Bounds      = oldBounds;
                e.Info.DisplayText = oldText;
            }
            finally
            {
                if (bClipping)
                {
                    clip.RestoreClipAPI(e.Graphics);
                    e.Graphics.Restore(GState);
                    e.Graphics.SetClip(oldClipBounds);
                    GState = null;
                    clip   = null;
                }
            }
            e.Handled = true;
        }
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (_readOnly)
            {
                return;
            }
            int   x       = e.X;
            int   y       = e.Y;
            int   nh      = 1;
            float yOffset = 0;
            float xOffset = this.AutoScrollPosition.X;
            SizeF size    = mathExp.ExpSize;

            if (size.Height > 0)
            {
                while (y > (nh * (size.Height + 8)))
                {
                    yOffset += (size.Height + 8);
                    xOffset -= this.ClientSize.Width;
                    nh++;
                }
                y -= (int)yOffset;
                x -= (int)xOffset;
            }
            HitTestResult hit = mathExp.HightLight(new PointF(x, y));

            if (hit != null)
            {
                Graphics g = this.CreateGraphics();
                System.Drawing.Drawing2D.GraphicsState gt0 = g.Save();
                if (_lastOffsetSaved)
                {
                    g.TranslateTransform(_lastOffsetX, _lastOffsetY);
                }
                if (hit.Replaced != null)
                {
                    g.DrawRectangle(Pens.White, hit.Replaced.Bounds);
                }
                g.Restore(gt0);
                g.TranslateTransform(xOffset, yOffset);
                _lastOffsetX     = xOffset;
                _lastOffsetY     = yOffset;
                _lastOffsetSaved = true;
                if (hit.Current != null)
                {
                    _highlighted = hit.Current;
                    g.DrawRectangle(pen, hit.Current.Bounds);
                }
                g.Restore(gt0);
            }
        }
예제 #17
0
파일: Turtle.cs 프로젝트: isindicic/slogo
        public void Draw()
        {
            if (showTurtle)
            {
                System.Drawing.Drawing2D.GraphicsState canvasState = canvas.Save();
                canvas.TranslateTransform((float)currentX, (float)currentY);
                canvas.RotateTransform((float)(90 - direction));

                canvas.DrawLine(drawingPen, -4, 4, 0, -8);
                canvas.DrawLine(drawingPen, 0, -8, 4, 4);
                canvas.DrawLine(drawingPen, -4, 4, 4, 4);

                canvas.Restore(canvasState);
            }
        }
        protected override void OnPaintActionView(System.Windows.Forms.PaintEventArgs e)
        {
            base.OnPaintActionView(e);
            int   d  = 5;
            float d2 = 2.5F;

            if (this.ClientSize.Width > 10 && this.ClientSize.Height > 10)
            {
                System.Drawing.Drawing2D.GraphicsState gt = e.Graphics.Save();
                e.Graphics.TranslateTransform((float)d2, (float)d2);
                Size size = new Size(this.ClientSize.Width - d, this.ClientSize.Height - d);
                VPLDrawing.VplDrawing.DrawRoundRectangle(e.Graphics, size, 100, 4, Pens.Blue, Pens.LightGray);
                e.Graphics.Restore(gt);
            }
            float y = d2;
            //draw condition text
            AB_LoopActions loop = ActionObject as AB_LoopActions;

            if (loop.Condition != null)
            {
                System.Drawing.Drawing2D.GraphicsState st = e.Graphics.Save();
                SizeF sizeC = loop.Condition.CalculateDrawSize(e.Graphics);
                float x     = (this.Width - sizeC.Width - d) / 2;
                if (x < d2)
                {
                    x = d2;
                }
                y = d2 + sizeC.Height;
                e.Graphics.TranslateTransform(x, d2);
                loop.Condition.Draw(e.Graphics);
                e.Graphics.Restore(st);
            }
            //draw action description
            if (y < this.Height - d)
            {
                string s = ActionName;
                if (string.IsNullOrEmpty(s))
                {
                    s = "Repeated actions";
                }
                System.Drawing.Drawing2D.GraphicsState st = e.Graphics.Save();
                e.Graphics.TranslateTransform(d2, y);
                e.Graphics.DrawString(s, TextFont, TextBrush, (float)0, (float)0);
                e.Graphics.Restore(st);
            }
        }
예제 #19
0
        protected override void OnPaint(PaintEventArgs e)
        {
            // Paint the background
            System.Drawing.Brush brush =
                new System.Drawing.SolidBrush(BackColor);
            e.Graphics.FillRectangle(brush, this.ClientRectangle);
            brush.Dispose();

            // Setup graphics
            System.Drawing.Drawing2D.GraphicsState state = e.Graphics.Save();
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            Rectangle rect = GetSquareRect();

            System.Drawing.Pen pen =
                new System.Drawing.Pen(ForeColor, 2);
            System.Drawing.Brush brush2 =
                new System.Drawing.SolidBrush(ForeColor);

            // Draw the circle
            e.Graphics.DrawEllipse(pen, rect);

            // Draw angle arrow
            PointF begin = PointF.Empty;
            PointF end   = PointF.Empty;

            MindFusion.Geometry.Geometry2D.Convert.PolarToDekart(
                new PointF(
                    rect.X + (float)rect.Width / 2,
                    rect.Y + (float)rect.Height / 2),
                _angle, rect.Width / 3, ref begin);
            MindFusion.Geometry.Geometry2D.Convert.PolarToDekart(
                new PointF(
                    rect.X + (float)rect.Width / 2,
                    rect.Y + (float)rect.Height / 2),
                _angle + 180, rect.Width / 3, ref end);
            e.Graphics.DrawLine(pen, begin, end);
            e.Graphics.FillEllipse(brush2, begin.X - 3, begin.Y - 3, 6, 6);

            brush2.Dispose();
            pen.Dispose();

            // Reset graphics
            e.Graphics.Restore(state);
        }
예제 #20
0
        /// <summary>
        /// Renders the view.
        /// </summary>
        /// <param name="g">Specifies the Graphics used to draw.</param>
        public void Render(Graphics g)
        {
            System.Drawing.Drawing2D.GraphicsState gstate = g.Save();

            g.TranslateTransform(0, -g.VisibleClipBounds.Height);
            g.ScaleTransform(1, -1, System.Drawing.Drawing2D.MatrixOrder.Append);

            g.DrawRectangle(Pens.SteelBlue, 1, 1, 2, 2);
            g.DrawLine(Pens.SteelBlue, 1, 3, 1, 4);
            g.DrawLine(Pens.SteelBlue, 3, 3, 4, 4);
            g.DrawLine(Pens.SteelBlue, 3, 1, 4, 1);

            foreach (GeomObj obj in m_rgObj)
            {
                obj.Render(g);
            }

            g.Restore(gstate);
        }
예제 #21
0
        /// <summary>
        /// 重新绘制本区域内的内容
        /// </summary>
        /// <param name="rect">相对当前屏幕的坐标矩形</param>
        public void paintArea(GDI.Rectangle rect)
        {
            if (rect.Height == 0 || rect.Width == 0)
            {
                return;
            }

            GDI.Drawing2D.GraphicsState state = g.Save();
            g.SetClip(rect);
            // 开始画图吧

            double iOffsetX = rect.X;
            int    iColumn  = GetCellColumn(ref iOffsetX);

            if (iColumn == -1)
            {
                g.Restore(state);
                return;
            }

            GB_GridView.CellPaintEventArgs e = new GB_GridView.CellPaintEventArgs();
            g.FillRectangle(m_background, rect);
            double iColumnWidth = rect.X - iOffsetX;

            for (int j = iColumn; j < Columns.Count; ++j)
            {
                if (iColumnWidth > ActualWidth)
                {
                    break; // 说明这一行画完了,开始画下一行吧
                }
                e.Bounds      = new GDI.Rectangle((int)iColumnWidth, 0, (int)Columns[j].Width, m_bufferedBmp.PixelHeight);
                iColumnWidth += Columns[j].Width;
                e.ColumnIndex = j;
                e.RowIndex    = -1;
                e.States      = GB_GridView.GridViewElementStates.Visible;
                e.Graphics    = g;
                e.Value       = Columns[j].Header.ToString();
                DefaultPaintCell(e);
            }


            g.Restore(state);
        }
        protected override void OnPaintActionView(System.Windows.Forms.PaintEventArgs e)
        {
            base.OnPaintActionView(e);
            int   d  = 5;
            float d2 = 2.5F;

            if (this.ClientSize.Width > 10 && this.ClientSize.Height > 10)
            {
                System.Drawing.Drawing2D.GraphicsState gt = e.Graphics.Save();
                e.Graphics.TranslateTransform((float)d2, (float)d2);
                Size size = new Size(this.ClientSize.Width - d, this.ClientSize.Height - d);
                VPLDrawing.VplDrawing.DrawRoundRectangle(e.Graphics, size, 100, 4, Pens.Blue, Pens.LightGray);
                e.Graphics.Restore(gt);
            }
            //draw icon
            Image img = Resources._method.ToBitmap();
            float x   = d + 2;
            float y   = (float)(d2 + (float)(this.ClientSize.Height - d2 - img.Height) / 2.0);

            if (y < d2)
            {
                y = d2;
            }
            e.Graphics.DrawImage(img, x, y);
            //draw action description
            x += img.Width + 2;
            if (x < this.ClientSize.Width - d)
            {
                string s = ActionName;
                if (string.IsNullOrEmpty(s))
                {
                    s = "Action group";
                }
                SizeF sf = e.Graphics.MeasureString(s, TextFont);
                y = (float)(d2 + (float)(this.ClientSize.Height - d2 - sf.Height) / 2.0);
                if (y < d2)
                {
                    y = d2;
                }
                e.Graphics.DrawString(s, TextFont, TextBrush, x, y);
            }
        }
예제 #23
0
        public override void OnDraw(System.Drawing.Graphics g)
        {
            SizeF  size1 = this[0].CalculateDrawSize(g);
            string s     = new string((char)0xD6, 1);
            Font   ft    = new Font("Symbol", size1.Height, FontStyle.Regular, GraphicsUnit.Pixel);
            SizeF  size  = g.MeasureString(s, ft);
            //
            float w = size1.Width + size.Width;
            float h = size1.Height;
            //
            float a1        = (float)0.5177618;
            float b1        = (float)0.1262125;
            float a2        = (float)0.0719113648;
            float b2        = (float)0.378640622;
            int   nLineTop  = (int)(a2 * size.Height + b2);
            int   nLineLeft = (int)(a1 * size.Height + b1);

            if (IsFocused)
            {
                g.FillRectangle(TextBrushBKFocus0, (float)0, (float)0, w, h);
                g.FillRectangle(TextBrushBKFocus, (float)0, (float)0, w, h);
                g.DrawString(s, ft, TextBrushFocus, 0, 0);
            }
            else
            {
                g.DrawString(s, ft, TextBrush, 0, 0);
            }
            if (IsFocused)
            {
                g.DrawLine(new Pen(TextBrushFocus), nLineLeft, nLineTop, nLineLeft + size1.Width, nLineTop);
            }
            else
            {
                g.DrawLine(new Pen(TextBrush), nLineLeft, nLineTop, nLineLeft + size1.Width, nLineTop);
            }
            //
            System.Drawing.Drawing2D.GraphicsState gt = g.Save();
            g.TranslateTransform(nLineLeft + 1, nLineTop + 1);
            this[0].Position = new Point(this.Position.X + nLineLeft + 1, Position.Y + nLineTop + 1);
            this[0].Draw(g);
            g.Restore(gt);
        }
예제 #24
0
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            int      picBoxWidth = pictureBox1.Size.Width;
            int      picBoxHeight = pictureBox1.Size.Height;
            int      halfWidth = pictureBox1.Size.Width / 2;
            int      halfHeight = pictureBox1.Size.Height / 2;
            Graphics objGraphic = e.Graphics; //**請注意這一行**
            Pen      pen = new Pen(Color.Black);
            int      b = 2; int m = 2; for (int x = 0; x < 426; x++)

            {
                int y = m * x + b; x = (y - b) / m;
                objGraphic.DrawLine(pen, x, y, -x, -y);
                System.Drawing.Drawing2D.GraphicsState graph = objGraphic.Save();
                objGraphic.Restore(graph);
            }
            objGraphic.DrawLine(pen, 0, halfHeight, picBoxWidth, halfHeight);
            objGraphic.DrawLine(pen, halfWidth, 0, halfWidth, picBoxHeight);
            objGraphic.DrawLine(pen, 20, 20, 300, 300);
        }
예제 #25
0
        /// <inheritdoc/>
        protected override void Start()
        {
            base.Start();

            //init
            pageNumber = 0;
            height     = 0;
            width      = 0;
            image      = null;
            g          = null;
            zoomX      = 1;
            zoomY      = 1;
            state      = null;

            curOriginY = 0;
            firstPage  = true;

            if (!SeparateFiles && !IsMultiFrameTiff)
            {
                // create one big image. To do this, calculate max width and sum of pages height
                float w = 0;
                float h = 0;

                foreach (int pageNo in Pages)
                {
                    SizeF size = Report.PreparedPages.GetPageSize(pageNo);
                    if (size.Width > w)
                    {
                        w = size.Width;
                    }
                    h += size.Height + paddingNonSeparatePages * 2;
                }

                w += paddingNonSeparatePages * 2;

                bigImage    = CreateImage((int)(w * ResolutionX / 96f), (int)(h * ResolutionY / 96f), "");
                bigGraphics = Graphics.FromImage(bigImage);
                bigGraphics.Clear(Color.White);
            }
            pageNumber = 0;
        }
예제 #26
0
        public void paint_me_vertical(ref Graphics gr0, ref PointF location, int x_offset = 0, int y_offset = 0, bool is_bold_true = false)
        {
            if (my_visible == true)
            {
                SizeF str_size = new SizeF();
                str_size = gr0.MeasureString(my_string, my_font);
                // Paint the x-axis in vertical alignment
                System.Drawing.Drawing2D.GraphicsState temp_gstate = gr0.Save();
                gr0.TranslateTransform((location.X + x_offset - co_functions.tosingle(str_size.Height * 0.5)), (location.Y + y_offset + co_functions.tosingle(str_size.Width * 0.5)));
                gr0.RotateTransform(270);
                gr0.TranslateTransform(-(location.X + x_offset - co_functions.tosingle(str_size.Height * 0.5)), -(location.Y + y_offset + co_functions.tosingle(str_size.Width * 0.5)));

                if (is_bold_true == true)
                {
                    my_font = new Font(my_font.FontFamily, my_font.Size, FontStyle.Bold);
                }

                gr0.DrawString(my_string, my_font, paint_brush, (location.X + x_offset - co_functions.tosingle(str_size.Height * 0.5)), (location.Y + y_offset + co_functions.tosingle(str_size.Width * 0.5)));
                gr0.Restore(temp_gstate);
            }
        }
예제 #27
0
 public void PaintPrimitive(IGraphics graphics, float angle, SizeF scale, TextParams textParams)
 {
     if (textParams.useCompatibleTextRendering)
     {
         graphics.DrawString(textParams, this.measuredSize);
     }
     else
     {
         TextFormatFlags flags                        = this.CreateTextFormatFlags(textParams);
         Graphics        underlayGraphics             = (Graphics)graphics.UnderlayGraphics;
         System.Drawing.Drawing2D.GraphicsState state = underlayGraphics.Save();
         underlayGraphics.ResetTransform();
         TextRenderer.DrawText(underlayGraphics,
                               textParams.text,
                               textParams.font,
                               Rectangle.Ceiling(textParams.paintingRectangle),
                               textParams.foreColor,
                               flags);
         underlayGraphics.Restore(state);
     }
 }
예제 #28
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            pe.Graphics.FillRectangle(mBackgroundColorBrush, ClientRectangle);
            if (mIsAnimated)
            {
                int loop1 = this.mAnimateState - mWorkBarDoubleWidth;
                while (loop1 < this.ClientRectangle.Width)
                {
                    pe.Graphics.FillRectangle(mAlternateBackgroundColorBrush, this.ClientRectangle.X + loop1, this.ClientRectangle.Y, mWorkBarWidth, this.ClientRectangle.Height);
                    loop1 += mWorkBarDoubleWidth;
                }
            }
            pe.Graphics.FillRectangle(mMaximumColorBrush, this.ClientRectangle.X, this.ClientRectangle.Y, this.mMaximumRatio, this.ClientRectangle.Height);
            pe.Graphics.FillRectangle(mCurrentColorBrush, this.ClientRectangle.X, this.ClientRectangle.Y, this.mCurrentRatio, this.ClientRectangle.Height);

            string label;

            if (this.mShowCurrent)
            {
                label = string.Format("{0} em {1} (máx. {2})", this.mCurrent, this.Maximum, this.mCeiling);
            }
            else
            {
                label = string.Format("{0} em {1}", this.Maximum, this.mCeiling);
            }

            Size labelSize = pe.Graphics.MeasureString(label, this.Font).ToSize();

            int x = (this.ClientRectangle.Width - labelSize.Width) / 2;

            int y = (this.ClientRectangle.Height - labelSize.Height) / 2;

            pe.Graphics.DrawString(label, this.Font, new SolidBrush(this.ForeColor), x, y);

            System.Drawing.Drawing2D.GraphicsState gs = pe.Graphics.Save();
            pe.Graphics.SetClip(new RectangleF(this.ClientRectangle.X, this.ClientRectangle.Y, this.mCurrentRatio, this.ClientRectangle.Height));
            pe.Graphics.DrawString(label, this.Font, this.mBackgroundColorBrush, x, y);
            pe.Graphics.Restore(gs);
        }
예제 #29
0
        /// <summary>
        /// Draws the control
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            int diameter = Math.Min(this.Width - 4, this.Height - 4);

            Pen potPen = new Pen(ForeColor, 3.0f);

            potPen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
            System.Drawing.Drawing2D.GraphicsState state = e.Graphics.Save();
            //e.Graphics.TranslateTransform(diameter / 2f, diameter / 2f);
            e.Graphics.TranslateTransform(this.Width / 2, this.Height / 2);
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            e.Graphics.DrawArc(potPen, new Rectangle(diameter / -2, diameter / -2, diameter, diameter), 135, 270);

            double percent = (value - minimum) / (maximum - minimum);
            double degrees = 135 + (percent * 270);
            double x       = (diameter / 2.0) * Math.Cos(Math.PI * degrees / 180);
            double y       = (diameter / 2.0) * Math.Sin(Math.PI * degrees / 180);

            e.Graphics.DrawLine(potPen, 0, 0, (float)x, (float)y);
            e.Graphics.Restore(state);
            base.OnPaint(e);
        }
예제 #30
0
        public override void DrawItem(Graphics g, bool selected, Project project)
        {
            Font   f        = this.GetFont();
            string text     = this.GetText(project);
            SizeF  sizeF    = g.MeasureString(text, f);
            Point  position = this.GetDrawingPosition(new Size((int)sizeF.Width, (int)sizeF.Height));

            Rectangle rect = GetDrawingRectangle(SizeFToSize(sizeF));

            if (selected)
            {
                g.FillRectangle(TicketItem.SelectedBrush, rect);
            }

            System.Drawing.Drawing2D.GraphicsState s = g.Save();
            g.ResetTransform();
            g.RotateTransform((int)this.Rotation, System.Drawing.Drawing2D.MatrixOrder.Append);
            g.TranslateTransform(rect.X, rect.Y, System.Drawing.Drawing2D.MatrixOrder.Append);
            //g.ScaleTransform(this.HorizontalScaling, 1f, System.Drawing.Drawing2D.MatrixOrder.Append);
            g.DrawString(text, f, Brushes.Black, RotatedTextPosition(rect));
            g.Restore(s);
        }
예제 #31
0
        private void Form1_DragDrop(object sender, DragEventArgs e)
        {
            string[] filename = new string[] { };
            string[] f = e.Data.GetFormats();
            Image s = null;
            try
            {
                if (e.Data.GetDataPresent(System.Windows.Forms.DataFormats.FileDrop))
                {
                    filename = (string[])e.Data.GetData(DataFormats.FileDrop);
                    this.Text = Path.GetFileName(filename[0]);
                    s = Image.FromFile(filename[0]);
                }

            }
            catch (Exception x) { MessageBox.Show(x.Message); }

            if(s!=null)
            {
                try
                {
                    pictureBox1.Image = s;
                    p.Image = pictureBox1.Image;
                }
                catch (Exception x) { }
            }
        }