/// <summary>Hit when the user clicks on the Configuration button/</summary>
        /// <param name="sender">btnConfig</param>
        /// <param name="e">RoutedEventArgs</param>
        private void btnConfig_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                frmNewSpiraProject frmAddProject = new frmNewSpiraProject();

                if (frmAddProject.ShowDialog().Value)
                {
                    //If a solution is loaded now, get the loaded solution.
                    if (Business.StaticFuncs.GetEnvironment.Solution.IsOpen)
                    {
                        this.loadSolution((string)Business.StaticFuncs.GetEnvironment.Solution.Properties.Item("Name").Value, true);
                    }
                    else
                    {
                        this.loadSolution(null);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogMessage(ex, "btnConfig_Click()");
                MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
            }
            e.Handled = true;
        }
Exemple #2
0
        /// <summary>Hit when the user wants to add/edit a serverproject.</summary>
        /// <param name="sender">btnNew / btnEdit</param>
        /// <param name="e">Event Args</param>
        private void btnNewEdit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Button button = (Button)sender;

                //Create the form.
                frmNewSpiraProject frmAddProject = new frmNewSpiraProject();
                frmAddProject.Owner = this;

                if (button.Name == "btnEdit")
                {
                    //Get the item selected.
                    Business.SpiraProject proj = (Business.SpiraProject) this.lstAvailProjects.SelectedItem;
                    frmAddProject.txbServer.Text       = proj.ServerURL.AbsoluteUri;
                    frmAddProject.txbUserID.Text       = proj.UserName;
                    frmAddProject.txbUserPass.Password = proj.UserPass;
                    int projnum = frmAddProject.cmbProjectList.Items.Add(proj);
                    frmAddProject.cmbProjectList.SelectedIndex = projnum;
                }

                if (frmAddProject.ShowDialog().Value)
                {
                    if (frmAddProject.cmbProjectList.SelectedItem != null)
                    {
                        Business.SpiraProject selProject = (Business.SpiraProject)frmAddProject.cmbProjectList.SelectedItem;

                        //Add it to the available list if there's no existing ones.
                        bool AddToSelected = false;
                        for (int i = 0; i < this.lstAvailProjects.Items.Count;)
                        {
                            if (((Business.SpiraProject) this.lstAvailProjects.Items[i]).IsEqualTo(selProject))
                            {
                                this.lstAvailProjects.Items.RemoveAt(i);
                            }
                            else
                            {
                                i++;
                            }
                        }
                        for (int i = 0; i < this.lstSelectProjects.Items.Count;)
                        {
                            if (((Business.SpiraProject) this.lstSelectProjects.Items[i]).IsEqualTo(selProject))
                            {
                                this.lstSelectProjects.Items.RemoveAt(i);
                                AddToSelected = true;
                            }
                            else
                            {
                                i++;
                            }
                        }

                        if (AddToSelected)
                        {
                            this.lstSelectProjects.Items.Add(selProject);
                        }
                        else
                        {
                            this.lstAvailProjects.Items.Add(selProject);
                        }
                    }
                    this._hasChanged = true;
                }
            }
            catch (Exception ex)
            {
                Logger.LogMessage(ex, "btnNewEdit_Click()");
                MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }