Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
        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);
        }