Ejemplo n.º 1
0
        public TakePhoto(ImageCollection image, NikonDevice device)
        {
            InitializeComponent();
            Cursor.Hide();
            this.DoubleBuffered = true;

            CenterComponents();
            // Hook up device capture events
            this.device             = device;
            device.ImageReady      += new ImageReadyDelegate(device_ImageReady);
            device.CaptureComplete += new CaptureCompleteDelegate(device_CaptureComplete);

            counter = new Counter();
            Image   = image;
            this.BackgroundImage = new Bitmap(Image.BackgroundImage);
            printImage           = new Bitmap(Image.BackgroundImage);
            timer          = new System.Timers.Timer(1000);
            timer.Elapsed += new ElapsedEventHandler(CountDown);

            closingTimer = new System.Timers.Timer(6000);

            CounterItem cItem = counter.CountDown();

            pictureBox1.Image = cItem.Number;
            pictureBox2.Image = cItem.Smile;
            timer.Start();
        }
Ejemplo n.º 2
0
        void CountDown(object o, ElapsedEventArgs a)
        {
            CounterItem cItem = counter.CountDown();

            if (cItem.Count == 0)
            {
                timer.Stop();

                if (device == null)
                {
                    return;
                }

                try
                {
                    pictureBox1.Image = ImageProcessing.Properties.Resources.smile;
                    pictureBox2.Image = null;
                    if (ClosingTimerStarted)
                    {
                        closingTimer.Elapsed -= new ElapsedEventHandler(CloseForm);
                        closingTimer.Stop();
                        ClosingTimerStarted = false;
                    }
                    closingTimer.Elapsed += new ElapsedEventHandler(CloseForm);
                    closingTimer.Start();
                    ClosingTimerStarted = true;
                    device.Capture();
                }
                catch (NikonException ex)
                {
                    if (ex.ErrorCode == eNkMAIDResult.kNkMAIDResult_OutOfFocus)
                    {
                        pictureBox3.Image = null;
                        pictureBox1.Image = ImageProcessing.Properties.Resources.focuserror;
                        pictureBox2.Image = null;
                    }
                    else if (ex.ErrorCode == eNkMAIDResult.kNkMAIDResult_BatteryDontWork)
                    {
                        pictureBox3.Image = null;
                        pictureBox1.Image = ImageProcessing.Properties.Resources.lowbattery;
                        pictureBox2.Image = null;
                    }
                    else if (ex.ErrorCode == eNkMAIDResult.kNkMAIDResult_UnexpectedError)
                    {
                        pictureBox3.Image = null;
                        pictureBox1.Image = ImageProcessing.Properties.Resources.unknownerror;
                        pictureBox2.Image = null;
                    }
                    counter       = new Counter();
                    timer.Enabled = true;
                    timer.Start();
                }
                return;
            }
            pictureBox1.Image = cItem.Number;
            pictureBox2.Image = cItem.Smile;
        }
Ejemplo n.º 3
0
        public TakePhoto(ImageCollection image, NikonDevice device, CoinSelector selector)
        {
            InitializeComponent();
            this.DoubleBuffered = true;
            this.Cursor         = new Cursor(GetType(), "hand128.cur");
            Cursor.Hide();
            CenterComponents();

            coinSelector = selector;
            coinSelector.OnCoinDetected += coinSelector_OnCoinDetected;
            coinSelector.PollingEnabled  = false;
            CoinData coinData = LogManager.GetLastCoinData();

            coinSelector.TotalCoin = coinData.TotalValue;
            coinSelector.UsedCoin  = coinData.UsedValue;
            // Hook up device capture events
            this.device             = device;
            device.ImageReady      += new ImageReadyDelegate(device_ImageReady);
            device.CaptureComplete += new CaptureCompleteDelegate(device_CaptureComplete);

            counter = new Counter();
            Image   = image;
            this.BackgroundImage = new Bitmap(Image.BackgroundImage);
            printImage           = new Bitmap(Image.BackgroundImage);
            timer          = new System.Timers.Timer(1000);
            timer.Elapsed += new ElapsedEventHandler(CountDown);
            timer.Enabled  = false;

            copyCount = new CopyCount(Settings.Instance.CopyCount);

            coinWaitTimer           = new System.Timers.Timer();
            coinWaitTimer.Interval  = 60000;
            coinWaitTimer.Enabled   = false;
            coinWaitTimer.AutoReset = false;
            coinWaitTimer.Elapsed  += coinWaitTimer_Elapsed;

            closingTimer = new System.Timers.Timer(6000);

            CounterItem cItem = counter.CountDown();

            pictureBox1.Image = cItem.Number;
            pictureBox2.Image = cItem.Smile;
            timer.Start();

            pictureBox5.Image = generateADImage(copyCount.Count);
            pictureBox8.Image = generateTotalCoinImage(copyCount.Count * Settings.Instance.COST);
            pictureBox9.Image = generateCoinImage(coinSelector.RemainedCoin);
        }
Ejemplo n.º 4
0
 public Counter()
 {
     numbers[0] = Resources._0;
     numbers[1] = Resources._1;
     numbers[2] = Resources._2;
     numbers[3] = Resources._3;
     numbers[4] = Resources._4;
     numbers[5] = Resources._5;
     numbers[6] = Resources._6;
     numbers[7] = Resources._7;
     numbers[8] = Resources._8;
     numbers[9] = Resources._9;
     smile      = Resources.smile;
     cItem      = new CounterItem();
     count      = 7;
 }