DrawLine() public method

public DrawLine ( Pen pen, Point pt1, Point pt2 ) : void
pen Pen
pt1 Point
pt2 Point
return void
コード例 #1
1
ファイル: Axis.cs プロジェクト: ElmarXCV/ComputerGraphics
        public void Draw(Graphics g)
        {
            Pen p = new Pen(Color.Green, 1f);

            g.DrawLine(p, 0, height / 2, width, height / 2);
            g.DrawLine(p, width / 2, 0, width / 2, height);
        }
コード例 #2
1
ファイル: FreeHandRegion.cs プロジェクト: andre-d/ShareXYZ
        protected override void Draw(Graphics g)
        {
            if (points.Count > 2)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;

                if (Config.UseDimming)
                {
                    using (Region region = new Region(regionFillPath))
                    {
                        g.Clip = region;
                        g.FillRectangle(lightBackgroundBrush, ScreenRectangle0Based);
                        g.ResetClip();
                    }
                }

                g.DrawPath(borderPen, regionFillPath);
                g.DrawPath(borderDotPen, regionFillPath);
                g.DrawLine(borderPen, points[points.Count - 1], points[0]);
                g.DrawLine(borderDotPen, points[points.Count - 1], points[0]);
                g.DrawRectangleProper(borderPen, currentArea);
            }

            base.Draw(g);
        }
コード例 #3
1
        public static void RepertoryImage(Graphics drawDestination)
        {
            StringFormat itemStringFormat = new StringFormat();
            RectangleF itemBox = new RectangleF(10, 30, 42, 10);
            RectangleF itemBox2 = new RectangleF(60, 48, 10, 10);
            itemStringFormat.Alignment = StringAlignment.Center;
            itemStringFormat.LineAlignment = StringAlignment.Far;
            drawDestination.DrawLine(Pens.LightGray,10,10,10,70);
            if (mMscStyle == MscStyle.SDL){
                PointF[] capPolygon = new PointF[3];
                capPolygon[0] = new PointF(61, 40);
                capPolygon[1] = new PointF(53, 44);
                capPolygon[2] = new PointF(53, 36);
                drawDestination.FillPolygon(Brushes.Black,capPolygon);
                drawDestination.DrawString("Lost",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
                drawDestination.DrawString("g",new Font("Arial",8),Brushes.Black,itemBox2,itemStringFormat);
                drawDestination.DrawLine(Pens.Black,10, 40, 60,40);
                drawDestination.FillEllipse(Brushes.Black, new RectangleF(60,35, 10,10));
            }
            else if(mMscStyle == MscStyle.UML2){

                drawDestination.DrawString("Lost",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
                drawDestination.DrawString("g",new Font("Arial",8),Brushes.Black,itemBox2,itemStringFormat);
                drawDestination.DrawLine(Pens.Black,10, 40, 60,40);
                drawDestination.DrawLine(Pens.Black,60, 40, 54,43);
                drawDestination.DrawLine(Pens.Black,60, 40, 54,37);
                drawDestination.FillEllipse(Brushes.Black, new RectangleF(60,35, 10,10));

            }
            itemStringFormat.Dispose();
        }
コード例 #4
1
		internal override void Draw(Graphics g)
		{
			IsInvalidated = false;

			Rectangle r = BaseElement.GetUnsignedRectangle(new Rectangle(location, size));

			Point[] points = new Point[5];
			points[0] = new Point(r.X + 0, r.Y + 0);
			points[1] = new Point(r.X + 0, r.Y + r.Height);
			points[2] = new Point(r.X + r.Width, r.Y + r.Height);

			//Fold
			points[3] = new Point(r.X + r.Width, r.Y + foldSize.Height);
			points[4] = new Point(r.X + r.Width - foldSize.Width, r.Y + 0);

			//foreach(Point p in points) p.Offset(location.X, location.Y);

			g.FillPolygon(GetBrush(r), points, FillMode.Alternate);
			g.DrawPolygon(new Pen(borderColor, borderWidth), points);

			g.DrawLine(new Pen(borderColor, borderWidth),
			           new Point(r.X + r.Width - foldSize.Width, r.Y + foldSize.Height),
			           new Point(r.X + r.Width, r.Y + foldSize.Height));

			g.DrawLine(new Pen(borderColor, borderWidth),
			           new Point(r.X + r.Width - foldSize.Width, r.Y + 0),
			           new Point(r.X + r.Width - foldSize.Width, r.Y + 0 + foldSize.Height));
		}
コード例 #5
1
ファイル: FreeHandRegion.cs プロジェクト: TreeSeed/ShareX
        protected override void Draw(Graphics g)
        {
            if (points.Count > 2)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;

                borderDotPen.DashOffset = (float)timer.Elapsed.TotalSeconds * 10;
                borderDotPen2.DashOffset = 5 + (float)timer.Elapsed.TotalSeconds * 10;

                using (Region region = new Region(regionFillPath))
                {
                    g.Clip = region;
                    g.FillRectangle(lightBackgroundBrush, ScreenRectangle0Based);
                    g.ResetClip();
                }

                g.DrawPath(borderDotPen, regionFillPath);
                g.DrawPath(borderDotPen2, regionFillPath);
                g.DrawLine(borderDotPen, points[points.Count - 1], points[0]);
                g.DrawLine(borderDotPen2, points[points.Count - 1], points[0]);
                g.DrawRectangleProper(borderPen, currentArea);
            }

            base.Draw(g);
        }
コード例 #6
1
		/// <summary></summary>
		/// <param name="box"></param>
		/// <param name="g"></param>
		protected override void PaintThisProgress(Rectangle box, Graphics g) {
			try {
				box.Width -= 1;
				box.Height -= 1;
			} catch {}
			if (box.Width <= 1) {
				return;
			}

			g.FillRectangle(brush, box);
			Rectangle innerBox = box;
			innerBox.Inflate(-1, -1);
			g.DrawRectangle(inner, innerBox);
			g.DrawLine(outer, box.X, box.Y, box.Right, box.Y);
			g.DrawLine(outer, box.X, box.Y, box.X, box.Bottom);
			g.DrawLine(edge, box.X, box.Bottom, box.Right, box.Bottom);

			if (gloss != null) {
				gloss.PaintGloss(box, g);
			}

			if (showEdge) {
				g.DrawLine(edge, box.Right, box.Y, box.Right, box.Bottom);
			}
		}
コード例 #7
0
ファイル: Plotter.cs プロジェクト: huynhdn/Weiler-Atherton
 private static void DrawAxis(Graphics graphics)
 {
     Brush b = new SolidBrush(Color.FromArgb(128, 0, 0, 0));
     Pen p = new Pen(b, 1);
     graphics.DrawLine(p, 0, imageSideSize / 2, imageSideSize, imageSideSize / 2);
     graphics.DrawLine(p, imageSideSize / 2, 0, imageSideSize / 2, imageSideSize);
 }
コード例 #8
0
    public override void Paint(System.Drawing.Graphics g, double x, double y, double scale)
    {
        double scaledRadius = this.Radius * scale;

        if ((x + scaledRadius < g.VisibleClipBounds.Left || x - scaledRadius > g.VisibleClipBounds.Right)
            &&
            (y + scaledRadius < g.VisibleClipBounds.Top || y - scaledRadius < g.VisibleClipBounds.Bottom))
        {
            return;
        }

        Vector orientation = this.Orientation.Copy();

        if (this.Radius == 0)
        {
            g.DrawLine(this.Pen, (float)x, (float)y, (float)(x + 1), (float)(y));
        }
        else
        {
            scaledRadius = Math.Max(Math.Ceiling(scaledRadius), 0.1);
            g.DrawEllipse(this.Pen,
                          (float)(x - scaledRadius),
                          (float)(y - scaledRadius),
                          (float)scaledRadius * 2,
                          (float)scaledRadius * 2);

            orientation *= scaledRadius;
            float x0 = (float)(x + (orientation * 0.9).X);
            float y0 = (float)(y + (orientation * 0.9).Y);
            float x1 = (float)(x + (orientation * 1.2).X);
            float y1 = (float)(y + (orientation * 1.2).Y);

            g.DrawLine(this.Pen, x0, y0, x1, y1);
        }
    }
コード例 #9
0
ファイル: GraphMaster.cs プロジェクト: Suhoy95/IsoclineShower
 public void DrawSolution(Graphics g,  Func<double, double, double> dy, double x0, double y0)
 {
     double x = x0, y = y0, step = 0.001;
     while(x <= max)
     {
         var k = dy(x, y);
         var nx = x + step;
         var ny = y + step * k;
         try
         {
             g.DrawLine(Pens.Black, Transform(x, y), Transform(nx, ny));
         }
         catch { };
         x = nx; y = ny;
     }
     x = x0; y = y0;
     while (x >= min)
     {
         var k = dy(x, y);
         var nx = x - step;
         var ny = y - step * k;
         try
         {
             g.DrawLine(Pens.Black, Transform(x, y), Transform(nx, ny));
         }
         catch { };
         x = nx; y = ny;
     }
 }
コード例 #10
0
        public override void ForceUpdate(Graphics g)
        {
            base.ForceUpdate(g);

            g.DrawLine(mLinePen, 0.0f, Size.Height * 0.5f, Size.Width, Size.Height * 0.5f);
            g.DrawLine(mLinePen, Size.Width * 0.5f, 0, Size.Width * 0.5f, Size.Height);
        }
コード例 #11
0
 public override void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect)
 {
     base.Draw(g, worldRect, canvasRect);
     var pen = new Pen(UpLineColor, LineWidth);
     var pen2 = new Pen(DownLineColor, LineWidth);
     pen.Alignment = PenAlignment.Center;
     pen2.Alignment = PenAlignment.Center;
     using (pen)
     {
         using (pen2)
         {
             for (int i = 0; i < Data.Count; i++)
             {
                 Pen pen3 = Data[i].open <= Data[i].close ? pen : pen2;
                 double xValue = i;
                 Point point3 =
                     Conversion.WorldToScreen(new PointD(xValue, (double)Data[i].low), worldRect,
                                                           canvasRect).Round();
                 Point point4 =
                     Conversion.WorldToScreen(new PointD(xValue, (double)Data[i].high), worldRect,
                                                           canvasRect).Round();
                 Point point =
                     Conversion.WorldToScreen(new PointD(xValue - _tickWidth, (double)Data[i].open), worldRect,
                                                           canvasRect).Round();
                 Point point2 =
                     Conversion.WorldToScreen(new PointD(xValue + _tickWidth, (double)Data[i].close),
                                                           worldRect, canvasRect).Round();
                 g.DrawLine(pen3, point3.X, point4.Y, point3.X, point3.Y);
                 g.DrawLine(pen3, point.X, point.Y, point3.X, point.Y);
                 g.DrawLine(pen3, point3.X, point2.Y, point2.X, point2.Y);
             }
         }
     }
 }
