BeginContainer() public method

public BeginContainer ( ) : GraphicsContainer
return GraphicsContainer
Beispiel #1
1
		public void Draw(Graphics g)
		{
			g.FillRectangle(SystemBrushes.AppWorkspace, Bounds);

			g.DrawRectangle(Pens.Black, mCanvasMarginWidth - 1, mCanvasMarginHeight - 1, 800 + 1, 600 + 1);

			g.TranslateTransform(mCanvasMarginWidth, mCanvasMarginHeight);
			GraphicsContainer containerState = g.BeginContainer();
			g.SmoothingMode = SmoothingMode.HighQuality;

			DrawCanvas(g);

			g.SmoothingMode = SmoothingMode.Default;
			g.EndContainer(containerState);
			g.TranslateTransform(-mCanvasMarginWidth, -mCanvasMarginHeight);


			//mCanvasBufferGraphics.FillRectangle(SystemBrushes.AppWorkspace, Bounds);

			//mCanvasBufferGraphics.DrawRectangle(Pens.Black, mCanvasMarginWidth - 1, mCanvasMarginHeight - 1, 800 + 1, 600 + 1);

			//DrawCanvas(mCanvasBufferGraphics);


			//Rectangle src = Bounds;
			//Rectangle dest = new Rectangle(0, 0, (int)(Bounds.Width * mScale), (int)(Bounds.Height * mScale));
			//dest.X = (Bounds.Width / 2) - (dest.Width / 2);
			//dest.Y = (Bounds.Height / 2) - (dest.Height / 2);

			//g.DrawImage(mCanvasBufferImage, dest, src, GraphicsUnit.Pixel);
		}
Beispiel #2
0
        public override void Paint(System.Drawing.Graphics g)
        {
            //base.Paint(g);
            GraphicsPath gp = new GraphicsPath();
            RectangleF   rf = Rectangle;

            rf.Inflate(-2, -2);
            gp.AddEllipse(rf);
            g.DrawPath(new Pen(ShapeColor), gp);
            //g.FillPath(new SolidBrush(ShapeColor), gp);

            //显示线路名
            if (ShowLabel)
            {
                Matrix m   = new Matrix();
                int    mod = (int)Angle % 360;
                PointF pf5 = new PointF(Rectangle.Right + 3, Rectangle.Top + Rectangle.Height / 2);
                if (mod == 0 || mod == 180)
                {
                    pf5 = new PointF(Rectangle.Right + 12, Rectangle.Bottom);
                    m.RotateAt(90, pf5);
                }
                GraphicsContainer gc = g.BeginContainer();
                g.Transform = m;
                g.DrawString(this.Text, this.Font, this.TextBrush, pf5);
                g.EndContainer(gc);
            }
        }
Beispiel #3
0
            protected override void Paint(sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, swf.DataGridViewPaintParts paintParts)
            {
                Handler.Paint(graphics, clipBounds, ref cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, ref paintParts);

                var val = value as object[];
                var img = val[0] as sd.Image;

                if (img != null)
                {
                    if (paintParts.HasFlag(swf.DataGridViewPaintParts.Background))
                    {
                        using (var b = new sd.SolidBrush(cellState.HasFlag(swf.DataGridViewElementStates.Selected) ? cellStyle.SelectionBackColor : cellStyle.BackColor))
                        {
                            graphics.FillRectangle(b, new sd.Rectangle(cellBounds.X, cellBounds.Y, IconSize + IconPadding * 2, cellBounds.Height));
                        }
                    }

                    var container = graphics.BeginContainer();
                    graphics.SetClip(cellBounds);
                    if (paintParts.HasFlag(swf.DataGridViewPaintParts.Background))
                    {
                        using (var background = new sd.SolidBrush(cellState.HasFlag(swf.DataGridViewElementStates.Selected) ? cellStyle.SelectionBackColor : cellStyle.BackColor))
                            graphics.FillRectangle(background, cellBounds);
                    }
                    graphics.InterpolationMode = InterpolationMode;
                    graphics.DrawImage(img, new sd.Rectangle(cellBounds.X + IconPadding, cellBounds.Y + (cellBounds.Height - Math.Min(img.Height, cellBounds.Height)) / 2, IconSize, IconSize));
                    graphics.EndContainer(container);
                    cellBounds.X     += IconSize + IconPadding * 2;
                    cellBounds.Width -= IconSize + IconPadding * 2;
                }
                base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
            }
Beispiel #4
0
        /// <summary>
        /// Paints the entity using the given graphics object
        /// </summary>
        /// <param name="g"></param>
        public override void Paint(System.Drawing.Graphics g)
        {
            if (!Visible)
            {
                return;
            }

            //g.DrawRectangle(Pens.OrangeRed, Rectangle);
            GraphicsContainer cto = g.BeginContainer();

            g.SetClip(Shape.Rectangle);
            plusminus.Paint(g);
            header.Paint(g);
            if (!mCollapsed && mShowLines)
            {
                g.DrawLine(ArtPallet.FolderLinesPen, Rectangle.X + 7, plusminus.Rectangle.Bottom, Rectangle.X + 7, plusminus.Rectangle.Bottom + mEntries.Count * (constItemHeight + constItemSpacing));
            }
            int k = 1;

            foreach (IShapeMaterial material in mEntries)
            {
                material.Paint(g);
                if (!mCollapsed && mShowLines)
                {
                    g.DrawLine(ArtPallet.FolderLinesPen, Rectangle.X + 7, plusminus.Rectangle.Bottom + k * (constItemHeight + constItemSpacing), Rectangle.X + 16, plusminus.Rectangle.Bottom + k * (constItemHeight + constItemSpacing));
                    k++;
                }
            }
            g.EndContainer(cto);
        }
Beispiel #5
0
        public override void Paint(System.Drawing.Graphics g)
        {
            //base.Paint(g);
            GraphicsPath gp  = new GraphicsPath();
            PointF       pf1 = new PointF(Rectangle.Left + Width / 2, Rectangle.Top);
            PointF       pf2 = new PointF(Rectangle.Left, Rectangle.Bottom);
            PointF       pf3 = new PointF(Rectangle.Right, Rectangle.Bottom);

            PointF[] pfs = new PointF[] { pf1, pf2, pf3 };
            GetTransForm().TransformPoints(pfs);
            gp.AddLines(pfs);
            g.FillPath(new SolidBrush(ShapeColor), gp);

            //显示线路名
            if (ShowLabel)
            {
                Matrix m   = new Matrix();
                int    mod = (int)Angle % 360;
                PointF pf5 = new PointF(Rectangle.Right + 3, Rectangle.Top + Rectangle.Height / 2);
                if (mod == 0 || mod == 180)
                {
                    pf5 = new PointF(Rectangle.Right + 12, Rectangle.Bottom);
                    m.RotateAt(90, pf5);
                }
                GraphicsContainer gc = g.BeginContainer();
                g.Transform = m;
                g.DrawString(this.Text, this.Font, this.TextBrush, pf5);
                g.EndContainer(gc);
            }
        }
Beispiel #6
0
        public override void Draw(Graphics g, int time)
        {
            //            this.GPath.Reset();
            GraphicsContainer container1 = g.BeginContainer();
            g.SmoothingMode = base.OwnerDocument.SmoothingMode;
            Matrix matrix1 = base.Transform.Matrix.Clone();

            if (!base.Visible)
            {
                g.SetClip(Rectangle.Empty);
            }

            markerTransForm.Multiply(matrix1, MatrixOrder.Prepend);

            base.GraphTransform.Matrix.Multiply(markerTransForm, MatrixOrder.Prepend);

            SvgElementCollection.ISvgElementEnumerator enumerator1 = base.GraphList.GetEnumerator();
            while (enumerator1.MoveNext())
            {
                IGraph graph1 = (IGraph) enumerator1.Current;
                graph1.GraphTransform.Matrix = base.GraphTransform.Matrix.Clone();
                graph1.IsMarkerChild = IsMarkerChild;
                graph1.Draw(g, time);
            }
            this.pretime = time;
            g.EndContainer(container1);
        }
