Exemplo n.º 1
0
        static void Test_text_editing()
        {
            var frm = new Form(0, 0, Console.WindowWidth, Console.WindowHeight)
            {
                Title = "Text editing"
            };

            frm.AddChild(new TextLine(2, 2, frm.Size.width - 4)
            {
                Label = "Single text line"
            });

            frm.AddChild(new TextArea(2, 4, 16, 5)
            {
                Label = "Multi-line text"
            });

            frm.AddChild(new Button(2, 10, 10, "Close")
            {
                OnPressed = (s, e) => {
                    BashForms.Close();
                }
            });

            BashForms.Open(frm);
        }
Exemplo n.º 2
0
        static void Test_labels()
        {
            var frm = new Form(0, 0, Console.WindowWidth, Console.WindowHeight)
            {
                Title = "Labels"
            };

            frm.AddChild(new Label(2, 2, "A single line label next to a multi line label")
            {
                ForegroundColor = ConsoleColor.DarkGray
            });

            frm.AddChild(new Label(2, 4, "Macbeth:"));

            frm.AddChild(new Label(11, 4, 15)
            {
                Name            = "lbl",
                CanBeMultiline  = true,
                Text            = "She should have died hereafter, there would have been a time for such a word.",
                BackgroundColor = ConsoleColor.DarkRed
            });
            frm.AddChild(new Button(2, 11, 10, "Close")
            {
                OnPressed = (s, e) => {
                    BashForms.Close();
                }
            });

            BashForms.Open(frm);
        }
Exemplo n.º 3
0
        static void miBasic_Tap(object sender, point e)
        {
            // Create form
            Form frm = new Form("frm");

            /*
             * frm.AddChild(new Label("This is a label", 4, 4));
             * frm.AddChild(new RichTextLabel("This is a <b>Rich<i>Text</i><color '0,0,255'>Label</color></b>; it supports changing of fonts and colors.", 4, 24, frm.Width - 8, 34));
             *
             * Panel pnl = new Panel(192, 63, 100, 100, Colors.Wheat);
             * pnl.AddChild(new Label("This label is inside a panel! And to the left is a picturebox.", 0, 0, 100, 100));
             * frm.AddChild(pnl);
             *
             * frm.AddChild(new Picturebox(Resources.GetBitmap(Resources.BitmapResources.fblogo), 4, 63));
             *
             * CommandButton cmdBack = new CommandButton("< Go Back", 4, frmMain.Height - 29, 95, 25);
             * cmdBack.Tap += new OnTap((object sender, point e) => ShowMainForm());
             * frm.AddChild(cmdBack);
             */

            frm.AddChild(new Label("lbl", "This is a label", Fonts.Droid11, 4, 4));
            frm.AddChild(new RichTextLabel("rtl", "This is a <b>Rich<i>Text</i><color '0,0,255'>Label</color></b>; it supports changing of fonts and colors.", Fonts.Droid11, 4, 24, frm.Width - 8, 34));

            // Activate form
            Core.ActiveContainer = frm;
        }
Exemplo n.º 4
0
        public PlayerUnitframe(InterfaceManager manager)
            : base(manager)
        {
            unitFramePlate = new Form(manager)
            {
                Size = new Vector2(160, 54),
                Background = new BorderGraphic(manager.GlyphCache) { Border = manager.DefaultSlimBorder }
            };

            namePlate = new TextGraphic(manager.GlyphCache)
            {
                Overflow = TextOverflow.Ignore,
                Anchor = Orientation.Left,
                Font = manager.DefaultFont
            };

            teamClassBox = new TeamClassBox(InterfaceManager)
            {
                Position = new Vector3(1, 1, 0),
                Anchor = Orientation.TopRight
            };

            hpBar = new ProgressBar(InterfaceManager)
            {
                Text = "$value$ / $maxvalue$",
                Font = Font,
                Background = null,
                Position = new Vector3(0, 18, 0)
            };
            ((StretchingImageGraphic)hpBar.ProgressGraphic).Texture = manager.View.content.Get<Texture>("hpbar.tga");
            manaBar = new ProgressBar(InterfaceManager)
            {
                Text = "$value$ / $maxvalue$",
                Font = Font,
                Background = null,
                Position = new Vector3(0, 18*2, 0)
            };
            ((StretchingImageGraphic)manaBar.ProgressGraphic).Texture = manager.View.content.Get<Texture>("manabar.tga");

            activeBuffs = new ActiveBuffsPanel(manager)
            {
                Size = new Vector2(Size.X, 12+2*buffOffset),
                Position = new Vector3(0, 18*3+buffOffset, -1),
                BuffIconSize = 12,
                BuffsAnchor = Orientation.TopLeft
            };
            IsClickable = true;

            unitFramePlate.AddChild(teamClassBox);
            unitFramePlate.AddChild(hpBar);
            unitFramePlate.AddChild(manaBar);
            AddChild(unitFramePlate);
            AddChild(activeBuffs);

            namePlate.Construct(InterfaceManager.Device);
            Models["Nameplate"] = namePlate.Model;
        }
Exemplo n.º 5
0
        public static MenuStrip AddMenuStrip(this Form form, params MenuItem[] items)
        {
            var strip = new MenuStrip("MainMenu", Fonts.Droid11, items, 0, 0, form.Width, 28);

            form.AddChild(strip);
            return(strip);
        }
Exemplo n.º 6
0
        public void Start()
        {
            // Setup
            _prv      = Core.ActiveContainer;
            _frmModal = new Form("modalWaitForm", Colors.Ghost);
            Core.SilentlyActivate(_frmModal);

            Core.Screen.SetClippingRectangle(0, 0, _frmModal.Width, _frmModal.Height);
            Core.ShadowRegion(_x, _y, _w, _h);
            Core.Screen.DrawRectangle(0, 0, _x, _y, _w, 1, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 179);
            Core.Screen.DrawRectangle(0, 0, _x, _y + _h - 1, _w, 1, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 179);
            Core.Screen.DrawRectangle(0, 0, _x, _y + 1, 1, _h - 2, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 179);
            Core.Screen.DrawRectangle(0, 0, _x + _w - 1, _y + 1, 1, _h - 2, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 179);
            Core.Screen.DrawRectangle(0, 0, _x + 1, _y + 1, _w - 2, _h - 2, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 256);
            Core.Screen.DrawRectangle(0, 0, _x + 1, _y + 1, _w - 2, 1, 0, 0, Colors.White, 0, 0, Colors.White, 0, 0, 51);
            Core.Screen.DrawRectangle(0, 0, _x + 1, _y + 2, _w - 2, 1, 0, 0, Colors.White, 0, 0, Colors.White, 0, 0, 26);

            // Add Progressbar
            _prog = new Progressbar("prog1", _x + 16, _y + _h - ((_large) ? 38 : 31), _w - 32, ((_large) ? 22 : 15), _min, _max, _value);

            // Draw Text
            Core.Screen.DrawTextInRect(_text, _x + 16, _y + 16, _w - 32, _h - _prog.Height - 32, Bitmap.DT_WordWrap, Colors.CharcoalDust, _font);

            _frmModal.AddChild(_prog);
            Core.Screen.Flush(_x - 2, _y - 2, _w + 4, _h + 4);
        }
