Inheritance: Pen, IDisposable
Exemple #1
0
        public void RunOnce(GDIRenderer aPort)
        {
            int cxClient = fSize.Width;
            int cyClient = fSize.Height;

            aPort.SaveState();

            GDIPen rectPen = new GDICosmeticPen(PenStyle.Solid, RGBColor.Black, Guid.NewGuid());
            GDISolidBrush rectBrush = new GDISolidBrush(RGBColor.White);

            // Do a rectangle
            Rectangle rect = Rectangle.FromLTRB(cxClient / 8, cyClient / 8,
                (7 * cxClient / 8), (7 * cyClient / 8));
            aPort.FillRectangle(rectBrush, rect.Left, rect.Top, rect.Width, rect.Height);
            aPort.DrawRectangle(rectPen, rect.Left, rect.Top, rect.Width, rect.Height);

            // Now do a couple of lines using a dash/dot/dot pen
            GDIPen aPen = new GDIPen(PenType.Cosmetic, PenStyle.DashDotDot, PenJoinStyle.Round, PenEndCap.Round, RGBColor.Black, 1, Guid.NewGuid());
            aPort.DrawLine(aPen, new Point(0, 0), new Point(cxClient, cyClient));
            aPort.DrawLine(aPen, new Point(0, cyClient), new Point(cxClient, 0));

            // Now an ellipse
            aPort.DrawEllipse(aPen, rect);

            // Last, a rounded rectangle
            Rectangle rRect = Rectangle.FromLTRB(cxClient / 4, cyClient / 4,
                3 * cxClient / 4, 3 * cyClient / 4);
            aPort.DrawRoundRect(aPen, rRect, cxClient / 4, cyClient / 4);

            aPort.ResetState();
  
        }
    public virtual Pen CreatePen(int aStyle, int width, uint color, Guid uniqueID)
    {
        GDIPen aPen = new GDIPen(aStyle, width, color, uniqueID);
        fObjectDictionary.Add(uniqueID, aPen);

        return aPen;
    }
Exemple #3
0
 static GDICosmeticPen()
 {
     Black = new GDICosmeticPen((Colorref)Colorrefs.Black);
     Red = new GDICosmeticPen((Colorref)Colorrefs.Red);
     Green = new GDICosmeticPen((Colorref)Colorrefs.Green);
     Blue = new GDICosmeticPen((Colorref)Colorrefs.Blue);
 }
Exemple #4
0
        public SketchWindow(int width, int height)
            :base()
        {
            InitializeComponent();

            fBlackPen = new GDIPen(RGBColor.Black);

            this.Size = new System.Drawing.Size(width, height);
            this.Text = "Sketcher";
            this.AllowDrop = true;

            fPointList = new List<Point>();

            // Create the backing buffer to retain the image
            // Make it bigger than any likely displays
            backingBuffer = GDIDIBSection.Create(1600, 1200);
            GDIContext bufferContext = GDIContext.CreateForBitmap(backingBuffer);

            bufferContext.ClearToWhite();
            fBackingGraphPort = new GDIRenderer(bufferContext);

            fRetainedGraphPort = new GraphPortDelegate();
            fRetainedGraphPort.AddGraphPort(fBackingGraphPort);
            fRetainedGraphPort.AddGraphPort(GraphPort);

            CreateSession();

        }
Exemple #5
0
 public static void Pack(BufferChunk chunk, GDIPen aPen)
 {
     chunk += GDI32.EMR_CREATEPEN;
     chunk += (int)aPen.Style;
     chunk += 1;
     chunk += aPen.Color;
     Pack(chunk, aPen.UniqueID);
 }
Exemple #6
0
        public BezierTest(Size aSize)
        {
            fFigure = new Point[4];
            Dimension = aSize;

            fBlackPen = new GDIPen(RGBColor.Black);
            fRedPen = new GDIPen(RGBColor.Red);
        }
Exemple #7
0
    public GRectangle(string name, int x, int y, int width, int height, uint bkColor, uint borderColor, float weight)
        :base(name, x, y, width, height)
	{
        fRectangle = new RectangleG(0, 0, width, height);
		fBackColor = bkColor;
		fBorderColor = borderColor;

        fPen = new GDIPen(fBorderColor);
	}
Exemple #8
0
		public GraphicArrow(string name, int frameLeft, int frameTop, int width, int height,
			uint fillColor, uint borderColor)
            : base(name, frameLeft, frameTop, width, height)
		{
            fPen = new GDIPen(borderColor);
            fBrush = new GDIBrush(BrushStyle.Solid, HatchStyle.Vertical, fillColor, Guid.NewGuid());
            fFillColor = fillColor;
			fBorderColor = borderColor;

			UpdateGeometryState();
        }
