當前位置: 首頁>>代碼示例>>C#>>正文


C# Canvas.SetScrollRegion方法代碼示例

本文整理匯總了C#中Canvas.SetScrollRegion方法的典型用法代碼示例。如果您正苦於以下問題:C# Canvas.SetScrollRegion方法的具體用法?C# Canvas.SetScrollRegion怎麽用?C# Canvas.SetScrollRegion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Canvas的用法示例。


在下文中一共展示了Canvas.SetScrollRegion方法的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 ();
		}
開發者ID:directhex,項目名稱:xamarin-gnome-sharp2,代碼行數:30,代碼來源:CanvasExample.cs

示例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 ();
	}
開發者ID:directhex,項目名稱:xamarin-gnome-sharp2,代碼行數:61,代碼來源:Fifteen.cs


注:本文中的Canvas.SetScrollRegion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。