예제 #1
0
        private void InitController()
        {
            FillRadialMenu(_mainWindow.RadialMenu);

            _mainWindow.EventKeyPress += (sender, args) =>
            {
                if (args.Key == KeyCode.Menu)
                {
                    ShowContacts();
                }
            };

            _mainWindow.ShowContactsBtn.EventMouseClick += (sender, args) =>
            {
                ShowContacts();
            };

            _mainWindow.RadialMenu.AddButton.EventMouseClick += (sender, args) =>
            {
                _mainWindow.RadialMenu.Hide();
                InputDialog input = new InputDialog("Add a contact...", "Add");
                input.OnCloseDialog += () =>
                {
                    Contact contact = ItemFactory.GetContact(input.GetResult(), _mainWindow.Menu);
                    contact.SetNotificationCount(_model.GetRandomNumber(1, 19));
                    _mainWindow.RadialMenu.AddItem(contact);
                    _mainWindow.RadialMenu.Show();
                };
                input.Show(_mainWindow);
            };
        }
예제 #2
0
        public override void InitElements()
        {
            AssingSize(_languageList, _profileList, _inputModeList);

            HorizontalStack _profileToolbar = new HorizontalStack();

            _profileToolbar.SetHeightPolicy(SizePolicy.Fixed);
            _profileToolbar.SetHeight(30);
            _profileToolbar.SetSpacing(10);

            AddItems(
                _headerTitle,
                _autoLaunchAppCheckBox,
                _startMinimizedCheckBox,
                _autoStartCheckBox,
                Items.GetHorizontalDivider(),
                _headerProfile,
                _profileToolbar,
                _inputModeList,
                Items.GetHorizontalDivider(),
                _headerLocale,
                _languageList
                );

            _profileToolbar.AddItems(_profileList, _addProfile, _copyProfile, _removeProfile);

            // apply settings
            _languageList.SetCurrentIndex(
                Controller.GetLocalizations().Keys.ToList().IndexOf(Controller.GetLanguage()["Locale"]));

            _profileList.SetCurrentIndex(
                Controller.GetAllProfiles().Select(p => p.Name).ToList().IndexOf(Controller.GetProfile().Name));

            _inputModeList.SetCurrentIndex(
                Parse.RepeatTypes(Controller.GetProfile().RepeatMode));

            // events
            _languageList.SelectionChanged += () =>
            {
                Controller.InvokeEventLanguageChanged(_languageList.GetTextSelection());
            };

            _profileList.SelectionChanged += () =>
            {
                Controller.InvokeEventProfileChanged(_profileList.GetTextSelection());
            };

            _inputModeList.SelectionChanged += () =>
            {
                Controller.GetProfile().RepeatMode = (RepeatType)_inputModeList.GetCurrentIndex();
            };

            _autoLaunchAppCheckBox.EventToggle += (value) =>
            {
                Controller.GetSettings().AutoLaunchOnSystemStartUp = value;
            };

            _startMinimizedCheckBox.EventToggle += (value) =>
            {
                Controller.GetSettings().StartAppMinimized = value;
            };

            _autoStartCheckBox.EventToggle += (value) =>
            {
                Controller.GetSettings().AutoStart = value;
            };

            _addProfile.EventMouseClick += (sender, args) =>
            {
                InputDialog input = new InputDialog(Controller.GetLanguage()["InputTitle"], Controller.GetLanguage()["AddButton"]);
                input.SetCancelVisible(false);
                input.OnCloseDialog += () =>
                {
                    if (input.GetResult().Length > 0)
                    {
                        Controller.InvokeEventAddProfile(input.GetResult());
                    }
                };
                input.Show(GetHandler());
            };

            _copyProfile.EventMouseClick += (sender, args) =>
            {
                InputDialog input = new InputDialog(Controller.GetLanguage()["InputTitle"], Controller.GetLanguage()["AddButton"]);
                input.SetCancelVisible(false);
                input.OnCloseDialog += () =>
                {
                    if (input.GetResult().Length > 0)
                    {
                        Controller.InvokeEventAddProfile(input.GetResult(), true);
                    }
                };
                input.Show(GetHandler());
            };

            _removeProfile.EventMouseClick += (sender, args) =>
            {
                MessageItem msg = new MessageItem(
                    Controller.GetLanguage()["MsgDeleteProfile"]
                    + " " + Controller.GetProfile().Name
                    + "\n" + Controller.GetLanguage()["MsgConfirm"],
                    Controller.GetLanguage()["DeleteProfileTitle"]);
                msg.GetOkButton().SetText(Controller.GetLanguage()["DeleteButton"]);
                msg.GetCancelButton().SetText(Controller.GetLanguage()["CancelButton"]);
                msg.OnCloseDialog += () =>
                {
                    if (msg.GetResult())
                    {
                        Controller.InvokeEventDeleteProfile();
                    }
                };
                msg.Show(GetHandler());
            };
        }
예제 #3
0
        public override void InitWindow()
        {
            // Window attr
            SetParameters("ComboBoxExample", "ComboBoxExample", 500, 400);

            // Layout attr
            VerticalStack layout = new VerticalStack();

            layout.SetBackground(60, 60, 60);
            layout.SetPadding(30, 30, 30, 30);

            // Creating MenuItems
            MenuItem filterItem = ItemsFactory.GetMenuItem("Open Filter Function Menu",
                                                           DefaultsService.GetDefaultImage(EmbeddedImage.Filter, EmbeddedImageSize.Size32x32));

            MenuItem recycleItem = ItemsFactory.GetMenuItem("Open Recycle Bin",
                                                            DefaultsService.GetDefaultImage(EmbeddedImage.RecycleBin, EmbeddedImageSize.Size32x32));

            MenuItem refreshItem = ItemsFactory.GetMenuItem("Refresh UI",
                                                            DefaultsService.GetDefaultImage(EmbeddedImage.Refresh, EmbeddedImageSize.Size32x32));

            MenuItem addMenuItemItem = ItemsFactory.GetMenuItem("Add New Function...",
                                                                DefaultsService.GetDefaultImage(EmbeddedImage.Add, EmbeddedImageSize.Size32x32));

            // Creating ComboBox
            ComboBox combo = new ComboBox(
                filterItem,
                recycleItem,
                refreshItem,
                addMenuItemItem
                );

            combo.SetAlignment(ItemAlignment.VCenter, ItemAlignment.HCenter);
            combo.SetText("Operations");
            combo.SetStyle(StyleFactory.GetComboBoxStyle());

            // Change event for "addMenuItemItem" - add a new MenuItem into ComboBox
            addMenuItemItem.EventMouseClick = (sender, args) =>
            {
                InputDialog inDialog = new InputDialog("Add new function...", "Add", "NewFunction");
                inDialog.OnCloseDialog += () =>
                {
                    if (inDialog.GetResult() != String.Empty)
                    {
                        combo.AddItem(ItemsFactory.GetMenuItem(inDialog.GetResult(),
                                                               DefaultsService.GetDefaultImage(EmbeddedImage.Import, EmbeddedImageSize.Size32x32)));
                    }
                };
                inDialog.Show(addMenuItemItem.GetHandler());
            };

            // Add ComboBox to Window
            AddItem(layout);
            layout.AddItem(combo);

            // Decorate our ComboBox with a white dot
            combo.AddItem(ItemsFactory.GetDot());

            //Optionally: Set start index (this method should only be called if ComboBox has already been added)
            // combo.SetCurrentIndex(0);
        }