public override BaseScreenComponent OnWindow(ModSettingsWindow window, float x, float y, ref int height)
 {
     return(MultiTextBox.Make(new Rect(x + 95, y, 40, 6), mt => mt.DoLayout(Value.First, Value.Second)));
 }
        protected override void Initialize()
        {
            _guiList     = new List <IObject>();
            MainInstance = this;

            // This is necessary for performance, it caches the resources before first use
            var caching = new ComboBox();

            caching.Initialize();
            caching.InitPropertyPanel();

            MouseGUI.Load();

            _fileMenu          = new ComboBox();
            _fileMenu.Position = new Point(32, 32);
            _fileMenu.Initialize();
            _fileMenu.Editable = false;

            _fileMenu.AddName("File", Color.Black, Singleton.Font.GetFont(FontManager.FontType.LUCIDA_CONSOLE));


            _fileMenu.AddNewItem("Save", () =>
            {
                //TODO:
            });
            _fileMenu.AddNewItem("Load", () =>
            {
                _fileMenu.Hide();
                // TODO:
            });


            _fileMenu.AddNewItem("Export", () =>
            {
                // TODO:

                _fileMenu.Hide();
            });
            _fileMenu.AddNewItem("Close", () =>
            {
                Exit();
            });


            // Toolbox elements
            UIToolShelf          = new Frame("UItoolboxTX", DrawPriority.NORMAL, MoveOption.STATIC);
            UIToolShelf.Position = new Point(32, 100);
            UIToolShelf.Initialize();


            _toolShelfComboBox = new ComboBox();
            _toolShelfComboBox.Initialize();
            _toolShelfComboBox.Editable      = true;;
            _toolShelfComboBox.DefaultOffset = new Point(8, 43);

            _toolShelfCheckbox = new CheckBox();
            _toolShelfCheckbox.Initialize();
            _toolShelfCheckbox.Text     = "CheckBox";
            _toolShelfCheckbox.Editable = true;;

            _toolShelfLabel = new Label();
            _toolShelfLabel.Initialize();
            _toolShelfLabel.TextColor = Color.White;
            _toolShelfLabel.Editable  = true;;

            _toolShelfTextbox = new TextBox();
            _toolShelfTextbox.Initialize();
            _toolShelfTextbox.Selected = false;
            _toolShelfTextbox.Editable = true;;

            _toolShelfButton = new Button();
            _toolShelfButton.Initialize();
            _toolShelfButton.Editable  = true;;
            _toolShelfButton.TextColor = Color.Black;

            _toolShelfToggle = new ToggleButton();
            _toolShelfToggle.Initialize();
            _toolShelfToggle.Editable = true;;
            _toolShelfToggle.Toggle   = false;

            _toolShelfSlider = new SliderBar();
            _toolShelfSlider.Initialize();
            _toolShelfSlider.Editable = true;;

            _toolShelfMultilineTextbox = new MultiTextBox();
            _toolShelfMultilineTextbox.Initialize();
            _toolShelfMultilineTextbox.Editable = true;;

            UIToolShelf.AddItem(new Point(32, 32), _toolShelfTextbox);
            UIToolShelf.AddItem(new Point(32, 96), _toolShelfLabel);
            UIToolShelf.AddItem(new Point(32, 160), _toolShelfButton);
            UIToolShelf.AddItem(new Point(32, 224), _toolShelfComboBox);
            UIToolShelf.AddItem(new Point(32, 288), _toolShelfCheckbox);
            UIToolShelf.AddItem(new Point(32, 352), _toolShelfToggle);
            UIToolShelf.AddItem(new Point(16, 416), _toolShelfSlider);
            UIToolShelf.AddItem(new Point(16, 480), _toolShelfMultilineTextbox);


            Selection = new ElementSelection();
            Selection.Initialize();
            Selection.Editable = false;
            Selection.Position = Point.Zero;

            UIToolShelf.Show();

            _mainFrameCaption = new Label("This is the Actual Window");
            _mainFrameCaption.Initialize();
            _mainFrameCaption.TextFont = Singleton.Font.GetFont(FontManager.FontType.GEORGIA);

            //Button btn = new Button();
            //btn.Initialize();
            //btn.Name = "btn1";
            //btn.TextColor = Color.Black;
            //btn.Setup();

            //Label lb = new Label("Hello World");
            //lb.Initialize();
            //lb.Name = "lb1";
            //lb.TextColor = Color.White;
            //lb.Setup();

            //ComboBox cb = new ComboBox();
            //cb.Initialize();
            //cb.Name = "cb1";
            //cb.TextColor = Color.Black;
            //cb.Setup();

            //SliderBar sb = new SliderBar();
            //sb.Initialize();
            //sb.Name = "sb1";
            //sb.Setup();

            //CheckBox ckb = new CheckBox();
            //ckb.Initialize();
            //ckb.Name = "ckb1";
            //ckb.Text = "Checkbox";
            //ckb.Setup();

            //ToggleButton tb = new ToggleButton();
            //tb.Initialize();
            //tb.Name = "tb1";
            //tb.Setup();

            //TextBox txt = new TextBox();
            //txt.Initialize();
            //txt.Setup();
            //txt.Name = "txt1";
            //txt.Text = "Sample";

            //MultiTextBox mtb = new MultiTextBox();
            //mtb.Initialize();
            //mtb.Setup();
            //mtb.Name = "mtb1";
            //RootContainer = new Grid();
            //RootContainer.Position = new Point(568, 100);
            //RootContainer.Initialize();
            //RootContainer.Setup();

            //RootContainer.AddItem(new Point(100, 100), btn, UIObject.DrawPriority.NORMAL);
            //RootContainer.AddItem(new Point(100, 100), lb, UIObject.DrawPriority.NORMAL);
            //RootContainer.AddItem(new Point(100, 100), cb, UIObject.DrawPriority.NORMAL);
            //RootContainer.AddItem(new Point(100, 100), sb, UIObject.DrawPriority.NORMAL);
            //RootContainer.AddItem(new Point(200, 300), ckb, UIObject.DrawPriority.NORMAL);
            //RootContainer.AddItem(new Point(100, 100), txt, UIObject.DrawPriority.NORMAL);
            //RootContainer.AddItem(new Point(400, 300), tb, UIObject.DrawPriority.NORMAL);
            //RootContainer.AddItem(new Point(100, 300), mtb, UIObject.DrawPriority.NORMAL);

            ////items.AddRange(new UIObject[]{
            ////btn, lb , cb, sb });

            //try
            //{
            //    using (XmlWriter xmlWriter = XmlTool.OpenXmlWriter("Text2.XRML"))
            //    {
            //        XmlTool.Serialize(RootContainer, xmlWriter, XmlTool.AddException(typeof(Color), "PackedValue"));
            //    }
            //}
            //catch (Exception ex)
            //{

            //}


            // Live editing is already possible only by using the Text2.XRML file
            // A full fledged XML Editor will be implemented next
            try
            {
                using (var XmlReader = XmlTool.OpenXmlReader("Text2.XRML"))
                {
                    RootContainer = (Grid)XmlTool.Deserialize(typeof(Grid), XmlReader, new XmlRootAttribute()
                    {
                        ElementName = "Grid",
                        IsNullable  = true
                    });
                }

                RootContainer.Initialize();
                RootContainer.Setup();

                RootContainer.Position = new Point(568, 100);
                List <Slot <UIObject> > backup = new List <Slot <UIObject> >();
                backup = RootContainer.Slots.ToList();

                // Temporary workaround to add items in the same order as it was saved
                // However it is not perfect yet
                backup = backup.OrderBy(s => s, Comparer <Slot <UIObject> > .Create((x, y) =>
                                                                                    (Point)x.Position > y.Position? 1 :
                                                                                    (Point)x.Position < y.Position ? -1 :
                                                                                    0)).ToList();

                for (int i = backup.Count - 1; i >= 0; i--)
                {
                    backup[i].Item.Editable = true;
                    backup[i].Item.Locked   = false;
                    RootContainer.Insert(backup[i]);
                }
                RootContainer.UpdateLayout();
                RootContainer.Show();
            }
            catch (Exception ex)
            {
            }
            using (TextReader reader = XmlTool.OpenTextReader("Text2.XRML"))
            {
                _xrml_text = reader.ReadToEnd();
            }

            _guiList.Add(Selection);
            _guiList.Add(_fileMenu);
            _guiList.Add(UIToolShelf);
            _guiList.Add(RootContainer);

            base.Initialize();
        }