Esempio n. 1
0
        public DeviceChangeArgs(DeviceChange changeType, string devicePath)
        {
            Contract.Requires<ArgumentException>(!string.IsNullOrWhiteSpace(devicePath));

            ChangeType = changeType;
            DevicePath = devicePath.ToLowerInvariant();
        }
        public void InputMain(Mainwindow mainwindow)
        {
            var bootwindow = mainwindow.bootwindow;

            bootwindow.ToRightButton.Visibility = Visibility.Hidden;
            bootwindow.ToLeftButton.Visibility  = Visibility.Hidden;

            var listdv = mainwindow.TADB.GetDevices();

            if (listdv.Count() >= 1)
            {
                //select the working  device
                mainwindow.TADB.SetDevice(listdv[0]);

                bootwindow.NaviSetion2();
            }
            else
            {
                DeviceChange deviceChange = null;
                deviceChange = (e, s) =>
                {
                    mainwindow.TADB.SetDevice(s);
                    bootwindow.NaviSetion2();
                    mainwindow.TADB.OndeivceConnect -= deviceChange;
                };
                mainwindow.TADB.OndeivceConnect += deviceChange;
            }
        }
Esempio n. 3
0
        public DeviceChangeArgs(DeviceChange changeType, string devicePath)
        {
            Contract.Requires <ArgumentException>(!string.IsNullOrWhiteSpace(devicePath));

            ChangeType = changeType;
            DevicePath = devicePath.ToLowerInvariant();
        }
 private void DeviceRemoved(object sender, INTV.Shared.Interop.DeviceManagement.DeviceChangeEventArgs e)
 {
     if (e.Type == INTV.Core.Model.Device.ConnectionType.Serial)
     {
         var removedDevice = AvailableSerialPorts.FirstOrDefault(p => p.PortName == e.Name);
         if (DeviceChange.IsDeviceChangeFromSystem(e.State))
         {
             if ((removedDevice != null) && AvailableSerialPorts.Remove(removedDevice))
             {
                 INTV.Shared.ComponentModel.CommandManager.InvalidateRequerySuggested();
             }
         }
         else
         {
             // Removal may also indicate that the device is not valid for use by the party responsible for showing the dialog.
             // In such a case, disable the item.
             if ((removedDevice != null) && !DisabledSerialPorts.Contains(e.Name))
             {
                 removedDevice.IsSelectable = false;
                 DisabledSerialPorts.Add(e.Name);
                 INTV.Shared.ComponentModel.CommandManager.InvalidateRequerySuggested();
             }
         }
     }
 }
Esempio n. 5
0
 private void DevTtyDeleted(object sender, System.IO.FileSystemEventArgs e)
 {
     if (e.ChangeType.HasFlag(System.IO.WatcherChangeTypes.Deleted))
     {
         DebugOutput("DeviceMonitor.FileSystemNotifcationPort: DevTtyDeleted: " + e.FullPath);
         DeviceChange.SystemReportsDeviceRemoved(this, e.FullPath, INTV.Core.Model.Device.ConnectionType.Serial);
     }
 }
Esempio n. 6
0
 private static void HandleSystemDidWake(object sender, EventArgs e)
 {
     DebugOutput("DeviceMonitor.HandleSystemDidWake");
     foreach (var port in INTV.Shared.Model.Device.SerialPortConnection.AvailablePorts)
     {
         DeviceChange.SystemReportsDeviceAdded(null, port, INTV.Core.Model.Device.ConnectionType.Serial);
     }
 }
