Beispiel #1
0
 public Form(FormStyle Style, Control Client, string Text)
 {
     this._RightTitleBar = new FlowContainer(Style.TitleBarItemSeperation, Axis.Horizontal);
     this._Client = Client;
     this._Style = Style;
     this._Text = Text;
 }
Beispiel #2
0
        /// <summary>
        /// Shows a messagebox with the specified options.
        /// </summary>
        public static void Show(LayerContainer LayerContainer, MessageBoxOptions Options)
        {
            MessageBoxStyle style = Options.Style;

            // Message
            Label message = new Label(Options.Message, style.MessageColor, style.MessageLabelStyle);

            ClickHandler anyclick = null;

            // Buttons
            FlowContainer buttonflow = new FlowContainer(style.ButtonSeperation, Axis.Horizontal);
            ButtonStyle bstyle = style.ButtonStyle;
            foreach (MessageBoxOptions._Button b in Options._Buttons)
            {
                string name = b.Name;
                Label label = new Label(name, bstyle.TextColor, bstyle.TextStyle);
                Button button = new Button(bstyle);
                button.Client = label;
                button.Click += b.Click;
                button.Click += delegate { anyclick(); };
                buttonflow.AddChild(button, button.GetFullSize(label.SuggestSize).X);
            }

            // Main flow container
            FlowContainer mainflow = new FlowContainer(style.MessageButtonSeperation, Axis.Vertical);
            mainflow.AddChild(message, message.GetHeight(style.ContentWidth));
            mainflow.AddChild(buttonflow.WithCenterAlign(new Point(buttonflow.SuggestLength, style.ButtonHeight)), style.ButtonHeight);

            // Margin and border
            MarginContainer margin = mainflow.WithMargin(style.Margin);
            Point finalsize = margin.GetSize(new Point(style.ContentWidth, mainflow.SuggestLength));
            Control final = margin;
            if (style.BorderSize > 0.0)
            {
                double bs = style.BorderSize;
                final = final.WithBorder(style.BorderColor, bs, bs, bs, bs);
                finalsize += new Point(bs, bs) * 2.0;
            }

            // Form (finally)
            Form form = new Form(final, Options.Title);
            form.ClientSize = finalsize;
            LayerContainer.AddControl(form, LayerContainer.Size * 0.5 - form.Size * 0.5);

            // Make it modal
            ModalOptions mo = new ModalOptions()
            {
                Lightbox = true,
                LowestModal = form,
                MouseFallthrough = false
            };
            LayerContainer.Modal = mo;

            // Create destruction procedure.
            anyclick = delegate
            {
                LayerContainer.Modal = null;
                form.Dismiss();
            };
        }
Beispiel #3
0
        /// <summary>
        /// Shows the terminal.
        /// </summary>
        public void Show(LayerContainer LayerContainer)
        {
            if(this._Terminal != null)
                return;

            this._LableItems = new FlowContainer(Axis.Vertical);

            foreach(SelectableLabel lbl in this.Buffer.ToArray())
                this._LableItems.AddChild(lbl, this._Style.LableHeight);

            this._ScrollContainer = new ScrollContainer(this._LableItems);
            this._ScrollContainer.ClientHeight = this.Buffer.Count * this._Style.LableHeight;

            FlowContainer flow2 = new FlowContainer(Axis.Vertical);

            Textbox command = new Textbox();

            command.TextChanged += delegate(string Text)
            {
                if(this.GetAutoComplete != null)
                {
                    string[] result = this.GetAutoComplete(Text);
                    PopupContainer pc = new PopupContainer(command);
                    //pc.Call

                    MenuItem[] items = new MenuItem[result.Length];

                    for(int i = 0; i < result.Length; i++)
                        items[i] = MenuItem.Create(result[i], delegate{});
                    pc.Items = items;
                    pc.Call(new Point(0,0));
                }
            };

            command.TextEntered += delegate(string Text)
            {
                this.Write("> " + Text);
                command.Text = "";

                LinkedList<string> parsed;
                string cmd;
                try
                {
                    parsed = Terminal.ParseArguments(Text);
                    cmd = parsed.First.Value;
                    parsed.RemoveFirst();
                }
                catch(ParseArgsException ex)
                {
                    this.Write("Parse error: " + ex.Message);
                    return;
                }

                if(this.DoCommand != null)
                {
                    if(!this.DoCommand(cmd, parsed))
                    {
                        this.Write("Command \"" + cmd + "\" not found!");
                    }
                }

            };

            flow2.AddChild(this._ScrollContainer, this._Style.TerminalHeight - this._Style.TextboxHeight);
            flow2.AddChild(command, this._Style.TextboxHeight);

            this._Terminal = new Form(flow2, "Terminal");
            this._Terminal.AddCloseButton();
            this._Terminal.ClientSize = new Point(this._Style.TerminalWidth, this._Style.TerminalHeight);
            LayerContainer.AddControl(this._Terminal, new Point(200,200));
        }