Beispiel #7
0
        static void RenderTo(this DrawingGroup drawing, d.Graphics graphics, double opacity)
        {
            var gc = graphics.BeginContainer();

            Utility.SetGraphicsQuality(graphics);
            if (drawing.Transform != null && !drawing.Transform.Value.IsIdentity)
            {
                graphics.MultiplyTransform(drawing.Transform.Value.ToGdiPlus(), d2.MatrixOrder.Prepend);
            }
            if (drawing.ClipGeometry != null)
            {
                graphics.Clip = new d.Region(drawing.ClipGeometry.ToGdiPlus());
            }
            if (!Utility.IsZero(drawing.Opacity - 1) && drawing.Children.Count > 1)
            {
                var intersects = false;
                var c          = drawing.Children.Count;
                var b          = new Rect[c];
                for (var i = 0; i < c; ++i)
                {
                    b[i] = drawing.Children[i].Bounds;
                }
                for (var i = 0; i < c; ++i)
                {
                    for (var j = 0; j < c; ++j)
                    {
                        if (i != j && Rect.Intersect(b[i], b[j]) != Rect.Empty)
                        {
                            intersects = true;
                            break;
                        }
                    }
                    if (intersects)
                    {
                        break;
                    }
                }
                if (intersects)
                {
                    Utility.Warning("DrawingGroup.Opacity creates translucency between overlapping children");
                }
            }
            foreach (Drawing d in drawing.Children)
            {
                d.RenderTo(graphics, opacity * drawing.Opacity);
            }
            graphics.EndContainer(gc);
            if (drawing.OpacityMask != null)
            {
                Utility.Warning("DrawingGroup OpacityMask ignored.");
            }
            if (drawing.BitmapEffect != null)
            {
                Utility.Warning("DrawingGroup BitmapEffect ignored.");
            }
            if (drawing.GuidelineSet != null)
            {
                Utility.Warning("DrawingGroup GuidelineSet ignored.");
            }
        }
        public override void Draw(Graphics g)
        {
            base.Draw(g);

            System.Drawing.Drawing2D.GraphicsContainer gc1 = g.BeginContainer(); {

                g.TranslateTransform((int)this.X,(int)this.Y);

                // Color
                int alpha = (int)( (1.0 - (double)this.Age/(double)_maxAge) * 255 );
                if(alpha > 255) alpha = 255;
                Color c = Color.FromArgb(alpha,Color.White);

                // Focus Circle
                g.DrawEllipse(new Pen(c),
                              (int)(-this.Radius),
                              (int)(-this.Radius),
                              (int)(this.Radius*2),
                              (int)(this.Radius*2) );

                // Draw message
                g.DrawString(this.Contents.ToString(), Config.DisplayTextFont, new SolidBrush(c), new PointF(-Config.DisplayTextFont.Size/2,this.Radius-Config.DisplayTextFont.Size*2));

            } g.EndContainer(gc1);
        }
        public override void DrawRegionRepresentation(Graphics gc, Render.RenderParameter r, Render.IDrawVisitor drawMethods, PointD mousePosition)
        {
            if (m_Param.Path.PointCount > 0)
            {
                GraphicsPath fill = new GraphicsPath();
                RectangleF rect = m_Param.Path.GetBounds();
                PointD refPt = (PointD)rect.Location + ((PointD)rect.Size.ToPointF()) / 2;
                // this will draw beyond the shape's location
                for (double i = -rect.Height; i < rect.Height; i++)
                {
                    PointD pt1 = refPt + PointD.Orthogonal(m_Param.V) * i * drawMethods.Spacing(m_Param.C);
                    PointD pt2 = pt1 + m_Param.V * rect.Width * rect.Height;
                    PointD pt3 = pt1 - m_Param.V * rect.Width * rect.Height;

                    fill.StartFigure();
                    fill.AddLine((Point)pt2, (Point)pt3);

                }

                GraphicsContainer c = gc.BeginContainer();
                gc.SetClip((Tools.Model.VectorPath)m_Param.Path);
                gc.DrawPath(r.RegionGuides, fill);
                gc.EndContainer(c);

            }
        }
 public override void Draw(Graphics graphics)
 {
     GraphicsContainer container = graphics.BeginContainer();
     Rectangle bounds = base.Bounds;
     using (Region region = new Region(new Rectangle(bounds.X, bounds.Y, bounds.Width + 1, bounds.Height + 1)))
     {
         graphics.Clip = region;
         StringFormat format = new StringFormat {
             Alignment = StringAlignment.Center,
             LineAlignment = StringAlignment.Center,
             Trimming = StringTrimming.Character,
             FormatFlags = StringFormatFlags.NoWrap
         };
         int maxVisibleItems = base.MaxVisibleItems;
         int scrollPosition = base.ScrollPosition;
         for (int i = scrollPosition; (i < base.Items.Count) && (i < (scrollPosition + maxVisibleItems)); i++)
         {
             System.Workflow.ComponentModel.Design.ItemInfo itemInfo = base.Items[i];
             Rectangle itemBounds = base.GetItemBounds(itemInfo);
             int pageFoldSize = itemBounds.Width / 5;
             GraphicsPath[] pathArray = ActivityDesignerPaint.GetPagePaths(itemBounds, pageFoldSize, DesignerContentAlignment.TopRight);
             using (GraphicsPath path = pathArray[0])
             {
                 using (GraphicsPath path2 = pathArray[1])
                 {
                     Brush white = Brushes.White;
                     if (base.SelectedItem == itemInfo)
                     {
                         white = PageStrip.SelectionBrush;
                     }
                     else if (base.HighlitedItem == itemInfo)
                     {
                         white = PageStrip.HighliteBrush;
                     }
                     graphics.FillPath(white, path);
                     graphics.DrawPath(Pens.DarkBlue, path);
                     graphics.FillPath(Brushes.White, path2);
                     graphics.DrawPath(Pens.DarkBlue, path2);
                     if (itemInfo.Image == null)
                     {
                         itemBounds.Y += pageFoldSize;
                         itemBounds.Height -= pageFoldSize;
                         graphics.DrawString((i + 1).ToString(CultureInfo.CurrentCulture), Control.DefaultFont, SystemBrushes.ControlText, itemBounds, format);
                     }
                     else
                     {
                         itemBounds.Y += pageFoldSize;
                         itemBounds.Height -= pageFoldSize;
                         itemBounds.X += (itemBounds.Width - itemBounds.Height) / 2;
                         itemBounds.Width = itemBounds.Height;
                         itemBounds.Inflate(-2, -2);
                         ActivityDesignerPaint.DrawImage(graphics, itemInfo.Image, itemBounds, DesignerContentAlignment.Center);
                     }
                 }
             }
         }
     }
     graphics.EndContainer(container);
 }
        public IDisposable ApplyOffset(float dx, float dy)
        {
            var graphicsContainer = m_Graphics.BeginContainer();

            m_Graphics.TranslateTransform(dx, dy);

            return(new DoOnDispose(() => m_Graphics.EndContainer(graphicsContainer)));
        }
Beispiel #12
0
        //рисует клетку поля field[i,j]
        private void cell(int i, int j)
        {
            int x = i * (cw + 2), y = j * (ch + 2);

            if (field[i, j] == 0)
            {
                //для этой клетки найдена пара, её нужно убрать с поля
                GraphicsContainer gr = g.BeginContainer();
                float             xs = (float)xscale / cw;
                float             ys = (float)yscale / ch;
                g.ScaleTransform(xs, ys);
                g.FillRectangle(SystemBrushes.Control, x + Convert.ToInt32(r / xs * i), y + Convert.ToInt32(r / ys * j) + Convert.ToInt32(menuStrip1.Height / ys), cw + 2 + r, ch + 2 + r);
                g.EndContainer(gr);
            }
            else if ((field[i, j] == 1))
            {
                //клетка открыта -вывести картинку
                GraphicsContainer gr = g.BeginContainer();
                float             xs = (float)xscale / cw;
                float             ys = (float)yscale / ch;
                g.ScaleTransform(xs, ys);
                g.DrawImage(pics, new Rectangle(x + Convert.ToInt32(2 / ys + r / xs * i), y + Convert.ToInt32(2 / ys + r / ys * j) + Convert.ToInt32(menuStrip1.Height / ys), cw, ch), new Rectangle(picture[i, j] * cw, 0, cw, ch), GraphicsUnit.Pixel);
                g.DrawRectangle(Pens.Black, x + Convert.ToInt32(2 / ys + r / xs * i), y + Convert.ToInt32(2 / ys + r / ys * j) + menuStrip1.Height / ys, cw, ch);
                g.EndContainer(gr);
            }
            else if ((field[i, j] == 2))
            {
                //клетка закрыта
                GraphicsContainer gr = g.BeginContainer();
                float             xs = (float)xscale / cw;
                float             ys = (float)yscale / ch;
                g.ScaleTransform(xs, ys);
                Brush b = new SolidBrush(back);
                g.DrawRectangle(Pens.Black, x + Convert.ToInt32(2 / ys + r / xs * i), y + Convert.ToInt32(2 / ys + r / ys * j) + Convert.ToInt32(menuStrip1.Height / ys), cw, ch);
                g.FillRectangle(b, x + Convert.ToInt32(2 / ys + r / xs * i), y + Convert.ToInt32(2 / ys + 2 + r / ys * j) + Convert.ToInt32(menuStrip1.Height / ys), cw, ch);
                g.EndContainer(gr);
            }
            else
            {
                MessageBox.Show(field[i, j] + "? Што?");
            }
        }
Beispiel #13
0
        public void DrawTile(Graphics graph)
        {
            var pointsByColors = this.GetAllBordersPoints();

            var containerState = graph.BeginContainer();
            graph.RotateTransform(90 * (int)this.Rotation);

            this.DrawPoints(graph, pointsByColors);
            this.DrawText(graph);

            graph.EndContainer(containerState);
        }
        /// <summary>
        /// Paints the entity using the given graphics object
        /// </summary>
        /// <param name="g"></param>
        public override void Paint(Graphics g)
        {
            if(!Visible)
                return;

            if(mIcon != null)
            {
                GraphicsContainer cto = g.BeginContainer();
                g.SetClip(Shape.Rectangle);
                g.DrawImage(mIcon, Rectangle);
                g.EndContainer(cto);
            }
        }
        protected override void OnPaint(System.Drawing.Graphics g)
        {
            //Set Location and Size of ChControl and Paint it
            GraphicsContainer gc = g.BeginContainer();

            foreach (ChControl cc in this.Children)
            {
                cc.Location = new Point(0, 0);
                cc.Size     = new Size(this.Width, this.Height);
                cc.Paint(g);
            }
            g.EndContainer(gc);
        }
        public override void Paint(Graphics g, TerrainMap tm)
        {
            if (tm.IsOnboard(Coords) && tm.Los[Coords])
            {
                var container = g.BeginContainer();

                tm.TranslateGraphicsToHex(g, Coords);
                g.DrawImage(_bmp, tm.BoardHexes[Coords].Board.HexgridPath.GetBounds());
                if (tm.ShowHexgrid) g.DrawPath(Pens.Black, tm.HexgridPath);

                g.EndContainer(container);
            }
        }