Exemplo n.º 7
0
        static void Test_lists()
        {
            var frm = new Form(0, 0, Console.WindowWidth, Console.WindowHeight)
            {
                Title = "Options"
            };

            frm.AddChild(new Label(2, 2, "Listbox"));
            var lb = new Listbox(2, 3, 10, 5, new[] { "Balin", "Dwalin",
                                                      "Kili", "Fili",
                                                      "Oin", "Gloin",
                                                      "Ori", "Nori", "Dori",
                                                      "Bifur", "Bofur", "Bombur",
                                                      "Thorin" });

            lb.Items[0].BackgroundColor = ConsoleColor.DarkYellow;
            lb.Items[1].ForegroundColor = ConsoleColor.Red;

            lb.OnPressed += (s, e) => MessageBox.ShowInfo("Dwarf selected: " + lb.Items[lb.CurrentItemIndex].Text);
            frm.AddChild(lb);

            frm.AddChild(new Label(2, 9, "Combobox"));
            var cb = new Combobox(2, 10, 21, 5, new[] { "Paris", "London", "Oslo", "Berlin", "New York", "Tokyo", "Rio", "Prague" })
            {
                Label = "Your favorite city"
            };

            frm.AddChild(cb);

            frm.AddChild(new Label(24, 10, 20)
            {
                Text            = "Press down-arrow to open list of choices.\nPress ESC to close list of choices.",
                CanBeMultiline  = true,
                ForegroundColor = ConsoleColor.DarkGray
            });

            frm.AddChild(new Label(2, 9, "Combobox with text limited to list items"));
            var cb2 = new Combobox(2, 12, 21, 4, new[] { "XS", "S", "M", "L", "XL", "XXL" })
            {
                Label            = "Select your t-shirt size",
                LimitTextToItems = true
            };

            frm.AddChild(cb2);

            frm.AddChild(new Button(2, 14, 10, "Close")
            {
                OnPressed = (s, e) => {
                    BashForms.Close();
                }
            });

            BashForms.Open(frm);
        }
