本文整理汇总了C#中Drawable.DrawLayout方法的典型用法代码示例。如果您正苦于以下问题:C# Drawable.DrawLayout方法的具体用法?C# Drawable.DrawLayout怎么用?C# Drawable.DrawLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drawable
的用法示例。
在下文中一共展示了Drawable.DrawLayout方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
protected override void Render (Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
{
try{
Gdk.Rectangle text_area1 = new Gdk.Rectangle();
Gdk.Rectangle text_area2 = new Gdk.Rectangle();
Gdk.Rectangle text_area3 = new Gdk.Rectangle();
text_area1.Y= cell_area.Y;
text_area2.Y= cell_area.Y+33;
text_area3.X = cell_area.Width-20;
text_area3.Y= cell_area.Y+33;
text_area3.Width = 75;
Pango.Layout text_l1 = new Pango.Layout(widget.PangoContext);
text_l1.FontDescription = Pango.FontDescription.FromString ("Meiryo,Arial 10.5");
text_l1.SetText(text1);
Pango.Layout text_l2 = new Pango.Layout(widget.PangoContext);
text_l2.FontDescription = Pango.FontDescription.FromString ("Meiryo,MS Gothic,Arial 8");
text_l2.SetText(text2);
text_l2.Alignment = Pango.Alignment.Right;
Pango.Layout text_l3 = new Pango.Layout(widget.PangoContext);
text_l3.Width = Pango.Units.FromPixels(text_area3.Width);
text_l3.FontDescription = Pango.FontDescription.FromString ("Meiryo,MS Gothic,Arial 8");
text_l3.Alignment = Pango.Alignment.Right;
text_l3.SetText(text3);
text_l2.Width = Pango.Units.FromPixels(cell_area.Width-text_l3.Text.Length*8-13);
StateType state = flags.HasFlag(CellRendererState.Selected) ?
widget.IsFocus ? StateType.Selected : StateType.Active : StateType.Normal;
text_l3.SetMarkup("<span color=" + (char)34 + "grey" + (char)34 + ">" + text_l3.Text + "</span>");;
window.DrawLayout(widget.Style.TextGC(state), 55, text_area1.Y, text_l1);
window.DrawLayout(widget.Style.TextGC(state), 55, text_area2.Y, text_l2);
window.DrawLayout(widget.Style.TextGC(state), text_area3.X, text_area3.Y, text_l3);
text_l1.Dispose ();
text_l2.Dispose ();
text_l3.Dispose ();
}catch(Exception e){
Console.WriteLine (e);
}
}
示例2: Render
//.........这里部分代码省略.........
// Now render the blocks
// The y position of the highlighted line
int selectedLineRowTop = -1;
BlockInfo lastCodeSegmentStart = null;
BlockInfo lastCodeSegmentEnd = null;
foreach (BlockInfo block in blocks)
{
if (block.Type == BlockType.Info) {
// Finished drawing the content of a code segment. Now draw the segment border and label.
if (lastCodeSegmentStart != null)
DrawCodeSegmentBorder (infoGC, ctx, cell_area.X, cell_area.Width, lastCodeSegmentStart, lastCodeSegmentEnd, lines, widget, window);
lastCodeSegmentStart = block;
}
lastCodeSegmentEnd = block;
if (block.YEnd < 0)
continue;
// Draw the block background
DrawBlockBg (ctx, cell_area.X + 1, cell_area.Width - 2, block);
// Get all text for the current block
StringBuilder sb = new StringBuilder ();
for (int n=block.FirstLine; n <= block.LastLine; n++) {
string s = ProcessLine (lines [n]);
if (sb.Length > 0)
sb.Append ('\n');
if (block.Type != BlockType.Info && s.Length > 0)
sb.Append (s, 1, s.Length - 1);
else
sb.Append (s);
}
// Draw a special background for the selected line
if (block.Type != BlockType.Info && p.HasValue && p.Value.X >= cell_area.X && p.Value.X <= cell_area.Right && p.Value.Y >= block.YStart && p.Value.Y <= block.YEnd) {
int row = (p.Value.Y - block.YStart) / lineHeight;
double yrow = block.YStart + lineHeight * row + 0.5;
double xrow = cell_area.X + LeftPaddingBlock + 0.5;
int wrow = cell_area.Width - 1 - LeftPaddingBlock;
if (block.Type == BlockType.Added)
ctx.Color = baseAddColor.AddLight (0.1).ToCairoColor ();
else if (block.Type == BlockType.Removed)
ctx.Color = baseRemoveColor.AddLight (0.1).ToCairoColor ();
else {
ctx.Color = widget.Style.Base (Gtk.StateType.Prelight).AddLight (0.1).ToCairoColor ();
xrow -= LeftPaddingBlock;
wrow += LeftPaddingBlock;
}
ctx.Rectangle (xrow, yrow, wrow, lineHeight);
ctx.Fill ();
selectedLine = block.SourceLineStart + row;
selctedPath = path;
selectedLineRowTop = (int)yrow;
}
// Draw the line text. Ignore header blocks, since they are drawn as labels in DrawCodeSegmentBorder
if (block.Type != BlockType.Info) {
layout.SetMarkup ("");
layout.SetText (sb.ToString ());
Gdk.GC gc;
switch (block.Type) {
case BlockType.Removed: gc = removedGC; break;
case BlockType.Added: gc = addedGC; break;
case BlockType.Info: gc = infoGC; break;
default: gc = normalGC; break;
}
window.DrawLayout (gc, cell_area.X + 2 + LeftPaddingBlock, block.YStart, layout);
}
// Finally draw the change symbol at the left margin
DrawChangeSymbol (ctx, cell_area.X + 1, cell_area.Width - 2, block);
}
// Finish the drawing of the code segment
if (lastCodeSegmentStart != null)
DrawCodeSegmentBorder (infoGC, ctx, cell_area.X, cell_area.Width, lastCodeSegmentStart, lastCodeSegmentEnd, lines, widget, window);
// Draw the source line number at the current selected line. It must be done at the end because it must
// be drawn over the source code text and segment borders.
if (selectedLineRowTop != -1)
DrawLineBox (normalGC, ctx, ((Gtk.TreeView)widget).VisibleRect.Right - 4, selectedLineRowTop, selectedLine, widget, window);
((IDisposable)ctx).Dispose ();
removedGC.Dispose ();
addedGC.Dispose ();
infoGC.Dispose ();
} else {
// Rendering a normal text row
int y = cell_area.Y + (cell_area.Height - height)/2;
window.DrawLayout (widget.Style.TextGC (GetState(flags)), cell_area.X, y, layout);
}
}
示例3: Render
protected override void Render (Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
{
if (isDisposed)
return;
if (diffMode) {
if (path.Equals (selctedPath)) {
selectedLine = -1;
selctedPath = null;
}
int w, maxy;
window.GetSize (out w, out maxy);
var treeview = widget as FileTreeView;
var p = treeview != null? treeview.CursorLocation : null;
int recty = cell_area.Y;
int recth = cell_area.Height - 1;
if (recty < 0) {
recth += recty + 1;
recty = -1;
}
if (recth > maxy + 2)
recth = maxy + 2;
window.DrawRectangle (widget.Style.BaseGC (Gtk.StateType.Normal), true, cell_area.X, recty, cell_area.Width - 1, recth);
Gdk.GC normalGC = widget.Style.TextGC (StateType.Normal);
Gdk.GC removedGC = new Gdk.GC (window);
removedGC.Copy (normalGC);
removedGC.RgbFgColor = new Color (255, 0, 0);
Gdk.GC addedGC = new Gdk.GC (window);
addedGC.Copy (normalGC);
addedGC.RgbFgColor = new Color (0, 0, 255);
Gdk.GC infoGC = new Gdk.GC (window);
infoGC.Copy (normalGC);
infoGC.RgbFgColor = new Color (0xa5, 0x2a, 0x2a);
int y = cell_area.Y + 2;
int cline = 1;
bool inHeader = true;
for (int n=0; n<lines.Length; n++, y += lineHeight) {
string line = lines [n];
if (line.Length == 0)
continue;
char tag = line [0];
// Keep track of the real file line
int thisLine = cline;
if (tag == '@') {
int l = ParseCurrentLine (line);
if (l != -1) cline = thisLine = l;
inHeader = false;
} else if (tag != '-' && !inHeader)
cline++;
if (y + lineHeight < 0)
continue;
if (y > maxy)
break;
Gdk.GC gc;
switch (tag) {
case '-': gc = removedGC; break;
case '+': gc = addedGC; break;
case '@': gc = infoGC; break;
default: gc = normalGC; break;
}
if (p.HasValue && p.Value.X >= cell_area.X && p.Value.X <= cell_area.Right && p.Value.Y >= y && p.Value.Y < y + lineHeight) {
window.DrawRectangle (widget.Style.BaseGC (Gtk.StateType.Prelight), true, cell_area.X, y, cell_area.Width - 1, lineHeight);
selectedLine = thisLine;
selctedPath = path;
}
layout.SetText (line);
window.DrawLayout (gc, cell_area.X + 2, y, layout);
}
window.DrawRectangle (widget.Style.DarkGC (Gtk.StateType.Prelight), false, cell_area.X, recty, cell_area.Width - 1, recth);
removedGC.Dispose ();
addedGC.Dispose ();
infoGC.Dispose ();
} else {
int y = cell_area.Y + (cell_area.Height - height)/2;
window.DrawLayout (widget.Style.TextGC (GetState(flags)), cell_area.X, y, layout);
}
}
示例4: Render
protected override void Render (Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
{
if (isDisposed)
return;
try {
if (diffMode) {
int w, maxy;
window.GetSize (out w, out maxy);
int recty = cell_area.Y;
int recth = cell_area.Height - 1;
if (recty < 0) {
recth += recty + 1;
recty = -1;
}
if (recth > maxy + 2)
recth = maxy + 2;
window.DrawRectangle (widget.Style.BaseGC (Gtk.StateType.Normal), true, cell_area.X, recty, cell_area.Width - 1, recth);
Gdk.GC normalGC = widget.Style.TextGC (StateType.Normal);
Gdk.GC removedGC = new Gdk.GC (window);
removedGC.Copy (normalGC);
removedGC.RgbFgColor = new Color (255, 0, 0);
Gdk.GC addedGC = new Gdk.GC (window);
addedGC.Copy (normalGC);
addedGC.RgbFgColor = new Color (0, 0, 255);
Gdk.GC infoGC = new Gdk.GC (window);
infoGC.Copy (normalGC);
infoGC.RgbFgColor = new Color (0xa5, 0x2a, 0x2a);
int y = cell_area.Y + 2;
for (int n = 0; n < lines.Length; n++,y += lineHeight) {
if (y + lineHeight < 0)
continue;
if (y > maxy)
break;
string line = lines[n];
if (line.Length == 0)
continue;
Gdk.GC gc;
switch (line[0]) {
case '-':
gc = removedGC;
break;
case '+':
gc = addedGC;
break;
case '@':
gc = infoGC;
break;
default:
gc = normalGC;
break;
}
layout.SetText (line);
window.DrawLayout (gc, cell_area.X + 2, y, layout);
}
window.DrawRectangle (widget.Style.DarkGC (Gtk.StateType.Prelight), false, cell_area.X, recty, cell_area.Width - 1, recth);
removedGC.Dispose ();
addedGC.Dispose ();
infoGC.Dispose ();
} else {
int y = cell_area.Y + (cell_area.Height - height) / 2;
window.DrawLayout (widget.Style.TextGC (GetState (flags)), cell_area.X, y, layout);
}
} catch (Exception e) {
Console.WriteLine (e);
}
}
示例5: Render
protected override void Render(Drawable window, Widget widget, Rectangle background_area, Rectangle cell_area, Rectangle expose_area, CellRendererState flags)
{
int width, height;
GetCellSize (widget, (int)(cell_area.Width - this.Xpad * 2), out width, out height);
int x = (int) (cell_area.X + this.Xpad);
int y = cell_area.Y + (cell_area.Height - height) / 2;
StateType state;
if (!sensitive)
state = StateType.Insensitive;
else if ((flags & CellRendererState.Selected) != 0)
state = StateType.Selected;
else
state = StateType.Normal;
if (IsGroup) {
TreeGroup grp = new TreeGroup ();
grp.X = x;
grp.Y = y;
grp.Group = Text;
grp.State = state;
InternalTree tree = (InternalTree) widget;
tree.Groups.Add (grp);
} else {
window.DrawLayout (widget.Style.TextGC (state), x, y, layout);
int bx = background_area.X + background_area.Width - 1;
Gdk.GC gc = new Gdk.GC (window);
gc.RgbFgColor = tree.Style.MidColors [(int)Gtk.StateType.Normal];
window.DrawLine (gc, bx, background_area.Y, bx, background_area.Y + background_area.Height);
}
}
示例6: Render
protected override void Render (Drawable window, Widget widget, Rectangle background_area, Rectangle cell_area, Rectangle expose_area, CellRendererState flags)
{
if (Template == null) {
DrawTemplateCategoryText (window, widget, cell_area, flags);
return;
}
using (var ctx = CairoHelper.Create (window)) {
using (var layout = new Pango.Layout (widget.PangoContext)) {
Rectangle iconRect = DrawIcon (window, widget, cell_area, flags);
if (!Template.AvailableLanguages.Any () || !IsTemplateRowSelected (widget, flags)) {
DrawTemplateNameText (window, widget, cell_area, iconRect, Rectangle.Zero, flags);
return;
}
int textHeight = 0;
int textWidth = 0;
SetMarkup (layout, GetSelectedLanguage ());
layout.GetPixelSize (out textWidth, out textHeight);
double scale = GtkWorkarounds.GetPixelScale ();
languageRect = GetLanguageButtonRectangle (window, widget, cell_area, textHeight, textWidth, scale);
DrawTemplateNameText (window, widget, cell_area, iconRect, languageRect, flags);
RoundBorder (ctx, languageRect.X, languageRect.Y, languageRect.Width, languageRect.Height);
SetSourceColor (ctx, Styles.NewProjectDialog.TemplateLanguageButtonBackground.ToCairoColor ());
ctx.Fill ();
int languageTextX = languageRect.X + GetLanguageLeftHandPadding (scale);
if (!TemplateHasMultipleLanguages ()) {
languageTextX = languageRect.X + (languageRect.Width - textWidth) / 2;
}
int languageTextY = languageRect.Y + (languageRect.Height - textHeight) / 2;
window.DrawLayout (widget.Style.TextGC (StateType.Normal), languageTextX, languageTextY, layout);
if (TemplateHasMultipleLanguages ()) {
int triangleX = languageTextX + textWidth + GetLanguageRightHandPadding (scale);
int triangleY = languageRect.Y + (languageRect.Height - ((int)(scale * dropdownTriangleHeight))) / 2;
DrawTriangle (ctx, triangleX, triangleY, scale);
}
}
}
}
示例7: DrawTemplateNameText
void DrawTemplateNameText (Drawable window, Widget widget, Rectangle cell_area, Rectangle iconRect, Rectangle languageRect, CellRendererState flags)
{
StateType state = GetState (widget, flags);
using (var layout = new Pango.Layout (widget.PangoContext)) {
layout.Ellipsize = Pango.EllipsizeMode.End;
int textPixelWidth = widget.Allocation.Width - ((int)Xpad * 2) - iconRect.Width - iconTextPadding - languageRect.Width;
layout.Width = (int)(textPixelWidth * Pango.Scale.PangoScale);
layout.SetMarkup (GLib.Markup.EscapeText (Template.Name));
int w, h;
layout.GetPixelSize (out w, out h);
int textY = cell_area.Y + (cell_area.Height - h) / 2;
window.DrawLayout (widget.Style.TextGC (state), iconRect.Right + iconTextPadding, textY, layout);
}
}
示例8: DrawTemplateCategoryText
void DrawTemplateCategoryText (Drawable window, Widget widget, Rectangle cell_area, CellRendererState flags)
{
StateType state = GetState (widget, flags);
using (var layout = new Pango.Layout (widget.PangoContext)) {
layout.Ellipsize = Pango.EllipsizeMode.End;
int textPixelWidth = widget.Allocation.Width - ((int)Xpad * 2);
layout.Width = (int)(textPixelWidth * Pango.Scale.PangoScale);
layout.SetMarkup (TemplateCategory);
int w, h;
layout.GetPixelSize (out w, out h);
int textX = cell_area.X + (int)Xpad + categoryTextPaddingX;
int textY = cell_area.Y + (cell_area.Height - h) / 2 + groupTemplateHeadingYOffset;
window.DrawLayout (widget.Style.TextGC (state), textX, textY, layout);
}
}
示例9: Render
public virtual void Render (Drawable window, Gdk.Rectangle bounds, StateType state)
{
int w, h;
layout.GetPixelSize (out w, out h);
int dy = (bounds.Height - h) / 2;
window.DrawLayout (container.Style.TextGC (state), bounds.X, dy + bounds.Y, layout);
}
示例10: DrawText
void DrawText (Drawable window)
{
var alloc = Allocation;
int pos = scrollStartPx - scrolledUpPx;
window.DrawLayout (Style.TextGC (StateType.Normal), 0, pos, layout);
int logoPos = pos + scrollHeightPx - monoPowered.Height / 2 - imageHeight / 2;
window.DrawPixbuf (backGc, monoPowered, 0, 0, (alloc.Width / 2) - (monoPowered.Width / 2),
logoPos, -1, -1, RgbDither.Normal, 0, 0);
}