public void DrawString(string Text, Rect theRect, IFontStyleInfo theFont) { GDIFontStyle FontStyle = (GDIFontStyle)theFont; if (CurrentTextColor != FontStyle.Win32ForeColor) { CurrentTextColor = FontStyle.Win32ForeColor; API.SetTextColor(hDC, FontStyle.Win32ForeColor); } IntPtr hOldFont = API.SelectObject(hDC, ((GDIFont)FontStyle.Font).hFont); API.RECT r = new API.RECT(); r.Left = theRect.Location.X; r.Top = theRect.Location.Y; r.Right = theRect.Right; r.Bottom = theRect.Bottom; // API.DrawText(hDC, Text, Text.Length, ref r, 2368); API.ExtTextOut(hDC, r.Left, r.Top, 4, ref r, Text, (uint)Text.Length, null); API.SelectObject(hDC, hOldFont); // No need to Delete hFont because we're going to reuse it // it is being saved in GDIFontStyle FontStyle // API.DeleteObject(hFont); // No need to restore old text color // because we're setting it new each time anyway // API.SetTextColor(hDC, hOldColor); }
/// <summary> /// Whole redraw cycle - raises main Repaint event /// for the clients to redraw themselves. /// </summary> /// <remarks>Uses a back buffer, which is being copied to the screen.</remarks> /// <param name="ToRedraw">A rectangular area which should be updated (redrawn)</param> public void Redraw(Rect toRedraw) { // size of the backbuffer to use DrawOperations.Viewport.Size.Set(this.ClientSize); // first, clear the buffer with the background color Renderer.Clear(); // Commented out caret functionality from here. // Let the TextBox draw the caret instead. // Kirill // hide the caret and see if anyone needs it //Caret textCursor = RendererSingleton.MyCaret; //textCursor.Visible = false; // raise main Repaint event // clients (those who draw on this DrawWindow) // handle the event and draw everything there // (they use the Renderer that they become over a parameter) #if DEFINE_ShouldMeasureRedrawTime GuiLabs.Canvas.Utils.Timer t = new GuiLabs.Canvas.Utils.Timer(); t.Start(); #endif if (Repaint != null) { Repaint(Renderer); } #if DEFINE_ShouldMeasureRedrawTime t.Stop(); if (font == null) { font = DrawOperations.Factory.ProduceNewFontStyleInfo("Verdana", 14, FontStyle.Regular); font.ForeColor = System.Drawing.Color.Red; } DrawOperations.DrawString( t.TimeElapsed.ToString(), DrawOperations.Viewport, font); #endif // if someone needed the cursor, he/she turned it on // so we draw the cursor only if someone needs it // (e.g. an active TextBox control) //Renderer.DrawOperations.DrawCaret(textCursor); // finally, copy the buffer to the screen Renderer.RenderBuffer(this, toRedraw); }
public void DrawString(string Text, Rect theRect, IFontStyleInfo theFont) { if (theFont.ForeColor != textBrush.Color) { textBrush.Color = theFont.ForeColor; } theRect.Location.FillPoint(ref textLocation); mGraphics.DrawString( Text, ((GDIPlusFontWrapper)(theFont.Font)).Font, textBrush, textLocation); }
/// <summary> /// ShapeStyle Constructor initializes the three objects with their default values. /// </summary> public ShapeStyle() { FillStyleInfo = RendererSingleton.Instance.DrawOperations.Factory.ProduceNewFillStyleInfo(System.Drawing.Color.White); LineStyleInfo = RendererSingleton.Instance.DrawOperations.Factory.ProduceNewLineStyleInfo(System.Drawing.Color.Black, 1); FontStyleInfo = RendererSingleton.Instance.DrawOperations.Factory.ProduceNewFontStyleInfo("Courier New", 10, System.Drawing.FontStyle.Regular); }
public void DrawStringWithSelection(Rect Block, int StartSelPos, int CaretPosition, string Text, IFontStyleInfo FontStyle) { TransformRect(Block); SourceDrawOperations.DrawStringWithSelection(R, StartSelPos, CaretPosition, Text, FontStyle); }
public void DrawString(string Text, Rect theRect, IFontStyleInfo theFont) { TransformRect(theRect); SourceDrawOperations.DrawString(Text, R, theFont); }
// TODO: Implement DrawStringWithSelection public void DrawStringWithSelection(Rect Block, int StartSelPos, int CaretPosition, string Text, IFontStyleInfo FontStyle) { }
public void DrawStringWithSelection( Rect Block, int StartSelPos, int CaretPosition, string Text, IFontStyleInfo FontStyle ) { // API.SetROP2(hDC, 14); // API.Rectangle(hDC, theRect.Location.X, theRect.Location.Y, theRect.Right, theRect.Bottom); // FillRectangle(theRect, selectionFillStyle); DrawString(Text, Block, FontStyle); if (StartSelPos == CaretPosition) return; int SelStart, SelEnd; if (CaretPosition > StartSelPos) { SelStart = StartSelPos; SelEnd = CaretPosition; } else { SelStart = CaretPosition; SelEnd = StartSelPos; } if (SelStart < 0) { SelStart = 0; } if (SelEnd > Text.Length) { SelEnd = Text.Length; } // Added the if-statement to check if the selection borders // are within the textlength string select = ""; if ((SelStart < Text.Length) && (SelEnd <= Text.Length)) select = Text.Substring(SelStart, SelEnd - SelStart); stringSize.Set(StringSize(Text.Substring(0, SelStart), FontStyle.Font)); stringPos.Set(Block.Location.X + stringSize.X, Block.Location.Y); stringRect.Set(stringPos, StringSize(select, FontStyle.Font)); FillRectangle(stringRect, System.Drawing.SystemColors.Highlight); System.Drawing.Color OldColor = FontStyle.ForeColor; FontStyle.ForeColor = System.Drawing.SystemColors.HighlightText; DrawString(select, stringRect, FontStyle); FontStyle.ForeColor = OldColor; }
public void DrawStringWithSelection ( Rect Block, int StartSelPos, int CaretPosition, string Text, IFontStyleInfo FontStyle ) { // API.SetROP2(hDC, 14); // API.Rectangle(hDC, theRect.Location.X, theRect.Location.Y, theRect.Right, theRect.Bottom); // FillRectangle(theRect, selectionFillStyle); DrawString(Text, Block, FontStyle); if (StartSelPos == CaretPosition) { return; } int SelStart, SelEnd; if (CaretPosition > StartSelPos) { SelStart = StartSelPos; SelEnd = CaretPosition; } else { SelStart = CaretPosition; SelEnd = StartSelPos; } if (SelStart < 0) { SelStart = 0; } if (SelEnd > Text.Length) { SelEnd = Text.Length; } // Added the if-statement to check if the selection borders // are within the textlength string select = ""; if ((SelStart < Text.Length) && (SelEnd <= Text.Length)) { select = Text.Substring(SelStart, SelEnd - SelStart); } stringSize.Set(StringSize(Text.Substring(0, SelStart), FontStyle.Font)); stringPos.Set(Block.Location.X + stringSize.X, Block.Location.Y); stringRect.Set(stringPos, StringSize(select, FontStyle.Font)); FillRectangle(stringRect, System.Drawing.SystemColors.Highlight); System.Drawing.Color OldColor = FontStyle.ForeColor; FontStyle.ForeColor = System.Drawing.SystemColors.HighlightText; DrawString(select, stringRect, FontStyle); FontStyle.ForeColor = OldColor; }