예제 #1
0
        public bool Initialize()
        {
            IDeviceList list = new DeviceList();
              list.Scan();
              this.logger.Debug("Found {0} devices", list.Count());

              this.device = list.FirstOrDefault();
              this.logger.Debug("Selected device: {0}", (this.device as Device)?.DevicePath ?? "None");

              return this.device != null;
        }
예제 #2
0
파일: Program.cs 프로젝트: Djuuu/LuxaforCli
        public static IDevice GetDevice()
        {
            IDeviceList list = new DeviceList();
            list.Scan();

            if (list.Count() == 0)
            {
                throw new Exception("No Luxafor device found");
            }

            return list.First();
        }
예제 #3
0
        public bool Initialize()
        {
            IDeviceList list = new DeviceList();

            list.Scan();
            this.logger.Debug("Found {0} devices", list.Count());

            this.device = list.FirstOrDefault();
            this.logger.Debug("Selected device: {0}", (this.device as Device)?.DevicePath ?? "None");

            return(this.device != null);
        }
예제 #4
0
        private void OKExecute(Window win)
        {
            if (win != null)
            {
                win.DialogResult = true;
                var selNode = DeviceList.FirstOrDefault(a => a.IsChecked);
                if (selNode != null)
                {
                    if (selNode.ViewType == Module.ViewType.Portait)
                    {
                        if (selNode.Type == DeviceType.PCWeb || selNode.Type == DeviceType.Tablet)
                        {
                            Swap(selNode);
                        }
                    }
                    else
                    {
                        if (selNode.Type == DeviceType.Mobile || selNode.Type == DeviceType.Watch)
                        {
                            Swap(selNode);
                        }
                    }
                }

                //UserSetting is checked
                //if user input a name, add it as a new device, else as usersetting
                //Current UserSetting will be added as another device, and add default userSetting again.
                if (UserSetting.IsChecked)
                {
                    if (!string.IsNullOrEmpty(_name))
                    {
                        var device = _document.DeviceSet.CreateDevice(_name);
                        device.IsChecked = true;
                        device.Width     = _width;
                        device.Height    = _height;
                        DeviceList.Insert(DeviceList.Count() - 2, new DeviceNode(device));
                        UserSetting.IsChecked = false;
                    }
                    else
                    {
                        UserSetting.Width  = _width;
                        UserSetting.Height = _height;
                    }
                }
                win.Close();
            }
        }
예제 #5
0
        private void OnStartCapture()
        {
            try
            {
                for (int i = 0; i < DeviceList.Count(); i++)
                {
                    if (CurrentDevice == DeviceList[i].Interface.FriendlyName)
                    {
                        captureDevice = DeviceList[i];
                        if (DeviceList[i] is AirPcapDevice)
                        {
                            _MainCodeBehind.ShowMessage("Wi-Fi");
                        }
                    }
                }

                int readTimeoutMilliseconds = 500;
                // открываем в режиме promiscuous, поддерживается также нормальный режим
                captureDevice.Open(DeviceMode.Promiscuous, readTimeoutMilliseconds);
                // регистрируем событие, которое срабатывает, когда пришел новый пакет
                captureDevice.OnPacketArrival += new PacketArrivalEventHandler(Program_OnPacketArrivalAsync);
                if (Col.Count == 0)
                {
                    num = 1;
                }
                // начинаем захват пакетов
                captureDevice.StartCapture();

                captureFileWriter = new CaptureFileWriterDevice(Path.GetTempPath() + "SnifferLogs.pcapng");

                ReadFile();
            }
            catch
            {
                _MainCodeBehind.ShowMessage("Интерфейс не выбран");
            }
        }