Esempio n. 1
0
        /// <summary>
        /// 点击启用单选框触发更改启用的配置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ChangeUsed(object sender, RoutedEventArgs e)
        {
            RadioButton button = (RadioButton)sender;

            if (nowUsed != null)
            {
                //try
                {
                    if (isTaskChange)
                    {
                        isTaskChange = false;
                        isListChange = false;
                        return;
                    }
                    button.IsChecked = true;
                    ListViewItem list  = (ListViewItem)New.FindName("UUID" + nowUsed.UUID);
                    RadioButton  radio = (RadioButton)list.FindName("CHECK" + nowUsed.UUID);
                    radio.IsChecked = false;

                    for (int i = 0; i <= TaskBarConfigList.Items.Count - 1; i++)
                    {
                        MenuItem menuItem = (MenuItem)TaskBarConfigList.Items[i];
                        if (menuItem.Name == "MENU" + button.Name.Substring(5))
                        {
                            isListChange       = true;
                            menuItem.IsChecked = true;
                            break;
                        }
                    }
                    for (int i = 0; i <= TaskBarConfigList.Items.Count - 1; i++)
                    {
                        MenuItem menuItem = (MenuItem)TaskBarConfigList.Items[i];
                        if (menuItem.Name == "MENU" + nowUsed.UUID)
                        {
                            isListChange       = true;
                            menuItem.IsChecked = false;
                            break;
                        }
                    }
                }
                //catch { }
            }
            for (int i = 0; i <= configs.Count - 1; i++)
            {
                if (configs[i].isUsed == true)
                {
                    if (configs[i].UUID == button.Name.Substring(5))
                    {
                        return;
                    }
                    configs[i].isUsed = false;
                    break;
                }
            }
            for (int i = 0; i <= configs.Count - 1; i++)
            {
                if (configs[i].UUID == button.Name.Substring(5))
                {
                    configs[i].isUsed = true;
                    nName.Text        = configs[i].Name;
                    nIP.Text          = configs[i].iP;
                    nAdd.Text         = configs[i].iPAdditional;
                    nSever.Text       = configs[i].severIP + ":" + configs[i].severPost;
                    nTeamName.Text    = configs[i].teamName;
                    nPassword.Text    = configs[i].teamPassword;
                    nowUsed           = configs[i];
                    break;
                }
            }
            File.Delete("Save\\Config.ssn2n");
            for (int i = 0; i <= configs.Count - 1; i++)
            {
                SaveLoader.AddSave(configs[i]);
            }
            isListChange = false;
            if (isRun)
            {
                SSUserClass.Proc.KillProc(SSUserClass.Proc.GetProc("edge"));
                isOpen.Text = "正在启动";
                ProgressBarHelper.SetAnimateTo(openPer, 50);
                RunFun();
            }
        }
Esempio n. 2
0
        private void OK_Click(object sender, RoutedEventArgs e)
        {
            panErrorMsg.Visibility = Visibility.Collapsed;
            switch (errMode)
            {
            case 1:         //未安装Tap运行环境
            {
                try
                {
                    Process.Start(Environment.CurrentDirectory + "\\System\\tap-windows.exe");
                }
                catch (Exception ex)
                {
                    errMode = 3;
                    panErrorMsg.Visibility = Visibility.Visible;
                    errorTitle.Text        = "打开失败";
                    errorSays.Text         = "请确认下载的程序包完整性……\n" + ex;
                }
            }
            break;

            case 2:
            {
                ProcessStartInfo psi = new ProcessStartInfo();
                psi.FileName = Process.GetCurrentProcess().MainModule.FileName;
                psi.Verb     = "runas";
                try
                {
                    Process.Start(psi);
                    Application.Current.Shutdown();
                }
                catch (Exception eE)
                {
                    MessageBox.Show("失败:" + eE);
                    Application.Current.Shutdown();
                }
            }
            break;

            case 3:
            {
                Application.Current.Shutdown();
            }
            break;

            case 4:
            {
                bool noSave = false;
                int  what   = -1;
                for (int i = 0; i <= configs.Count - 1; i++)
                {
                    if ((configs[i].Name) == Name.Text)
                    {
                        what = i;
                        break;
                    }
                }
                if (!String.IsNullOrWhiteSpace(IP.Text))
                {
                    configs[what].iP = IP.Text;
                }
                else
                {
                    noSave = true;
                }
                if (!String.IsNullOrWhiteSpace(IPAdd.Text))
                {
                    configs[what].iPAdditional = IPAdd.Text;
                }
                configs[what].isDHCP = isDHCP.IsChecked == true ? true : false;
                if (!String.IsNullOrWhiteSpace(SeverIP.Text))
                {
                    configs[what].severIP = SeverIP.Text;
                }
                else
                {
                    noSave = true;
                }
                if (!String.IsNullOrWhiteSpace(SeverPost.Text))
                {
                    configs[what].severPost = Convert.ToInt32(SeverPost.Text);
                }
                else
                {
                    noSave = true;
                }
                if (!String.IsNullOrWhiteSpace(TeamName.Text))
                {
                    configs[what].teamName = TeamName.Text;
                }
                else
                {
                    noSave = true;
                }
                if (!String.IsNullOrWhiteSpace(Password.Text))
                {
                    configs[what].teamPassword = Password.Text;
                }
                else
                {
                    noSave = true;
                }
                if (!String.IsNullOrWhiteSpace(Name.Text))
                {
                    configs[what].Name = Name.Text;
                }
                else
                {
                    noSave = true;
                }
                configs[what].isUsed = false;
                if (!noSave)
                {
                    File.Delete("Save\\Config.ssn2n");
                    for (int i = 0; i <= configs.Count - 1; i++)
                    {
                        SaveLoader.AddSave(configs[i]);
                    }
                }
                else
                {
                    panErrorMsg.Visibility = Visibility.Visible;
                    errMode         = 0;
                    errorTitle.Text = "提醒";
                    errorSays.Text  = "请将数据填写完整。";
                }
            }
            break;
            }
        }
