Пример #1
0
 private async void DeviceList_SubItemChecking(object sender, SubItemCheckingEventArgs e)
 {
     if (!await SubItemCheckingHandler(e.CurrentValue, e.NewValue, e.Column.Index, e.RowObject))
     {
         e.Canceled = true;
         e.NewValue = e.CurrentValue;
     }
 }
Пример #2
0
        private void targetTreeView_SubItemChecking(object sender, SubItemCheckingEventArgs e)
        {
            var node = e.RowObject as MappingNode;

            //make sure the childeNodes are set on target nodes and they don't automatically get all child nodes
            if (node != null)
            {
                node.setChildNodes();
            }
        }
        private void targetTreeView_SubItemChecking(object sender, SubItemCheckingEventArgs e)
        {
            var node = e.RowObject as MappingNode;

            //make sure the childeNodes are set on target nodes as they don't automatically get all child nodes
            if (node != null && e.NewValue == CheckState.Checked)
            {
                //make sure to set showAll property to allow the GUI to expand
                node.showAll = true;
                node.setChildNodes();
                this.targetTreeView.Expand(node);
            }
        }
Пример #4
0
        private void container_SubItemChecking(object sender, SubItemCheckingEventArgs e)
        {
            CleanError();
            SelectedFlight = e.RowObject as IFlight;
            foreach (var flight in this.container.Objects)
            {
                container.UncheckSubItem(flight, selectedColumn);
            }
            e.NewValue = CheckState.Checked;

            if (OnSelectedFlight != null)
            {
                OnSelectedFlight(e.RowObject, new EventArgs());
            }
        }
Пример #5
0
 private void ListView_SubItemChecking(object sender, SubItemCheckingEventArgs e)
 {
     try
     {
         try
         {
             Dm.Instance.SaveObject(e.RowObject);
         }
         catch (JValidationException ex)
         {
             AppManager.ShowValidationErrorMessage(ex.ValidationResult);
             //todo
             //AttrHelper.SetPropertyValue(rowObject, column.AspectName, e.Value);
         }
     }
     catch (Exception ex)
     {
         Log.ShowError(ex);
     }
 }
        private void sourceTreeView_SubItemChecking(object sender, SubItemCheckingEventArgs e)
        {
            var node = e.RowObject as MappingNode;

            //make sure the childeNodes are set as they don't automatically get all child nodes
            if (node != null && e.NewValue == CheckState.Checked)
            {
                //make sure to set showAll property to allow the GUI to expand
                node.showAll = true;
                //get child nodes
                node.setChildNodes();
                //make sure we get the mappings
                node.getMyMappings();
                foreach (var subNode in node.allChildNodes)
                {
                    //and the mappings of the childNodes
                    subNode.getMyMappings();
                }
                //then expand
                this.sourceTreeView.Expand(node);
                //reload the target to make sure all target nodes for the mappings are there
                this.targetTreeView.RefreshObject(node.mappingSet.target);
            }
        }
Пример #7
0
 private void olstActivityDiary_SubItemChecking(object sender, SubItemCheckingEventArgs e)
 {
     e.NewValue = e.CurrentValue;
 }