コード例 #12
0
ファイル: HotPixelCorrector.cs プロジェクト: hpavlov/tangra3
        public static void DrawOverlay(Graphics g, int topNumCandidates, bool showPeakPixels)
        {
            if (s_CandidateScores != null)
            {
                s_TopCandidatesToTake = topNumCandidates;

                var hotPixelsList = s_Candidates.Take(topNumCandidates);
                if (m_ShowHotPixelPositions)
                {
                    foreach (ImagePixel pixel in hotPixelsList)
                    {
                        g.DrawEllipse(Pens.Yellow, pixel.X - 5, pixel.Y - 5, 10, 10);
                    }
                }

                if (showPeakPixels && topNumCandidates < s_Candidates.Count())
                {
                    for (int i = topNumCandidates; i < s_Candidates.Length; i++)
                    {
                        ImagePixel pixel= s_Candidates[i];
                        g.DrawLine(Pens.Pink, pixel.X - 5, pixel.Y, pixel.X + 5, pixel.Y);
                        g.DrawLine(Pens.Pink, pixel.X, pixel.Y - 5, pixel.X, pixel.Y + 5);
                        g.DrawString(s_CandidateScores[i].ToString("0.00"), s_Font, Brushes.Pink, pixel.X + 1, pixel.Y - 10);
                    }
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// Draws the lines of the X and Y axes, and draws the hash marks for both lines.
        /// </summary>
        /// <param name="g">The <see cref="Graphics"/> instance to draw the lines on.</param>
        public void DrawAxes(Graphics g)
        {
            Pen black = Pens.Black;

            // X axis
            g.DrawLine(black,
                       (int)Math.Ceiling(Window.MaximumX * XScale),
                       0,
                       (int)Math.Floor(Window.MinimumX * XScale),
                       0);

            // Y axis
            g.DrawLine(black,
                       0,
                       (int)Math.Ceiling(Window.MaximumY * YScale),
                       0,
                       (int)Math.Floor(Window.MinimumY * YScale));

            if (Parent.EnableDynamicTickMarks)
            {
                DrawDynamicTicks(g);
            }
            else
            {
                DrawStaticTicks(g);
            }
        }
コード例 #14
0
        protected override void PaintSquare(Graphics graphics, Rectangle clipRectangle, int pipeWidth, bool isHighlighted, bool isFrozen, bool isFlooded)
        {
            /* pipe brush - if flooded, it's red, otherwise silver */
            Brush pipeBrush = isFlooded ? Brushes.Red : Brushes.Silver;

            int x = (clipRectangle.Width - pipeWidth) / 2;
            int y = clipRectangle.Y;
            int w = pipeWidth;
            int h = clipRectangle.Height - x;

            /* pipe rectangle, first upside */
            Rectangle pipeRectangle = new Rectangle(x, y, w, h);
            graphics.FillRectangle(pipeBrush, pipeRectangle);

            graphics.DrawLine(new Pen(Color.Gray, BORDER_WIDTH), new Point(x, y), new Point(x, y + h - pipeWidth));
            graphics.DrawLine(new Pen(Color.Gray, BORDER_WIDTH), new Point(x + w, y), new Point(x + w, y + h));

            x = clipRectangle.X;
            y = (clipRectangle.Height - pipeWidth) / 2;
            w = clipRectangle.Width - y;
            h = pipeWidth;

            /* pipe rectangle, second leftside */
            pipeRectangle = new Rectangle(x, y, w - BORDER_WIDTH, h);
            graphics.FillRectangle(pipeBrush, pipeRectangle);

            graphics.DrawLine(new Pen(Color.Gray, BORDER_WIDTH), new Point(x, y), new Point(x + w - pipeWidth, y));
            graphics.DrawLine(new Pen(Color.Gray, BORDER_WIDTH), new Point(x, y + h), new Point(x + w, y + h));
        }
コード例 #15
0
ファイル: Adventurer.cs プロジェクト: Gluestick/AIssignment
 public override void Paint(Graphics g)
 {
     if (_path != null)
     {
         var enumerator = _path.Path.GetEnumerator();
         foreach (GraphEdge edge in _path.ConsideredEdges)
         {
             g.DrawLine(ConsideredEdgePen,
                 (int)edge.Source.Position.X, (int)edge.Source.Position.Y,
                 (int)edge.Destination.Position.X, (int)edge.Destination.Position.Y
             );
         }
         enumerator.MoveNext();
         GraphNode last = enumerator.Current;
         while (enumerator.MoveNext())
         {
             g.DrawLine(PathPen,
                 (int)last.Position.X, (int)last.Position.Y,
                 (int)enumerator.Current.Position.X, (int)enumerator.Current.Position.Y
             );
             last = enumerator.Current;
         }
     }
     _spriteSet.PaintAt(g, this.Position);
 }
コード例 #16
0
ファイル: HistogramDrawer.cs プロジェクト: MihanEntalpo/HOLO
        public void Draw(Histogram hist, Graphics gr, Rectangle bounds)
        {
            var w = bounds.Width;
            var kx = 1f / bounds.Width;
            var ky = 1f * bounds.Height;
            var cy = bounds.Top + bounds.Height;
            var cx = bounds.Left;

            var ddd = hist[1f];

            var max = 0f;

            for (float i = 0; i <= 1; i += 1f / w)
            {
                var v = hist[i];
                if (v > max)
                    max = v;
            }

            ky = bounds.Height / max;

            using (var pen = new Pen(ForeColor))
                for (float i = 0; i <= 1; i += 1f/w)
                {
                    var x = i * w;
                    var y = hist[i] * ky;
                    gr.DrawLine(pen, cx + x, cy, cx + x, cy - y);
                }

            using (var pen = new Pen(ForeColor))
                gr.DrawLine(pen, cx, cy, cx + w, cy);
        }
コード例 #17
0
ファイル: Form1.cs プロジェクト: bzamecnik/bokehlab
        private void PaintLinearBench(Graphics g)
        {
            int radius = (int) circleRadius;
            DrawCircle(g, Pens.Blue, new Point(), radius);

            // draw the optical border
            g.DrawLine(new Pen(Color.Black, 4.0f), new Point(-radius, 0), new Point(radius, 0));

            double eta = Bench.RefractiveIndexAir / Bench.RefractiveIndexGlass;
            double criticalAngle = (eta > 1.0) ? Math.PI + Math.Asin(1 / eta) : Math.Asin(eta);
            SphericLens.Vector criticalAngleVector = new SphericLens.Vector() { Phi = criticalAngle, Radius = radius };
            Point criticalAnglePoint = SphericPointToFormsPoint(SphericLens.Point.FromVector(-criticalAngleVector));
            g.DrawLine(Pens.Red, new Point(), criticalAnglePoint);
            criticalAnglePoint.X *= -1;
            g.DrawLine(Pens.Red, new Point(), criticalAnglePoint);

            // draw the normal
            g.DrawLine(Pens.Brown, new Point(), new Point(0, (int)Bench.Normal.Radius));

            // draw the incomint ray
            g.DrawLine(Pens.Green, new Point(), SphericPointToFormsPoint(SphericLens.Point.FromVector(Bench.Direction)));

            // draw the refracted ray
            g.DrawLine(Pens.Blue, new Point(), SphericPointToFormsPoint(SphericLens.Point.FromVector(Bench.RefractedDirection)));
        }
コード例 #18
0
ファイル: FATabStripCloseButton.cs プロジェクト: tbalci/EFPT
        public void DrawCross(Graphics g)
        {
            if (isMouseOver)
            {
                Color fill = renderer.ColorTable.ButtonSelectedHighlight;

                g.FillRectangle(new SolidBrush(fill), crossRect);

                Rectangle borderRect = crossRect;

                borderRect.Width--;
                borderRect.Height--;

                g.DrawRectangle(SystemPens.Highlight, borderRect);
            }

            using (Pen pen = new Pen(Color.Black, 1.6f))
            {
                g.DrawLine(pen, crossRect.Left + 3, crossRect.Top + 3,
                    crossRect.Right - 5, crossRect.Bottom - 4);

                g.DrawLine(pen, crossRect.Right - 5, crossRect.Top + 3,
                    crossRect.Left + 3, crossRect.Bottom - 4);
            }
        }
コード例 #19
0
        public void Draw(Graphics g)
        {
            g.Clear(Color.Gray);

            PointF cellSize = new PointF((float)Size.X / (ChessGameField.FIELD_SIZE), (float)Size.Y / (ChessGameField.FIELD_SIZE));

            for (int i = 0; i <= ChessGameField.FIELD_SIZE; ++i)
            {
                g.DrawLine(Pens.Black, Pos.X + i * cellSize.X, Pos.Y, Pos.X + i * cellSize.X, Pos.Y + Size.Y);
            }

            for (int i = 0; i <= ChessGameField.FIELD_SIZE; ++i)
            {
                g.DrawLine(Pens.Black, Pos.X, Pos.Y + i * cellSize.Y, Pos.X + Size.X, Pos.Y + i * cellSize.Y);
            }

            Field.ForEachCell((pos, cell) => { if (cell.figure != null) cell.figure.Draw(g, GetColor(cell.figure.GetOwner()), GetCellPos(pos, cellSize), cellSize); return true; });

            if (State == ActionState.Selected)
            {
                PointF pos = GetCellPos(SelectedPoint, cellSize);
                Pen pen = new Pen(Brushes.Green, 2);
                int border = 4;
                g.DrawRectangle(pen, new Rectangle((int)pos.X + border + 1, (int)pos.Y + border + 1, (int)cellSize.X - border*2, (int)cellSize.Y - border*2));
            }
        }
コード例 #20
0
        public override void Draw(Graphics g)
        {
            if (this.lineComponent.IsSelected)
            {
                g.DrawLine(ViewFactory.BoundingBoxPen, this.lineComponent.StartPoint.X, this.lineComponent.StartPoint.Y, this.lineComponent.ControlPoint1.X, this.lineComponent.ControlPoint1.Y);
                g.DrawLine(ViewFactory.BoundingBoxPen, this.lineComponent.EndPoint.X, this.lineComponent.EndPoint.Y, this.lineComponent.ControlPoint2.X, this.lineComponent.ControlPoint2.Y);
            }
            if (this.lineComponent.ParentMoving)
            {
                g.DrawBezier(ViewFactory.LinePen,
                    this.lineComponent.StartPoint.MakePointF(),
                    this.lineComponent.ControlPoint1.MakePointF(),
                    this.lineComponent.ControlPoint2.MakePointF(),
                    this.lineComponent.EndPoint.MakePointF());
            }
            else
            {
                g.DrawLines(ViewFactory.LinePen, this.lineComponent.points.ToArray());
                /*DrawPoint(g, new FlowChartPoint(points[points.Count/2].X,points[points.Count/2].Y), 
                    GraphicsSettings.LabelPen, GraphicsSettings.EdgeBoxWidth);*/
            }

            DrawArrow(g, this.lineComponent.EndPoint, this.lineComponent.ControlPoint2,
                ViewFactory.ArrowBrush,
                ViewFactory.ArrowPen,
                ViewFactory.ArrowLength);

            if (this.lineComponent.IsSelected)
            {
                DrawPoint(g, this.lineComponent.ControlPoint1, ViewFactory.EdgePen, ViewFactory.EdgeBoxWidth);
                DrawPoint(g, this.lineComponent.ControlPoint2, ViewFactory.EdgePen, ViewFactory.EdgeBoxWidth);
            }
            base.Draw(g);
        }
コード例 #21
0
ファイル: Square.cs プロジェクト: jappeace/hw-isgp-xna-pract3
 public void Draw(Graphics g)
 {
     g.DrawLine(Pens.Red, new Point((int)_v1.x + 250, (int)_v1.y + 250), new Point((int)_v2.x + 250, (int)_v2.y + 250));
     g.DrawLine(Pens.Red, new Point((int)_v2.x + 250, (int)_v2.y + 250), new Point((int)_v3.x + 250, (int)_v3.y + 250));
     g.DrawLine(Pens.Red, new Point((int)_v3.x + 250, (int)_v3.y + 250), new Point((int)_v4.x + 250, (int)_v4.y + 250));
     g.DrawLine(Pens.Red, new Point((int)_v4.x + 250, (int)_v4.y + 250), new Point((int)_v1.x + 250, (int)_v1.y + 250));
 }
コード例 #22
0
		public static void PaindCircleWithUpArrows(Graphics g, Rectangle rect, float thickness, Color color)
		{
			using (Pen pen = new Pen(color, thickness))
			{
				g.DrawEllipse(pen, rect);
				rect.Inflate(1, 1);
				int x = rect.Width;
				int y = rect.Height;
				Point p1 = new Point();
				Point p2 = new Point();

				p1.X = (3*x)/8;
				p1.Y = y/2;
				p2.X = x/2;
				p2.Y = y/4;
				g.DrawLine(pen, p1, p2);


				p1.X = (5*x)/8;
				p1.Y = y/2;
				g.DrawLine(pen, p2, p1);

				p1.X = (3*x)/8;
				p1.Y = (3*y)/4;
				p2.X = x/2;
				p2.Y = y/2;
				g.DrawLine(pen, p1, p2);


				p1.X = (5*x)/8;
				p1.Y = 3*y/4;
				g.DrawLine(pen, p2, p1);
			}
		}
コード例 #23
0
        /// <summary>
        /// Draw rectangle
        /// </summary>
        /// <param name="g"></param>
        public override void Draw(Graphics g)
        {
            Pen pen = new Pen(Color, PenWidth);

            Rectangle _rect = new Rectangle();
            _rect = DrawRectangle.GetNormalizedRectangle(Rectangle);

            int x = _rect.X;
            int y = _rect.Y;
            int w = _rect.Width;
            int h = _rect.Height;
            int wArc = (w/6);
            int wArc2 = wArc * 2;
            int wReta = w - wArc;

            // g.DrawArc(pen, DrawRectangle.GetNormalizedRectangle(Rectangle), -270, 180);
            g.DrawArc(pen, x - wArc, y, wArc2, h, 270, 180);
            g.DrawArc(pen, x - wArc + wReta, y, wArc2, h, 270, 180);

            Point SE = new Point(x, y);          //SuperiorEsquerdo
            Point SD = new Point(x + wReta, y);             //SuperiorDireito

            Point IE = new Point(x, y + h);      //InferioriEsquerdo
            Point ID = new Point(x + wReta, y + h);         //InferiorDireito

            g.DrawLine(pen, SE, SD);
            g.DrawLine(pen, IE, ID);

            //g.DrawRectangle(pen, x, y, w, h);

            pen.Dispose();
        }
コード例 #24
0
        public void DrawInto(Graphics g)
        {
            int cellWidth = Width / puzzle.Size;
            int cellHeight = Height / puzzle.Size;

            g.Clear(Color.White);

            for (int x = 1; x <= puzzle.Size - 1; x++)
            {
                g.DrawLine(Pens.Black, new Point(cellWidth * x, 0), new Point(cellWidth * x, Height));
                g.DrawLine(Pens.Black, new Point(0, cellHeight * x), new Point(Width, cellHeight * x));
            }

            for (int i = 0; i < puzzle.Size; i++)
            {
                for (int j = 0; j < puzzle.Size; j++)
                {
                    float y = cellHeight * i + cellHeight / 2 - font.Height / 2;
                    float x = cellWidth * j + cellWidth / 2 - font.Size / 2;

                    if (showSolution && puzzle.IsSolution(j, i))
                        g.FillRectangle(new SolidBrush(Color.FromArgb(100, Color.Yellow)), new Rectangle(new Point(cellWidth * j, cellHeight * i), new Size(cellWidth, cellHeight)));

                    g.DrawString(puzzle[i, j].ToString(), font, Brushes.Black, new PointF(x, y));
                }
            }
        }
コード例 #25
0
        public override void Paint(Graphics graphics)
        {
            Point lastPoint = this.StartPoint;
            bool firstLine = true;
            
            foreach (var item in this.Points)
            {
                if (firstLine)
                {
                    graphics.DrawLine(this.FirstLinePen, lastPoint, item.Center);
                    item.Paint(graphics);

                    firstLine = false;
                }
                else
                {
                    graphics.DrawLine(this.NormalLinePen, lastPoint, item.Center);
                    item.Paint(graphics);
                }

                lastPoint = item.Center;
            }

            // It depends on the way of creating the line, where to draw the arrow.
            if (this.CurrentLineDirection == LineDirection.OutputToInput)
                graphics.DrawLine(this.LastLinePen, lastPoint, this.EndPoint);
            else if (this.CurrentLineDirection == LineDirection.InputToOutput && !firstLine)
                graphics.DrawLine(this.NormalLinePen, lastPoint, this.EndPoint);
            else if (firstLine)
                graphics.DrawLine(this.FirstLinePen, lastPoint, this.EndPoint);         
        }
コード例 #26
0
       /// <summary>
       /// Draws the point symbol in the view
       /// </summary>
       /// <param name="g"></param>
       /// <param name="clip"></param>
       protected virtual void OnDraw(Graphics g, Rectangle clip)
       {
           if (_borderStyle == BorderStyle.Fixed3D)
           {
               g.DrawLine(Pens.White, 0, Height - 1, Width - 1, Height - 1);
               g.DrawLine(Pens.White, Width - 1, 0, Width - 1, Height - 1);
               g.DrawLine(Pens.Gray, 0, 0, 0, Height - 1);
               g.DrawLine(Pens.Gray, 0, 0, Width - 1, 0);
           }
           if (_borderStyle == BorderStyle.FixedSingle)
           {
               g.DrawRectangle(Pens.Black, 0, 0, Width - 1, Height - 1);
           }
           int w = Width;
           int h = Height;
           if (_symbolizer == null) return;
           int lineWidth = Convert.ToInt32(_symbolizer.GetWidth());
           if (lineWidth > 128) lineWidth = 128;
           if (lineWidth < 1) lineWidth = 1;
 
           GraphicsPath gp = new GraphicsPath();
           gp.AddLines(new[]{new Point(lineWidth, (h * 2) / 3), new Point(w/3, h / 3), new Point((w * 2) / 3, (h*2)/3), new Point(w - lineWidth, h/3)});
           _symbolizer.DrawPath(g, gp, 1);
         
       }
コード例 #27
0
        private void wypelniony()
        {
           
            bmp = new Bitmap((int)pbWIDTH, (int)pbHEIGHT);
            

            Point p1 = new Point((int)(pbWIDTH / 6), (int)(pbHEIGHT / 2));
            Point p2 = new Point((int)(pbWIDTH * 5 / 6), (int)(pbHEIGHT / 2));
            Point p1_25 = new Point(pbWIDTH / 3, pbHEIGHT / 4 * 3);
            Point p2_25 = new Point((int)(pbWIDTH / 3 * 2), (int)(pbHEIGHT / 4 * 3));
            Point p1_75 = new Point((int)(pbWIDTH / 3), (int)(pbHEIGHT / 4));
            Point p2_75 = new Point((int)(pbWIDTH / 3 * 2), (int)(pbHEIGHT / 4));
            Pen pen1 = new Pen(Brushes.Black, width_pen1);
            Pen pen2 = new Pen(Brushes.Black, width_pen2);

            

            g = Graphics.FromImage(bmp);
            g.Clear(Color.CornflowerBlue);
            g.FillRectangle(Brushes.White, new Rectangle(0, 0, pbWIDTH, pbHEIGHT - (int)(pbComplete * pbUnit)));
            g.DrawRectangle(pen1, 0, 0, pbWIDTH, pbHEIGHT);
            g.DrawLine(pen2, p1, p2);
            g.DrawLine(pen2, p1_25, p2_25);
            g.DrawLine(pen2, p1_75, p2_75);
            //g.DrawString(pbComplete + "%", new Font("Arial", pbHEIGHT / 5),Brushes.Black,new PointF(pbWIDTH/12,pbHEIGHT/4));
            this.Image = bmp;
            //return bmp;
        }
コード例 #28
0
    public virtual void  drawMatrix(bool[][] matrix)
    {
        if (image == null)
        {
            image = new System.Drawing.Bitmap(matrix.Length, matrix[0].Length, (System.Drawing.Imaging.PixelFormat)System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            //UPGRADE_TODO: Method 'java.awt.Component.setSize' was converted to 'System.Windows.Forms.Control.Size' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtComponentsetSize_int_int'"
            Size = new System.Drawing.Size(matrix.Length, matrix[0].Length);
        }
        System.Drawing.Graphics g2d = System.Drawing.Graphics.FromImage(image);
        g2d.setColor(java.awt.Color.WHITE);
        int width = Width;

        for (int x = 0; x < matrix.Length; x++)
        {
            g2d.DrawLine(SupportClass.GraphicsManager.manager.GetPen(g2d), x, 0, x, width);
        }
        g2d.setColor(java.awt.Color.BLACK);
        for (int x = 0; x < matrix.Length; x++)
        {
            for (int y = 0; y < matrix[0].Length; y++)
            {
                if (matrix[x][y] == true)
                {
                    g2d.DrawLine(SupportClass.GraphicsManager.manager.GetPen(g2d), x, y, x, y);
                }
            }
        }
        //UPGRADE_TODO: Method 'java.awt.Component.repaint' was converted to 'System.Windows.Forms.Control.Refresh' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtComponentrepaint'"
        Refresh();
    }
コード例 #29
0
        public void DrawCross(Graphics g)
        {
            if (this.IsMouseOver)
            {
                Color fill = this.renderer.ColorTable.ButtonSelectedHighlight;

                g.FillRectangle(new SolidBrush(fill), this.Rect);

                Rectangle borderRect = this.Rect;

                borderRect.Width--;
                borderRect.Height--;

                g.DrawRectangle(SystemPens.Highlight, borderRect);
            }

            using (Pen pen = new Pen(Color.Black, 1f))
            {
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
                g.DrawLine(pen, this.Rect.Left + 3, this.Rect.Top + 4,
                    this.Rect.Right - 6, this.Rect.Bottom - 4);
                g.DrawLine(pen, this.Rect.Left + 4, this.Rect.Top + 4,
                    this.Rect.Right - 5, this.Rect.Bottom - 4);

                g.DrawLine(pen, this.Rect.Right - 6, this.Rect.Top + 4,
                    this.Rect.Left + 3, this.Rect.Bottom - 4);
                g.DrawLine(pen, this.Rect.Right - 5, this.Rect.Top + 4,
                    this.Rect.Left + 4, this.Rect.Bottom - 4);
            }
        }
コード例 #30
0
        public override void Draw(RectangleF dirtyRect)
        {
            Graphics g = new Graphics();

            var ClientRectangle = new Rectangle((int)dirtyRect.X,
                                                (int)dirtyRect.Y,
                                                (int)dirtyRect.Width,
                                                (int)dirtyRect.Height);

            // Calculate the location and size of the drawing area
            // Within which we want to draw the graphics:
            //Rectangle ChartArea = ClientRectangle;
            Rectangle ChartArea = new Rectangle(50, 50,
                                                ClientRectangle.Width - 70, ClientRectangle.Height - 70);
            g.DrawRectangle(Pens.LightCoral, ChartArea);

            PlotArea = new Rectangle(ChartArea.Location, ChartArea.Size);
            PlotArea.Inflate(-offset, -offset);
            //Draw ClientRectangle and PlotArea using pen:
            g.DrawRectangle(Pens.Black, PlotArea);
            // Generate Sine and Cosine data points to plot:
            PointF[] pt1 = new PointF[nPoints];
            PointF[] pt2 = new PointF[nPoints];
            for (int i = 0; i < nPoints; i++)
            {
                pt1[i] = new PointF(i / 5.0f, (float)Math.Sin(i/5.0f));
                pt2[i] = new PointF(i / 5.0f, (float)Math.Cos(i/5.0f));
            }
            for (int i = 1; i < nPoints; i++)
            {
                g.DrawLine(Pens.Blue, Point2D(pt1[i - 1]), Point2D(pt1[i]));
                g.DrawLine(Pens.Red, Point2D(pt2[i - 1]), Point2D(pt2[i]));
            }
            g.Dispose();
        }
コード例 #31
0
ファイル: Map.Drawing.cs プロジェクト: SnakeSolidNL/tools
 private void drawBlock(int tx, int ty, int dir, Graphics g, Pen pen)
 {
     switch (dir)
     {
         case Directions.North:
             {
                 g.DrawLine(pen, Config.LineSize + bsize(tx), Config.LineSize / 2 + bsize(ty),
                     bsize(tx + 1), Config.LineSize / 2 + bsize(ty));
                 break;
             }
         case Directions.South:
             {
                 g.DrawLine(pen, Config.LineSize + bsize(tx), Config.LineSize / 2 + bsize(ty + 1),
                     bsize(tx + 1), Config.LineSize / 2 + bsize(ty + 1));
                 break;
             }
         case Directions.West:
             {
                 g.DrawLine(pen, Config.LineSize / 2 + bsize(tx), Config.LineSize + bsize(ty),
                     Config.LineSize / 2 + bsize(tx), bsize(ty + 1));
                 break;
             }
         case Directions.East:
             {
                 g.DrawLine(pen, Config.LineSize / 2 + bsize(tx + 1), Config.LineSize + bsize(ty),
                     Config.LineSize / 2 + bsize(tx + 1), bsize(ty + 1));
                 break;
             }
     }
 }
コード例 #32
0
ファイル: Triangle2D.cs プロジェクト: byfine/MatrixTransform
 public void Draw(Graphics g)
 {
     Pen pen = new Pen(Color.Red, 2);
     g.DrawLine(pen, A, B);
     g.DrawLine(pen, B, C);
     g.DrawLine(pen, C, A);
 }
コード例 #33
0
    private void CreateImage(string checkCode)
    {
        int iwidth = (int)(checkCode.Length * 25);

        System.Drawing.Bitmap   image = new System.Drawing.Bitmap(iwidth, 30);
        System.Drawing.Graphics g     = System.Drawing.Graphics.FromImage(image);
        System.Drawing.Font     f     = new System.Drawing.Font("Arial", 20, System.Drawing.FontStyle.Bold);
        System.Drawing.Brush    b     = new System.Drawing.SolidBrush(System.Drawing.Color.White);
        //g.FillRectangle(new System.Drawing.SolidBrush(Color.Blue),0,0,image.Width, image.Height);
        g.Clear(System.Drawing.Color.Blue);
        g.DrawString(checkCode, f, b, 3, 3);

        System.Drawing.Pen blackPen = new System.Drawing.Pen(System.Drawing.Color.Black, 0);
        Random             rand     = new Random();

        for (int i = 0; i < 5; i++)
        {
            int y = rand.Next(image.Height);
            g.DrawLine(blackPen, 0, y, image.Width, y);
        }

        System.IO.MemoryStream ms = new System.IO.MemoryStream();
        image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
        Response.ClearContent();
        Response.ContentType = "image/Jpeg";
        Response.BinaryWrite(ms.ToArray());
        g.Dispose();
        image.Dispose();
    }
コード例 #34
0
    public static string createModel(String[] array)
    {
        if (array.Length > 0)
        {
            System.Drawing.Bitmap   bm = new System.Drawing.Bitmap(400, array.Length * 90);
            System.Drawing.Graphics g  = System.Drawing.Graphics.FromImage(bm);
            g.Clear(System.Drawing.Color.White);
            int x = 100;
            int y = 10;
            System.Drawing.StringFormat f = new System.Drawing.StringFormat();
            f.Alignment     = System.Drawing.StringAlignment.Center;
            f.LineAlignment = System.Drawing.StringAlignment.Center;
            System.Drawing.Font font;
            System.Drawing.Drawing2D.LinearGradientBrush b = new System.Drawing.Drawing2D.LinearGradientBrush(new System.Drawing.Point(0, 40), new System.Drawing.Point(30, 130), System.Drawing.Color.GreenYellow, System.Drawing.Color.LemonChiffon);
            for (int i = 0; i < array.Length; i++)
            {
                font = new System.Drawing.Font("Arial Unicode MS", 10, System.Drawing.FontStyle.Regular);
                g.DrawImageUnscaled(System.Drawing.Image.FromFile(HttpContext.Current.Request.MapPath("tskOval.png")), x, y);
                g.DrawString(array[i].Substring(0, (array[i].Length > 52 ? 52 : array[i].Length)), font, System.Drawing.Brushes.Black, new System.Drawing.Rectangle(x + 30, y + 6, 172, 40), f);
                y += 85;
            }

            x = 100;
            y = 10;
            int y1, y2;
            for (int i = 1; i < array.Length; i++)
            {
                System.Drawing.Pen p = new System.Drawing.Pen(System.Drawing.Color.Black);
                p.Width = 1.5F;
                y1      = (((i) * 50) + y + ((i - 1) * 35));
                y2      = (((i) * 50) + y + ((i) * 35));
                g.DrawLine(p, 200, y1 + 2, 200, y2);
                System.Drawing.Point[] pns = new System.Drawing.Point[4];
                pns[0] = new System.Drawing.Point(195, y2 - 5);
                pns[1] = new System.Drawing.Point(200, y2);
                pns[2] = new System.Drawing.Point(205, y2 - 5);
                pns[3] = new System.Drawing.Point(195, y2 - 5);
                g.FillPolygon(System.Drawing.Brushes.Black, pns);

                // g.DrawString(((Node)SessionClass.Flow[i-1]).decision.Equals("True")?"Yes":"No", new System.Drawing.Font("Arial Unicode MS", 9, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, new System.Drawing.Point(205, y1 +6));
            }
            string res = HttpContext.Current.Server.MapPath("Results") + "\\User" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".png";
            bm.Save(res, System.Drawing.Imaging.ImageFormat.Png);
            return("Results/" + res.Replace(HttpContext.Current.Server.MapPath("Results") + "\\", ""));
        }
        else
        {
            return("");
        }
    }
コード例 #35
0
    private void drawRuler(Graphics g, int left, int right, int level)
    {
        if (level < 1)
        {
            return;
        }

        int mid = (left + right) / 2;

        /******************
         ***** Uncomment this section to see the drawing in slow motion
         *****Thread.Sleep( TimeSpan.FromMilliseconds(100) );
         ***********/
        g.DrawLine(drawingPen, mid, 80, mid, 80 - level * 5);

        drawRuler(g, left, mid - 1, level - 1);
        drawRuler(g, mid + 1, right, level - 1);
    }
コード例 #36
0
ファイル: Form1.cs プロジェクト: ibrahimnamdar/Lorenz-Chaos
        void DrawLorenzChaos(double a, double b, double r)
        {
            //double a = 10, b = (8.0 / 3.0), r = 28;     //standard values for lorenz model

            /*m defines the number of iterations of the for loop so the number of lines drawn
             * good idea to keep m inversely proportional to dt (the time interval). A smaller dt will
             * mean smaller lines so smoother overall drawing m=50000 and dt=0.0005 is a good starting point
             * that demonstrates chaos well*/
            double m = 500000, dt = 0.00055;

            //EVOLUTION VALUE FOR RUNGE_KUTTA METHOD
            //values for first particle
            double y11, y12, y13;
            double y21, y22, y23;
            double y31, y32, y33;
            double y41, y42, y43;
            double y51, y52, y53;
            double xi, yi, xf, yf;          //coordinates for drawing particle 1 trajectory

            double f10, f11, f12, f13;      //function values to be calculated,
            double f20, f21, f22, f23;      //for fxy (x>1) these are intermediate fn calculations at different
            double f30, f31, f32, f33;      //times in Runga Kutta

            //values for second particle
            double z11, z12, z13;
            double z21, z22, z23;
            double z31, z32, z33;
            double z41, z42, z43;
            double z51, z52, z53;
            double ai, bi, af, bf;          //coordinates for drawing particle 2 trajectory (these are badly named...)

            double g10, g11, g12, g13;      //equivalent of f values for particle 2
            double g20, g21, g22, g23;
            double g30, g31, g32, g33;

            //OTHER NEEDED QUANTITIES
            int    i;            //for loop iteration integer
            int    k1    = 20;   //scaling factors to make drawing fill form
            int    k2    = 9;
            int    y0    = 280;  //offset values to centre drawing on form
            int    x0    = 400;
            int    start = 10;   //starting position for calculations
            double diff  = 0.01; //initial displacement between two particles

            //starting positions for particles
            y11 = start;//particle 1
            y12 = start;
            y13 = start;

            z11 = start + diff;//particle 2
            z12 = start + diff;
            z13 = start + diff;

            //initial coords for particles at t=0
            xi = (y11) * k1 + x0;
            yi = (y12) * k2 + y0;
            ai = (z11) * k1 + x0;
            bi = (z12) * k2 + y0;
            for (i = 1; i <= m; i++)
            {
                f10 = a * (y12 - y11);
                f20 = r * y11 - y12 - y11 * y13;
                f30 = y11 * y12 - b * y13;

                y21 = y11 + f10 * dt / 2;               //finding y1 y2 y3 at the first
                y22 = y12 + f20 * dt / 2;               //fraction of dt
                y23 = y13 + f30 * dt / 2;

                f11 = a * (y22 - y21);
                f21 = r * y21 - y22 - y21 * y23;
                f31 = y21 * y22 - b * y23;

                y31 = y11 + f11 * dt / 2;               //finding y1 y2 y3 at the second
                y32 = y12 + f21 * dt / 2;               //fraction of dt
                y33 = y13 + f31 * dt / 2;

                f12 = a * (y32 - y31);
                f22 = r * y31 - y32 - y31 * y33;
                f32 = y31 * y32 - b * y33;

                y41 = y11 + f12 * dt;               //finding y1 y2 y3 at the third
                y42 = y12 + f22 * dt;               //fraction of dt
                y43 = y13 + f32 * dt;

                f13 = a * (y42 - y41);
                f23 = r * y41 - y42 - y41 * y43;
                f33 = y41 * y42 - b * y43;

                y51 = y11 + (f10 + 2 * f11 + 2 * f12 + f13) * dt / 6; //final y values at y(t+dt)
                y52 = y12 + (f20 + 2 * f21 + 2 * f22 + f23) * dt / 6; //then to be repesated in for loop for all steps
                y53 = y13 + (f30 + 2 * f31 + 2 * f32 + f33) * dt / 6;

                xf = (y51) * k1 + x0;
                yf = (y52) * k2 + y0;

                //second particle calculation
                g10 = a * (z12 - z11);
                g20 = r * z11 - z12 - z11 * z13;
                g30 = z11 * z12 - b * z13;

                z21 = z11 + g10 * dt / 2;               //finding y1 y2 y3 at the first
                z22 = z12 + g20 * dt / 2;               //fraction of dt
                z23 = z13 + g30 * dt / 2;

                g11 = a * (z22 - z21);
                g21 = r * z21 - z22 - z21 * z23;
                g31 = z21 * z22 - b * z23;

                z31 = z11 + g11 * dt / 2;               //finding y1 y2 y3 at the second
                z32 = z12 + g21 * dt / 2;               //fraction of dt
                z33 = z13 + g31 * dt / 2;

                g12 = a * (z32 - z31);
                g22 = r * z31 - z32 - z31 * z33;
                g32 = z31 * z32 - b * z33;

                z41 = z11 + g12 * dt;               //finding y1 y2 y3 at the third
                z42 = z12 + g22 * dt;               //fraction of dt
                z43 = z13 + g32 * dt;

                g13 = a * (z42 - z41);
                g23 = r * z41 - z42 - z41 * z43;
                g33 = z41 * z42 - b * z43;

                z51 = z11 + (g10 + 2 * g11 + 2 * g12 + g13) * dt / 6; //final y values at y(t+dt)
                z52 = z12 + (g20 + 2 * g21 + 2 * g22 + g23) * dt / 6; //then to be repesated in for loop for all steps
                z53 = z13 + (g30 + 2 * g31 + 2 * g32 + g33) * dt / 6;

                af = (z51) * k1 + x0;
                bf = (z52) * k2 + y0;


                //DRAWING LINE JUST CALCULATED

                mut.WaitOne();
                System.Drawing.Graphics graphicsObj = Graphics.FromImage(offScrBuff);

                graphicsObj.DrawLine(Pens.Red, (int)xi, (int)yi, (int)xf, (int)yf);

                graphicsObj.DrawLine(Pens.RoyalBlue, (int)ai, (int)bi, (int)af, (int)bf);

                graphicsObj.Dispose();
                mut.ReleaseMutex();

                pictureBox1.Invalidate();


                //REDEFINING COORDS AND VALUES FOR NEXT LOOP
                //first particle
                xi  = (y51) * k1 + x0;
                yi  = (y52) * k2 + y0;
                y11 = y51;
                y12 = y52;
                y13 = y53;

                //second particle
                ai  = (z51) * k1 + x0;
                bi  = (z52) * k2 + y0;
                z11 = z51;
                z12 = z52;
                z13 = z53;

                /*even at 1 the below makes the program far too slow, need an alternative
                 * intention was for it to allow user to see the particle trajectories better*/
                //System.Threading.Thread.Sleep(1);
            }
        }
コード例 #37
0
    // originally from https://stackoverflow.com/questions/2042155/high-quality-graph-waveform-display-component-in-c-sharp,
    // adapted to use the pcm_f32le format and replace GDI+ with WPF drawing
    private BitmapSource _Draw_GDI(CancellationToken ct, double height, double width)
    {
        isDrawing       = true;
        reader.Position = 0;
        int bytesPerSample = (reader.WaveFormat.BitsPerSample / 8) * reader.WaveFormat.Channels;

        //Give a size to the bitmap; either a fixed size, or something based on the length of the audio
        System.Drawing.Bitmap   bitmap   = new System.Drawing.Bitmap((int)width, (int)height);
        System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);
        graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
        graphics.Clear(System.Drawing.Color.Transparent);
        System.Drawing.Pen bluePen = new System.Drawing.Pen(Constants.Editor.Waveform.ColourGDI);

        int samplesPerPixel = (int)(reader.Length / (double)(height * bytesPerSample));
        int bytesPerPixel   = bytesPerSample * samplesPerPixel;
        int bytesRead;

        byte[] waveData = new byte[bytesPerPixel];
        // draw each pixel of height
        for (int y = 0; y < height; y++)
        {
            bytesRead = reader.Read(waveData, 0, bytesPerPixel);
            if (bytesRead == 0)
            {
                break;
            }

            float low  = 0;
            float high = 0;
            // read all samples for this pixel and take the extreme values
            for (int n = 0; n < bytesRead; n += bytesPerSample)
            {
                float sample = BitConverter.ToSingle(waveData, n);
                if (sample < low)
                {
                    low = sample;
                }
                if (sample > high)
                {
                    high = sample;
                }
                if (ct.IsCancellationRequested)
                {
                    isDrawing = false;
                    return(null);
                }
            }
            float lowPercent  = (low + 1) / 2;
            float highPercent = (high + 1) / 2;
            float lowValue    = (float)width * lowPercent;
            float highValue   = (float)width * highPercent;
            graphics.DrawLine(bluePen, lowValue, (int)height - y, highValue, (int)height - y);
        }
        //bitmap.Save("out.bmp");
        // https://stackoverflow.com/questions/94456/load-a-wpf-bitmapimage-from-a-system-drawing-bitmap#1069509
        BitmapSource b = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight((int)width, (int)height));

        b.Freeze();
        isDrawing = false;
        return(b);
    }
コード例 #38
0
ファイル: Form1.cs プロジェクト: yavuzhanocak/CarInterface
            public void DrawLines(System.Drawing.Graphics Graphics)
            {
                Pen          majorTickPen = new Pen(LinearGauge.MajorTickMarkColor);
                Pen          minorTickPen = new Pen(LinearGauge.MinorTickMarkColor);
                Brush        brush        = new SolidBrush(LinearGauge.ForeColor);
                StringFormat sf           = new StringFormat();

                Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                majorTicksDistance     = ((LinearGauge.MaximumValue - LinearGauge.MinimumValue) / LinearGauge.MajorDifference);
                majorTicksCount        = ((int)(LinearGauge.MaximumValue - LinearGauge.MinimumValue) / (LinearGauge.MajorDifference)) + 1;
                double majorTickValue = LinearGauge.MinimumValue;
                float  tickPosition   = 25f;
                float  temp1          = 0;
                float  s = (LinearGauge.MaximumValue - LinearGauge.MinimumValue) % LinearGauge.MajorDifference;

                sf.Alignment     = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;
                float        minortickValue    = 0;
                float        tickPositionMinor = 0;
                GraphicsPath path  = new GraphicsPath();
                int          minor = LinearGauge.MinorTickCount;

                m_minorTicksPixels = ((this.LinearGauge.Height - 50) / majorTicksDistance);
                int x = this.LinearGauge.Width / 2;

                temp1 = 0;
                for (int L = 1; L <= majorTicksCount; L++)
                {
                    Graphics.DrawLine(majorTickPen, x, this.LinearGauge.Height - tickPosition, x - LinearGauge.MajorTicksHeight, this.LinearGauge.Height - tickPosition);
                    Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                    if (LinearGauge.ShowScaleLabel)
                    {
                        Graphics.DrawString(Math.Round(majorTickValue, 2).ToString(),
                                            LinearGauge.Font, brush, new PointF(x - LinearGauge.MajorTicksHeight - 25, this.LinearGauge.Height - tickPosition), sf);
                    }
                    if (L == majorTicksCount)
                    {
                        minor = (LinearGauge.MinorTickCount * (int)Math.Ceiling(s)) / LinearGauge.MajorDifference;
                    }
                    if (majorTickValue < LinearGauge.MaximumValue)
                    {
                        for (int S = 1; S <= minor; S++)
                        {
                            minortickValue    = (m_minorTicksPixels / (LinearGauge.MinorTickCount + 1)) * S;
                            tickPositionMinor = this.LinearGauge.Height - (minortickValue + temp1 + 25);
                            Graphics.DrawLine(minorTickPen, x, (float)tickPositionMinor, x - LinearGauge.MinorTickHeight, (float)tickPositionMinor);
                        }
                        temp1 = m_minorTicksPixels * L;
                    }

                    majorTickValue += LinearGauge.MajorDifference;
                    tickPosition   += m_minorTicksPixels;
                }
                Graphics.FillRectangle(new SolidBrush(LinearGauge.GaugeBaseColor), this.LinearGauge.Width / 2, start - 1, 1, (((this.majorTicksDistance)) * m_minorTicksPixels) + 2);
                if (this.LinearGauge.MinimumValue > 0)
                {
                    Graphics.FillRectangle(new SolidBrush(LinearGauge.ValueIndicatorColor), this.LinearGauge.Width / 2 + 10, start + (majorTicksDistance * m_minorTicksPixels) - (((LinearGauge.Value / LinearGauge.MajorDifference)) * m_minorTicksPixels), 5, (((LinearGauge.Value / LinearGauge.MajorDifference)) * m_minorTicksPixels) + 2);
                }
                else
                {
                    Graphics.FillRectangle(new SolidBrush(LinearGauge.ValueIndicatorColor), this.LinearGauge.Width / 2 + 10, start + (majorTicksDistance * m_minorTicksPixels) - ((((Math.Abs(this.LinearGauge.MinimumValue) + LinearGauge.Value) / LinearGauge.MajorDifference)) * m_minorTicksPixels), 5, ((((Math.Abs(this.LinearGauge.MinimumValue) + LinearGauge.Value) / LinearGauge.MajorDifference)) * m_minorTicksPixels) + 2);
                }
                brush.Dispose();
                minorTickPen.Dispose();
            }
コード例 #39
0
ファイル: Form1.cs プロジェクト: asvilatuna/complex-roots
        private void Calcular()
        {
            for (int k = 0; k < n; k++)
            {
                Decimal R = decimal.Round(Convert.ToDecimal(Roots * Math.Cos(((2 * k * Pi) + O) / n)), 3, MidpointRounding.AwayFromZero);

                Decimal I = decimal.Round(Convert.ToDecimal(Roots * Math.Sin(((2 * k * Pi) + O) / n)), 3, MidpointRounding.AwayFromZero);

                float r = (float)R;

                float i = (float)I;

                int midx = 660;

                int midy = 270;

                EspacioComplejo();

                Lapiz = new System.Drawing.Pen(System.Drawing.Color.Black);

                Vector = this.CreateGraphics();

                Vector.DrawLine(Lapiz, 440, midy, 890, midy);

                Vector.DrawLine(Lapiz, midx, 500, midx, 50);

                IMG.SetBounds(645, 30, 40, 15);

                IMG.Text = "Img(Z)";

                IMG.BackColor = Color.Transparent;

                this.Controls.Add(IMG);

                REAL.SetBounds(900, midy - 10, 60, 40);

                REAL.Text = "Real(Z)";

                this.Controls.Add(REAL);

                if (Roots <= 20)
                {
                    Lapiz.Color = System.Drawing.Color.Red;

                    Vector.DrawLine(Lapiz, midx, midy, midx + 20 * (float)Real, midy - 20 * (float)Img);

                    Lapiz.Color = System.Drawing.Color.Blue;

                    Vector.DrawLine(Lapiz, midx, midy, midx + 20 * r, midy - 20 * i);
                }
                else

                {
                    Lapiz.Color = System.Drawing.Color.Red;

                    Vector.DrawLine(Lapiz, midx, midy, midx + 20 * (float)Real, midy - 20 * (float)Img);

                    Lapiz.Color = System.Drawing.Color.Blue;

                    Vector.DrawLine(Lapiz, midx, midy, midx + r, midy - i);
                }


                if (R >= 0)

                {
                    if (I >= 0)


                    {
                        Results.Text += Environment.NewLine + " Evaluamos para k = " + k;

                        Results.Text += Environment.NewLine + "";

                        Results.Text += Environment.NewLine + " " + (Convert.ToString(R) + " + " + (Convert.ToString(I))) + " i";

                        Results.Text += Environment.NewLine + "";
                    }
                    else
                    {
                        Results.Text += Environment.NewLine + " Evaluamos para k = " + k;

                        Results.Text += Environment.NewLine + "";

                        Results.Text += Environment.NewLine + " " + (Convert.ToString(R) + " " + (Convert.ToString(I))) + " i";

                        Results.Text += Environment.NewLine + "";
                    }
                }
                else
                {
                    if (I >= 0)

                    {
                        Results.Text += Environment.NewLine + " Evaluamos para k = " + k;

                        Results.Text += Environment.NewLine + "";

                        Results.Text += Environment.NewLine + " " + (Convert.ToString(R) + " + " + (Convert.ToString(I))) + " i";

                        Results.Text += Environment.NewLine + "";
                    }
                    else
                    {
                        Results.Text += Environment.NewLine + " Evaluamos para k = " + k;

                        Results.Text += Environment.NewLine + "";

                        Results.Text += Environment.NewLine + " " + (Convert.ToString(R) + " " + (Convert.ToString(I))) + " i";

                        Results.Text += Environment.NewLine + "";
                    }
                }

                aux = 1;

                btnCalcular.Text = "Borrar";



                Vectors.Add(Convert.ToString(R) + " + " + (Convert.ToString(I)) + " i");
            }
        }
コード例 #40
0
    private void CreateCheckCodeImage(string checkCode)
    {
        if (checkCode == null || checkCode.Trim() == String.Empty)
        {
            return;
        }

        System.Drawing.Bitmap   image = new System.Drawing.Bitmap((int)Math.Ceiling((checkCode.Length * 15.0 + 40)), 23);
        System.Drawing.Graphics g     = System.Drawing.Graphics.FromImage(image);

        try
        {
            //生成随机生成器
            Random random = new Random();

            //清空图片背景色
            g.Clear(System.Drawing.Color.White);

            //画图片的背景噪音线
            for (int i = 0; i < 25; i++)
            {
                int x1 = random.Next(image.Width);
                int x2 = random.Next(image.Width);
                int y1 = random.Next(image.Height);
                int y2 = random.Next(image.Height);

                g.DrawLine(new System.Drawing.Pen(System.Drawing.Color.Silver), x1, y1, x2, y2);
            }

            System.Drawing.Font font = new System.Drawing.Font("Arial", 14, (System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic));
            System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new System.Drawing.Rectangle(0, 0, image.Width, image.Height), System.Drawing.Color.Blue, System.Drawing.Color.DarkRed, 1.2f, true);

            int cySpace = 16;
            for (int i = 0; i < validateCodeCount; i++)
            {
                g.DrawString(checkCode.Substring(i, 1), font, brush, (i + 1) * cySpace, 1);
            }

            //画图片的前景噪音点
            for (int i = 0; i < 100; i++)
            {
                int x = random.Next(image.Width);
                int y = random.Next(image.Height);

                image.SetPixel(x, y, System.Drawing.Color.FromArgb(random.Next()));
            }

            //画图片的边框线
            g.DrawRectangle(new System.Drawing.Pen(System.Drawing.Color.Silver), 0, 0, image.Width - 1, image.Height - 1);

            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
            Response.ClearContent();
            Response.ContentType = "image/Gif";
            Response.BinaryWrite(ms.ToArray());
        }
        finally
        {
            g.Dispose();
            image.Dispose();
        }
    }
コード例 #41
0
ファイル: CharPicker.cs プロジェクト: smartree/Zydeo
        /// <summary>
        /// Paints the control.
        /// </summary>
        public override void DoPaint(System.Drawing.Graphics g)
        {
            // Get character rectangles
            CharRect[] rects = getCharRects();

            // Background
            using (Brush b = new SolidBrush(ZenParams.WindowColor))
            {
                g.FillRectangle(b, 0, 0, Width, Height);
            }
            // Characters
            if (items != null)
            {
                StringFormat sf = StringFormat.GenericTypographic;
                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                using (Brush b = new SolidBrush(Color.Black))
                {
                    for (int i = 0; i != rects.Length; ++i)
                    {
                        RectangleF rect = rects[i].Rect;
                        // Background
                        using (Brush bgb = new SolidBrush(rects[i].BgColor))
                        {
                            g.FillRectangle(bgb, rect);
                        }
                        // Draw character, if any
                        if (i >= items.Length)
                        {
                            continue;
                        }
                        string str = ""; str += items[i];
                        HanziRenderer.DrawString(g, str, new PointF(rect.X + charOfsX, rect.Y + charOfsY), b,
                                                 fontFam, fontScript, fontSize, FontStyle.Regular);
                    }
                }
            }
            // Error message
            else
            {
                StringFormat sf = StringFormat.GenericDefault;
                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
                string line1    = tprov.GetString("CharPickerError1");
                string line2    = tprov.GetString("CharPickerError2");
                float  fontSize = Magic.CharPickerErrorFontSize;
                using (Font f1 = SystemFontProvider.Instance.GetSystemFont(FontStyle.Bold, fontSize))
                    using (Font f2 = SystemFontProvider.Instance.GetSystemFont(FontStyle.Regular, fontSize))
                        using (Brush b = new SolidBrush(Color.Black))
                        {
                            float  padL   = 10F * Scale;
                            float  padR   = 10F * Scale;
                            SizeF  sz1    = g.MeasureString(line1, f1, (int)(Width - padL - padR), sf);
                            SizeF  sz2    = g.MeasureString(line2, f2, (int)(Width - padL - padR), sf);
                            float  hblock = sz1.Height + sz2.Height;
                            PointF pt1    = new PointF(padL, (((float)Height - 2) - hblock) / 2F);
                            PointF pt2    = new PointF(pt1.X, pt1.Y + sz1.Height);
                            g.DrawString(line1, f1, b, pt1);
                            g.DrawString(line2, f2, b, new RectangleF(pt2.X, pt2.Y, Width - pt2.X - 1, Height - pt2.Y - 1));
                        }
            }
            // Border
            using (Pen p = new Pen(ZenParams.BorderColor))
            {
                g.DrawLine(p, 0, 0, Width, 0);
                g.DrawLine(p, Width - 1, 0, Width - 1, Height);
                g.DrawLine(p, Width - 1, Height - 1, 0, Height - 1);
                g.DrawLine(p, 0, Height - 1, 0, 0);
            }
        }
コード例 #42
0
        public override void DrawLine(int x1, int y1, int x2, int y2)
        {
            Pen myPen = new Pen(Color.FromArgb(trans, line.R, line.G, line.B), lineWidth);

            g.DrawLine(myPen, x1, x2, y1, y2);
        }
コード例 #43
0
 /// <summary>
 /// Draws a representation of the line in the legend
 /// </summary>
 /// <param name="g">The graphics surface on which to draw.</param>
 /// <param name="startEnd">A rectangle specifying the bounds of the area in the legend set aside for drawing.</param>
 public void DrawInLegend(System.Drawing.Graphics g, System.Drawing.Rectangle startEnd)
 {
     g.DrawLine(pen_, startEnd.Left, (startEnd.Top + startEnd.Bottom) / 2,
                startEnd.Right, (startEnd.Top + startEnd.Bottom) / 2);
 }
コード例 #44
0
        public override void DrawAppointment(System.Drawing.Graphics g, System.Drawing.Rectangle rect, Appointment appointment, bool isSelected, System.Drawing.Rectangle gripRect)
        {
            if (appointment == null)
            {
                throw new ArgumentNullException("appointment");
            }

            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            /*
             * Logic for drawing the appointment:
             * 1) Do something messy with the colours
             *
             * 2) Determine background pattern
             * 2.1) App is locked -> HatchBrush
             * 2.2) Normal app -> Nothing
             *
             * 3) Draw the background of appointment
             *
             * 4) Draw the edges of appointment
             * 4.1) If app is selected -> just draw the selection rectangle
             * 4.2) If not -> draw the gripper, border (if required) and shadows
             */

            if (rect.Width != 0 && rect.Height != 0)
            {
                using (StringFormat format = new StringFormat())
                {
                    format.Alignment     = StringAlignment.Near;
                    format.LineAlignment = StringAlignment.Near;

                    Color start = InterpolateColors(appointment.Color, Color.White, 0.4f);
                    Color end   = InterpolateColors(appointment.Color, Color.FromArgb(191, 210, 234), 0.7f);
                    // if appointment is locked, draw different background pattern
                    if ((appointment.Locked))
                    {
                        // Draw back
                        using (Brush m_Brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.LargeConfetti, Color.Blue, appointment.Color))
                            g.FillRectangle(m_Brush, rect);

                        // little transparent
                        start = Color.FromArgb(230, start);
                        end   = Color.FromArgb(180, end);

                        GraphicsPath path = new GraphicsPath();
                        path.AddRectangle(rect);
                    }

                    // Draw the background of the appointment

                    using (LinearGradientBrush aGB = new LinearGradientBrush(rect, start, end, LinearGradientMode.Vertical))
                        g.FillRectangle(aGB, rect);

                    // If the appointment is selected, only need to draw the selection frame

                    if (isSelected)
                    {
                        Rectangle m_BorderRectangle = rect;

                        using (Pen m_Pen = new Pen(appointment.BorderColor, 3))
                            g.DrawRectangle(m_Pen, rect);

                        m_BorderRectangle.Inflate(2, 2);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, m_BorderRectangle);

                        m_BorderRectangle.Inflate(-4, -4);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, m_BorderRectangle);
                    }
                    else
                    {
                        // Draw gripper

                        gripRect.Width += 1;

                        start = InterpolateColors(appointment.BorderColor, appointment.Color, 0.2f);
                        end   = InterpolateColors(appointment.BorderColor, Color.White, 0.6f);

                        using (LinearGradientBrush aGB = new LinearGradientBrush(rect, start, end, LinearGradientMode.Vertical))
                            g.FillRectangle(aGB, gripRect);

                        //  Draw border if needed
                        if (appointment.DrawBorder)
                        {
                            using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                                g.DrawRectangle(m_Pen, rect);
                        }

                        // Draw shadow lines
                        int xLeft   = rect.X + 6;
                        int xRight  = rect.Right + 1;
                        int yTop    = rect.Y + 1;
                        int yButton = rect.Bottom + 1;

                        for (int i = 0; i < 5; i++)
                        {
                            using (Pen shadow_Pen = new Pen(Color.FromArgb(70 - 12 * i, Color.Black)))
                            {
                                g.DrawLine(shadow_Pen, xLeft + i, yButton + i, xRight + i - 1, yButton + i); //horisontal lines
                                g.DrawLine(shadow_Pen, xRight + i, yTop + i, xRight + i, yButton + i);       //vertical
                            }
                        }
                    }

                    // draw appointment text

                    rect.X += gripRect.Width;
                    // width of shadow is 6.
                    rect.Width -= 6;

                    g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                    g.DrawString(appointment.Title, this.BaseFont, SystemBrushes.WindowText, rect, format);
                    g.TextRenderingHint = TextRenderingHint.SystemDefault;
                }
            }
        }
