Example #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");
            }
        }
Example #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            ListView     lv            = tabControl.SelectedIndex == 0 ? listAppRules : listFSRules;
            int          selectedIndex = tabControl.SelectedIndex;
            Client       client        = clients[listClients.SelectedIndices[0]];
            AuxiliarForm auxForm;
            AppCtrlRule  appRule = new AppCtrlRule();
            FSRule       fsRule  = new FSRule();

            if (selectedIndex == 0)
            {
                appRule = client.AppCtrlRules[listAppRules.SelectedIndices[0]];
                auxForm = new AuxiliarForm(selectedIndex == 0 ? AuxFormType.UpdateAppCtrl : AuxFormType.UpdateFSScan, appRule);
            }
            else
            {
                fsRule  = client.FSRules[listFSRules.SelectedIndices[0]];
                auxForm = new AuxiliarForm(selectedIndex == 0 ? AuxFormType.UpdateAppCtrl : AuxFormType.UpdateFSScan, fsRule);
            }

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

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

            string[] values = auxForm.Values;
            if (selectedIndex == 0)
            {
                UpdateAppCtrlRule(values, appRule.RuleID);
            }
            else
            {
                UpdateFSScanRule(values, fsRule.RuleID);
            }
        }
Example #3
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);
            }
        }