本文整理汇总了C#中Cairo.Context.RoundedRectangle方法的典型用法代码示例。如果您正苦于以下问题:C# Context.RoundedRectangle方法的具体用法?C# Context.RoundedRectangle怎么用?C# Context.RoundedRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo.Context
的用法示例。
在下文中一共展示了Context.RoundedRectangle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public override void Render(Node node, Context context)
{
ButtonNode button = node as ButtonNode;
context.RoundedRectangle (0.5, 0.5, button.Width - 1, button.Height - 1, button.Rounding);
if (button.Relief) {
using (var lg = new global::Cairo.LinearGradient (0, 0, 0, button.Height)) {
CreateGradient (lg, button.State, button.Opacity);
context.Pattern = lg;
context.FillPreserve ();
}
context.LineWidth = 1;
context.Color = new Color (0.8, 0.8, 0.8, button.Opacity).ToCairo ();
context.Stroke ();
}
}
示例2: DrawBackground
public override void DrawBackground (Mono.TextEditor.MonoTextEditor editor, Context cr, LineMetrics metrics, int startOffset, int endOffset)
{
int markerStart = usage.Offset;
int markerEnd = usage.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) {
Mono.TextEditor.Highlighting.AmbientColor colorStyle;
if ((usage.UsageType & ReferenceUsageType.Write) == ReferenceUsageType.Write ||
(usage.UsageType & ReferenceUsageType.Declariton) == ReferenceUsageType.Declariton) {
colorStyle = editor.ColorStyle.ChangingUsagesRectangle;
} else {
colorStyle = editor.ColorStyle.UsagesRectangle;
}
using (var lg = new LinearGradient (@from + 1, y + 1, to , y + editor.LineHeight)) {
lg.AddColorStop (0, colorStyle.Color);
lg.AddColorStop (1, colorStyle.SecondColor);
cr.SetSource (lg);
cr.RoundedRectangle (@from + 0.5, y + 1.5, to - @from - 1, editor.LineHeight - 2, editor.LineHeight / 4);
cr.FillPreserve ();
}
cr.SetSourceColor (colorStyle.BorderColor);
cr.Stroke ();
}
}
示例3: ClipChildren
public override void ClipChildren(Node node, Context context)
{
ButtonNode button = node as ButtonNode;
context.RoundedRectangle (0.5, 0.5, button.Width - 1, button.Height - 1, button.Rounding);
context.Clip ();
}