コード例 #45
0
 public void DrawLine(float x1, float y1, float x2, float y2)
 {
     PlatformGraphics.DrawLine(this.linePen, x1, y1, x2, y2);
 }
コード例 #46
0
 public override void Draw(System.Drawing.Graphics graphics)
 {
     graphics.DrawLine(new Pen(Color.Black), Begin, End);
 }
コード例 #47
0
        static public bool DrawGraphicsPath(
            System.Drawing.Graphics pGraphics,
            System.Drawing.Drawing2D.GraphicsPath pGraphicsPath,
            System.Drawing.Color clrPen,
            float fPenWidth)
        {
            if (pGraphics == null || pGraphicsPath == null)
            {
                return(false);
            }

            System.Drawing.Drawing2D.PathData pathData = pGraphicsPath.PathData;

            if (pathData.Points.Length <= 0)
            {
                return(false);
            }

            System.Drawing.Pen pen = new Pen(clrPen, fPenWidth);
            pen.LineJoin = LineJoin.Round;


            stBezier bezier    = new stBezier();
            stStart  start     = new stStart();
            PointF   prevPoint = new PointF();

            for (int i = 0; i < pathData.Types.Length; ++i)
            {
                byte maskedByte = pathData.Types[i];
                if (pathData.Types[i] == (byte)PathPointType.PathTypeMask)
                {
                    maskedByte = (byte)(pathData.Types[i] & 0x3);
                }

                switch (maskedByte)
                {
                case PathPointType.Start:
                case PathPointType.Start | PathPointType.PathMarker:
                    start.fPoint  = pathData.Points[i];
                    start.nCount  = 1;
                    start.bDrawn  = false;
                    bezier.nCount = 0;
                    break;

                case PathPointType.Line:
                case PathPointType.Line | PathPointType.PathMarker:
                    pGraphics.DrawLine(pen, prevPoint, pathData.Points[i]);
                    break;

                case PathPointType.Line | PathPointType.CloseSubpath:
                case PathPointType.Line | PathPointType.PathMarker | PathPointType.CloseSubpath:
                    pGraphics.DrawLine(pen, prevPoint, pathData.Points[i]);
                    pGraphics.DrawLine(pen, pathData.Points[i], start.fPoint);
                    start.nCount = 0;
                    break;

                case PathPointType.Bezier:
                case PathPointType.Bezier | PathPointType.PathMarker:
                    bezier.fPoints[bezier.nCount] = pathData.Points[i];
                    bezier.nCount++;
                    if (bezier.nCount == 1)
                    {
                        pGraphics.DrawLine(pen, prevPoint, pathData.Points[i]);
                    }
                    if (bezier.nCount >= 4)
                    {
                        pGraphics.DrawBezier(pen,
                                             bezier.fPoints[0], bezier.fPoints[1],
                                             bezier.fPoints[2], bezier.fPoints[3]);
                        bezier.nCount = 0;
                    }
                    break;

                case PathPointType.Bezier | PathPointType.CloseSubpath:
                case PathPointType.Bezier | PathPointType.PathMarker | PathPointType.CloseSubpath:
                    bezier.fPoints[bezier.nCount] = pathData.Points[i];
                    bezier.nCount++;
                    if (bezier.nCount == 1)
                    {
                        pGraphics.DrawLine(pen, prevPoint, pathData.Points[i]);
                    }
                    if (bezier.nCount >= 4)
                    {
                        pGraphics.DrawBezier(pen,
                                             bezier.fPoints[0], bezier.fPoints[1],
                                             bezier.fPoints[2], bezier.fPoints[3]);
                        bezier.nCount = 0;
                        if (start.nCount == 1)
                        {
                            pGraphics.DrawLine(pen, pathData.Points[i], start.fPoint);
                            start.nCount = 0;
                        }
                    }
                    else if (start.nCount == 1)
                    {
                        pGraphics.DrawLine(pen, pathData.Points[i], start.fPoint);
                        start.nCount = 0;
                        start.bDrawn = true;
                    }
                    break;

                default:
                {
                    //wchar_t buf[200];
                    //memset(buf,0, sizeof(buf));
                    //wsprintf(buf,_T("maskedByte: 0x%X\n"), maskedByte);
                    //OutputDebugStringW(buf);
                }
                break;
                }
                prevPoint = pathData.Points[i];
            }

            return(true);
        }
