Example #1
0
        public ConnectionTypeDialog(int[] usbdevices, String[] ports, IPAddress[] addresses, String preferred)
        {
            this.usbdevices = usbdevices;
            this.ports      = ports;
            this.addresses  = addresses;
            this.selected   = null;

            int pref = 0;

            InitializeComponent();

            headerText.Text = MainWindowVM.GetLocalization["dHeaderConnection"];
            butCancel.Text  = MainWindowVM.GetLocalization["dButCancel"];
            butRetry.Text   = MainWindowVM.GetLocalization["dButRetry"];

            foreach (int i in usbdevices)
            {
                String txt = "USB " + i;
                if (txt.Equals(preferred))
                {
                    pref = PortList.Items.Count;
                }
                PortList.Items.Add(txt);
            }
            foreach (String p in ports)
            {
                if (p.Equals(preferred))
                {
                    pref = PortList.Items.Count;
                }
                PortList.Items.Add(p);
            }
            foreach (IPAddress a in addresses)
            {
                String txt = a.ToString();
                if (txt.Equals(preferred))
                {
                    pref = PortList.Items.Count;
                }
                PortList.Items.Add(txt);
            }

            if (PortList.Items.Count > 0)
            {
                PortList.Focus();
                PortList.SelectedIndex = pref;
            }
        }
        public ConnectionTypeDialog(int[] usbdevices, String[] ports, IPAddress[] addresses, String preferred)
        {
            this.usbdevices = usbdevices;
            this.ports      = ports;
            this.addresses  = addresses;
            this.selected   = null;

            int pref = 0;

            InitializeComponent();

            foreach (int i in usbdevices)
            {
                String txt = "USB " + i;
                if (txt.Equals(preferred))
                {
                    pref = PortList.Items.Count;
                }
                PortList.Items.Add(txt);
            }
            foreach (String p in ports)
            {
                if (p.Equals(preferred))
                {
                    pref = PortList.Items.Count;
                }
                PortList.Items.Add(p);
            }
            foreach (IPAddress a in addresses)
            {
                String txt = a.ToString();
                if (txt.Equals(preferred))
                {
                    pref = PortList.Items.Count;
                }
                PortList.Items.Add(txt);
            }

            if (PortList.Items.Count > 0)
            {
                PortList.Focus();
                PortList.SelectedIndex = pref;
            }
        }