コード例 #1
0
ファイル: ProjectForm.cs プロジェクト: LazyBui/Peygir
        private void AddMilestone()
        {
            using (var form = new MilestoneDetailsForm(mContext, Project, null)) {
                if (form.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                Milestone milestone = form.RetrieveMilestone();

                // Add.
                milestone.Add(mContext);

                // Flush.
                mContext.Flush();

                // Show milestones.
                ShowMilestones();

                FormUtil.SelectNew(milestonesListView, milestone);

                PopulateTicketFilters();

                UpdateButtonsEnabledProperty();

                milestonesListView.Focus();
            }
        }
コード例 #2
0
        private void projectComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            int selectedIndex = projectComboBox.SelectedIndex;

            milestoneComboBox.BeginUpdate();
            milestoneComboBox.SelectedItem = null;
            milestoneComboBox.Items.Clear();
            milestoneComboBox.Enabled = false;
            if (selectedIndex != -1)
            {
                var project    = (Project)projectComboBox.SelectedItem;
                var milestones = project.GetMilestones(mContext);
                if (!milestones.Any())
                {
                    DialogResult result = MessageBox.Show(
                        Resources.String_AskUserAboutMilestone,
                        Resources.String_Error,
                        MessageBoxButtons.YesNoCancel,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        FormUtil.GetMessageBoxOptions(this));

                    if (result == DialogResult.Yes)
                    {
                        using (var form = new MilestoneDetailsForm(mContext, project, null)) {
                            if (form.ShowDialog() != DialogResult.OK)
                            {
                                return;
                            }
                            Milestone milestone = form.RetrieveMilestone();

                            // Add.
                            milestone.Add(mContext);

                            // Flush.
                            mContext.Flush();

                            milestones = new[] { milestone };
                        }
                    }
                }
                milestoneComboBox.Items.AddRange(milestones);
                milestoneComboBox.Enabled = milestones.Any();
                if (milestones.Length == 1)
                {
                    milestoneComboBox.SelectedItem = milestones[0];
                }
            }
            milestoneComboBox.EndUpdate();
        }