コード例 #48
0
        public override void DrawDayHeader(System.Drawing.Graphics g, System.Drawing.Rectangle rect, DateTime date)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            using (StringFormat format = new StringFormat())
            {
                format.Alignment     = StringAlignment.Center;
                format.FormatFlags   = StringFormatFlags.NoWrap;
                format.LineAlignment = StringAlignment.Center;

                using (StringFormat formatdd = new StringFormat())
                {
                    formatdd.Alignment     = StringAlignment.Near;
                    formatdd.FormatFlags   = StringFormatFlags.NoWrap;
                    formatdd.LineAlignment = StringAlignment.Center;

                    using (SolidBrush brush = new SolidBrush(this.BackColor))
                        g.FillRectangle(brush, rect);

                    using (Pen aPen = new Pen(Color.FromArgb(205, 219, 238)))
                        g.DrawLine(aPen, rect.Left, rect.Top + (int)rect.Height / 2, rect.Right, rect.Top + (int)rect.Height / 2);

                    using (Pen aPen = new Pen(Color.FromArgb(141, 174, 217)))
                        g.DrawRectangle(aPen, rect);

                    rect.X     += 1;
                    rect.Width -= 1;
                    using (Pen aPen = new Pen(Color.FromArgb(141, 174, 217)))
                        g.DrawRectangle(aPen, rect);

                    Rectangle topPart = new Rectangle(rect.Left + 1, rect.Top + 1, rect.Width - 2, (int)(rect.Height / 2) - 1);
                    Rectangle lowPart = new Rectangle(rect.Left + 1, rect.Top + (int)(rect.Height / 2) + 1, rect.Width - 1, (int)(rect.Height / 2) - 1);

                    using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(228, 236, 246), Color.FromArgb(214, 226, 241), LinearGradientMode.Vertical))
                        g.FillRectangle(aGB, topPart);

                    using (LinearGradientBrush aGB = new LinearGradientBrush(lowPart, Color.FromArgb(194, 212, 235), Color.FromArgb(208, 222, 239), LinearGradientMode.Vertical))
                        g.FillRectangle(aGB, lowPart);

                    if (date.Date.Equals(DateTime.Now.Date))
                    {
                        topPart.Inflate((int)(-topPart.Width / 4 + 1), 1); //top left orange area
                        topPart.Offset(rect.Left - topPart.Left + 1, 1);
                        topPart.Inflate(1, 0);
                        using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(247, 207, 114), Color.FromArgb(251, 230, 148), LinearGradientMode.Horizontal))
                        {
                            topPart.Inflate(-1, 0);
                            g.FillRectangle(aGB, topPart);
                        }

                        topPart.Offset(rect.Right - topPart.Right, 0);        //top right orange
                        topPart.Inflate(1, 0);
                        using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(251, 230, 148), Color.FromArgb(247, 207, 114), LinearGradientMode.Horizontal))
                        {
                            topPart.Inflate(-1, 0);
                            g.FillRectangle(aGB, topPart);
                        }

                        using (Pen aPen = new Pen(Color.FromArgb(128, 240, 154, 30))) //center line
                            g.DrawLine(aPen, rect.Left, topPart.Bottom - 1, rect.Right, topPart.Bottom - 1);

                        topPart.Inflate(0, -1);
                        topPart.Offset(0, topPart.Height + 1); //lower right
                        using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(240, 157, 33), Color.FromArgb(250, 226, 142), LinearGradientMode.BackwardDiagonal))
                            g.FillRectangle(aGB, topPart);

                        topPart.Offset(rect.Left - topPart.Left + 1, 0); //lower left
                        using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(240, 157, 33), Color.FromArgb(250, 226, 142), LinearGradientMode.ForwardDiagonal))
                            g.FillRectangle(aGB, topPart);
                        using (Pen aPen = new Pen(Color.FromArgb(238, 147, 17)))
                            g.DrawRectangle(aPen, rect);
                    }

                    g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

                    //get short dayabbr. if narrow dayrect
                    string sTodaysName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(date.DayOfWeek);
                    if (rect.Width < 105)
                    {
                        sTodaysName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(date.DayOfWeek);
                    }

                    rect.Offset(2, 1);

                    using (Font fntDay = new Font("Segoe UI", 8))
                        g.DrawString(sTodaysName, fntDay, SystemBrushes.WindowText, rect, format);

                    rect.Offset(-2, -1);

                    using (Font fntDayDate = new Font("Segoe UI", 9, FontStyle.Bold))
                        g.DrawString(date.ToString(" d"), fntDayDate, SystemBrushes.WindowText, rect, formatdd);
                }
            }
        }
