protected override void OnDraw(Context ctx, Rectangle dirtyRect) { // Line arround ctx.SetColor(Colors.DarkGray); // Drive line arround ctx.Rectangle(Bounds); ctx.Fill(); ctx.SetColor(Colors.Gray); ctx.Rectangle(Bounds.Inflate(-margin, -margin)); ctx.Fill(); // Draw image ctx.DrawImage(Image.FromResource(Logo), 5.0, 5.0); // Draw text ctx.SetColor(Colors.White); TextLayout _layout = new TextLayout(); _layout.Font = Font.WithSize(22); _layout.Text = Label; _layout.SetFontWeight(FontWeight.Bold, 0, Label.Length); // Cocoa layouts ctx.DrawTextLayout(_layout, 45, ((Config.Cocoa || Config.Gtk) ? 5 : 2)); }
protected override void OnDraw(Xwt.Drawing.Context ctx, Rectangle dirtyRect) { if (Bounds.IsEmpty) { return; } ctx.Rectangle(0, 0, Bounds.Width, Bounds.Height); Gradient g = null; if (Linear) { g = new LinearGradient(0, 0, Bounds.Width, Bounds.Height); } else { g = new RadialGradient(Bounds.Width / 2, Bounds.Height / 2, Bounds.Width / 2, Bounds.Width / 2, Bounds.Height / 2, Bounds.Width / 4); } g.AddColorStop(0, new Color(1, 0, 0)); g.AddColorStop(1, new Color(0, 1, 0)); ctx.Pattern = g; ctx.Fill(); Rectangle r = rect.Inflate(5, 5); ctx.Rectangle(r); ctx.SetColor(new Color(0, 0, 1)); ctx.SetLineWidth(1); ctx.Stroke(); }
public void PatternsAndImages (Context ctx, double x, double y) { ctx.Save (); ctx.Translate (x, y); ctx.SetColor (Colors.Black); // Dashed lines ctx.SetLineWidth (2); ctx.SetLineDash (15, 10, 10, 5, 5); ctx.Rectangle (10, 10, 100, 100); ctx.Stroke (); ctx.SetLineDash (0); // Image var arcColor = new Color (1, 0, 1); ImageBuilder ib = new ImageBuilder (30, 30); ib.Context.Arc (15, 15, 15, 0, 360); ib.Context.SetColor (arcColor); ib.Context.Fill (); ib.Context.SetColor (Colors.DarkKhaki); ib.Context.Rectangle (0, 0, 5, 5); ib.Context.Fill (); var img = ib.ToVectorImage (); ctx.DrawImage (img, 0, 0); ctx.DrawImage (img, 0, 50, 50, 10); ctx.Arc (100, 100, 15, 0, 360); arcColor.Alpha = 0.4; ctx.SetColor (arcColor); ctx.Fill (); // ImagePattern ctx.Save (); ctx.Translate (x + 130, y); ctx.Pattern = new ImagePattern (img); ctx.Rectangle (0, 0, 100, 100); ctx.Fill (); ctx.Restore (); ctx.Restore (); // Setting pixels ctx.SetLineWidth (1); for (int i=0; i<50;i++) { for (var j=0; j<50;j++) { Color c = Color.FromHsl (0.5, (double)i / 50d, (double)j / 50d); ctx.Rectangle (i, j, 1, 1); ctx.SetColor (c); ctx.Fill (); } } }
protected override void OnDraw(Context ctx, Rectangle dirtyRect) { ctx.SetColor(new Color(0.5, 0.5, 0.5)); ctx.Rectangle(Bounds); ctx.Fill(); ctx.SetColor(new Color(0.8, 0.8, 0.8)); ctx.Rectangle(Bounds.Inflate(-margin, -margin)); ctx.Fill(); ctx.SetColor(highlight ? Color.BlendWith(Xwt.Drawing.Colors.White, 0.5) : Color); ctx.Rectangle(Bounds.Width / 2 - coreSize.Width / 2, Bounds.Height / 2 - coreSize.Height / 2, coreSize.Width, coreSize.Height); ctx.Fill(); }
protected override void OnDraw(Xwt.Drawing.Context cr, Rectangle bound) { { cr.Rectangle(bound.X, bound.Y, bound.Width, bound.Height); cr.SetSourceColor(editor.ColorStyle.PlainText.Background); cr.Fill(); using (var layout = PangoUtil.CreateLayout(editor)) { layout.Font = editor.Options.Font; layout.Text = "000,00-00"; var mins = layout.GetSize(); var line = editor.GetLine(editor.Caret.Line); var visColumn = line.GetVisualColumn(editor.GetTextEditorData(), editor.Caret.Column); if (visColumn != editor.Caret.Column) { layout.Text = editor.Caret.Line + "," + editor.Caret.Column + "-" + visColumn; } else { layout.Text = editor.Caret.Line + "," + editor.Caret.Column; } var statuss = layout.GetSize(); statuss.Width = System.Math.Max(statuss.Width, mins.Width); statuss.Width += 8; cr.MoveTo(Size.Width - statuss.Width, 0); statuss.Width += 8; cr.SetSourceColor(editor.ColorStyle.PlainText.Foreground); cr.ShowLayout(layout); layout.Text = statusText ?? ""; var size = layout.GetSize(); var x = System.Math.Min(0, -size.Width + Size.Width - editor.TextViewMargin.CharWidth - statuss.Width); cr.MoveTo(x, 0); cr.SetSourceColor(editor.ColorStyle.PlainText.Foreground); cr.ShowLayout(layout); if (ShowCaret) { if (editor.TextViewMargin.caretBlink) { cr.Rectangle(size.Width + x, 0, (int)editor.TextViewMargin.CharWidth, (int)editor.LineHeight); cr.Fill(); } } } } }
void DrawFoldSegment(Xwt.Drawing.Context ctx, double x, double y, bool isOpen, bool isSelected) { var drawArea = new Rectangle(System.Math.Floor(x + (Width - foldSegmentSize) / 2) + 0.5, System.Math.Floor(y + (editor.LineHeight - foldSegmentSize) / 2) + 0.5, foldSegmentSize, foldSegmentSize); ctx.Rectangle(drawArea); ctx.SetSourceColor(isOpen ? foldBgGC : foldToggleMarkerBackground); ctx.FillPreserve(); ctx.SetSourceColor(isSelected ? foldLineHighlightedGC : foldLineGC); ctx.Stroke(); ctx.DrawLine(isSelected ? foldLineHighlightedGC : foldToggleMarkerGC, drawArea.X + drawArea.Width * 2 / 10, drawArea.Y + drawArea.Height / 2, drawArea.X + drawArea.Width - drawArea.Width * 2 / 10, drawArea.Y + drawArea.Height / 2); if (!isOpen) { ctx.DrawLine(isSelected ? foldLineHighlightedGC : foldToggleMarkerGC, drawArea.X + drawArea.Width / 2, drawArea.Y + drawArea.Height * 2 / 10, drawArea.X + drawArea.Width / 2, drawArea.Y + drawArea.Height - drawArea.Height * 2 / 10); } }
protected internal override void DrawBackground(Context cr, Xwt.Rectangle area, DocumentLine line, int lineNumber, double x, double y, double height) { cr.Save(); cr.SetColor(Colors.LightGray); cr.Rectangle(x, y, Width, height + 1); cr.Fill(); cr.Restore(); }
protected override void OnDraw(Xwt.Drawing.Context ctx, Rectangle dirtyRect) { ctx.Rectangle(0, 0, Bounds.Width, Bounds.Height); var g = new LinearGradient(0, 0, Bounds.Width, Bounds.Height); g.AddColorStop(0, new Color(1, 0, 0)); g.AddColorStop(1, new Color(0, 1, 0)); ctx.Pattern = g; ctx.Fill(); Rectangle r = rect.Inflate(5, 5); ctx.Rectangle(r); ctx.SetColor(new Color(0, 0, 1)); ctx.SetLineWidth(1); ctx.Stroke(); }
protected override void OnDraw(Context ctx) { ctx.SetLineWidth (5); ctx.SetColor (new Color (1.0f, 0f, 0.5f)); ctx.Rectangle (5, 5, 200, 100); ctx.FillPreserve (); ctx.SetColor (new Color (0f, 0f, 1f)); ctx.Stroke (); }
protected override void OnDraw(Context ctx, Rectangle dirtyRect) { if (Window?.DrawRedDebugOutline ?? false) { ctx.SetColor(Colors.Blue); ctx.Rectangle(0, 0, Bounds.Width, Bounds.Height); ctx.Stroke(); ctx.SetColor(Colors.Black); } }
void DrawGutterBackground(Xwt.Drawing.Context cr, int line, double x, double y, double lineHeight) { if (editor.Caret.Line == line) { editor.TextViewMargin.DrawCaretLineMarker(cr, x, y, Width, lineHeight); return; } cr.Rectangle(x, y, Width, lineHeight); cr.SetSourceColor(lineNumberBgGC); cr.Fill(); }
public override bool DrawBackground(TextEditor editor, Xwt.Drawing.Context cr, double y, LineMetrics metrics) { if (metrics.SelectionStart > 0) { return(true); } cr.SetSourceColor(color); cr.Rectangle(metrics.TextRenderStartPosition, y, metrics.TextRenderEndPosition - metrics.TextRenderStartPosition, editor.LineHeight); cr.Fill(); return(true); }
public override bool DrawBackground(TextEditor editor, Xwt.Drawing.Context cr, MarginDrawMetrics metrics) { var width = metrics.Width; cr.Rectangle(metrics.X, metrics.Y, metrics.Width, metrics.Height); var lineNumberGC = editor.ColorStyle.LineNumbers.Foreground; cr.SetSourceColor(editor.Caret.Line == metrics.LineNumber ? editor.ColorStyle.LineMarker.Color : lineNumberGC); cr.Fill(); return(true); }
protected override void OnDraw(Context ctx, Rectangle dirtyRect) { base.OnDraw(ctx, dirtyRect); ctx.Save(); ctx.SetColor(editor.Options.Background); ctx.Rectangle(dirtyRect); ctx.Fill(); ctx.Restore(); UpdateMarginXOffsets(); RenderMargins(ctx, dirtyRect); }
protected void InitBlank (int width = 50, int height = 50) { if (builder != null) builder.Dispose (); builder = new ImageBuilder (width, height); context = builder.Context; context.Rectangle (0, 0, width, height); context.SetColor (Colors.White); context.Fill (); context.SetColor (Colors.Black); context.SetLineWidth (1); }
protected override void OnDraw(Context ctx, Rectangle cellArea) { var pct = GetValue (ValueField); var size = (cellArea.Width * pct) / 100f; cellArea.Width = (int) size; ctx.SetLineWidth (1); ctx.Rectangle (cellArea.Inflate (-0.5, -0.5)); ctx.SetColor (Colors.LightBlue); ctx.FillPreserve (); ctx.SetColor (Colors.Gray); ctx.Stroke (); }
public override bool DrawBackground(TextEditor editor, Xwt.Drawing.Context cr, double y, LineMetrics metrics) { var caretOffset = editor.Caret.Offset - BaseOffset; foreach (var link in mode.Links) { if (!link.IsEditable) { continue; } bool isPrimaryHighlighted = link.PrimaryLink.Offset <= caretOffset && caretOffset <= link.PrimaryLink.EndOffset; foreach (TextSegment segment in link.Links) { if ((BaseOffset + segment.Offset <= metrics.TextStartOffset && metrics.TextStartOffset < BaseOffset + segment.EndOffset) || (metrics.TextStartOffset <= BaseOffset + segment.Offset && BaseOffset + segment.Offset < metrics.TextEndOffset)) { int strOffset = BaseOffset + segment.Offset - metrics.TextStartOffset; int strEndOffset = BaseOffset + segment.EndOffset - metrics.TextStartOffset; var x_pos = metrics.Layout.Layout.IndexToPos(strOffset).X; var x_pos2 = metrics.Layout.Layout.IndexToPos(strEndOffset).X; x_pos = (int)(x_pos); x_pos2 = (int)(x_pos2); Color fillGc, rectangleGc; if (segment == link.PrimaryLink) { fillGc = isPrimaryHighlighted ? editor.ColorStyle.PrimaryTemplateHighlighted.SecondColor : editor.ColorStyle.PrimaryTemplate.SecondColor; rectangleGc = isPrimaryHighlighted ? editor.ColorStyle.PrimaryTemplateHighlighted.SecondColor : editor.ColorStyle.PrimaryTemplate.SecondColor; } else { fillGc = isPrimaryHighlighted ? editor.ColorStyle.SecondaryTemplateHighlighted.SecondColor : editor.ColorStyle.SecondaryTemplate.SecondColor; rectangleGc = isPrimaryHighlighted ? editor.ColorStyle.SecondaryTemplateHighlighted.Color : editor.ColorStyle.SecondaryTemplate.Color; } // Draw segment double x1 = metrics.TextRenderStartPosition + x_pos - 1; double x2 = metrics.TextRenderStartPosition + x_pos2 - 1 + 0.5; cr.Rectangle(x1 + 0.5, y + 0.5, x2 - x1, editor.LineHeight - 1); cr.SetSourceColor(fillGc); cr.FillPreserve(); cr.SetSourceColor(rectangleGc); cr.Stroke(); } } } return(true); }
internal protected override void Draw (Context ctx, Rectangle area, long line, double x, double y) { ctx.Rectangle (x, y, Width, Editor.LineHeight); ctx.SetColor (Style.HexOffsetBg); ctx.Fill (); if (line >= 0 && line * Editor.BytesInRow < Data.Length) { LayoutWrapper layout = GetLayout (line); var sz = layout.Layout.GetSize (); ctx.SetColor (line != Caret.Line ? Style.HexOffset : Style.HexOffsetHighlighted); ctx.DrawTextLayout (layout.Layout, x + Width - sz.Width - 4, y); if (layout.IsUncached) layout.Dispose (); } }
protected override void OnDraw (Context ctx, Rectangle dirtyRect) { base.OnDraw (ctx, dirtyRect); ctx.Rectangle (0, 0, Size.Width, Size.Height); ctx.SetColor (Colors.LightGray); ctx.Fill (); ctx.SetColor (Colors.Black); using (var layout = new TextLayout (this)) { layout.Text = text; ctx.DrawTextLayout (layout, new Point (0, 20)); } }
internal protected override void Draw (Context win, Rectangle area, long line, double x, double y) { win.Rectangle (x, y, Width, Editor.LineHeight); win.SetColor (Style.IconBarBg); win.Fill (); win.MoveTo (x + Width - 1, y); win.LineTo (x + Width - 1, y + Editor.LineHeight); win.SetColor (Style.IconBarSeperator); win.Stroke (); foreach (long bookmark in Data.Bookmarks) { if (line * Editor.BytesInRow <= bookmark && bookmark < line * Editor.BytesInRow + Editor.BytesInRow) { DrawBookmark (win, x, y); return; } } }
internal protected override void Draw(Xwt.Drawing.Context ctx, Rectangle area, DocumentLine lineSegment, int line, double x, double y, double lineHeight) { bool backgroundIsDrawn = false; if (lineSegment != null) { foreach (var marker in lineSegment.Markers) { var marginMarker = marker as MarginMarker; if (marginMarker != null && marginMarker.CanDrawBackground(this)) { backgroundIsDrawn = marginMarker.DrawBackground(editor, ctx, new MarginDrawMetrics(this, area, lineSegment, line, x, y, lineHeight)); } } } if (!backgroundIsDrawn) { ctx.Rectangle(x, y, Width, lineHeight); ctx.SetSourceColor(backgroundColor); ctx.Fill(); ctx.MoveTo(x + Width - 0.5, y); ctx.LineTo(x + Width - 0.5, y + lineHeight); ctx.SetSourceColor(separatorColor); ctx.Stroke(); } if (lineSegment != null && line <= editor.Document.LineCount) { foreach (var marker in lineSegment.Markers) { var marginMarker = marker as MarginMarker; if (marginMarker != null && marginMarker.CanDrawForeground(this)) { marginMarker.DrawForeground(editor, ctx, new MarginDrawMetrics(this, area, lineSegment, line, x, y, lineHeight)); } } if (DrawEvent != null) { DrawEvent(this, new BookmarkMarginDrawEventArgs(editor, ctx, lineSegment, line, x, y)); } } }
protected override void OnDraw(Context ctx, Rectangle dirtyRect) { base.OnDraw(ctx, dirtyRect); ctx.SetColor(Colors.Gray); ctx.SetLineWidth(1); ctx.RoundRectangle(0, Padding.Top / 2 - .5, Width - 4.5, Height - Padding.Bottom * 1.5, 3); ctx.Stroke(); var tl = new TextLayout(this) { Text = title, Width = Width - Padding.Left - Padding.Right / 2 }; ctx.SetColor(Colors.White); ctx.Rectangle(Padding.Left, 0, tl.GetSize().Width, Padding.Top); ctx.Fill(); ctx.SetColor(Colors.Black); ctx.DrawTextLayout(tl, Padding.Left, 0); }
protected void TestDrawing1(Xwt.Drawing.Context ctx, double x, double y) { ctx.Save(); ctx.Translate(x, y); var r = 5; var l = 10; var t = 10; var w = 50; var h = 30; // top left //ctx.Arc(l + r, t + r, r, 180, 270); ctx.Rectangle(l, t, w, h); ctx.SetColor(Colors.Black); ctx.Stroke(); ctx.Restore(); }
protected internal override void Draw (Context drawable, Rectangle area, long line, double x, double y) { drawable.Rectangle (x, y, Width, Editor.LineHeight); drawable.SetColor (Style.HexDigitBg); drawable.Fill (); }
protected override void OnDraw(Context ctx, Rectangle cellArea) { ctx.Rectangle (BackgroundBounds); ctx.SetColor (new Color (0.9, 0.9, 0.9)); ctx.Fill (); ctx.Rectangle (Bounds); ctx.SetColor (new Color (0.7, 0.7, 0.7)); ctx.Fill (); var pct = GetValue (ValueField); var size = (cellArea.Width * pct.Value) / 100f; cellArea.Width = (int) size; ctx.SetLineWidth (1); ctx.Rectangle (cellArea.Inflate (-0.5, -0.5)); ctx.SetColor (Selected ? Colors.Blue : Colors.LightBlue); ctx.FillPreserve (); ctx.SetColor (Colors.Gray); ctx.Stroke (); if (pct.YPos != -1) { ctx.MoveTo (cellArea.Right, Bounds.Y + pct.YPos); ctx.Arc (cellArea.Right, Bounds.Y + pct.YPos, 2.5, 0, 360); ctx.SetColor (Colors.Red); ctx.Fill (); } }
public virtual void Rectangles (Context ctx, double x, double y) { ctx.Save (); ctx.Translate (x, y); // Simple rectangles ctx.SetLineWidth (1); ctx.Rectangle (0, 0, 10, 10); ctx.SetColor (Colors.Black); ctx.Fill (); ctx.Rectangle (15, 0, 10, 10); ctx.SetColor (Colors.Black); ctx.Stroke (); ctx.SetLineWidth (3); ctx.Rectangle (0, 15, 10, 10); ctx.SetColor (Colors.Black); ctx.Fill (); ctx.Rectangle (15, 15, 10, 10); ctx.SetColor (Colors.Black); ctx.Stroke (); ctx.Restore (); // Rectangle with hole ctx.Save (); ctx.Translate (x + 50, y); ctx.Rectangle (0, 0, 40, 40); ctx.MoveTo (35, 35); ctx.RelLineTo (0, -20); ctx.RelLineTo (-20, 0); ctx.RelLineTo (0, 20); ctx.ClosePath (); ctx.SetColor (Colors.Black); ctx.Fill (); ctx.Restore (); // Rounded Rectangle with Arcs ctx.Save (); ctx.Translate (x + 120, y); var r = 5; var l = 0; var t = 0; var w = 50; var h = 30; ctx.SetColor (Colors.Black); // top left ctx.Arc (l + r, t + r, r, 180, 270); // top right ctx.Arc (l + w - r, t + r, r, 270, 0); // bottom right ctx.Arc (l + w - r, t + h - r, r, 0, 90); // bottom left ctx.Arc (l + r, t + h - r, r, 90, 180); ctx.ClosePath (); ctx.StrokePreserve (); ctx.SetColor (Colors.AntiqueWhite); ctx.Fill (); ctx.Restore (); }
/// <summary> /// Draw The legend /// </summary> /// <param name="ctx">The Drawing Context with on which to draw</param> /// <param name="position">The position of the top left of the axis.</param> /// <param name="plots">Array of plot objects to appear in the legend.</param> /// <param name="scale">if the legend is set to scale, the amount to scale by.</param> /// <returns>bounding box</returns> public Rectangle Draw(Context ctx, Point position, ArrayList plots, double scale ) { // first of all determine the Font to use in the legend. Font textFont; if (AutoScaleText) { textFont = font_.WithScaledSize (scale); } else { textFont = font_; } ctx.Save (); // determine max width and max height of label strings and // count the labels. int labelCount = 0; int unnamedCount = 0; double maxHt = 0; double maxWd = 0; TextLayout layout = new TextLayout (); layout.Font = textFont; for (int i=0; i<plots.Count; ++i) { if (!(plots[i] is IPlot)) { continue; } IPlot p = (IPlot)plots[i]; if (!p.ShowInLegend) { continue; } string label = p.Label; if (label == "") { unnamedCount += 1; label = "Series " + unnamedCount.ToString(); } layout.Text = label; Size labelSize = layout.GetSize (); if (labelSize.Height > maxHt) { maxHt = labelSize.Height; } if (labelSize.Width > maxWd) { maxWd = labelSize.Width; } ++labelCount; } bool extendingHorizontally = numberItemsHorizontally_ == -1; bool extendingVertically = numberItemsVertically_ == -1; // determine width in legend items count units. int widthInItemCount = 0; if (extendingVertically) { if (labelCount >= numberItemsHorizontally_) { widthInItemCount = numberItemsHorizontally_; } else { widthInItemCount = labelCount; } } else if (extendingHorizontally) { widthInItemCount = labelCount / numberItemsVertically_; if (labelCount % numberItemsVertically_ != 0) widthInItemCount += 1; } else { throw new NPlotException( "logic error in legend base" ); } // determine height of legend in items count units. int heightInItemCount = 0; if (extendingHorizontally) { if (labelCount >= numberItemsVertically_) { heightInItemCount = numberItemsVertically_; } else { heightInItemCount = labelCount; } } else { // extendingVertically heightInItemCount = labelCount / numberItemsHorizontally_; if (labelCount % numberItemsHorizontally_ != 0) heightInItemCount += 1; } double lineLength = 20; double hSpacing = (int)(5.0f * scale); double vSpacing = (int)(3.0f * scale); double boxWidth = (int) ((float)widthInItemCount * (lineLength + maxWd + hSpacing * 2.0f ) + hSpacing); double boxHeight = (int)((float)heightInItemCount * (maxHt + vSpacing) + vSpacing); double totalWidth = boxWidth; double totalHeight = boxHeight; // draw box around the legend. if (BorderStyle == BorderType.Line) { ctx.SetColor (bgColor_); ctx.Rectangle (position.X, position.Y, boxWidth, boxHeight); ctx.FillPreserve (); ctx.SetColor (borderColor_); ctx.Stroke (); } else if (BorderStyle == BorderType.Shadow) { double offset = (4.0 * scale); Color shade = Colors.Gray; shade.Alpha = 0.5; ctx.SetColor (Colors.Gray); ctx.Rectangle (position.X+offset, position.Y+offset, boxWidth, boxHeight); ctx.Fill (); ctx.SetColor (bgColor_); ctx.Rectangle (position.X, position.Y, boxWidth, boxHeight); ctx.FillPreserve (); ctx.SetColor (borderColor_); ctx.Stroke (); totalWidth += offset; totalHeight += offset; } /* else if ( this.BorderStyle == BorderType.Curved ) { // TODO. make this nice. } */ else { // do nothing. } // now draw entries in box.. labelCount = 0; unnamedCount = 0; int plotCount = -1; for (int i=0; i<plots.Count; ++i) { if (!(plots[i] is IPlot)) { continue; } IPlot p = (IPlot)plots[i]; if (!p.ShowInLegend) { continue; } plotCount += 1; double xpos, ypos; if (extendingVertically) { xpos = plotCount % numberItemsHorizontally_; ypos = plotCount / numberItemsHorizontally_; } else { xpos = plotCount / numberItemsVertically_; ypos = plotCount % numberItemsVertically_; } double lineXPos = (position.X + hSpacing + xpos * (lineLength + maxWd + hSpacing * 2.0)); double lineYPos = (position.Y + vSpacing + ypos * (vSpacing + maxHt)); p.DrawInLegend (ctx, new Rectangle (lineXPos, lineYPos, lineLength, maxHt)); double textXPos = lineXPos + hSpacing + lineLength; double textYPos = lineYPos; string label = p.Label; if (label == "") { unnamedCount += 1; label = "Series " + unnamedCount.ToString(); } layout.Text = label; ctx.DrawTextLayout (layout, textXPos, textYPos); ++labelCount; } ctx.Restore (); return new Rectangle (position.X, position.Y, totalWidth, totalHeight); }
protected sealed override void OnDraw(Context ctx, Rectangle bounds) { if (bounds.Width <= 0 || bounds.Height <= 0) { return; } var frame = GetFrame(ctx.ScaleFactor); var fixedWidth = frame.Bitmap.Width - 2 - frame.StretchableWidth; var fixedHeight = frame.Bitmap.Height - 2 - frame.StretchableHeight; double totalVariableWidth = bounds.Width - fixedWidth / frame.ScaleFactor; double totalVariableHeight = bounds.Height - fixedHeight / frame.ScaleFactor; double remainingVariableHeight = totalVariableHeight; double y = bounds.Y, yb = 1; int tileIndex = 0; ctx.Save(); if (totalVariableWidth < 0) { if (fixedWidth > 0) { ctx.Scale(bounds.Width / fixedWidth, 1); } totalVariableWidth = 0; } if (totalVariableHeight < 0) { if (fixedHeight > 0) { ctx.Scale(1, bounds.Height / fixedHeight); } totalVariableHeight = 0; } foreach (var vs in frame.VerticalSections) { double sh = CalcSectionSize(frame, vs, totalVariableHeight, frame.StretchableHeight, ref remainingVariableHeight); double x = bounds.X, xb = 1; double remainingVariableWidth = totalVariableWidth; foreach (var hs in frame.HorizontalSections) { var sourceRegion = new Rectangle(xb, yb, hs.Size, vs.Size); double sw = CalcSectionSize(frame, hs, totalVariableWidth, frame.StretchableWidth, ref remainingVariableWidth); var targetRegion = new Rectangle(x, y, sw, sh); if (vs.Mode != RenderMode.Tile && hs.Mode != RenderMode.Tile) { var t = GetTile(frame, tileIndex, sourceRegion); ctx.DrawImage(t, targetRegion); } else { double pw = hs.Size / frame.ScaleFactor; double ph = vs.Size / frame.ScaleFactor; if (hs.Mode == RenderMode.Stretch) { pw = targetRegion.Width; } if (vs.Mode == RenderMode.Stretch) { ph = targetRegion.Height; } if (pw <= 0 || ph <= 0) { continue; } ctx.Save(); ctx.Translate(targetRegion.Location); targetRegion.Location = Point.Zero; ctx.Pattern = new ImagePattern(GetTile(frame, tileIndex, sourceRegion).WithSize(pw, ph)); ctx.NewPath(); ctx.Rectangle(targetRegion); ctx.Fill(); ctx.Restore(); } x += sw; xb += hs.Size; tileIndex++; } yb += vs.Size; y += sh; } ctx.Restore(); }
void FillCellBackground (Context ctx, Color color) { ctx.Rectangle (BackgroundBounds); ctx.SetColor (color); ctx.Fill (); }
internal protected override void Draw (Context ctx, Rectangle area, long line, double x, double y) { ctx.Rectangle (x, y, Width, Editor.LineHeight); ctx.SetColor (Style.HexDigitBg); ctx.Fill (); LayoutWrapper layout = GetLayout (line); if (!Data.IsSomethingSelected && !Caret.InTextEditor && line == Data.Caret.Line) { var column = (int)(Caret.Offset % BytesInRow); var xOffset = charWidth * column; ctx.Rectangle (x + xOffset, y, charWidth, Editor.LineHeight); ctx.SetColor (Style.HighlightOffset); ctx.Fill (); } ctx.SetColor (Style.HexDigit); ctx.DrawTextLayout (layout.Layout, x, y); if (layout.IsUncached) layout.Dispose (); }
protected override void OnDraw(Context ctx, Rectangle dirtyRect) { if (colorBox == null) { using (var ib = new ImageBuilder (size, size)) { for (int i=0; i<size; i++) { for (int j=0; j<size; j++) { ib.Context.Rectangle (i, j, 1, 1); ib.Context.SetColor (GetColor (i,j)); ib.Context.Fill (); } } colorBox = ib.ToImage (); } } ctx.DrawImage (colorBox, padding, padding); ctx.SetLineWidth (1); ctx.SetColor (Colors.Black); ctx.Rectangle (selection.X + padding - 2 + 0.5, selection.Y + padding - 2 + 0.5, 4, 4); ctx.Stroke (); }
protected override void OnDraw(Xwt.Drawing.Context ctx) { base.OnDraw(ctx); // Simple rectangles ctx.SetLineWidth(1); ctx.Rectangle(100, 5, 10, 10); ctx.SetColor(Color.Black); ctx.Fill(); ctx.Rectangle(115, 5, 10, 10); ctx.SetColor(Color.Black); ctx.Stroke(); // ctx.SetLineWidth(3); ctx.Rectangle(100, 20, 10, 10); ctx.SetColor(Color.Black); ctx.Fill(); ctx.Rectangle(115, 20, 10, 10); ctx.SetColor(Color.Black); ctx.Stroke(); // Rectangle with hole ctx.Rectangle(10, 100, 40, 40); ctx.MoveTo(45, 135); ctx.RelLineTo(0, -20); ctx.RelLineTo(-20, 0); ctx.RelLineTo(0, 20); ctx.ClosePath(); ctx.SetColor(Color.Black); ctx.Fill(); // Dashed lines ctx.SetLineDash(15, 10, 10, 5, 5); ctx.Rectangle(100, 100, 100, 100); ctx.Stroke(); ctx.SetLineDash(0); ImageBuilder ib = new ImageBuilder(30, 30, ImageFormat.ARGB32); ib.Context.Arc(15, 15, 15, 0, 360); ib.Context.SetColor(new Color(1, 0, 1)); ib.Context.Rectangle(0, 0, 5, 5); ib.Context.Fill(); var img = ib.ToImage(); ctx.DrawImage(img, 90, 90); ctx.DrawImage(img, 90, 140, 50, 10); ctx.Arc(190, 190, 15, 0, 360); ctx.SetColor(new Color(1, 0, 1, 0.4)); ctx.Fill(); ctx.Save(); ctx.Translate(90, 220); ctx.Pattern = new ImagePattern(img); ctx.Rectangle(0, 0, 100, 70); ctx.Fill(); ctx.Restore(); ctx.Translate(30, 30); double end = 270; for (double n = 0; n <= end; n += 5) { ctx.Save(); ctx.Rotate(n); ctx.MoveTo(0, 0); ctx.RelLineTo(30, 0); double c = n / end; ctx.SetColor(new Color(c, c, c)); ctx.Stroke(); ctx.Restore(); } ctx.ResetTransform(); }
public void Draw(Xwt.Drawing.Context cr, Rectangle area) { TextViewMargin textViewMargin = editor.TextViewMargin; ISyntaxMode mode = Document.SyntaxMode != null && editor.Options.EnableSyntaxHighlighting ? Document.SyntaxMode : new SyntaxMode(Document); TextViewMargin.LayoutWrapper lineLayout = null; double brightness = HslColor.Brightness(editor.ColorStyle.PlainText.Background); int colorCount = foldSegments.Count + 2; cr.SetColor(GetColor(-1, brightness, colorCount)); cr.Rectangle(area); cr.Fill(); var rectangles = new Rectangle[foldSegments.Count]; const int xPadding = 4; const int yPadding = 2; const int rightMarginPadding = 16; for (int i = foldSegments.Count - 1; i >= 0; i--) { var segment = foldSegments[i]; if (segment.IsInvalid) { continue; } var segmentStartLine = segment.StartLine; var segmentEndLine = segment.EndLine; int curWidth = 0; var endLine = segmentEndLine.NextLine; var y = editor.LineToY(segmentStartLine.LineNumber); if (y < editor.VAdjustment.Value) { segmentStartLine = editor.GetLine(editor.YToLine(editor.VAdjustment.Value)); y = editor.LineToY(segmentStartLine.LineNumber); } for (var curLine = segmentStartLine; curLine != endLine && y < editor.VAdjustment.Value + editor.Size.Height; curLine = curLine.NextLine) { var curLayout = textViewMargin.CreateLinePartLayout(mode, curLine, curLine.Offset, curLine.Length, -1, -1); var width = (int)(curLayout.Width); curWidth = System.Math.Max(curWidth, width); y += editor.GetLineHeight(curLine); } double xPos = textViewMargin.XOffset; double rectangleWidth = 0, rectangleHeight = 0; lineLayout = textViewMargin.CreateLinePartLayout(mode, segmentStartLine, segmentStartLine.Offset, segmentStartLine.Length, -1, -1); var rectangleStart = lineLayout.Layout.IndexToPos(GetFirstNonWsIdx(lineLayout.Layout.Text)); xPos = System.Math.Max(textViewMargin.XOffset, (textViewMargin.XOffset + textViewMargin.TextStartPosition + rectangleStart.X) - xPadding); lineLayout = textViewMargin.CreateLinePartLayout(mode, segmentEndLine, segmentEndLine.Offset, segmentEndLine.Length, -1, -1); var rectangleEnd = lineLayout.Layout.IndexToPos(GetFirstNonWsIdx(lineLayout.Layout.Text)); xPos = System.Math.Min(xPos, System.Math.Max(textViewMargin.XOffset, (textViewMargin.XOffset + textViewMargin.TextStartPosition + rectangleEnd.X) - xPadding)); rectangleWidth = textViewMargin.XOffset + textViewMargin.TextStartPosition + curWidth - xPos + xPadding * 2; if (i < foldSegments.Count - 1) { rectangleWidth = System.Math.Max((rectangles[i + 1].X + rectangles[i + 1].Width + rightMarginPadding) - xPos, rectangleWidth); } y = editor.LineToY(segment.StartLine.LineNumber); var yEnd = editor.LineToY(segment.EndLine.LineNumber + 1) + (segment.EndLine.LineNumber == editor.LineCount ? editor.LineHeight : 0); if (yEnd == 0) { yEnd = editor.VAdjustment.UpperValue; } rectangleHeight = yEnd - y; rectangles[i] = new Rectangle(xPos, y - yPadding, rectangleWidth, rectangleHeight + yPadding * 2); } for (int i = 0; i < foldSegments.Count; i++) { Rectangle clampedRect; var rect = rectangles[i]; if (i == foldSegments.Count - 1) { /* var radius = (int)(editor.Options.Zoom * 2); * int w = 2 * radius; * using (var shadow = new Blur ( * System.Math.Min ((int)rect.Width + w * 2, editor.Allocation.Width), * System.Math.Min ((int)rect.Height + w * 2, editor.Allocation.Height), * radius)) { * using (var gctx = shadow.GetContext ()) { * gctx.Color = new Color (0, 0, 0, 0); * gctx.Fill (); * * var a = 0; * var b = 0; * DrawRoundRectangle (gctx, true, true, w - a, w - b, editor.LineHeight / 4, rect.Width + a * 2, rect.Height + a * 2); * var bg = editor.ColorStyle.Default.CairoColor; * gctx.Color = new Color (bg.R, bg.G, bg.B, 0.6); * gctx.Fill (); * } * * cr.Save (); * cr.Translate (rect.X - w - editor.HAdjustment.Value, rect.Y - editor.VAdjustment.Value - w); * shadow.Draw (cr); * cr.Restore (); * }*/ var curPadSize = 1; var age = (DateTime.Now - startTime).TotalMilliseconds; var alpha = 0.1; if (age < animationLength) { var animationState = age / (double)animationLength; curPadSize = (int)(3 + System.Math.Sin(System.Math.PI * animationState) * 3); alpha = 0.1 + (1.0 - animationState) / 5; } var bg = editor.ColorStyle.PlainText.Foreground; cr.SetColor(bg.WithAlpha(alpha)); clampedRect = ClampRect(rect.X - editor.HAdjustment.Value - curPadSize, rect.Y - editor.VAdjustment.Value - curPadSize, editor.LineHeight / 2, rect.Width + curPadSize * 2, rect.Height + curPadSize * 2, area); DrawRoundRectangle(cr, true, true, clampedRect.X, clampedRect.Y, editor.LineHeight / 2, clampedRect.Width, clampedRect.Height); cr.Fill(); if (age < animationLength) { var animationState = age / (double)animationLength; curPadSize = (int)(2 + System.Math.Sin(System.Math.PI * animationState) * 2); clampedRect = ClampRect(rect.X - editor.HAdjustment.Value - curPadSize, rect.Y - editor.VAdjustment.Value - curPadSize, editor.LineHeight / 2, rect.Width + curPadSize * 2, rect.Height + curPadSize * 2, area); DrawRoundRectangle(cr, true, true, clampedRect.X, clampedRect.Y, editor.LineHeight / 2, clampedRect.Width, clampedRect.Height); cr.SetSourceColor(GetColor(i, brightness, colorCount)); cr.Fill(); continue; } } clampedRect = ClampRect(rect.X - editor.HAdjustment.Value, rect.Y - editor.VAdjustment.Value, editor.LineHeight / 2, rect.Width, rect.Height, area); DrawRoundRectangle(cr, true, true, clampedRect.X, clampedRect.Y, editor.LineHeight / 2, clampedRect.Width, clampedRect.Height); cr.SetSourceColor(GetColor(i, brightness, colorCount)); cr.Fill(); } }
internal protected override void Draw(Xwt.Drawing.Context cr, Rectangle area, DocumentLine lineSegment, int line, double x, double y, double lineHeight) { var marker = lineSegment != null ? (MarginMarker)lineSegment.Markers.FirstOrDefault(m => m is MarginMarker && ((MarginMarker)m).CanDraw(this)) : null; if (marker != null) { bool hasDrawn = marker.DrawBackground(editor, cr, new MarginDrawMetrics(this, area, lineSegment, line, x, y, lineHeight)); if (!hasDrawn) { marker = null; } } foldSegmentSize = marginWidth * 4 / 6; foldSegmentSize -= (foldSegmentSize) % 2; Rectangle drawArea = new Rectangle(x, y, marginWidth, lineHeight); var state = editor.Document.GetLineState(lineSegment); bool isFoldStart = false; bool isContaining = false; bool isFoldEnd = false; bool isStartSelected = false; bool isContainingSelected = false; bool isEndSelected = false; if (editor.Options.ShowFoldMargin && line <= editor.Document.LineCount) { startFoldings.Clear(); containingFoldings.Clear(); endFoldings.Clear(); foreach (FoldSegment segment in editor.Document.GetFoldingContaining(lineSegment)) { if (segment.StartLine.Offset == lineSegment.Offset) { startFoldings.Add(segment); } else if (segment.EndLine.Offset == lineSegment.Offset) { endFoldings.Add(segment); } else { containingFoldings.Add(segment); } } isFoldStart = startFoldings.Count > 0; isContaining = containingFoldings.Count > 0; isFoldEnd = endFoldings.Count > 0; isStartSelected = this.lineHover != null && IsMouseHover(startFoldings); isContainingSelected = this.lineHover != null && IsMouseHover(containingFoldings); isEndSelected = this.lineHover != null && IsMouseHover(endFoldings); } if (marker == null) { if (editor.GetTextEditorData().HighlightCaretLine&& editor.Caret.Line == line) { editor.TextViewMargin.DrawCaretLineMarker(cr, x, y, Width, lineHeight); } else { var bgGC = foldBgGC; if (editor.TextViewMargin.BackgroundRenderer != null) { if (isContainingSelected || isStartSelected || isEndSelected) { bgGC = foldBgGC; } else { bgGC = foldLineHighlightedGCBg; } } cr.Rectangle(drawArea); cr.SetSourceColor(bgGC); cr.Fill(); } } if (editor.Options.EnableQuickDiff) { if (state == TextDocument.LineState.Changed) { cr.SetSourceColor(lineStateChangedGC); cr.Rectangle(x + 1, y, marginWidth / 3, lineHeight); cr.Fill(); } else if (state == TextDocument.LineState.Dirty) { cr.SetSourceColor(lineStateDirtyGC); cr.Rectangle(x + 1, y, marginWidth / 3, lineHeight); cr.Fill(); } } if (editor.Options.ShowFoldMargin && line <= editor.Document.LineCount) { double foldSegmentYPos = y + System.Math.Floor(editor.LineHeight - foldSegmentSize) / 2; double xPos = x + System.Math.Floor(marginWidth / 2) + 0.5; if (isFoldStart) { bool isVisible = true; bool moreLinedOpenFold = false; foreach (FoldSegment foldSegment in startFoldings) { if (foldSegment.IsFolded) { isVisible = false; } else { moreLinedOpenFold = foldSegment.EndLine.Offset > foldSegment.StartLine.Offset; } } bool isFoldEndFromUpperFold = false; foreach (FoldSegment foldSegment in endFoldings) { if (foldSegment.EndLine.Offset > foldSegment.StartLine.Offset && !foldSegment.IsFolded) { isFoldEndFromUpperFold = true; } } DrawFoldSegment(cr, x, y, isVisible, isStartSelected); if (isContaining || isFoldEndFromUpperFold) { cr.DrawLine(isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Y, xPos, foldSegmentYPos - 2); } if (isContaining || moreLinedOpenFold) { cr.DrawLine(isEndSelected || (isStartSelected && isVisible) || isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, foldSegmentYPos + foldSegmentSize + 2, xPos, drawArea.Y + drawArea.Height); } } else { if (isFoldEnd) { double yMid = System.Math.Floor(drawArea.Y + drawArea.Height / 2) + 0.5; cr.DrawLine(isEndSelected ? foldLineHighlightedGC : foldLineGC, xPos, yMid, x + marginWidth - 2, yMid); cr.DrawLine(isContainingSelected || isEndSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Y, xPos, yMid); if (isContaining) { cr.DrawLine(isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, yMid, xPos, drawArea.Y + drawArea.Height); } } else if (isContaining) { cr.DrawLine(isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Y, xPos, drawArea.Y + drawArea.Height); } } } }
public virtual void Texts(Xwt.Drawing.Context ctx, double x, double y) { ctx.Save(); ctx.Translate(x, y); ctx.SetColor(Colors.Black); var col1 = new Rectangle(); var col2 = new Rectangle(); var text = new TextLayout(); text.Font = this.Font.WithSize(24); Console.WriteLine(text.Font.Size); // first text text.Text = "Lorem ipsum dolor sit amet,"; var size1 = text.GetSize(); col1.Width = size1.Width; col1.Height += size1.Height + 10; ctx.DrawTextLayout(text, 0, 0); // proofing width; test should align with text above ctx.SetColor(Colors.DarkMagenta); text.Text = "consetetur sadipscing elitr, sed diam nonumy"; text.Width = col1.Width; var size2 = text.GetSize(); ctx.DrawTextLayout(text, 0, col1.Bottom); col1.Height += size2.Height + 10; ctx.SetColor(Colors.Black); // proofing scale, on second col ctx.Save(); ctx.SetColor(Colors.Red); col2.Left = col1.Right + 10; text.Text = "eirmod tempor invidunt ut."; var scale = 1.2; text.Width = text.Width / scale; var size3 = text.GetSize(); col2.Height = size3.Height * scale; col2.Width = size3.Width * scale + 5; ctx.Scale(scale, scale); ctx.DrawTextLayout(text, col2.Left / scale, col2.Top / scale); ctx.Restore(); // proofing heigth, on second col ctx.Save(); ctx.SetColor(Colors.DarkCyan); text.Text = "Praesent ac lacus nec dolor pulvinar feugiat a id elit."; var size4 = text.GetSize(); text.Height = size4.Height / 2; text.Trimming = TextTrimming.WordElipsis; ctx.DrawTextLayout(text, col2.Left, col2.Bottom + 5); ctx.SetLineWidth(1); ctx.SetColor(Colors.Blue); ctx.Rectangle(new Rectangle(col2.Left, col2.Bottom + 5, text.Width, text.Height)); ctx.Stroke(); ctx.Restore(); // drawing col line ctx.SetLineWidth(1); ctx.SetColor(Colors.Black.WithAlpha(.5)); ctx.MoveTo(col1.Right + 5, col1.Top); ctx.LineTo(col1.Right + 5, col1.Bottom); ctx.Stroke(); ctx.MoveTo(col2.Right + 5, col2.Top); ctx.LineTo(col2.Right + 5, col2.Bottom); ctx.Stroke(); ctx.SetColor(Colors.Black); // proofing rotate, and printing size to see the values ctx.Save(); text.Font = this.Font.WithSize(10); text.Text = string.Format("Size 1 {0}\r\nSize 2 {1}\r\nSize 3 {2} Scale {3}", size1, size2, size3, scale); text.Width = -1; // this clears textsize text.Height = -1; ctx.Rotate(5); // maybe someone knows a formula with angle and textsize to calculyte ty var ty = 30; ctx.DrawTextLayout(text, ty, col1.Bottom + 10); ctx.Restore(); // scale example here: ctx.Restore(); TextLayout tl0 = new TextLayout(this); tl0.Font = this.Font.WithSize(10); tl0.Text = "This text contains attributes."; tl0.SetUnderline(0, "This".Length); tl0.SetForeground(new Color(0, 1.0, 1.0), "This ".Length, "text".Length); tl0.SetBackground(new Color(0, 0, 0), "This ".Length, "text".Length); tl0.SetFontWeight(FontWeight.Bold, "This text ".Length, "contains".Length); tl0.SetFontStyle(FontStyle.Italic, "This text ".Length, "contains".Length); tl0.SetStrikethrough("This text contains ".Length, "attributes".Length); ctx.DrawTextLayout(tl0, col2.Left, col2.Bottom + 100); // Text boces y = 180; // Without wrapping TextLayout tl = new TextLayout(this); tl.Text = "Stright text"; DrawText(ctx, tl, ref y); // With wrapping tl = new TextLayout(this); tl.Text = "The quick brown fox jumps over the lazy dog"; tl.Width = 100; DrawText(ctx, tl, ref y); // With blank lines tl = new TextLayout(this); tl.Text = "\nEmpty line above\nLine break above\n\nEmpty line above\n\n\nTwo empty lines above\nEmpty line below\n"; tl.Width = 200; DrawText(ctx, tl, ref y); }
protected override void OnDraw(Context ctx, Rectangle dirtyRect) { ctx.Save (); ctx.Translate (-hscroll.Value, -vscroll.Value); ctx.Rectangle (new Rectangle (0, 0, imageSize, imageSize)); ctx.SetColor (Xwt.Drawing.Colors.White); ctx.Fill (); ctx.Arc (imageSize / 2, imageSize / 2, imageSize / 2 - 20, 0, 360); ctx.SetColor (new Color (0,0,1)); ctx.Fill (); ctx.Restore (); ctx.Rectangle (0, 0, Bounds.Width, 30); ctx.SetColor (new Color (1, 0, 0, 0.5)); ctx.Fill (); }
/// <summary> /// Draws the candle plot with the specified Drawing Context and X,Y axes /// </summary> /// <param name="ctx">The Drawing Context with which to draw</param> /// <param name="xAxis">The physical X-Axis to draw against</param> /// <param name="yAxis">The physical Y-Axis to draw against</param> public void Draw(Context ctx, PhysicalAxis xAxis, PhysicalAxis yAxis) { CandleDataAdapter cd = new CandleDataAdapter (DataSource, DataMember, AbscissaData, OpenData, LowData, HighData, CloseData); double offset = 0; if (Centered) { offset = CalculatePhysicalSeparation (cd,xAxis)/2; } double addAmount = StickWidth/2; double stickWidth = StickWidth; if (StickWidth == AutoScaleStickWidth) { // default addAmount = 2; stickWidth = 4; double minDist = CalculatePhysicalSeparation (cd, xAxis); addAmount = minDist / 3; stickWidth = addAmount * 2; } ctx.Save (); ctx.SetLineWidth (1); /* // brant hyatt proposed. if (Style == Styles.Stick) { p.Width = stickWidth; addAmount = stickWidth + 2; } */ for (int i=0; i<cd.Count; ++i) { PointOLHC point = (PointOLHC)cd [i]; if ((!double.IsNaN (point.Open)) && (!double.IsNaN(point.High)) && (!double.IsNaN (point.Low)) && (!double.IsNaN(point.Close))) { double xPos = (xAxis.WorldToPhysical (point.X, false)).X; if (xPos + offset + addAmount < xAxis.PhysicalMin.X || xAxis.PhysicalMax.X < xPos + offset - addAmount) { continue; } double yLo = (yAxis.WorldToPhysical (point.Low, false)).Y; double yHi = (yAxis.WorldToPhysical (point.High, false)).Y; double yOpn = (yAxis.WorldToPhysical (point.Open, false)).Y; double yCls = (yAxis.WorldToPhysical (point.Close,false)).Y; if (Style == Styles.Stick) { /* // brant hyatt proposed. if (i > 0) { if ( ((PointOLHC)cd[i]).Close > ((PointOLHC)cd[i-1]).Close) { p.Color = BullishColor; } else { p.Color = BearishColor; } } */ ctx.SetColor (Color); ctx.MoveTo (xPos+offset, yLo); ctx.LineTo (xPos+offset, yHi); // Low to High line ctx.MoveTo (xPos-addAmount+offset, yOpn); ctx.LineTo (xPos+offset, yOpn); // Open line ctx.MoveTo (xPos+addAmount+offset, yCls); ctx.LineTo (xPos+offset, yCls); // Close line ctx.Stroke (); } else if (Style == Styles.Filled) { ctx.MoveTo (xPos+offset, yLo); ctx.LineTo (xPos+offset, yHi); ctx.Stroke (); if (yOpn > yCls) { ctx.SetColor (BullishColor); ctx.Rectangle (xPos-addAmount+offset, yCls, stickWidth, yOpn - yCls); ctx.FillPreserve (); ctx.SetColor (Color); ctx.Stroke (); } else if (yOpn < yCls) { ctx.SetColor (BearishColor); ctx.Rectangle (xPos-addAmount+offset, yOpn, stickWidth, yCls - yOpn); ctx.FillPreserve (); ctx.SetColor (Color); ctx.Stroke (); } else { // Cls == Opn ctx.MoveTo (xPos-addAmount+offset, yOpn); ctx.LineTo (xPos-addAmount+stickWidth+offset, yCls); ctx.Stroke (); } } } } ctx.Restore (); }
void DrawText(Context ctx, TextLayout tl, ref double y) { double x = 10; var s = tl.GetSize (); var rect = new Rectangle (x, y, s.Width, s.Height).Inflate (0.5, 0.5); ctx.SetLineWidth (1); ctx.SetColor (Colors.Blue); ctx.Rectangle (rect); ctx.Stroke (); ctx.SetColor (Colors.Black); ctx.DrawTextLayout (tl, x, y); y += s.Height + 20; }
protected override sealed void OnDraw(Context ctx, Rectangle bounds) { var frame = GetFrame (ctx.ScaleFactor); var fixedWidth = frame.Bitmap.Width - 2 - frame.StretchableWidth; var fixedHeight = frame.Bitmap.Height - 2 - frame.StretchableHeight; double totalVariableWidth = bounds.Width - fixedWidth / frame.ScaleFactor; double totalVariableHeight = bounds.Height - fixedHeight / frame.ScaleFactor; double remainingVariableHeight = totalVariableHeight; double y = bounds.Y, yb = 1; int tileIndex = 0; ctx.Save (); if (totalVariableWidth < 0) { if (fixedWidth > 0) ctx.Scale (bounds.Width / fixedWidth, 1); totalVariableWidth = 0; } if (totalVariableHeight < 0) { if (fixedHeight > 0) ctx.Scale (1, bounds.Height / fixedHeight); totalVariableHeight = 0; } foreach (var vs in frame.VerticalSections) { double sh = CalcSectionSize (frame, vs, totalVariableHeight, frame.StretchableHeight, ref remainingVariableHeight); double x = bounds.X, xb = 1; double remainingVariableWidth = totalVariableWidth; foreach (var hs in frame.HorizontalSections) { var sourceRegion = new Rectangle (xb, yb, hs.Size, vs.Size); double sw = CalcSectionSize (frame, hs, totalVariableWidth, frame.StretchableWidth, ref remainingVariableWidth); var targetRegion = new Rectangle (x, y, sw, sh); if (vs.Mode != RenderMode.Tile && hs.Mode != RenderMode.Tile) { var t = GetTile (frame, tileIndex, sourceRegion); ctx.DrawImage (t, targetRegion); } else { double pw = hs.Size / frame.ScaleFactor; double ph = vs.Size / frame.ScaleFactor; if (hs.Mode == RenderMode.Stretch) { pw = targetRegion.Width; } if (vs.Mode == RenderMode.Stretch) { ph = targetRegion.Height; } ctx.Save (); ctx.Translate (targetRegion.Location); targetRegion.Location = Point.Zero; ctx.Pattern = new ImagePattern (GetTile (frame, tileIndex, sourceRegion).WithSize (pw, ph)); ctx.NewPath (); ctx.Rectangle (targetRegion); ctx.Fill (); ctx.Restore (); } x += sw; xb += hs.Size; tileIndex++; } yb += vs.Size; y += sh; } ctx.Restore (); }
protected override void OnDraw(Context ctx) { ctx.SetColor (new Color (0.5, 0.5, 0.5)); ctx.Rectangle (Bounds); ctx.Fill (); ctx.SetColor (new Color (0.8, 0.8, 0.8)); ctx.Rectangle (Bounds.Inflate (-margin, -margin)); ctx.Fill (); ctx.SetColor (Color); ctx.Rectangle (Bounds.Width / 2 - coreSize.Width / 2, Bounds.Height / 2 - coreSize.Height / 2, coreSize.Width, coreSize.Height); ctx.Fill (); }
protected override void OnDraw (Context ctx, Rectangle dirtyRect) { double width = Size.Width - padding * 2; int range = (int)Size.Height - padding * 2; for (int n=0; n < range; n++) { ctx.Rectangle (padding, padding + n, width, 1); ctx.SetColor (Color.FromHsl (hue, saturation, (double)(range - n - 1) / (double)(range - 1))); ctx.Fill (); } ctx.Rectangle (0.5, padding + (int)(((double)range) * (1-light)) + 0.5 - 2, Size.Width - 1, 4); ctx.SetColor (Colors.Black); ctx.SetLineWidth (1); ctx.Stroke (); }
protected override void OnDraw (Context ctx, Rectangle dirtyRect) { if (colorBox == null) { using (var ib = new ImageBuilder (size, size)) { for (int i=0; i<size; i++) { for (int j=0; j<size; j++) { ib.Context.Rectangle (i, j, 1, 1); ib.Context.SetColor (GetColor (i,j)); ib.Context.Fill (); } } if (ParentWindow != null) colorBox = ib.ToBitmap (this); // take screen scale factor into account else colorBox = ib.ToBitmap (); } } ctx.DrawImage (colorBox, padding, padding); ctx.SetLineWidth (1); ctx.SetColor (Colors.Black); ctx.Rectangle (selection.X + padding - 2 + 0.5, selection.Y + padding - 2 + 0.5, 4, 4); ctx.Stroke (); }
public virtual void Scale(Context ctx, double ax, double ay) { ctx.Save (); ctx.Translate (ax, ay); ctx.SetColor (Colors.Black); ctx.SetLineWidth (1); var x = 0d; var y = 0d; var w = 10d; var inc = .1d; for (var i = inc; i < 3.5d; i +=inc) { ctx.Save (); ctx.Scale (i, i); ctx.Rectangle (x, y, w, w); ctx.SetColor (Colors.Yellow.WithAlpha (1 / i)); ctx.FillPreserve (); ctx.SetColor (Colors.Red.WithAlpha (1 / i)); ctx.Stroke (); ctx.MoveTo (x += w * inc, y += w * inc / 3); ctx.Restore (); } ctx.Restore (); }
protected override void OnDraw (Context ctx, Rectangle dirtyRect) { ctx.Rectangle (Bounds); ctx.SetColor (Colors.White); ctx.Fill (); ctx.MoveTo (0, 0); ctx.LineTo (Size.Width, 0); ctx.LineTo (0, Size.Height); ctx.LineTo (0, 0); ctx.SetColor (Colors.Black); ctx.Fill (); ctx.Rectangle (Bounds); ctx.SetColor (color); ctx.Fill (); }
protected override void OnDraw (Context ctx, Rectangle dirtyRect) { base.OnDraw (ctx, dirtyRect); ctx.Save (); if (parent.CurrentRow < 0) return; var row_bounds = parent.ListView.GetRowBounds (parent.CurrentRow, false); var row_bg_bounds = parent.ListView.GetRowBounds (parent.CurrentRow, true); if (TrackerBg != null) { ctx.DrawImage (TrackerBg, row_bg_bounds, new Rectangle (0, 0, row_bg_bounds.Width, row_bg_bounds.Height)); } foreach (var col in parent.ListView.Columns) { foreach (var cell in col.Views) { var cell_bg_bounds = parent.ListView.GetCellBounds (parent.CurrentRow, cell, true); var cell_bounds = parent.ListView.GetCellBounds (parent.CurrentRow, cell, false); cell_bounds.Y -= row_bg_bounds.Y; cell_bounds.X += parent.ListView.HorizontalScrollControl.Value; cell_bg_bounds.Y -= row_bg_bounds.Y; cell_bg_bounds.X += parent.ListView.HorizontalScrollControl.Value; ctx.SetColor (Colors.Red); ctx.Rectangle (cell_bg_bounds); ctx.Stroke (); ctx.SetColor (Colors.Green); ctx.Rectangle (cell_bounds); ctx.Stroke (); } } row_bounds.Y -= row_bg_bounds.Y; row_bounds.X += parent.ListView.HorizontalScrollControl.Value; row_bg_bounds.Y = 0; row_bg_bounds.X += parent.ListView.HorizontalScrollControl.Value; ctx.SetColor (Colors.Red); ctx.Rectangle (row_bg_bounds); ctx.Stroke (); ctx.SetColor (Colors.Blue); ctx.Rectangle (row_bounds); ctx.Stroke (); ctx.Restore (); }