Beispiel #17
0
 public override void OnRender(Graphics g)
 {
    //g.DrawRectangle(Pen, new System.Drawing.Rectangle(LocalPosition.X, LocalPosition.Y, Size.Width, Size.Height));
    {
       g.TranslateTransform(ToolTipPosition.X, ToolTipPosition.Y);
       var c = g.BeginContainer();
       {                 
          g.RotateTransform(Bearing - Overlay.Control.Bearing);            
          g.ScaleTransform(Scale, Scale);
          
          g.FillPolygon(Fill, Arrow);               
       }                                                                
       g.EndContainer(c);
       g.TranslateTransform(-ToolTipPosition.X, -ToolTipPosition.Y);
    }
 }
        private void BeginContainerVoid(Graphics g)
        {
            // Begin graphics container.
            GraphicsContainer containerState = g.BeginContainer();

            // Translate world transformation.
            g.TranslateTransform(100.0F, 100.0F);

            // Fill translated rectangle in container with red.
            g.FillRectangle(new SolidBrush(Color.Red), 0, 0, 200, 200);

            // End graphics container.
            g.EndContainer(containerState);

            // Fill untransformed rectangle with green.
            g.FillRectangle(new SolidBrush(Color.Green), 0, 0, 200, 200);
        }
        public static void DrawReverseString( Graphics g, string drawText, Font drawFont, Rectangle drawRect, Brush drawBrush, StringFormat drawFormat )
        {
            GraphicsContainer container = g.BeginContainer();

              // The text will be rotated around the origin (0,0) and so needs moving
              // back into position by using a transform
              g.TranslateTransform(drawRect.Left * 2 + drawRect.Width,
            drawRect.Top * 2 + drawRect.Height);

              // Rotate the text by 180 degress to reverse the direction
              g.RotateTransform(180);

              // Draw the string as normal and let then transforms do the work
              g.DrawString(drawText, drawFont, drawBrush, drawRect, drawFormat);

              g.EndContainer(container);
        }
Beispiel #20
0
        public override void Paint(System.Drawing.Graphics g)
        {
            base.Paint(g);
            float f1 = Width * 2 / 3;

            System.Drawing.RectangleF r1 = new System.Drawing.RectangleF(this.Rectangle.Location, new System.Drawing.SizeF(f1, this.Rectangle.Height * 3 / 5));
            System.Drawing.RectangleF r2 = new System.Drawing.RectangleF(new PointF(this.Rectangle.X, this.Rectangle.Y + this.Height * 2 / 5), new System.Drawing.SizeF(f1, this.Height * 3 / 5));
            System.Drawing.RectangleF r3 = new System.Drawing.RectangleF(new PointF(this.Rectangle.X + this.Width / 3, this.Rectangle.Y + this.Height * 1 / 5), new System.Drawing.SizeF(f1, this.Height * 3 / 5));
            GraphicsContainer         gc = g.BeginContainer(Rectangle, Rectangle, GraphicsUnit.Pixel);

            g.SmoothingMode = SmoothingMode.HighQuality;
            g.Transform     = GetTransForm();
            g.DrawEllipse(this.Pen, r1);
            g.DrawEllipse(this.Pen, r2);
            g.DrawEllipse(this.Pen, r3);
            g.EndContainer(gc);
        }
        protected virtual void FillShadow(Graphics g, RectangleF r)
        {
            Color sc = Color.FromArgb(100,
                this.ShadowColor.R,
                this.ShadowColor.G,
                this.ShadowColor.B
                );
            SolidBrush brush = new SolidBrush(sc);

            SmoothingMode m = g.SmoothingMode;
            g.SmoothingMode = SmoothingMode.AntiAlias;

            GraphicsContainer cont = g.BeginContainer();
                g.TranslateTransform(this.ShadowWidth,this.ShadowWidth);
                g.FillRectangle(brush,r.X,r.Y,r.Width,r.Height);
            g.EndContainer(cont);
            g.SmoothingMode = m;
        }
        /// <summary>
        /// Paint me
        /// </summary>
        /// <param name="g"></param>
        protected override void OnPaint(System.Drawing.Graphics g)
        {
            try
            {
                StringFormat xsf = new StringFormat();
                xsf.Alignment = StringAlignment.Center;
                StringFormat ysf = new StringFormat();
                ysf.Alignment = StringAlignment.Far;

                //Draw axislabels for X axis
                foreach (data d in xaxis)
                {
                    //Check that the value is legal then draw
                    if (!(double.IsInfinity(d.f) || double.IsNaN(d.f)))
                    {
                        g.DrawString(d.Name, Font, sb,
                                     new RectangleF(
                                         new PointF((float)(MarginLeft + gr.GraphTransform.TranslateX((double)d.f) - d.Width / 2), Height - MarginBottom + 1),
                                         new SizeF(d.Width, MarginBottom)), xsf);
                    }
                }

                //Draw axislabels for Y axis
                foreach (data d in yaxis)
                {
                    //Check that the value is legal then draw
                    if (!(double.IsInfinity(d.f) || double.IsNaN(d.f)))
                    {
                        g.DrawString(d.Name, Font, sb,
                                     new RectangleF(
                                         new PointF(0, (float)(MarginTop + gr.GraphTransform.TranslateY((double)d.f) - d.Height / 2)),
                                         new SizeF(MarginLeft, d.Height)), ysf);
                    }
                }
            }
            catch {}

            //Paint DrawGrid
            GraphicsContainer gc = g.BeginContainer();

            gr.Location = new Point(MarginLeft, MarginTop);
            gr.Paint(g);
            g.EndContainer(gc);
        }
Beispiel #23
0
            protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, swf.DataGridViewPaintParts paintParts)
            {
                Handler.Paint(graphics, clipBounds, ref cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, ref paintParts);

                var val = value as object[];
                var img = val[0] as sd.Image;

                if (img != null)
                {
                    var container = graphics.BeginContainer();
                    graphics.SetClip(cellBounds);
                    graphics.InterpolationMode = InterpolationMode;
                    graphics.DrawImage(img, new sd.Rectangle(cellBounds.X + IconPadding, cellBounds.Y + (cellBounds.Height - Math.Min(img.Height, cellBounds.Height)) / 2, IconSize, IconSize));
                    graphics.EndContainer(container);
                    cellBounds.X     += IconSize + IconPadding * 2;
                    cellBounds.Width -= IconSize + IconPadding * 2;
                }
                base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
            }
 public override void Draw(Graphics graphics)
 {
     GraphicsContainer container = graphics.BeginContainer();
     Rectangle bounds = base.Bounds;
     using (Region region = new Region(new Rectangle(bounds.X, bounds.Y, bounds.Width + 1, bounds.Height + 1)))
     {
         graphics.Clip = region;
         base.itemStrip.Draw(graphics);
         if (base.itemStrip.ScrollPosition > 0)
         {
             this.DrawButton(graphics, (base.Orientation == Orientation.Horizontal) ? ScrollButton.Left : ScrollButton.Up);
         }
         if ((base.itemStrip.ScrollPosition + base.itemStrip.MaxVisibleItems) < base.itemStrip.Items.Count)
         {
             this.DrawButton(graphics, (base.Orientation == Orientation.Horizontal) ? ScrollButton.Right : ScrollButton.Down);
         }
     }
     graphics.EndContainer(container);
 }
Beispiel #25
0
        /// <summary>
        /// Метод рисования графического примитива
        /// </summary>
        /// <param name="g"></param>
        /// <returns></returns>
        public override void Draw(System.Drawing.Graphics g)
        {
            GraphicsContainer containerState = null;

            try
            {
                /*создать графический контейнер, в нем можно делать с графиксом что угодно*/
                containerState = g.BeginContainer();
                using (Matrix transform = g.Transform)
                {
                    /*
                     * чтобы нарисовать примитив в нужном масштабе и положении
                     * нужно умножить матрицу преобразования графикса на матрицу ей обратную
                     * т.е на единичной матрице графикса рисуем примитив
                     */
                    transform.Invert();
                    g.MultiplyTransform(transform);
                    if (g.VisibleClipBounds.IntersectsWith(_boundRect) == true)
                    {
                        /*
                         * если видимый прямоугольник графикса пересекается
                         * с ограничивающим прямоугольноком примитива
                         * рисуем его
                         */
                        g.DrawEllipse(_pen, _circleRect);
                        g.DrawRectangle(_pen, _boundRect);
                        g.DrawLine(_pen, _circlePoint, _centerPoint);
                    }
                }
            }
            finally
            {
                if (containerState != null)
                {
                    /*закрыть графический контейнер*/
                    g.EndContainer(containerState);
                }
            }
        }
Beispiel #26
0
 internal void Draw(Graphics g, Matrix matrix1)
 {
     GraphicsContainer container1 = g.BeginContainer();
     g.Transform=matrix1;
     this.symbolElement.Draw(g,0);
     g.EndContainer(container1);
     //			g.DrawPath(Pens.Black,path);
 }
