Exemplo n.º 1
0
        public bool SaveConfig(ipgwConfig myconfig)
        {
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.CreateXmlDeclaration("1.0", "utf-8", null);
            XmlElement root = xmldoc.CreateElement("ipgw");
            XmlElement node = xmldoc.CreateElement("uid");

            node.InnerText = myconfig.uid;
            root.AppendChild(node);
            node           = xmldoc.CreateElement("pwd");
            node.InnerText = myconfig.pwd;
            root.AppendChild(node);
            node           = xmldoc.CreateElement("linkOnStart");
            node.InnerText = myconfig.linkOnStart;
            root.AppendChild(node);
            node           = xmldoc.CreateElement("minOnStart");
            node.InnerText = myconfig.minOnStart;
            root.AppendChild(node);
            node           = xmldoc.CreateElement("onClosing");
            node.InnerText = myconfig.onClosing;
            root.AppendChild(node);

            xmldoc.AppendChild(root);
            try
            {
                xmldoc.Save(appdata + "/2645/ipgw_new/ipgw.config");
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 2
0
        public ConfigForm()
        {
            InitializeComponent();
            this.ch = new ConfigHelper();
            //检查是否为首次启动
            if (ch.Check())
            {
                this.myconfig                    = ch.LoadConfig();
                this.cancelButton.Enabled        = true;
                this.uidBox.Text                 = myconfig.uid;
                this.pwdBox.Text                 = myconfig.pwd;
                this.linkOnStartCheckBox.Checked = (myconfig.linkOnStart == "true");
                this.minOnStartCheckBox.Checked  = (myconfig.minOnStart == "true");
                switch (myconfig.onClosing)
                {
                case "none":
                    this.noneRadioButton.Checked = true;
                    break;

                case "exit":
                    this.exitRadioButton.Checked = true;
                    break;

                case "minimum":
                    this.minimumRadioButton.Checked = true;
                    break;
                }
            }
            else
            {
                this.cancelButton.Enabled = false;
                this.myconfig             = new ipgwConfig();
            }
        }
Exemplo n.º 3
0
 public MainForm()
 {
     InitializeComponent();
     this.ch       = new ConfigHelper();
     this.myconfig = new ipgwConfig();
     this.hh       = new httpHelper();
     this.tempE    = new onClosingForm.onClosingEventArgs();
     //检查是否为首次启动
     if (ch.Check())
     {
         this.myconfig = ch.LoadConfig();
     }
     else
     {
         MessageBox.Show("欢迎使用IP控制网关!在开始之前,请进行简单的配置。", "欢迎", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.button1_Click(new object(), new EventArgs());
     }
     //若需要,自动最小化
     if (this.myconfig.minOnStart == "true")
     {
         this.Visible             = false;
         this.ShowInTaskbar       = false;
         this.WindowState         = FormWindowState.Minimized;
         this.notifyIcon1.Visible = true;
     }
     //若需要,进行自动连接
     if (this.myconfig.linkOnStart == "true")
     {
         this.hh.Logout(this.myconfig.uid, this.myconfig.pwd);
         this.连接网络ToolStripMenuItem_Click(new object(), new EventArgs());
         this.获取信息ToolStripMenuItem_Click(new object(), new EventArgs());
     }
 }
Exemplo n.º 4
0
        public ipgwConfig LoadConfig()
        {
            XmlDocument xmldoc   = new XmlDocument();
            ipgwConfig  myconfig = new ipgwConfig();

            xmldoc.Load(appdata + "/2645/ipgw_new/ipgw.config");
            XmlNode root = xmldoc.SelectSingleNode(xmldoc.DocumentElement.Name);

            myconfig.uid         = root.SelectSingleNode("uid").InnerText;
            myconfig.pwd         = root.SelectSingleNode("pwd").InnerText;
            myconfig.linkOnStart = root.SelectSingleNode("linkOnStart").InnerText;
            myconfig.minOnStart  = root.SelectSingleNode("minOnStart").InnerText;
            myconfig.onClosing   = root.SelectSingleNode("onClosing").InnerText;
            return(myconfig);
        }
Exemplo n.º 5
0
 public onClosingForm(ipgwConfig myconfig)
 {
     InitializeComponent();
     this.myconfig = myconfig;
 }
Exemplo n.º 6
0
 /// <summary>
 /// 相应设置窗口改变设置事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void ConfigChanged(object sender, ConfigForm.ConfigChangedEventArgs e)
 {
     this.myconfig = e.myconfig;
 }