Esempio n. 7
0
 private void LoadDeviceSetting(object sender, MouseButtonEventArgs e)
 {
     if (sender is TreeViewItem treeViewItem)
     {
         selectdevice = (MonchaDevice)treeViewItem.DataContext;
         DeviceChange?.Invoke(this, (MonchaDevice)treeViewItem.DataContext);
     }
 }
 private void DeviceAdded(object sender, INTV.Shared.Interop.DeviceManagement.DeviceChangeEventArgs e)
 {
     if ((e.Type == INTV.Core.Model.Device.ConnectionType.Serial) && DeviceChange.IsDeviceChangeFromSystem(e.State))
     {
         if (!AvailableSerialPorts.Any(p => p.PortName == e.Name) && ((InclusionFilter == null) || InclusionFilter(Connection.CreatePseudoConnection(e.Name, e.Type))))
         {
             AvailableSerialPorts.Add(new SerialPortViewModel(e.Name));
         }
         INTV.Shared.ComponentModel.CommandManager.InvalidateRequerySuggested();
     }
 }
Esempio n. 9
0
        private void AddDeviceToList(string DeviceNameString)
        {
            devices.Add(DeviceNameString.ToLowerInvariant(), new HidDevice(this, DeviceNameString));

            EmitLogMessage(HidLogMessageType.Info, "Device Attach: " + DeviceNameString);

            if (DeviceChange != null)
            {
                DeviceChange.Invoke(this, null);
            }
        }
Esempio n. 10
0
 private void DeviceRemoved(object sender, DeviceChangeEventArgs e)
 {
     if ((e.Type == INTV.Core.Model.Device.ConnectionType.Serial) && DeviceChange.IsDeviceChangeFromSystem(e.State))
     {
         var removedDevice = SerialPorts.FirstOrDefault(p => p.PortName == e.Name);
         if ((removedDevice != null) && SerialPorts.Remove(removedDevice))
         {
             INTV.Shared.ComponentModel.CommandManager.InvalidateRequerySuggested();
         }
     }
     RaisePropertyChanged("IsPortValid");
 }
Esempio n. 11
0
        private void RemoveDeviceFromList(string DeviceNameString)
        {
            devices[DeviceNameString].Dispose();
            devices[DeviceNameString] = null;
            devices.Remove(DeviceNameString);

            EmitLogMessage(HidLogMessageType.Info, "Device Removal: " + DeviceNameString);

            if (DeviceChange != null)
            {
                DeviceChange.Invoke(this, null);
            }
        }
Esempio n. 12
0
 private void DeviceAdded(object sender, DeviceChangeEventArgs e)
 {
     if ((e.Type == INTV.Core.Model.Device.ConnectionType.Serial) && DeviceChange.IsDeviceChangeFromSystem(e.State))
     {
         var acceptPort = IsNotExclusivePort(Connection.CreatePseudoConnection(e.Name, ConnectionType.Serial));
         if (acceptPort && !SerialPorts.Any(p => p.PortName == e.Name))
         {
             SerialPorts.Add(new SerialPortViewModel(e.Name));
         }
         INTV.Shared.ComponentModel.CommandManager.InvalidateRequerySuggested();
     }
     RaisePropertyChanged("IsPortValid");
 }
        private void PlayerChangeOutput()
        {
            var selector = new DeviceChange();

            string[] devices = Player.Instance.GetDevices();
            selector.DataContext = devices;
            selector.OkClicked   = new Action(() =>
            {
                var name = devices[selector.DeviceIndex];
                Properties.Settings.Default.SampleRate = selector.SampleRate;
                Player.Instance.ChangeDevice(name);
            });
            View.ShowDialog(selector);
        }
Esempio n. 14
0
    private void Awake()
    {
        if (_instance == null)
        {
            _instance = this;
            return;
        }

        if (_instance != this)
        {
            Debug.LogWarning("A DeviceChange object has been created twice or more. This instance will be destroyed.");
            Destroy(this);
        }
    }
Esempio n. 15
0
        private void BtnChangeDev_Click(object sender, RoutedEventArgs e)
        {
            if (!_loaded)
            {
                return;
            }
            var selector = new DeviceChange();

            string[] devices = _player.GetDevices();
            selector.DataContext = devices;
            selector.OkClicked   = new Action(() =>
            {
                var name = devices[selector.DeviceIndex];
                Properties.Settings.Default.SampleRate = selector.SampleRate;
                _player.ChangeDevice(name);
            });
            MainWindow.ShowDialog(selector);
        }