Пример #8
0
        public async void SubItemCheckingHandler(SubItemCheckingEventArgs e)
        {
            try
            {
                //Don't allow blocking / redirection while the sniffer is active or any other operation.
                if (OperationIsInProgress)
                {
                    MetroMessageBox.Show(this, "The Speed Limiter can't be used while the sniffer is active!", "Error", MessageBoxButtons.OK,
                                         MessageBoxIcon.Error);
                    e.Canceled = true;
                    return;
                }

                //Get the device in the selected row
                fastObjectListView1.SelectObject(e.RowObject);
                Device device = e.RowObject as Device;

                if (device.IsGateway || device.IsLocalDevice)
                {
                    MetroMessageBox.Show(this, "This operation can not target the gateway or your own ip address!", "Error", MessageBoxButtons.OK,
                                         MessageBoxIcon.Error);
                    e.Canceled = true;
                    return;
                }

                if (e.NewValue == CheckState.Checked && e.Column.Index == 6 && !device.Blocked && !device.Redirected)
                {
                    //Update device state in list
                    var listDevice = Devices.FirstOrDefault(D => D.Value.MAC == device.MAC);
                    if (listDevice.Equals(default(KeyValuePair <IPAddress, Device>)))
                    {
                        throw new CustomExceptions.DeviceNotInListException("Device was not found in the list of targeted devices.");
                    }

                    listDevice.Value.Blocked = true;

                    //Update device state in UI
                    device.Blocked      = true;
                    device.DeviceStatus = "Offline";
                    fastObjectListView1.UpdateObject(device);
                    pictureBox1.Image = NetStalker.Properties.Resources.icons8_ok_red;

                    //Activate the BR if it's not already active
                    if (!Blocker_Redirector.BRMainSwitch)
                    {
                        if (Blocker_Redirector.BRTask != null && Blocker_Redirector.BRTask.Status == TaskStatus.Running)
                        {
                            Blocker_Redirector.BRTask.Wait();
                        }

                        Blocker_Redirector.BRMainSwitch = true;
                        Blocker_Redirector.BlockAndRedirect();
                    }
                }
                else if (e.NewValue == CheckState.Checked && e.Column.Index == 5 && !device.Blocked && !device.Redirected)
                {
                    //Update device state in list
                    var listDevice = Devices.FirstOrDefault(D => D.Value.MAC == device.MAC);
                    if (listDevice.Equals(default(KeyValuePair <IPAddress, Device>)))
                    {
                        throw new CustomExceptions.DeviceNotInListException("Device was not found in the list of targeted devices.");
                    }

                    listDevice.Value.Blocked    = true;
                    listDevice.Value.Redirected = true;

                    //Update device state in UI
                    device.Blocked     = true;
                    device.Redirected  = true;
                    device.DownloadCap = 0;
                    device.UploadCap   = 0;
                    fastObjectListView1.UpdateObject(device);
                    pictureBox1.Image = NetStalker.Properties.Resources.icons8_ok_red;

                    //Activate the BR if it's not already active
                    if (!Blocker_Redirector.BRMainSwitch)
                    {
                        if (Blocker_Redirector.BRTask != null && Blocker_Redirector.BRTask.Status == TaskStatus.Running)
                        {
                            Blocker_Redirector.BRTask.Wait();
                        }

                        Blocker_Redirector.BRMainSwitch = true;
                        Blocker_Redirector.BlockAndRedirect();
                    }

                    //Start value counter if it's not already started
                    if (!ValuesTimer.Enabled)
                    {
                        ValuesTimer.Enabled = true;
                    }
                }
                else if (e.NewValue == CheckState.Unchecked && e.Column.Index == 6 && device.Blocked && !device.Redirected)
                {
                    //Update device state in list
                    var listDevice = Devices.FirstOrDefault(D => D.Value.MAC == device.MAC);
                    if (listDevice.Equals(default(KeyValuePair <IPAddress, Device>)))
                    {
                        throw new CustomExceptions.DeviceNotInListException("Device was not found in the list of targeted devices.");
                    }

                    listDevice.Value.Blocked = false;

                    //Update device state in UI
                    device.Blocked      = false;
                    device.DeviceStatus = "Online";
                    fastObjectListView1.UpdateObject(device);

                    await Scanner.RestoreDevice(device);

                    //Checks if there are any devices left with active targeting
                    if (!Devices.Any(D => D.Value.Blocked == true))
                    {
                        pictureBox1.Image = NetStalker.Properties.Resources.color_ok;
                        Blocker_Redirector.BRMainSwitch = false;
                    }
                }
                else if (e.NewValue == CheckState.Unchecked && e.Column.Index == 5 && device.Redirected)
                {
                    //Update device state in list
                    var listDevice = Devices.FirstOrDefault(D => D.Value.MAC == device.MAC);
                    if (listDevice.Equals(default(KeyValuePair <IPAddress, Device>)))
                    {
                        throw new CustomExceptions.DeviceNotInListException("Device was not found in the list of targeted devices.");
                    }

                    listDevice.Value.Blocked     = false;
                    listDevice.Value.Redirected  = false;
                    listDevice.Value.Limited     = false;
                    listDevice.Value.DownloadCap = 0;
                    listDevice.Value.UploadCap   = 0;

                    device.Blocked       = false;
                    device.Redirected    = false;
                    device.Limited       = false;
                    device.DownloadCap   = 0;
                    device.UploadCap     = 0;
                    device.DownloadSpeed = "";
                    device.UploadSpeed   = "";
                    fastObjectListView1.UpdateObject(device);

                    await Scanner.RestoreDevice(device);

                    //Checks if there are any devices left with the Redirected switch
                    if (!Devices.Any(D => D.Value.Redirected == true))
                    {
                        pictureBox1.Image = NetStalker.Properties.Resources.color_ok;
                        Blocker_Redirector.BRMainSwitch = false;
                        ValuesTimer.Enabled             = false;
                        ValuesTimer.Stop();
                    }
                }
                else
                {
                    //The user action didn't hit any of our conditions so we cancel it and reset the value
                    e.Canceled = true;
                    e.NewValue = e.CurrentValue;
                }
            }
            catch (CustomExceptions.DeviceNotInListException)
            {
                MetroMessageBox.Show(this, "The selected device was not found in the list or targets", "Error", MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
                e.Canceled = true;
            }
        }
Пример #9
0
 private void FastObjectListView1_SubItemChecking(object sender, SubItemCheckingEventArgs e)
 {
     SubItemCheckingHandler(e);
 }
Пример #10
0
        private void FastObjectListView1_SubItemChecking(object sender, SubItemCheckingEventArgs e)
        {
            try
            {
                if (SnifferStarted)//deal with the small hang on activation
                {
                    throw new OperationInProgressException();
                }

                if (!checkboxcanbeclicked)
                {
                    e.Canceled = true;
                    return;
                }

                fastObjectListView1.SelectObject(e.RowObject);
                Device device = e.RowObject as Device;
                if (device.IsGateway || device.IsLocalDevice)
                {
                    throw new Controller.GatewayTargeted();
                }
                device.GatewayMAC = GetGatewayMAC();
                device.GatewayIP  = GetGatewayIP();
                device.LocalIP    = GetLocalIP();

                if (e.NewValue == CheckState.Checked && e.Column.Index == 6 && !device.BlockerActive && !device.RedirectorActive)
                {
                    try
                    {
                        device.Blocked       = true;
                        device.BlockerActive = true;
                        device.DeviceStatus  = "Offline";
                        device.BlockOrRedirect();
                        fastObjectListView1.UpdateObject(device);
                        pictureBox1.Image = NetStalker.Properties.Resources.icons8_ok_96;
                    }
                    catch (Exception)
                    {
                    }
                }
                else if (e.NewValue == CheckState.Checked && e.Column.Index == 5 && !device.RedirectorActive && !device.BlockerActive)
                {
                    try
                    {
                        new Thread(() =>
                        {
                            loading = new Loading();
                            loading.ShowDialog();
                        }).Start();

                        device.Blocked          = true;
                        device.Redirected       = true;
                        device.RedirectorActive = true;
                        device.BlockOrRedirect();
                        GetReady();
                        device.LimiterStarted = true;
                        device.DownloadCap    = 0;
                        device.UploadCap      = 0;
                        if (!ValuesTimer.Enabled)
                        {
                            //PopulateDeviceList();
                            //PopulateCalled = true;
                            ValuesTimer.Start();
                        }
                        LoDevices = fastObjectListView1.Objects.Cast <Device>().ToList();
                        new Thread(() =>
                        {
                            LimiterClass LimitDevice = new LimiterClass(device);
                            LimitDevice.StartLimiter();
                        }).Start();
                        loading.BeginInvoke(new Action(() => { loading.Close(); }));
                        pictureBox1.Image = NetStalker.Properties.Resources.icons8_ok_96;
                    }
                    catch (Exception)
                    {
                    }
                }
                else if (e.NewValue == CheckState.Unchecked && e.Column.Index == 6 && device.BlockerActive)
                {
                    try
                    {
                        device.Blocked       = false;
                        device.BlockerActive = false;
                        device.DeviceStatus  = "Online";
                        fastObjectListView1.UpdateObject(device);
                        PopulateForBlocker();
                        foreach (var Dev in LODFB)
                        {
                            if (Dev.Blocked)
                            {
                                return;
                            }
                        }
                        pictureBox1.Image = NetStalker.Properties.Resources.icons8_ok_96px;
                    }
                    catch (Exception)
                    {
                    }
                }
                else if (e.NewValue == CheckState.Unchecked && e.Column.Index == 5 && device.RedirectorActive)
                {
                    try
                    {
                        device.Blocked          = false;
                        device.Redirected       = false;
                        device.RedirectorActive = false;
                        device.LimiterStarted   = false;
                        device.DownloadCap      = 0;
                        device.UploadCap        = 0;
                        device.DownloadSpeed    = "";
                        device.UploadSpeed      = "";
                        fastObjectListView1.UpdateObject(device);
                        foreach (Device Device in LoDevices)
                        {
                            if (Device.LimiterStarted)
                            {
                                return;
                            }
                        }
                        ValuesTimer.Stop();
                        PopulateCalled = false;
                        fastObjectListView1.UpdateObject(device);
                        pictureBox1.Image = NetStalker.Properties.Resources.icons8_ok_96px;
                    }
                    catch (Exception)
                    {
                    }
                }
                else
                {
                    e.Canceled = true;
                    e.NewValue = e.CurrentValue;
                }
            }
            catch (Controller.GatewayTargeted)
            {
                MetroMessageBox.Show(this, "This operation can not target the gateway or your own ip address!", "Error", MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
                e.Canceled = true;
            }
            catch (OperationInProgressException)
            {
                MetroMessageBox.Show(this, "The Speed Limiter can't be used while the sniffer is active!", "Error", MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
            }
        }