Exemplo n.º 1
0
        /// <summary>
        /// Constructor of the class
        /// </summary>
        public Form1()
        {
            // Start timer to enable form after loading controls
            System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
            timer.Interval = 3000;
            timer.Start();
            timer.Tick += delegate { Opacity = 100; };

            // Make logfile folder to myDocuments
            string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            path = Path.Combine(path, "\\Ruhtinas Software\\PLDControl\\Data\\");

            // Check if folder exists, if not make the folder
            DirectoryInfo di = new DirectoryInfo(path);

            if (!di.Exists)
            {
                di.Create();
            }
            // Create path to logfile
            filename = Path.Combine(path, LOGFILE_NAME);

            InitializeComponent();
            ClearLogFile(); // Clears previous logfile
            InitializeForm();

            // Create fillock object to pass filename and file lock status to ConsoleWindow
            fileLock          = new dataTransfer();
            fileLock.locking  = false;
            fileLock.filepath = path;

            pictureBox2.SizeMode = PictureBoxSizeMode.Zoom;

            // Create timer to update stopwatch label
            System.Windows.Forms.Timer updateTimer = new System.Windows.Forms.Timer();
            updateTimer.Interval = 10; // update time every 10 milliseconds
            updateTimer.Start();
            updateTimer.Tick += delegate {
                TimeSpan ts          = stopwatch.Elapsed; // Bind label text to stopwatch value
                string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
                SetTimeText(elapsedTime);
            };

            // Starting camera capture
            webcam();

            // Setting up serial communications
            DefineSerial();
            DefineLaserSerial();

            // Initialization of laser serial messaging buffer
            buffer = "";

            // uncheck offradiobutton
            offradioButton.Checked = true;

            // Startup finished
            startup = false;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor for console window class
 /// </summary>
 /// <param name="mainlock">object to pass boolean value for file locking</param>
 public ConsoleWindow(dataTransfer mainlock)
 {
     fileLock = mainlock; // locking object for logfile
     path     = fileLock.filepath;
     InitializeComponent();
     InitializeLogging();
     // Closing created filesystem watcher when form closes. Not necessary but to be sure
     this.FormClosed += delegate { watcher.EnableRaisingEvents = false; watcher.Dispose(); };
 }