private void BtnEditConnection_Click(object sender, EventArgs e) { var connectionNode = tvQpInstructions.SelectedNode; var connectionContext = connectionNode.Tag as ConnectionContext; if (connectionContext == null) { return; } var form = new ConnectForm(); form.EditConnectionInfo(connectionContext.ConnectionInfo); var ret = form.ShowDialog(); if (ret != DialogResult.OK) { return; } var connectionInfo = form.ConnectionInfo; connectionContext.Dispose(); treeNodeCollection.Remove(connectionNode); addConnection(connectionInfo); QpdFileUtils.SaveQpbFile(connectionInfo); }
private void BtnImportConnectionFile_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = QPDFILE_FILTER; var ret = ofd.ShowDialog(); if (ret == DialogResult.Cancel) { return; } try { var file = ofd.FileName; ConnectionInfo connectionInfo = QpdFileUtils.Load(file); connectionInfo.Name = Path.GetFileNameWithoutExtension(file); addConnection(connectionInfo); QpdFileUtils.SaveQpbFile(connectionInfo); MessageBox.Show("导入成功!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show($"导入失败,原因:{ExceptionUtils.GetExceptionMessage(ex)}", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void MainForm_Load(object sender, EventArgs e) { var connectionInfos = QpdFileUtils.GetConnectionInfosFromQpbFileFolder(); if (connectionInfos != null) { foreach (var connectionInfo in connectionInfos) { addConnection(connectionInfo); } } }
private void BtnAddConnection_Click(object sender, EventArgs e) { var form = new ConnectForm(); var ret = form.ShowDialog(); if (ret != DialogResult.OK) { return; } var connectionInfo = form.ConnectionInfo; addConnection(connectionInfo); QpdFileUtils.SaveQpbFile(connectionInfo); }
private async void BtnConnectConnection_Click(object sender, EventArgs e) { var connectionNode = tvQpInstructions.SelectedNode; var connectionContext = connectionNode.Tag as ConnectionContext; if (connectionContext == null) { return; } this.Enabled = false; try { var preConnectionInfoContent = Quick.Xml.XmlConvert.Serialize(connectionContext.ConnectionInfo); await connectionContext.Connect(); connectionNode.ImageIndex = connectionNode.SelectedImageIndex = 1; connectionContext.QpClient.Disconnected += (sender, e) => { Invoke(new Action(() => { connectionNode.ImageIndex = connectionNode.SelectedImageIndex = 0; connectionContext.Dispose(); })); }; displayInstructions(connectionNode, connectionContext.ConnectionInfo.Instructions); connectionNode.ExpandAll(); var currentConnectionInfoContent = Quick.Xml.XmlConvert.Serialize(connectionContext.ConnectionInfo); if (currentConnectionInfoContent != preConnectionInfoContent) { QpdFileUtils.SaveQpbFile(connectionContext.ConnectionInfo); } } catch (Exception ex) { MessageBox.Show($"连接失败,原因:{ExceptionUtils.GetExceptionMessage(ex)}", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } this.Enabled = true; }
private void BtnDelConnection_Click(object sender, EventArgs e) { var connectionNode = tvQpInstructions.SelectedNode; var connectionContext = connectionNode.Tag as ConnectionContext; if (connectionContext == null) { return; } var ret = MessageBox.Show($"确定要删除连接[{connectionContext.ConnectionInfo.Name}]?", "删除确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (ret == DialogResult.Cancel) { return; } connectionContext.Dispose(); treeNodeCollection.Remove(connectionNode); QpdFileUtils.DeleteQpbFile(connectionContext.ConnectionInfo); }
private void BtnExportConnectionFile_Click(object sender, EventArgs e) { var connectionNode = tvQpInstructions.SelectedNode; var connectionContext = connectionNode.Tag as ConnectionContext; if (connectionContext == null) { return; } SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = QPDFILE_FILTER; var ret = sfd.ShowDialog(); if (ret == DialogResult.Cancel) { return; } var file = sfd.FileName; QpdFileUtils.SaveQpbFile(connectionContext.ConnectionInfo, file); MessageBox.Show("导出成功!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); }