Beispiel #4
0
    public static void Main()
    {
        HostWindow window = new HostWindow(delegate
        {
            // Create a layer container
            LayerContainer lc = new LayerContainer();

            // Create a form with many buttons
            {
                FlowContainer flow = new FlowContainer(10.0, Axis.Vertical);
                for (int t = 0; t < 40; t++)
                {
                    int i = t + 1;
                    Button b = new Button("Button #" + i.ToString());
                    flow.AddChild(b, 30.0);
                    b.Click += delegate
                    {
                        MessageBox.ShowOKCancel(lc, "Button Clicked!", "You have clicked button #" + i.ToString() + ".", null);
                    };
                }
                Point targetflowsize = new Point(120.0, flow.SuggestLength);
                MarginContainer margin = flow.WithMargin(10.0);
                Point targetmarginsize = margin.GetSize(targetflowsize);
                WindowContainer win = new WindowContainer(margin);
                SunkenContainer sunken = new SunkenContainer(win);
                ScrollContainer scroll = new ScrollContainer(win, sunken.WithBorder(1.0, 1.0, 0.0, 1.0));
                scroll.ClientHeight = targetmarginsize.Y;

                Form form = new Form(scroll, "Lots of buttons");
                form.ClientSize = new Point(targetmarginsize.X + 20.0, 200.0);
                lc.AddControl(form, new Point(30.0, 30.0));
            }

            // Popup test
            {
                Label label = new Label("Right click for popup", Color.RGB(0.0, 0.3, 0.0), new LabelStyle()
                    {
                        HorizontalAlign = TextAlign.Center,
                        VerticalAlign = TextAlign.Center,
                        Wrap = TextWrap.Ellipsis
                    });
                PopupContainer pc = new PopupContainer(label);
                pc.ShowOnRightClick = true;
                pc.Items = new MenuItem[]
                {
                    MenuItem.Create("Do nothing", delegate { }),
                    MenuItem.Create("Remain inert", delegate { }),
                    MenuItem.Create("Make a message box", delegate
                    {
                        MessageBox.ShowOKCancel(lc, "Message Box", "Done", null);
                    }),
                    MenuItem.Seperator,
                    MenuItem.Create("Mouseover me!", new MenuItem[]
                    {
                        MenuItem.Create("Some", delegate { }),
                        MenuItem.Create("Items", delegate { }),
                        MenuItem.Create("Spawn", delegate { }),
                        MenuItem.Create("Another", delegate { }),
                        MenuItem.Create("Popup", delegate { }),
                    }),
                    MenuItem.Seperator,
                    MenuItem.Create("Try", delegate { }),
                    MenuItem.Create("The", delegate { }),
                    MenuItem.Create("Keyboard", delegate { }),
                };

                Form form = new Form(pc.WithAlign(label.SuggestSize, Align.Center, Align.Center).WithBorder(1.0), "Popup Test");
                form.ClientSize = new Point(200.0, 50.0);
                lc.AddControl(form, new Point(230.0, 30.0));
                form.AddCloseButton();
            }

            // Timers and progress bars
            {
                FlowContainer flow = new FlowContainer(10.0, Axis.Vertical);
                Button addbutton = new Button("Add Some");
                Button resetbutton = new Button("Reset");
                Progressbar bar = new Progressbar();
                flow.AddChild(addbutton, 30.0);
                flow.AddChild(resetbutton, 30.0);
                flow.AddChild(bar, 30.0);

                addbutton.Click += delegate
                {
                    bar.Value = bar.Value + 0.05;
                };
                resetbutton.Click += delegate
                {
                    bar.Value = 0.0;
                };

                MarginContainer margin = flow.WithMargin(20.0);

                Form form = new Form(margin.WithBorder(1.0), "Progress bars!");
                form.ClientSize = margin.GetSize(new Point(200.0, flow.SuggestLength)) + new Point(4, 4);
                lc.AddControl(form, new Point(230.0, 150.0));
                form.AddCloseButton();
            }

            // Textbox
            {
                Textbox tb = new Textbox();
                MarginContainer margin = tb.WithMargin(20.0);

                Form form = new Form(margin.WithBorder(1.0), "Change the title of this form!");
                form.ClientSize = margin.GetSize(new Point(400.0, 32.0));
                lc.AddControl(form, new Point(30.0, 360.0));

                tb.TextChanged += delegate(string Text)
                {
                    form.Text = Text;
                };
            }

            return lc;
        }, "Lots of controls");
        window.Run();
    }
Beispiel #5
0
                /// <summary>
                /// Creates a function that displays the selection to the user.
                /// </summary>
                public Action<GUIControlContext> Display(GameBoardView BoardView)
                {
                    return delegate(GUIControlContext Context)
                    {
                        LayerContainer lc;
                        Point offset;
                        if (Context.FindAncestor<LayerContainer>(out lc, out offset))
                        {
                            FlowContainer options = new FlowContainer(20.0, Axis.Horizontal);
                            Pane pane = new Pane(new SunkenContainer(options.WithMargin(20.0)).WithBorder(1.0));
                            ModalOptions mo = new ModalOptions()
                            {
                                Lightbox = false,
                                LowestModal = pane,
                                MouseFallthrough = false
                            };

                            foreach (_Possible p in this._Items)
                            {
                                _Possible ip = p;
                                Button button = new Button(ButtonStyle.CreateSolid(Skin.Default), new _PieceIcon(p.Move.NewState).CreateControl());
                                options.AddChild(button, 150.0);
                                button.Click += delegate
                                {
                                    lc.Modal = null;
                                    pane.Dismiss();
                                    BoardView.MakeMove(ip.Move, ip.Board);
                                };
                            }

                            pane.ClientSize = new Point(options.SuggestLength + 42.0, 190.0);
                            Rectangle merect = new Rectangle(offset, Context.Control.Size);

                            lc.AddControl(pane, merect.Location + merect.Size * 0.5 - pane.Size * 0.5);
                            lc.Modal = mo;
                        }
                    };
                }