Exemple #9
0
    public GraphicLine(string name, int x1, int y1, int x2, int y2, uint color, int width)
        :base(name, x1,y1, x2-x1, y2-y1)
	{
        fLine = new LineG(new Point(x1, y1), new Point(x2, y2));

		fWidth = width;
		fColor = color;

		// The weight is in points, so we need to convert to local units.
		// In this case, we'll go with inches.
        fPen = new GDIPen(PenType.Geometric, PenStyle.Solid, PenJoinStyle.Round, PenEndCap.Round, color, Frame.Width, Guid.NewGuid());
	}
		public GradientRectangle(int x, int y, int width, int height, uint colorBegin, uint colorEnd, uint colorBorder, float angle)
			:base("GradientRectangle",x,y,width,height)
		{
			fColorBegin = colorBegin;
			fColorEnd = colorEnd;
			fColorBorder = colorBorder;
			fAngle = angle;
            fBorderPen = new GDIPen(PenType.Cosmetic, PenStyle.Solid, PenJoinStyle.Round, PenEndCap.Round, colorBorder, 1, Guid.NewGuid());

            fGradient = new GradientRect(0, 0, width, height, colorBegin, colorEnd, GradientRectDirection.Vertical);
            fBorder = new System.Drawing.Rectangle(0, 0, width, height);
        }
Exemple #11
0
        public void RunOnce(GDIRenderer aPort)
        {
            // Do some path stuff
            GPath aPath = new GPath();
            
            aPath.Begin();
            aPath.MoveTo(10, 10, false);
            aPath.LineTo(10, 100, false);
            aPath.LineTo(100, 100, true);
            aPath.End();

            GDIBrush pathBrush = new GDIBrush(BrushStyle.Solid, HatchStyle.BDiagonal, RGBColor.Cyan, Guid.NewGuid());
            aPort.FillPath(pathBrush, aPath);

            GDIPen pathPen = new GDIPen(PenType.Geometric, 
                PenStyle.Solid, 
                PenJoinStyle.Round, 
                PenEndCap.Round, 
                RGBColor.Black, 
                10, 
                Guid.NewGuid());
            //aPort.DrawPath(pathPen, aPath);

            // Now use a GDIPath
            aPort.SetBkMode((int)BackgroundMixMode.Transparent);
            aPort.SetTextColor(RGBColor.Black);

            GDIFont aFont = new GDIFont("Impact", 96, Guid.NewGuid());

            GDIContext dc = aPort.DeviceContext;
            GDIPath gdipath = new GDIPath(dc, Guid.NewGuid());
            gdipath.Begin();
            aPort.SetFont(aFont);
            aPort.DrawString(200, 200, "The Scaled Text");
            gdipath.End();
            aPort.Flush();

            // First fill the text
            aPort.FillPath(pathBrush, gdipath);

            // Then stroke the path around it
            GDIPen textPen = new GDIPen(PenType.Geometric,
                PenStyle.Solid,
                PenJoinStyle.Round,
                PenEndCap.Round,
                RGBColor.Black,
                2,
                Guid.NewGuid());
            aPort.DrawPath(textPen, gdipath);
            aPort.Flush();

        }
	public ClockWindow()
		:base("Digital Clock",10,10,320,110)
	{
        //BackgroundColor = RGBColor.LtGray;

        fBlackPen = new GDICosmeticPen(PenStyle.Solid, Colorrefs.Black, Guid.NewGuid());
        fBackgroundBrush = new GDIBrush(BrushStyle.Solid, HatchStyle.Vertical, Colorrefs.Black, Guid.NewGuid());

        fIsTracking = false;
        fClockDisplay = new DigitalClockDisplay(true, false);
        //SetWindowAlpha(128);

        StartTimer(1000);
	}
Exemple #13
0
        public static GDIPen UnpackGPen(BufferChunk chunk)
        {
            uint     penColor;
            PenStyle penStyle;
            Guid     uniqueID;
            int      penSize;

            penStyle = (PenStyle)chunk.NextInt32();
            penSize  = chunk.NextInt32();
            penColor = chunk.NextUInt32();
            uniqueID = UnpackGuid(chunk);

            GDIPen aPen = new GDIPen(PenType.Cosmetic, PenStyle.Solid, PenJoinStyle.Round, PenEndCap.Round, penColor, penSize, uniqueID);

            return(aPen);
        }
Exemple #14
0
        public void RunOnce(GDIRenderer aPort)
        {
            int i;
            int cxClient = fSize.Width;
            int cyClient = fSize.Height;
            Point[] points = new Point[fNumSegments];

            aPort.SaveState();

            GDIPen redPen = new GDIPen(RGBColor.Red);
            aPort.DrawLine(redPen, new Point(0, cyClient/2), new Point(cxClient, cyClient / 2));

            GDIPen blackPen = new GDIPen(RGBColor.Black);
            for (i = 0; i < fNumSegments; i++)
            {
                points[i].X = i * cxClient / fNumSegments;
                points[i].Y = (int)(((double)cyClient/2.0f)*(1.0f-Math.Sin(Math.PI*2.0f*(double)i/(double)fNumSegments)));
            }

            aPort.DrawLines(blackPen, points);


            aPort.ResetState();
        }
Exemple #15
0
        public static GDIPen UnpackGPen(BufferChunk chunk)
        {
            uint penColor;
            PenStyle penStyle;
            Guid uniqueID;
            int penSize;

            penStyle = (PenStyle)chunk.NextInt32();
            penSize = chunk.NextInt32();
            penColor = chunk.NextUInt32();
            uniqueID = UnpackGuid(chunk);

            GDIPen aPen = new GDIPen(PenType.Cosmetic, PenStyle.Solid, PenJoinStyle.Round, PenEndCap.Round, penColor, penSize, uniqueID);
            return aPen;            
        }