本文整理汇总了C#中Gdk.GetSize方法的典型用法代码示例。如果您正苦于以下问题:C# Gdk.GetSize方法的具体用法?C# Gdk.GetSize怎么用?C# Gdk.GetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdk
的用法示例。
在下文中一共展示了Gdk.GetSize方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSurface
public static Surface CreateSurface(Gdk.Drawable d)
{
int width, height;
d.GetSize (out width, out height);
XlibSurface surface = new XlibSurface (GdkUtils.GetXDisplay (d.Display),
(IntPtr)GdkUtils.GetXid (d),
GdkUtils.GetXVisual (d.Visual),
width, height);
return surface;
}
示例2: DrawGrid
public static void DrawGrid(Gdk.Drawable wnd, int Size)
{
int Width, Height;
var gc = new Gdk.GC (wnd);
Gdk.Color line_color = new Gdk.Color (0, 255, 255);
gc.RgbFgColor = line_color;
wnd.GetSize (out Width, out Height);
for (int i = 0; i < Width; i += Size)
wnd.DrawLine (gc, i, 0, i, Height);
for (int i = 0; i < Height; i += Size)
wnd.DrawLine (gc, 0, i, Width, i);
}
示例3: SetSourceDrawable
public static void SetSourceDrawable (Context ctx, Gdk.Drawable d, double x, double y)
{
try {
gdk_cairo_set_source_pixmap (ctx.Handle, d.Handle, x, y);
} catch (EntryPointNotFoundException) {
int width, height;
d.GetSize (out width, out height);
XlibSurface surface = new XlibSurface (GdkUtils.GetXDisplay (d.Display),
(IntPtr)GdkUtils.GetXid (d),
GdkUtils.GetXVisual (d.Visual),
width, height);
SurfacePattern p = new SurfacePattern (surface);
Matrix m = new Matrix ();
m.Translate (-x, -y);
p.Matrix = m;
ctx.Source = p;
}
}
示例4: DrawTicks
void DrawTicks(Gdk.Window win, Gdk.GC gc, TickEnumerator e, AxisPosition pos, AxisDimension ad, int tickSize, bool showLabels)
{
int rwidth, rheight;
win.GetSize (out rwidth, out rheight);
Pango.Layout layout = null;
if (showLabels) {
layout = new Pango.Layout (this.PangoContext);
layout.FontDescription = Pango.FontDescription.FromString ("Tahoma 8");
}
bool isX = pos == AxisPosition.Top || pos == AxisPosition.Bottom;
bool isTop = pos == AxisPosition.Top || pos == AxisPosition.Right;
double start = GetStart (ad);
double end = GetEnd (ad);
e.Init (GetOrigin (ad));
while (e.CurrentValue > start)
e.MovePrevious ();
int lastPosLabel;
int lastPos;
int lastTw = 0;
if (isX) {
lastPosLabel = reverseXAxis ? left + width + MinLabelGapX : left - MinLabelGapX;
lastPos = left - minTickStep*2;
}
else {
lastPosLabel = reverseYAxis ? top - MinLabelGapY : rheight + MinLabelGapY;
lastPos = top + height + minTickStep*2;
}
for ( ; e.CurrentValue <= end; e.MoveNext ())
{
int px, py;
int tw = 0, th = 0;
int tick = tickSize;
GetPoint (e.CurrentValue, e.CurrentValue, out px, out py);
if (showLabels) {
layout.SetMarkup (e.CurrentLabel);
layout.GetPixelSize (out tw, out th);
}
if (isX) {
if (Math.Abs ((long)px - (long)lastPos) < minTickStep || px < left || px > left + width)
continue;
lastPos = px;
bool labelFits = false;
if ((Math.Abs (px - lastPosLabel) - (tw/2) - (lastTw/2)) >= MinLabelGapX) {
lastPosLabel = px;
lastTw = tw;
labelFits = true;
}
if (isTop) {
if (showLabels) {
if (labelFits)
win.DrawLayout (gc, px - (tw/2), top - AreaBorderWidth - th, layout);
else
tick = tick / 2;
}
win.DrawLine (gc, px, top, px, top + tick);
}
else {
if (showLabels) {
if (labelFits)
win.DrawLayout (gc, px - (tw/2), top + height + AreaBorderWidth, layout);
else
tick = tick / 2;
}
win.DrawLine (gc, px, top + height, px, top + height - tick);
}
}
else {
if (Math.Abs ((long)lastPos - (long)py) < minTickStep || py < top || py > top + height)
continue;
lastPos = py;
bool labelFits = false;
if ((Math.Abs (py - lastPosLabel) - (th/2) - (lastTw/2)) >= MinLabelGapY) {
lastPosLabel = py;
lastTw = th;
labelFits = true;
}
if (isTop) {
if (showLabels) {
if (labelFits)
win.DrawLayout (gc, left + width + AreaBorderWidth + 1, py - (th/2), layout);
else
tick = tick / 2;
}
win.DrawLine (gc, left + width, py, left + width - tick, py);
//.........这里部分代码省略.........
示例5: DrawLayout
public void DrawLayout(Gdk.Drawable drawable, Gdk.GC gc, FontService fontService)
{
Gdk.Pixbuf pixbuf = BuildImage(fontService);
int w = -1, h = -1;
drawable.GetSize(out w, out h);
pixbuf.RenderToDrawable(drawable, gc, 0, 0, 0, 0, w, h, Gdk.RgbDither.Normal, 0, 0);
// manual dispose
(pixbuf as IDisposable).Dispose ();
}
示例6: DrawSample
public void DrawSample(Gdk.Drawable drawable, string text)
{
using (Cairo.Context ctx = Gdk.CairoHelper.Create (drawable))
{
using (Pango.Layout layout = Pango.CairoHelper.CreateLayout (ctx))
{
AssignLayout(layout);
layout.SetText(text);
// dest size
int width, height;
drawable.GetSize(out width, out height);
// set pos
Pango.Rectangle te = Pango.Rectangle.Zero;
if (text.Length > 0)
{
Pango.Rectangle unused;
layout.GetPixelExtents(out unused, out te);
te.X = (width - te.Width) / 2;
te.Y = (height - te.Height) / 2;
}
// fill background
ctx.Save();
int boxSize = 20, padding = 0;
Cairo.Color clr1 = Gui.CairoExtensions.RgbToColor(0xE77817);
Cairo.Color clr2 = Gui.CairoExtensions.RgbToColor(0x383431);
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
ctx.Rectangle(i * (boxSize + padding), j * (boxSize + padding), boxSize, boxSize);
if ((i + j) % 2 == 0)
ctx.SetSourceRGBA(clr1.R, clr1.G, clr1.B, clr1.A);
else
ctx.SetSourceRGBA(clr2.R, clr2.G, clr2.B, clr2.A);
ctx.Fill();
}
}
ctx.Restore();
// show text
if (text.Length > 0)
{
ctx.Save();
ctx.MoveTo(te.X, te.Y);
ctx.Color = new Cairo.Color(1.0, 1.0, 1.0, 1.0);
ctx.Antialias = Cairo.Antialias.Gray;
ctx.Operator = Cairo.Operator.Source;
Pango.CairoHelper.ShowLayout(ctx, layout);
ctx.Restore();
}
}
}
}
示例7: DrawFocus
void DrawFocus(Gdk.Window window, Color c)
{
int x, y, width, height;
window.GetPosition(out x, out y);
window.GetSize(out width, out height);
System.Drawing.Rectangle r = new System.Drawing.Rectangle(x, y, width, height);
using (Cairo.Context context = Gdk.CairoHelper.Create(window))
{
uint b = mainBox.BorderWidth;
// Top
using (Cairo.Gradient gradient = createGradient(0.0, 0.0, 0, b, c))
{
context.SetSource(gradient);
context.MoveTo(0, 0);
context.LineTo(r.Width, 0);
context.LineTo(r.Width - b + 1, b);
context.LineTo(b - 1, b);
context.ClosePath();
context.Fill();
}
// Left
using (Cairo.Gradient gradient = createGradient(0.0, 0.0, b, 0, c))
{
context.SetSource(gradient);
context.MoveTo(0, 0);
context.LineTo(b, b - 1);
context.LineTo(b, r.Height - b + 1);
context.LineTo(0, r.Height);
context.ClosePath();
context.Fill();
}
// Bottom
using (Cairo.Gradient gradient = createGradient(0.0, r.Height, 0, r.Height - b, c))
{
context.SetSource(gradient);
context.MoveTo(0, r.Height);
context.LineTo(b - 1, r.Height - b);
context.LineTo(r.Width - b + 1, r.Height - b);
context.LineTo(r.Width, r.Height);
context.ClosePath();
context.Fill();
}
// Right
using (Cairo.Gradient gradient = createGradient(r.Width, 0, r.Width - b, 0, c))
{
context.SetSource(gradient);
context.MoveTo(r.Width, 0);
context.LineTo(r.Width - b, b - 1);
context.LineTo(r.Width - b, r.Height - b + 1);
context.LineTo(r.Width, r.Height);
context.ClosePath();
context.Fill();
}
}
}
示例8: DrawText
void DrawText(Gdk.Window window, Cairo.Context cr, string text)
{
bool theme;
Gdk.GC light;
const int marginx = 10;
int winWidth, winHeight, w, h;
window.GetSize (out winWidth, out winHeight);
if (project != null && project.Details.Theme != null) {
theme = true;
}
else
theme = false;
if (theme == true) {
if (winWidth > project.Details.Width)
winWidth = project.Details.Width;
if (winHeight > project.Details.Height)
winHeight = project.Details.Height;
}
Pango.Layout layout = new Pango.Layout (this.PangoContext);
layout.Width = winWidth * (int) Pango.Scale.PangoScale;
layout.SetMarkup (text);
layout.GetPixelSize (out w, out h);
if (theme) {
// TODO: We should force the ink colour too
cr.Color = new Cairo.Color (0, 0, 0, 0.7);
cr.Rectangle (((winWidth - w) /2) - marginx, (winHeight / 2), w + marginx * 2, h * 2);
cr.Fill ();
cr.Stroke ();
light = Style.LightGC (StateType.Normal);
}
light = Style.DarkGC (StateType.Normal);
window.DrawLayout (light, (winWidth - w) /2, (winHeight / 2) + 4, layout);
layout.Dispose ();
}
示例9: WindowPositionAndSize
Rectangle WindowPositionAndSize(Gdk.Window window)
{
int x,y,width,height;
window.GetPosition(out x, out y);
window.GetSize(out width, out height);
return new Rectangle(x,y,width,height);
}
示例10: GetRect
private static Gdk.Rectangle GetRect(Gdk.Window window)
{
Gdk.Rectangle rect = Gdk.Rectangle.Zero;
int vx, vy;
window.GetPosition(out vx, out vy);
rect.X = vx;
rect.Y = vy;
window.GetSize(out vx, out vy);
rect.Width = vx;
rect.Height = vy;
return rect;
}