Example #1
0
        private void GetValuesHandler(object sender, PassValuesEventArgs args)
        {
            //获取新建的解决方案
            NewSolutionWindow nsw = sender as NewSolutionWindow;

            if (nsw != null &&
                args != null)
            {
                bool flag = args.Flag;

                if (flag == true)
                {
                    M_SolutionClass m = args.Result as M_SolutionClass;

                    if (m != null)
                    {
                        this.currentSolutionCollection.SolutionsCollection.Add(m);
                    }
                }

                this.otherLb.Content = args.Description;
            }
            else
            {
                NewProjectWindow npw = sender as NewProjectWindow;

                if (nsw != null &&
                    args != null)
                {
                    bool flag = args.Flag;

                    if (flag == true)
                    {
                        M_ProjectClass m = args.Result as M_ProjectClass;

                        if (m != null)
                        {
                            this.currentSolution.SolutionProjectsCollection.Add(m);
                        }
                    }

                    this.otherLb.Content = args.Description;
                }
                else
                {
                    ArchiveProjectWindow apw = sender as ArchiveProjectWindow;

                    if (apw != null &&
                        args != null)
                    {
                        //bool flag = args.Flag;

                        //if (flag == true)
                        //{
                        //    M_SolutionClass m = args.Result as M_SolutionClass;

                        //    if (m != null)
                        //    {
                        //        this.currentSolutionCollection.SolutionsCollection.Add(m);
                        //    }
                        //}

                        this.otherLb.Content = args.Description;

                        //更新解决方案显示
                        //this.currentProjectItem.Header = this.currentProject.CurrentProjectVersion.Name;
                    }
                    else
                    {
                        this.otherLb.Content = "Incorrect Sender or Invalid args";
                    }
                }
            }
        }
        private void projectBtn_Click(object sender, RoutedEventArgs e)
        {
            Button bt = sender as Button;

            if (bt != null)
            {
                if (bt.Name.Equals(this.AddProjectBtn.Name))
                {
                    //todo
                    NewProjectWindow npw = new NewProjectWindow();
                    npw.PassValuesEvent +=
                        (ss, ee) =>
                    {
                        this.infoSbi.Content = ee.Description;

                        if (ee.Flag == true)
                        {
                            MyVersionManagementLib.M_ProjectClass project =
                                ee.Result as MyVersionManagementLib.M_ProjectClass;

                            if (project != null)
                            {
                                this.projectsCollection.Add(project);
                            }
                        }
                    };

                    npw.ShowDialog();
                }
                else if (bt.Name.Equals(this.removeProjectBtn.Name))
                {
                    //todo
                    if (this.projectsCollection != null &&
                        this.projectsCollection.Count > 0 &&
                        this.projectsCollectionTv.SelectedIndex >= 0)
                    {
                        this.projectsCollection.RemoveAt(this.projectsCollectionTv.SelectedIndex);
                    }
                }
                else if (bt.Name.Equals(this.okBtn.Name))
                {
                    MyVersionManagementLib.M_SolutionClass solution = null;
                    string name        = this.solutoinTitleTb.Text;
                    string description = this.solutionDescriptionTb.Text;
                    bool   flag;
                    string resDescription = "";

                    //create a new solution
                    if (string.IsNullOrWhiteSpace(name) ||
                        string.IsNullOrWhiteSpace(description))
                    {
                        flag = false;

                        resDescription = "Solution Name/Description is null or whitespace.";
                    }
                    else
                    {
                        solution = new MyVersionManagementLib.M_SolutionClass(name, description);

                        if (this.projectsCollection != null &&
                            this.projectsCollection.Count > 0)
                        {
                            foreach (MyVersionManagementLib.M_ProjectClass p in this.projectsCollection)
                            {
                                solution.SolutionProjectsCollection.Add(p);
                            }
                        }

                        flag = true;

                        resDescription = "Solution create successfully.";
                    }

                    PassValuesEventArgs args = new PassValuesEventArgs(solution, flag, resDescription);

                    PassValuesEvent(this, args);

                    this.Close();
                }
                else if (bt.Name.Equals(this.cancleBtn.Name))
                {
                    //
                    PassValuesEventArgs args = new PassValuesEventArgs(null, false, "Create solution canceled.");

                    PassValuesEvent(this, args);

                    this.Close();
                }
                else
                {
                    //
                }
            }
        }