Ejemplo n.º 1
0
 public MainForm()
 {
     //
     // The InitializeComponent() call is required for Windows Forms designer support.
     //
     InitializeComponent();
     LogFileName = System.Configuration.ConfigurationManager.AppSettings["ImagesFolder"] + @"\LogFile.txt";
     myScannerControl = new ScannerControl(LogFileName);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Starts and stops the scanning
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void CbScanStopCheckedChanged(object sender, EventArgs e)
        {
            // -------------------------------------------------
            // if the button was pressed - performs scanning
            // -------------------------------------------------
            if (cbScanStop.Checked)
            {
                StartLogging();

                // disabling the configuration and enabling the status group
                // ----------------------------------------------------------
                gbExperimentStatus.Enabled = true;
                gbScanningConfiguration.Enabled = false;
                gbExperimentConfiguration.Enabled = false;
                cbScanStop.Text = "Stop";
                cbScanStop.Enabled = false;

                // Initializing the properties of scanning for each scanner
                // ---------------------------------------------------------
                AllScannersEnabled = false;
                NumberOfScanners = lbScannersList.SelectedItems.Count;
                Scanners = new ScannerControl[NumberOfScanners];
                LastScans = new Bitmap[NumberOfScanners];

                ListBox.SelectedIndexCollection SelectedInd  = lbScannersList.SelectedIndices;
                cmbActiveScanners.Items.Clear();

                for ( int i=0;i<NumberOfScanners;i++)
                {
                    Scanners[i] = new ScannerControl(LogFileName);
                    Scanners[i].SelectDevice( ScannersList[SelectedInd[i]],Convert.ToInt32(ConfigurationManager.AppSettings["ScanningDPI"]));

                    cmbActiveScanners.Items.Add(lbScannersList.SelectedItems[i]);

                }

                // taking the fisrt picture
                // -------------------------
                if (cbRecordEnvRoom.Checked)
                {
                    LogEnvRoom();
                }
                ScanNow();

                // total experiment progress bar
                progExperimentProgress.Minimum = 0;
                progExperimentProgress.Maximum = Convert.ToInt32((dtpEndDateTime.Value - DateTime.Now).Ticks/(HunderdNano2Sec));
                progExperimentProgress.Value = 0;

                // Setting the timer to the first picture
                // ---------------------------------------
                int TimeToFirstScan = Convert.ToInt32((dtpStartDateTime.Value - DateTime.Now).Ticks/HunderdNano2Sec);
                if (TimeToFirstScan < 0)
                {
                    // starting experiment immediatly
                    StartTimerTick(this, new EventArgs());
                }
                else
                {
                    // starting experiment with delay
                    StartTimer.Interval =  TimeToFirstScan*1000 ;
                    StartTimer.Start();
                    // starting progress bar
                    NextScan = dtpStartDateTime.Value;
                    progTimeToNextScan.Minimum = 0;
                    progTimeToNextScan.Maximum = TimeToFirstScan;
                    progTimeToNextScan.Value = 0;
                    lblTimeToNextScan.Text = @"Time To Next Scan: " + Seconds2hhmmssString(TimeToFirstScan);//TimeToFirstScan.ToString() + " seconds";
                }
                UpdateProgressTimer.Start();
            }
            // ---------------------------------------------
            // if the button was unpressed - stops scanning
            // ---------------------------------------------
            else
            {
                DialogResult result = MessageBox.Show( @"Are you sure you want to stop scanning?",
                                                      @"Stop Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning  );
                if ( result == DialogResult.Yes)
                {
                    StatusLabel.Text = "please wait while scanners are reconnected";
                    this.Refresh();
                    ScanningTimer.Stop();
                    StartTimer.Stop();
                    UpdateProgressTimer.Stop();
                    gbScanningConfiguration.Enabled   = true;
                    gbExperimentConfiguration.Enabled = true;
                    gbExperimentStatus.Enabled        = true;
                    EnableAllScanners();
                    string msgText = "Process was stopped by user at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm");
                    StatusLabel.Text = msgText;
                    scnMngrLog.LogInfo(msgText);
                    cbScanStop.Text = "Scan";
                    cbScanStop.Enabled = true;
                }
                else
                {
                    cbScanStop.Checked = true;
                }

            }
        }