Inheritance: GDIObject
Exemple #1
0
        public TextTest(Size aSize)
        {
            fSize = aSize;
            fOrigin = new Point(0, 0);
            fTextColor = RGBColor.Red;
            fFont = new GDIFont("Algerian", 96, Guid.NewGuid());
            fStringMessage = "Hello World!";

            Dimension = aSize;
        }
Exemple #2
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();

        }
        /// <summary>
        /// Default constructor for the window.  The window is located at 0,0 with
        /// a size of 640,480
        /// </summary>
		public KeyboardTestWindow()
			: base("KeyboardTestWindow",10,10,640,480)
		{
            PrintKeyboards();
            PrintMice();

            fFont = new GDIFont("Courier", 12);

			TextStr0 = "00000000 00000000 00000000 00000000 <-- KeyData\n-------- -------- -----------------\n|||    |     |            |        \n|||    |     |            |____ repeat count\n|||    |     |_________________ OEM code\n|||    |_______________ extended key flag\n|||____________________ context code\n||_____________________ previous key state\n|______________________ transition state";
			BuffStr0 = TextStr0.ToCharArray(0,TextStr0.Length);

			TextStr1 = "-------- -------- 00000000 00000000 <-- wParam\n";
			BuffStr1 = TextStr1.ToCharArray(0,TextStr1.Length);

			TextStr2 = "CHARACTER TYPED:   ";
			BuffStr2 = TextStr2.ToCharArray(0,TextStr2.Length);

			TextStr3 = "Backspace key:   ";
			BuffStr3 = TextStr3.ToCharArray(0,TextStr3.Length);
			
			TextStr4 = "Shift state:      ";
			BuffStr4 = TextStr4.ToCharArray(0,TextStr4.Length);

			StrON = "ON ";
			StrOFF = "OFF";

			fCharTypedLabel = new StringLabel("Character Typed", "Courier", 30, 0, 0);
            AddGraphic(fCharTypedLabel);
			
            fBackspaceLabel = new StringLabel("Backspace Key", "Courier", 30, 10, 17 * 17);
            AddGraphic(fBackspaceLabel);
			
            fShiftLabel = new StringLabel("Shift State", "Courier", 30, 0, 0);
			
			// Cell Layout thing
            //Rectangle frame = new Rectangle(0, 0, 400, 60);
            //GraphicGroup cellGroup = new GraphicGroup("cellGroup", frame);
            //cellGroup.LayoutHandler = new GraphicCell(Position.Right, 4); 
            //cellGroup.AddGraphic(fCharTypedLabel, null);

			// Binary layout thing
            //GraphicGroup binaryGroup = new GraphicGroup("binaryGroup", frame);
            //binaryGroup.LayoutHandler = new BinaryLayout(Position.BottomRight, 4); 
            //binaryGroup.AddGraphic(cellGroup, null);
            //binaryGroup.AddGraphic(fShiftLabel, null);

			
            //AddGraphic(binaryGroup, null);
            
            
            //BackgroundColor = RGBColor.LtGray;
		}
Exemple #4
0
 public TextRun(GDIFont aFont, int x, int y, int width, int height)
     :base("TextRun", x, y, width, height)
 {
     fIndexOfFirstCharacter = 0;
     fIndexOfNextCharacter = 0;
     fIndexOfLastCharacter = -1;
     fCharacters = new List<char>();
     fFont = aFont;
     fFontSize = fFont.MeasureString("W");
     Rectangle frame = Frame;
     frame.Height = fFontSize.Height;
     Frame = frame;
 }
        TextRun fCurrentTextRun;    // The TextRun object used to display the text
        #endregion

        #region Constructors
        public SingleLineTextEditor(string name, int x, int y, int width, int height)
            : base(name, x, y, width, height)
        {
            //Debug = true;
            SetEditMode(EditMode.Insert);

            fFont = new GDIFont("Courier", 24, Guid.NewGuid());
            fFontSize = fFont.MeasureString("W");

            fCaretStartPosition = new Point(4, 4);
            fCaretPosition = fCaretStartPosition;
            fCharacterPosition = 0;

            fCurrentTextRun = new TextRun(fFont, fCaretStartPosition.X, fCaretStartPosition.Y, fFontSize.Width, fFontSize.Height);
        }
        public void AddDeliverable(string deliverable)
		{
            GDIFont font = new GDIFont("Tahoma", 6, Guid.NewGuid());
			TextBox tBox = new TextBox(deliverable, "Tahoma", 6, GDIFont.FontStyle.Regular, 0, 0, Frame.Width - 6, (int)((font.Height*2)/72F), 0);

            //StringFormat aFormat = new StringFormat();
            //aFormat.Alignment = StringAlignment.Near;
            //aFormat.LineAlignment = StringAlignment.Near;
			//aFormat.Trimming = StringTrimming.Word;
			//aFormat.FormatFlags |= StringFormatFlags.NoClip;
			//aFormat.FormatFlags |= StringFormatFlags.NoWrap;

			//tBox.StringFormat = aFormat;


			AddGraphic(tBox);

		}
Exemple #7
0
        public StringLabel(string aString, string aFontName, int pointSize, int x, int y, GFont.FontStyle style)
            : base("StringLabel",x,y,0,0)
        {
			// WAA
			fNeedsCalculation = true;
			fStyle = style;
            fString = aString;
            fFontName = aFontName;
			fPointSize = pointSize;
			fStartPoint = new Point(x,y);
            fBasePoint = new Point(x, y);
 
			fTextColor = RGBColor.Black;
            fBackColor = RGBColor.TRANSPARENT;
            fBrush = new GBrush(fTextColor);

            fFont = new GDIFont(fFontName, fPointSize);

			Recalculate();
        }
