Exemplo n.º 1
0
        private void txtRemoteAddress_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (txtRemoteAddress.SelectedItem != null && txtRemoteAddress.SelectedItem is ConfigFileEntity)
            {
                ConfigFileEntity cfe = txtRemoteAddress.SelectedItem as ConfigFileEntity;

                txtRemotePass.Text = cfe.RemotePass;
                txtRemoteFile.Text = cfe.RemoteFile;
                txtRemoteName.Text = cfe.RemoteName;
            }
        }
Exemplo n.º 2
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtRemoteAddress.Text))
                {
                    DialogResult = DialogResult.Cancel;
                    return;
                }

                RemoteConfigObj = Activator.GetObject(typeof(Z.C.RemoteConfig), GetRemoteAddress()) as RemoteConfig;

                //检查是否能够正常使用
                RemoteConfigObj.GetConfig(txtRemoteName.Text, txtRemotePass.Text);

                if (txtRemoteAddress.SelectedItem is ConfigFileEntity)
                {
                }
                else
                {
                    //检查是否有重复的, 如果是重复的, 则重新赋值
                    ConfigFileEntity cfe = ManagerConfig.Instance.Find(txtRemoteAddress.Text);

                    if (cfe != null)
                    {
                        cfe.RemotePass = txtRemotePass.Text;
                        cfe.RemoteFile = txtRemoteFile.Text;
                    }
                    else
                    {
                        cfe = new ConfigFileEntity();

                        cfe.RemoteAddress = GetRemoteAddress();
                        cfe.RemotePass    = txtRemotePass.Text;
                        cfe.RemoteFile    = txtRemoteFile.Text;
                        cfe.RemoteName    = txtRemoteName.Text;

                        ManagerConfig.Instance.List.Add(cfe);
                        ManagerConfig.Instance.List.Sort();
                    }
                    ManagerConfig.Save();
                }

                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                ConfigFileEntity cfe = new ConfigFileEntity();

                cfe.RemoteAddress = txtRemoteAddress.Text;
                cfe.RemotePass    = txtRemotePass.Text;
                cfe.RemoteName    = txtRemoteName.Text;
                cfe.RemoteFile    = txtRemoteFile.Text;

                cfe.Content = txtConfigXml.Text;

                MessageBox.Show(saveFileDialog1.FileName);

                File.WriteAllText(saveFileDialog1.FileName, Z.Util.XmlTools.ToXml(cfe));

                btnSave.Enabled = false;
            }
        }
Exemplo n.º 4
0
        void OpenConfig(ConfigFileEntity config)
        {
            try
            {
                if (string.IsNullOrEmpty(config.RemoteAddress))
                {
                    return;
                }

                RemoteConfigObj = Activator.GetObject(typeof(Z.C.RemoteConfig), config.RemoteAddress) as RemoteConfig;

                //检查是否能够正常使用
                string strConfig = RemoteConfigObj.GetConfig(config.RemoteName, config.RemotePass).Trim();

                txtConfigXml.Text = strConfig;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message);
            }
        }
Exemplo n.º 5
0
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     CurrentConfig = e.Argument as ConfigFileEntity;
     OpenConfig(e.Argument as ConfigFileEntity);
 }