Exemplo n.º 1
0
        private void playBtn_Click(object sender, RoutedEventArgs e)
        {
            GameDataGrid gdg         = (GameDataGrid)Display_game_results.SelectedItem;
            InputDialog  inputDialog = new InputDialog("How much credit would you like to use?", "0");
            int          credit      = 0;

            if (inputDialog.ShowDialog() == true)
            {
                credit = Int32.Parse(inputDialog.Answer);
            }
            //Join game function
            manager.JoinGame(gdg.ID, credit);
        }
Exemplo n.º 2
0
        /**
         * When the user hits the new doc button, it asks for the name and then
         * saves it to the storage.
         */
        private void createDocumentButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Make sure a destination is selected
                if (treeView.SelectedNode == null)
                {
                    MessageBox.Show("Please select destination of new document");
                }
                else
                {
                    InputDialog inputDialog = new InputDialog("Input name of new Document");
                    inputDialog.ShowDialog();

                    if (!inputDialog.Canceled)
                    {
                        string   title  = inputDialog.Input;
                        Document newDoc = new Document("", title, activeUser);

                        // Create a path for the document
                        string path = treeView.SelectedNode.FullPath;
                        if (selectedFolder.FileType == DocType.Project)
                        {
                            path = "";
                        }
                        else if (isDocument)
                        {
                            path = path.Substring(
                                selectedProject.ToString().Count() + 1,
                                path.Count() - selectedDocument.Title.Count() - selectedProject.ToString().Count() - 2);
                        }
                        else
                        {
                            path = path.Substring(selectedProject.ToString().Count() + 1);
                        }



                        path = Regex.Replace(path, @"\\", "/");

                        Controller.CreateDocument(activeUser, path, selectedProject, title);

                        RefreshTreeView();
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Sorry, something went wrong trying to contact the server.");
            }
        }
Exemplo n.º 3
0
        /**
         * Called when the window is loaded.
         */
        private void MainWindow_Load(object sender, EventArgs e)
        {
            // Ask for who the user is
            InputDialog inputDialog = new InputDialog("Hello and welcome! Who are you? (Input username)",
                                                      "",
                                                      false);

            inputDialog.ShowDialog();
            activeUser = new User(inputDialog.Input);

            userLabel.Text = "Logged in as: " + activeUser.ToString();

            RefreshTreeView();
        }
Exemplo n.º 4
0
        private void createFolderButton_Click(object sender, EventArgs e)
        {
            // Make sure a destination is selected
            if (treeView.SelectedNode == null)
            {
                MessageBox.Show("Please select destination of new folder");
            }
            else
            {
                InputDialog inputDialog = new InputDialog("What should your new folder be called?", "name");
                inputDialog.ShowDialog();
                if (!inputDialog.Canceled)
                {
                    if (!CheckName(inputDialog.Input))
                    {
                        return;
                    }

                    string path;
                    // If the project root itself is selected, just discard the whole path
                    if (selectedFolder.FileType == DocType.Project)
                    {
                        path = inputDialog.Input;
                    }
                    else
                    {
                        path = treeView.SelectedNode.FullPath;
                        path = path.Substring(selectedProject.ToString().Count() + 1);

                        if (isDocument)
                        {
                            path = path.Substring(0, path.Count() - selectedDocument.Title.Count() - 1);
                        }

                        path = Regex.Replace(path, @"\\", "/");

                        path += "/" + inputDialog.Input;
                    }

                    Controller.CreateDocument(activeUser, path, selectedProject, "Welcome to your new folder!");
                }
                RefreshTreeView();
            }
        }
Exemplo n.º 5
0
        private void renameButton_Click(object sender, EventArgs e)
        {
            // If a document was selected
            if (isDocument)
            {
                InputDialog inputDialog = new InputDialog("Input new name for Document", selectedDocument.Title);
                inputDialog.ShowDialog();

                if (!inputDialog.Canceled)
                {
                    Document doc = Controller.OpenDocument(selectedProject.Id, selectedDocument.Id);
                    doc.Title = inputDialog.Input;
                    Controller.SaveDocument(selectedProject, doc, activeUser);
                }
            }
            // or if a folder was selected
            else if (selectedFolder.FileType == DocType.Folder)
            {
                InputDialog inputDialog = new InputDialog("Input new name for Folder", selectedFolder.Title);
                inputDialog.ShowDialog();

                if (!inputDialog.Canceled)
                {
                    if (!CheckName(inputDialog.Input))
                    {
                        return;
                    }

                    // Build the old and new part of the path for documents
                    string fullpath = treeView.SelectedNode.FullPath;
                    string oldpath  = fullpath.Substring(selectedProject.ToString().Count() + 1);
                    oldpath = Regex.Replace(oldpath, @"\\", "/");

                    string newpath = oldpath.Substring(0, oldpath.Count() - selectedFolder.Title.Count());
                    newpath += inputDialog.Input;

                    RenameFolderChildren(selectedFolder, oldpath, newpath);
                }
            }

            RefreshTreeView();
        }