Exemple #8
0
        public TextBox(string aString, string aFontName, int pointSize, FontStyle style, 
            int x, int y, int width, int height, 
            StringAlignment align, StringAlignment lineAlign, uint txtColor, Graphic background)
			: base("TextBox", x, y, width, height)
		{
			fBackground = background;
			fString = aString;
			fFontName = aFontName;
			fPointSize = pointSize;
			fFontStyle = style;
            fFont = new GDIFont(fFontName, fPointSize);

			fTextColor = txtColor;
			fBackColor = RGBColor.TRANSPARENT;
            fHAlignment = align;
            fVAlignment = lineAlign;

            CalculateTextOrigin();

            //fStringFormat = new StringFormat();
            //fStringFormat.Alignment = align;
            //fStringFormat.LineAlignment = lineAlign;
        }
Exemple #9
0
 public GlyphRunG(string aString, GDIFont aFont)
 {
     fFont = aFont;
     fString = aString;
 }
Exemple #10
0
 public virtual void SelectObject(GDIFont aFont)
 {
 }
Exemple #11
0
        public virtual void SetFont(GDIFont aFont)
        {
            // 1. Check to see if the font object already exists in our
            // list of objects
            bool containsObject = fObjectDictionary.ContainsKey(aFont.UniqueID);

            // 2. If the object is already in the dictionary, then select
            // it as the current font and return.
            if (containsObject) // and the object is a brush
            {
                // Get a hold of the actual object in the dictionary
                GDIObject aUniqueObject = fObjectDictionary[aFont.UniqueID];

                // Select it based on it's handle
                if (aUniqueObject != null)
                    DeviceContext.SelectObject(aUniqueObject);

                return;
            }

            // 3. If the font is not found, then create a new font, 
            // and put it into the table.
            CreateFont(aFont.FaceName, aFont.Height, aFont.UniqueID);

            // 4. Select the new font
            SelectUniqueObject(aFont.UniqueID);
        }
Exemple #12
0
 public virtual void CreateFont(string faceName, int height, Guid aGuid)
 {
     GDIFont aFont = new GDIFont(faceName, height, aGuid);
     fObjectDictionary.Add(aGuid, aFont);
 }
Exemple #13
0
        public TextBox(string aString, string aFontName, int pointSize, GDIFont.FontStyle style, int x, int y, int width, int height, Graphic background)
			: this(aString, aFontName, pointSize, style, x, y, width, height, StringAlignment.Center, StringAlignment.Center, RGBColor.Black, background)
		{
		}
Exemple #14
0
        public TextBox(string aString, string aFontName, int pointSize, GDIFont.FontStyle style, int x, int y, int width, int height, uint txtColor)
			:this(aString,aFontName,pointSize,style,x,y,width,height,StringAlignment.Center,StringAlignment.Center,txtColor,null)
		{
		}
Exemple #15
0
 public virtual void SetFont(GDIFont aFont)
 {
 }
Exemple #16
0
        public static void Pack(BufferChunk chunk, GDIFont aFont)
        {
            chunk += GDI32.EMR_EXTCREATEFONTINDIRECTW;

            chunk += aFont.FaceName.Length;
            chunk += aFont.FaceName;
            chunk += (int)aFont.Height;
            chunk += (byte)1; // newFont.fLogFont.lfCharSet;
            chunk += (byte)0; // newFont.fLogFont.lfClipPrecision;
            chunk += (int)0; // newFont.fLogFont.lfEscapement;
            chunk += (byte)0; // newFont.fLogFont.lfItalic;
            chunk += (int)0; // newFont.fLogFont.lfOrientation;
            chunk += (byte)0; // newFont.fLogFont.lfOutPrecision;
            chunk += (byte)0; // newFont.fLogFont.lfPitchAndFamily;
            chunk += (byte)0; // newFont.fLogFont.lfQuality;
            chunk += (byte)0; // newFont.fLogFont.lfStrikeOut;
            chunk += (byte)0; // newFont.fLogFont.lfUnderline;
            chunk += (int)0; // newFont.fLogFont.lfWeight;
            chunk += (int)0; // newFont.fLogFont.lfWidth;

            // Write the GUID
            Pack(chunk, aFont.UniqueID);
        }
    public override void CreateFont(string faceName, int height, Guid uniqueID)
    {
        Font newFont = new GDIFont(faceName, height, uniqueID);

        BufferChunk chunk = new BufferChunk(1024);
        chunk += GDI32.EMR_EXTCREATEFONTINDIRECTW;

        chunk += faceName.Length;
        chunk += faceName;
        chunk += (int)height;
        chunk += (byte)1; // newFont.fLogFont.lfCharSet;
        chunk += (byte)0; // newFont.fLogFont.lfClipPrecision;
        chunk += (int)0; // newFont.fLogFont.lfEscapement;
        chunk += (byte)0; // newFont.fLogFont.lfItalic;
        chunk += (int)0; // newFont.fLogFont.lfOrientation;
        chunk += (byte)0; // newFont.fLogFont.lfOutPrecision;
        chunk += (byte)0; // newFont.fLogFont.lfPitchAndFamily;
        chunk += (byte)0; // newFont.fLogFont.lfQuality;
        chunk += (byte)0; // newFont.fLogFont.lfStrikeOut;
        chunk += (byte)0; // newFont.fLogFont.lfUnderline;
        chunk += (int)0; // newFont.fLogFont.lfWeight;
        chunk += (int)0; // newFont.fLogFont.lfWidth;

        // Write the GUID
        chunk += (int)16; // For size of the following array
        chunk += newFont.UniqueID.ToByteArray();

        PackCommand(chunk);

    }