コード例 #49
0
        protected override void Render(GH_Canvas canvas, System.Drawing.Graphics graphics, GH_CanvasChannel channel)
        {
            switch (channel)
            {
            case GH_CanvasChannel.Objects:
                //We need to draw everything outselves.

                Color myColour = UI.Colour.GsaDarkBlue;
                Brush myBrush  = new SolidBrush(myColour);

                //Text boxes
                Brush activeFillBrush  = myBrush;
                Brush passiveFillBrush = Brushes.LightGray;
                Color borderColour     = myColour;
                Color passiveBorder    = Color.DarkGray;
                Brush annoText         = Brushes.Black;

                Font font = GH_FontServer.Standard;
                int  s    = 8;
                if (Grasshopper.CentralSettings.CanvasFullNames)
                {
                    s    = 10;
                    font = GH_FontServer.Standard;
                }

                //draw the component
                base.RenderComponentCapsule(canvas, graphics, true, true, true, true, true, true);

                Pen pen = new Pen(borderColour);

                graphics.DrawString(SpacerTxt1, GH_FontServer.Small, annoText, SpacerBounds1, GH_TextRenderingConstants.CenterCenter);
                graphics.DrawLine(pen, SpacerBounds1.X, SpacerBounds1.Y + SpacerBounds1.Height / 2, SpacerBounds1.X + (SpacerBounds1.Width - GH_FontServer.StringWidth(SpacerTxt1, GH_FontServer.Small)) / 2 - 4, SpacerBounds1.Y + SpacerBounds1.Height / 2);
                graphics.DrawLine(pen, SpacerBounds1.X + (SpacerBounds1.Width - GH_FontServer.StringWidth(SpacerTxt1, GH_FontServer.Small)) / 2 + GH_FontServer.StringWidth(SpacerTxt1, GH_FontServer.Small) + 4, SpacerBounds1.Y + SpacerBounds1.Height / 2, SpacerBounds1.X + SpacerBounds1.Width, SpacerBounds1.Y + SpacerBounds1.Height / 2);

                graphics.DrawString("x", font, annoText, xTxtBounds1, GH_TextRenderingConstants.CenterCenter);
                ButtonsUI.CheckBox.DrawCheckButton(graphics, new PointF(xBounds1.X + xBounds1.Width / 2, xBounds1.Y + xBounds1.Height / 2), x1, activeFillBrush, borderColour, passiveFillBrush, passiveBorder, s);

                graphics.DrawString("y", font, annoText, yTxtBounds1, GH_TextRenderingConstants.CenterCenter);
                ButtonsUI.CheckBox.DrawCheckButton(graphics, new PointF(yBounds1.X + yBounds1.Width / 2, yBounds1.Y + yBounds1.Height / 2), y1, activeFillBrush, borderColour, passiveFillBrush, passiveBorder, s);

                graphics.DrawString("z", font, annoText, zTxtBounds1, GH_TextRenderingConstants.CenterCenter);
                ButtonsUI.CheckBox.DrawCheckButton(graphics, new PointF(zBounds1.X + zBounds1.Width / 2, zBounds1.Y + zBounds1.Height / 2), z1, activeFillBrush, borderColour, passiveFillBrush, passiveBorder, s);

                graphics.DrawString("xx", font, annoText, xxTxtBounds1, GH_TextRenderingConstants.CenterCenter);
                ButtonsUI.CheckBox.DrawCheckButton(graphics, new PointF(xxBounds1.X + xxBounds1.Width / 2, xxBounds1.Y + xxBounds1.Height / 2), xx1, activeFillBrush, borderColour, passiveFillBrush, passiveBorder, s);

                graphics.DrawString("yy", font, annoText, yyTxtBounds1, GH_TextRenderingConstants.CenterCenter);
                ButtonsUI.CheckBox.DrawCheckButton(graphics, new PointF(yyBounds1.X + yyBounds1.Width / 2, yyBounds1.Y + yyBounds1.Height / 2), yy1, activeFillBrush, borderColour, passiveFillBrush, passiveBorder, s);

                graphics.DrawString("zz", font, annoText, zzTxtBounds1, GH_TextRenderingConstants.CenterCenter);
                ButtonsUI.CheckBox.DrawCheckButton(graphics, new PointF(zzBounds1.X + zzBounds1.Width / 2, zzBounds1.Y + zzBounds1.Height / 2), zz1, activeFillBrush, borderColour, passiveFillBrush, passiveBorder, s);

                graphics.DrawString(SpacerTxt2, GH_FontServer.Small, annoText, SpacerBounds2, GH_TextRenderingConstants.CenterCenter);
                graphics.DrawLine(pen, SpacerBounds2.X, SpacerBounds2.Y + SpacerBounds2.Height / 2, SpacerBounds2.X + (SpacerBounds2.Width - GH_FontServer.StringWidth(SpacerTxt2, GH_FontServer.Small)) / 2 - 4, SpacerBounds2.Y + SpacerBounds2.Height / 2);
                graphics.DrawLine(pen, SpacerBounds2.X + (SpacerBounds2.Width - GH_FontServer.StringWidth(SpacerTxt2, GH_FontServer.Small)) / 2 + GH_FontServer.StringWidth(SpacerTxt2, GH_FontServer.Small) + 4, SpacerBounds2.Y + SpacerBounds2.Height / 2, SpacerBounds2.X + SpacerBounds2.Width, SpacerBounds2.Y + SpacerBounds2.Height / 2);

                graphics.DrawString("x", font, annoText, xTxtBounds2, GH_TextRenderingConstants.CenterCenter);
                ButtonsUI.CheckBox.DrawCheckButton(graphics, new PointF(xBounds2.X + xBounds2.Width / 2, xBounds2.Y + xBounds2.Height / 2), x2, activeFillBrush, borderColour, passiveFillBrush, passiveBorder, s);

                graphics.DrawString("y", font, annoText, yTxtBounds2, GH_TextRenderingConstants.CenterCenter);
                ButtonsUI.CheckBox.DrawCheckButton(graphics, new PointF(yBounds2.X + yBounds2.Width / 2, yBounds2.Y + yBounds2.Height / 2), y2, activeFillBrush, borderColour, passiveFillBrush, passiveBorder, s);

                graphics.DrawString("z", font, annoText, zTxtBounds2, GH_TextRenderingConstants.CenterCenter);
                ButtonsUI.CheckBox.DrawCheckButton(graphics, new PointF(zBounds2.X + zBounds2.Width / 2, zBounds2.Y + zBounds2.Height / 2), z2, activeFillBrush, borderColour, passiveFillBrush, passiveBorder, s);

                graphics.DrawString("xx", font, annoText, xxTxtBounds2, GH_TextRenderingConstants.CenterCenter);
                ButtonsUI.CheckBox.DrawCheckButton(graphics, new PointF(xxBounds2.X + xxBounds2.Width / 2, xxBounds2.Y + xxBounds2.Height / 2), xx2, activeFillBrush, borderColour, passiveFillBrush, passiveBorder, s);

                graphics.DrawString("yy", font, annoText, yyTxtBounds2, GH_TextRenderingConstants.CenterCenter);
                ButtonsUI.CheckBox.DrawCheckButton(graphics, new PointF(yyBounds2.X + yyBounds2.Width / 2, yyBounds2.Y + yyBounds2.Height / 2), yy2, activeFillBrush, borderColour, passiveFillBrush, passiveBorder, s);

                graphics.DrawString("zz", font, annoText, zzTxtBounds2, GH_TextRenderingConstants.CenterCenter);
                ButtonsUI.CheckBox.DrawCheckButton(graphics, new PointF(zzBounds2.X + zzBounds2.Width / 2, zzBounds2.Y + zzBounds2.Height / 2), zz2, activeFillBrush, borderColour, passiveFillBrush, passiveBorder, s);

                break;

            default:
                base.Render(canvas, graphics, channel);
                break;
            }
        }
