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


C# Dialog.CloseWindow方法代码示例

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


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

示例1: initGUI

        protected override bool initGUI()
        {
            _guiMgr = new GUIManager(_screenMgr);
            _screenMgr.Components.Add(_guiMgr);
            _guiMgr.Initialize();

            #region Shorthand GUI item creation
            // Create a MenuItem
            Func<UIComponent, String, MenuItem> create_mi =
                (UIComponent parent, String text) =>
                {
                    MenuItem mi             = new MenuItem(_screenMgr, _guiMgr);
                    mi.Text                 = text;

                    if          (parent is MenuBar)     (parent as MenuBar).Add(mi);
                    else if     (parent is MenuItem)    (parent as MenuItem).Add(mi);

                    return mi;
                };

            // Create a TextButton
            Func<UIComponent, String, int, int, int, int, TextButton> create_btn =
                (UIComponent parent, String text, int w, int h, int x, int y) =>
                {
                    TextButton btn = new TextButton(_screenMgr, _guiMgr);

                    btn.Text                = text;
                    btn.Width               = w;
                    btn.Height              = h;
                    btn.X                   = x;
                    btn.Y                   = y;

                    if          (parent is Dialog)      (parent as Dialog).Add(btn);
                    else if     (parent is Window)      (parent as Window).Add(btn);

                    return btn;
                };

            // Create a Dialog
            Func<String, int, int, int, int, Dialog> create_dialog =
                (String text, int w, int h, int x, int y) =>
                {
                    Dialog dialog = new Dialog(_screenMgr, _guiMgr);
                    _guiMgr.Add(dialog);

                    dialog.TitleText        = text;
                    dialog.Width            = w;
                    dialog.Height           = h;
                    dialog.X                = x;
                    dialog.Y                = y;
                    dialog.HasCloseButton   = false;

                    int bwidth              = 50;
                    int bheight             = 20;
                    int bxoffs              = 10;
                    int byoffs              = dialog.Height - 60;

                    // Ok button
                    TextButton btnOk = create_btn(
                        dialog, "Ok", bwidth, bheight, bxoffs, byoffs);
                    btnOk.Click += delegate(UIComponent sender)
                    {
                        dialog.DialogResult = DialogResult.OK;
                        dialog.CloseWindow();
                    };

                    // Cancel button
                    TextButton btnCancel = create_btn(
                        dialog, "Cancel", bwidth, bheight, bxoffs * 2 + bwidth, byoffs);
                    btnCancel.Click += delegate(UIComponent sender)
                    {
                        dialog.DialogResult = DialogResult.Cancel;
                        dialog.CloseWindow();
                    };

                    return dialog;
                };

            // Create a text box
            Func<UIComponent, String, int, int, int, TextBox> create_textbox =
                (UIComponent parent, String text, int w, int x, int y) =>
                {
                    TextBox textBox = new TextBox(_screenMgr, _guiMgr);

                    textBox.Width           = w;
                    textBox.X               = x;
                    textBox.Y               = y;

                    Label label             = new Label(_screenMgr, _guiMgr);
                    label.Text              = text;
                    label.Width             = 100;
                    label.Height            = 50;
                    label.X                 = x - label.Width;
                    label.Y                 = y + 5;

                    if (parent is Dialog)
                    {
                        (parent as Dialog).Add(textBox);
                        (parent as Dialog).Add(label);
                    }
//.........这里部分代码省略.........
开发者ID:jrs1498,项目名称:GDDGame1,代码行数:101,代码来源:GameEditorScreen.cs


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