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); } } }
public GameConfigDB AddNewGameConfig(string name) { string relativeFullPath = Config.GetConfigDirectory(RELATIVE_PATH); relativeFullPath += "game_" + name + ".xml"; GameConfigDescriptorLoader gameConfigDescriptorLoader = new GameConfigDescriptorLoader(relativeFullPath); _gamesLoader.Add(gameConfigDescriptorLoader); gameConfigDescriptorLoader.CreateNew(name); gameConfigDescriptorLoader.Save(); gameConfigDescriptorLoader.Load(); return(gameConfigDescriptorLoader.GetConfig()); }
private int HandleComparison(GameConfigDescriptorLoader value1, GameConfigDescriptorLoader value2) { int creationDate1 = value1.GetConfig().GetCreationDate(); int creationDate2 = value2.GetConfig().GetCreationDate(); if (creationDate1 < creationDate2) { return(-1); } else if (creationDate1 > creationDate2) { return(1); } else { return(0); } }