コード例 #50
0
 public void DrawLine(GraphicsModel.Point pt1, GraphicsModel.Point pt2, double lineWidth, GraphicsModel.Color color)
 {
     Pen.Width = (float)lineWidth;
     Pen.Color = Convert(color);
     Gfx.DrawLine(Pen, Convert(pt1), Convert(pt2));
 }
コード例 #51
0
        /// <CalculateValues>
        /// The below is the method that calculates the values to be place while painting
        /// </CalculateValues>
        ///
        #endregion


        /// <Paint >
        /// The below is the method that draws the control on the screen
        /// </Paint >
        ///
        #region Paint Method Override -- This method draws the control on the screen

        private void OnPaintDrawSliderAndBar(System.Drawing.Graphics myGraphics, PaintEventArgs e)
        {
            System.Drawing.Brush brSolidBrush;
            System.Drawing.Pen   myPen;

            // If Interesting mouse event happened on the Thumb1 Draw Thumb1
            if (bMouseEventThumb1)
            {
                brSolidBrush = new System.Drawing.SolidBrush(this.BackColor);
                if (null != strLeftImagePath)
                {
                    myGraphics.FillRectangle(brSolidBrush, ptThumbPoints1[0].X, ptThumbPoints1[1].Y, fWidthOfThumb, fHeightOfThumb);
                }
                else
                {
                    myGraphics.FillClosedCurve(brSolidBrush, ptThumbPoints1, System.Drawing.Drawing2D.FillMode.Winding, 0f);
                }
            }
            //if interesting mouse event happened on Thumb2 draw thumb2
            if (bMouseEventThumb2)
            {
                brSolidBrush = new System.Drawing.SolidBrush(this.BackColor);

                if (null != strRightImagePath)
                {
                    myGraphics.FillRectangle(brSolidBrush, ptThumbPoints2[2].X, ptThumbPoints2[1].Y, fWidthOfThumb, fHeightOfThumb);
                }
                else
                {
                    myGraphics.FillClosedCurve(brSolidBrush, ptThumbPoints2, System.Drawing.Drawing2D.FillMode.Winding, 0f);
                }
            }

            // The Below lines are to draw the Thumb and the Lines
            // The Infocus and the Disabled colors are drawn properly based
            // onthe  calculated values
            brSolidBrush = new System.Drawing.SolidBrush(clrInFocusRangeLabelColor);
            myPen        = new System.Drawing.Pen(clrInFocusRangeLabelColor, unSizeOfMiddleBar);

            ptThumbPoints1[0].X = fThumb1Point;
            ptThumbPoints1[1].X = fThumb1Point;
            ptThumbPoints1[2].X = fThumb1Point + fWidthOfThumb;

            ptThumbPoints2[0].X = fThumb2Point;
            ptThumbPoints2[1].X = fThumb2Point;
            ptThumbPoints2[2].X = fThumb2Point - fWidthOfThumb;

            myPen = new System.Drawing.Pen(clrDisabledBarColor, unSizeOfMiddleBar);
            myGraphics.DrawLine(myPen, fLeftCol, ptThumbPoints1[2].Y, fThumb1Point, ptThumbPoints1[2].Y);

            myGraphics.DrawLine(myPen, fLeftCol, ptThumbPoints1[2].Y, fLeftCol, ptThumbPoints1[2].Y + fntLabelFont.SizeInPoints);
            myGraphics.DrawLine(myPen, fRightCol, ptThumbPoints1[2].Y, fRightCol, ptThumbPoints1[2].Y + fntLabelFont.SizeInPoints);

            brSolidBrush = new System.Drawing.SolidBrush(clrStringOutputFontColor);
            myGraphics.DrawString(strRangeString, fntRangeOutputStringFont, brSolidBrush, fLeftCol, fLeftRow * 2 - fntRangeOutputStringFont.Size - 3);

            myPen = new System.Drawing.Pen(clrInFocusBarColor, unSizeOfMiddleBar);
            myGraphics.DrawLine(myPen, ptThumbPoints1[2].X, ptThumbPoints1[2].Y, fThumb2Point, /* - fWidthOfThumb*/ ptThumbPoints1[2].Y);

            myPen = new System.Drawing.Pen(clrDisabledBarColor, unSizeOfMiddleBar);
            myGraphics.DrawLine(myPen, fThumb2Point, ptThumbPoints2[2].Y, fRightCol, ptThumbPoints2[2].Y);

            // If the Thumb is an Image it draws the Image or else it draws the Thumb
            if (null != strLeftImagePath)
            {
                myGraphics.DrawImage(imImageLeft, ptThumbPoints1[0].X, ptThumbPoints1[1].Y, fWidthOfThumb, fHeightOfThumb);
            }
            else
            {
                brSolidBrush = new System.Drawing.SolidBrush(clrThumbColor);
                myGraphics.FillClosedCurve(brSolidBrush, ptThumbPoints1, System.Drawing.Drawing2D.FillMode.Winding, 0f);
            }

            // If the Thumb is an Image it draws the Image or else it draws the Thumb
            if (null != strRightImagePath)
            {
                myGraphics.DrawImage(imImageRight, ptThumbPoints2[2].X, ptThumbPoints2[1].Y, fWidthOfThumb, fHeightOfThumb);
            }
            else
            {
                brSolidBrush = new System.Drawing.SolidBrush(clrThumbColor);
                myGraphics.FillClosedCurve(brSolidBrush, ptThumbPoints2, System.Drawing.Drawing2D.FillMode.Winding, 0f);
            }
        }
