private void OnAsyncConnectCompleted(object sender, AsyncTaskResultPostedEventArgs e) { this.Connecting = false; ConnectType data = (ConnectType) e.Data; ConnectionTask task = sender as ConnectionTask; if (((task != this._connectionTask) || task.IsCanceled) && (task.Database != null)) { try { task.Database.Disconnect(); } catch { } } else if (task.Database == null) { this.ReportError(task.Exception, "Unable to connect to the database."); } else { switch (data) { case ConnectType.ConnectButton: { this.ConnectionSettings.Filename = this._filenameEdit.Text; AccessDatabase database = new AccessDatabase(this.ConnectionSettings); try { database.Connect(); base.DialogResult = DialogResult.OK; base.Close(); return; } catch (Exception exception) { this.ReportError(exception.Message, "Unable to connect to the database."); } finally { database.Disconnect(); } break; } } task.Database.Disconnect(); } }
private void OnAsyncConnectCompleted(object sender, AsyncTaskResultPostedEventArgs e) { this.Connecting = false; ConnectType data = (ConnectType) e.Data; ConnectionTask task = sender as ConnectionTask; this._databaseCombo.Text = this._savedDatabaseText; if (((task != this._connectionTask) || task.IsCanceled) && (task.Database != null)) { try { task.Database.Disconnect(); } catch { } return; } if (task.Database == null) { this.ReportError(task.Exception, "Unable to connect to the database."); return; } this._databaseCombo.Items.Clear(); switch (data) { case ConnectType.DropDown: foreach (string str in task.Database.GetDatabaseNames()) { this._databaseCombo.Items.Add(str); } try { this._skipDropDownEvent = true; this._databaseCombo.DroppedDown = false; Application.DoEvents(); this._databaseCombo.DroppedDown = true; Application.DoEvents(); goto Label_0193; } finally { this._skipDropDownEvent = false; } break; case ConnectType.ConnectButton: break; default: goto Label_0193; } this.ConnectionSettings.Database = this._savedDatabaseText.Trim(); SqlDatabase database = new SqlDatabase(this.ConnectionSettings); try { database.Connect(); if (!database.DatabaseExists(this.ConnectionSettings.Database)) { throw new InvalidOperationException(string.Format("A database named '{0}' could not be found. Please check the connection settings and the spelling of the database name.", this.ConnectionSettings.Database)); } base.DialogResult = DialogResult.OK; base.Close(); return; } catch (Exception exception) { this.ReportError(exception.Message, "Unable to connect to the database."); } finally { database.Disconnect(); } Label_0193: task.Database.Disconnect(); }
private void OnConnectionComplete(object sender, AsyncTaskResultPostedEventArgs e) { this._gradientBand.Stop(); this._gradientBand.Visible = false; this._okButton.Enabled = true; this._connectionTask = null; this._connection = (FtpConnection) e.Data; if (this._connection != null) { this._httpUrl = this._httpUrlTextBox.Text.Trim(); if (this._httpUrl.EndsWith("/")) { this._httpUrl = this._httpUrl.Substring(0, this._httpUrl.Length - 1); } base.DialogResult = DialogResult.OK; base.Close(); } else { ((IMxUIService) this.GetService(typeof(IMxUIService))).ReportError("Could not connect to the specified FTP site.\r\nCheck the site address and user information before trying again.", this.Text, false); } }
private void OnSearchResultsPosted(object sender, AsyncTaskResultPostedEventArgs e) { if ((this._searchTask != null) && (this._searchTask == sender)) { ICollection data = e.Data as ICollection; if ((data != null) && (data.Count != 0)) { try { this._listView.BeginUpdate(); foreach (MemberInfo info in data) { System.Type reflectedType = info as System.Type; string extraData = string.Empty; if (reflectedType == null) { reflectedType = info.ReflectedType; if (this._searchOnly) { extraData = string.Concat(new object[] { info.Name, " [", info.MemberType, "]" }); } } OpenTypeProjectItem item = new OpenTypeProjectItem(reflectedType, this._project); item.EnsureTypeInformation(); ClassViewListViewItem item2 = new ClassViewListViewItem(item, extraData); this._listView.Items.Add(item2); } } finally { this._listView.EndUpdate(); } if (this._statusBar != null) { this._statusBar.SetProgress(Math.Max(10, e.PercentComplete)); this._statusBar.SetText("Searching..."); } this._listView.Focus(); this.UpdateCommands(); } if (e.IsComplete) { this._listView.WatermarkText = "No Classes Found"; if (this._statusBar != null) { this._statusBar.SetProgress(0); this._statusBar.SetText(string.Empty); } this._searchTask = null; } } }
private void OnSearchResultsPosted(object sender, AsyncTaskResultPostedEventArgs e) { if ((this._searchTask != null) && (this._searchTask == sender)) { ICollection data = e.Data as ICollection; if ((data != null) && (data.Count != 0)) { foreach (System.Type type in data) { this._searchResults.Add(type); } } if (e.IsComplete) { this._searchTask = null; System.Type type2 = null; if (this._searchResults.Count > 0) { foreach (System.Type type3 in this._searchResults) { if (type3.Name.ToLower() == this._searchString.ToLower()) { type2 = type3; break; } } } if (type2 != null) { ((IClassViewService) this).ShowType(type2); } else { IUIService service = (IUIService) base.ServiceProvider.GetService(typeof(IUIService)); if (service != null) { service.ShowMessage("No help found for '" + this._searchString + "'", "Help", MessageBoxButtons.OK); } } this._searchString = null; } } }
private void OnDownloadLibraryComplete(object sender, AsyncTaskResultPostedEventArgs args) { byte[] data = (byte[]) args.Data; if (data == null) { MessageBox.Show(this, "Error downloading library.", "Component Gallery", MessageBoxButtons.OK, MessageBoxIcon.Hand); } string tempFileName = Path.GetTempFileName(); try { FileStream stream = null; try { stream = new FileStream(tempFileName, FileMode.Create); stream.Write(data, 0, data.Length); stream.Flush(); } finally { if (stream != null) { stream.Close(); } } Interop.WINTRUST_FILE_INFO structure = new Interop.WINTRUST_FILE_INFO(); structure.cbStruct = Marshal.SizeOf(typeof(Interop.WINTRUST_FILE_INFO)); structure.pcwszFilePath = Marshal.StringToHGlobalUni(tempFileName); structure.hFile = IntPtr.Zero; Interop.WINTRUST_DATA pWinTrustData = new Interop.WINTRUST_DATA(); pWinTrustData.cbStruct = Marshal.SizeOf(typeof(Interop.WINTRUST_DATA)); pWinTrustData.pPolicyCallbackData = IntPtr.Zero; pWinTrustData.pSIPClientData = IntPtr.Zero; pWinTrustData.dwUIChoice = 1; pWinTrustData.fdwRevocationChecks = 1; pWinTrustData.dwUnionChoice = 1; IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(structure)); Marshal.StructureToPtr(structure, ptr, false); pWinTrustData.pSomething = ptr; try { if (Interop.WinVerifyTrust(base.Handle, ref Interop.WINTRUST_ACTION_GENERIC_VERIFY_V2, ref pWinTrustData) != 0) { this._library = null; } else { try { this._library = Library.CreateLibrary(data); base.DialogResult = DialogResult.OK; base.Close(); } catch { MessageBox.Show(this, "The downloaded library is invalid.", "Component Gallery", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } } finally { if (structure.pcwszFilePath != IntPtr.Zero) { Marshal.FreeHGlobal(structure.pcwszFilePath); } if (ptr != IntPtr.Zero) { Marshal.FreeHGlobal(ptr); } } } catch (Exception exception) { MessageBox.Show(this, exception.Message, "Component Gallery", MessageBoxButtons.OK, MessageBoxIcon.Hand); } finally { if (File.Exists(tempFileName)) { File.Delete(tempFileName); } } }