Exemple #1
0
        public void Run()
        {
            try
            {
                PrintManager.PrintBatchHandler batch1 = _printManager.startNewBatch(PrintTemplateType.Wide);
                batch1.AddImage(GetImageSourceFromPath("pack://application:,,,/Kinect_Standing.bmp"));
                batch1.AddImage(GetImageSourceFromPath("pack://application:,,,/Kinect_Standing.bmp"));
                batch1.CompleteBatch(1);

                PrintManager.PrintBatchHandler batch2 = _printManager.startNewBatch(PrintTemplateType.Wide);
                batch2.AddImage(GetImageSourceFromPath("pack://application:,,,/Kinect_Standing.bmp"));
                batch2.AddImage(GetImageSourceFromPath("pack://application:,,,/Kinect_Leaning.bmp"));
                batch2.CompleteBatch(1);

                PrintManager.PrintBatchHandler batch3 = _printManager.startNewBatch(PrintTemplateType.Wide);
                batch3.AddImage(GetImageSourceFromPath("pack://application:,,,/Kinect_Leaning.bmp"));
                batch3.AddImage(GetImageSourceFromPath("pack://application:,,,/Kinect_Standing.bmp"));
                batch3.CompleteBatch(1);

                PrintManager.PrintBatchHandler batch4 = _printManager.startNewBatch(PrintTemplateType.Wide);
                batch4.AddImage(GetImageSourceFromPath("pack://application:,,,/Kinect_Leaning.bmp"));
                batch4.AddImage(GetImageSourceFromPath("pack://application:,,,/Kinect_Leaning.bmp"));
                batch4.CompleteBatch(2);

                //System.Diagnostics.Debug.WriteLine("Print result: " + (result ? "success" : "failure"));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("=========== Exception In Main ===========");
                System.Diagnostics.Debug.WriteLine("{0}", ex.Message);
                System.Diagnostics.Debug.WriteLine("=========================================");
            }
        }
        public void Run()
        {
            try
            {
                ImageSource[] images = new ImageSource[]
                {
                    GetImageSourceFromPath("backgroundImages/beach.bmp"),
                    GetImageSourceFromPath("backgroundImages/LukeVaderDual.bmp")
                };


                PrintManager.PrintBatchHandler batch1 = _printManager.startNewBatch(PrintTemplateType.Wide);
                batch1.AddImage(images[0]);
                batch1.AddImage(images[1]);
                batch1.CompleteBatch(1);
                //System.Diagnostics.Debug.WriteLine("Print result: " + (result ? "success" : "failure"));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("=========== Exception In Main ===========");
                System.Diagnostics.Debug.WriteLine("{0}", ex.Message);
                System.Diagnostics.Debug.WriteLine("=========================================");
            }
        }
