Пример #1
0
 // ReSharper restore InconsistentNaming
 // ReSharper disable InconsistentNaming
 private void _cs_GetAsyncSearchResultPartCompleted(object sender, GetAsyncSearchResultPartCompletedEventArgs e)
 {
     if (e.Error == null && !_searchCancelled)
     {
         Results = e.Result;
         if (Results != null && Results.Length > 0)
         {
             var resultsForm = new frmResults(Results, _cs, _ci, _token, _transferType, _closeOnTransfer)
             {
                 Icon = _owner.Icon,
                 Text = Application.ProductName + ": ChemSpider " + _searchType + " Search Results"
             };
             resultsForm.StructureTransfering += (resultsForm_StructureTransfering);
             _frmProgress.Close();
             resultsForm.Show(_owner);
         }
         else
         {
             _owner.Cursor = Cursors.Default;
             _frmProgress.Close();
             Application.DoEvents();
             if (!_errorState)
                 MessageBox.Show(_owner, "Search found no hits", Application.ProductName, MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
         }
     }
     else
     {
         _errorState = true;
         _frmProgress.Close();
         Application.DoEvents();
         _owner.Cursor = Cursors.Default;
         MessageBox.Show(_owner, "Error executing search: " + e.Error.Message, Application.ProductName, MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
     }
 }
Пример #2
0
        // ReSharper restore InconsistentNaming
        // ReSharper disable InconsistentNaming
        void cs_SimpleSearchCompleted(object sender, SimpleSearchCompletedEventArgs e)
        {
            if (!e.Cancelled && !_searchCancelled)
            {
                if (e.Error == null)
                {
                    if (e.Result.Length != 0)
                    {
                        Results = e.Result;
                        var resultsForm = new frmResults(Results, _cs, _ci, _token, _transferType, _closeOnTransfer)
                        { Icon = _owner.Icon, Text = Application.ProductName + ": ChemSpider Text Search Results" };
                        resultsForm.StructureTransfering += (resultsForm_StructureTransfering);
                        _frmProgress.Close();
                        Application.DoEvents();
                        resultsForm.Show(_owner);
                    }
                    else
                    {
                        _owner.Cursor = Cursors.Default;
                        _frmProgress.Close();
                        Application.DoEvents();
                        if (!_errorState)
                            MessageBox.Show(_owner, "Search found no hits", Application.ProductName, MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }

                }
                else
                {
                    _owner.Cursor = Cursors.Default;
                    _frmProgress.Close();
                    Application.DoEvents();
                    MessageBox.Show(_owner, "Error executing search: " + e.Error.Message, Application.ProductName,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }

            }
            else
            {
                _owner.Cursor = Cursors.Default;
                _frmProgress.Close();
                Application.DoEvents();
                if (!_errorState)
                    MessageBox.Show(_owner, "Search cancelled by user", Application.ProductName, MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
        }