private void projectBtn_Click(object sender, RoutedEventArgs e) { var bt = sender as Button; if (bt != null) { if (bt.Name.Equals(this.selectLocationBtn.Name)) { System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog(); if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.projectLocationTb.Text = dialog.SelectedPath; } } else if (bt.Name.Equals(this.selectWorkspaceBtn.Name)) { System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog(); dialog.Description = "Your project files will be stored here."; dialog.ShowNewFolderButton = true; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.projectWorkspaceTb.Text = dialog.SelectedPath; } } else if (bt.Name.Equals(this.okBtn.Name)) { MyVersionManagementLib.M_ProjectClass project = null; string name = this.projectNameTb.Text; string description = this.projectDescriptionTb.Text; string location = this.projectLocationTb.Text; string workspace = this.projectWorkspaceTb.Text; int main = this.mainCmb.SelectedIndex + 1; int sub = this.subCmb.SelectedIndex; int stage = this.stageCmb.SelectedIndex; MyVersionManagementLib.M_VersionClass.GreekAlphabet greek = (MyVersionManagementLib.M_VersionClass.GreekAlphabet) this.greekCmb.SelectedIndex; MyVersionManagementLib.M_VersionClass version = new MyVersionManagementLib.M_VersionClass(DateTime.Now.ToString("yyyyMMdd"), main, sub, stage, greek); bool flag; string resDescription = ""; //create a new solution if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(location) || string.IsNullOrWhiteSpace(workspace) || string.IsNullOrWhiteSpace(description)) { flag = false; resDescription = "Project Name/Location/Workspace/Description is null or whitespace."; } else { project = new MyVersionManagementLib.M_ProjectClass(name, location, workspace, description, version); flag = true; resDescription = "Project create successfully."; } PassValuesEventArgs args = new PassValuesEventArgs(project, flag, resDescription); PassValuesEvent(this, args); this.Close(); } else if (bt.Name.Equals(this.cancleBtn.Name)) { PassValuesEventArgs args = new PassValuesEventArgs(null, false, "Create project canceled."); PassValuesEvent(this, args); this.Close(); } else { // } } }
private void projectBtn_Click(object sender, RoutedEventArgs e) { var bt = sender as Button; if (bt != null) { if (bt.Name.Equals(this.viewLocationBtn.Name)) { Process.Start(this.project.ProjectLocation); //System.Windows.Forms.FolderBrowserDialog dialog = // new System.Windows.Forms.FolderBrowserDialog(); //if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) //{ // this.projectLocationTb.Text = dialog.SelectedPath; //} } else if (bt.Name.Equals(this.selectOrViewWorkspaceBtn.Name)) { System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog(); dialog.Description = "Your project files will be stored here."; dialog.ShowNewFolderButton = true; dialog.SelectedPath = this.project.ProjectWorkspace; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.projectWorkspaceTb.Text = dialog.SelectedPath; } } else if (bt.Name.Equals(this.okBtn.Name)) { //MyVersionManagementLib.M_ProjectClass project = null; //string name = this.projectNameTb.Text; //string description = this.projectDescriptionTb.Text; //string location = this.projectLocationTb.Text; //string workspace = this.projectWorkspaceTb.Text; int main = this.mainCmb.SelectedIndex; int sub = this.subCmb.SelectedIndex; int stage = this.stageCmb.SelectedIndex; MyVersionManagementLib.M_VersionClass.GreekAlphabet greek = (MyVersionManagementLib.M_VersionClass.GreekAlphabet) this.greekCmb.SelectedIndex; MyVersionManagementLib.M_VersionClass version = new MyVersionManagementLib.M_VersionClass(DateTime.Now.ToString("yyyyMMdd"), main, sub, stage, greek); bool flag; string archiveResult; string resDescription = ""; this.project.CurrentProjectVersion.VersionDescription = this.projectDescriptionTb.Text; //更新版本号,默认只更新日期版本号 if (main < 0 || sub < 0 || stage < 0 || greek < 0) { flag = false; resDescription = "Project new version NO. is not select correctly."; } else { //判断是否需要进一步更新版本号(防止出现版本号相同的情况) if (this.project.CurrentProjectVersion.Version.CompareTo(version, out resDescription) >= 0) { version.Update(out resDescription); } if (this.project.Archive(out archiveResult, version) > 0) { flag = true; resDescription = "Project Archive successfully."; } else { flag = false; resDescription = "Project Archive Failed, Details: " + archiveResult; } } PassValuesEventArgs args = new PassValuesEventArgs(project, flag, resDescription); PassValuesEventMethod(args); this.Close(); } else if (bt.Name.Equals(this.cancleBtn.Name)) { PassValuesEventArgs args = new PassValuesEventArgs(null, false, "Archive project canceled."); PassValuesEventMethod(args); this.Close(); } else { // } } }