Exemplo n.º 8
0
        private static void SetupMainForm()
        {
            // Step 4.1: Create the main form
            //             "mainForm":      Every control in Tinkr has a name
            //             Colors.DarkGray: Every Form has also a background color
            //           The width and height of a form is automatically set to screen size
            var frm = new Form("mainForm", Colors.DarkGray);

            // Step 4.2: Create a simple label
            //             "label":       The name of the label
            //             "Tutorial...": Text of the label
            //             Fonts.Droid12Bold: The font used to render the label
            //             10, 10:        The top left x and y coordinates of the label
            //           The size of the label is automatically calculated acoording to the content when using this constructor
            var label = new Label("label", "Tutorial 01: Getting started (NETMF)", Fonts.Droid12Bold, 10, 10);

            // Step 4.3: Add the label to the form
            //           Every control needs to be added to the form.
            //           Every control derived from Container can hold controls
            //           These contols are rendered recursively
            frm.AddChild(label);

            // Step 4.4: Create a button
            //             "button":      The name of the button
            //             "Show prompt": The content text of the button
            //             Fonts.Droid11: The font used to render the content text
            //             10, 40:        The top left x and y coordinates of the button
            //           The size of the button is automatically calculated according to the content when using this constructor
            var button = new Button("button", "Show prompt", Fonts.Droid11, 10, 40);

            // Step 4.5: Add a tap handler to the button
            //           The tap event is like the click event in a desktop application.
            //           But since NETMF devices usually have a touch screen it's called tap.
            button.Tap += ButtonOnTap;

            // Step 4.6: Add the button to the form
            frm.AddChild(button);

            // Step 4.7: Set the form as the active container.
            //           The active container is rendered and all touch events are directed to it.
            Core.ActiveContainer = frm;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Display demo selection screen
        /// </summary>
        private static void DemoSelect()
        {
            // Create form
            Form frm = new Form("frm", Colors.DarkGray);

            // Create menu
            MenuStrip ms = new MenuStrip("ms", Fonts.Droid9, 0, 0, frm.Width, 24);

            // Add menu items
            MenuItem miView = new MenuItem("miView", "View");

            ms.AddMenuItem(miView);

            // "View" sub items
            MenuItem miBasic = new MenuItem("miBasic", "Basic Controls");

            miBasic.Tap += new OnTap(miBasic_Tap);
            miView.AddMenuItem(miBasic);

            MenuItem miCollection = new MenuItem("miCollection", "Collection Controls");

            miView.AddMenuItem(miCollection);

            MenuItem miInput = new MenuItem("miInput", "Input Controls");

            miView.AddMenuItem(miInput);

            MenuItem miDialogs = new MenuItem("miDialogs", "Dialogs");

            miView.AddMenuItem(miDialogs);

            // "Dialogs" sub items
            MenuItem midPrompt = new MenuItem("midPrompt", "Prompt Dialog");

            miDialogs.AddMenuItem(midPrompt);

            MenuItem midSel = new MenuItem("midSel", "Selection Dialog");

            miDialogs.AddMenuItem(midSel);

            MenuItem midOpen = new MenuItem("midOpen", "Open File Dialog");

            miDialogs.AddMenuItem(midOpen);

            MenuItem midSave = new MenuItem("midSave", "Save File Dialog");

            miDialogs.AddMenuItem(midSave);

            // Add menu to form
            frm.AddChild(ms);

            // Activate form
            Core.ActiveContainer = frm;
        }
Exemplo n.º 10
0
        static void Testbed()
        {
            // Create the main form
            Form frmMain = new Form("frmMain");

            // Add a button
            Button btn1 = new Button("btn1", "Launch Sample App", Fonts.Droid16, 4, 4);

            //btn1.Tap += (object sender, point e) => new Thread(LaunchApp).Start();
            frmMain.AddChild(btn1);

            // Activate the form
            Core.ActiveContainer = frmMain;
        }
Exemplo n.º 11
0
        private Panel GetNewRootPanel()
        {
            var c = _form.GetChildByName("Root");

            if (c != null)
            {
                _form.RemoveChild(c);
                c.Dispose();
            }
            var p = new Panel("Root", 0, 28, _form.Width, _form.Height - 28);

            _form.AddChild(p);
            return(p);
        }
Exemplo n.º 12
0
        private static int InternalShow(ListboxItem[] values, Font font, int defaultSelection = 0, bool zebraStripe = false)
        {
            IContainer prv      = Core.ActiveContainer;
            var        frmModal = new Form("modalAlertForm");
            var        btn1     = new Button("btnModal", "Select", font, 0, 0);

            btn1.X = frmModal.Width - btn1.Width - 4;
            btn1.Y = frmModal.Height - btn1.Height - 4;

            btn1.BorderColor        = ColorUtility.ColorFromRGB(13, 86, 124);
            btn1.NormalColorTop     = Colors.LightBlue;
            btn1.NormalColorBottom  = ColorUtility.ColorFromRGB(26, 129, 182);
            btn1.PressedColorBottom = Colors.LightBlue;
            btn1.PressedColorTop    = btn1.NormalColorBottom;
            btn1.NormalTextColor    = Colors.White;
            btn1.PressedTextColor   = Colors.White;

            var lst1 = new Listbox("lstModal", font, 4, 4, frmModal.Width - 8, frmModal.Height - btn1.Height - 12, values)
            {
                ZebraStripe = zebraStripe
            };

            lst1.SelectedIndexChanged += delegate { btn1.Enabled = lst1.SelectedIndex > -1; };
            lst1.SelectedIndex         = defaultSelection;

            btn1.Tap += delegate { Unblock(lst1.SelectedIndex); };

            frmModal.AddChild(lst1);
            frmModal.AddChild(btn1);

            Core.ActiveContainer = frmModal;

            ModalBlock();

            Core.ActiveContainer = prv;
            return(_selIndex);
        }
Exemplo n.º 13
0
        static void Test_filesystemdlg()
        {
            var frm = new Form(0, 0, Console.WindowWidth, Console.WindowHeight)
            {
                Title = "Filesystem Dialog"
            };

            frm.AddChild(new Label(2, 2, "Path to open dialog on: "));
            frm.AddChild(new TextLine(26, 2, 20)
            {
                Text = "../..", Name = "txtPath"
            });
            frm.AddChild(new Option(26, 3, 20, "Directories only")
            {
                Name = "optDirsOnly"
            });
            frm.AddChild(new Option(26, 4, 20, "Allow new name")
            {
                Name = "optNewFileOrFoldername"
            });
            frm.AddChild(new Listbox(50, 2, 20, 20)
            {
                Name = "lbSelected", TabIndex = -1, BackgroundColor = ConsoleColor.DarkGray
            });

            frm.AddChild(new Button(26, 5, 10, "Open...")
            {
                OnPressed = (s, e) => {
                    var fsdlg = new FilesystemDialog(frm.Child <TextLine>("txtPath").Text)
                    {
                        ListDirectoriesOnly      = frm.Child <Option>("optDirsOnly").Selected,
                        AllowNewFileOrFoldername = frm.Child <Option>("optNewFileOrFoldername").Selected
                    };
                    var selection = BashForms.OpenModal(fsdlg);

                    frm.Child <Listbox>("lbSelected").Clear();
                    frm.Child <Listbox>("lbSelected").AddRange(selection.Select(fn => new Listbox.Item(fn)));
                }
            });

            frm.AddChild(new Button(26, 7, 10, "Close")
            {
                OnPressed = (s, e) => BashForms.Close()
            });

            BashForms.Open(frm);
        }
Exemplo n.º 14
0
        public MainWindow()
        {
            _frm = new Form(0, 0, Console.WindowWidth, Console.WindowHeight)
            {
                Title = "ToDoBeDoBeDo Task Management"
            };

            _frm.MenuBar.Menu.AddItem(new MenuItem("File")).Submenu.AddItem(new MenuItem("Close", "mnuClose")
            {
                Shortcut = 'x'
            });

            _frm.MenuBar.Menu.AddItem(new MenuItem("Edit")).Submenu.AddItems(new[] {
                new MenuItem("Add", "mnuAdd")
                {
                    Shortcut = '+'
                },
                new MenuItem("Delete", "mnuDel")
                {
                    Shortcut = '-'
                }
            });

            var mnuFilterOverdue = new MenuItem("Filter for overdue", "mnuFilterOverdue");
            var mnuFilterDue     = new MenuItem("Filter for due", "mnuFilterDue");
            var mnuFilterASAP    = new MenuItem("Filter for ASAP", "mnuFilterASAP");

            _frm.MenuBar.Menu.AddItem(new MenuItem("View")).Submenu.AddItems(new[] {
                mnuFilterOverdue, mnuFilterDue, mnuFilterASAP
            });

            _frm.MenuBar.OnSelected += (item, e) => {
                switch (item.Name)
                {
                case "mnuAdd":
                    OnNewTaskRequest();
                    _frm.MenuBar.HasFocus = false;
                    break;

                case "mnuDel":
                    if (_lstTasks.CurrentItemIndex >= 0 && MessageBox.AskForYes("Delete current item?"))
                    {
                        OnDeleteTaskRequest((string)_lstTasks.CurrentItem.Attachment);
                    }
                    _frm.MenuBar.HasFocus = false;
                    break;

                case "mnuFilterOverdue":
                case "mnuFilterDue":
                case "mnuFilterASAP":
                    item.Checked = !item.Checked;
                    OnQueryTasksRequest(Build_query());
                    break;

                case "mnuClose":
                    BashForms.Close();
                    _frm.MenuBar.HasFocus = false;
                    break;
                }
            };


            const int SUBJECT_COL_WIDTH = 20;
            const int DESC_COL_WIDTH    = 30;
            const int DUE_COL_WIDTH     = 10;
            const int PRIO_COL_WIDTH    = 13;

            _frm.AddChild(new Label(2, 2, "Subject".PadRight(SUBJECT_COL_WIDTH) + "|" + "Description".PadRight(DESC_COL_WIDTH) + "|" + "Due".PadRight(DUE_COL_WIDTH) + "|" + "Priority".PadRight(PRIO_COL_WIDTH))
            {
                BackgroundColor = ConsoleColor.DarkBlue,
                ForegroundColor = ConsoleColor.White
            });

            _lstTasks = new Listbox(2, 3, _frm.Size.width - 4, _frm.Size.height - 6)
            {
                FocusBackgroundColor = ConsoleColor.Black,
                Columns = new[] { SUBJECT_COL_WIDTH, DESC_COL_WIDTH, DUE_COL_WIDTH, PRIO_COL_WIDTH }
            };

            _lstTasks.OnPressed = (w, e) => {
                if (_lstTasks.CurrentItemIndex >= 0)
                {
                    OnEditTaskRequest((string)_lstTasks.CurrentItem.Attachment);
                }
            };
            _frm.AddChild(_lstTasks);

            _txtQuery = new TextLine(2, _lstTasks.Position.top + _lstTasks.Size.height + 1, 45)
            {
                Label = "query: words or #tags separated by spaces"
            };
            _frm.AddChild(_txtQuery);

            _frm.AddChild(new Button(_txtQuery.Position.left + _txtQuery.Size.width + 2, _txtQuery.Position.top, 10, "Filter")
            {
                OnPressed = (s, e) => {
                    OnQueryTasksRequest(Build_query());
                }
            });


            string Build_query()
            {
                var query = _txtQuery.Text;

                if (mnuFilterOverdue.Checked)
                {
                    query += " !overdue";
                }
                if (mnuFilterDue.Checked)
                {
                    query += " !due";
                }
                if (mnuFilterASAP.Checked)
                {
                    query += " !asap";
                }
                return(query);
            }
        }
Exemplo n.º 15
0
        public override void Enter()
        {
            var interfaceManager = Program.Instance.InterfaceManager;

            interfaceManager.Add(new Control(interfaceManager)
            {
                Background = new StretchingImageGraphic(interfaceManager.GlyphCache)
                {
                    Size = new Vector2(1300, 1585),
                    Texture = Program.Instance.content.Get<Texture>("lobbyBackground.jpg")
                },
                Size = new Vector2(1300, 1585),
                Position = new Vector3(0, 0, 90)
            });
            Form form = new Form(interfaceManager)
            {
                Size = new Vector2(200, 250),
                Anchor = Orientation.Center,
                Position = new Vector3(0, 0, 50)
            };

            form.AddChild(new TextBox(interfaceManager)
            {
                Font = Program.Instance.BigFont,
                Text = "Battle of the Clans",
                Position = new Vector3(0, -50, 0),
                TextAnchor = Orientation.Top,
                Anchor = Orientation.Top,
                Size = new Vector2(600, 60),
                Background = null,
                ReadOnly = true
            });

            int y = 10;

            form.AddChild(new TextBox(interfaceManager)
            {
                Size = new Vector2(150, 16),
                Text = "Nick",
                Position = new Vector3(10, y, 0),
                Background = null,
                ReadOnly = true
            });
            nick = new TextBox(interfaceManager)
            {
                Size = new Vector2(180, 20),
                Text = (String)System.Windows.Forms.Application.UserAppDataRegistry.GetValue("LastNick", ""),
                Position = new Vector3(10, y + 16, 0)
            };
            form.AddChild(nick);
            y += 40;
            form.AddChild(new TextBox(interfaceManager)
            {
                Size = new Vector2(150, 16),
                Text = "Address",
                Position = new Vector3(10, y, 0),
                Background = null,
                ReadOnly = true
            });
            address = new TextBox(interfaceManager)
            {
                Size = new Vector2(180, 20),
                Text = (String)System.Windows.Forms.Application.UserAppDataRegistry.GetValue("LastAddr", "127.0.0.1"),
                Position = new Vector3(10, y + 16, 0)
            };
            form.AddChild(address);
            y += 40;
            form.AddChild(new TextBox(interfaceManager)
            {
                Size = new Vector2(150, 16),
                Text = "Port",
                Position = new Vector3(10, y, 0),
                Background = null,
                ReadOnly = true
            });
            port = new TextBox(interfaceManager)
            {
                Size = new Vector2(180, 20),
                Text = (String)System.Windows.Forms.Application.UserAppDataRegistry.GetValue("LastPort", "4777"),
                Position = new Vector3(10, y + 16, 0)
            };
            form.AddChild(port);
            y += 40;
            form.AddChild(new TextBox(interfaceManager)
            {
                Size = new Vector2(150, 16),
                Text = "Map",
                Position = new Vector3(10, y, 0),
                Background = null,
                ReadOnly = true
            });
            map = new TextBox(interfaceManager)
            {
                Size = new Vector2(180, 20),
                Text = (String)System.Windows.Forms.Application.UserAppDataRegistry.GetValue("LastMap", "Test"),
                Position = new Vector3(10, y + 16, 0)
            };
            form.AddChild(map);
            y += 40;
            form.AddChild(new TextBox(interfaceManager)
            {
                Size = new Vector2(150, 16),
                Text = "Store Combat Log",
                Position = new Vector3(10, y, 0),
                Background = null,
                ReadOnly = true
            });
            storeCombatLog = new Checkbox(interfaceManager)
            {
                Checked = ((String)System.Windows.Forms.Application.UserAppDataRegistry.GetValue("StoreCombatLog", "False")) == "True",
                Position = new Vector3(10, y + 16, 0)
            };
            form.AddChild(storeCombatLog);

            Button connect = new Button(interfaceManager)
            {
                Size = new Vector2(80, 20),
                Text = "Connect",
                Position = new Vector3(10, 10, 0),
                Anchor = Orientation.BottomRight
            };
            connect.Click += new EventHandler((object o, EventArgs e) => {
                System.Windows.Forms.Application.UserAppDataRegistry.SetValue("LastNick", nick.Text);
                System.Windows.Forms.Application.UserAppDataRegistry.SetValue("LastAddr", address.Text);
                System.Windows.Forms.Application.UserAppDataRegistry.SetValue("LastPort", port.Text);
                Program.Instance.ChangeState(new ConnectingState(nick.Text, address.Text, int.Parse(port.Text))); });
            form.AddChild(connect);

            Button host = new Button(interfaceManager)
            {
                Size = new Vector2(80, 20),
                Text = "Host",
                Position = new Vector3(10, 10, 0),
                Anchor = Orientation.BottomLeft
            };
            host.Click += new EventHandler((object o, EventArgs e) =>
            {
                System.Windows.Forms.Application.UserAppDataRegistry.SetValue("LastNick", nick.Text);
                System.Windows.Forms.Application.UserAppDataRegistry.SetValue("LastPort", port.Text);
                System.Windows.Forms.Application.UserAppDataRegistry.SetValue("LastMap", map.Text);
                System.Windows.Forms.Application.UserAppDataRegistry.SetValue("StoreCombatLog", storeCombatLog.Checked);
                Program.Instance.Server = new Server.Server_(map.Text, int.Parse(port.Text), storeCombatLog.Checked);
                Program.Instance.ChangeState(new ConnectingState(nick.Text, "127.0.0.1", int.Parse(port.Text)));
            });
            form.AddChild(host);
            interfaceManager.Add(form);
        }
 public void MessageBox(String message)
 {
     Form f = new Form
     {
         Anchor = Orientation.Center,
         Size = new Vector2(200, 150),
         Clickable = true
     };
     Label t = new Label
     {
         Text = message,
         TextAnchor = Orientation.Center,
         Anchor = Orientation.Top,
         Size = new Vector2(200, 100),
         Background = null,
         Position = new Vector2(0, 10),
     };
     f.AddChild(t);
     Button b = new Button
     {
         Text = "Ok",
         Anchor = Orientation.Bottom,
         Position = new Vector2(0, 10),
         Size = new Vector2(100, 20)
     };
     b.MouseClick += new System.Windows.Forms.MouseEventHandler((e, o) => f.Remove());
     f.AddChild(b);
     Root.AddChild(f);
 }
Exemplo n.º 17
0
        static void Test_messageboxes()
        {
            var frm = new Form(0, 0, Console.WindowWidth, Console.WindowHeight)
            {
                Title = "MessageBox"
            };

            frm.AddChild(new Label(2, 2, "Messagebox result:"));
            frm.AddChild(new Label(2, 3, 18)
            {
                BackgroundColor = ConsoleColor.DarkRed, Name = "lblResult"
            });

            frm.MenuBar.Menu.AddItem("Ok");
            frm.MenuBar.Menu.AddItem("YesNo");
            frm.MenuBar.Menu.AddItem("OkCancelIgnore");
            frm.MenuBar.Menu.AddItem("None");
            frm.MenuBar.Menu.AddItem("Exit");

            frm.MenuBar.OnSelected += (mnuItem, e) =>
            {
                switch (mnuItem.Text)
                {
                case "Ok":
                    var result = MessageBox.Show("Gimme an ok!", (MessageBox.Results.Ok, "Okay!"));
                    frm.Child <Label>("lblResult").Text = result.ToString();
                    break;

                case "YesNo":
                    result = MessageBox.Show("Shall I?",
                                             (MessageBox.Results.Yes, "YES"),
                                             (MessageBox.Results.No, "No,no!"),
                                             "Question");
                    frm.Child <Label>("lblResult").Text = result.ToString();
                    break;

                case "OkCancelIgnore":
                    result = MessageBox.Show("Shall I?",
                                             (MessageBox.Results.Continue, "Continue"),
                                             (MessageBox.Results.Cancel, "Cancel"),
                                             (MessageBox.Results.Ignore, "Never mind"),
                                             "What's your choice?");
                    frm.Child <Label>("lblResult").Text = result.ToString();
                    break;

                case "None":
                    result = MessageBox.Show("I am confused",
                                             (MessageBox.Results.None, "Continue"),
                                             (MessageBox.Results.None, "Cancel"),
                                             (MessageBox.Results.None, "Never mind"),
                                             "No choice?");
                    frm.Child <Label>("lblResult").Text = result.ToString();
                    break;

                case "Exit":
                    BashForms.Close();
                    break;
                }
            };

            frm.AddChild(new Label(2, 5, 40, "Switch to the menu with F2 and choose a MessageBox demo.\n\nIn the message boxes use (shift-)TAB to switch between buttons.")
            {
                ForegroundColor = ConsoleColor.DarkGray
            });

            BashForms.Open(frm);
        }
Exemplo n.º 18
0
        public static PromptResult Show(string title, string message, Font titleFont, Font messageFont, PromptType type = PromptType.OK, Bitmap icon = null)
        {
            int w, h, y, i;
            int xOffset = 0;

            Core.Screen.SetClippingRectangle(0, 0, Core.ScreenWidth, Core.ScreenHeight);

            Color cR1 = ColorUtility.ColorFromRGB(226, 92, 79);
            Color cR2 = ColorUtility.ColorFromRGB(202, 48, 53);

            IContainer prv      = Core.ActiveContainer;
            var        frmModal = new Form("modalAlertForm", Colors.Ghost);

            frmModal.TouchDown += frmModal_TouchDown;
            frmModal.TouchUp   += frmModal_TouchUp;
            Core.SilentlyActivate(frmModal);

            // Determine required size
            titleFont.ComputeExtent(title, out w, out h);
            size sz = FontManager.ComputeExtentEx(messageFont, message);

            if (sz.Width > w)
            {
                w = sz.Width;
            }

            if (icon != null)
            {
                xOffset = icon.Width + 16;
                w      += xOffset;
            }

            // Adjust for Buttons
            switch (type)
            {
            case PromptType.AbortContinue:
                i = FontManager.ComputeExtentEx(messageFont, "AbortContinue").Width + 30;
                break;

            case PromptType.AbortRetryContinue:
                i = FontManager.ComputeExtentEx(messageFont, "AbortRetryContinue").Width + 40;
                break;

            case PromptType.OKCancel:
                i = FontManager.ComputeExtentEx(messageFont, "   OK   Cancel").Width + 30;
                break;

            case PromptType.YesNo:
                i = FontManager.ComputeExtentEx(messageFont, "  Yes     No   ").Width + 30;
                break;

            case PromptType.YesNoCancel:
                i = FontManager.ComputeExtentEx(messageFont, "  Yes     No   Cancel").Width + 30;
                break;

            default:
                i = FontManager.ComputeExtentEx(messageFont, "   OK   ").Width + 20;
                break;
            }
            if (w < i)
            {
                w = i;
            }

            // Add Padding
            w += 32;

            // Now make sure we're within the screen width
            if (w > Core.ScreenWidth - 32)
            {
                w = Core.ScreenWidth - 32;
            }

            // Get height of the 2 strings
            messageFont.ComputeTextInRect(message, out y, out i, w - 32 - xOffset);
            if (icon != null && i < icon.Height)
            {
                i = icon.Height;
            }
            h = i + titleFont.Height + 74 + (messageFont.Height);

            // Check the height in screen
            if (h > Core.ScreenHeight - 32)
            {
                h = Core.ScreenHeight - 32;
            }

            // Center
            int x = Core.ScreenWidth / 2 - w / 2;

            y = Core.ScreenHeight / 2 - h / 2;

            Core.ShadowRegion(x, y, w, h);
            Core.Screen.DrawRectangle(0, 0, x, y, w, 1, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 179);
            Core.Screen.DrawRectangle(0, 0, x, y + h - 1, w, 1, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 179);
            Core.Screen.DrawRectangle(0, 0, x, y + 1, 1, h - 2, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 179);
            Core.Screen.DrawRectangle(0, 0, x + w - 1, y + 1, 1, h - 2, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 179);
            Core.Screen.DrawRectangle(0, 0, x + 1, y + 1, w - 2, h - 2, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 256);
            Core.Screen.DrawRectangle(0, 0, x + 1, y + 1, w - 2, 1, 0, 0, Colors.White, 0, 0, Colors.White, 0, 0, 51);
            Core.Screen.DrawRectangle(0, 0, x + 1, y + 2, w - 2, 1, 0, 0, Colors.White, 0, 0, Colors.White, 0, 0, 26);

            // Tilebar text
            Core.Screen.DrawTextInRect(title, x + 16 + xOffset, y + 16, w - 32 - xOffset, titleFont.Height, Bitmap.DT_TrimmingCharacterEllipsis, Colors.CharcoalDust, titleFont);

            // Body text
            Core.Screen.DrawTextInRect(message, x + 16 + xOffset, y + 32 + titleFont.Height, w - 32 - xOffset, h - 74 - titleFont.Height, Bitmap.DT_TrimmingCharacterEllipsis + Bitmap.DT_WordWrap, Colors.CharcoalDust, messageFont);

            // Icon
            if (icon != null)
            {
                Core.Screen.DrawImage(x + 16, y + 16, icon, 0, 0, icon.Width, icon.Height);
            }

            // Buttons
            x = Core.ScreenWidth / 2 - w / 2;
            y = Core.ScreenHeight / 2 - h / 2;
            switch (type)
            {
            case PromptType.AbortContinue:
                _btns    = new Button[2];
                _btns[1] = new Button("btnContinue", "Continue", messageFont, 0, y + h - messageFont.Height - 26);
                _btns[0] = new Button("btnAbort", "Abort", messageFont, 0, _btns[1].Y, Colors.White, Colors.White, Colors.DarkRed, Colors.DarkRed)
                {
                    NormalColorTop     = cR1,
                    NormalColorBottom  = cR2,
                    PressedColorTop    = cR2,
                    PressedColorBottom = cR1
                };
                _btns[1].Tap += (sender, e) => EndModal(PromptResult.Continue);
                _btns[0].Tap += (sender, e) => EndModal(PromptResult.Abort);

                x          = x + (w / 2) - ((_btns[1].Width + _btns[0].Width + 16) / 2);
                _btns[0].X = x;
                _btns[1].X = x + _btns[0].Width + 16;
                break;

            case PromptType.AbortRetryContinue:
                _btns    = new Button[3];
                _btns[2] = new Button("btnContinue", "Continue", messageFont, 0, y + h - messageFont.Height - 26);
                _btns[1] = new Button("btnRetry", "Retry", messageFont, 0, _btns[2].Y);
                _btns[0] = new Button("btnAbort", "Abort", messageFont, 0, _btns[1].Y, Colors.White, Colors.White, Colors.DarkRed, Colors.DarkRed)
                {
                    NormalColorTop     = cR1,
                    NormalColorBottom  = cR2,
                    PressedColorTop    = cR2,
                    PressedColorBottom = cR1
                };
                _btns[2].Tap += (sender, e) => EndModal(PromptResult.Continue);
                _btns[1].Tap += (sender, e) => EndModal(PromptResult.Retry);
                _btns[0].Tap += (sender, e) => EndModal(PromptResult.Abort);


                x          = x + (w / 2) - ((_btns[2].Width + _btns[1].Width + _btns[0].Width + 32) / 2);
                _btns[0].X = x;
                _btns[1].X = x + _btns[0].Width + 16;
                _btns[2].X = x + _btns[0].Width + _btns[1].Width + 32;
                break;

            case PromptType.OKCancel:
                _btns    = new Button[2];
                _btns[1] = new Button("btnCancel", "Cancel", messageFont, 0, y + h - messageFont.Height - 26, Colors.White, Colors.White, Colors.DarkRed, Colors.DarkRed)
                {
                    NormalColorTop     = cR1,
                    NormalColorBottom  = cR2,
                    PressedColorTop    = cR2,
                    PressedColorBottom = cR1
                };
                _btns[0]      = new Button("btnOK", "  OK  ", messageFont, 0, _btns[1].Y);
                _btns[1].Tap += (sender, e) => EndModal(PromptResult.Cancel);
                _btns[0].Tap += (sender, e) => EndModal(PromptResult.OK);


                x          = x + (w / 2) - ((_btns[1].Width + _btns[0].Width + 16) / 2);
                _btns[0].X = x;
                _btns[1].X = x + _btns[0].Width + 16;
                break;

            case PromptType.YesNo:
                _btns    = new Button[2];
                _btns[1] = new Button("btnNo", "  No  ", messageFont, 0, y + h - messageFont.Height - 26, Colors.White, Colors.White, Colors.DarkRed, Colors.DarkRed)
                {
                    NormalColorTop     = cR1,
                    NormalColorBottom  = cR2,
                    PressedColorTop    = cR2,
                    PressedColorBottom = cR1
                };
                _btns[0]      = new Button("btnYes", " Yes ", messageFont, 0, _btns[1].Y);
                _btns[1].Tap += (sender, e) => EndModal(PromptResult.No);
                _btns[0].Tap += (sender, e) => EndModal(PromptResult.Yes);


                x          = x + (w / 2) - ((_btns[1].Width + _btns[0].Width + 16) / 2);
                _btns[0].X = x;
                _btns[1].X = x + _btns[0].Width + 16;
                break;

            case PromptType.YesNoCancel:
                _btns    = new Button[3];
                _btns[2] = new Button("btnCancel", "Cancel", messageFont, 0, y + h - messageFont.Height - 26, Colors.White, Colors.White, Colors.DarkRed, Colors.DarkRed)
                {
                    NormalColorTop     = cR1,
                    NormalColorBottom  = cR2,
                    PressedColorTop    = cR2,
                    PressedColorBottom = cR1
                };
                _btns[1]      = new Button("btnNo", "  No  ", messageFont, 0, y + h - messageFont.Height - 26);
                _btns[0]      = new Button("btnYes", " Yes ", messageFont, 0, _btns[1].Y);
                _btns[2].Tap += (sender, e) => EndModal(PromptResult.Cancel);
                _btns[1].Tap += (sender, e) => EndModal(PromptResult.No);
                _btns[0].Tap += (sender, e) => EndModal(PromptResult.Yes);


                x          = x + (w / 2) - ((_btns[2].Width + _btns[1].Width + _btns[0].Width + 32) / 2);
                _btns[0].X = x;
                _btns[1].X = x + _btns[0].Width + 16;
                _btns[2].X = x + _btns[0].Width + _btns[1].Width + 32;
                break;

            default:
                _btns         = new Button[1];
                _btns[0]      = new Button("btnOK", "  OK  ", messageFont, 0, y + h - messageFont.Height - 26);
                _btns[0].Tap += (sender, e) => EndModal(PromptResult.OK);

                _btns[0].X = x + (w / 2) - (_btns[0].Width / 2);
                break;
            }

            // Add Buttons
            for (i = 0; i < _btns.Length; i++)
            {
                frmModal.AddChild(_btns[i]);
            }

            Core.Screen.Flush();

            ModalBlock();

            Core.ActiveContainer = prv;

            return(_result);
        }
Exemplo n.º 19
0
        static void Choose_a_demo()
        {
            var frm = new Form(0, 0, Console.WindowWidth, Console.WindowHeight)
            {
                Title = "Choose a demo"
            };
            var mnusw = frm.MenuBar.Menu.AddItem("Single widgets");

            mnusw.Submenu.AddItem("Lbls", "mnuLabels");
            mnusw.Submenu.AddItem("Texts", "mnuText");
            mnusw.Submenu.AddItem("Options", "mnuOptions");
            mnusw.Submenu.AddItem("Lists", "mnuLists");

            mnusw.Submenu.AddItem("Dialogs")
            .Submenu.AddItems(new[] {
                new MenuItem("MsgBox", "mnuMsgBox"),
                new MenuItem("FileSys", "mnuFileSys")
            });
            var mnusc = frm.MenuBar.Menu.AddItem("Scenarios");

            mnusc.Submenu.AddItem("ToDo App", "mnuToDo");
            frm.MenuBar.Menu.AddItem("Exit", "mnuExit");

            frm.MenuBar.OnSelected += (mnuItem, e) => {
                switch (mnuItem.Name)
                {
                case "mnuExit":
                    BashForms.Close();
                    break;

                case "mnuLabels":
                    Test_labels();
                    break;

                case "mnuText":
                    Test_text_editing();
                    break;

                case "mnuOptions":
                    Test_options();
                    break;

                case "mnuLists":
                    Test_lists();
                    break;

                case "mnuMsgBox":
                    Test_messageboxes();
                    break;

                case "mnuFileSys":
                    Test_filesystemdlg();
                    break;

                case "mnuToDo":
                    ToDoApp.Enterypoint();
                    break;
                }
            };

            frm.AddChild(new Label(2, 3, 40)
            {
                Text            = "* Press F2 to enter menu.\n* Use left/right arrow to move between menu item.\n* Use ENTER to select menu item/enter next menu level.\n* Use ESC to back up menu level.\n\n* Use (shift-)TAB to move between controls.\n\n* Use F5 to refresh screen.",
                CanBeMultiline  = true,
                ForegroundColor = ConsoleColor.DarkGray
            });

            BashForms.Open(frm);
        }
Exemplo n.º 20
0
        static void Test_options()
        {
            var frm = new Form(0, 0, Console.WindowWidth, Console.WindowHeight)
            {
                Title = "Options"
            };

            frm.AddChild(new Label(2, 2, "Which animals are mammals?"));
            frm.AddChild(new Option(4, 3, 20, "Dog")
            {
                Name = "optDog"
            });
            frm.AddChild(new Option(4, 4, 20, "Ant")
            {
                Name = "optAnt"
            });
            frm.AddChild(new Option(4, 5, 20, "Cat")
            {
                Name = "optCat"
            });
            frm.AddChild(new Option(4, 6, 20, "Dolphin")
            {
                Name = "optDolphin"
            });
            frm.AddChild(new Button(4, 7, 10, "Check")
            {
                OnPressed = (s, _) => {
                    var correct = frm.Child <Option>("optDog").Selected&& frm.Child <Option>("optCat").Selected&&
                                  frm.Child <Option>("optDolphin").Selected&&
                                  !frm.Child <Option>("optAnt").Selected;
                    MessageBox.ShowInfo(correct ? "Correct! You're the best!" : "Sorry, wrong. Try again", " Quiz Result");
                }
            });

            frm.AddChild(new Label(2, 9, "Who's your favorite hero?"));
            var grp = new SingleOptionGroup();

            grp.OnSelected += (s, _) => MessageBox.ShowInfo("Good choice: " + s.Text);
            frm.AddChild(new Option(4, 10, 20, "Superman")
            {
                OptionGroup = grp
            });
            frm.AddChild(new Option(4, 11, 20, "Donald Duck")
            {
                OptionGroup = grp
            });
            frm.AddChild(new Option(4, 12, 20, "Batman")
            {
                OptionGroup = grp
            });
            frm.AddChild(new Option(4, 13, 20, "Antman")
            {
                OptionGroup = grp
            });

            frm.AddChild(new Label(32, 2, 30, "Move between the options using (shift-)TAB!\nEach is a control of its own.\n\nPress ENTER or SPACE to toggle an option.")
            {
                ForegroundColor = ConsoleColor.DarkGray
            });

            frm.AddChild(new Button(2, 15, 10, "Close")
            {
                OnPressed = (s, e) => {
                    BashForms.Close();
                }
            });

            BashForms.Open(frm);
        }
Exemplo n.º 21
0
        public static int Show(string title, string message, string[] buttonOptions, Font titleFont, Font messageFont, Bitmap icon = null)
        {
            int w, h, y, i;
            int xOffset = 0;
            int btnsW   = 16;

            // Create Buttons first this time
            _btns = new Button[buttonOptions.Length];
            for (i = 0; i < _btns.Length; i++)
            {
                _btns[i] = new Button("btn" + i, buttonOptions[i], messageFont, 0, 0);
                btnsW   += _btns[i].Width + 16;
            }

            Core.Screen.SetClippingRectangle(0, 0, Core.ScreenWidth, Core.ScreenHeight);

            //Color cR1 = ColorUtility.ColorFromRGB(226, 92, 79);
            //Color cR2 = ColorUtility.ColorFromRGB(202, 48, 53);

            IContainer prv      = Core.ActiveContainer;
            var        frmModal = new Form("modalAlertForm", Colors.Ghost);

            frmModal.TouchDown += frmModal_TouchDown;
            frmModal.TouchUp   += frmModal_TouchUp;
            Core.SilentlyActivate(frmModal);

            // Determine required size
            titleFont.ComputeExtent(title, out w, out h);
            size sz = FontManager.ComputeExtentEx(messageFont, message);

            if (sz.Width > w)
            {
                w = sz.Width;
            }

            if (icon != null)
            {
                xOffset = icon.Width + 16;
                w      += xOffset;
            }

            // Adjust for button sizes
            if (w < btnsW)
            {
                w = btnsW;
            }

            // Add Padding
            w += 32;

            // Now make sure we're within the screen width
            if (w > Core.ScreenWidth - 32)
            {
                w = Core.ScreenWidth - 32;
            }

            // Get height of the 2 strings
            messageFont.ComputeTextInRect(message, out y, out i, w - 32 - xOffset);
            if (icon != null && i < icon.Height)
            {
                i = icon.Height;
            }
            h = i + titleFont.Height + 74 + (messageFont.Height);

            // Check the height in screen
            if (h > Core.ScreenHeight - 32)
            {
                h = Core.ScreenHeight - 32;
            }

            // Center
            int x = Core.ScreenWidth / 2 - w / 2;

            y = Core.ScreenHeight / 2 - h / 2;

            Core.ShadowRegion(x, y, w, h);
            Core.Screen.DrawRectangle(0, 0, x, y, w, 1, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 179);
            Core.Screen.DrawRectangle(0, 0, x, y + h - 1, w, 1, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 179);
            Core.Screen.DrawRectangle(0, 0, x, y + 1, 1, h - 2, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 179);
            Core.Screen.DrawRectangle(0, 0, x + w - 1, y + 1, 1, h - 2, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 179);
            Core.Screen.DrawRectangle(0, 0, x + 1, y + 1, w - 2, h - 2, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 256);
            Core.Screen.DrawRectangle(0, 0, x + 1, y + 1, w - 2, 1, 0, 0, Colors.White, 0, 0, Colors.White, 0, 0, 51);
            Core.Screen.DrawRectangle(0, 0, x + 1, y + 2, w - 2, 1, 0, 0, Colors.White, 0, 0, Colors.White, 0, 0, 26);

            // Tilebar text
            Core.Screen.DrawTextInRect(title, x + 16 + xOffset, y + 16, w - 32 - xOffset, titleFont.Height, Bitmap.DT_TrimmingCharacterEllipsis, Colors.CharcoalDust, titleFont);

            // Body text
            Core.Screen.DrawTextInRect(message, x + 16 + xOffset, y + 32 + titleFont.Height, w - 32 - xOffset, h - 74 - titleFont.Height, Bitmap.DT_TrimmingCharacterEllipsis + Bitmap.DT_WordWrap, Colors.CharcoalDust, messageFont);

            // Icon
            if (icon != null)
            {
                Core.Screen.DrawImage(x + 16, y + 16, icon, 0, 0, icon.Width, icon.Height);
            }

            // Position Buttons
            x = x + (w / 2) - (btnsW / 2);
            for (i = 0; i < _btns.Length; i++)
            {
                _btns[i].Tag  = i;
                _btns[i].Y    = y + h - 16 - _btns[i].Height;
                _btns[i].X    = x;
                x            += _btns[i].Width + 16;
                _btns[i].Tap += (sender, e) => EndModal((Button)sender);
                frmModal.AddChild(_btns[i]);
            }

            Core.Screen.Flush();

            ModalBlock();

            Core.ActiveContainer = prv;

            return(_iResult);
        }
Exemplo n.º 22
0
        public static string Show(string title, Font titleFont, Font bodyFont)
        {
            IContainer prv      = Core.ActiveContainer;
            var        frmModal = new Form("modalAlertForm", Colors.Ghost);

            _result = string.Empty;

            Core.Screen.SetClippingRectangle(0, 0, frmModal.Width, frmModal.Height);
            Core.Screen.DrawRectangle(0, 0, 4, 4, frmModal.Width - 8, frmModal.Height - 8, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 256);
            Core.ShadowRegion(4, 4, frmModal.Width - 8, frmModal.Height - 8);

            Core.Screen.DrawTextInRect(title, 8, 8, frmModal.Width - 16, titleFont.Height, Bitmap.DT_TrimmingCharacterEllipsis, Colors.Charcoal, titleFont);

            var tv1 = new Treeview("tv1", bodyFont, 8, 16 + titleFont.Height, frmModal.Width - 16, frmModal.Height - 41 - bodyFont.Height - titleFont.Height);

            VolumeInfo[] vi = VolumeInfo.GetVolumes();

            for (int i = 0; i < vi.Length; i++)
            {
                var viNode = new TreeviewNode(vi[i].RootDirectory)
                {
                    Tag = vi[i].RootDirectory
                };

                if (vi[i].IsFormatted)
                {
                    if (Directory.GetDirectories(vi[i].RootDirectory).Length > 0)
                    {
                        var ni = new TreeviewNode(string.Empty)
                        {
                            Tag = null
                        };
                        viNode.AddNode(ni);
                    }
                }

                tv1.AddNode(viNode);
            }
            tv1.NodeExpanded += tv1_NodeExpanded;
            frmModal.AddChild(tv1);

            var btnSelect = new Button("btnSel", "Select", bodyFont, 8, frmModal.Height - 22 - bodyFont.Height)
            {
                BorderColor        = ColorUtility.ColorFromRGB(13, 86, 124),
                NormalColorTop     = Colors.LightBlue,
                NormalColorBottom  = ColorUtility.ColorFromRGB(26, 129, 182),
                PressedColorBottom = Colors.LightBlue
            };

            btnSelect.PressedColorTop  = btnSelect.NormalColorBottom;
            btnSelect.NormalTextColor  = Colors.White;
            btnSelect.PressedTextColor = Colors.White;
            btnSelect.Tap += (sender, e) => ReturnSelection(tv1);
            frmModal.AddChild(btnSelect);

            Color cR1       = ColorUtility.ColorFromRGB(226, 92, 79);
            Color cR2       = ColorUtility.ColorFromRGB(202, 48, 53);
            var   btnCancel = new Button("btnCancel", "Cancel", bodyFont, 0, btnSelect.Y, Colors.White, Colors.White, Colors.DarkRed, Colors.DarkRed)
            {
                NormalColorTop     = cR1,
                NormalColorBottom  = cR2,
                PressedColorTop    = cR2,
                PressedColorBottom = cR1
            };

            btnCancel.X    = frmModal.Width - btnCancel.Width - 8;
            btnCancel.Tap += (sender, e) => _activeBlock.Set();

            frmModal.AddChild(btnCancel);

            Core.SilentlyActivate(frmModal);
            frmModal.Render(new rect(4, 12 + titleFont.Height, frmModal.Width - 8, frmModal.Height - 20 - titleFont.Height));
            Core.Screen.Flush();

            ModalBlock();

            Core.ActiveContainer = prv;

            return(_result);
        }
Exemplo n.º 23
0
        // ReSharper disable once UnusedMethodReturnValue.Local
        // ReSharper disable once UnusedParameter.Local
        //TODO: check why param extensions is not in use
        private static string CreateDialog(string title, Font titleFont, Font bodyFont, string startDirectory, string[] extentions)
        {
            IContainer prv = Core.ActiveContainer;

            lock (Core.Screen)
            {
                var frmModal = new Form("modalAlertForm", Colors.Ghost);
                _inputResult = string.Empty;

                Core.Screen.SetClippingRectangle(0, 0, frmModal.Width, frmModal.Height);
                Core.Screen.DrawRectangle(0, 0, 4, 4, frmModal.Width - 8, frmModal.Height - 8, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 256);
                Core.ShadowRegion(4, 4, frmModal.Width - 8, frmModal.Height - 8);

                Core.Screen.DrawTextInRect(title, 8, 8, frmModal.Width - 16, titleFont.Height, Bitmap.DT_TrimmingCharacterEllipsis, Colors.Charcoal, titleFont);

                var tv1 = new Treeview("tv1", bodyFont, 8, 16 + titleFont.Height, 120, frmModal.Height - 45 - bodyFont.Height - titleFont.Height);

                VolumeInfo[] vi = VolumeInfo.GetVolumes();

                for (int i = 0; i < vi.Length; i++)
                {
                    var viNode = new TreeviewNode(vi[i].RootDirectory)
                    {
                        Tag = vi[i].RootDirectory
                    };

                    if (vi[i].IsFormatted)
                    {
                        if (Directory.GetDirectories(vi[i].RootDirectory).Length > 0)
                        {
                            var ni = new TreeviewNode(string.Empty)
                            {
                                Tag = null
                            };
                            viNode.AddNode(ni);
                        }
                    }

                    tv1.AddNode(viNode);
                }
                tv1.NodeExpanded += tv1_NodeExpanded;
                frmModal.AddChild(tv1);

                var fb1 = new Filebox("fb1", null, bodyFont, 132, tv1.Y, frmModal.Width - 141, tv1.Height);
                frmModal.AddChild(fb1);


                Color cR1       = ColorUtility.ColorFromRGB(226, 92, 79);
                Color cR2       = ColorUtility.ColorFromRGB(202, 48, 53);
                var   btnCancel = new Button("btnCancel", "Cancel", bodyFont, 8, frmModal.Height - 26 - bodyFont.Height, Colors.White, Colors.White, Colors.DarkRed, Colors.DarkRed)
                {
                    NormalColorTop     = cR1,
                    NormalColorBottom  = cR2,
                    PressedColorTop    = cR2,
                    PressedColorBottom = cR1
                };
                btnCancel.Height += 4;
                btnCancel.Tap    += (sender, e) => _activeBlock.Set();

                var btnSelect = new Button("btnSel", (_isSave) ? "Save File" : "Open File", bodyFont, 8, frmModal.Height - 26 - bodyFont.Height)
                {
                    BorderColor        = ColorUtility.ColorFromRGB(13, 86, 124),
                    NormalColorTop     = Colors.LightBlue,
                    NormalColorBottom  = ColorUtility.ColorFromRGB(26, 129, 182),
                    PressedColorBottom = Colors.LightBlue
                };
                btnSelect.PressedColorTop  = btnSelect.NormalColorBottom;
                btnSelect.NormalTextColor  = Colors.White;
                btnSelect.PressedTextColor = Colors.White;
                btnSelect.X       = frmModal.Width - btnSelect.Width - 8;
                btnSelect.Height += 4;
                btnSelect.Enabled = false;
                frmModal.AddChild(btnSelect);

                frmModal.AddChild(btnCancel);

                var txt1 = new Textbox("txt1", string.Empty, bodyFont, Colors.Charcoal, btnCancel.X + btnCancel.Width + 4, btnCancel.Y, frmModal.Width - 28 - btnCancel.Width - btnSelect.Width, btnSelect.Height, ' ', !_isSave);
                frmModal.AddChild(txt1);

                Core.SilentlyActivate(frmModal);
                frmModal.Render(new rect(4, 12 + titleFont.Height, frmModal.Width - 8, frmModal.Height - 20 - titleFont.Height));
                Core.Screen.Flush();

                tv1.NodeTapped           += (node, e) => tv1_NodeTapped(node, fb1);
                fb1.PathChanged          += (sender, value) => SetTvPath(value, tv1, fb1);
                fb1.SelectedIndexChanged += (sender, value) => FbIndexChange(fb1, txt1);
                txt1.TextChanged         += (sender, value) => btnSelect.Enabled = txt1.Text != string.Empty;
                SetTvPath(startDirectory, tv1, fb1);
                btnSelect.Tap += (sender, e) => ReturnSelection(tv1, txt1);
            }

            ModalBlock();

            Core.ActiveContainer = prv;

            return(_inputResult);
        }