Beispiel #27
0
        /// <summary>
        /// Paint me
        /// </summary>
        /// <param name="g"></param>
        protected override void OnPaint(System.Drawing.Graphics g)
        {
            //Y coordinate for ChControl
            int y = 5;

            //X coordiante for ChControl
            int x = 5;

            //Height of ChControl
            int height = Height;

            //Width of ChControl
            int width = Width;

            //Draw title
            if (ShowTitle)
            {
                SizeF ts = g.MeasureString(Title, bold, Width, tsf);
                g.DrawString(Title,
                             bold,
                             new SolidBrush(ForeColor),
                             new RectangleF(new Point(0, y), new SizeF(Width, ts.Height)),
                             tsf);

                //Add Title Height to y coordinate
                y += (int)Math.Ceiling(ts.Height);
            }


            //Draw XLabel
            SizeF xs = g.MeasureString(XLabel, Font, Width, tsf);

            g.DrawString(XLabel,
                         Font,
                         new SolidBrush(ForeColor),
                         new RectangleF(new Point(0, Height - (int)Math.Ceiling(xs.Height)), new SizeF(Width, xs.Height)),
                         tsf);
            //Subtract X Label height from ChControl height
            height -= (int)Math.Ceiling(xs.Height);

            //Draw Y Titles
            if (ShowLegend)
            {
//				//Draw Legend

                if (legendhorizontal)
                {
                    ly.Font = Font;
                    ly.MeasureContent(g);
                    GraphicsContainer gc1 = g.BeginContainer();
                    g.TranslateTransform(Width - ly.Width - 1, 1);
                    ly.Paint(g);
                    g.EndContainer(gc1);

                    //Subtract legend width from ChControl width
                    width -= ly.Width + 1;
                }
                else
                {
                    GraphicsContainer gc1 = g.BeginContainer();
                    g.TranslateTransform(1, this.Height / 2 - ly.Height / 2);
                    ly.Paint(g);
                    g.EndContainer(gc1);
                    x += ly.Width + 1;
                }
//				}
//				//Draw Single Y Title
//				else if (YLabels.Length == 1)
//				{
//					GraphicsContainer gc1 = g.BeginContainer();
//					SizeF ys = g.MeasureString(YLabels[0],Font,Height,tsf);
//					g.RotateTransform(-90);
//					g.DrawString(YLabels[0],Font,new SolidBrush(ForeColor),
//						new RectangleF(new PointF(-Height,0),new SizeF(Height,ys.Height)),tsf);
//					g.EndContainer(gc1);
//
//					//Add Y title height to ChControl X coordinate
//					x += (int)Math.Ceiling(ys.Height);
//				}
            }

            //Draw X axis label
            if (XType != null)
            {
                SizeF xss = g.MeasureString(XType, Font);
                g.DrawString(XType, Font, new SolidBrush(ForeColor), width - xss.Width, height - xss.Height);

                //Subtract Height of x axis label from ChControl height
                height -= (int)Math.Ceiling(xss.Height);
            }

            //Draw Y axis label
            if (YType != null)
            {
                SizeF xss = g.MeasureString(YType, Font);
                g.DrawString(YType, Font, new SolidBrush(ForeColor), 0, y);

                //Set the x coordinate to new value if it is too small
                if (x < (int)Math.Ceiling(xss.Width))
                {
                    x = (int)Math.Ceiling(xss.Width);
                }
            }

            //Set Location and Size of ChControl and Paint it
            GraphicsContainer gc = g.BeginContainer();

            cc.Location = new Point(x, y);
            cc.Paint(g);
            g.EndContainer(gc);
        }
        public void Render(Graphics g)
        {
            if (this.VisitedGraph==null)
                return;
            if (this.positions.Count==0)
                return;

            GraphicsContainer container = null;
            RectangleF bb = GetBoundingBox();

            g.FillRectangle(Brushes.White,g.ClipBounds);
            g.BeginContainer(GetOriginalBox(),bb,GraphicsUnit.Pixel);

            if (this.edgeVisible)
            {
                int index = 0;
                foreach(IEdge e in this.VisitedGraph.Edges)
                {
                    this.edgeRenderer.Render(g,
                                             e,
                                             this.Positions[e.Source],
                                             this.Positions[e.Target]
                                             );
                    ++index;
                }
            }

            if (this.vertexVisible)
            {
                this.vertexRenderer.PreRender();
                foreach(DictionaryEntry de in this.Positions)
                {
                    this.vertexRenderer.Render(g,(IVertex)de.Key,(PointF)de.Value);
                }
            }

            if (container!=null)
                g.EndContainer(container);
        }
        private void Render(Graphics graphics, Size size, Random random, IEnumerable<CharRenderInfo> characters, StringFormat format, float textWidth)
        {
            string text = Text;

            int x = (text.Length == 1)
                ? (int)(size.Width / 2 - textWidth / 2)
                : margin;

            int stepX = (text.Length == 1)
                ? 0
                : (int)(size.Width - textWidth - margin * 2) / (text.Length - 1);

            foreach (CharRenderInfo c in characters)
            {
                Font font = c.Font;
                int rotate = random.Next(minRotation, maxRotation + 1);
                int maxY = size.Height - font.Height - margin * 2;
                int y = (margin >= maxY) ? margin : random.Next(margin, maxY + 1);

                GraphicsContainer container = graphics.BeginContainer();

                graphics.TranslateTransform(x + c.Size.Width / 2, y + c.Size.Height / 2);
                graphics.RotateTransform(rotate);
                graphics.TranslateTransform(-c.Size.Width / 2, -c.Size.Height / 2);

                RenderCharacter(graphics, c.Char, c.Size, c.Font, c.Color, format, random);

                graphics.EndContainer(container);

                x += (int)c.Size.Width + stepX;
            }
        }
Beispiel #30
0
        public override void Draw(Graphics g, int time)
        {
            if (base.DrawVisible)
            {
                GraphicsContainer container1 = g.BeginContainer();
            //				if (this.pretime != time)
            //				{
            //					int num1 = 0;
            //					int num2 = 0;
            //					AnimFunc.CreateAnimateValues(this, time, out num1, out num2);
            //				}
                Matrix matrix1 = this.Transform.Matrix.Clone();
                base.GraphTransform.Matrix.Multiply(matrix1, MatrixOrder.Prepend);
                if (!this.editMode)
                {
                    g.SmoothingMode = base.OwnerDocument.SmoothingMode;

                    if (this == this.OwnerTextElement)
                    {
                        ClipPath.Clip(g, time, this);
                    }
                    if (!base.Visible)
                    {
                        g.SetClip(Rectangle.Empty);
                    }
                    ISvgBrush brush1 = base.GraphBrush;

                    if (this == this.OwnerTextElement)
                    {
                        this.currentPostion = PointF.Empty;
                    }
                    float single1 = this.Size;
                    this.GPath = new GraphicsPath();
                    using (StringFormat format1 = this.GetGDIStringFormat())
                    {

                        using (FontFamily family1 = this.GetGDIFontFamily())
                        {
                            if (this.X == 0)
                            {
                                this.currentPostion.X = this.currentPostion.X + this.Dx;
                            }
                            else
                            {
                                this.currentPostion.X = (this.X + this.Dx);
                            }
                            if (this.Y == 0)
                            {
                                this.currentPostion.Y = this.currentPostion.Y + this.Dy;
                            }
                            else
                            {
                                this.currentPostion.Y = (this.Y + this.Dy);
                            }
                            //this.currentPostion.Y += (this.Y + this.Dy);
                            int num3 = this.GetGDIStyle();
                            base.TempFillOpacity = Math.Min(1f, base.FillOpacity);
                            base.TempOpacity = Math.Min(1f, base.Opacity);
                            base.TempStrokeOpacity = Math.Min(1f, base.StrokeOpacity);
                            this.old = true;
            //							this.OwnerDocument.BeginPrint=true;
                            bool flag = false;
                            foreach (XmlNode node1 in this.ChildNodes)
                            {
                                GraphicsPath path1 = new GraphicsPath();
                                if (node1 is Text)
                                {
                                    ((Text) node1).currentPostion = this.currentPostion;
                                    ((Text) node1).GraphTransform.Matrix = base.GraphTransform.Matrix.Clone();
                                    ((Text) node1).Draw(g, time);
                                    this.currentPostion = ((Text) node1).currentPostion;
                                    if (((Text) node1).GPath.PointCount > 0)
                                    {
                                        this.GPath.StartFigure();
                                        this.GPath.AddPath(((Text) node1).GPath, false);
                                    }
                                    continue;
                                }
                                if (node1.NodeType == XmlNodeType.Text)
                                {
                                    string text1 = "t";//this.TrimText(node1.Value);
                                    Font font1 =null;
                                    try
                                    {
                                        font1=new Font(family1.Name, single1, (FontStyle) num3,GraphicsUnit.Pixel);
                                    }
                                    catch
                                    {
                                        int ii=0;
                                        ii++;

                                    }
                                    float single2 = (((float) family1.GetCellAscent(FontStyle.Regular))/((float) family1.GetEmHeight(FontStyle.Regular)))*single1;
                                    SizeF ef1 = g.MeasureString(text1, font1, new PointF(this.currentPostion.X, this.currentPostion.Y - single2), format1);
                                    float single3 = ef1.Width;

                                    float single5 = (((float) family1.GetLineSpacing(FontStyle.Regular)) / ((float) family1.GetEmHeight(FontStyle.Regular))) * single1 ; //�о�

                                    float offy = this.currentPostion.Y -single2;
                                    float offx = this.currentPostion.X;

                                    for(int i=0 ;i<Lines.Length;i++)
                                    {
                                        if (!base.ShowBound && (this.OwnerDocument.BeginPrint || LimitSize))
                                        {
                                            GraphicsContainer gc=g.BeginContainer();
                                            g.TextRenderingHint =System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
                                            g.Transform=base.GraphTransform.Matrix;
                                            //g.DrawString(lines[i], font1,new SolidBrush(Color.Black),100,100);
                                            Color color1 =Color.Black;
                                            if (this.SvgAttributes.Contains("stroke"))
                                            {
                                                color1=Stroke.GetStroke(this).StrokeColor;
                                                if (color1.IsEmpty || color1==Color.Transparent || color1==Color.Empty )
                                                    color1 = Color.Black;
                                            }

                                            g.DrawString(lines[i], font1,new SolidBrush(color1),new PointF(offx, offy),format1);
                                            g.EndContainer(gc);
                                            SizeF ef2 = g.MeasureString(lines[i], font1, new PointF(offx, offy), format1);
                                            path1.AddString(lines[i],family1,num3,single1,new PointF(offx, offy),format1);
                                        }
                                        else
                                        {
                                            flag = true;
                                            path1.AddString(lines[i], family1, num3, single1, new PointF(offx, offy), format1);
                                        }
                                        if(Vertical)
                                        {
                                            offx += single5;
                                        }
                                        else
                                        {
                                            offy += single5;
                                        }
                                    }
                                    this.currentPostion.X += ((single3*3f)/4f);
                                    this.GPath.StartFigure();
                                    this.GPath.AddPath(path1, false);
                                    float single4 = base.Opacity;
                                    if (this.svgAnimAttributes.ContainsKey("fill-opacity"))
                                    {
                                        single4 = Math.Min(single4, base.FillOpacity);
                                    }
                                    path1.Transform(base.GraphTransform.Matrix);
                                    if (!base.ShowBound && !(this.OwnerDocument.BeginPrint || LimitSize))
                                    {

                                        brush1.Paint(path1, g, time, single4);
                                        //								Stroke stroke1 = Stroke.GetStroke(this);
                                        //								stroke1.Paint(g, this,path1, time);
                                        base.GraphStroke.Paint(g, this, path1, 0);
                                        continue;
                                    }
                                    else if(flag)
                                    {
                                        g.DrawPath(new Pen(base.BoundColor), path1);
                                    }
                                }
                                path1.Dispose();
                            }
                        }
                    }

                    matrix1.Dispose();
                    ClipPath.DrawClip(g, time, this);
                    g.EndContainer(container1);
                    this.pretime = time;
                    this.old = false;
                }
            }
        }
