private void Cmd_Criar_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (!(Utils.RemoveNonPathCharacters(Utils.AsciiCleaning(Txb_projectId.Text)).Equals(Txb_projectId.Text)) || Txb_projectId.Text.Equals("")) { MessageBox.Show("Ivalid ID!", "New project", MessageBoxButton.OK, MessageBoxImage.Error); } else { Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog(); saveFileDialog.Filter = "Projeto do Horus |*.hrp"; saveFileDialog.FileName = Txb_projectId.Text; saveFileDialog.DefaultExt = ".hrp"; saveFileDialog.InitialDirectory = Registry.Get("NewProjectLocation", ""); Nullable <bool> saveResult = saveFileDialog.ShowDialog(); if (saveResult ?? false) { Registry.Set("NewProjectLocation", System.IO.Path.GetDirectoryName(saveFileDialog.FileName)); Project novo = new Project(Txb_projectName.Text, Txb_projectDescription.Text, Txb_projectId.Text); if (Project.Write(novo, saveFileDialog.FileName)) { App.currentProject = novo; App.currentProjectPath = saveFileDialog.FileName; showHome = false; OpenProject openproject = new OpenProject(); openproject.Show(); this.Close(); } } } }
private void Cmd_open_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog(); openFileDialog.Filter = "Projeto do Horus |*.hrp"; openFileDialog.DefaultExt = ".hrp"; openFileDialog.InitialDirectory = Registry.Get("OpenProjectLocation", ""); Nullable <bool> openResult = openFileDialog.ShowDialog(); if (openResult ?? false) { Registry.Set("OpenProjectLocation", System.IO.Path.GetDirectoryName(openFileDialog.FileName)); Project novo = Project.Load(openFileDialog.FileName); App.currentProject = novo; App.currentProjectPath = openFileDialog.FileName; OpenProject openproject = new OpenProject(); openproject.Show(); this.Close(); } }