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


C# VBox.Show方法代码示例

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


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

示例1: Main

    private static int Main(string[] args)
    {
        // * Init GTK.
        Gtk.Application.Init ("Color", ref args);

        // * Init GtkGLExt.
        GtkGL.Application.Init (ref args);

        // * Display mode.
        GdkGL.ConfigMode mode = GdkGL.ConfigMode.Index;

        for (int i = 0; i < args.Length; i++)
        {
            if (args[i] == "--rgb")
                mode = GdkGL.ConfigMode.Rgb;
        }

        // * Query OpenGL extension version.
        int major, minor;
        Query.Version (out major, out minor);
        Console.WriteLine ("\nOpenGL extension version - {0}.{1}", major, minor);

        // * Configure OpenGL-capable visual.
        // Try double-buffered visual
        GdkGL.Config glconfig = new GdkGL.Config (mode | GdkGL.ConfigMode.Depth | GdkGL.ConfigMode.Double);
        if (glconfig == null) {
          		Console.WriteLine ("*** Cannot find the double-buffered visual.\n*** Trying single-buffered visual.");
            glconfig = new GdkGL.Config (mode | GdkGL.ConfigMode.Depth);
            if (glconfig == null) {
                  Console.WriteLine ("*** Cannot find any OpenGL-capable visual.");
                  return 1;
            }
        }

        GlUtilities.WriteOutConfig (glconfig);
        bool is_rgba = glconfig.IsRgba;

        // Top-level window.
        Window window = new Window (WindowType.Toplevel);
        window.Title = "color";

        // Perform the resizes immediately
        window.ResizeMode = ResizeMode.Immediate;

        // Get automatically redrawn if any of their children changed allocation.
        window.ReallocateRedraws = true;

        window.DeleteEvent += new DeleteEventHandler (Window_Delete);

        // VBox.
        VBox vbox = new VBox (false, 0);
        window.Add (vbox);
        vbox.Show ();

        // Drawing area for drawing OpenGL scene.
        ColorTriangle drawing_area = new ColorTriangle (glconfig);
        drawing_area.SetSizeRequest (200, 200);

        vbox.PackStart (drawing_area, true, true, 0);
        drawing_area.Show ();

        // Simple quit button.
        Button button = new Button ("Quit");
        button.Pressed += new EventHandler (Button_Click);
        vbox.PackStart (button, false, false, 0);
        button.Show ();

        // * Show window.
        window.Show ();

        // * Allocate colors.
        if (!is_rgba) {
            Gdk.Colormap colormap = glconfig.Colormap;
            Console.WriteLine ("\nAllocate colors.");

            // Allocate writable color cells.
            bool[] success = new bool [NUM_COLORS];
            int not_allocated = colormap.AllocColors (colors, NUM_COLORS, false, false, success);
            for (int i = 0; i < NUM_COLORS; i++)
                Console.WriteLine ("{0}", success[i]);

            Console.WriteLine ("Not allocated = {0}", not_allocated);

            for (int i = 0; i < NUM_COLORS; i++)
                Console.WriteLine ("colors[{0}] = [ {1}, {2}, {3}, {4} ]",  i,
                                                                            colors[i].Pixel,
                                                                            colors[i].Red,
                                                                            colors[i].Green,
                                                                            colors[i].Blue
                                                                            );
            Console.WriteLine ("\nQuery colors.");

            for (int i = 0; i < NUM_COLORS; i++) {
                Gdk.Color color = new Gdk.Color ();
                color.Pixel = colors[i].Pixel;
                colormap.QueryColor (colors[i].Pixel, ref color);
                Console.WriteLine ("colors[{0}] = { {1}, {2}, {3}, {4} }",  i,
                                                                            colors[i].Pixel,
                                                                            color.Red,
                                                                            color.Green,
//.........这里部分代码省略.........
开发者ID:GNOME,项目名称:gtkglext-sharp,代码行数:101,代码来源:color.cs

示例2: Main

    public static int Main(string[] args)
    {
        /*
            * Init GTK.
            */
            Gtk.Application.Init (/*"Gears3D", null*/);

            /*
            * Init GtkGLExt.
            */
            GtkGL.Application.Init (ref args);

            /*
            * Command line options.
            */
            for (int i = 0; i < args.Length; i++)
                if (args[i] ==  "--async")
                    is_sync = false;

            /*
            * Configure OpenGL-capable visual.
            */

            /* Try double-buffered visual */
            GdkGL.Config glconfig = new GdkGL.Config (GdkGL.ConfigMode.Rgb | GdkGL.ConfigMode.Depth | GdkGL.ConfigMode.Double);
            if (glconfig == null) {
          		Console.WriteLine ("*** Cannot find the double-buffered visual.\n*** Trying single-buffered visual.");
                /* Try single-buffered visual */
                glconfig = new GdkGL.Config (GdkGL.ConfigMode.Rgb | GdkGL.ConfigMode.Depth);
                if (glconfig == null) {
                      Console.WriteLine ("*** Cannot find any OpenGL-capable visual.");
                      return 1;
                }
            }

            /*
            * Top-level window.
            */
            Window window = new Window (WindowType.Toplevel);
            window.Title = "gears";

            /* Get automatically redrawn if any of their children changed allocation. */
            window.ReallocateRedraws = true;

            window.DeleteEvent += new DeleteEventHandler (Window_Delete);

            /*
            * VBox.
            */
            VBox vbox = new VBox (false, 0);
            window.Add (vbox);
            vbox.Show ();

            /*
            * Drawing area for drawing OpenGL scene.
            */
            /* Set OpenGL-capability to the widget. */
            GearsArea drawing_area = new GearsArea (glconfig);
            drawing_area.SetSizeRequest (300, 300);

            window.KeyPressEvent += new KeyPressEventHandler (drawing_area.OnKeyPress);

            vbox.PackStart (drawing_area, true, true, 0);
            drawing_area.Show ();

            /*
            * Simple quit button.
            */
            Button button = new Button ("Quit");
            button.Clicked += new EventHandler (Button_Click);
            vbox.PackStart (button, false, false, 0);
            button.Show ();

            /*
            * Show window.
            */
            window.Show ();

            /*
            * Main loop.
            */
            Gtk.Application.Run ();
            return 0;
    }
开发者ID:GNOME,项目名称:gtkglext-sharp,代码行数:84,代码来源:gears.cs


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