本文整理汇总了C#中Gdk.GC.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# GC.Dispose方法的具体用法?C# GC.Dispose怎么用?C# GC.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdk.GC
的用法示例。
在下文中一共展示了GC.Dispose方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDrawVolumeExposeEvent
protected void OnDrawVolumeExposeEvent(object o, Gtk.ExposeEventArgs args)
{
Gdk.Color back = Style.Background(StateType.Normal);
Gdk.Color fore = Style.Foreground(StateType.Normal);
Drawable draw = args.Event.Window;
int width;
int height;
draw.GetSize(out width, out height);
Gdk.GC gc = new Gdk.GC(draw);
gc.Foreground = back;
gc.Background = back;
draw.DrawRectangle(gc, true, 0, 0, width, height);
//Color lightSlateGray = new Color(119,136,153);
//gc.Colormap.AllocColor(ref lightSlateGray, false, true);
int outside = height * 8 / 10;
int middle = height * 6 / 10;
int inside = height * 4 / 10;
int startOut = 24;
int startMiddle = 30;
int startInside = 36;
int endOut = width - 24;
int endMiddle = width - 30;
int endInside = width - 36;
gc.Foreground = fore;
gc.Foreground = fore;
gc.SetLineAttributes(outside, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
draw.DrawLine(gc, startOut, height / 2, endOut, height / 2);
gc.Foreground = back;
gc.Background = back;
gc.SetLineAttributes(middle, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
draw.DrawLine(gc, startMiddle, height / 2, endMiddle, height / 2);
int endX = (endInside - startInside) * Percentage / 100 + startInside;
gc.Foreground = fore;
gc.Foreground = fore;
gc.SetLineAttributes(inside, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
draw.DrawLine(gc, startInside, height / 2, endX, height / 2);
gc.Dispose();
}
示例2: Draw
public void Draw(Drawable draw, Gdk.Color back)
{
Gdk.GC gc = new Gdk.GC(draw);
try {
int width;
int height;
draw.GetSize(out width, out height);
int xPoint = (width * Volume) / 100;
int yTop = height * Volume / 100;
List<Point> points = new List<Point>();
points.Add(new Point(0,0));
points.Add(new Point(xPoint, yTop));
points.Add(new Point(xPoint, height));
points.Add(new Point(0,height));
points.Add(new Point(0,0));
gc.Foreground = back;
gc.Background = back;
draw.DrawPolygon(gc, true, points.ToArray());
draw.DrawRectangle(gc, true, xPoint, 0, width, height);
points.Clear();
points.Add(new Point(0,0));
points.Add(new Point(xPoint, yTop));
points.Add(new Point(xPoint, 0));
points.Add(new Point(0,0));
gc.Foreground = new Gdk.Color(0,128,0);
gc.Background = new Gdk.Color(0,128,0);
draw.DrawPolygon(gc, true, points.ToArray());
} catch (Exception ex) {
Console.WriteLine(ex.Source);
Console.WriteLine(ex.StackTrace);
}
gc.Dispose();
}
示例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);
if (DrawLeft) {
cell_area.Width += cell_area.X - leftSpace;
cell_area.X = leftSpace;
}
var treeview = widget as FileTreeView;
var p = treeview != null? treeview.CursorLocation : null;
cell_area.Width -= RightPadding;
window.DrawRectangle (widget.Style.BaseGC (Gtk.StateType.Normal), true, cell_area.X, cell_area.Y, cell_area.Width - 1, cell_area.Height);
Gdk.GC normalGC = widget.Style.TextGC (StateType.Normal);
Gdk.GC removedGC = new Gdk.GC (window);
removedGC.Copy (normalGC);
removedGC.RgbFgColor = baseRemoveColor.AddLight (-0.3);
Gdk.GC addedGC = new Gdk.GC (window);
addedGC.Copy (normalGC);
addedGC.RgbFgColor = baseAddColor.AddLight (-0.3);
Gdk.GC infoGC = new Gdk.GC (window);
infoGC.Copy (normalGC);
infoGC.RgbFgColor = widget.Style.Text (StateType.Normal).AddLight (0.2);
Cairo.Context ctx = CairoHelper.Create (window);
Gdk.Color bgColor = new Gdk.Color (0,0,0);
// Rendering is done in two steps:
// 1) Get a list of blocks to render
// 2) render the blocks
int y = cell_area.Y + 2;
// cline keeps track of the current source code line (the one to jump to when double clicking)
int cline = 1;
bool inHeader = true;
BlockInfo currentBlock = null;
List<BlockInfo> blocks = new List<BlockInfo> ();
for (int n=0; n<lines.Length; n++, y += lineHeight) {
string line = lines [n];
if (line.Length == 0) {
currentBlock = null;
y -= lineHeight;
continue;
}
char tag = line [0];
if (line.StartsWith ("---") || line.StartsWith ("+++")) {
// Ignore this part of the header.
currentBlock = null;
y -= lineHeight;
continue;
}
if (tag == '@') {
int l = ParseCurrentLine (line);
if (l != -1) cline = l - 1;
inHeader = false;
} else if (tag != '-' && !inHeader)
cline++;
BlockType type;
bool hasBg = false;
switch (tag) {
case '-': type = BlockType.Removed; break;
case '+': type = BlockType.Added; break;
case '@': type = BlockType.Info; break;
default: type = BlockType.Unchanged; break;
}
if (currentBlock == null || type != currentBlock.Type) {
if (y > maxy)
break;
// Starting a new block. Mark section ends between a change block and a normal code block
if (currentBlock != null && IsChangeBlock (currentBlock.Type) && !IsChangeBlock (type))
currentBlock.SectionEnd = true;
currentBlock = new BlockInfo () {
YStart = y,
FirstLine = n,
Type = type,
SourceLineStart = cline,
SectionStart = (blocks.Count == 0 || !IsChangeBlock (blocks[blocks.Count - 1].Type)) && IsChangeBlock (type)
};
//.........这里部分代码省略.........
示例4: OnExposeEvent
protected override bool OnExposeEvent (Gdk.EventExpose args)
{
Gdk.Window window = args.Window;
var alloc = Allocation;
int width = alloc.Width;
int height = alloc.Height;
int lineWidth = width - margin * 2;
int xpos = margin + padding;
int yPos = margin;
if (PreviewCompletionString) {
layout.SetText (
string.IsNullOrEmpty (CompletionString) ? MonoDevelop.Core.GettextCatalog.GetString ("Select template") : CompletionString
);
int wi, he;
layout.GetPixelSize (out wi, out he);
window.DrawRectangle (this.Style.BaseGC (StateType.Insensitive), true, margin, yPos, lineWidth, he + padding);
window.DrawLayout (
string.IsNullOrEmpty (CompletionString) ? this.Style.TextGC (StateType.Insensitive) : this.Style.TextGC (StateType.Normal),
xpos,
yPos,
layout
);
yPos += rowHeight;
}
//when there are no matches, display a message to indicate that the completion list is still handling input
if (filteredItems.Count == 0) {
Gdk.GC gc = new Gdk.GC (window);
gc.RgbFgColor = new Gdk.Color (0xff, 0xbc, 0xc1);
window.DrawRectangle (gc, true, 0, yPos, width, height - yPos);
layout.SetText (win.DataProvider.ItemCount == 0 ? NoSuggestionsMsg : NoMatchesMsg);
int lWidth, lHeight;
layout.GetPixelSize (out lWidth, out lHeight);
gc.RgbFgColor = new Gdk.Color (0, 0, 0);
window.DrawLayout (gc, (width - lWidth) / 2, yPos + (height - lHeight - yPos) / 2, layout);
gc.Dispose ();
return true;
}
var textGCInsensitive = this.Style.TextGC (StateType.Insensitive);
var textGCNormal = this.Style.TextGC (StateType.Normal);
var fgGCNormal = this.Style.ForegroundGC (StateType.Normal);
var matcher = CompletionMatcher.CreateCompletionMatcher (CompletionString);
var highlightColor = HighlightColor;
Iterate (true, ref yPos, delegate (Category category, int ypos) {
if (ypos >= height - margin)
return;
// window.DrawRectangle (this.Style.BackgroundGC (StateType.Insensitive), true, 0, yPos, width, rowHeight);
int x = 2;
if (!string.IsNullOrEmpty (category.CompletionCategory.Icon)) {
var icon = ImageService.GetPixbuf (category.CompletionCategory.Icon, IconSize.Menu);
window.DrawPixbuf (fgGCNormal, icon, 0, 0, margin, ypos, icon.Width, icon.Height, Gdk.RgbDither.None, 0, 0);
x = icon.Width + 4;
}
layout.SetMarkup ("<span weight='bold'>" + category.CompletionCategory.DisplayText + "</span>");
window.DrawLayout (textGCInsensitive, x, ypos, layout);
layout.SetMarkup ("");
}, delegate (Category curCategory, int item, int itemidx, int ypos) {
if (ypos >= height - margin)
return false;
if (InCategoryMode && curCategory != null && curCategory.CompletionCategory != null) {
xpos = margin + padding + 8;
} else {
xpos = margin + padding;
}
string markup = win.DataProvider.HasMarkup (item) ? (win.DataProvider.GetMarkup (item) ?? "<null>") : GLib.Markup.EscapeText (win.DataProvider.GetText (item) ?? "<null>");
string description = win.DataProvider.GetDescription (item);
if (string.IsNullOrEmpty (description)) {
layout.SetMarkup (markup);
} else {
if (item == SelectedItem) {
layout.SetMarkup (markup + " " + description );
} else {
layout.SetMarkup (markup + " <span foreground=\"darkgray\">" + description + "</span>");
}
}
int mw, mh;
layout.GetPixelSize (out mw, out mh);
if (mw > listWidth) {
WidthRequest = listWidth = mw;
win.WidthRequest = win.Allocation.Width + mw - width;
win.QueueResize ();
}
string text = win.DataProvider.GetText (item);
if ((!SelectionEnabled || item != SelectedItem) && !string.IsNullOrEmpty (text)) {
int[] matchIndices = matcher.GetMatch (text);
if (matchIndices != null) {
Pango.AttrList attrList = layout.Attributes ?? new Pango.AttrList ();
for (int newSelection = 0; newSelection < matchIndices.Length; newSelection++) {
int idx = matchIndices[newSelection];
Pango.AttrForeground fg = new Pango.AttrForeground (highlightColor.Red, highlightColor.Green, highlightColor.Blue);
fg.StartIndex = (uint)idx;
fg.EndIndex = (uint)(idx + 1);
//.........这里部分代码省略.........
示例5: 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);
}
}
示例6: 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);
}
}
示例7: OnExposeEvent
protected override bool OnExposeEvent (Gdk.EventExpose args)
{
using (var context = Gdk.CairoHelper.Create (args.Window)) {
context.LineWidth = 1;
Gdk.Window window = args.Window;
var alloc = Allocation;
int width = alloc.Width;
int height = alloc.Height;
context.Rectangle (args.Area.X, args.Area.Y, args.Area.Width, args.Area.Height);
context.Color = this.backgroundColor;
context.Fill ();
int xpos = iconTextSpacing;
int yPos = (int)-vadj.Value;
//when there are no matches, display a message to indicate that the completion list is still handling input
if (filteredItems.Count == 0) {
Gdk.GC gc = new Gdk.GC (window);
gc.RgbFgColor = backgroundColor.ToGdkColor ();
window.DrawRectangle (gc, true, 0, yPos, width, height - yPos);
noMatchLayout.SetText (win.DataProvider.ItemCount == 0 ? NoSuggestionsMsg : NoMatchesMsg);
int lWidth, lHeight;
noMatchLayout.GetPixelSize (out lWidth, out lHeight);
gc.RgbFgColor = (Mono.TextEditor.HslColor)textColor;
window.DrawLayout (gc, (width - lWidth) / 2, yPos + (height - lHeight - yPos) / 2 - lHeight, noMatchLayout);
gc.Dispose ();
return false;
}
var textGCNormal = new Gdk.GC (window);
textGCNormal.RgbFgColor = (Mono.TextEditor.HslColor)textColor;
var fgGCNormal = this.Style.ForegroundGC (StateType.Normal);
var matcher = CompletionMatcher.CreateCompletionMatcher (CompletionString);
Iterate (true, ref yPos, delegate (Category category, int ypos) {
if (ypos >= height)
return;
if (ypos < -rowHeight)
return;
// window.DrawRectangle (this.Style.BackgroundGC (StateType.Insensitive), true, 0, yPos, width, rowHeight);
int x = 2;
if (category.CompletionCategory != null && !string.IsNullOrEmpty (category.CompletionCategory.Icon)) {
var icon = ImageService.GetPixbuf (category.CompletionCategory.Icon, IconSize.Menu);
window.DrawPixbuf (fgGCNormal, icon, 0, 0, 0, ypos, icon.Width, icon.Height, Gdk.RgbDither.None, 0, 0);
x = icon.Width + 4;
}
context.Rectangle (0, ypos, Allocation.Width, rowHeight);
context.Color = backgroundColor;
context.Fill ();
// layout.SetMarkup ("<span weight='bold' foreground='#AAAAAA'>" + (category.CompletionCategory != null ? category.CompletionCategory.DisplayText : "Uncategorized") + "</span>");
// window.DrawLayout (textGCInsensitive, x - 1, ypos + 1 + (rowHeight - py) / 2, layout);
// layout.SetMarkup ("<span weight='bold'>" + (category.CompletionCategory != null ? category.CompletionCategory.DisplayText : "Uncategorized") + "</span>");
categoryLayout.SetMarkup ((category.CompletionCategory != null ? category.CompletionCategory.DisplayText : "Uncategorized"));
int px, py;
categoryLayout.GetPixelSize (out px, out py);
window.DrawLayout (textGCNormal, x, ypos + (rowHeight - py) / 2, categoryLayout);
}, delegate (Category curCategory, int item, int itemidx, int ypos) {
if (ypos >= height)
return false;
if (ypos < -rowHeight)
return true;
const int categoryModeItemIndenting = 0;
if (InCategoryMode && curCategory != null && curCategory.CompletionCategory != null) {
xpos = iconTextSpacing + categoryModeItemIndenting;
} else {
xpos = iconTextSpacing;
}
string markup = win.DataProvider.HasMarkup (item) ? (win.DataProvider.GetMarkup (item) ?? "<null>") : GLib.Markup.EscapeText (win.DataProvider.GetText (item) ?? "<null>");
string description = win.DataProvider.GetDescription (item);
if (string.IsNullOrEmpty (description)) {
layout.SetMarkup (markup);
} else {
if (item == SelectedItem) {
layout.SetMarkup (markup + " " + description);
} else {
layout.SetMarkup (markup + " <span foreground=\"darkgray\">" + description + "</span>");
}
}
string text = win.DataProvider.GetText (item);
if (!string.IsNullOrEmpty (text)) {
int[] matchIndices = matcher.GetMatch (text);
if (matchIndices != null) {
Pango.AttrList attrList = layout.Attributes ?? new Pango.AttrList ();
for (int newSelection = 0; newSelection < matchIndices.Length; newSelection++) {
int idx = matchIndices [newSelection];
var fg = new AttrForeground ((ushort)(highlightColor.R * ushort.MaxValue), (ushort)(highlightColor.G * ushort.MaxValue), (ushort)(highlightColor.B * ushort.MaxValue));
fg.StartIndex = (uint)idx;
fg.EndIndex = (uint)(idx + 1);
attrList.Insert (fg);
}
layout.Attributes = attrList;
}
}
//.........这里部分代码省略.........
示例8: OnTableTabsExposeEvent
protected void OnTableTabsExposeEvent (object o, ExposeEventArgs args) {
Color fore = Style.Foreground(StateType.Normal);
Drawable draw = args.Event.Window;
Gdk.GC gc = new Gdk.GC(draw);
try {
Rectangle tabRect;
switch (notebook.CurrentPage) {
case 0: // WiFi
tabRect = imageTabWiFi.Allocation;
break;
case 1: // Clock
tabRect = imageTabClock.Allocation;
break;
case 2: // Radio
tabRect = imageTabRadio.Allocation;
break;
case 3: // weather
tabRect = imageTabWeather.Allocation;
break;
default:
tabRect = imageTabIntercom.Allocation;
break;
}
Rectangle rect = notebook.Allocation;
rect.Inflate(4, 4);
tabRect.Inflate(4, 4);
List<Gdk.Point> points = new List<Gdk.Point>();
points.Add(new Point(rect.Left, rect.Top));
points.Add(new Point(rect.Right, rect.Top));
points.Add(new Point(rect.Right, tabRect.Top));
points.Add(new Point(tabRect.Right, tabRect.Top));
points.Add(new Point(tabRect.Right, tabRect.Bottom));
points.Add(new Point(rect.Right, tabRect.Bottom));
points.Add(new Point(rect.Right, rect.Bottom));
points.Add(new Point(rect.Left, rect.Bottom));
points.Add(new Point(rect.Left, rect.Top));
gc.Foreground = fore;
gc.Background = fore;
gc.SetLineAttributes(4, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
draw.DrawLines(gc, points.ToArray());
} catch (Exception ex) {
Console.WriteLine(ex.Source);
Console.WriteLine(ex.StackTrace);
}
gc.Dispose();
}
示例9: OnCtlDrawingMetaExposeEvent
protected void OnCtlDrawingMetaExposeEvent (object o, ExposeEventArgs args) {
Gdk.Color back = ctlDrawingMeta.Style.Background(StateType.Normal);
Gdk.Color fore = ctlDrawingMeta.Style.Foreground(StateType.Normal);
Drawable draw = ctlDrawingMeta.GdkWindow;
Gdk.GC gc = new Gdk.GC(draw);
try {
gc.Foreground = back;
gc.Background = back;
int width;
int height;
draw.GetSize(out width, out height);
draw.DrawRectangle(gc, true, 0, 0, width, height);
gc.Foreground = fore;
String stationName = "No station";
if (station != null) {
stationName = station.CallLetters + "\n" + station.Location;
}
String text = stationName + "\n" +
artist + "\n" +
song;
Pango.FontDescription font = Pango.FontDescription.FromString("Serif 14");
Pango.Layout layout = ctlDrawingMeta.CreatePangoLayout(text);
layout.FontDescription = font;
layout.Width = Pango.Units.FromPixels(width);
draw.DrawLayoutWithColors(gc, 0, 0, layout, fore, back);
layout.Dispose();
} catch (Exception ex) {
Console.WriteLine(ex.Source);
Console.WriteLine(ex.StackTrace);
}
gc.Dispose();
}
示例10: OnDrawWiFiExposeEvent
protected void OnDrawWiFiExposeEvent (object o, ExposeEventArgs args) {
Gdk.Color back = drawWiFi.Style.Background(StateType.Normal);
Gdk.Color fore = drawWiFi.Style.Foreground(StateType.Normal);
Drawable draw = drawWiFi.GdkWindow;
Gdk.GC gc = new Gdk.GC(draw);
try {
gc.Foreground = back;
gc.Background = back;
int width;
int height;
draw.GetSize(out width, out height);
draw.DrawRectangle(gc, true, 0, 0, width, height);
gc.Foreground = fore;
lastNoise = recognizer.Noise;
lastRecognized = recognizer.TimeRecognized.ToShortTimeString() + ": " + recognizer.KeywordRecognized;
lastBuffer = recognizer.BufferSize;
lastStatus = status;
String text = "IP: " + ipAddress + "\n" +
"Status: " + lastStatus + "\n" +
"Recognized: " + lastRecognized + "\n" +
"Buffer: " + lastBuffer + "\n" +
"Noise: " + lastNoise + "\n" +
"Active Alarm: " + activeAlarm + "\n" +
"Next Alarm: " + nextAlarm + "\n";
if (activeConnection == null) {
text += "WiFi: Not connected\n";
} else {
text += "WiFi: " + activeConnection.ESSID + "\n";
text += "BSSID: " + activeConnection.BSSID + "\n";
text += "Channel: " + activeConnection.Channel + "\n";
text += "Signal: " + activeConnection.Signal + "\n";
text += "Encryption: " + activeConnection.Encryption + "\n";
}
Pango.FontDescription font = Pango.FontDescription.FromString("Serif 10");
Pango.Layout layout = drawWiFi.CreatePangoLayout(text);
layout.FontDescription = font;
layout.Width = Pango.Units.FromPixels(width);
draw.DrawLayoutWithColors(gc, 0, 0, layout, fore, back);
layout.Dispose();
} catch (Exception ex) {
Console.WriteLine(ex.Source);
Console.WriteLine(ex.StackTrace);
}
gc.Dispose();
}
示例11: OnDrawClockExposeEvent
protected void OnDrawClockExposeEvent(object o, Gtk.ExposeEventArgs args)
{
Gdk.Color back = Style.Background(StateType.Normal);
Gdk.Color fore = Style.Foreground(StateType.Normal);
Drawable draw = args.Event.Window;
int width;
int height;
draw.GetSize(out width, out height);
Gdk.GC gc = new Gdk.GC(draw);
gc.Foreground = back;
gc.Background = back;
Point start;
Point stop;
double xMax;
double yMax;
double angle = 0;
int size = width < height ? width : height;
size -= Spacing;
Point center = new Point(width / 2, height / 2);
Rectangle rect = new Rectangle((width - size) / 2, (height - size) / 2, size, size);
if (clockFace != null && (clockFace.Width != width || clockFace.Height != height)) {
clockFace.Dispose();
clockFace = null;
}
if (clockFace == null) {
draw.DrawPixbuf(gc, clockFace, 0, 0, 0, 0, width, height, RgbDither.None, 0, 0);
draw.DrawRectangle(gc, true, 0, 0, width, height);
gc.Foreground = fore;
gc.SetLineAttributes(4, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
draw.DrawArc(gc, false, rect.Left, rect.Top, size, size, 0, 360 * 64);
gc.SetLineAttributes(1, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
for (int index = 0; index < 60; index++, angle += Math.PI / 30.0) {
xMax = Math.Cos(angle) * size / 2;
yMax = Math.Sin(angle) * size / 2;
start = center;
stop = center;
if ((index % 5) == 0) {
int hour = ((index / 5) + 3) % 12;
if (hour == 0) hour = 12;
start.Offset((int)(xMax / 1.30), (int)(yMax / 1.30));
Pango.FontDescription font = Pango.FontDescription.FromString("Serif 10");
Pango.Layout layout = CreatePangoLayout(hour.ToString());
layout.FontDescription = font;
layout.Width = Pango.Units.FromPixels(100);
int textWidth;
int textHeight;
layout.GetPixelSize(out textWidth, out textHeight);
start.Offset(-textWidth / 2, -textHeight / 2);
draw.DrawLayoutWithColors(gc, start.X, start.Y, layout, fore, back);
layout.Dispose();
start = center;
gc.SetLineAttributes(4, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
start.Offset((int)(xMax / 1.05), (int)(yMax / 1.05));
stop.Offset((int)xMax, (int)yMax);
draw.DrawLine(gc, start.X, start.Y, stop.X, stop.Y);
gc.SetLineAttributes(1, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
} else {
start.Offset((int)(xMax / 1.05), (int)(yMax / 1.05));
stop.Offset((int)xMax, (int)yMax);
draw.DrawLine(gc, start.X, start.Y, stop.X, stop.Y);
}
}
clockFace = Pixbuf.FromDrawable(draw, draw.Colormap, 0, 0, 0, 0, width, height);
} else {
draw.DrawPixbuf(gc, clockFace, 0, 0, 0, 0, width, height, RgbDither.None, 0, 0);
}
gc.Foreground = fore;
double startAngle = 1.5 * Math.PI;
double secondAngle;
double minuteAngle;
double hourAngle;
if (AnalogMovement) {
double value = (CurrentTime.Second * 1000) + CurrentTime.Millisecond;
double divisor = 60000.0;
secondAngle = 2.0 * Math.PI * value / divisor + startAngle;
//.........这里部分代码省略.........
示例12: OnDrawWeatherExposeEvent
protected void OnDrawWeatherExposeEvent(object o, ExposeEventArgs args)
{
Gdk.Color back = Style.Background(StateType.Normal);
Gdk.Color fore = Style.Foreground(StateType.Normal);
Drawable draw = drawWeather.GdkWindow;
Gdk.GC gc = new Gdk.GC(draw);
try {
gc.Foreground = back;
gc.Background = back;
int width;
int height;
draw.GetSize(out width, out height);
draw.DrawRectangle(gc, true, 0, 0, width, height);
gc.Foreground = fore;
String text = "";
if (Weather.Forecasts.Count > SelectedForecast) {
WeatherService.WeatherPeriod info = Weather.Forecasts[SelectedForecast];
text = info.Title + " - " + info.Forecast + "\n";
}
Pango.FontDescription font = Pango.FontDescription.FromString("Serif 14");
Pango.Layout layout = drawWeather.CreatePangoLayout(text);
layout.FontDescription = font;
layout.Width = Pango.Units.FromPixels(width);
draw.DrawLayoutWithColors(gc, 0, 0, layout, fore, back);
layout.Dispose();
} catch (Exception ex) {
Console.WriteLine(ex.Source);
Console.WriteLine(ex.StackTrace);
}
gc.Dispose();
}
示例13: OnTableWeatherExposeEvent
protected void OnTableWeatherExposeEvent(object o, ExposeEventArgs args)
{
Color fore = Style.Foreground(StateType.Normal);
Drawable draw = args.Event.Window;
Gdk.GC gc = new Gdk.GC(draw);
Rectangle rect;
switch (SelectedForecast) {
case 0:
rect = imageMorning1.Allocation;
break;
case 1:
rect = imageDay1.Allocation;
break;
case 2:
rect = imageMorning2.Allocation;
break;
case 3:
rect = imageDay2.Allocation;
break;
case 4:
rect = imageMorning3.Allocation;
break;
case 5:
rect = imageDay3.Allocation;
break;
case 6:
rect = imageMorning4.Allocation;
break;
default:
rect = imageDay4.Allocation;
break;
}
gc.Foreground = fore;
gc.Background = fore;
gc.SetLineAttributes(4, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);
draw.DrawRectangle(gc, false, rect);
gc.Dispose();
}
示例14: OnExposeEvent
protected override bool OnExposeEvent(Gdk.EventExpose ev)
{
base.OnExposeEvent(ev);
// Insert drawing code here.
var window = ev.Window;
var gc = new Gdk.GC(window);
// window.DrawRectangle(gc, true, new Rectangle(0, 0, 100, 100));
int width = this.DrawingWidth;
int height = this.DrawingHeight;
CheckerPattern.Draw(window, gc, 10, width, height);
DrawImage(window, gc);
DrawIslands(window, gc);
m_linkIslandsHelper.Step4_Draw(window, gc);
gc.Dispose();
return true;
}