本文整理汇总了C#中Canvas.SetSizeRequest方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.SetSizeRequest方法的具体用法?C# Canvas.SetSizeRequest怎么用?C# Canvas.SetSizeRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Canvas
的用法示例。
在下文中一共展示了Canvas.SetSizeRequest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanvasExample
public CanvasExample () {
Gtk.Window win = new Gtk.Window ("Canvas example");
win.DeleteEvent += new DeleteEventHandler (Window_Delete);
VBox vbox = new VBox (false, 0);
win.Add (vbox);
vbox.PackStart (new Label ("Drag - move object.\n" +
"Double click - change color\n" +
"Right click - delete object"),
false, false, 0);
canvas = new Canvas ();
canvas.SetSizeRequest (width, height);
canvas.SetScrollRegion (0.0, 0.0, (double) width, (double) height);
vbox.PackStart (canvas, false, false, 0);
HBox hbox = new HBox (false, 0);
vbox.PackStart (hbox, false, false, 0);
Button add_button = new Button ("Add an object");
add_button.Clicked += new EventHandler (AddObject);
hbox.PackStart (add_button, false, false, 0);
Button quit_button = new Button ("Quit");
quit_button.Clicked += new EventHandler (Quit);
hbox.PackStart (quit_button, false, false, 0);
win.ShowAll ();
}
示例2: Main
static void Main (string [] args)
{
if (args.Length > 0 && args [0] == "debug")
BoardPiece.Debug = true;
Program fifteen = new Program ("Fifteen", "0.1", Modules.UI, args);
window = new Gtk.Window ("Fifteen #");
VBox box = new VBox (false, 0);
window.Add (box);
window.DefaultWidth = 300;
window.DefaultHeight = 300;
VBox vbox = new VBox (false, 4);
vbox.BorderWidth = 4;
MenuBar menu = Create_Menu ();
box.PackStart (menu, false, false, 0);
box.PackStart (vbox, false, false, 0);
window.DeleteEvent += new DeleteEventHandler (Window_Delete);
Alignment alignment = new Alignment (0.5f, 0.5f, 0.0f, 0.0f);
vbox.PackStart (alignment, true, true, 4);
Frame frame = new Frame (null);
frame.ShadowType = ShadowType.In;
alignment.Add (frame);
canvas = new Canvas ();
canvas.SetSizeRequest (BoardPiece.PIECE_SIZE * 4 + 1, BoardPiece.PIECE_SIZE * 4 + 1);
canvas.SetScrollRegion (0, 0, BoardPiece.PIECE_SIZE * 4 + 1, BoardPiece.PIECE_SIZE * 4 + 1);
frame.Add (canvas);
board = new BoardPiece [16];
for (int i = 0; i < 15; i ++) {
int y = i /4;
int x = i % 4;
board [i] = new BoardPiece (canvas.Root (), board, x, y, i);
}
box.PackStart (new HSeparator (), false, false, 0);
HBox hbox = new HBox (false, 4);
box.PackStart (hbox, true, false, 4);
// Scramble button here.
Button scramble = new Button ("_Scramble");
scramble.BorderWidth = 8;
scramble.Clicked += new EventHandler (Scramble);
scramble.CanDefault = true;
hbox.PackStart (scramble, true, true, 4);
scramble.GrabDefault ();
// Close button
Button close = new Button ("_Close");
close.BorderWidth = 8;
close.Clicked += new EventHandler (Quit);
hbox.PackStart (close, true, true, 4);
window.ShowAll ();
fifteen.Run ();
}