コード例 #1
0
        private void CreateNewTab(GameConfigDB gameConfigDB, bool isInitializing = false)
        {
            UITabPage uiTabPage = UITabPageCreator.CreateUICanvasTab(notebook1, gameConfigDB, isInitializing);

            uiTabPage.OnDeleteTabAcceptEvent += OnDeleteTabAccept;
            uiTabPage.OnTabSelectedEvent     += OnTabSelected;
        }
コード例 #2
0
 public UISection(UITabPage parent, GameConfigSectionDescriptor sectionDescriptor, Point origin)
 {
     _parent     = parent;
     _origin     = origin;
     _UIElements = new List <UICommandElement>();
     AddSection(sectionDescriptor);
 }
コード例 #3
0
 public WindowNewSection(UITabPage parent, int sectionIndex) :
     base(Gtk.WindowType.Toplevel)
 {
     this.Build();
     _parent       = parent;
     _sectionIndex = sectionIndex;
 }
コード例 #4
0
 public WindowAddExposedCommand(UITabPage parent, int sectionIndex) :
     base(Gtk.WindowType.Toplevel)
 {
     this.Build();
     _parent       = parent;
     _sectionIndex = sectionIndex;
     RefreshCommandPickerVisibility();
 }
コード例 #5
0
 private void SelectFirstTab()
 {
     if (notebook1.NPages > 0)
     {
         notebook1.Page = 0;
         UITabPage firstTab = GetCurrentTabPage();
         firstTab.InitDropEvent();
     }
 }
コード例 #6
0
        public void Uptade()
        {
            UITabPage uiTabPage = GetCurrentTabPage();

            if (uiTabPage != null)
            {
                uiTabPage.Update();
            }
        }
コード例 #7
0
        public WindowAddSequenceCommand(UITabPage parent, int sectionIndex) :
            base(Gtk.WindowType.Toplevel)
        {
            this.Build();
            _parent       = parent;
            _sectionIndex = sectionIndex;
            _commandList  = new List <WidgetSequenceCommandEntry>();

            AddNewCommandEntry();
        }
コード例 #8
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);
                }
            }
        }
コード例 #9
0
 public WindowAddExposedCommand(UITabPage parent, UICommandElement uiCommandElement, GameConfigButtonDescriptor commandDescriptor) :
     base(Gtk.WindowType.Toplevel)
 {
     this.Build();
     _parent = parent;
     _editCommandDescriptor = commandDescriptor;
     _editUICommandElement  = uiCommandElement;
     _inputTittle.Text      = _editCommandDescriptor._tittle;
     _inputCommand.Text     = _editCommandDescriptor._command;
     RefreshCommandPickerVisibility();
 }
コード例 #10
0
        public UITabPage GetCurrentTabPage()
        {
            Widget currentPage = notebook1.GetNthPage(notebook1.Page);
            object data        = currentPage.Data["UITabPage"];

            if (data != null)
            {
                UITabPage tabPage = Utils.static_cast <UITabPage>(data);
                return(tabPage);
            }

            return(null);
        }
コード例 #11
0
        public static UITabPage CreateUICanvasTab(Gtk.Notebook parentNotebook, GameConfigDB gameConfigDB, bool isInitializing = false)
        {
            Gtk.ScrolledWindow scrolledWindow = new Gtk.ScrolledWindow();
            scrolledWindow.Name       = "_scrolledWindow" + nextGeneratedTabIndex;
            scrolledWindow.ShadowType = ((Gtk.ShadowType)(1));
            scrolledWindow.ShowAll();

            Gtk.Viewport viewport = new Gtk.Viewport();
            viewport.ShadowType = ((Gtk.ShadowType)(0));

            Gtk.Fixed canvas = new Gtk.Fixed();
            canvas.WidthRequest  = 800;
            canvas.HeightRequest = 600;
            canvas.Name          = "_gameCanvas" + nextGeneratedTabIndex;
            canvas.HasWindow     = false;
            canvas.ShowAll();
            viewport.Add(canvas);
            viewport.ShowAll();
            scrolledWindow.Add(viewport);

            Gtk.Viewport viewportLabel = new Gtk.Viewport();
            viewportLabel.ShadowType    = ((Gtk.ShadowType)(0));
            viewportLabel.WidthRequest  = 80;
            viewportLabel.HeightRequest = 30;

            Gtk.Label label = new Gtk.Label();
            label.Name      = "label1";
            label.LabelProp = global::Mono.Unix.Catalog.GetString(gameConfigDB.GetName());
            label.ShowAll();
            viewportLabel.Add(label);

            if (parentNotebook.NPages <= 0 || isInitializing)
            {
                parentNotebook.Add(scrolledWindow);
                parentNotebook.SetTabLabel(scrolledWindow, viewportLabel);
            }
            else
            {
                parentNotebook.InsertPage(scrolledWindow, viewportLabel, parentNotebook.NPages - 1);
                parentNotebook.Page = parentNotebook.NPages - 2;
            }

            UITabPage tabPage = new UITabPage(gameConfigDB, scrolledWindow, viewport, label, canvas);

            tabPage.InitDropEvent();
            scrolledWindow.Data.Add("UITabPage", tabPage);

            return(tabPage);
        }
コード例 #12
0
        private void OnTabSelected(UITabPage tabPage)
        {
            int pages = notebook1.NPages;

            for (int i = 0; i < pages; ++i)
            {
                Widget    currentPage    = notebook1.GetNthPage(i);
                UITabPage currentTabPage = Utils.static_cast <UITabPage>(currentPage.Data["UITabPage"]);
                if (currentTabPage == tabPage)
                {
                    notebook1.Page = i;
                    return;
                }
            }
        }
コード例 #13
0
        public WindowAddSequenceCommand(UITabPage parent, UICommandElement uiCommandElement, GameConfigButtonDescriptor commandDescriptor) :
            base(Gtk.WindowType.Toplevel)
        {
            this.Build();
            _parent                = parent;
            _commandList           = new List <WidgetSequenceCommandEntry>();
            _editCommandDescriptor = commandDescriptor;
            _editUICommandElement  = uiCommandElement;

            _inputTitle.Text = _editCommandDescriptor._tittle;
            foreach (GameConfigCommandDescriptor command in commandDescriptor._commandList)
            {
                AddCommandEntry(command);
            }
        }
コード例 #14
0
        private void OnDeleteTabAccept(UITabPage tabPage)
        {
            int pages = notebook1.NPages;

            for (int i = 0; i < pages; ++i)
            {
                Widget    currentPage    = notebook1.GetNthPage(i);
                UITabPage currentTabPage = Utils.static_cast <UITabPage>(currentPage.Data["UITabPage"]);
                if (currentTabPage == tabPage)
                {
                    notebook1.RemovePage(i);
                    if (i > 0)
                    {
                        notebook1.Page = i - 1;
                    }

                    GamesConfigLoader gamesConfigLoader = MainApp.GetInstance().GetConfig().GetGameConfig();
                    gamesConfigLoader.DeleteGameConfig(currentTabPage.GetGameConfig());
                    return;
                }
            }
        }
コード例 #15
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);
                }
            }
        }