コード例 #52
0
        protected void PaintXErrorBars(System.Drawing.Graphics g, IPlotArea layer, Altaxo.Graph.Gdi.Plot.Data.Processed2DPlotData pdata)
        {
            // Plot error bars for the independent variable (x)
            PlotRangeList rangeList = pdata.RangeList;

            PointF[]       ptArray   = pdata.PlotPointsInAbsoluteLayerCoordinates;
            INumericColumn posErrCol = _positiveErrorColumn.Document;
            INumericColumn negErrCol = _negativeErrorColumn.Document;

            if (posErrCol == null && negErrCol == null)
            {
                return; // nothing to do if both error columns are null
            }
            System.Drawing.Drawing2D.GraphicsPath errorBarPath = new System.Drawing.Drawing2D.GraphicsPath();

            Region oldClippingRegion = g.Clip;
            Region newClip           = (Region)oldClippingRegion.Clone();

            foreach (PlotRange r in rangeList)
            {
                int lower  = r.LowerBound;
                int upper  = r.UpperBound;
                int offset = r.OffsetToOriginal;
                for (int j = lower; j < upper; j++)
                {
                    AltaxoVariant x  = pdata.GetXPhysical(j + offset);
                    Logical3D     lm = layer.GetLogical3D(pdata, j + offset);
                    lm.RX += _cachedLogicalShiftOfIndependent;
                    if (lm.IsNaN)
                    {
                        continue;
                    }

                    Logical3D lh      = lm;
                    Logical3D ll      = lm;
                    bool      lhvalid = false;
                    bool      llvalid = false;
                    if (posErrCol != null)
                    {
                        lh.RX   = layer.XAxis.PhysicalVariantToNormal(x + Math.Abs(posErrCol[j + offset]));
                        lhvalid = !lh.IsNaN;
                    }
                    if (negErrCol != null)
                    {
                        ll.RX   = layer.XAxis.PhysicalVariantToNormal(x - Math.Abs(negErrCol[j + offset]));
                        llvalid = !ll.IsNaN;
                    }
                    if (!(lhvalid || llvalid))
                    {
                        continue; // nothing to do for this point if both pos and neg logical point are invalid.
                    }
                    // now paint the error bar
                    if (_symbolGap) // if symbol gap, then clip the painting, exclude a rectangle of size symbolSize x symbolSize
                    {
                        double xlm, ylm;
                        layer.CoordinateSystem.LogicalToLayerCoordinates(lm, out xlm, out ylm);
                        newClip.Union(oldClippingRegion);
                        newClip.Exclude(new RectangleF((float)(xlm - _symbolSize / 2), (float)(ylm - _symbolSize / 2), _symbolSize, _symbolSize));
                        g.Clip = newClip;
                    }

                    if (lhvalid && llvalid)
                    {
                        errorBarPath.Reset();
                        layer.CoordinateSystem.GetIsoline(errorBarPath, ll, lm);
                        layer.CoordinateSystem.GetIsoline(errorBarPath, lm, lh);
                        g.DrawPath(_strokePen, errorBarPath);
                    }
                    else if (llvalid)
                    {
                        layer.CoordinateSystem.DrawIsoline(g, _strokePen, ll, lm);
                    }
                    else if (lhvalid)
                    {
                        layer.CoordinateSystem.DrawIsoline(g, _strokePen, lm, lh);
                    }


                    // now the end bars
                    if (_showEndBars)
                    {
                        if (lhvalid)
                        {
                            PointF outDir;
                            layer.CoordinateSystem.GetNormalizedDirection(lm, lh, 1, new Logical3D(0, 1), out outDir);
                            outDir.X *= _symbolSize / 2;
                            outDir.Y *= _symbolSize / 2;
                            double xlay, ylay;
                            layer.CoordinateSystem.LogicalToLayerCoordinates(lh, out xlay, out ylay);
                            // Draw a line from x,y to
                            g.DrawLine(_strokePen, (float)(xlay - outDir.X), (float)(ylay - outDir.Y), (float)(xlay + outDir.X), (float)(ylay + outDir.Y));
                        }

                        if (llvalid)
                        {
                            PointF outDir;
                            layer.CoordinateSystem.GetNormalizedDirection(lm, ll, 1, new Logical3D(0, 1), out outDir);
                            outDir.X *= _symbolSize / 2;
                            outDir.Y *= _symbolSize / 2;
                            double xlay, ylay;
                            layer.CoordinateSystem.LogicalToLayerCoordinates(ll, out xlay, out ylay);
                            // Draw a line from x,y to
                            g.DrawLine(_strokePen, (float)(xlay - outDir.X), (float)(ylay - outDir.Y), (float)(xlay + outDir.X), (float)(ylay + outDir.Y));
                        }
                    }
                }
            }

            g.Clip = oldClippingRegion;
        }
コード例 #53
0
ファイル: clsIMR_middlelayPrint.cs プロジェクト: ewin66/HIS
            public override void m_mthPrintNextLine(ref int p_intPosY, System.Drawing.Graphics p_objGrp, System.Drawing.Font p_fntNormalText)
            {
                if (p_intPosY == m_intLongLineTop + 5)
                {
                    m_mthPrintLine(ref p_intPosY, p_objGrp, p_fntNormalText);
                }
                Rectangle rtgTitle    = new Rectangle(m_intLeftX, p_intPosY + 5, c_intTitleWidth, c_intHeight);
                Rectangle rtgTitle2   = new Rectangle(m_intLeftX, p_intPosY + 5, 20, c_intHeight);
                Rectangle rtgTitle3   = new Rectangle(m_intLeftX + 30, p_intPosY + 5, 60, c_intHeight);
                Rectangle rtgDianoseR = new Rectangle(c_intShortLeft, p_intPosY + 5, c_intWidth, 10);
                Rectangle rtgDianoseL = new Rectangle(c_intShortRight, p_intPosY + 5, c_intWidth, 10);

                StringFormat stfTitle = new StringFormat(StringFormatFlags.FitBlackBox);
                Font         fntTitle = new Font("SimSun", 12);

                int intRealHeight = 0;
                int intTempHeight = 0;

                m_intPosY = p_intPosY;
                //  System.Resources.ResourceManager rm = new ResourceManager("HRPControl.Resources.Image", new com.digitalwave.Utility.Controls.ctlPaintContainer().GetType().Assembly);


                //********************
                if (m_strTitleArr == null)
                {
                    if (p_intPosY + 40 > ((int)enmRectangleInfo.BottomY - 50))
                    {
                        m_blnHaveMoreLine = true;
                        p_intPosY        += 500;
                        return;
                    }
                    //if (m_strTitle == "晶状体")hhjhj
                    //{
                    //    rtgDianoseR = new Rectangle(c_intShortLeft, p_intPosY + 5, c_intWidth - 100, 100);
                    //    rtgDianoseL = new Rectangle(c_intShortRight, p_intPosY + 5, c_intWidth - 100, 100);
                    //  //  Image img = (Bitmap)rm.GetObject("晶状体");
                    //  //  p_objGrp.DrawImage(img, c_intShortLeft + c_intWidth - 100, p_intPosY + 10, 100, 80);
                    //   // p_objGrp.DrawImage(img, c_intShortRight + c_intWidth - 100, p_intPosY + 10, 100, 80);
                    //}
                    p_objGrp.DrawString(m_strTitle, fntTitle, Brushes.Black, rtgTitle, stfTitle);
                    string str = "<root />";
                    if (m_strTitle == "引产方法")
                    {
                        p_objGrp.DrawLine(Pens.Black, m_intLeftX, p_intPosY, (int)enmRectangleInfo.RightX, p_intPosY);
                        if (m_objItemContentRArr != null)
                        {
                            string strSign = (m_objItemContentRArr[0] == null ? "" : (m_objItemContentRArr[0].m_strItemContent == null ? "" : m_objItemContentRArr[0].m_strItemContent));
                            //if (m_objItemContentRArr[1] != null && m_objItemContentRArr[1].m_strItemContent != null && m_objItemContentRArr[1].m_strItemContent != "")
                            //{
                            //    strSign += " 矫正" + (m_objItemContentRArr[1] == null ? "" : (m_objItemContentRArr[1].m_strItemContent == null ? "" : m_objItemContentRArr[1].m_strItemContent));
                            //}
                            m_objDiagnoseR.m_mthSetContextWithCorrectBefore(strSign, str, m_dtmFirstPrintTime, true);
                        }
                        if (m_objItemContentLArr != null)
                        {
                            string strSign2 = (m_objItemContentLArr[0] == null ? "" : (m_objItemContentLArr[0].m_strItemContent == null ? "" : m_objItemContentLArr[0].m_strItemContent));
                            if (m_objItemContentLArr[1] != null && m_objItemContentLArr[1].m_strItemContent != null && m_objItemContentLArr[1].m_strItemContent != "")
                            {
                                strSign2 += " 矫正" + (m_objItemContentLArr[1] == null ? "" : (m_objItemContentLArr[1].m_strItemContent == null ? "" : m_objItemContentLArr[1].m_strItemContent));
                            }
                            m_objDiagnoseL.m_mthSetContextWithCorrectBefore(strSign2, str, m_dtmFirstPrintTime, true);
                        }
                    }

                    else
                    {
                        m_mthSetPrintInfo(m_objDiagnoseR, m_objDiagnoseL, (m_objItemContentRArr == null ? null : m_objItemContentRArr[0]), (m_objItemContentLArr == null ? null : m_objItemContentLArr[0]));
                    }
                    m_objDiagnoseR.m_blnPrintAllBySimSun(11, rtgDianoseR, p_objGrp, out intRealHeight, false);
                    intTempHeight = intRealHeight;
                    m_objDiagnoseL.m_blnPrintAllBySimSun(11, rtgDianoseL, p_objGrp, out intRealHeight, false);
                    int intHeight = Math.Max(intTempHeight, intRealHeight);
                    if (intHeight > Math.Max(c_intHeight, rtgDianoseR.Height))
                    {
                        p_intPosY += intHeight + 5;
                    }
                    else
                    {
                        p_intPosY += Math.Max(c_intHeight, rtgDianoseR.Height);
                    }
                    p_objGrp.DrawLine(Pens.Black, m_intLeftX, p_intPosY, (int)enmRectangleInfo.RightX, p_intPosY);
                }
                else
                {
                    if (m_blnIsFirstPrint == true)
                    {
                        if (m_strTitle == "瞳孔")
                        {
                            rtgDianoseR = new Rectangle(c_intShortLeft, p_intPosY + 5, c_intWidth - 72, 0);
                            rtgDianoseL = new Rectangle(c_intShortRight, p_intPosY + 5, c_intWidth - 72, 0);
                            // Image img = (Bitmap)rm.GetObject("瞳孔");
                            //  p_objGrp.DrawImage(img, c_intShortLeft + c_intWidth - 72, p_intPosY + 10, 72, 48);
                            //   p_objGrp.DrawImage(img, c_intShortRight + c_intWidth - 72, p_intPosY + 10, 72, 48);
                        }
                        if (m_strTitle == "眼底情况")
                        {
                            rtgDianoseR = new Rectangle(c_intShortLeft, p_intPosY + 5, c_intWidth - 100, 0);
                            rtgDianoseL = new Rectangle(c_intShortRight, p_intPosY + 5, c_intWidth - 100, 0);
                            //  Image imgR = (Bitmap)rm.GetObject("右视网膜");
                            // Image imgL = (Bitmap)rm.GetObject("左视网膜");
                            //  p_objGrp.DrawImage(imgR, c_intShortLeft + c_intWidth - 100, p_intPosY + 10, 100, 100);
                            //  p_objGrp.DrawImage(imgL, c_intShortRight + c_intWidth - 100, p_intPosY + 10, 100, 100);
                        }
                        m_blnIsFirstPrint = false;
                    }
                    for (int i = m_intIndex; i < m_strTitleArr.Length; i++)
                    {
                        if (p_intPosY + 40 > ((int)enmRectangleInfo.BottomY - 50))
                        {
                            m_blnHaveMoreLine = true;
                            m_intIndex        = i;
                            p_objGrp.DrawString(m_strTitle, fntTitle, Brushes.Black, rtgTitle2, stfTitle);
                            p_objGrp.DrawLine(Pens.Black, (int)enmRectangleInfo.LeftX + 20, m_intPosY, (int)enmRectangleInfo.LeftX + 20, p_intPosY);
                            p_objGrp.DrawLine(Pens.Black, c_intShortLeft, m_intPosY, c_intShortLeft, p_intPosY);
                            p_objGrp.DrawLine(Pens.Black, c_intShortRight, m_intPosY, c_intShortRight, p_intPosY);
                            p_intPosY += 500;
                            return;
                        }
                        p_objGrp.DrawString(m_strTitleArr[i], fntTitle, Brushes.Black, rtgTitle3, stfTitle);

                        m_mthSetPrintInfo(m_objDiagnoseR, m_objDiagnoseL, (m_objItemContentRArr == null ? null : m_objItemContentRArr[i]), (m_objItemContentLArr == null ? null : m_objItemContentLArr[i]));
                        m_objDiagnoseR.m_blnPrintAllBySimSun(11, rtgDianoseR, p_objGrp, out intRealHeight, false);

                        intTempHeight = intRealHeight;
                        m_objDiagnoseL.m_blnPrintAllBySimSun(11, rtgDianoseL, p_objGrp, out intRealHeight, false);
                        int intHeight = Math.Max(intTempHeight, intRealHeight);
                        if (intHeight > Math.Max(c_intHeight, rtgDianoseR.Height))
                        {
                            p_intPosY += intHeight + 2;
                        }
                        else
                        {
                            p_intPosY += Math.Max(c_intHeight, rtgDianoseR.Height);
                        }
                        rtgDianoseR.Y = p_intPosY + 2;
                        rtgDianoseL.Y = p_intPosY + 2;
                        rtgTitle3.Y   = p_intPosY + 3;

                        if (m_strTitle == "眼底情况" || m_strTitle == "瞳孔")
                        {
                            p_objGrp.DrawLine(Pens.Black, (int)enmRectangleInfo.LeftX + 20, p_intPosY, (int)enmRectangleInfo.LeftX + c_intWidth - 100, p_intPosY);
                            p_objGrp.DrawLine(Pens.Black, c_intShortRight, p_intPosY, c_intShortRight + c_intWidth - 100, p_intPosY);
                        }
                        else
                        {
                            p_objGrp.DrawLine(Pens.Black, (int)enmRectangleInfo.LeftX + 20, p_intPosY, (int)enmRectangleInfo.RightX, p_intPosY);
                        }
                    }
                    rtgTitle2.Height = p_intPosY - m_intPosY;
                    p_objGrp.DrawLine(Pens.Black, m_intLeftX, p_intPosY, (int)enmRectangleInfo.RightX, p_intPosY);
                    p_objGrp.DrawLine(Pens.Black, (int)enmRectangleInfo.LeftX + 20, m_intPosY, (int)enmRectangleInfo.LeftX + 20, p_intPosY);
                    p_objGrp.DrawString(m_strTitle, fntTitle, Brushes.Black, rtgTitle2, stfTitle);
                }
                p_objGrp.DrawLine(Pens.Black, c_intShortLeft, m_intPosY, c_intShortLeft, p_intPosY);
                p_objGrp.DrawLine(Pens.Black, c_intShortRight, m_intPosY, c_intShortRight, p_intPosY);
                //********************
                fntTitle.Dispose();
                stfTitle.Dispose();

                m_blnHaveMoreLine = false;
            }
