コード例 #1
0
ファイル: MainForm.cs プロジェクト: modulexcite/Strike.NET
        private void menuItemExit_Click(object sender, EventArgs e)
        {
            if (SearchBackgroundWorker.IsBusy)
            {
                SearchBackgroundWorker.CancelAsync();
            }

            Application.Exit();
        }
コード例 #2
0
 private void SearchButton_Click(object sender, EventArgs e)
 {
     if (ResultsListView.Focused)
     {
         // submit will show messages if results view has focus
         ShowSelectedUsers();
     }
     else if (this.IsSearching)
     {
         // if searching, stop the search
         this.IsSearching = false;
         SearchBackgroundWorker.CancelAsync();
     }
     else
     {
         // perform search
         this.IsSearching         = true;
         this.SearchButton.Text   = "Stop";
         this.statusStrip.Visible = true;
         int statusHeight = this.statusStrip.Height;
         this.MinimumSize = new Size(_originalSize.Width, _originalSize.Height + statusHeight);
         int preferredHeight = this.MinimumSize.Height * 2 + statusHeight;
         if (this.Height < preferredHeight)
         {
             this.Size = new Size(this.Width, preferredHeight);
         }
         if (!SearchBackgroundWorker.IsBusy) // BUGFIX #36: check bg worker status before invoking
         {
             // search by properties
             this.ResultsListView.Items.Clear();
             this.ResultsListView.Cursor    = Cursors.WaitCursor;
             this.toolStripStatusLabel.Text = "Searching...";
             Application.DoEvents();
             this.ResultsListView.BeginUpdate();
             SearchBackgroundWorker.RunWorkerAsync(new SearchParameters()
             {
                 Name              = _displayNameTextBox.Text,
                 Email             = _emailTextBox.Text,
                 CandidateID       = _candidatePicker.SelectedCid,
                 ElectionCycle     = _electionPicker.SelectedElection == null ? null : _electionPicker.SelectedElection.Cycle,
                 GroupID           = _groupComboBox.SelectedGroup,
                 Disabled          = _disabledCheckBox.CheckState == CheckState.Indeterminate ? null : (bool?)(_disabledCheckBox.Checked),
                 Locked            = _lockedCheckBox.CheckState == CheckState.Indeterminate ? null : (bool?)(_lockedCheckBox.Checked),
                 Used              = _loggedInCheckBox.CheckState == CheckState.Indeterminate ? null : (bool?)(_loggedInCheckBox.Checked),
                 CreationStartDate = _createStartDatePicker.Enabled ? (DateTime?)_createStartDatePicker.Value.Date : null,
                 CreationEndDate   = _createEndDatePicker.Enabled ? (DateTime?)_createEndDatePicker.Value.Date : null,
             });
         }
     }
 }
コード例 #3
0
 private void SearchButton_Click(object sender, EventArgs e)
 {
     if (ResultsListView.Focused)
     {
         // submit will show messages if results view has focus
         ShowSelectedMessages();
     }
     else if (this.IsSearching)
     {
         // if searching, stop the search
         this.IsSearching = false;
         SearchBackgroundWorker.CancelAsync();
     }
     else
     {
         // perform search
         this.IsSearching         = true;
         this.SearchButton.Text   = "Stop";
         this.statusStrip.Visible = true;
         int statusHeight = this.statusStrip.Height;
         this.MinimumSize = new Size(_originalSize.Width, _originalSize.Height + statusHeight);
         int preferredHeight = this.MinimumSize.Height * 2 + statusHeight;
         if (this.Height < preferredHeight)
         {
             this.Size = new Size(this.Width, preferredHeight);
         }
         if (!SearchBackgroundWorker.IsBusy) // BUGFIX #36: check bg worker status before invoking
         {
             // search by properties
             this.ResultsListView.Items.Clear();
             this.ResultsListView.Cursor    = Cursors.WaitCursor;
             this.toolStripStatusLabel.Text = "Searching...";
             Application.DoEvents();
             this.ResultsListView.BeginUpdate();
             SearchBackgroundWorker.RunWorkerAsync(new SearchParameters()
             {
                 CandidateID     = _candidatePicker.SelectedCid,
                 ElectionCycle   = _electionPicker.SelectedElection == null ? null : _electionPicker.SelectedElection.Cycle,
                 Creator         = _cfbEmployeePicker.SelectedEmployee,
                 Category        = _categoryComboBox.SelectedCategory,
                 Title           = string.IsNullOrEmpty(_subjectTextBox.Text) ? null : _subjectTextBox.Text,
                 Body            = string.IsNullOrEmpty(_bodyTextBox.Text) ? null : _bodyTextBox.Text,
                 PostedStartDate = _postedStartDatePicker.Enabled ? (DateTime?)_postedStartDatePicker.Value.Date : null,
                 PostedEndDate   = _postedEndDatePicker.Enabled ? (DateTime?)_postedEndDatePicker.Value.Date : null,
                 Opened          = _openedCheckBox.CheckState == CheckState.Indeterminate ? null : (bool?)_openedCheckBox.Checked,
                 HasAttachments  = _attachmentsCheckBox.CheckState == CheckState.Indeterminate ? null : (bool?)_attachmentsCheckBox.Checked,
             });
         }
     }
 }