Beispiel #1
0
 private void OnDeleteTabPagePressed(object sender, ButtonReleaseEventArgs e)
 {
     UIUtils.ShutDownWindowSafe(ref _windowPrompt);
     _windowPrompt = new WindowPrompt("Are you sure to delete this tab and all its content?");
     _windowPrompt.OnAcceptEvent += OnDeleteTabAccept;
     _windowPrompt.OnCancelEvent += OnClosePrompt;
     MoveWindowToWindowPos(_windowPrompt);
     _windowPrompt.Show();
 }
Beispiel #2
0
        protected void OnImportCommandsButtonPress(object sender, EventArgs e)
        {
            Gtk.FileChooserDialog fileChooser = new Gtk.FileChooserDialog
                                                    ("Choose files"
                                                    , this
                                                    , FileChooserAction.Open
                                                    , "Select"
                                                    , ResponseType.Accept
                                                    , "Cancel"
                                                    , ResponseType.Close);

            Gtk.FileFilter xmlFileFilter = new Gtk.FileFilter();
            xmlFileFilter.AddPattern("*.xml");
            fileChooser.AddFilter(xmlFileFilter);

            int response = fileChooser.Run();

            if (response == Utils.static_cast <int>(ResponseType.Close))
            {
                UIUtils.ShutDownWindow(ref fileChooser);
            }
            else if (response == Utils.static_cast <int>(ResponseType.Accept))
            {
                string fullPath = fileChooser.Filename;
                UIUtils.ShutDownWindow(ref fileChooser);

                GameConfigDescriptorLoader loader = new GameConfigDescriptorLoader(fullPath);
                FileOperationResult        fileOperationResult = loader.Load();

                if (fileOperationResult.IsSuccess())
                {
                    GameConfigDB sourceConfigDB = loader.GetConfig();

                    UITabPage    currentTabPage = GetCurrentTabPage();
                    GameConfigDB targetConfigDB = currentTabPage.GetGameConfig();

                    foreach (GameConfigSectionDescriptor sectionDescriptor in sourceConfigDB.GetSections())
                    {
                        targetConfigDB.AddSection(sectionDescriptor);
                        currentTabPage.AddNewSection(sectionDescriptor);
                    }

                    currentTabPage.RefreshCanvas();
                }
                else
                {
                    UIUtils.ShutDownWindowSafe(ref _windowPrompt);
                    _windowPrompt = new WindowPrompt(fileOperationResult.GetResult());
                    _windowPrompt.OnAcceptEvent += OnAlertAccept;
                    _windowPrompt.SetCancelVisible(false);
                    _windowPrompt.Show();
                    MainApp.GetInstance().MoveWindowToMousePos(_windowPrompt);
                }
            }
        }
Beispiel #3
0
        public void RemoveSection(int sectionIndex)
        {
            UIUtils.ShutDownWindowSafe(ref _windowPrompt);
            GameConfigSectionDescriptor sectionToDelete = _gameConfigDB.GetSection(sectionIndex);

            _windowPrompt = new WindowPrompt("Are you sure to delete section \"" + sectionToDelete._tittle + "\" and all its content ?");
            _windowPrompt.SetExternalData(sectionIndex);
            _windowPrompt.OnAcceptEvent += OnRemoveSectionAccept;
            _windowPrompt.OnCancelEvent += OnClosePrompt;
            MoveWindowToWindowPos(_windowPrompt);
            _windowPrompt.Show();
        }
Beispiel #4
0
        protected void OnExportCommandsButtonPress(object sender, EventArgs e)
        {
            Gtk.FileChooserDialog fileChooser = new Gtk.FileChooserDialog
                                                    ("Choose files"
                                                    , this
                                                    , FileChooserAction.SelectFolder
                                                    , "Select"
                                                    , ResponseType.Accept
                                                    , "Cancel"
                                                    , ResponseType.Close);
            int response = fileChooser.Run();

            if (response == Utils.static_cast <int>(ResponseType.Close))
            {
                UIUtils.ShutDownWindow(ref fileChooser);
            }
            else if (response == Utils.static_cast <int>(ResponseType.Accept))
            {
                string fullPath = fileChooser.Filename + "/exported_commands.xml";
                UIUtils.ShutDownWindow(ref fileChooser);
                UITabPage currentTabPage = GetCurrentTabPage();
                currentTabPage.GetGameConfig();

                GamesConfigLoader   gamesLoader         = MainApp.GetInstance().GetConfig().GetGameConfig();
                FileOperationResult fileOperationResult = gamesLoader.Export(fullPath, currentTabPage.GetGameConfig());

                if (!fileOperationResult.IsSuccess())
                {
                    UIUtils.ShutDownWindowSafe(ref _windowPrompt);
                    _windowPrompt = new WindowPrompt(fileOperationResult.GetResult());
                    _windowPrompt.OnAcceptEvent += OnAlertAccept;
                    _windowPrompt.SetCancelVisible(false);
                    _windowPrompt.Show();
                    MainApp.GetInstance().MoveWindowToMousePos(_windowPrompt);
                }
            }
        }