コード例 #54
0
        } // End Property Image


        private static System.Drawing.Image Generate(string captchaText)
        {
            double[][] coord     = null;
            int        image2d_x = 0;
            int        image2d_y = 0;


            double bevel      = 3;
            float  fontSize   = 20f;
            string fontFamily = "Arial";

            // fontFamily = "Algerian";



            // Calculate projection matrix
            double[] T = MathHelpers.cameraTransform(
                // new double[] { 0, -200, 250 },
                new double[] { MathHelpers.rand(-90, 90), -200, MathHelpers.rand(150, 250) },
                new double[] { 0, 0, 0 }
                );


            T = MathHelpers.matrixProduct(
                T,
                MathHelpers.viewingTransform(60, 300, 3000)
                //MathHelpers.viewingTransform(15, 30, 3000)
                );


            // string fontFile = FileHelper.MapProjectPath("Img/3DCaptcha.ttf");
            // fontFile = Helpers.MapProjectPath("Img/ALGER.ttf");

            // using (System.Drawing.Font font = GetCustomFont(fontFile, fontSize))
            using (System.Drawing.Font font = new System.Drawing.Font(fontFamily, fontSize, System.Drawing.FontStyle.Bold))
            {
                using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(1, 1))
                {
                    using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp))
                    {
                        System.Drawing.SizeF size = g.MeasureString(captchaText, font, new System.Drawing.PointF(10, 10), System.Drawing.StringFormat.GenericTypographic);
                        image2d_x = (int)(size.Width * 1.1) + 5;
                        image2d_y = (int)(size.Height) + 5;
                    } // End Using g
                }     // End Using bmp

                using (System.Drawing.Bitmap image2d = new System.Drawing.Bitmap(image2d_x, image2d_y))
                {
                    using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image2d))
                    {
                        g.Clear(System.Drawing.Color.Black);
                        g.DrawString(captchaText, font, System.Drawing.Brushes.White, new System.Drawing.PointF(1, -1));
                        // image2d.Save(FileHelper.MapProjectPath("Img/ftstring.png"), System.Drawing.Imaging.ImageFormat.Png);


                        coord = new double[image2d_x * image2d_y][]; // { image2d_x * image2d_y };
                        // Calculate coordinates

                        int count = 0;
                        for (int y = 0; y < image2d_y; y += 2)
                        {
                            for (int x = 0; x < image2d_x; x++)
                            {
                                // Calculate x1, y1, x2, y2
                                double xc = x - image2d_x / 2.0;
                                double zc = y - image2d_y / 2.0;

                                double   yc  = -(image2d.GetPixel(x, y).ToArgb() & 0xff) / 256.0 * bevel;
                                double[] xyz = new double[] { xc, yc, zc, 1 };
                                xyz = MathHelpers.vectorProduct(xyz, T);

                                coord[count] = xyz;
                                count++;
                            } // Next x
                        }     // Next y
                    }         // End Using g
                }             // End Using image2d
            }                 // End Using font



            // Create 3d image
            int image3d_x = 256;
            //image3d_y = image3d_x / 1.618;
            int image3d_y = image3d_x * 9 / 16;

            // image3d_x = 256 * 4;
            // image3d_y = (int)(image3d_x * 0.05);


            // using (
            System.Drawing.Bitmap image3d = new System.Drawing.Bitmap(image3d_x, image3d_y); //)
            {
                using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image3d))
                {
                    //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
                    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

                    // g.Clear(System.Drawing.Color.White);

                    System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, image3d.Width, image3d.Height);

                    System.Drawing.Drawing2D.HatchBrush hatchBrush = new System.Drawing.Drawing2D.HatchBrush(
                        System.Drawing.Drawing2D.HatchStyle.LightDownwardDiagonal,
                        System.Drawing.Color.Blue
                        //, System.Drawing.Color.Black
                        , System.Drawing.Color.Lavender
                        );

                    g.FillRectangle(hatchBrush, rect);



                    int    count = 0;
                    double scale = 1.75 - image2d_x / 400.0;

                    for (int y = 0; y < image2d_y; y++)
                    {
                        for (int x = 0; x < image2d_x; x++)
                        {
                            if (x > 0)
                            {
                                if (coord[count - 1] == null)
                                {
                                    continue;
                                }

                                double x0 = coord[count - 1][0] * scale + image3d_x / 2.0;
                                double y0 = coord[count - 1][1] * scale + image3d_y / 2.0;
                                double x1 = coord[count][0] * scale + image3d_x / 2.0;
                                double y1 = coord[count][1] * scale + image3d_y / 2.0;

                                //using (System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Blue, 0.25f)) { g.DrawLine(pen, (int)x0, (int)y0, (int)x1, (int)y1); }
                                g.DrawLine(System.Drawing.Pens.Blue, (int)x0, (int)y0, (int)x1, (int)y1);
                                // g.DrawLine(System.Drawing.Pens.White, (int)x0, (int)y0, (int)x1, (int)y1);
                            } // End if (x > 0)

                            count++;
                        } // Next x
                    }     // Next y
                }         // End Using g

                /*
                 * using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
                 * {
                 *  image3d.Save(ms, format);
                 *  imageBytes = ms.ToArray();
                 * } // End Using ms
                 */
            } // End using image3d

            return(image3d);
        } // End Function Generate
コード例 #55
0
        public void Draw(System.Drawing.Graphics graphics)
        {
            if (graphics == null)
            {
                return;
            }

            int x1, y1, x2, y2;

            //randomly shift a little at every endpoint
            var endXShift  = this._Shifter.Next(_MAX_SHIFT);
            var endYShift  = this._Shifter.Next(_MAX_SHIFT);
            var directionX = this._Shifter.Next(2);
            var directionY = this._Shifter.Next(2);

            var x = this.EndPosition.X;
            var y = this.EndPosition.Y;

            x += directionX == 1 ? endXShift : -1 * endXShift;

            this.EndPosition = new Point(x, y);

            if (this.Parent == null)
            {
                this.Thickness = this._Shifter.Next(_MAX_THICKNESS);
                endXShift      = this._Shifter.Next(_MAX_SHIFT);
                directionX     = this._Shifter.Next(2);

                x = this.StartPosition.X;
                y = this.StartPosition.Y;

                x += directionX == 1 ? endXShift : -1 * endXShift;

                this.StartPosition = new Point(x, y);
            }

            if (this.LeftChild != null && this.RightChild != null)
            {
                x = this.EndPosition.X;
                y = this.EndPosition.Y;

                y += directionY == 1 ? endYShift : -1 * endYShift;

                this.EndPosition = new Point(x, y);
            }

            x1 = this.StartPosition.X;
            y1 = this.StartPosition.Y;

            x2 = this.EndPosition.X;
            y2 = this.EndPosition.Y;

            //randomly skip a tick
            if (this.Parent == null)
            {
                this.ShouldSkip = this._Shifter.Next(this._SkipRate) == 0;
            }

            if (!this.ShouldSkip)
            {
                var pen = new Pen(this.Color, this.Thickness);
                graphics.DrawLine(pen, x1, y1, x2, y2);
            }

            if (this.LeftChild != null)
            {
                this.LeftChild.Draw(graphics);
            }

            if (this.RightChild != null)
            {
                this.RightChild.Draw(graphics);
            }

            if (this.Parent == null)
            {
                this.Age++;
            }
        }
コード例 #56
0
ファイル: clsIMR_middlelayPrint.cs プロジェクト: ewin66/HIS
 /// <summary>
 /// 打印顶部直线和标题
 /// </summary>
 /// <param name="p_intPosY"></param>
 /// <param name="p_objGrp"></param>
 /// <param name="p_fntNormalText"></param>
 private void m_mthPrintLine(ref int p_intPosY, System.Drawing.Graphics p_objGrp, System.Drawing.Font p_fntNormalText)
 {
     p_objGrp.DrawString("右                                 左", p_fntNormalText, Brushes.Black, (int)enmRectangleInfo.LeftX + 100, p_intPosY + 3);
     p_intPosY += 30;
     p_objGrp.DrawLine(Pens.Black, m_intLeftX, p_intPosY, (int)enmRectangleInfo.RightX, p_intPosY);
 }
コード例 #57
0
        /// <summary>
        /// Paints a border around the image. If Image drop shadow is enabled,
        /// a shodow is drawn too.
        /// </summary>
        /// <param name="g">The graphics object</param>
        /// <param name="ImageRect">the rectangle region of the image</param>
        private void paint_ImageBorder(System.Drawing.Graphics g, System.Drawing.Rectangle ImageRect)
        {
            System.Drawing.Rectangle rect = ImageRect;

            //
            // If ImageDropShadow = true, draw shadow
            //
            if (ImageDropShadow)
            {
                System.Drawing.Pen p0 = new System.Drawing.Pen(System.Drawing.Color.FromArgb(80, 0, 0, 0));
                System.Drawing.Pen p1 = new System.Drawing.Pen(System.Drawing.Color.FromArgb(40, 0, 0, 0));
                g.DrawLine(p0, new Point(rect.Right, rect.Bottom), new Point(rect.Right + 1, rect.Bottom));
                g.DrawLine(p0, new Point(rect.Right + 1, rect.Top + 1), new Point(rect.Right + 1, rect.Bottom + 0));
                g.DrawLine(p1, new Point(rect.Right + 2, rect.Top + 2), new Point(rect.Right + 2, rect.Bottom + 1));
                g.DrawLine(p0, new Point(rect.Left + 1, rect.Bottom + 1), new Point(rect.Right + 0, rect.Bottom + 1));
                g.DrawLine(p1, new Point(rect.Left + 1, rect.Bottom + 2), new Point(rect.Right + 1, rect.Bottom + 2));
            }
            //
            // Draw Image Border
            //
            if (ImageBorderEnabled)
            {
                Color[] ColorArray         = null;
                float[] PositionArray      = null;
                System.Drawing.Color color = this.ImageBorderColor;
                if (!this.Enabled)
                {
                    color = System.Drawing.Color.LightGray;
                }
                //
                // initialize color and position array
                //
                ColorArray = new Color[] {
                    Blend(color, System.Drawing.Color.White, 40),
                    Blend(color, System.Drawing.Color.White, 20),
                    Blend(color, System.Drawing.Color.White, 30),
                    Blend(color, System.Drawing.Color.White, 00),
                    Blend(color, System.Drawing.Color.Black, 30),
                    Blend(color, System.Drawing.Color.Black, 70),
                };
                PositionArray = new float[] { 0.0f, .20f, .50f, .60f, .90f, 1.0f };
                //
                // create blend object
                //
                System.Drawing.Drawing2D.ColorBlend blend = new System.Drawing.Drawing2D.ColorBlend();
                blend.Colors    = ColorArray;
                blend.Positions = PositionArray;
                //
                // create brush and pens
                //
                System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(rect, this.BackColor, Blend(this.BackColor, this.BackColor, 10), System.Drawing.Drawing2D.LinearGradientMode.Vertical);
                brush.InterpolationColors = blend;
                System.Drawing.Pen pen0 = new System.Drawing.Pen(brush, 1);
                System.Drawing.Pen pen1 = new System.Drawing.Pen(System.Drawing.Color.Black);
                //
                // calculate points to draw line
                //
                rect.Inflate(1, 1);
                Point[] pts = border_Get(rect.Left, rect.Top, rect.Width, rect.Height);
                this.border_Contract(1, ref pts);
                //
                // draw line 0
                //
                g.DrawLines(pen1, pts);
                //
                // draw line 1
                //
                this.border_Contract(1, ref pts);
                g.DrawLines(pen0, pts);
                //
                // release resources
                //
                pen1.Dispose();
                pen0.Dispose();
                brush.Dispose();
            }
        }
コード例 #58
0
        public override void DrawAppointment(System.Drawing.Graphics g, System.Drawing.Rectangle rect, Appointment appointment, bool isSelected, int gripWidth)
        {
            StringFormat m_Format = new StringFormat();

            m_Format.Alignment     = StringAlignment.Near;
            m_Format.LineAlignment = StringAlignment.Near;

            Color start = InterpolateColors(appointment.Color, Color.White, 0.4f);
            Color end   = InterpolateColors(appointment.Color, Color.FromArgb(235, 108, 163), 0.7f); //

            if ((appointment.Locked))
            {
                // Draw back
                using (Brush m_Brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.LargeConfetti, Color.Blue, appointment.Color))
                    g.FillRectangle(m_Brush, rect);

                // little transparent
                start = Color.FromArgb(230, start);
                end   = Color.FromArgb(180, end);

                GraphicsPath path = new GraphicsPath();
                path.AddRectangle(rect);

                using (LinearGradientBrush aGB = new LinearGradientBrush(rect, start, end, LinearGradientMode.Vertical))
                    g.FillRectangle(aGB, rect);
            }
            else
            {
                // Draw back
                using (LinearGradientBrush aGB = new LinearGradientBrush(rect, start, end, LinearGradientMode.Vertical))
                    g.FillRectangle(aGB, rect);
            }

            if (isSelected)
            {
                Rectangle m_BorderRectangle = rect;

                using (Pen m_Pen = new Pen(appointment.BorderColor, 4))
                    g.DrawRectangle(m_Pen, rect);

                m_BorderRectangle.Inflate(2, 2);

                using (Pen m_Pen = new Pen(TrueCrimson, 1)) // using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                    g.DrawRectangle(m_Pen, m_BorderRectangle);

                m_BorderRectangle.Inflate(-4, -4);

                using (Pen m_Pen = new Pen(TrueCrimson, 1)) // using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                    g.DrawRectangle(m_Pen, m_BorderRectangle);
            }
            else
            {
                // Draw gripper
                Rectangle m_GripRectangle = rect;

                m_GripRectangle.Width = gripWidth + 1;

                start = InterpolateColors(appointment.BorderColor, appointment.Color, 0.2f);
                end   = InterpolateColors(appointment.BorderColor, Color.White, 0.6f);

                using (LinearGradientBrush aGB = new LinearGradientBrush(rect, start, end, LinearGradientMode.Vertical))
                    g.FillRectangle(aGB, m_GripRectangle);

                using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                    g.DrawRectangle(m_Pen, rect);

                // Draw shadow lines
                int xLeft   = rect.X + 6;
                int xRight  = rect.Right + 1;
                int yTop    = rect.Y + 1;
                int yButton = rect.Bottom + 1;

                for (int i = 0; i < 5; i++)
                {
                    using (Pen shadow_Pen = new Pen(Color.FromArgb(70 - 12 * i, Color.Black)))
                    {
                        g.DrawLine(shadow_Pen, xLeft + i, yButton + i, xRight + i - 1, yButton + i); //horisontal lines
                        g.DrawLine(shadow_Pen, xRight + i, yTop + i, xRight + i, yButton + i);       //vertical
                    }
                }
            }

            rect.X += gripWidth;
            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            g.DrawString(appointment.Title, this.BaseFont, SystemBrushes.WindowText, rect, m_Format);
            g.TextRenderingHint = TextRenderingHint.SystemDefault;
        }
コード例 #59
0
        public void DrawChevron(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds, System.Drawing.Color color)
        {
            int xMiddle = (bounds.X + (bounds.Width / 2)) - 2;
            int yMiddle = bounds.Y + (bounds.Height / 2);

            graphics.SmoothingMode = SmoothingMode.HighQuality;
            using (Pen linePen = new Pen(color))
            {
                graphics.DrawLine(linePen, (int)(xMiddle - 1), (int)(yMiddle - 5), (int)(xMiddle + 1), (int)(yMiddle - 3));
                graphics.DrawLine(linePen, (int)(xMiddle - 1), (int)(yMiddle - 1), (int)(xMiddle + 1), (int)(yMiddle - 3));
                graphics.DrawLine(linePen, xMiddle, (int)(yMiddle - 5), (int)(xMiddle + 2), (int)(yMiddle - 3));
                graphics.DrawLine(linePen, xMiddle, (int)(yMiddle - 1), (int)(xMiddle + 2), (int)(yMiddle - 3));
                graphics.DrawLine(linePen, (int)(xMiddle + 2), (int)(yMiddle - 5), (int)(xMiddle + 4), (int)(yMiddle - 3));
                graphics.DrawLine(linePen, (int)(xMiddle + 2), (int)(yMiddle - 1), (int)(xMiddle + 4), (int)(yMiddle - 3));
                graphics.DrawLine(linePen, (int)(xMiddle + 3), (int)(yMiddle - 5), (int)(xMiddle + 5), (int)(yMiddle - 3));
                graphics.DrawLine(linePen, (int)(xMiddle + 3), (int)(yMiddle - 1), (int)(xMiddle + 5), (int)(yMiddle - 3));
                graphics.DrawLine(linePen, xMiddle, (int)(yMiddle + 4), (int)(xMiddle + 4), (int)(yMiddle + 4));
                graphics.DrawLine(linePen, (int)(xMiddle + 1), (int)(yMiddle + 5), (int)(xMiddle + 3), (int)(yMiddle + 5));
                graphics.DrawLine(linePen, (int)(xMiddle + 2), (int)(yMiddle + 6), (int)(xMiddle + 2), (int)(yMiddle + 4));
            }
        }
コード例 #60
0
 int line(int x, int y, int shift)
 {
     graphicsObj = Graphics.FromImage(bmp);
     graphicsObj.DrawLine(myPen, x, y, x + shift, y);
     return(x + shift);
 }