Beispiel #1
0
        private void InitUI()
        {
            string ipFromStr = null;
            string ipToStr   = null;

            Dispatcher.Invoke((Action)(() => ipFromStr = this.textBoxIPFrom.Text));
            Dispatcher.Invoke((Action)(() => ipToStr = this.textBoxIPTo.Text));

            if (!NetworkTools.IsStringIPAddress(ipFromStr))
            {
                MessageBox.Show(Wsapm.Resources.Wsapm.NetworkMachineChoiceWindow_MessageIPFromNoRealIP, Wsapm.Resources.Wsapm.General_MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (!NetworkTools.IsStringIPAddress(ipToStr))
            {
                MessageBox.Show(Wsapm.Resources.Wsapm.NetworkMachineChoiceWindow_MessageIPToNoRealIP, Wsapm.Resources.Wsapm.General_MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var ipFrom = IPAddress.Parse(ipFromStr);
            var ipTo   = IPAddress.Parse(ipToStr);

            var ipRange  = NetworkTools.GetIPAddressRange(ipFrom, ipTo);
            var machines = NetworkTools.GetNetworkMachinesInLocalNetworkFromIPAddressRange(ipRange, cancellationTokenSource.Token);

            if (machines == null || machines.Length == 0)
            {
                return;
            }

            //var machines = DecaTec.Toolkit.Tools.NetworkTools.GetComputersInLocalNetwork();
            colView = CollectionViewSource.GetDefaultView(machines);
            Dispatcher.Invoke((Action)(() => this.networkMachineDataGrid.ItemsSource = colView));
            Dispatcher.Invoke((Action)(() => this.networkMachineDataGrid.Items.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending))));
        }