Exemplo n.º 1
0
        private void StartForceAutoIP(object data)
        {
            lock (this)
            {
                List <CameraInfo> infos      = (List <CameraInfo>)data;
                LoadingWindow     loadingWnd = new LoadingWindow();
                using (loadingWnd)
                {
                    loadingWnd.Show();
                    loadingWnd.SetProgressBar(0, "Start auto forcing IP...");
                    foreach (CameraInfo info in infos)
                    {
                        try
                        {
                            ManagedBusManager.ForceAllIPAddressesAutomatically(info.serialNumber);
                        }
                        catch (FC2Exception ex)
                        {
                            loadingWnd.SetProgressBar(10, "Error auto forcing IP...");
                            MessageBox.Show(
                                ex.Message,
                                "Error auto forcing IP",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                            Enabled = true;
                            ex.Dispose();
                            return;
                        }
                    }

                    loadingWnd.SetProgressBar(30, "Configuration completed... Please wait for 5 second...");

                    // Sleep for 5s before refreshing
                    for (int i = 0; i < 50; i++)
                    {
                        Thread.Sleep(100);
                        loadingWnd.SetProgressBar(30 + i);
                    }

                    loadingWnd.SetProgressBar(90, "Auto forcing IP completed... Refreshing camera list...");
                    loadingWnd.Hide();
                    loadingWnd.Close();

                    // bring to front
                    //this.Activate();

                    if (InvokeRequired == true)
                    {
                        Invoke(new RefreshCameraListCallback(RefreshCameraList));
                    }
                    else
                    {
                        RefreshCameraList();
                    }
                }
            }
        }