Beispiel #1
0
            public _Item(PopupStyle Style, MenuItem Source, double Y)
            {
                this.Source = Source;
                this.Y = Y;

                TextMenuItem tmi = Source as TextMenuItem;
                if (tmi != null)
                {
                    this.Sample = Style.Font.CreateSample(tmi.Text, null, TextAlign.Left, TextAlign.Center, TextWrap.Ellipsis);
                }

                CommandMenuItem cmi = Source as CommandMenuItem;
                if (cmi != null)
                {
                    this.Size = new Point(this.Sample.Size.X, Style.StandardItemHeight);
                }

                CompoundMenuItem cpmi = Source as CompoundMenuItem;
                if (cpmi != null)
                {
                    this.Size = new Point(this.Sample.Size.X + Style.CompoundArrowSize.X, Style.StandardItemHeight);
                }

                SeperatorMenuItem smi = Source as SeperatorMenuItem;
                if (smi != null)
                {
                    this.Size = new Point(0.0, Style.SeperatorHeight + Style.SeperatorPadding * 2.0);
                }
            }
Beispiel #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));
        }