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
        public MainWindow()
            : base("XChess", 640, 480)
        {
            this.VSync = VSyncMode.Off;

            Board board = Board.Initial;
            Game game = new AIGame(0, board);
            this.Control = this._LayerContainer = new LayerContainer((this._View = new GameBoardView(game)));
            this.WindowState = WindowState.Maximized;
        }
Esempio n. 3
0
 /// <summary>
 /// Shows a messagebox with the OK and cancel options. Action is only performed on OK.
 /// </summary>
 public static void ShowOKCancel(LayerContainer Container, string Title, string Message, ClickHandler OnOKClick, MessageBoxStyle Style)
 {
     MessageBoxOptions mbo = new MessageBoxOptions();
     mbo.AddButton("OK", OnOKClick);
     mbo.AddButton("Cancel", null);
     mbo.Title = Title;
     mbo.Message = Message;
     mbo.Style = Style;
     Show(Container, mbo);
 }
Esempio n. 4
0
        public MainWindow()
            : base("MD", 640, 480)
        {
            this.WindowState = WindowState.Maximized;

            // Client area
            VariableContainer clientarea = new VariableContainer();

            // Menu items
            MenuItem[] menuitems = new MenuItem[]
            {
                MenuItem.Create("File", new MenuItem[]
                {
                    MenuItem.Create("Import", delegate
                    {
                        using(var fd = new WinForms.OpenFileDialog())
                        {
                            fd.Filter = "MP3 Files |*.mp3";
                            if (fd.ShowDialog() == WinForms.DialogResult.OK)
                            {
                                string file = fd.FileName;
                                AudioContext ac = new AudioContext();
                                MemoryAudioSource mas = new MP3AudioFeed(file).Copy(4096, 4096 * 100);

                                SpectrogramView sp = new SpectrogramView(mas);
                                clientarea.Client = sp;

                                AudioOutput ao = new AudioOutput(mas.Play);
                                ao.Play();
                            }
                            else
                            {
                                return;
                            }
                        }
                    }),
                    MenuItem.Create("Exit", delegate
                    {
                        this.Close();
                    })
                })
            };

            // Menu and splitter
            Menu menu = new Menu(menuitems);
            SplitContainer sc = new SplitContainer(Axis.Vertical, menu.WithBorder(0.0, 0.0, 0.0, 1.0), clientarea);
            sc.NearSize = 30.0;

            // Main layer container
            LayerContainer lc = new LayerContainer(sc);

            this.Control = lc;
        }
Esempio n. 5
0
 /// <summary>
 /// Calls up a precreated popup in the given container at the offset (which becomes the topleft point).
 /// </summary>
 public static void Call(LayerContainer Container, Point Offset, Popup Popup)
 {
     Point size = Popup.Size;
     Offset.X = Math.Min(Offset.X, Container.Size.X - size.X);
     Offset.Y = Math.Min(Offset.Y, Container.Size.Y - size.Y);
     Container.AddControl(Popup, Offset);
     ModalOptions mo = new ModalOptions()
     {
         MouseFallthrough = true,
         Lightbox = false,
         LowestModal = Popup
     };
     mo.BackgroundClick += delegate
     {
         Popup.Dismiss();
     };
     Container.Modal = mo;
 }
Esempio n. 6
0
 /// <summary>
 /// Calls up a popup in the container at the offset, using the default popup style.
 /// </summary>
 public static Popup Call(LayerContainer Container, Point Offset, IEnumerable<MenuItem> Items)
 {
     return Call(Container, Offset, Items, new PopupStyle());
 }
Esempio n. 7
0
 /// <summary>
 /// Calls up a popup in the container at the offset (which becomes the topleft point). 
 /// </summary>
 public static Popup Call(LayerContainer Container, Point Offset, IEnumerable<MenuItem> Items, PopupStyle Style)
 {
     Popup p = new Popup(Style, Items);
     Call(Container, Offset, p);
     return p;
 }
Esempio n. 8
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));
        }
Esempio n. 9
0
 /// <summary>
 /// Shows a messagebox with the default style with the OK and cancel options. Action is only performed on OK. 
 /// </summary>
 public static void ShowOKCancel(LayerContainer Container, string Title, string Message, ClickHandler OnOKClick)
 {
     ShowOKCancel(Container, Title, Message, OnOKClick, new MessageBoxStyle());
 }