Beispiel #31
0
        public void DrawInBox(Graphics g, RectangleF box,GraphicsUnit gu)
        {
            if (box.IsEmpty)return;
            GraphicsContainer gc = g.BeginContainer(box,this.GPath.GetBounds(),gu);
            SvgElementCollection.ISvgElementEnumerator enumerator1 = base.GraphList.GetEnumerator();
            Matrix matrix1 = base.GraphTransform.Matrix.Clone();
            while (enumerator1.MoveNext())
            {
                IGraph graph1 = (IGraph) enumerator1.Current;
                Matrix matrix2 = graph1.GraphTransform.Matrix;

                graph1.GraphTransform.Matrix =new Matrix();

                graph1.Draw(g, 0);
            }
            g.EndContainer(gc);
        }
Beispiel #32
0
        /// <summary>
        /// ��·
        /// </summary>
        /// <param name="g"></param>
        /// <param name="time"></param>
        private void Draw2(Graphics g, int time)
        {
            if (base.DrawVisible) {
                Matrix matrix1 = base.Transform.Matrix.Clone();

                GraphicsContainer container1 = g.BeginContainer();

                g.SmoothingMode = base.OwnerDocument.SmoothingMode;

                Matrix matrix2 = base.GraphTransform.Matrix.Clone();
                base.GraphTransform.Matrix.Multiply(matrix1, MatrixOrder.Prepend);

                ClipAndMask.ClipPath.Clip(g, time, this);
                bool flag1 = base.Visible;
                if (!base.Visible) {
                    g.SetClip(Rectangle.Empty);
                }
                float single1 = this.StrokeOpacity;
                if (this.svgAnimAttributes.ContainsKey("fill-opacity")) {
                    single1 = Math.Min(single1, (float)this.svgAnimAttributes["fill-opacity"]);
                }
                ISvgBrush brush1 = this.GraphBrush;
                using (GraphicsPath path1 = (GraphicsPath)this.GPath.Clone()) {
                    path1.Transform(base.GraphTransform.Matrix);
                    if (!base.ShowBound) {

                        float width1 = Width * GraphTransform.Matrix.Elements[0];
                        Stroke stroke = Stroke.GetStroke(this);
                        Color color1 = Color.FromArgb(75, 75, 75);
                        if (stroke.StrokeColor.ToArgb()!=Color.Black.ToArgb()) color1 = stroke.StrokeColor;
                        using (Pen p = new Pen(Color.FromArgb((int)(single1 * 255), color1))) {
                            p.Width = width1;
                            g.DrawPath(p, path1);
                        }
                        if (LineType == "3") {
                            using (Pen p = new Pen(Color.Yellow)) {
                                if (width1 > 30)
                                    p.Width = 2;
                                else
                                    p.Width = 1;
                                //p.DashPattern = new float[] { 10, 10 };
                                g.DrawPath(p, path1);
                            }
                        } else {
                            //using (Pen p = new Pen(Color.Yellow)) {
                            //    if (width1 > 30)
                            //        p.Width = 2;
                            //    else
                            //        p.Width = 1;
                            //    g.DrawPath(p, path1);
                            //}
                        }
                        if (LineType == "4") {

                            using (Pen p =  new Pen(Color.FromArgb((int)(single1*255),color1))) {
                                p.Width = width1;
                                float f22 = width1 / 4f;
                                ImageAttributes imageAttributes = new ImageAttributes();
                                ColorMatrix cmatrix1 = new ColorMatrix();
                                cmatrix1.Matrix00 = 1f;
                                cmatrix1.Matrix11 = 1f;
                                cmatrix1.Matrix22 = 1f;
                                cmatrix1.Matrix33 = single1;//͸����
                                cmatrix1.Matrix44 = 1f;
                                //����͸����
                                imageAttributes.SetColorMatrix(cmatrix1, ColorMatrixFlag.Default, ColorAdjustType.Default);
                                if (BackgroundImage == null) BackgroundImageFile = "road.png";
                                TextureBrush tbush = new TextureBrush(BackgroundImage,new Rectangle(0,0,BackgroundImage.Width,BackgroundImage.Height),imageAttributes);
                                tbush.WrapMode = WrapMode.Tile;
                                for (int i = 0; i < path1.PointCount - 1;i++ ) {
                                    float k = (path1.PathPoints[i+1].Y - path1.PathPoints[i].Y) / (path1.PathPoints[i+1].X - path1.PathPoints[i].X);

                                    float y1 = path1.PathPoints[i].Y - path1.PathPoints[i+1].Y;
                                    float y2 = path1.PathPoints[i].X - path1.PathPoints[i+1].X;
                                    float k2 = (float)Math.Abs(k);
                                    float angle = (float)Math.Atan(k2) * 180 / (float)Math.PI;
                                    if (k < 0) {  angle = 360-angle; }

                                    PointF[] pts = new PointF[] { new PointF(path1.PathPoints[i].X, path1.PathPoints[i].Y - 26) };
                                    Matrix matrix11 = new Matrix();
                                    matrix11.RotateAt(angle, path1.PathPoints[i]);
                                    matrix11.Translate(path1.PathPoints[i].X, path1.PathPoints[i].Y);
                                    matrix11.Scale(width1 / 50, width1 / 50);
                                    //tbush.ScaleTransform(width1 / 50, width1 / 50, MatrixOrder.Append);
                                    //tbush.RotateTransform(angle, MatrixOrder.Append);
                                    //tbush.TranslateTransform(path1.PathPoints[i].X, path1.PathPoints[i].Y , MatrixOrder.Append);
                                    tbush.Transform = matrix11;

                                    p.Brush = tbush.Clone() as TextureBrush;
                                    p.Alignment = PenAlignment.Center;

                                    g.DrawLine(p, path1.PathPoints[i], path1.PathPoints[i + 1]);
                                    tbush.ResetTransform();
                                }
                            }
                            if (BackgroundImageFile == "road.png") {
                                using (Pen p = new Pen(Color.Yellow)) {
                                    if (width1 > 30)
                                        p.Width = 2;
                                    else
                                        p.Width = 1;
                                    g.DrawPath(p, path1);
                                }
                            }
                        }

                    } else {
                        g.DrawPath(new Pen(base.BoundColor), path1);
                    }
                    this.DrawConnect(g);
                }
                matrix1.Dispose();
                ClipAndMask.ClipPath.DrawClip(g, time, this);
                g.EndContainer(container1);
                this.pretime = time;
            }
        }
 internal static void DrawDropShadow(Graphics graphics, Rectangle shadowSourceRectangle, Color baseColor, int shadowDepth, LightSourcePosition lightSourcePosition, float lightSourceIntensity, bool roundEdges)
 {
     if (graphics == null)
     {
         throw new ArgumentNullException("graphics");
     }
     if ((shadowSourceRectangle.IsEmpty || (shadowSourceRectangle.Width < 0)) || (shadowSourceRectangle.Height < 0))
     {
         throw new ArgumentException(SR.GetString("Error_InvalidShadowRectangle"), "shadowRectangle");
     }
     if ((shadowDepth < 1) || (shadowDepth > 12))
     {
         throw new ArgumentException(SR.GetString("Error_InvalidShadowDepth"), "shadowDepth");
     }
     if ((lightSourceIntensity <= 0f) || (lightSourceIntensity > 1f))
     {
         throw new ArgumentException(SR.GetString("Error_InvalidLightSource"), "lightSourceIntensity");
     }
     Rectangle rectangle = shadowSourceRectangle;
     Size empty = Size.Empty;
     if ((lightSourcePosition & LightSourcePosition.Center) > 0)
     {
         rectangle.Inflate(shadowDepth, shadowDepth);
     }
     if ((lightSourcePosition & LightSourcePosition.Left) > 0)
     {
         empty.Width += shadowDepth + 1;
     }
     else if ((lightSourcePosition & LightSourcePosition.Right) > 0)
     {
         empty.Width -= shadowDepth + 1;
     }
     if ((lightSourcePosition & LightSourcePosition.Top) > 0)
     {
         empty.Height += shadowDepth + 1;
     }
     else if ((lightSourcePosition & LightSourcePosition.Bottom) > 0)
     {
         empty.Height -= shadowDepth + 1;
     }
     rectangle.Offset(empty.Width, empty.Height);
     GraphicsContainer container = graphics.BeginContainer();
     GraphicsPath path = new GraphicsPath();
     if (roundEdges)
     {
         path.AddPath(GetRoundedRectanglePath(shadowSourceRectangle, 8), true);
     }
     else
     {
         path.AddRectangle(shadowSourceRectangle);
     }
     try
     {
         using (Region region = new Region(path))
         {
             graphics.SmoothingMode = SmoothingMode.AntiAlias;
             graphics.ExcludeClip(region);
             Color color = Color.FromArgb(Convert.ToInt32((float) (40f * lightSourceIntensity)), baseColor);
             int num = Math.Max(40 / shadowDepth, 2);
             for (int i = 0; i < shadowDepth; i++)
             {
                 rectangle.Inflate(-1, -1);
                 using (Brush brush = new SolidBrush(color))
                 {
                     using (GraphicsPath path2 = new GraphicsPath())
                     {
                         if (roundEdges)
                         {
                             path2.AddPath(GetRoundedRectanglePath(rectangle, 8), true);
                         }
                         else
                         {
                             path2.AddRectangle(rectangle);
                         }
                         graphics.FillPath(brush, path2);
                     }
                 }
                 color = Color.FromArgb(color.A + num, color.R, color.G, color.B);
             }
         }
     }
     finally
     {
         graphics.EndContainer(container);
     }
 }
