Example #1
0
        public void AddProperties(PropertyOwner owner)
        {
            _comboAddConfirm = new TextBoxConfirmAction();

            _addButton = new Button("PropertyPanelComboAddBTNTX", OverlayOption.NORMAL, DrawPriority.NORMAL);
            _remButton = new Button("PropertyPanelComboDelBTNTX", OverlayOption.NORMAL, DrawPriority.NORMAL);


            Properties.Add(_comboAddConfirm, new Point(55, 555));

            _comboAddConfirm.Initialize();
            _addButton.Initialize();
            _addButton.Initialize();

            _comboAddConfirm.AddButton(_addButton, 4);
            _comboAddConfirm.AddButton(_remButton, 4);
            _comboAddConfirm.Show();

            AddEvents();
        }
        void AddEvents()
        {
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            _locker.MouseEvent.onMouseOver += (sender, args) =>
            {
                _lockerTooltip.Show();
            };
            _locker.MouseEvent.onMouseOut += (sender, args) =>
            {
                _lockerTooltip.Hide();
            };
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            _locker.MouseEvent.onMouseClick += (sender, args) =>
            {
                _locker.Selected = !_locker.Selected;
                Owner.Locked     = _locker.Selected;
                Owner.Editable   = !Owner.Locked;
            };
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            _layoutCBG.SetSelected(_grid);
            _grid.MouseEvent.onMouseClick += (sender, args) =>
            {
                _layoutCBG.SetSelected(_grid);
                MainWindow.RemoveContainer();
                MainWindow.RootContainer = UIFactory <UIObject, IContainer> .CreateContainer(MainWindow.RootContainer, new Grid(), MainWindow._mainBatch);

                MainWindow.AddContainer();
                MainWindow.RootContainer.Show();
            };
            _free.MouseEvent.onMouseClick += (sender, args) =>
            {
                _layoutCBG.SetSelected(_free);

                MainWindow.RemoveContainer();
                MainWindow.RootContainer = UIFactory <UIObject, IContainer> .CreateContainer(MainWindow.RootContainer, new Frame("FrameEditorTX", DrawPriority.NORMAL), MainWindow._mainBatch);

                MainWindow.AddContainer();
                MainWindow.RootContainer.Show();
            };
            _vertical.MouseEvent.onMouseClick += (sender, args) =>
            {
                _layoutCBG.SetSelected(_vertical);
                MainWindow.RemoveContainer();
                MainWindow.RootContainer = UIFactory <UIObject, IContainer> .CreateContainer(MainWindow.RootContainer, new VerticalStack(), MainWindow._mainBatch);

                MainWindow.AddContainer();
                MainWindow.RootContainer.Show();
            };
            _horizontal.MouseEvent.onMouseClick += (sender, args) =>
            {
                _layoutCBG.SetSelected(_horizontal);
                MainWindow.RemoveContainer();
                MainWindow.RootContainer = UIFactory <UIObject, IContainer> .CreateContainer(MainWindow.RootContainer, new HorizontalStack(), MainWindow._mainBatch);

                MainWindow.AddContainer();
                MainWindow.RootContainer.Show();
            };
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            _onClickConfirm.MouseEvent.onMouseClick += (sender, args) =>
            {
                _onClickConfirm.Selected = true;
            };

            _onOverConfirm.MouseEvent.onMouseClick += (sender, args) =>
            {
                _onOverConfirm.Selected = true;
            };

            _onOutConfirm.MouseEvent.onMouseClick += (sender, args) =>
            {
                _onOutConfirm.Selected = true;
            };

            _okClickConfirm.MouseEvent.onMouseClick += (sender, args) =>
            {
                // TODO:
                _onClickConfirm.Hide();
                _events.Hide();
            };
            _cancelClickConfirm.MouseEvent.onMouseClick += (sender, args) =>
            {
                _onClickConfirm.Clear();
                _onClickConfirm.Hide();
                _events.Hide();
            };

            _okOverConfirm.MouseEvent.onMouseClick += (sender, args) =>
            {
                // TODO:
                _onOverConfirm.Hide();
                _events.Hide();
            };
            _cancelOverConfirm.MouseEvent.onMouseClick += (sender, args) =>
            {
                _onOverConfirm.Clear();
                _onOverConfirm.Hide();
                _events.Hide();
            };

            _okOutConfirm.MouseEvent.onMouseClick += (sender, args) =>
            {
                // TODO:
                _onOutConfirm.Hide();
                _events.Hide();
            };
            _cancelOutConfirm.MouseEvent.onMouseClick += (sender, args) =>
            {
                _onOutConfirm.Clear();
                _onOutConfirm.Hide();
                _events.Hide();
            };

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            _events.MouseEvent.onMouseClick += (sender, args) =>
            {
                _events.Show();
                _onClickConfirm.Hide();
                _onOverConfirm.Hide();
                _onOutConfirm.Hide();
            };

            _events.AddNewItem("OnClick", () =>
            {
                UIObject item = _events["OnClick"];

                _onClickConfirm.Show();
                _onOverConfirm.Hide();
                _onOutConfirm.Hide();
            });

            _events.AddNewItem("MouseOver", () =>
            {
                UIObject item = _events["MouseOver"];


                _onOverConfirm.Show();
                _onClickConfirm.Hide();
                _onOutConfirm.Hide();
            });

            _events.AddNewItem("MouseOut", () =>
            {
                UIObject item = _events["MouseOut"];

                _onOutConfirm.Show();
                _onClickConfirm.Hide();
                _onOverConfirm.Hide();
            });
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            _showhide.MouseEvent.onMouseClick += (sender, args) =>
            {
                if (_showhide.Selected)
                {
                    Owner.Active = false;
                }
                else
                {
                    Owner.Active = true;
                }
            };
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            _search.MouseEvent.onMouseClick += (sender, args) =>
            {
                _search.Selected = true;
            };

            _search.KeyboardEvents.onKeyReleased += (sender, args) =>
            {
                if (Singleton.Input.KeyReleased(Keys.Back))
                {
                    MainWindow.Selection.Hide();
                }
                else
                {
                    if (Singleton.Input.KeyReleased(Singleton.Input.CurrentKey))
                    {
                        if (_search.Text.Length >= 3)
                        {
                            string pattern = @".*(?=" + _search.Text + ")+";
                            Regex  reg     = new Regex(pattern, RegexOptions.IgnoreCase);

                            var objectsFound = MainWindow.RootContainer.Slots.Where(t => reg.Match(t.Item.Name).Success).ToList();

                            if (objectsFound.Count > 0)
                            {
                                var owner = objectsFound.Last().Item;
                                MainWindow.Selection.Position = owner.Position;

                                Point rightBarPosition  = new Point(owner.Right, owner.Top);
                                Point leftBarPosition   = new Point(owner.Left, owner.Top);
                                Point topBarPosition    = new Point(owner.Left, owner.Top);
                                Point bottomBarPosition = new Point(owner.Left, owner.Bottom);

                                MainWindow.Selection.UpdatePosition(rightBarPosition,
                                                                    leftBarPosition,
                                                                    topBarPosition,
                                                                    bottomBarPosition);

                                MainWindow.Selection.UpdateSize(owner);

                                _search.Clear();
                                _search.SimulateInput(owner.Name);
                                MainWindow.Selection.Show();
                            }
                        }
                    }
                }
            };
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        }