예제 #1
0
 /// <summary>
 /// 窗口关闭
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Window_Closed(object sender, EventArgs e)
 {
     if (IsModify)
     {
         if (MessageBox.Show("修改成功!重启软件生效。是否立即重启软件?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
         {
             AGVUtils.RestartSystem();
         }
     }
 }
예제 #2
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (string.IsNullOrEmpty(tbAGVnum.Text.Trim()))
            {
                MessageBox.Show("输入不能为空!");
                tbAGVnum.Focus();
                e.Cancel = true;
                return;
            }
            Regex regex = new Regex(@"^[0-9]*[1-9][0-9]*$");//匹配正整数

            if (!regex.IsMatch(tbAGVnum.Text.Trim()))
            {
                MessageBox.Show("请输入正整数字!");
                tbAGVnum.Focus();
                e.Cancel = true;
                return;
            }
            try
            {
                Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                cfa.AppSettings.Settings["AGVNUM_MAX"].Value = tbAGVnum.Text.Trim();
                cfa.AppSettings.Settings["MapScale"].Value   = tbMapScale.Text.Trim();
                cfa.AppSettings.Settings["TRAFFICFUN"].Value = cbTrafficFun.IsChecked.ToString();
                cfa.AppSettings.Settings["DOCKFUN"].Value    = cbDockFun.IsChecked.ToString();
                cfa.AppSettings.Settings["CHARGEFUN"].Value  = cbChargeFun.IsChecked.ToString();
                cfa.AppSettings.Settings["CALLFUN"].Value    = cbCallFun.IsChecked.ToString();
                cfa.AppSettings.Settings["CLIENTFUN"].Value  = cbClientFun.IsChecked.ToString();
                cfa.Save(ConfigurationSaveMode.Modified);
                if (!GetParamString().Equals(InitParamString))
                {
                    if (MessageBox.Show("修改成功!重启软件生效。是否立即重启软件?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                    {
                        AGVUtils.RestartSystem();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("修改失败!原因:" + ex.Message);
                e.Cancel = true;
            }
        }
예제 #3
0
 /// <summary>
 /// 修改配置参数
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnModify_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(tbAGVnum.Text.Trim()))// || string.IsNullOrEmpty(tbWaiting.Text.Trim()))
         {
             MessageBox.Show("输入不能为空!");
             return;
         }
         Regex regex = new Regex(@"^[0-9]*[1-9][0-9]*$"); //匹配正整数
         if (regex.IsMatch(tbAGVnum.Text.Trim()))         // && regex.IsMatch(tbWaiting.Text.Trim()))
         {
             Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
             cfa.AppSettings.Settings["AGVNUM_MAX"].Value = tbAGVnum.Text.Trim();
             cfa.AppSettings.Settings["MapScale"].Value   = tbMapScale.Text.Trim();
             cfa.AppSettings.Settings["TRAFFICFUN"].Value = cbTrafficFun.IsChecked.ToString();
             cfa.AppSettings.Settings["DOCKFUN"].Value    = cbDockFun.IsChecked.ToString();
             cfa.AppSettings.Settings["CHARGEFUN"].Value  = cbChargeFun.IsChecked.ToString();
             cfa.AppSettings.Settings["CALLFUN"].Value    = cbCallFun.IsChecked.ToString();
             cfa.AppSettings.Settings["CLIENTFUN"].Value  = cbClientFun.IsChecked.ToString();
             //cfa.AppSettings.Settings["TRAFFIC_CONAREA_MAX"].Value = tbTraffic.Text.Trim();
             //cfa.AppSettings.Settings["TRAFFIC_CONAREA_MARKNUM_MAX"].Value = tbMark.Text.Trim();
             //cfa.AppSettings.Settings["TRAFFIC_CONAREA_WAITAGVNUM_MAX"].Value = tbWaiting.Text.Trim();
             cfa.Save(ConfigurationSaveMode.Modified);
             if (MessageBox.Show("修改成功!重启软件生效。是否立即重启软件?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
             {
                 AGVUtils.RestartSystem();
             }
         }
         else
         {
             MessageBox.Show("请输入正整数字!");
         }
     }
     catch
     {
         MessageBox.Show("修改失败!");
     }
 }