// Select this brush into a graphics object. public override void Select(IToolkitGraphics graphics) { Win32.Api.SetTextColor((graphics as DrawingGraphics).hdc, backColor); Win32.Api.SetBkColor((graphics as DrawingGraphics).hdc, foreColor); base.Select(graphics); }
// Select this brush into a graphics object. public override void Select(IToolkitGraphics graphics) { Win32.Api.SetTextColor( (graphics as DrawingGraphics).hdc, backColor); Win32.Api.SetBkColor( (graphics as DrawingGraphics).hdc,foreColor); base.Select(graphics); }
// Select this brush into a graphics object. public override void Select(IToolkitGraphics _graphics) { DrawingGraphics graphics = (_graphics as DrawingGraphics); if (graphics != null) { Xsharp.Graphics g = graphics.graphics; Xsharp.Bitmap bitmap; lock (typeof(DrawingHatchBrush)) { bitmap = GetBitmap(style); } g.Function = GCFunction.GXcopy; g.SubwindowMode = SubwindowMode.ClipByChildren; if (bitmap != null) { // Use an opaque stipple to fill the region. g.Foreground = DrawingToolkit.DrawingToXColor(foreColor); g.Background = DrawingToolkit.DrawingToXColor(backColor); g.SetFillOpaqueStippled(bitmap, 0, 0); } else { // We don't recognize this hatch style, so use a // solid brush with the foreground color. g.Foreground = DrawingToolkit.DrawingToXColor(foreColor); g.SetFillSolid(); } graphics.Brush = this; } }
// Select this brush into a graphics object. public override void Select(IToolkitGraphics _graphics) { DrawingGraphics graphics = (_graphics as DrawingGraphics); if(graphics != null) { Xsharp.Graphics g = graphics.graphics; Xsharp.Bitmap bitmap; lock(typeof(DrawingHatchBrush)) { bitmap = GetBitmap(style); } g.Function = GCFunction.GXcopy; g.SubwindowMode = SubwindowMode.ClipByChildren; if(bitmap != null) { // Use an opaque stipple to fill the region. g.Foreground = DrawingToolkit.DrawingToXColor(foreColor); g.Background = DrawingToolkit.DrawingToXColor(backColor); g.SetFillOpaqueStippled(bitmap, 0, 0); } else { // We don't recognize this hatch style, so use a // solid brush with the foreground color. g.Foreground = DrawingToolkit.DrawingToXColor(foreColor); g.SetFillSolid(); } graphics.Brush = this; } }
// Select a brush-based pen into a graphics object. public override void Select(IToolkitGraphics graphics, IToolkitBrush brush) { // Set the basic line information first. Select(graphics); // Select the brush details into the graphics context. brush.Select(graphics); }
// Create a "Graphics" object from an "IToolkitGraphics" handler. public static Graphics CreateGraphics(IToolkitGraphics graphics) { if (graphics == null) { throw new ArgumentNullException("graphics"); } return(new Graphics(graphics)); }
// Create a "Graphics" object from an "IToolkitGraphics" handler. public static Graphics CreateGraphics(IToolkitGraphics graphics, Rectangle baseWindow) { if (graphics == null) { throw new ArgumentNullException("graphics"); } return(new Graphics(graphics, baseWindow)); }
// Window Constructor. Copies the existing Graphics and creates a new // Graphics that has an origin of baseWindow.Location and is always clipped // to baseWindow internal Graphics(IToolkitGraphics graphics, Rectangle baseWindow) : this(graphics) { this.baseWindow = baseWindow; clip = new Region(baseWindow); clip.Translate(-baseWindow.X, -baseWindow.Y); Clip = clip; }
// Get a list of all font families on this system, or all font // families that are compatible with a particular IToolkitGraphics. public FontFamily[] GetFontFamilies(IToolkitGraphics graphics) { // We only support three font families. Extend later. return(new FontFamily [] { new FontFamily("Arial"), new FontFamily("Times New Roman"), new FontFamily("Courier New"), }); }
// Select this font into a graphics object. public void Select(IToolkitGraphics graphics) { if ((graphics as DrawingGraphics).Font == this) return; Win32.Api.SelectObject((graphics as DrawingGraphics).hdc, hFont); (graphics as DrawingGraphics).Font = this; Win32.Api.SetBkMode((graphics as DrawingGraphics).hdc,Win32.Api.BackGroundModeType.TRANSPARENT); }
// Constructor. internal Graphics(IToolkitGraphics graphics) { this.graphics = graphics; this.clip = null; this.transform = null; this.pageScale = 1.0f; this.pageUnit = GraphicsUnit.World; this.stackTop = null; this.baseWindow = Rectangle.Empty; }
// Select this font into a graphics object. public void Select(IToolkitGraphics graphics) { if ((graphics as DrawingGraphics).Font == this) { return; } Win32.Api.SelectObject((graphics as DrawingGraphics).hdc, hFont); (graphics as DrawingGraphics).Font = this; Win32.Api.SetBkMode((graphics as DrawingGraphics).hdc, Win32.Api.BackGroundModeType.TRANSPARENT); }
}; // class FamilyComparer // Get a list of all font families on this system, or all font // families that are compatible with a particular IToolkitGraphics. public FontFamily[] GetFontFamilies(IToolkitGraphics graphics) { lock (this) { if (families != null) { return(families); } String[] names = app.Display.FontFamilies; int size = names.Length; if (Array.IndexOf(names, "microsoft sans serif") == -1) { ++size; } if (Array.IndexOf(names, "arial") == -1) { ++size; } if (Array.IndexOf(names, "times new roman") == -1) { ++size; } if (Array.IndexOf(names, "courier new") == -1) { ++size; } families = new FontFamily [size]; size = 0; foreach (String name in names) { families[size++] = new FontFamily (CultureInfo.CurrentCulture.TextInfo. ToTitleCase(name)); } if (Array.IndexOf(names, "microsoft sans serif") == -1) { families[size++] = new FontFamily ("Microsoft Sans Serif"); } if (Array.IndexOf(names, "arial") == -1) { families[size++] = new FontFamily("Arial"); } if (Array.IndexOf(names, "times new roman") == -1) { families[size++] = new FontFamily("Times New Roman"); } if (Array.IndexOf(names, "courier new") == -1) { families[size++] = new FontFamily("Courier New"); } Array.Sort(families, new FamilyComparer()); return(families); } }
public void EndDoubleBuffer() { DrawingGraphics g = bufferGraphics as DrawingGraphics; // Copy the buffer hdc to the window hdc. Win32.Api.BitBlt(window.hdc, 0, 0, size.Width, size.Height, g.hdc, 0, 0, Win32.Api.RopType.SRCCOPY); // Remove out the bitmap from the hdc. Win32.Api.SelectObject(g.hdc, hOldBitmap); hOldBitmap = IntPtr.Zero; bufferGraphics.Dispose(); bufferGraphics = null; }
// Create a "Graphics" object from an "IToolkitGraphics" handler. // Start with a clip that has already been set in the underlying IToolkitGraphics. public static Graphics CreateGraphics(IToolkitGraphics graphics, Region clip) { if (graphics == null) { throw new ArgumentNullException("graphics"); } Graphics createdGraphics = new Graphics(graphics); createdGraphics.SetClipInternal(clip); return(createdGraphics); }
// Select this brush into a graphics object. public override void Select(IToolkitGraphics _graphics) { innerBrush.Select(_graphics); DrawingGraphics graphics = (_graphics as DrawingGraphics); if(graphics != null) { Xsharp.Graphics g = graphics.graphics; g.Function = GCFunction.GXxor; g.SubwindowMode = SubwindowMode.IncludeInferiors; } graphics.Brush = this; }
// Select this brush into a graphics object. public override void Select(IToolkitGraphics _graphics) { DrawingGraphics graphics = (_graphics as DrawingGraphics); if(graphics != null) { Xsharp.Graphics g = graphics.graphics; g.Function = GCFunction.GXcopy; g.SubwindowMode = SubwindowMode.ClipByChildren; g.SetFillSolid(); g.Foreground = DrawingToolkit.DrawingToXColor(Color); graphics.Brush = this; } }
// Select this brush into a graphics object. public override void Select(IToolkitGraphics _graphics) { innerBrush.Select(_graphics); DrawingGraphics graphics = (_graphics as DrawingGraphics); if (graphics != null) { Xsharp.Graphics g = graphics.graphics; g.Function = GCFunction.GXxor; g.SubwindowMode = SubwindowMode.IncludeInferiors; } graphics.Brush = this; }
// Select this brush into a graphics object. public void Select(IToolkitGraphics _graphics) { DrawingGraphics graphics = (_graphics as DrawingGraphics); if(graphics != null && image != null) { Xsharp.Graphics g = graphics.graphics; Xsharp.Image nativeImage = image.GetNativeImage(); g.Function = GCFunction.GXcopy; g.SubwindowMode = SubwindowMode.ClipByChildren; g.SetFillTiled(nativeImage.Pixmap, (int)(dstRect.X), (int)(dstRect.Y)); } }
// Select this brush into a graphics object. public override void Select(IToolkitGraphics _graphics) { DrawingGraphics graphics = (_graphics as DrawingGraphics); if (graphics != null) { Xsharp.Graphics g = graphics.graphics; g.Function = GCFunction.GXcopy; g.SubwindowMode = SubwindowMode.ClipByChildren; g.SetFillSolid(); g.Foreground = DrawingToolkit.DrawingToXColor(Color); graphics.Brush = this; } }
// Select this brush into a graphics object. public void Select(IToolkitGraphics _graphics) { DrawingGraphics graphics = (_graphics as DrawingGraphics); if (graphics != null && image != null) { Xsharp.Graphics g = graphics.graphics; Xsharp.Image nativeImage = image.GetNativeImage(); g.Function = GCFunction.GXcopy; g.SubwindowMode = SubwindowMode.ClipByChildren; g.SetFillTiled(nativeImage.Pixmap, (int)(dstRect.X), (int)(dstRect.Y)); } }
public override void Select(IToolkitGraphics graphics) { // See if the cached brush is for this hdc. if (selectedHdc != (graphics as DrawingGraphics).hdc) { // If we have previously selected into a different hdc, then delete and recreate. if (selectedHdc != IntPtr.Zero) { Win32.Api.DeleteObject(hBrush); } hBrush = image.BrushFromBitmap((graphics as DrawingGraphics).hdc); } base.Select(graphics); }
// Select this pen into a graphics object. public void Select(IToolkitGraphics _graphics) { PostscriptGraphics graphics = (_graphics as PostscriptGraphics); if (graphics != null) { if (selectedInto == graphics && graphics.selectObject == this) { // Same pen as last time, so don't output a // redundant version of the Postscript definitions. return; } if (selectedInto != null) { selectedInto.selectObject = null; selectedInto = null; } graphics.writer.WriteLine("grestore gsave"); switch (properties.PenType) { case PenType.SolidColor: { Color color = properties.Color; #if CONFIG_EXTENDED_NUMERICS graphics.writer.WriteLine ("{0} {1} {2} setrgbcolor", ((double)(color.R)) / 255.0, ((double)(color.G)) / 255.0, ((double)(color.B)) / 255.0); #endif } break; // TODO: other pen types } #if CONFIG_EXTENDED_NUMERICS graphics.writer.WriteLine("{0} setlinewidth", properties.Width); #else graphics.writer.WriteLine("{0} setlinewidth", (int)(properties.Width)); #endif // TODO: caps, joins, miters, etc selectedInto = graphics; graphics.selectObject = this; } }
// Select this pen into a graphics object. public void Select(IToolkitGraphics _graphics) { PostscriptGraphics graphics = (_graphics as PostscriptGraphics); if(graphics != null) { if(selectedInto == graphics && graphics.selectObject == this) { // Same pen as last time, so don't output a // redundant version of the Postscript definitions. return; } if(selectedInto != null) { selectedInto.selectObject = null; selectedInto = null; } graphics.writer.WriteLine("grestore gsave"); switch(properties.PenType) { case PenType.SolidColor: { Color color = properties.Color; #if CONFIG_EXTENDED_NUMERICS graphics.writer.WriteLine ("{0} {1} {2} setrgbcolor", ((double)(color.R)) / 255.0, ((double)(color.G)) / 255.0, ((double)(color.B)) / 255.0); #endif } break; // TODO: other pen types } #if CONFIG_EXTENDED_NUMERICS graphics.writer.WriteLine("{0} setlinewidth", properties.Width); #else graphics.writer.WriteLine("{0} setlinewidth", (int)(properties.Width)); #endif // TODO: caps, joins, miters, etc selectedInto = graphics; graphics.selectObject = this; } }
public IToolkitGraphics BeginDoubleBuffer() { Size newSize = (window as IToolkitWindow).Dimensions.Size; // If the size changes, we need to recreate the buffer. if (size != newSize) { DeleteBuffer(); CreateBuffer(newSize); } // Setup the hdc. IntPtr hBitmapDC = Win32.Api.CreateCompatibleDC(window.hdc); hOldBitmap = Win32.Api.SelectObject(hBitmapDC, hBitmap); // Create a DrawingGraphics from the hdc. bufferGraphics = new DrawingGraphics(window.Toolkit, hBitmapDC); return bufferGraphics; }
// Select this font into a graphics object. public void Select(IToolkitGraphics _graphics) { DrawingGraphics graphics = (_graphics as DrawingGraphics); if(graphics != null) { lock(this) { if(xfont == null) { xfont = Xsharp.Font.CreateFont (properties.Name, (int)(properties.SizeInPoints * (10.0f * (PointSizeConversion/dpi))), (Xsharp.FontStyle)(properties.Style)); } graphics.Font = this; } } }
public IToolkitGraphics BeginDoubleBuffer() { Size newSize = (window as IToolkitWindow).Dimensions.Size; // If the size changes, we need to recreate the buffer. if (size != newSize) { DeleteBuffer(); CreateBuffer(newSize); } // Setup the hdc. IntPtr hBitmapDC = Win32.Api.CreateCompatibleDC(window.hdc); hOldBitmap = Win32.Api.SelectObject(hBitmapDC, hBitmap); // Create a DrawingGraphics from the hdc. bufferGraphics = new DrawingGraphics(window.Toolkit, hBitmapDC); return(bufferGraphics); }
// Select this font into a graphics object. public void Select(IToolkitGraphics _graphics) { DrawingGraphics graphics = (_graphics as DrawingGraphics); if (graphics != null) { lock (this) { if (xfont == null) { xfont = Xsharp.Font.CreateFont (properties.Name, (int)(properties.SizeInPoints * (10.0f * (PointSizeConversion / dpi))), (Xsharp.FontStyle)(properties.Style)); } graphics.Font = this; } } }
// Create a Graphics that is internally offset to baseWindow internal Graphics(Graphics graphics, Rectangle baseWindow) { // Use the same toolkit this.graphics = graphics.graphics; if (graphics.clip != null) { clip = graphics.clip.Clone(); clip.Intersect(baseWindow); } else clip = new Region(baseWindow); // Find out what the clip is with our new Origin clip.Translate(-baseWindow.X, -baseWindow.Y); this.baseWindow = baseWindow; if (graphics.transform != null) this.transform = new Matrix(graphics.transform); this.pageScale = graphics.pageScale; this.pageUnit = graphics.pageUnit; this.stackTop = null; Clip = clip; }
// Create a "Graphics" object from an "IToolkitGraphics" handler. public static Graphics CreateGraphics(IToolkitGraphics graphics) { if(graphics == null) { throw new ArgumentNullException("graphics"); } return new Graphics(graphics); }
// Select this brush into a graphics object. public override void Select(IToolkitGraphics graphics) { // TODO: need to handle the XOR property. innerBrush.Select(graphics); }
// Get the LOGFONT information for this toolkit font. public void ToLogFont(Object lf, IToolkitGraphics graphics) { // Nothing to do here in this implementation. }
// Select a brush-based pen into a graphics object. public override void Select(IToolkitGraphics graphics, IToolkitBrush brush) { Select(graphics); }
// Calculate and draw the string by drawing each line. public void Draw (Graphics graphics, String text, Font font, Rectangle drawLayout, StringFormat format, Brush brush) { // set the current graphics this.graphics = graphics; // set the current toolkit graphics this.toolkitGraphics = graphics.ToolkitGraphics; // set the current text this.text = text; // set the current font this.font = font; // set the current layout rectangle this.layout = drawLayout; // set the current brush this.brush = brush; // ensure we have a string format if(format == null) { format = SF_DEFAULT; } // set the current string format this.format = format; // set the default hotkey index this.hotkeyIndex = -1; // set the current line height lineHeight = font.Height; // set the only whole lines flag onlyWholeLines = (((format.FormatFlags & StringFormatFlags.LineLimit) != 0) || ((format.Trimming & StringTrimming.None) != 0)); // set the index of the next character nextIndex = 0; // set the current line space usage lineSpaceUsedUp = 0; // set the current line number lineNumber = 0; // set the previous span ended in new line flag prevIsNewLine = false; // select the current font into the graphics context graphics.SelectFont(font); // select the current brush into the graphics context graphics.SelectBrush(brush); // set the current text start int textStart = 0; // set the current text length int textLength = 0; // set the current text width int textWidth = 0; // get the actual hotkey index, if needed if(format.HotkeyPrefix != HotkeyPrefix.None) { // get the hotkey index hotkeyIndex = text.IndexOf('&'); // handle the hotkey as needed if(hotkeyIndex != -1) { if(hotkeyIndex >= (text.Length - 1) || Char.IsControl(text[hotkeyIndex + 1])) { // no need for this anymore hotkeyIndex = -1; } else { // remove the hotkey character text = text.Substring(0, hotkeyIndex) + text.Substring(hotkeyIndex + 1); // set the current text this.text = text; // prepare to show or hide the underline if(format.HotkeyPrefix == HotkeyPrefix.Show) { // get the underline font underlineFont = new Font (font, font.Style | FontStyle.Underline); } else { // no need for this anymore hotkeyIndex = -1; } } } } // draw the text try { // handle drawing based on line alignment if(format.LineAlignment == StringAlignment.Near) { // set the current y position int y = layout.Top; // get the maximum y position int maxY = layout.Bottom; // adjust for whole lines, if needed if(onlyWholeLines) { maxY -= ((maxY - y) % lineHeight); } // get the last line y position int lastLineY = maxY - lineHeight; // create character spans CharSpan span = new CharSpan(); CharSpan prev = new CharSpan(); // set the first span flag bool firstSpan = true; // process the text while(nextIndex < text.Length) { // get the next span of characters GetNextSpan(span); // draw the pending line, as needed if(span.newline && !firstSpan) { // draw the line, if needed if(textWidth > 0) { // remove trailing spaces, if needed if(!firstSpan && text[prev.start] == ' ') { // update text width textWidth -= GetSpanWidth(prev); // update text length textLength -= prev.length; } // draw the line DrawLine (textStart, textLength, textWidth, y, (y > lastLineY)); } // update the y position y += lineHeight; // update the line number ++lineNumber; // update the text start textStart = span.start; // reset the text length textLength = 0; // reset the text width textWidth = 0; } // update the text length textLength += span.length; // update the text width textWidth += GetSpanWidth(span); // copy span values to previous span span.CopyTo(prev); // set the first span flag firstSpan = false; // break if the y position is out of bounds if(y > maxY) { break; } } // draw the last line, if needed if(textWidth > 0 && y <= maxY) { // draw the last line DrawLine (textStart, textLength, textWidth, y, (y > lastLineY)); } } else { // set default lines to draw int linesToDraw = 0; // calculate lines to draw if(onlyWholeLines) { linesToDraw = layout.Height / lineHeight; } else { linesToDraw = (int)Math.Ceiling((double)layout.Height / lineHeight); } // create line span list LineSpan[] lines = new LineSpan[linesToDraw]; // create character spans CharSpan span = new CharSpan(); CharSpan prev = new CharSpan(); // set the first span flag bool firstSpan = true; // set the current line position int linePos = 0; // populate line span list while(linePos < lines.Length && nextIndex < text.Length) { // get the next span of characters GetNextSpan(span); // handle span on new line if(span.newline && !firstSpan) { // remove trailing spaces, if needed if(!firstSpan && text[prev.start] == ' ') { // update text width textWidth -= GetSpanWidth(prev); // update text length textLength -= prev.length; } // create line span for current line LineSpan lineSpan = new LineSpan (textStart, textLength, textWidth); // add current line span to line span list lines[linePos++] = lineSpan; // update text start textStart = span.start; // update text length textLength = 0; // update text width textWidth = 0; } // update text length textLength += span.length; // update text width textWidth += GetSpanWidth(span); // copy span values to previous span span.CopyTo(prev); // set the first span flag firstSpan = false; } // add the last line to the line span list if(linePos < lines.Length) { // create line span for last line LineSpan lineSpan = new LineSpan (textStart, textLength, textWidth); // add last line span to the line span list lines[linePos++] = lineSpan; } // calculate the top line y int y = (layout.Height - (linePos * lineHeight)); // adjust y for center alignment, if needed if(format.LineAlignment == StringAlignment.Center) { y /= 2; } // translate y to layout rectangle y += layout.Top; // adjust line position to last line --linePos; // draw the lines for(int i = 0; i < linePos; ++i) { // get the current line LineSpan line = lines[i]; // draw the current line DrawLine (line.start, line.length, line.pixelWidth, y, false); // update the y position y += lineHeight; } // draw the last line DrawLine (lines[linePos].start, lines[linePos].length, lines[linePos].pixelWidth, y, true); } } finally { // dispose the underline font, if we have one if(underlineFont != null) { // dispose the underline font underlineFont.Dispose(); // reset the underline font underlineFont = null; } } }
private void Dispose(bool disposing) { lock(this) { if(graphics != null) { graphics.Dispose(); graphics = null; } if (clip != null) { clip.Dispose(); clip = null; } } }
public abstract void Select(IToolkitGraphics graphics);
// Calculate text metrics information. // // Note that this is currently broken. Turn this on at your own risk. public Size GetBounds (Graphics graphics, String text, Font font, SizeF layoutSize, StringFormat format, out int charactersFitted, out int linesFilled) { // set the current graphics this.graphics = graphics; // set the current toolkit graphics this.toolkitGraphics = graphics.ToolkitGraphics; // set the current text this.text = text; // set the current font this.font = font; // ensure we have a string format if(format == null) { format = SF_DEFAULT; } // set the current string format this.format = format; // set the current layout rectangle this.layout = new Rectangle (0, 0, (int)layoutSize.Width, (int)layoutSize.Height); // set the current line height lineHeight = font.Height; // set the only whole lines flag onlyWholeLines = (((format.FormatFlags & StringFormatFlags.LineLimit) != 0) || ((format.Trimming & StringTrimming.None) != 0)); // set the index of the next character nextIndex = 0; // set the current line space usage lineSpaceUsedUp = 0; // set the previous span ended in new line flag prevIsNewLine = false; // select the current font into the graphics context graphics.SelectFont(font); // set the text width int textWidth = 0; // set the maximum width int maxWidth = 0; // set the default characters fitted charactersFitted = 0; // set the default lines filled linesFilled = 0; // remove the hotkey prefix, if needed if(format.HotkeyPrefix != HotkeyPrefix.None) { // get the hotkey index hotkeyIndex = text.IndexOf('&'); // handle the hotkey as needed if(hotkeyIndex != -1) { if(hotkeyIndex < (text.Length - 1) && !Char.IsControl(text[hotkeyIndex + 1])) { // remove the hotkey character text = text.Substring(0, hotkeyIndex) + text.Substring(hotkeyIndex + 1); // set the current text this.text = text; // update characters fitted ++charactersFitted; } // no need for this anymore hotkeyIndex = -1; } } // create character spans CharSpan span = new CharSpan(); CharSpan prev = new CharSpan(); // set the first span flag bool firstSpan = true; // set the measure trailing spaces flag bool mts = ((format.FormatFlags & StringFormatFlags.MeasureTrailingSpaces) != 0); // process the text while(nextIndex < text.Length) { // get the next span of characters GetNextSpan(span); // handle span on new line if(span.newline) { // remove trailing spaces, if needed if(!firstSpan && !mts && text[prev.start] == ' ') { // update the text width textWidth -= GetSpanWidth(prev); } // update the maximum width, if needed if(textWidth > maxWidth) { maxWidth = textWidth; } // update the text width textWidth = 0; // update the lines filled ++linesFilled; } // update the text width textWidth += GetSpanWidth(span); // update the characters fitted charactersFitted += span.length; // copy span values to previous span span.CopyTo(prev); } // update the maximum width, if needed if(textWidth > maxWidth) { maxWidth = textWidth; } // update the lines filled to account for the first line ++linesFilled; // update the maximum width, if needed if(maxWidth > layout.Width) { maxWidth = layout.Width; } // calculate the height int height = (lineHeight * linesFilled); // update the height, if needed if(height > layout.Height) { height = layout.Height; } // return the size of the text return new Size(maxWidth, height); }
// Get the LOGFONT information for this toolkit font. public void ToLogFont(Object lf, IToolkitGraphics graphics) { Win32.Api.LOGFONT logFont; Win32.Api.GetObject(hFont, Marshal.SizeOf(typeof(Win32.Api.LOGFONT)), out logFont); lf = logFont; }
public FontFamily[] GetFontFamilies(IToolkitGraphics graphics) { throw new NotImplementedException(); }
public void Select(IToolkitGraphics graphics) { graphics.Pen = this; }
// Create a "Graphics" object from an "IToolkitGraphics" handler. public static Graphics CreateGraphics(IToolkitGraphics graphics, Rectangle baseWindow) { if(graphics == null) { throw new ArgumentNullException("graphics"); } return new Graphics(graphics, baseWindow); }
// Create a "Graphics" object from an "IToolkitGraphics" handler. // Start with a clip that has already been set in the underlying IToolkitGraphics. public static Graphics CreateGraphics(IToolkitGraphics graphics, Region clip) { if(graphics == null) { throw new ArgumentNullException("graphics"); } Graphics createdGraphics = new Graphics(graphics); createdGraphics.SetClipInternal(clip); return createdGraphics; }
// Select this pen into a graphics object. public override void Select(IToolkitGraphics _graphics) { if (_graphics == null) return; if (_graphics is DrawingGraphics) { DrawingGraphics graphics = _graphics as DrawingGraphics; Xsharp.Graphics g = graphics.graphics; int width = (int)(properties.Width); LineStyle style = MapLineStyle(properties.DashStyle); if(style == LineStyle.LineOnOffDash) { if(width == 1) { width = 0; } switch(properties.DashStyle) { case DashStyle.Dash: { g.DashPattern = dash; } break; case DashStyle.Dot: { g.DashPattern = dot; } break; case DashStyle.DashDot: { g.DashPattern = dashdot; } break; case DashStyle.DashDotDot: { g.DashPattern = dashdotdot; } break; case DashStyle.Custom : { float [] src = properties.DashPattern; int iLen = src.Length; byte [] ayCopy = new byte[ iLen ]; float fWidth = properties.Width; float tmp; for( int i = 0; i < iLen; i++ ) { tmp = src[i]*fWidth; if( tmp < 0 ) tmp = 0; else if( tmp > 0xFF ) tmp = 0xFF; ayCopy[i] = (byte) ( tmp ); if( ayCopy[i] == 0 ) ayCopy[i] = 1; // must not be zero } g.DashPattern = ayCopy; } break; } } g.Function = GCFunction.GXcopy; g.SubwindowMode = SubwindowMode.ClipByChildren; g.LineWidth = width; g.LineStyle = style; g.CapStyle = MapCapStyle(properties.EndCap); g.JoinStyle = MapJoinStyle(properties.LineJoin); g.Foreground = DrawingToolkit.DrawingToXColor (properties.Color); g.SetFillSolid(); graphics.Pen = this; } else if (_graphics is DrawingGraphicsImage) { DrawingGraphicsImage graphics = _graphics as DrawingGraphicsImage; graphics.Pen = this; } }
// Get the LOGFONT information for this toolkit font. public void ToLogFont(Object lf, IToolkitGraphics graphics) { Win32.Api.LOGFONT logFont; Win32.Api.GetObject( hFont, Marshal.SizeOf(typeof(Win32.Api.LOGFONT)), out logFont); lf = logFont; }
}; // class FamilyComparer // Get a list of all font families on this system, or all font // families that are compatible with a particular IToolkitGraphics. public FontFamily[] GetFontFamilies(IToolkitGraphics graphics) { lock(this) { if(families != null) { return families; } String[] names = app.Display.FontFamilies; int size = names.Length; if(Array.IndexOf(names, "microsoft sans serif") == -1) { ++size; } if(Array.IndexOf(names, "arial") == -1) { ++size; } if(Array.IndexOf(names, "times new roman") == -1) { ++size; } if(Array.IndexOf(names, "courier new") == -1) { ++size; } families = new FontFamily [size]; size = 0; foreach(String name in names) { families[size++] = new FontFamily (CultureInfo.CurrentCulture.TextInfo. ToTitleCase(name)); } if(Array.IndexOf(names, "microsoft sans serif") == -1) { families[size++] = new FontFamily ("Microsoft Sans Serif"); } if(Array.IndexOf(names, "arial") == -1) { families[size++] = new FontFamily("Arial"); } if(Array.IndexOf(names, "times new roman") == -1) { families[size++] = new FontFamily("Times New Roman"); } if(Array.IndexOf(names, "courier new") == -1) { families[size++] = new FontFamily("Courier New"); } Array.Sort(families, new FamilyComparer()); return families; } }
// Select this pen into a graphics object. public override void Select(IToolkitGraphics graphics) { (graphics as DrawingGraphics).Pen = this; }
public void Select(IToolkitGraphics graphics) { graphics.Brush = this; }
public void ToLogFont(object lf, IToolkitGraphics graphics) { }
// Select a brush-based pen into a graphics object. public void Select(IToolkitGraphics graphics, IToolkitBrush brush) { Select(graphics); // TODO: select the brush information }
public abstract void Select(IToolkitGraphics graphics, IToolkitBrush brush);
// Select this brush into a graphics object. public override void Select(IToolkitGraphics graphics) { (graphics as ToolkitGraphicsBase).Brush = this; }
public void Select(IToolkitGraphics graphics, IToolkitBrush brush) { graphics.Pen = this; }