本文整理汇总了C#中Gdk.GC.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Gdk.GC.Dispose方法的具体用法?C# Gdk.GC.Dispose怎么用?C# Gdk.GC.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdk.GC
的用法示例。
在下文中一共展示了Gdk.GC.Dispose方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnExposeEvent
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
{
base.OnExposeEvent (evnt);
if (Child1 != null && Child1.Visible && Child2 != null && Child2.Visible) {
var gc = new Gdk.GC (evnt.Window);
gc.RgbFgColor = (HslColor) Styles.ThinSplitterColor;
var x = Child1.Allocation.X + Child1.Allocation.Width;
evnt.Window.DrawLine (gc, x, Allocation.Y, x, Allocation.Y + Allocation.Height);
gc.Dispose ();
}
return true;
}
示例2: OnExposeEvent
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
{
Gdk.Rectangle rect;
if (GradientBackround) {
rect = new Gdk.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
HslColor gcol = Style.Background (Gtk.StateType.Normal);
using (Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow)) {
cr.NewPath ();
cr.MoveTo (rect.X, rect.Y);
cr.RelLineTo (rect.Width, 0);
cr.RelLineTo (0, rect.Height);
cr.RelLineTo (-rect.Width, 0);
cr.RelLineTo (0, -rect.Height);
cr.ClosePath ();
Cairo.Gradient pat = new Cairo.LinearGradient (rect.X, rect.Y, rect.X, rect.Bottom);
Cairo.Color color1 = gcol;
pat.AddColorStop (0, color1);
gcol.L -= 0.1;
if (gcol.L < 0) gcol.L = 0;
pat.AddColorStop (1, gcol);
cr.Pattern = pat;
cr.FillPreserve ();
}
} else if (BackgroundColor != null) {
using (Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow)) {
cr.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
cr.Color = BackgroundColor.Value.ToCairoColor ();
cr.Fill ();
}
} else if (useChildBackgroundColor && Child != null) {
using (Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow)) {
cr.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
cr.Color = Child.Style.Base (StateType.Normal).ToCairoColor ();
cr.Fill ();
}
}
bool res = base.OnExposeEvent (evnt);
var borderColor = new Gdk.GC (GdkWindow);
borderColor.RgbFgColor = BorderColor != null ? BorderColor.Value : Style.Dark (Gtk.StateType.Normal);
rect = Allocation;
for (int n=0; n<topMargin; n++)
GdkWindow.DrawLine (borderColor, rect.X, rect.Y + n, rect.Right - 1, rect.Y + n);
for (int n=0; n<bottomMargin; n++)
GdkWindow.DrawLine (borderColor, rect.X, rect.Bottom - n, rect.Right, rect.Bottom - n);
for (int n=0; n<leftMargin; n++)
GdkWindow.DrawLine (borderColor, rect.X + n, rect.Y, rect.X + n, rect.Bottom);
for (int n=0; n<rightMargin; n++)
GdkWindow.DrawLine (borderColor, rect.Right - n, rect.Y, rect.Right - n, rect.Bottom);
if (showTopShadow) {
using (Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow)) {
cr.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, shadowSize);
Cairo.Gradient pat = new Cairo.LinearGradient (rect.X, rect.Y, rect.X, rect.Y + shadowSize);
pat.AddColorStop (0, new Cairo.Color (0, 0, 0, shadowStrengh));
pat.AddColorStop (1, new Cairo.Color (0, 0, 0, 0));
cr.Pattern = pat;
cr.Fill ();
}
}
borderColor.Dispose ();
return res;
}
示例3: OnExposeEvent
protected override bool OnExposeEvent(Gdk.EventExpose evnt)
{
if (VisualStyle.TabStyle == DockTabStyle.Normal) {
Gdk.GC gc = new Gdk.GC (GdkWindow);
gc.RgbFgColor = VisualStyle.PadBackgroundColor.Value;
evnt.Window.DrawRectangle (gc, true, Allocation);
gc.Dispose ();
}
return base.OnExposeEvent (evnt);
}
示例4: DrawAsBrowser
void DrawAsBrowser (Gdk.EventExpose evnt)
{
var alloc = Allocation;
Gdk.GC bgc = new Gdk.GC (GdkWindow);
var c = new HslColor (VisualStyle.PadBackgroundColor.Value);
c.L *= 0.7;
bgc.RgbFgColor = c;
bool first = true;
bool last = true;
TabStrip tabStrip = null;
if (Parent is TabStrip.TabStripBox) {
var tsb = (TabStrip.TabStripBox) Parent;
var cts = tsb.Children;
first = cts[0] == this;
last = cts[cts.Length - 1] == this;
tabStrip = tsb.TabStrip;
}
if (Active || (first && last)) {
Gdk.GC gc = new Gdk.GC (GdkWindow);
gc.RgbFgColor = VisualStyle.PadBackgroundColor.Value;
evnt.Window.DrawRectangle (gc, true, alloc);
if (!first)
evnt.Window.DrawLine (bgc, alloc.X, alloc.Y, alloc.X, alloc.Y + alloc.Height - 1);
if (!(last && first) && !(tabStrip != null && tabStrip.VisualStyle.ExpandedTabs.Value && last))
evnt.Window.DrawLine (bgc, alloc.X + alloc.Width - 1, alloc.Y, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1);
gc.Dispose ();
} else {
Gdk.GC gc = new Gdk.GC (GdkWindow);
gc.RgbFgColor = tabStrip != null ? tabStrip.VisualStyle.InactivePadBackgroundColor.Value : frame.DefaultVisualStyle.InactivePadBackgroundColor.Value;
evnt.Window.DrawRectangle (gc, true, alloc);
gc.Dispose ();
evnt.Window.DrawLine (bgc, alloc.X, alloc.Y + alloc.Height - 1, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1);
}
bgc.Dispose ();
}
示例5: OnExposeEvent
protected override bool OnExposeEvent (Gdk.EventExpose args)
{
using (var g = Gdk.CairoHelper.Create (args.Window)) {
g.Translate (Allocation.X, Allocation.Y);
g.LineWidth = 1;
Gdk.GC gc = new Gdk.GC (args.Window);
layout.SetMarkup (TitleText);
int width, height;
layout.GetPixelSize (out width, out height);
width += xBorder * 2;
FoldingScreenbackgroundRenderer.DrawRoundRectangle (g, true, false, 0.5, 0.5, height + yBorder * 2 + 1.5, width, height + yBorder * 2);
g.SetSourceColor (Styles.TableLayoutModeTitleBackgroundColor.ToCairoColor ());
g.FillPreserve ();
g.SetSourceColor (Styles.TableLayoutModeBorderColor.ToCairoColor ());
g.Stroke ();
g.Save ();
g.SetSourceColor (Styles.TableLayoutModeTextColor.ToCairoColor ());
g.Translate (xBorder, yBorder);
g.ShowLayout (layout);
g.Restore ();
FoldingScreenbackgroundRenderer.DrawRoundRectangle (g, false, true, 0.5, height * 2 + yBorder * 2 + 0.5, height, Allocation.Width - 1, Allocation.Height - height * 2 - yBorder * 2 - 1);
g.SetSourceColor (Styles.TableLayoutModeBackgroundColor.ToCairoColor ());
g.FillPreserve ();
g.SetSourceColor (Styles.TableLayoutModeBorderColor.ToCairoColor ());
g.Stroke ();
g.MoveTo (xSpacer + 0.5, height * 2 + yBorder * 2);
g.LineTo (xSpacer + 0.5, Allocation.Height - 1);
g.SetSourceColor (Styles.TableLayoutModeGridColor.ToCairoColor ());
g.Stroke ();
int y = height + yBorder * 2;
for (int i = 0; i < Items.Count; i++) {
KeyValuePair<string, string> pair = Items[i];
layout.SetMarkup (pair.Key);
layout.GetPixelSize (out width, out height);
if (i == 0) {
FoldingScreenbackgroundRenderer.DrawRoundRectangle (g, false, true, false, false, 0, y + 0.5, height + 1.5, Allocation.Width, height);
g.SetSourceColor (Styles.TableLayoutModeCategoryBackgroundColor.ToCairoColor ());
g.FillPreserve ();
g.SetSourceColor (Styles.TableLayoutModeBorderColor.ToCairoColor ());
g.Stroke ();
g.MoveTo (xSpacer + 0.5, height + yBorder * 2 + 1);
g.LineTo (xSpacer + 0.5, height * 2 + yBorder * 2 + 1);
g.SetSourceColor (Styles.TableLayoutModeGridColor.ToCairoColor ());
g.Stroke ();
}
gc.RgbFgColor = (HslColor)(i == 0 ? Styles.TableLayoutModeBackgroundColor : Styles.TableLayoutModeTextColor).ToCairoColor ();
g.Save ();
g.SetSourceColor (Styles.TableLayoutModeTextColor.ToCairoColor ());
g.Translate (xBorder, y);
g.ShowLayout (layout);
g.Restore ();
g.Save ();
g.SetSourceColor (Styles.TableLayoutModeTextColor.ToCairoColor ());
g.Translate (xSpacer + xBorder, y);
layout.SetMarkup (pair.Value);
g.ShowLayout (layout);
g.Restore ();
// draw top line
if (i > 0) {
g.MoveTo (1, y + 0.5);
g.LineTo (Allocation.Width - 1, y + 0.5);
g.SetSourceColor (Styles.TableLayoutModeGridColor.ToCairoColor ());
g.Stroke ();
}
y += height;
}
gc.Dispose ();
}
return base.OnExposeEvent (args);
}
示例6: HandleWidgetExposeEvent
void HandleWidgetExposeEvent(object o, Gtk.ExposeEventArgs args)
{
// The Entry's GdkWindow is the top level window onto which
// the frame is drawn; the actual text entry is drawn into a
// separate window, so we can ensure that for themes that don't
// respect HasFrame, we never ever allow the base frame drawing
// to happen
if (args.Event.Window == Widget.GdkWindow)
return;
if (Widget.Text.Length > 0)
return;
if (layout == null) {
layout = new Pango.Layout (Widget.PangoContext);
layout.FontDescription = Widget.PangoContext.FontDescription.Copy ();
}
int wh, ww;
args.Event.Window.GetSize (out ww, out wh);
int width, height;
layout.SetText (placeHolderText);
layout.GetPixelSize (out width, out height);
Gdk.GC gc = new Gdk.GC (args.Event.Window);
gc.Copy (Widget.Style.TextGC (Gtk.StateType.Normal));
Color color_a = Util.ToXwtColor (Widget.Style.Base (Gtk.StateType.Normal));
Color color_b = Util.ToXwtColor (Widget.Style.Text (Gtk.StateType.Normal));
gc.RgbFgColor = Util.ToGdkColor (color_b.BlendWith (color_a, 0.5));
args.Event.Window.DrawLayout (gc, 2, (wh - height) / 2 + 1, layout);
gc.Dispose ();
}
示例7: OnExposeEvent
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
{
if (TabStrip.VisualStyle.TabStyle == DockTabStyle.Normal) {
var alloc = Allocation;
Gdk.GC gc = new Gdk.GC (GdkWindow);
gc.RgbFgColor = TabStrip.VisualStyle.InactivePadBackgroundColor.Value.ToGdkColor ();
evnt.Window.DrawRectangle (gc, true, alloc);
gc.Dispose ();
Gdk.GC bgc = new Gdk.GC (GdkWindow);
var c = TabStrip.VisualStyle.PadBackgroundColor.Value;
c.Light *= 0.7;
bgc.RgbFgColor = c.ToGdkColor ();
evnt.Window.DrawLine (bgc, alloc.X, alloc.Y + alloc.Height - 1, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1);
bgc.Dispose ();
}
return base.OnExposeEvent (evnt);
}
示例8: drawHVBox
void drawHVBox(Gdk.EventExpose evnt, Gdk.Window GdkWindow, Gdk.Rectangle alloc)
{
if (VisualStyle.TabStyle == DockTabStyle.Normal)
{
Gdk.GC gc = new Gdk.GC(GdkWindow);
gc.RgbFgColor = VisualStyle.InactivePadBackgroundColor.Value;
evnt.Window.DrawRectangle(gc, true, alloc);
gc.Dispose();
Gdk.GC bgc = new Gdk.GC(GdkWindow);
var c = new HslColor(VisualStyle.PadBackgroundColor.Value);
c.L *= 0.7;
bgc.RgbFgColor = c;
evnt.Window.DrawLine(bgc, alloc.X, alloc.Y + alloc.Height - 1, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1);
bgc.Dispose();
}
}
示例9: OnExposeEvent
protected override bool OnExposeEvent (Gdk.EventExpose evt)
{
if (!IsDrawable)
return false;
int width, height;
GdkWindow.GetSize (out width, out height);
Gdk.Rectangle a = new Gdk.Rectangle (0,0,width,height);
byte b2 = 210;
int ssLT = 12;
int ssRB = 7;
double grey = 0.6;
double greyb1 = 0.9;
double greyb2 = 0.6;
Gdk.Rectangle rect = a;
Cairo.Color back1 = new Cairo.Color (greyb1, greyb1, greyb1);
Cairo.Color back2 = new Cairo.Color (greyb2, greyb2, greyb2);
Cairo.Color cdark = new Cairo.Color (grey, grey, grey, 1);
Cairo.Color clight = new Cairo.Color (grey, grey, grey, 0);
using (Cairo.Context cr = Gdk.CairoHelper.Create (evt.Window)) {
DrawGradient (cr, rect, 0, 0, 1, 1, back1, back2);
rect.X = a.X;
rect.Y = a.Y;
rect.Height = ssLT;
rect.Width = a.Width;
DrawGradient (cr, rect, 0, 0, 0, 1, cdark, clight);
rect.Y = a.Bottom - ssRB;
rect.Height = ssRB;
DrawGradient (cr, rect, 0, 0, 0, 1, clight, cdark);
rect.X = a.X;
rect.Y = a.Y;
rect.Width = ssLT;
rect.Height = a.Height;
DrawGradient (cr, rect, 0, 0, 1, 0, cdark, clight);
rect.X = a.Right - ssRB;
rect.Width = ssRB;
DrawGradient (cr, rect, 0, 0, 1, 0, clight, cdark);
Gdk.GC gc = new Gdk.GC (GdkWindow);
gc.RgbBgColor = new Gdk.Color (b2,b2,b2);
gc.RgbFgColor = new Gdk.Color (b2,b2,b2);
GdkWindow.DrawRectangle (gc, false, a.X, a.Y, a.Width, a.Height);
gc.Dispose ();
}
return base.OnExposeEvent (evt);
}
示例10: UpdatePreview
protected void UpdatePreview()
{
thumb_image.Clear();
FileIsGood = false;
int size = 200, margins = 30;
if (System.IO.File.Exists(mFilename)) // Selected item is a file
{
origsize_label.Markup = "";
GLib.Timeout.Add(100, new GLib.TimeoutHandler(delegate {
Gdk.Pixmap pm = null;
Gdk.GC gc = null;
Gdk.Pixbuf pb = null;
try
{
pm = new Gdk.Pixmap(thumb_image.GdkWindow, size + margins, size + margins, -1);
gc = new Gdk.GC(thumb_image.GdkWindow);
pm.DrawRectangle(gc, true, new Gdk.Rectangle(0, 0, size + margins, size + margins));
RawDescriptionLoader rdl = RawDescriptionLoader.FromFile(mFilename);
string idtext = "";
try
{
idtext += "Shot has been taken\n" +
" on <b>" + rdl.TimeStamp.ToString("MMMM, d, yyyy") + "</b> at <b>" + rdl.TimeStamp.ToString("h:mm:ss tt") + "</b>,\n";
idtext += " with <b>" + rdl.CameraMaker + " " + rdl.CameraModel + "</b>\n\n";
idtext += "ISO speed: <b>" + rdl.ISOSpeed.ToString("0") + "</b>\n";
if (rdl.Shutter > 1)
idtext += "Shutter: <b>" + rdl.Shutter.ToString("0.0") + "</b> sec\n";
else
idtext += "Shutter: <b>1/" + (1.0 / (rdl.Shutter + 0.000001)).ToString("0") + "</b> sec\n";
idtext += "Aperture: <b>" + rdl.Aperture.ToString("0.0") + "</b>\n" +
"Focal length: <b>" + rdl.FocalLength.ToString("0") + "</b> mm\n";
if (rdl.Artist != "") idtext += "Artist: <b>" + rdl.Artist + "</b>\n";
if (rdl.Description != "") idtext += "Description: <b>" + rdl.Description + "</b>\n";
Console.WriteLine(rdl.Flip);
// Creating the thumbnail pixbuf
pb = new Gdk.Pixbuf(rdl.ThumbnailData);
}
catch (Exception ex)
{
Console.WriteLine("Can't load the thumbnail: " + ex.Message);
idtext += "\n<i>Can't load the thumbnail.</i>";
}
identification_label.Markup = idtext;
if (pb != null)
{
// Scaling the thumbnail
Gdk.Pixbuf pbold = pb;
int imgw = pb.Width, imgh = pb.Height;
if (pb.Width > pb.Height)
pb = pb.ScaleSimple(size, (int)((double)pb.Height / pb.Width * size), Gdk.InterpType.Bilinear);
else
pb = pb.ScaleSimple((int)((double)pb.Width / pb.Height * size), size, Gdk.InterpType.Bilinear);
pbold.Dispose();
// Rotating the thumbnail
if (rdl.Flip != RawDescriptionLoader.FlipValues.None)
{
pbold = pb;
if (rdl.Flip == RawDescriptionLoader.FlipValues.UpsideDown)
pb = pb.RotateSimple(Gdk.PixbufRotation.Upsidedown);
else if (rdl.Flip == RawDescriptionLoader.FlipValues.Clockwise)
{
int t = imgw;
imgw = imgh;
imgh = t;
pb = pb.RotateSimple(Gdk.PixbufRotation.Clockwise);
}
else if (rdl.Flip == RawDescriptionLoader.FlipValues.Counterclockwise)
{
int t = imgw;
imgw = imgh;
imgh = t;
pb = pb.RotateSimple(Gdk.PixbufRotation.Counterclockwise);
}
pbold.Dispose();
}
origsize_label.Markup = "Image size: <b>" + imgw + "</b> x <b>" + imgh + "</b>";
pm.DrawPixbuf(gc, pb, 0, 0,
(size + margins) / 2 - pb.Width / 2,
(size + margins) / 2 - pb.Height / 2,
pb.Width, pb.Height, Gdk.RgbDither.Max, 0, 0);
thumb_image.SetFromPixmap(pm, null);
pb.Dispose();
//.........这里部分代码省略.........
示例11: OnExposeEvent
protected override bool OnExposeEvent(Gdk.EventExpose evnt)
{
if (VisualStyle.TabStyle == DockTabStyle.Normal) {
Gdk.GC gc = new Gdk.GC (GdkWindow);
gc.RgbFgColor = VisualStyle.PadBackgroundColor.Value;
evnt.Window.DrawRectangle (gc, true, Allocation);
gc.Dispose ();
}
bool result = base.OnExposeEvent(evnt);
Gdk.Color? col = VisualStyle.PadBackgroundColor;
if (col.HasValue)
{
DrawFocus(evnt.Window, Color.FromArgb(255, col.Value.Red / 256, col.Value.Green / 256, col.Value.Blue / 256));
}
return result;
}
示例12: OnExposeEvent
protected override bool OnExposeEvent (Gdk.EventExpose e)
{
Gdk.GC gc = new Gdk.GC (e.Window);
int count = 0;
foreach (Hunk h in hunks) {
IncPos(h, ref count);
}
int start = 0;
foreach (Hunk h in hunks) {
int size = 0;
IncPos(h, ref size);
if (h.Same)
gc.RgbFgColor = widget.ColorDefault;
else if (h.Original().Count == 0)
gc.RgbFgColor = widget.ColorAdded;
else if (h.ChangedLists == 1 && h.Changes(0).Count == 0)
gc.RgbFgColor = widget.ColorRemoved;
else
gc.RgbFgColor = widget.ColorChanged;
GdkWindow.DrawRectangle(gc, true, 0, Allocation.Height*start/count, Allocation.Width, Allocation.Height*size/count);
start += size;
}
gc.RgbFgColor = widget.ColorGrey;
e.Window.DrawRectangle(gc, false,
1,
(int)(Allocation.Height*scroller.Vadjustment.Value/scroller.Vadjustment.Upper) + 1,
Allocation.Width-3,
(int)(Allocation.Height*((double)scroller.Allocation.Height/scroller.Vadjustment.Upper))-2);
gc.RgbFgColor = widget.ColorBlack;
e.Window.DrawRectangle(gc, false,
0,
(int)(Allocation.Height*scroller.Vadjustment.Value/scroller.Vadjustment.Upper),
Allocation.Width-1,
(int)(Allocation.Height*((double)scroller.Allocation.Height/scroller.Vadjustment.Upper)));
gc.Dispose ();
return true;
}
示例13: DrawAsBrowser
void DrawAsBrowser (Gdk.EventExpose evnt)
{
var alloc = Allocation;
Gdk.GC bgc = new Gdk.GC (GdkWindow);
var baseColor = Style.Background (StateType.Normal);
var c = new HslColor (baseColor);
c.L *= 0.7;
bgc.RgbFgColor = c;
var cts = ((SquaredTabStrip.TabStripBox)Parent).Children;
var first = cts[0] == this;
var last = cts[cts.Length - 1] == this;
if (Active || (first && last)) {
Gdk.GC gc = new Gdk.GC (GdkWindow);
gc.RgbFgColor = baseColor;
evnt.Window.DrawRectangle (gc, true, alloc);
if (!first)
evnt.Window.DrawLine (bgc, alloc.X, alloc.Y, alloc.X, alloc.Y + alloc.Height - 1);
if (!last || !first)
evnt.Window.DrawLine (bgc, alloc.X + alloc.Width - 1, alloc.Y, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1);
gc.Dispose ();
} else {
c = new HslColor (baseColor);
c.L *= 0.9;
Gdk.GC gc = new Gdk.GC (GdkWindow);
gc.RgbFgColor = c;
evnt.Window.DrawRectangle (gc, true, alloc);
gc.Dispose ();
evnt.Window.DrawLine (bgc, alloc.X, alloc.Y + alloc.Height - 1, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1);
}
bgc.Dispose ();
}
示例14: OnExposeEvent
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
{
var alloc = Allocation;
var baseColor = Style.Background (StateType.Normal);
var c = new HslColor (baseColor);
c.L *= 0.9;
Gdk.GC gc = new Gdk.GC (GdkWindow);
gc.RgbFgColor = c;
evnt.Window.DrawRectangle (gc, true, alloc);
gc.Dispose ();
Gdk.GC bgc = new Gdk.GC (GdkWindow);
c = new HslColor (baseColor);
c.L *= 0.7;
bgc.RgbFgColor = c;
evnt.Window.DrawLine (bgc, alloc.X, alloc.Y + alloc.Height - 1, alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1);
bgc.Dispose ();
return base.OnExposeEvent (evnt);
}