示例#1
0
 private void BtnSendCmd_Click(object sender, RoutedEventArgs e)
 {
     var inputWindow = new InputWindow("请输入指令", string.Empty)
     {
         AcAddItem = str =>
         {
             string file;
             string args;
             if (str.StartsWith("\""))
             {
                 file = str.Substring(0, str.IndexOf('\"', 1));
                 args = str.Substring(str.IndexOf('\"')).Trim();
             }
             else
             {
                 file = str.Substring(0, str.IndexOf(' '));
                 args = str.Substring(str.IndexOf(' ')).Trim();
             }
             var proc = new Process
             {
                 StartInfo =
                 {
                     FileName  = file,
                     Arguments = args
                 }
             };
         }
     };
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnModifyService_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new InputWindow(InputBoxContent, LbService.SelectedItem.ToString())
            {
                AcAddItem = str => LbService.Items[LbService.SelectedIndex] = str
            };

            dialog.ShowDialog();
        }
示例#3
0
        private void BtnEnterShadow_Click(object sender, RoutedEventArgs e)
        {
            var pwd         = string.Empty;
            var inputWindow = new InputWindow("请输入Shadow Defender密码", string.Empty)
            {
                AcAddItem = input => pwd = input
            };
            var flag = inputWindow.ShowDialog();

            if (flag ?? false)
            {
                Worker.RunWorkerAsync((true, pwd));
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnAddService_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new InputWindow(InputBoxContent, string.Empty)
            {
                AcAddItem = str =>
                {
                    LbService.Items.Add(str);
                    BtnModifyService.IsEnabled = true;
                    BtnDeleteService.IsEnabled = true;
                }
            };

            dialog.ShowDialog();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnAddGroup_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new InputWindow(InputBoxContent, string.Empty)
            {
                AcAddItem = str =>
                {
                    CbGroup.Items.Add(str);
                    CbEnabled.IsChecked      = true;
                    BtnModifyGroup.IsEnabled = true;
                    BtnDeleteGroup.IsEnabled = true;
                    Services.Add(new ServiceGroupModel
                    {
                        Nickname = str,
                        Enabled  = true
                    });
                    CbGroup.SelectedItem = str;
                }
            };

            dialog.ShowDialog();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnModifyGroup_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new InputWindow(InputBoxContent, CbGroup.SelectionBoxItem.ToString())
            {
                AcAddItem = str =>
                {
                    var selected = Services.First(tmp => tmp.Nickname == CbGroup.SelectedItem.ToString());
                    var services = selected.Services;
                    Services.Remove(selected);
                    CbGroup.Items.Remove(selected.Nickname);

                    Services.Add(new ServiceGroupModel
                    {
                        Nickname = str,
                        Enabled  = CbEnabled.IsChecked ?? true,
                        Services = services
                    });
                    CbGroup.Items.Add(str);
                    CbGroup.SelectedItem = str;
                }
            };

            dialog.ShowDialog();
        }