protected override void DrawFrame (Cairo.Context context, double lineWidth, Cairo.Color lineColor, Cairo.Color fillColor) { // base.DrawFrame (context, lineWidth, lineColor, fillColor); rect = DisplayBox; rect.OffsetDot5(); // HERZUM SPRINT 1.2 // CairoFigures.CurvedRectangle(context, rect, 30); CairoFigures.AngleFrame(context, rect, 0,0,0,0); // END HERZUM SPRINT 1.2 Cairo.Color fillColorOrigin; fillColorOrigin = fillColor; lineWidth = 1; fillColor = new Cairo.Color (1.0, 1.0, 1.0, 1.0); context.Color = fillColor; context.FillPreserve(); context.Color = lineColor; context.LineWidth = lineWidth; double[] dash = {2, 0, 2}; context.SetDash (dash, 0); context.Stroke(); rect2 = DisplayBox; rect2.Width = DisplayBox.Width; rect2.Height = 30; rect2.OffsetDot5(); CairoFigures.CurvedRectangle(context, rect2, 30); fillColor = fillColorOrigin; context.Color = fillColor; context.FillPreserve(); context.Color = lineColor; context.LineWidth = lineWidth; context.Stroke(); // HERZUM SPRINT 2.1 // m_applicationContext.MainWindow.ExperimentCanvasPad.LoopNodeControlCurrent = this; // END HERZUM SPRINT 2.1 // HERZUM SPRINT 5.0: TLAB-235 // DrawScope (); DrawScope ("Enter","Exit"); // END HERZUM SPRINT 5.0: TLAB-235 }
static void DrawIcon (MonoTextEditor editor, Cairo.Context cr, DocumentLine lineSegment, double x, double y, double width, double height) { if (lineSegment.IsBookmarked) { var color1 = editor.ColorStyle.Bookmarks.Color; var color2 = editor.ColorStyle.Bookmarks.SecondColor; DrawRoundRectangle (cr, x + 1, y + 1, 8, width - 4, height - 4); // FIXME: VV: Remove gradient features using (var pat = new Cairo.LinearGradient (x + width / 4, y, x + width / 2, y + height - 4)) { pat.AddColorStop (0, color1); pat.AddColorStop (1, color2); cr.SetSource (pat); cr.FillPreserve (); } // FIXME: VV: Remove gradient features using (var pat = new Cairo.LinearGradient (x, y + height, x + width, y)) { pat.AddColorStop (0, color2); //pat.AddColorStop (1, color1); cr.SetSource (pat); cr.Stroke (); } } }
static void draw (Cairo.Context gr, int width, int height) { gr.Scale (width, height); gr.LineWidth = 0.04; gr.MoveTo ( new PointD (0.5, 0.1) ); gr.LineTo ( new PointD (0.9, 0.9) ); gr.RelLineTo ( new Distance (-0.4, 0.0) ); gr.CurveTo ( new PointD (0.2, 0.9), new PointD ( 0.2, 0.5), new PointD (0.5, 0.5) ); gr.ClosePath (); gr.MoveTo ( new PointD (0.25, 0.1) ); gr.RelLineTo ( new Distance (0.2, 0.2) ); gr.RelLineTo ( new Distance ( -0.2, 0.2) ); gr.RelLineTo ( new Distance (-0.2, -0.2) ); gr.ClosePath (); gr.Color = new Color (0, 0, 1, 1); gr.FillPreserve (); gr.Color = new Color ( 0, 0, 0, 1); gr.Stroke (); }
void DrawFace (Cairo.PointD center, double radius, Cairo.Context e) { e.Arc (center.X, center.Y, radius, 0, 360); Cairo.Gradient pat = new Cairo.LinearGradient (100, 200, 200, 100); pat.AddColorStop (0, Generator.ConvertC (new Eto.Drawing.Color (240, 240, 230, 75))); pat.AddColorStop (1, Generator.ConvertC (new Eto.Drawing.Color (0, 0, 0, 50))); e.LineWidth = 0.1; e.Pattern = pat; e.FillPreserve (); e.Stroke (); }
protected override void DrawFrame (Cairo.Context context, double lineWidth, Cairo.Color lineColor, Cairo.Color fillColor) { RectangleD rect = DisplayBox; rect.OffsetDot5(); CairoFigures.AngleFrame(context, rect, 15, 0, 15, 0); context.Color = fillColor; context.FillPreserve(); context.Color = lineColor; context.LineWidth = lineWidth; context.Stroke(); }
protected override void DrawFrame (Cairo.Context context, double lineWidth, Cairo.Color lineColor, Cairo.Color fillColor) { RectangleD rect = DisplayBox; rect.OffsetDot5(); context.Rectangle(GdkCairoHelper.CairoRectangle(rect)); context.Color = fillColor; context.FillPreserve(); context.Color = lineColor; context.LineWidth = lineWidth; context.Stroke(); }
static void DrawFace (Cairo.PointD center, double radius, Cairo.Context e) { e.Arc (center.X, center.Y, radius, 0, 360); Cairo.Gradient pat = new Cairo.LinearGradient (100, 200, 200, 100); pat.AddColorStop (0, Eto.Drawing.Color.FromArgb (240, 240, 230, 75).ToCairo ()); pat.AddColorStop (1, Eto.Drawing.Color.FromArgb (0, 0, 0, 50).ToCairo ()); e.LineWidth = 0.1; e.Pattern = pat; e.FillPreserve (); e.Stroke (); }
public void DrawIcon (TextEditor editor, Cairo.Context cr, LineSegment lineSegment, int lineNumber, double x, double y, double width, double height) { if (lineSegment.IsBookmarked) { Cairo.Color color1 = editor.ColorStyle.BookmarkColor1; Cairo.Color color2 = editor.ColorStyle.BookmarkColor2; DrawRoundRectangle (cr, x + 1, y + 1, 8, width - 4, height - 4); Cairo.Gradient pat = new Cairo.LinearGradient (x + width / 4, y, x + width / 2, y + height - 4); pat.AddColorStop (0, color1); pat.AddColorStop (1, color2); cr.Pattern = pat; cr.FillPreserve (); pat = new Cairo.LinearGradient (x, y + height, x + width, y); pat.AddColorStop (0, color2); //pat.AddColorStop (1, color1); cr.Pattern = pat; cr.Stroke (); } }
static void draw (Cairo.Context gr, int width, int height) { gr.Scale (width, height); gr.LineWidth = 0.04; gr.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Bold); gr.SetFontSize (0.35); gr.MoveTo ( new PointD(0.04, 0.53) ); gr.ShowText ("Hello"); gr.MoveTo ( new PointD(0.27, 0.65) ); gr.TextPath ("void"); gr.ColorRgb = new Color (0.5, 0.5, 1, 0); gr.FillPreserve (); gr.ColorRgb = new Color (0, 0, 0, 0); gr.LineWidth = 0.01; gr.Stroke (); gr.Color = new Color (1,0.2,0.2, 0.6); gr.Arc (0.04, 0.53, 0.02, 0, 2*M_PI); gr.Arc (0.27, 0.65, 0.02, 0, 2*M_PI); gr.Fill (); }
protected void DrawSearchIndicator (Cairo.Context cr) { int diameter = Math.Min (Allocation.Width, (int)IndicatorHeight) - indicatorPadding * 2; var x1 = Math.Round (Allocation.Width / 2d); double y1 = indicatorPadding; if (diameter % 2 == 0) { x1 += 0.5; y1 += 0.5; } cr.Arc (x1, y1, diameter / 2d, 0, 2 * Math.PI); var darkColor = (HslColor)TextEditor.ColorStyle.SearchResult.Color; darkColor.L *= 0.5; if (flatStyle) { using (var pattern = new Cairo.SolidPattern (TextEditor.ColorStyle.SearchResultMain.Color)) { cr.Pattern = pattern; cr.FillPreserve (); } } else { using (var pattern = new Cairo.RadialGradient (x1, y1, Allocation.Width / 2, x1 - Allocation.Width, y1 - Allocation.Width, Allocation.Width)) { pattern.AddColorStop (0, darkColor); pattern.AddColorStop (1, TextEditor.ColorStyle.SearchResultMain.Color); cr.Pattern = pattern; cr.FillPreserve (); } } cr.Color = darkColor; cr.Stroke (); }
public void DrawIcon(TextEditor editor, Cairo.Context cr, DocumentLine lineSegment, int lineNumber, double x, double y, double width, double height) { if (BookmarkService.Instance.CheckLineForBookmark (editor.FileName, lineSegment.LineNumber)) { Cairo.Color color1 = editor.ColorStyle.Bookmarks.Color; Cairo.Color color2 = editor.ColorStyle.Bookmarks.SecondColor; if (Bookmark.BookmarkType == BookmarkType.Local) DrawRoundRectangle (cr, x + 1, y + 1, 8, width - 4, height - 4); else DrawCircle (cr, x + (width / 2), y + (height / 2), 6); using (var pat = new Cairo.LinearGradient (x + width / 4, y, x + width / 2, y + height - 4)) { pat.AddColorStop (0, color1); pat.AddColorStop (1, color2); cr.Pattern = pat; cr.FillPreserve (); } using (var pat = new Cairo.LinearGradient (x, y + height, x + width, y)) { pat.AddColorStop (0, color2); //pat.AddColorStop (1, color1); cr.Pattern = pat; cr.Stroke (); } cr.Color = new Cairo.Color (0, 0, 0); cr.SelectFontFace (DesktopService.DefaultMonospaceFont, Cairo.FontSlant.Normal, Cairo.FontWeight.Bold); cr.SetFontSize (12); var te = cr.TextExtents (Bookmark.Number.ToString ()); cr.MoveTo (x + 5, y + 1 + te.Height); cr.ShowText (Bookmark.Number.ToString ()); } }
void DrawProgressBar (Cairo.Context context, double progress, Gdk.Rectangle bounding, StatusArea.RenderArg arg) { LayoutRoundedRectangle (context, new Gdk.Rectangle (bounding.X, bounding.Y, (int) (bounding.Width * progress), bounding.Height)); context.Clip (); LayoutRoundedRectangle (context, bounding); context.Color = Styles.WithAlpha (Styles.StatusBarProgressBackgroundColor, Styles.StatusBarProgressBackgroundColor.A * arg.ProgressBarAlpha); context.FillPreserve (); context.ResetClip (); context.Color = Styles.WithAlpha (Styles.StatusBarProgressOutlineColor, Styles.StatusBarProgressOutlineColor.A * arg.ProgressBarAlpha); context.LineWidth = 1; context.Stroke (); }
void DrawBackground(Cairo.Context context, Gdk.Rectangle region, int radius, StateType state) { double rad = radius - 0.5; int centerX = region.X + region.Width / 2; int centerY = region.Y + region.Height / 2; context.MoveTo (centerX + rad, centerY); context.Arc (centerX, centerY, rad, 0, Math.PI * 2); double high; double low; switch (state) { case StateType.Selected: high = 0.85; low = 1.0; break; case StateType.Prelight: high = 1.0; low = 0.9; break; case StateType.Insensitive: high = 0.95; low = 0.83; break; default: high = 1.0; low = 0.85; break; } using (var lg = new LinearGradient (0, centerY - rad, 0, centerY +rad)) { lg.AddColorStop (0, new Cairo.Color (high, high, high)); lg.AddColorStop (1, new Cairo.Color (low, low, low)); context.SetSource (lg); context.FillPreserve (); } context.SetSourceRGBA (0, 0, 0, 0.4); context.LineWidth = 1; context.Stroke (); }
void DrawExpander (Cairo.Context ctx, double ex, double ey, bool expanded, bool hilight) { ctx.NewPath (); ctx.LineWidth = 1; ctx.Rectangle (ex, ey, ExpanderSize, ExpanderSize); if (hilight) ctx.SetSourceColor (Style.Background (Gtk.StateType.Normal).ToCairoColor ()); else ctx.SetSourceColor (Style.White.ToCairoColor ()); ctx.FillPreserve (); ctx.SetSourceColor (Style.Foreground (Gtk.StateType.Normal).ToCairoColor ()); ctx.Stroke (); ctx.NewPath (); ctx.MoveTo (ex + 2, ey + (ExpanderSize/2)); ctx.RelLineTo (ExpanderSize - 4, 0); if (!expanded) { ctx.MoveTo (ex + (ExpanderSize/2), ey + 2); ctx.RelLineTo (0, ExpanderSize - 4); } ctx.Stroke (); }
void DrawCodeSegmentBorder (Gdk.GC gc, Cairo.Context ctx, double x, int width, BlockInfo firstBlock, BlockInfo lastBlock, string[] lines, Gtk.Widget widget, Gdk.Drawable window) { int shadowSize = 2; int spacing = 4; int bottomSpacing = (lineHeight - spacing) / 2; ctx.Rectangle (x + shadowSize + 0.5, firstBlock.YStart + bottomSpacing + spacing - shadowSize + 0.5, width - shadowSize*2, shadowSize); ctx.Color = new Cairo.Color (0.9, 0.9, 0.9); ctx.LineWidth = 1; ctx.Fill (); ctx.Rectangle (x + shadowSize + 0.5, lastBlock.YEnd + bottomSpacing + 0.5, width - shadowSize*2, shadowSize); ctx.Color = new Cairo.Color (0.9, 0.9, 0.9); ctx.Fill (); ctx.Rectangle (x + 0.5, firstBlock.YStart + bottomSpacing + spacing + 0.5, width, lastBlock.YEnd - firstBlock.YStart - spacing); ctx.Color = new Cairo.Color (0.7,0.7,0.7); ctx.Stroke (); string text = lines[firstBlock.FirstLine].Replace ("@","").Replace ("-",""); text = "<span size='x-small'>" + text.Replace ("+","</span><span size='small'>➜</span><span size='x-small'> ") + "</span>"; layout.SetText (""); layout.SetMarkup (text); int tw,th; layout.GetPixelSize (out tw, out th); th--; int dy = (lineHeight - th) / 2; ctx.Rectangle (x + 2 + LeftPaddingBlock - 1 + 0.5, firstBlock.YStart + dy - 1 + 0.5, tw + 2, th + 2); ctx.LineWidth = 1; ctx.Color = widget.Style.Base (Gtk.StateType.Normal).ToCairoColor (); ctx.FillPreserve (); ctx.Color = new Cairo.Color (0.7, 0.7, 0.7); ctx.Stroke (); window.DrawLayout (gc, (int)(x + 2 + LeftPaddingBlock), firstBlock.YStart + dy, layout); }
/// <summary> /// Draws the rectangle frame into the given cairo context /// </summary> /// <param name="context">Context.</param> /// <param name="lineWidth">Line width.</param> /// <param name="lineColor">Line color.</param> /// <param name="fillColor">Fill color.</param> protected virtual void DrawFrame(Cairo.Context context, double lineWidth, Cairo.Color lineColor, Cairo.Color fillColor) { RectangleD rect = DisplayBox; rect.OffsetDot5(); CairoFigures.CurvedRectangle (context, rect, 8); context.Color = fillColor; context.FillPreserve(); context.Color = lineColor; context.LineWidth = lineWidth; context.Stroke(); }
//TODO: improve this function public override void BasicDraw(Cairo.Context context) { if (DisplayBox.Width == 0 || DisplayBox.Height == 0) { return; } //Draw table context.LineWidth = 1.0; context.Save (); context.Translate (DisplayBox.X, DisplayBox.Y); context.Scale (DisplayBox.Width, DisplayBox.Height); context.Rectangle (0.0, 0.0, 1, 1); context.Restore (); _tableName.BasicDraw (context); syncFigureMetrics (); //Draw Table name Line PointD start0 = new PointD (DisplayBox.X, DisplayBox.Y + 1); context.Color = new Cairo.Color (0.8, 0.8, 1, 0.7); context.Rectangle (start0, _width, _tableName.BasicDisplayBox.Height - 5); context.FillPreserve (); context.Stroke (); //Draw Indexes Line PointD start = new PointD (DisplayBox.X, DisplayBox.Y + calcIndexLabelHeightPos ()); context.Color = new Cairo.Color (0.8, 0.8, 1, 0.7); context.Rectangle (start, _width, _indexLabel.BasicDisplayBox.Height - 4); context.FillPreserve (); context.Stroke (); //Draw Triggers Line PointD start2 = new PointD (DisplayBox.X, DisplayBox.Y + calcTriggerLabelHeightPos ()); context.Color = new Cairo.Color (0.8, 0.8, 1, 0.7); context.Rectangle (start2, _width, _triggerLabel.BasicDisplayBox.Height - 4); context.FillPreserve (); context.Stroke (); }
public override void DrawBackground (MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset) { this.editor = editor; int markerStart = base.Offset; int markerEnd = base.EndOffset; if (markerEnd < startOffset || markerStart > endOffset) return; double @from; double to; var startXPos = metrics.TextRenderStartPosition; var endXPos = metrics.TextRenderEndPosition; var y = metrics.LineYRenderStartPosition; if (markerStart < startOffset && endOffset < markerEnd) { @from = startXPos; to = endXPos; } else { int start = startOffset < markerStart ? markerStart : startOffset; int end = endOffset < markerEnd ? endOffset : markerEnd; uint curIndex = 0, byteIndex = 0; TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex); int x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X; @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale); TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex); x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X; to = startXPos + (int)(x_pos / Pango.Scale.PangoScale); } @from = Math.Max (@from, editor.TextViewMargin.XOffset); to = Math.Max (to, editor.TextViewMargin.XOffset); if (@from < to) { cr.SetSourceColor (background(editor).Color); cr.RoundedRectangle (@from + 2.5, y + 0.5, to - @from, editor.LineHeight - 1, 2); // 2.5 to make space for the column guideline if (background(editor).HasBorderColor) { cr.FillPreserve (); cr.SetSourceColor (background(editor).BorderColor); cr.Stroke (); } else { cr.Fill (); } } }
void DrawFoldSegment (Cairo.Context ctx, double x, double y, bool isOpen, bool isSelected) { var drawArea = new Cairo.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); }
void DrawChangeSymbol (Cairo.Context ctx, double x, int width, BlockInfo block) { if (!IsChangeBlock (block.Type)) return; Gdk.Color color = block.Type == BlockType.Added ? baseAddColor : baseRemoveColor; int ssize = 8; int barSize = 3; if (ssize - 2 > lineHeight) ssize = lineHeight - 2; if (ssize <= 0) return; double inSize = (ssize / 2) - (barSize / 2); double py = block.YStart + ((block.YEnd - block.YStart) / 2 - ssize / 2) + 0.5; double px = x + (LeftPaddingBlock/2) - (ssize / 2) + 0.5; if (block.Type == BlockType.Added) { ctx.MoveTo (px + inSize, py); ctx.RelLineTo (barSize, 0); ctx.RelLineTo (0, inSize); ctx.RelLineTo (inSize, 0); ctx.RelLineTo (0, barSize); ctx.RelLineTo (-inSize, 0); ctx.RelLineTo (0, inSize); ctx.RelLineTo (-barSize, 0); ctx.RelLineTo (0, -inSize); ctx.RelLineTo (-inSize, 0); ctx.RelLineTo (0, -barSize); ctx.RelLineTo (inSize, 0); ctx.RelLineTo (0, -inSize); ctx.ClosePath (); } else { ctx.MoveTo (px, py + inSize); ctx.RelLineTo (ssize, 0); ctx.RelLineTo (0, barSize); ctx.RelLineTo (-ssize, 0); ctx.RelLineTo (0, -barSize); ctx.ClosePath (); } ctx.Color = color.ToCairoColor (); ctx.FillPreserve (); ctx.Color = color.AddLight (-0.2).ToCairoColor ();; ctx.LineWidth = 1; ctx.Stroke (); }
void DrawLineBox (Gdk.GC gc, Cairo.Context ctx, int right, int top, int line, Gtk.Widget widget, Gdk.Drawable window) { layout.SetText (""); layout.SetMarkup ("<small>" + line.ToString () + "</small>"); int tw,th; layout.GetPixelSize (out tw, out th); th--; int dy = (lineHeight - th) / 2; ctx.Rectangle (right - tw - 2 + 0.5, top + dy - 1 + 0.5, tw + 2, th + 2); ctx.LineWidth = 1; ctx.Color = widget.Style.Base (Gtk.StateType.Normal).ToCairoColor (); ctx.FillPreserve (); ctx.Color = new Cairo.Color (0.7, 0.7, 0.7); ctx.Stroke (); window.DrawLayout (gc, right - tw - 1, top + dy, layout); }
void DrawIndicator (Cairo.Context cr, QuickTaskSeverity severity) { cr.Rectangle (3, Allocation.Height - Allocation.Width + 3, Allocation.Width - 6, Allocation.Width - 6); var darkColor = (HslColor)GetIndicatorColor (severity); darkColor.L *= 0.5; using (var pattern = new Cairo.LinearGradient (0, 0, Allocation.Width - 3, Allocation.Width - 3)) { pattern.AddColorStop (0, darkColor); pattern.AddColorStop (1, GetIndicatorColor (severity)); cr.Pattern = pattern; cr.FillPreserve (); } cr.Color = darkColor; cr.Stroke (); }
void DecorateMatchingBracket (Cairo.Context ctx, LayoutWrapper layout, int offset, int length, double xPos, double y, int selectionStart, int selectionEnd) { uint curIndex = 0, byteIndex = 0; if (offset <= highlightBracketOffset && highlightBracketOffset <= offset + length) { int index = highlightBracketOffset - offset; Pango.Rectangle rect = layout.Layout.IndexToPos ((int)TranslateToUTF8Index (layout.LineChars, (uint)index, ref curIndex, ref byteIndex)); var bracketMatch = new Cairo.Rectangle (xPos + rect.X / Pango.Scale.PangoScale + 0.5, y + 0.5, (rect.Width / Pango.Scale.PangoScale) - 1, (rect.Height / Pango.Scale.PangoScale) - 1); if (BackgroundRenderer == null) { ctx.Color = this.ColorStyle.BraceMatchingRectangle.Color; ctx.Rectangle (bracketMatch); ctx.FillPreserve (); ctx.Color = this.ColorStyle.BraceMatchingRectangle.SecondColor; ctx.Stroke (); } } }
void DrawSearchIndicator (Cairo.Context cr) { int x1 = 1 + Allocation.Width / 2; int y1 = Allocation.Height - Allocation.Width + (Allocation.Width + 3) / 2; cr.Arc (x1, y1, (Allocation.Width - 5) / 2, 0, 2 * Math.PI); var darkColor = (HslColor)TextEditor.ColorStyle.SearchTextBg; darkColor.L *= 0.5; using (var pattern = new Cairo.RadialGradient (x1, y1, Allocation.Width / 2, x1 - Allocation.Width, y1 - Allocation.Width, Allocation.Width)) { pattern.AddColorStop (0, darkColor); pattern.AddColorStop (1, TextEditor.ColorStyle.SearchTextMainBg); cr.Pattern = pattern; cr.FillPreserve (); } cr.Color = darkColor; cr.Stroke (); }
protected void FillGradient (Cairo.Context cr, Cairo.Color color1, Cairo.Color color2, double x, double y, double size) { using (var pat = new Cairo.LinearGradient (x + size / 4, y, x + size / 2, y + size - 4)) { pat.AddColorStop (0, color1); pat.AddColorStop (1, color2); cr.Pattern = pat; cr.FillPreserve (); } }
QuickTaskSeverity DrawQuickTasks (Cairo.Context cr) { QuickTaskSeverity severity = QuickTaskSeverity.None; int h = Allocation.Height - Allocation.Width - 6; foreach (var task in AllTasks) { double y = h * TextEditor.LineToY (task.Location.Line) / Math.Max (TextEditor.EditorLineThreshold * TextEditor.LineHeight + TextEditor.GetTextEditorData ().TotalHeight, TextEditor.Allocation.Height); var color = (HslColor)GetBarColor (task.Severity); cr.Color = color; cr.Rectangle (3, y - 1, Allocation.Width - 5, 4); cr.FillPreserve (); color.L *= 0.7; cr.Color = color; cr.Rectangle (3, y - 1, Allocation.Width - 5, 4); cr.Stroke (); switch (task.Severity) { case QuickTaskSeverity.Error: severity = QuickTaskSeverity.Error; break; case QuickTaskSeverity.Warning: if (severity == QuickTaskSeverity.None) severity = QuickTaskSeverity.Warning; break; } } return severity; }
protected virtual void DrawBackground (Cairo.Context context, Gdk.Rectangle region) { LayoutRoundedRectangle (context, region); context.ClipPreserve (); using (LinearGradient lg = new LinearGradient (region.X, region.Y, region.X, region.Y + region.Height)) { lg.AddColorStop (0, Styles.StatusBarFill1Color); lg.AddColorStop (1, Styles.StatusBarFill4Color); context.Pattern = lg; context.FillPreserve (); } context.Save (); double midX = region.X + region.Width / 2.0; double midY = region.Y + region.Height; context.Translate (midX, midY); using (RadialGradient rg = new RadialGradient (0, 0, 0, 0, 0, region.Height * 1.2)) { rg.AddColorStop (0, Styles.StatusBarFill1Color); rg.AddColorStop (1, Styles.WithAlpha (Styles.StatusBarFill1Color, 0)); context.Scale (region.Width / (double)region.Height, 1.0); context.Pattern = rg; context.Fill (); } context.Restore (); using (LinearGradient lg = new LinearGradient (0, region.Y, 0, region.Y + region.Height)) { lg.AddColorStop (0, Styles.StatusBarShadowColor1); lg.AddColorStop (1, Styles.WithAlpha (Styles.StatusBarShadowColor1, Styles.StatusBarShadowColor1.A * 0.2)); LayoutRoundedRectangle (context, region, 0, -1); context.LineWidth = 1; context.Pattern = lg; context.Stroke (); } using (LinearGradient lg = new LinearGradient (0, region.Y, 0, region.Y + region.Height)) { lg.AddColorStop (0, Styles.StatusBarShadowColor2); lg.AddColorStop (1, Styles.WithAlpha (Styles.StatusBarShadowColor2, Styles.StatusBarShadowColor2.A * 0.2)); LayoutRoundedRectangle (context, region, 0, -2); context.LineWidth = 1; context.Pattern = lg; context.Stroke (); } context.ResetClip (); }
void DrawSearchResults (Cairo.Context cr) { int h = Allocation.Height - Allocation.Width - 6; foreach (var region in TextEditor.TextViewMargin.SearchResults) { int line = TextEditor.OffsetToLineNumber (region.Offset); double y = h * TextEditor.LineToY (line) / Math.Max (TextEditor.EditorLineThreshold * TextEditor.LineHeight + TextEditor.GetTextEditorData ().TotalHeight, TextEditor.Allocation.Height); bool isMainSelection = false; if (TextEditor.TextViewMargin.MainSearchResult != null) isMainSelection = region.Offset == TextEditor.TextViewMargin.MainSearchResult.Offset; var color = (HslColor)(isMainSelection ? TextEditor.ColorStyle.SearchTextMainBg : TextEditor.ColorStyle.SearchTextBg); cr.Color = color; cr.Rectangle (3, y - 1, Allocation.Width - 5, 4); cr.FillPreserve (); color.L *= 0.7; cr.Color = color; cr.Rectangle (3, y - 1, Allocation.Width - 5, 4); cr.Stroke (); } }
void DrawIndicator (Cairo.Context cr, Cairo.Color color, Cairo.Color borderColor) { var width = Allocation.Width; int diameter = Math.Min (width, (int)IndicatorHeight) - indicatorPadding * 2; var x1 = Math.Round (width / 2d); double y1 = indicatorPadding + diameter / 2; if (diameter % 2 == 0) { x1 += 0.5; y1 += 0.5; } cr.Arc (x1, y1, diameter / 2d, 0, 2 * Math.PI); if (Platform.IsWindows) { using (var pattern = new Cairo.SolidPattern (color)) { cr.SetSource (pattern); cr.FillPreserve (); } } else { using (var pattern = new Cairo.RadialGradient (x1, y1, width / 2, x1 - width, y1 - width, width)) { pattern.AddColorStop (0, borderColor); pattern.AddColorStop (1, color); cr.SetSource (pattern); cr.FillPreserve (); } } cr.SetSourceColor (borderColor); cr.Stroke (); }
public void Draw(Cairo.Context g, double scale, bool fillSelection) { g.Save (); g.Translate (0.5, 0.5); g.Scale (scale, scale); g.AppendPath (selection_path); if (fillSelection) { g.Color = new Cairo.Color (0.7, 0.8, 0.9, 0.2); g.FillRule = Cairo.FillRule.EvenOdd; g.FillPreserve (); } g.LineWidth = 1 / scale; // Draw a white line first so it shows up on dark backgrounds g.Color = new Cairo.Color (1, 1, 1); g.StrokePreserve (); // Draw a black dashed line over the white line g.SetDash (new double[] { 2 / scale, 4 / scale }, 0); g.Color = new Cairo.Color (0, 0, 0); g.Stroke (); g.Restore (); }