当前位置: 首页>>代码示例>>C#>>正文


C# Window.GetSize方法代码示例

本文整理汇总了C#中Gtk.Window.GetSize方法的典型用法代码示例。如果您正苦于以下问题:C# Window.GetSize方法的具体用法?C# Window.GetSize怎么用?C# Window.GetSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gtk.Window的用法示例。


在下文中一共展示了Window.GetSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

    public static void Main(string[] args)
    {
        Node n = null;

        if (args.Length == 0){
            Console.WriteLine ("Must specify the XML file with the data to load");
            return;
        }
        try {
            n = LoadNodes (args [0], "Size", "Foo");
        } catch {
            Console.WriteLine ("Unable to load {0}", args [0]);
            throw;
        }

        Gtk.Application.Init ();
        MoonlightRuntime.Init ();

        Gtk.Window w = new Gtk.Window ("Foo");
        var v = new Gtk.VBox (false, 0);

        w.DeleteEvent += delegate {
            Gtk.Application.Quit ();
        };

        w.SetSizeRequest (width, height);
        MoonlightHost h = new MoonlightHost ();

        v.PackStart (h, true, true, 0);
        var back = new Gtk.Button ("Back");
        v.PackStart (back, false, false, 0);
        w.Add (v);

        w.ShowAll ();

        // Make it pretty, skip all levels that are just 1 element
        while (n.Children.Count == 1)
            n = n.Children [0];

        // Render
        TreemapRenderer r = new TreemapRenderer (n, "");
        r.KeyDown += delegate (object sender, KeyEventArgs e) {
            if (e.Key == Key.Back)
                r.Back ();
        };

        back.Clicked += delegate {
            r.Back ();
        };

        SetSize (r, width, height);

        h.Application.RootVisual = r;

        w.ResizeChecked += delegate(object sender, EventArgs e) {
            int new_width, new_heigth;
            w.GetSize (out new_width, out new_heigth);

            SetSize (r, new_width, new_heigth);;
        };

        Gtk.Application.Run ();
    }
开发者ID:mono,项目名称:TreemapViewer,代码行数:63,代码来源:Main.cs

示例2: CenterWindow

		/// <summary>Centers a window relative to its parent.</summary>
		static void CenterWindow (Window child, Window parent)
		{
			child.Child.Show ();
			int w, h, winw, winh, x, y, winx, winy;
			child.GetSize (out w, out h);
			parent.GetSize (out winw, out winh);
			parent.GetPosition (out winx, out winy);
			x = Math.Max (0, (winw - w) /2) + winx;
			y = Math.Max (0, (winh - h) /2) + winy;
			child.Move (x, y);
		}
开发者ID:wickedshimmy,项目名称:monodevelop,代码行数:12,代码来源:MessageService.cs

示例3: CenterWindow

		/// <summary>Centers a window relative to its parent.</summary>
		static void CenterWindow (Window child, Window parent)
		{
			if (child == null || parent == null)
				return;

			child.Child.Show ();
			int w, h, winw, winh, x, y, winx, winy;
			child.GetSize (out w, out h);
			parent.GetSize (out winw, out winh);
			parent.GetPosition (out winx, out winy);
			x = System.Math.Max (0, (winw - w) /2) + winx;
			y = System.Math.Max (0, (winh - h) /2) + winy;
			child.Move (x, y);
		}
开发者ID:wanglehui,项目名称:mono-addins,代码行数:15,代码来源:Services.cs


注:本文中的Gtk.Window.GetSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。