public SettingsWindow(string portName, bool force, USBWatcher watcher)
        {
            InitializeComponent();

            this.watcher = watcher;
            watcher.usbPlugged += FillUsbList;
            watcher.usbUnplugged += FillUsbList;

            FillUsbList();
            usbDevices.ItemsSource = UsbStrings;
            usbDevices.DisplayMemberPath = "Port";
            usbDevices.SelectedValuePath = "Port";

            for (int i = 0; i < UsbStrings.Count; i++)
            {
                if (UsbStrings[i].Port.Equals(portName))
                {
                    usbDevices.SelectedIndex = i;
                }
            }

            if (force)
            {
                btnCancel.IsEnabled = false;
                //WindowStyle = WindowStyle.None;
                if (UsbStrings.Count > 0)
                {
                    usbDevices.SelectedIndex = 0;
                }
            }
        }
Beispiel #2
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    watcher.Dispose();
                    port.Close();
                    port.Dispose();
                }

                watcher = null;
                port = null;

                disposedValue = true;
            }
        }