Beispiel #34
0
		protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
		{

            TreeGridNode node = this.OwningNode;
            if (node == null) return;

            Image image = node.Image;

            if (this._imageHeight == 0 && image != null) this.UpdateStyle();

			// paint the cell normally
			base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);

            // TODO: Indent width needs to take image size into account
			Rectangle glyphRect = new Rectangle(cellBounds.X + this.GlyphMargin, cellBounds.Y, INDENT_WIDTH, cellBounds.Height - 1);
			int glyphHalf = glyphRect.Width / 2;

			//TODO: This painting code needs to be rehashed to be cleaner
			int level = this.Level;

            //TODO: Rehash this to take different Imagelayouts into account. This will speed up drawing
			//		for images of the same size (ImageLayout.None)
			if (image != null)
			{
				Point pp;
				if (_imageHeight > cellBounds.Height)
                    pp = new Point(glyphRect.X + this.glyphWidth, cellBounds.Y + _imageHeightOffset);
				else
                    pp = new Point(glyphRect.X + this.glyphWidth, (cellBounds.Height / 2 - _imageHeight / 2) + cellBounds.Y);

				// Graphics container to push/pop changes. This enables us to set clipping when painting
				// the cell's image -- keeps it from bleeding outsize of cells.
				System.Drawing.Drawing2D.GraphicsContainer gc = graphics.BeginContainer();
				{
					graphics.SetClip(cellBounds);
					graphics.DrawImageUnscaled(image, pp);
				}
				graphics.EndContainer(gc);
			}

			// Paint tree lines			
            if (node._grid.ShowLines)
            {
                using (Pen linePen = new Pen(SystemBrushes.ControlDark, 1.0f))
                {
                    linePen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                    bool isLastSibling = node.IsLastSibling;
                    bool isFirstSibling = node.IsFirstSibling;
                    if (node.Level == 1)
                    {
                        // the Root nodes display their lines differently
                        if (isFirstSibling && isLastSibling)
                        {
                            // only node, both first and last. Just draw horizontal line
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2);
                        }
                        else if (isLastSibling)
                        {
                            // last sibling doesn't draw the line extended below. Paint horizontal then vertical
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2);
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2);
                        }
                        else if (isFirstSibling)
                        {
                            // first sibling doesn't draw the line extended above. Paint horizontal then vertical
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2);
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.X + 4, cellBounds.Bottom);
                        }
                        else
                        {
                            // normal drawing draws extended from top to bottom. Paint horizontal then vertical
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2);
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Bottom);
                        }
                    }
                    else
                    {
                        if (isLastSibling)
                        {
                            // last sibling doesn't draw the line extended below. Paint horizontal then vertical
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2);
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2);
                        }
                        else
                        {
                            // normal drawing draws extended from top to bottom. Paint horizontal then vertical
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2);
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Bottom);
                        }

                        // paint lines of previous levels to the root
                        TreeGridNode previousNode = node.Parent;
                        int horizontalStop = (glyphRect.X + 4) - INDENT_WIDTH;

                        while (!previousNode.IsRoot)
                        {
                            if (previousNode.HasChildren && !previousNode.IsLastSibling)
                            {
                                // paint vertical line
                                graphics.DrawLine(linePen, horizontalStop, cellBounds.Top, horizontalStop, cellBounds.Bottom);
                            }
                            previousNode = previousNode.Parent;
                            horizontalStop = horizontalStop - INDENT_WIDTH;
                        }
                    }

                }
            }

            if (node.HasChildren || node._grid.VirtualNodes)
            {
                // Paint node glyphs				
                if (node.IsExpanded)
                    node._grid.rOpen.DrawBackground(graphics, new Rectangle(glyphRect.X, glyphRect.Y + (glyphRect.Height / 2) - 4, 10, 10));
                else
                    node._grid.rClosed.DrawBackground(graphics, new Rectangle(glyphRect.X, glyphRect.Y + (glyphRect.Height / 2) - 4, 10, 10));
            }


		}
Beispiel #35
0
        /// <summary>
        /// Paint me
        /// </summary>
        /// <param name="g"></param>
        protected override void OnPaint(System.Drawing.Graphics g)
        {
            GridLinesXCount = 0;
            GridLinesYCount = 0;

            #region Draw X Grid
            switch (XAxisType)
            {
            //Draw gridlines for linear axis
            case AxisType.LIN:
                double tmpXval = X.Min;
                while (tmpXval <= (X.Max + X.Step / 2))
                {
                    //Translate into screen coordinates
                    float x = gm.TranslateX(tmpXval);

                    //Draw gridline
                    PointF p1 = new PointF((float)x, 0);
                    PointF p2 = new PointF((float)x, Height);
                    g.DrawLine(pen1, p2, p1);

                    //Increase tmpval
                    tmpXval += X.Step;

                    //Increase GridLines counter
                    GridLinesXCount++;
                }
                break;

            //Draw gridlines for logarithmic axis
            case AxisType.LOG:
                for (int i = (int)X.Min; i < (int)X.Max + 1; i++)
                {
                    //Translate into screen coordinates;
                    int x = (int)gm.TranslateX(i);

                    //Draw main axis
                    g.DrawLine(pen1,
                               new PointF(x, 0),
                               new PointF(x, Height));

                    //Draw intermediate axis
                    if (i < X.Max)
                    {
                        for (int z = 2; z < 10; z++)
                        {
                            //Get intermediate value
                            double xs = (double)Math.Log10(z) + i;

                            //Translate into screen coordinates
                            x = (int)gm.TranslateX(xs);

                            g.DrawLine(pen2,
                                       new PointF(x, 0),
                                       new PointF(x, Height));
                        }
                    }

                    //Increase GridLines counter
                    GridLinesXCount++;
                }
                break;
            }
            #endregion

            #region Draw Y Grid
            float y;
            switch (YAxisType)
            {
            //Draw gridlines for linear y axis
            case AxisType.LIN:
                double temp_y = Y.Min;
                while (temp_y <= (Y.Max + Y.Step / 2))
                {
                    //Translate into screen coordinates
                    y = gm.TranslateY(temp_y);

                    //Draw Grid lines
                    g.DrawLine(pen1,
                               new PointF(Width, y),
                               new PointF(0, y));

                    //Increase tmpval
                    temp_y += Y.Step;

                    //Increase GridLines counter
                    GridLinesYCount++;
                }

                //Draw GidLine for Zero
                if (showzero)
                {
                    y = gm.TranslateY(0);
                    g.DrawLine(pen1,
                               new PointF(0, y),
                               new PointF(Width, y));
                }
                break;

            //Draw gridlines for logarithmic y axis
            case AxisType.LOG:
                for (int i = (int)Y.Min; i < Y.Max + 1; i++)
                {
                    //Translate into screen coordinates
                    y = gm.TranslateY(i);

                    //Draw major line
                    g.DrawLine(pen1,
                               new PointF(0, y),
                               new PointF(Width, y));

                    //Draw minor lines
                    if (i < Y.Max)
                    {
                        for (int z = 2; z < 10; z++)
                        {
                            //Get minor line position
                            double ys = (double)Math.Log10(z) + i;

                            //Translate into screen coordinates
                            y = gm.TranslateY(ys);

                            //Draw minor line
                            g.DrawLine(pen2,
                                       new PointF(0, (float)y),
                                       new PointF(Width, (float)y));
                        }
                    }

                    //Increase GridLines counter
                    GridLinesYCount++;
                }
                break;
            }
            #endregion

            //Set Location and Size of ChControl and Paint it
            GraphicsContainer gc = g.BeginContainer();
            foreach (ChControl cc in this.Children)
            {
//				if(cc is DrawPlot)
//					((DrawPlot)cc).Initialize();
                cc.Location = new Point(0, 0);
                cc.Size     = new Size(this.Width, this.Height);
                cc.Paint(g);
            }
            g.EndContainer(gc);
        }