Esempio n. 16
0
        private static void HandleSystemWillSleep(object sender, SystemWillSleepEventArgs e)
        {
            DebugOutput("DeviceMonitor.HandleSystemWillSleep CanCancel: " + e.CanCancel + " PreventSystemSleepDuringDeviceCommands: " + Properties.Settings.Default.PreventSystemSleepDuringDeviceCommands);
            var cancelSleep = false;

            if (e.CanCancel && Properties.Settings.Default.PreventSystemSleepDuringDeviceCommands)
            {
                var portBeingUsed = GetDevices().FirstOrDefault(d => d.IsValid && (d.Port != null) && d.Port.IsOpen && d.Port.IsInUse);
                cancelSleep = portBeingUsed != null;
                e.Cancel    = cancelSleep;
                DebugOutput("DeviceMonitor.HandleSystemWillSleep will cancel: " + cancelSleep + " port being used: " + (cancelSleep ? portBeingUsed.Name : "<null>"));
            }
            if (!cancelSleep)
            {
                foreach (var port in INTV.Shared.Model.Device.SerialPortConnection.AvailablePorts)
                {
                    DeviceChange.SystemReportsDeviceRemoved(null, port, INTV.Core.Model.Device.ConnectionType.Serial);
                }
            }
        }
Esempio n. 17
0
        private static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == WM_DEVICECHANGE) //WM_DEVICECHANGE
            {
                DeviceChange?.Invoke();
                var ports    = SerialPort.GetPortNames();
                var oldPorts = ComPorts.Except(ports).ToArray();
                var newPorts = ports.Except(ComPorts).ToArray();

                foreach (var newPort in newPorts)
                {
                    comPorts.Add(newPort);
                }
                foreach (var oldPort in oldPorts)
                {
                    comPorts.Remove(oldPort);
                }
            }
            //  do stuff
            return(IntPtr.Zero);
        }
Esempio n. 18
0
 private void OnCDChange(DeviceChangeEventArgs ea)
 {
     DeviceChange?.Invoke(this, ea);
 }
Esempio n. 19
0
 private void DeviceChangeBehavior_DeviceChanged(object sender, DeviceChange e)
 {
     ExecuteCommand(new DeviceChangeEventArgs {
         DeviceChange = e
     });
 }
Esempio n. 20
0
 void SignalDeviceChange(DeviceChange state, DeviceBroadcastInterface volume)
 {
     _manager.EnqueueEvent(_manager.DeviceChanged, new DeviceChangeArgs(state, volume.Name));
 }
Esempio n. 21
0
 public void OnDeviceChange()
 {
     DeviceChange?.Invoke(this, EventArgs.Empty);
 }
Esempio n. 22
0
 private void HandleSystemDidPowerOn(object sender, EventArgs args)
 {
     DeviceChange.RaiseSystemDidPowerOnEvent(sender, args);
 }
Esempio n. 23
0
 private void HandleSystemWillPowerOff(object sender, EventArgs args)
 {
     DeviceChange.RaiseSystemWillPowerOffEvent(sender, args);
 }
Esempio n. 24
0
 private void HandleSystemWillSleep(object sender, SystemWillSleepEventArgs args)
 {
     DeviceChange.RaiseSystemWillSleepEvent(sender, args);
 }
Esempio n. 25
0
 private static void ReportPortDeparture(string portName)
 {
     DebugOutput("IOService: Departure: port: " + portName);
     DeviceChange.SystemReportsDeviceRemoved(null, portName, INTV.Core.Model.Device.ConnectionType.Serial);
 }
Esempio n. 26
0
 private static void ReportPortArrival(string portName)
 {
     DebugOutput("IOService: Arrival: port: " + portName);
     DeviceChange.SystemReportsDeviceAdded(null, portName, INTV.Core.Model.Device.ConnectionType.Serial);
 }