public void loadGame() { DirectoryInfo d = new DirectoryInfo(Path.Combine(Application.dataPath, "Games")); //FileInfo[] Files = d.GetFiles("*.txt"); //Getting Text files listOfGames = d.GetFiles("*.txt"); List <string> fileNames = new List <string>(); foreach (FileInfo file in listOfGames) { fileNames.Add(file.Name); } DropdownDialog.Show(fileNames, "Load game", loadGameFromJson); }
/*public static DeckMeta LoadDeckInfoFromFile(string fileName) * { * string dataAsJson = null; * string filePath = Path.Combine(Application.streamingAssetsPath, Path.Combine("DeckInfos", fileName)); #if UNITY_EDITOR || UNITY_IOS || UNITY_STANDALONE_WIN * dataAsJson = File.ReadAllText(filePath); * #elif UNITY_ANDROID * WWW reader = new WWW (filePath); * while (!reader.isDone) { * } * dataAsJson = reader.text; #endif * * return JsonUtility.FromJson<DeckMeta>(dataAsJson); * }*/ public void OnLoadDeckLayoutButtonPressed() { DirectoryInfo dataDir = new DirectoryInfo(Path.Combine(Application.persistentDataPath, "DeckLayouts")); List <string> fileNames = new List <string>(); if (dataDir.Exists) { FileInfo[] fileinfos = dataDir.GetFiles(); for (int i = 0; i < fileinfos.Length; i++) { string name = Path.GetFileNameWithoutExtension(fileinfos[i].Name); fileNames.Add(name); } DropdownDialog.Show(fileNames, "Select a file", (int index) => { currentDeckLayout = LoadDeckLayoutFromFile(fileinfos[index].Name); deckMeta = decksFile.decks[currentDeckLayout.deckIndex].deckMeta; cardList.Load(deckMeta, currentDeckLayout.cardNums); }); } }
private void moveButton_Click(object sender, EventArgs e) { List<string> folders = new List<string>(); TreeNode projectNode = treeView.Nodes[0]; folders.Add(projectNode.FullPath); GetFoldersInFolder(projectNode, folders); // Move diffrently depending on whether it's a folder or document being moved if (isDocument) { DropdownDialog<string> folderDialog = new DropdownDialog<string>("Which folder should the document be moved to?", folders, true); folderDialog.ShowDialog(); if (folderDialog.Canceled) return; // Figure out new path string path = folderDialog.Selected; if (selectedProject.ToString() == path) path = ""; else path = path.Substring(selectedProject.ToString().Count() + 1); path = Regex.Replace(path, @"\\", "/"); moveDocument(path, selectedDocument.Id); } else { DropdownDialog<string> folderDialog = new DropdownDialog<string>("Which folder should the folder be moved to?", folders, true); folderDialog.ShowDialog(); if (folderDialog.Canceled) return; // Figure out new path string path = folderDialog.Selected; if (selectedProject.ToString() == path) path = ""; else path = path.Substring(selectedProject.ToString().Count() + 1); path = Regex.Replace(path, @"\\", "/"); MoveFolder(selectedFolder, path); } RefreshTreeView(); }
/** * Find out what projects that aren't on this storage yet, * ask the user for one to donwload, and then get all the documents * from that project */ private void getProjectButton_Click(object sender, EventArgs e) { try { // Ask server for all available projects List<Project> serverProjects = ServerController.GetAllProjectsAvailable(activeUser); List<Project> newProjects = new List<Project>(); // Check which ones that aren't added yet foreach (Project p in serverProjects) { bool contained = false; foreach (Project q in projects) { if (p.Id == q.Id) contained = true; } if (!contained) newProjects.Add(p); } // If there's no new projects, tell the user if (newProjects.Count == 0) MessageBox.Show("There are no new projects on the server"); else { // Show a dropdowndialog with all the choices DropdownDialog<Project> dialog = new DropdownDialog<Project>( "Choose a project from the server to download", newProjects); dialog.ShowDialog(); if (!dialog.Canceled) { Project newProject = dialog.Selected; // Ask the server for all document for the selected project List<Document> docs = ServerController.GetAllProjectDocuments(newProject); // Save it all Controller.UpdateProject(newProject); foreach (Document d in docs) { Controller.SaveDocument(newProject, d, activeUser, true); } } } RefreshTreeView(); } catch (Exception) { MessageBox.Show("Sorry, something went wrong trying to contact the server."); } }