Beispiel #36
0
        private void draw2(Graphics g, int time)
        {
            if (base.DrawVisible)
            {
                GraphicsContainer container1 = g.BeginContainer();
                Matrix matrix1 = base.Transform.Matrix.Clone();
                base.GraphTransform.Matrix.Multiply(matrix1, MatrixOrder.Prepend);
                if (!this.editMode)
                {
                    g.SmoothingMode = base.OwnerDocument.SmoothingMode;

                    if (this == this.OwnerTextElement)
                    {
                        ClipPath.Clip(g, time, this);
                    }
                    if (!base.Visible)
                    {
                        g.SetClip(Rectangle.Empty);
                    }
                    ISvgBrush brush1 = base.GraphBrush;

                    if (this == this.OwnerTextElement)
                    {
                        this.currentPostion = PointF.Empty;
                    }
                    float single1 = this.Size;
                    this.GPath = new GraphicsPath();
                    using (StringFormat format1 = this.GetGDIStringFormat())
                    {

                        using (FontFamily family1 = this.GetGDIFontFamily())
                        {
                            if (this.X == 0)
                            {
                                this.currentPostion.X = this.currentPostion.X + this.Dx;
                            }
                            else
                            {
                                this.currentPostion.X = (this.X + this.Dx);
                            }
                            if (this.Y == 0)
                            {
                                this.currentPostion.Y = this.currentPostion.Y + this.Dy;
                            }
                            else
                            {
                                this.currentPostion.Y = (this.Y + this.Dy);
                            }
                            //this.currentPostion.Y += (this.Y + this.Dy);
                            int num3 = this.GetGDIStyle();
                            base.TempFillOpacity = Math.Min(1f, base.FillOpacity);
                            base.TempOpacity = Math.Min(1f, base.Opacity);
                            base.TempStrokeOpacity = Math.Min(1f, base.StrokeOpacity);
                            this.old = true;
                            foreach (XmlNode node1 in this.ChildNodes)
                            {
                                GraphicsPath path1 = new GraphicsPath();
                                if (node1 is Text)
                                {
                                    ((Text) node1).currentPostion = this.currentPostion;
                                    ((Text) node1).GraphTransform.Matrix = base.GraphTransform.Matrix.Clone();
                                    ((Text) node1).Draw(g, time);
                                    this.currentPostion = ((Text) node1).currentPostion;
                                    if (((Text) node1).GPath.PointCount > 0)
                                    {
                                        this.GPath.StartFigure();
                                        this.GPath.AddPath(((Text) node1).GPath, false);
                                    }
                                    continue;
                                }
                                if (node1.NodeType == XmlNodeType.Text)
                                {
                                    string text1 = "t";//this.TrimText(node1.Value);
                                    Font font1 = new Font(family1.Name, single1, (FontStyle) num3);
                                    float single2 = (((float) family1.GetCellAscent(FontStyle.Regular))/((float) family1.GetEmHeight(FontStyle.Regular)))*single1;
                                    SizeF ef1 = g.MeasureString(text1, font1, new PointF(this.currentPostion.X, this.currentPostion.Y - single2), format1);
                                    float single3 = ef1.Width;

                                    float single5 = (((float) family1.GetLineSpacing(FontStyle.Regular)) / ((float) family1.GetEmHeight(FontStyle.Regular))) * single1 ; //�о�

                                    float offy = this.currentPostion.Y -single2;
                                    float offx = this.currentPostion.X;
                                    for(int i=0 ;i<Lines.Length;i++)
                                    {
                                        if (!base.ShowBound)
                                        {
                                            GraphicsContainer gc=g.BeginContainer();
                                            g.Transform=base.GraphTransform.Matrix;
                                            //g.DrawString(lines[i], font1,new SolidBrush(Color.Black),100,100);
                                            g.DrawString(lines[i], font1,new SolidBrush(Color.Black),new PointF(offx, offy));
                                            g.EndContainer(gc);
                                        }
                                        path1.AddString(lines[i], family1, num3, single1, new PointF(offx, offy), format1);
                                        if(Vertical)
                                        {
                                            offx += single5;
                                        }
                                        else
                                        {
                                            offy += single5;
                                        }
                                    }
                                    this.currentPostion.X += ((single3*3f)/4f);
                                    this.GPath.StartFigure();
                                    this.GPath.AddPath(path1, false);
                                    float single4 = base.Opacity;
                                    if (this.svgAnimAttributes.ContainsKey("fill-opacity"))
                                    {
                                        single4 = Math.Min(single4, base.FillOpacity);
                                    }

                                    path1.Transform(base.GraphTransform.Matrix);

                                    if (!base.ShowBound)
                                    {

            //										brush1.Paint(path1, g, time, single4);
            //										//								Stroke stroke1 = Stroke.GetStroke(this);
            //										//								stroke1.Paint(g, this,path1, time);
            //										base.GraphStroke.Paint(g, this, path1, 0);
                                        continue;
                                    }
                                    else
                                    {
                                        g.DrawPath(new Pen(base.BoundColor), path1);
                                    }
                                }
                                path1.Dispose();
                            }
                        }
                    }

                    matrix1.Dispose();
                    ClipPath.DrawClip(g, time, this);
                    g.EndContainer(container1);
                    this.pretime = time;
                    this.old = false;
                }
            }
        }
    /// <summary>
    /// Custom paints the cell. The base implementation of the DataGridViewTextBoxCell 
    /// type is called first to draw the text box part. Then the <see cref="Image"/> is drawn.
    /// </summary>
    /// <param name="graphics">The <see cref="Graphics"/> used to paint the <see cref="DataGridViewCell"/>.</param>
    /// <param name="clipBounds">A <see cref="Rectangle"/> that represents the area of the <see cref="DataGridView"/> that needs to be repainted.</param>
    /// <param name="cellBounds">A <see cref="Rectangle"/> that contains the bounds of the <see cref="DataGridViewCell"/> that is being painted.</param>
    /// <param name="rowIndex">The row index of the cell that is being painted.</param>
    /// <param name="cellState">A bitwise combination of <see cref="DataGridViewElementStates"/> values that specifies the state of the cell.</param>
    /// <param name="value">The data of the <see cref="DataGridViewCell"/> that is being painted.</param>
    /// <param name="formattedValue">The formatted data of the <see cref="DataGridViewCell"/> that is being painted.</param>
    /// <param name="errorText">An error message that is associated with the cell.</param>
    /// <param name="cellStyle">A <see cref="DataGridViewCellStyle"/> that contains formatting and style information about the cell.</param>
    /// <param name="advancedBorderStyle">A <see cref="DataGridViewAdvancedBorderStyle"/> that contains border styles for the cell that is being painted.</param>
    /// <param name="paintParts">A bitwise combination of the <see cref="DataGridViewPaintParts"/> values that specifies which parts of the cell need to be painted.</param>
    protected override void Paint(Graphics graphics, Rectangle clipBounds,
                Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState,
                object value, object formattedValue, string errorText,
                DataGridViewCellStyle cellStyle,
                DataGridViewAdvancedBorderStyle advancedBorderStyle,
                DataGridViewPaintParts paintParts)
    {
      // Paint the base content
      base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState,
                  value, formattedValue, errorText, cellStyle,
                  advancedBorderStyle, paintParts);

      if (this.Image != null)
      {
        // Draw the image clipped to the cell.
        System.Drawing.Drawing2D.GraphicsContainer container = graphics.BeginContainer();

        graphics.SetClip(cellBounds);
        graphics.DrawImage(this.Image, cellBounds.Location.X, cellBounds.Location.Y, this.Image.Width, this.Image.Height);

        graphics.EndContainer(container);
      }
    }
Beispiel #38
0
        public virtual void Draw(Graphics g, int time)
        {
            if (this.DrawVisible)
            {
            //				int num1 = 0;
            //				int num2 = 0;
            //				if (this.pretime != time)
            //				{

            //					AnimFunc.CreateAnimateValues(this, time, out num1, out num2);
            //				}
                GraphicsContainer container1 = g.BeginContainer();
                g.SmoothingMode = base.OwnerDocument.SmoothingMode;
                if (!this.Visible)
                {
                    g.SetClip(Rectangle.Empty);
                }
                Matrix matrix1 = this.Transform.Matrix.Clone();
                this.GraphTransform.Matrix.Multiply(matrix1, MatrixOrder.Prepend);
                //g.Transform = matrix1;
                ClipAndMask.ClipPath.Clip(g, time, this);
                this.TempFillOpacity = Math.Min(1f, this.FillOpacity);
                this.TempOpacity = Math.Min(1f, this.Opacity);
                this.TempStrokeOpacity = Math.Min(1f, this.StrokeOpacity);
                Matrix matrix2 = this.GraphTransform.Matrix.Clone();
                if (this.pretime != time)
                {
                    this.graphPath.Reset();
                    foreach(IGraph childgraph in this.graphList )
                    {
                        childgraph.ShowConnectPoints=false;
                    }
                }
                SvgElementCollection.ISvgElementEnumerator enumerator1 = this.graphList.GetEnumerator();
                while (enumerator1.MoveNext())
                {
                    IGraph graph1 = (IGraph) enumerator1.Current;
                    graph1.GraphTransform.Matrix = matrix2.Clone();
                    graph1.Draw(g, time);
                    if ((this.pretime != time))
                    {
                        GraphicsPath path1 = (GraphicsPath) graph1.GPath.Clone();
                        path1.Transform(graph1.Transform.Matrix);
                        this.graphPath.StartFigure();
                        if (path1.PointCount > 0)
                        {
                            this.graphPath.AddPath(path1, false);
                        }
                    }
                }
                if(this.pretime != time)
                {
                    this.CreateConnectPoint();
                }
                this.DrawConnect(g);
                ClipAndMask.ClipPath.DrawClip(g, time, this);
                g.EndContainer(container1);
                this.pretime = time;
            }
        }
Beispiel #39
0
 private void DrawTitleBox(Graphics g)
 {
     GraphicsContainer container = g.BeginContainer();
     Rectangle titleBorderRect = TitleBorderRect;
     g.SetClip(new Rectangle(titleBorderRect.X, titleBorderRect.Y, titleBorderRect.Width,
                             titleBorderRect.Bottom + 1));
     int upHeight = titleBorderRect.Height/2,
         downHeight = titleBorderRect.Height - upHeight;
     var upBox = new Rectangle(titleBorderRect.X, titleBorderRect.Y, titleBorderRect.Width, upHeight);
     var downBox = new Rectangle(titleBorderRect.X, titleBorderRect.Y + upHeight, titleBorderRect.Width,
                                 downHeight);
     if (Chart.visualSettings.ChartFrameStyle == FrameStyle.ThreeD)
     {
         var pen = new Pen(ControlPaint.Dark(Chart.visualSettings.PaneFrameBorderColor, 0.5f));
         var brushUp = new LinearGradientBrush(new Point(0, 0), new Point(0, upHeight + 3),
                                               Chart.visualSettings.PaneFrameBorderMarginGradientColor,
                                               Chart.visualSettings.PaneFrameBorderCenterGradientColor);
         var brushDn = new LinearGradientBrush(new Point(0, 0), new Point(0, downHeight),
                                               Chart.visualSettings.PaneFrameBorderCenterGradientColor,
                                               Chart.visualSettings.PaneFrameBorderMarginGradientColor);
         using (pen)
         {
             using (brushUp)
             {
                 using (brushDn)
                 {
                     Renderer.Draw3DBorder(g, titleBorderRect, Chart.visualSettings.PaneFrameBorderColor,
                                           Border3DStyle.Raised);
                     g.DrawLine(pen, titleBorderRect.Left, titleBorderRect.Bottom, titleBorderRect.Right - 1,
                                titleBorderRect.Bottom);
                     g.FillRectangle(brushUp, upBox);
                     g.FillRectangle(brushDn, downBox);
                 }
             }
         }
     }
     else if (Chart.visualSettings.ChartFrameStyle == FrameStyle.Flat)
     {
         var pen2 = new Pen(Chart.visualSettings.PaneFrameBorderColor);
         var brush2 = new SolidBrush(Chart.visualSettings.PaneFrameBackColor);
         using (pen2)
         {
             using (brush2)
             {
                 g.FillRectangle(brush2, titleBorderRect);
                 g.DrawLine(pen2, titleBorderRect.Left, titleBorderRect.Bottom, titleBorderRect.Right - 1,
                            titleBorderRect.Bottom);
             }
         }
     }
     g.EndContainer(container);
 }
