Ejemplo n.º 1
0
        private void btnSetOption_Click(object sender, EventArgs e)
        {
            AuxiliarForm auxForm = new AuxiliarForm(AuxFormType.SetOption);

            auxForm.Text = "Set Option";

            auxForm.ShowDialog();
            if (auxForm.Result != AuxFormResult.Completed)
            {
                return;
            }

            string[] values = auxForm.Values;

            try
            {
                int    option = int.Parse(values[0]);
                int    value  = int.Parse(values[1]);
                Client client = clients[listClients.SelectedIndices[0]];

                BackgroundWorker bw = new BackgroundWorker();

                bw.DoWork += new DoWorkEventHandler((object sender2, DoWorkEventArgs e2) =>
                {
                    e2.Result = ctrl.SendSetOption(client, option, value);
                });

                bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler((object sender2, RunWorkerCompletedEventArgs e2) =>
                {
                    if (e2.Error != null)
                    {
                        MessageBox.Show(e2.Error.Message, "Error");
                        return;
                    }

                    int result      = (int)e2.Result;
                    bool hadSuccess = result == 1;
                    MessageBox.Show(
                        string.Format("Set Option {0} {1} {2}", option, value, (hadSuccess ? "had success" : "failed")),
                        hadSuccess ? "Success" : "Error"
                        );
                });

                bw.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }
Ejemplo n.º 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ListView     lv            = tabControl.SelectedIndex == 0 ? listAppRules : listFSRules;
            int          selectedIndex = tabControl.SelectedIndex;
            AuxiliarForm auxForm       = new AuxiliarForm(selectedIndex == 0 ? AuxFormType.AddAppCtrl : AuxFormType.AddFSScan);

            if (selectedIndex == 0)
            {
                auxForm.ValidateFunction = (string[] results) =>
                {
                    ;
                };
            }
            else
            {
                auxForm.ValidateFunction = (string[] results) =>
                {
                };
            }

            auxForm.Text = selectedIndex == 0 ? "Add Application Control Rule" : "Add File System Scan Rule";
            auxForm.ShowDialog();

            if (auxForm.Result != AuxFormResult.Completed)
            {
                return;
            }

            string[] values = auxForm.Values;
            if (selectedIndex == 0)
            {
                AddAppCtrlRule(values);
            }
            else
            {
                AddFSScanRule(values);
            }
        }