Esempio n. 1
0
        private void AddList(SaveLoader.N2NConfig config)
        {
            SolidColorBrush Brush = new SolidColorBrush();

            Brush.Color = Color.FromArgb(189, 230, 251, 255);


            ListViewItem item  = new ListViewItem();
            WrapPanel    wrap  = new WrapPanel();
            RadioButton  check = new RadioButton();
            TextBlock    text  = new TextBlock();

            item.Height = 25;
            item.Name   = "UUID" + config.UUID;
            RegisterName("UUID" + config.UUID, item);
            wrap.Margin            = new Thickness(10, 0, 10, 0);
            wrap.VerticalAlignment = VerticalAlignment.Center;
            check.Name             = "CHECK" + config.UUID;
            RegisterName("CHECK" + config.UUID, check);
            check.Background        = Brushes.Transparent;
            check.GroupName         = "Used";
            check.Checked          += ChangeUsed;
            check.VerticalAlignment = VerticalAlignment.Center;
            RadioButtonHelper.SetCheckedBackground(check, Brushes.Transparent);
            RadioButtonHelper.SetGlyphBrush(check, Brushes.Transparent);
            RadioButtonHelper.SetCheckedGlyphBrush(check, Brush);
            text.Text              = "| " + config.Name;
            text.Foreground        = Brush;
            text.VerticalAlignment = VerticalAlignment.Center;

            //托盘菜单项
            MenuItem menu = new MenuItem();

            menu.Header   = config.Name;
            menu.Height   = 25;
            menu.MinWidth = 150;
            menu.Name     = "MENU" + config.UUID;
            RegisterName("MENU" + config.UUID, menu);
            menu.Click += TaskBarChangeList;

            if (config.isUsed)
            {
                item.IsSelected       = true;
                menu.IsChecked        = true;
                check.IsChecked       = true;
                nowUsed               = config;
                nName.Text            = config.Name;
                nIP.Text              = config.iP;
                nAdd.Text             = config.iPAdditional;
                nSever.Text           = config.severIP + ":" + config.severPost;
                nTeamName.Text        = config.teamName;
                nPassword.Text        = config.teamPassword;
                nowConfigs.Visibility = Visibility.Visible;
            }

            wrap.Children.Add(check);
            wrap.Children.Add(text);
            item.Content = wrap;
            ConfigList.Items.Add(item);
            TaskBarConfigList.Items.Add(menu);
        }
Esempio n. 2
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. 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  = "请将数据填写完整。";
         }
     }
 }