Esempio n. 3
0
 private void Run_Click(object sender, RoutedEventArgs e)
 {
     if (isRun)
     {
         SSUserClass.Proc.KillProc(SSUserClass.Proc.GetProc("edge"));
     }
     else if (a.IsSelected)
     {
         RunFun();
         isOpen.Text = "正在启动";
         ProgressBarHelper.SetAnimateTo(openPer, 50);
     }
     else if (b.IsSelected)
     {
         //添加
         if (configs[0].iP == "new" && !canAdd)
         {
             canAdd = true;
             panErrorMsg.Visibility = Visibility.Visible;
             errMode         = 0;
             errorTitle.Text = "提醒";
             errorSays.Text  = "点击添加将将当前配置显示区的配置添加入列表(本次点击无效)。";
             return;
         }
         bool noSave = false;
         SaveLoader.N2NConfig config = new SaveLoader.N2NConfig();
         if (!String.IsNullOrWhiteSpace(Name.Text))
         {
             for (int i = 0; i <= configs.Count - 1; i++)
             {
                 if ((configs[i].Name) == Name.Text)
                 {
                     errMode = 4;
                     panErrorMsg.Visibility = Visibility.Visible;
                     errorTitle.Text        = "提醒";
                     errorSays.Text         = "存在同名的配置将覆盖保存。";
                     return;
                 }
             }
         }
         if (!String.IsNullOrWhiteSpace(IP.Text))
         {
             config.iP = IP.Text;
         }
         else
         {
             noSave = true;
         }
         if (!String.IsNullOrWhiteSpace(IPAdd.Text))
         {
             config.iPAdditional = IPAdd.Text;
         }
         config.isDHCP = isDHCP.IsChecked == true ? true : false;
         if (!String.IsNullOrWhiteSpace(SeverIP.Text))
         {
             config.severIP = SeverIP.Text;
         }
         else
         {
             noSave = true;
         }
         if (!String.IsNullOrWhiteSpace(SeverPost.Text))
         {
             config.severPost = Convert.ToInt32(SeverPost.Text);
         }
         else
         {
             noSave = true;
         }
         if (!String.IsNullOrWhiteSpace(TeamName.Text))
         {
             config.teamName = TeamName.Text;
         }
         else
         {
             noSave = true;
         }
         if (!String.IsNullOrWhiteSpace(Password.Text))
         {
             config.teamPassword = Password.Text;
         }
         else
         {
             noSave = true;
         }
         if (!String.IsNullOrWhiteSpace(Name.Text))
         {
             config.Name = Name.Text;
         }
         else
         {
             noSave = true;
         }
         config.isUsed = false;
         config.UUID   = DateTime.Now.ToString("yyyyMMddhhmmssfff");
         if (!noSave)
         {
             SaveLoader.AddSave(config);
             configs.Add(config);
             AddList(config);
         }
         else
         {
             panErrorMsg.Visibility = Visibility.Visible;
             errMode         = 0;
             errorTitle.Text = "提醒";
             errorSays.Text  = "请将数据填写完整。";
         }
     }
 }