Esempio n. 1
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();
            };
        }
Esempio n. 2
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));
        }