Exemple #3
0
        private void SetupStates()
        {
            SELECT_BACKGROUND = new State("SELECT_BACKGROUND", (eventType, eventArgs, stateData) =>
            {
                switch (eventType)
                {
                case EventType.TRANSITION_TO_STATE:
                    ChangeState(SELECT_BACKGROUND);
                    Dispatcher.Invoke(() => tabControl.SelectedIndex = 0);

                    if (_currentBatch.TemplateFull)
                    {
                        _currentBatch = _printManager.startNewBatch(PrintTemplateType.Wide);
                    }

                    UpdateStatus();
                    break;

                case EventType.PREVIEW_IMAGE_ARRIVED:
                    if (!_havePrintError)
                    {
                        Dispatcher.Invoke(() => backgroundPreview.Source = eventArgs as ImageSource);
                    }
                    break;

                case EventType.TAKE_PICTURE_REQUEST:
                    if (!_havePrintError)
                    {
                        COUNTDOWN.HandleEvent(EventType.TRANSITION_TO_STATE, null);
                    }
                    break;

                case EventType.PRINT_ERROR:
                    DefaultPrintErrorHandler(eventArgs as String);
                    break;
                }
            });

            COUNTDOWN = new State("COUNTDOWN", (eventType, eventArgs, stateData) =>
            {
                Thread countdownThread;

                switch (eventType)
                {
                case EventType.TRANSITION_TO_STATE:
                    ChangeState(COUNTDOWN);
                    Dispatcher.Invoke(() => { tabControl.SelectedIndex = 1; countdownPreview.Source = backgroundPreview.Source; });

                    countdownThread = new Thread(() =>
                    {
                        while (_havePrintError)
                        {
                        }

                        int countDown = _countdownLength;
                        while (countDown > 0)
                        {
                            Dispatcher.Invoke(() => countdownLabel.Content = countDown.ToString());
                            Thread.Sleep(500);
                            Dispatcher.Invoke(() => countdownLabel.Content = "");
                            Thread.Sleep(500);
                            countDown--;
                        }

                        Dispatcher.Invoke(() => countdownLabel.Content = "SMILE !");
                        Thread.Sleep(2000);
                        Dispatcher.Invoke(() => countdownLabel.Content = "");
                        //_readyForCapture = true;
                        _imageProducer.SetConfiguration(ImageProducerConfiguration.Simple("captureHighQuality"));
                    });
                    countdownThread.Start();
                    break;

                case EventType.PREVIEW_IMAGE_ARRIVED:
                    if (!_havePrintError)
                    {
                        Dispatcher.Invoke(() => countdownPreview.Source = eventArgs as ImageSource);
                    }
                    break;

                case EventType.IMAGE_CAPTURED:
                    BitmapSource image = eventArgs as BitmapSource;

                    if (_createNewBackground)
                    {
                        _createNewBackground = false;
                        String timeStamp     = BuildTimestampString();
                        WriteImageFile(image, BuildAbsoluteFilePath(_backgroundImagePath, timeStamp, "bmp"));
                        _backgroundIterator.Add(new BackgroundImage(timeStamp, image));
                        _backgroundIterator.MoveLast();
                        UpdateCarousel();

                        Dictionary <String, BitmapSource> outMap = new Dictionary <string, BitmapSource>();
                        outMap.Add(timeStamp, image);
                        _imageProducer.SetConfiguration(ImageProducerConfiguration.Simple("addBackgroundImages", outMap));
                    }
                    else
                    {
                        _currentBatch.AddImage(image);
                        WriteImageFile(image, BuildAbsoluteFilePath(_imageSavePath, BuildTimestampString(), "bmp"));
                    }

                    if (_currentBatch.TemplateFull)
                    {
                        Dispatcher.InvokeAsync(() => PRINTING.HandleEvent(EventType.TRANSITION_TO_STATE, null));
                    }
                    else
                    {
                        Dispatcher.InvokeAsync(() => SELECT_BACKGROUND.HandleEvent(EventType.TRANSITION_TO_STATE, null));
                    }

                    break;

                case EventType.PRINT_ERROR:
                    DefaultPrintErrorHandler(eventArgs as String);
                    break;
                }
            });


            PRINTING = new State("PRINTING", (eventType, eventArgs, stateData) =>
            {
                switch (eventType)
                {
                case EventType.TRANSITION_TO_STATE:
                    ChangeState(PRINTING);
                    Dispatcher.Invoke(() => tabControl.SelectedIndex = 2);

                    _currentBatch.CompleteBatch(_copyCount);
                    Thread waitThread = new Thread(() =>
                    {
                        Thread.Sleep(3000);

                        while (_havePrintError)
                        {
                        }

                        Dispatcher.Invoke(() => SELECT_BACKGROUND.HandleEvent(EventType.TRANSITION_TO_STATE, null));
                    });
                    waitThread.Start();
                    break;

                case EventType.PRINT_ERROR:
                    DefaultPrintErrorHandler(eventArgs as String);
                    break;
                }
            });
            SELECT_BACKGROUND.HandleEvent(EventType.TRANSITION_TO_STATE, null);
        }