Beispiel #40
0
 private void DrawTitle(Graphics g)
 {
     try
     {
         GraphicsContainer container = g.BeginContainer();
         Rectangle titleBoxRect = TitleBoxRect;
         if (titleBoxRect.Width < (LeftBorderWidth + RightBorderWidth))
         {
             titleBoxRect.Width = 0;
         }
         g.SetClip(titleBoxRect);
         RectangleF layoutRectangle = titleBoxRect;
         layoutRectangle.Inflate(-2f, -2f);
         layoutRectangle.Width = 0f;
         var stringFormat = new StringFormat {Alignment = StringAlignment.Near};
         stringFormat.FormatFlags |= StringFormatFlags.NoClip | StringFormatFlags.NoWrap;
         stringFormat.Trimming = StringTrimming.None;
         using (var brush = new SolidBrush(Chart.visualSettings.PaneFrame2TextColor))
         {
             foreach (Series.Series series in Owner.Series)
             {
                 SizeF ef3 = g.MeasureString(series.Name, Font, layoutRectangle.Location, stringFormat);
                 layoutRectangle.Offset(layoutRectangle.Width, 0f);
                 layoutRectangle.Width = ef3.Width;
                 layoutRectangle.Intersect(titleBoxRect);
                 string title = series.Name;
                 if (!string.IsNullOrEmpty(Title)) title = Title;
                 g.DrawString(title, Font, brush, layoutRectangle, stringFormat);
                 if (string.IsNullOrEmpty(Title))
                 {
                     // если заголовок не задан отдельно - вывести результирующую
                     ef3 = g.MeasureString(series.CurrentPriceString + "0", Font, layoutRectangle.Location,
                                             stringFormat);
                     layoutRectangle.Offset(layoutRectangle.Width, 0f);
                     layoutRectangle.Width = ef3.Width;
                     layoutRectangle.Intersect(titleBoxRect);
                     g.DrawString(series.CurrentPriceString, Font, brush, layoutRectangle, stringFormat);
                 }
                 break; // вывести только первую
             }
         }
         g.EndContainer(container);
     }
     catch
     {
     }
 }
Beispiel #41
0
        protected void PaintMarkers(Graphics g)
        {
            string markerStartUrl = extractMarkerUrl(this.GetAttribute("marker-start"));
            string markerEndUrl = extractMarkerUrl(this.GetAttribute("marker-end"));
            PointF[] points1 = this.Points.Clone() as PointF[];
            int num1 = 0;
            int num11 = 1;

            int num3 = 0;
            int num33 = 1;

            if (points1.Length > 3) {
                num33 = points1.Length - 1;
                num3 = num33 - 1;
            }

            base.GraphTransform.Matrix.TransformPoints(points1);

            float angle = 0f;//(float)(180*Math.Atan2(points1[1].Y - points1[0].Y,points1[1].X-points1[0].X)/Math.PI);

            GraphicsContainer container1 = g.BeginContainer();

            Marker element1;
            if (markerStartUrl.Length > 0) {
                angle = (float)(180 * Math.Atan2(points1[num11].Y - points1[num1].Y, points1[num11].X - points1[num1].X) / Math.PI);

                element1 = (Marker)NodeFunc.GetRefNode(markerStartUrl, this.OwnerDocument);
                if (element1 is Marker) {
                    ((Marker)element1).GraphTransform.Matrix = new Matrix();
                    Matrix matrix1 = ((Marker)element1).MarkerTransForm;

                    matrix1.Rotate(angle);
                    matrix1.Translate(points1[num1].X, points1[num1].Y, MatrixOrder.Append);
                    element1.GraphStroke = this.GraphStroke;
                    element1.IsMarkerChild = true;
                    ((Marker)element1).Draw(g, 0);
                }
            }

            if (markerEndUrl.Length > 0) {
                angle = (float)(180 * Math.Atan2(points1[num33].Y - points1[num3].Y, points1[num33].X - points1[num3].X) / Math.PI);

                element1 = (Marker)NodeFunc.GetRefNode(markerEndUrl, this.OwnerDocument);
                if (element1 is Marker) {
                    ((Marker)element1).GraphTransform.Matrix = new Matrix();
                    Matrix matrix1 = ((Marker)element1).MarkerTransForm;

                    matrix1.Rotate(angle);
                    matrix1.Translate(points1[num33].X, points1[num33].Y, MatrixOrder.Append);
                    element1.GraphStroke = this.GraphStroke;
                    element1.IsMarkerChild = true;
                    ((Marker)element1).Draw(g, 0);
                }
            }
            g.EndContainer(container1);
        }
Beispiel #42
0
		public static GraphicsContainer Rotate(Graphics g, float angle, PointF center)
		{
			GraphicsContainer gcr = g.BeginContainer();
			RotateMatrix m = Rotate(angle, center.X, center.Y);
			g.Transform = m.Matrix;
			return gcr;
		}
Beispiel #43
0
        public override void Draw(Graphics g, int time)
        {
            if (base.DrawVisible)
            {
                Matrix matrix1 = base.Transform.Matrix.Clone();

                GraphicsContainer container1 = g.BeginContainer();

                g.SmoothingMode = base.OwnerDocument.SmoothingMode;

                Matrix matrix2 = base.GraphTransform.Matrix.Clone();
                base.GraphTransform.Matrix.Multiply(matrix1, MatrixOrder.Prepend);

                ClipAndMask.ClipPath.Clip(g, time, this);
                bool flag1 = base.Visible;
                if (!base.Visible)
                {
                    g.SetClip(Rectangle.Empty);
                }
                float single1 = this.Opacity;
                if (this.svgAnimAttributes.ContainsKey("fill-opacity"))
                {
                    single1 = Math.Min(single1, (float) this.svgAnimAttributes["fill-opacity"]);
                }
                ISvgBrush brush1 = this.GraphBrush;
                Stroke stroke1 =this.graphStroke;
                using (GraphicsPath path1 = (GraphicsPath) this.GPath.Clone())
                {
                    path1.Transform(base.GraphTransform.Matrix);
                    if (!base.ShowBound)
                    {
                        if (this.IsMarkerChild) {
                            Marker marker= this.ParentNode as Marker;
                            this.IsChanged = false;
                            this.pretime = time;
                            stroke1 = marker.GraphStroke;
                            if (brush1 != null && !brush1.IsEmpty())
                                brush1 = marker.GraphBrush;

                        }
                        if (((brush1 != null) && !(this is Line)) && !(this is Polyline)) {
                            brush1.Paint(path1, g, time, single1);
                        }

                        stroke1.Paint(g, this, path1, time);

                        if(this is Polyline)
                        {
                            if (LineType == "1") {
                                //ƽ���ߣ�
                                using (Pen p = new Pen(brush1.Pen.Color)) {
                                    p.Width = this.graphStroke.StrokePen.Width;
                                    p.CompoundArray = new float[] { 0f, 0.1f, 0.9f, 1f };
                                    g.DrawPath(p, path1);
                                }
                            } else if(LineType == "2") {//��·Ч��
                                using (Pen p = new Pen(Color.FromArgb(120,120,120))) {
                                    p.Width = this.graphStroke.StrokePen.Width;
                                    p.CompoundArray = new float[] { 0f, 0.1f, 0.9f, 1f };
                                    g.DrawPath(p, path1);
                                }
                            }
                        }
                    }
                    else
                    {
                        g.DrawPath(new Pen(base.BoundColor), path1);
                    }
                    this.DrawConnect(g);
                }
                matrix1.Dispose();
                ClipAndMask.ClipPath.DrawClip(g, time, this);
                g.EndContainer(container1);
                this.pretime = time;
            }
        }
            public override void Draw(Graphics graphics)
            {
                GraphicsContainer graphicsState = graphics.BeginContainer();

                Rectangle bounds = Bounds;
                using (Region clipRegion = new Region(new Rectangle(bounds.X, bounds.Y, bounds.Width + 1, bounds.Height + 1)))
                {
                    graphics.Clip = clipRegion;

                    StringFormat format = new StringFormat();
                    format.Alignment = StringAlignment.Center;
                    format.LineAlignment = StringAlignment.Center;
                    format.Trimming = StringTrimming.Character;
                    format.FormatFlags = StringFormatFlags.NoWrap;

                    int visibleItems = MaxVisibleItems;
                    int scrollPosition = ScrollPosition;
                    for (int itemIndex = scrollPosition; itemIndex < Items.Count && itemIndex < (scrollPosition + visibleItems); itemIndex++)
                    {
                        ItemInfo itemInfo = Items[itemIndex];
                        Rectangle itemRectangle = GetItemBounds(itemInfo);

                        int margin = itemRectangle.Width / 5;
                        GraphicsPath[] graphicsPath = ActivityDesignerPaint.GetPagePaths(itemRectangle, margin, DesignerContentAlignment.TopRight);
                        using (GraphicsPath pagePath = graphicsPath[0])
                        using (GraphicsPath pageFoldPath = graphicsPath[1])
                        {
                            Brush pageBrush = Brushes.White;
                            if (SelectedItem == itemInfo)
                                pageBrush = PageStrip.SelectionBrush;
                            else if (HighlitedItem == itemInfo)
                                pageBrush = PageStrip.HighliteBrush;

                            graphics.FillPath(pageBrush, pagePath);
                            graphics.DrawPath(Pens.DarkBlue, pagePath);
                            graphics.FillPath(Brushes.White, pageFoldPath);
                            graphics.DrawPath(Pens.DarkBlue, pageFoldPath);

                            if (itemInfo.Image == null)
                            {
                                itemRectangle.Y += margin;
                                itemRectangle.Height -= margin;
                                int index = itemIndex + 1;
                                graphics.DrawString(index.ToString(CultureInfo.CurrentCulture), Control.DefaultFont, SystemBrushes.ControlText, (RectangleF)itemRectangle, format);
                            }
                            else
                            {
                                itemRectangle.Y += margin; itemRectangle.Height -= margin;
                                itemRectangle.X += (itemRectangle.Width - itemRectangle.Height) / 2;
                                itemRectangle.Width = itemRectangle.Height;
                                itemRectangle.Inflate(-2, -2);
                                ActivityDesignerPaint.DrawImage(graphics, itemInfo.Image, itemRectangle, DesignerContentAlignment.Center);
                            }
                        }
                    }
                }

                graphics.EndContainer(graphicsState);
            }