internal void CaptureFinished()
 {
     CapturePreviews.DecrementCaptures();
     finishedCapture.Background = Brushes.Green;
     RunningLabel.Content       = "Capture Process Finished";
     running = false;
 }
        // This window is responsble for handling the captures of the object that represents, and thus
        // manages the MainCapture thread and hosts capture taking functions
        public CaptureWindow(CapturePreviews capt, Image img, int[] param, string folder)
        {
            InitializeComponent();

            this.Width  = 1200;
            this.Height = 900;

            cp = capt;

            cfs = new List <captureFramework>();

            // A task holds details for a capture process (See <Task> constructior definition)
            List <Uri> u = new List <Uri>();

            t = new Task(this, param[0], param[1], param[2], param[3], u, folder);

            Directory.CreateDirectory(folder);
            file = new LogFile(t.getFolder(), t.getIndex(), t.getNumberOfCaptures());


            file.BuildAndSave();

            // Thread initialization
            MainCapture newCapture = new MainCapture();

            newCaptureThread = new Thread(newCapture.StartCapture);
            newCaptureThread.SetApartmentState(ApartmentState.STA);
            newCaptureThread.Start(t);
            running = true;
            playing = false;

            StackPanel aux   = new StackPanel();
            Rectangle  frame = new Rectangle();

            frame.Width  = 570;
            frame.Height = 550;

            frame.Stroke          = Brushes.Black;
            frame.StrokeThickness = 4;

            aux.Children.Add(frame);
            StackPanel.SetZIndex(aux, 10);

            ImagesCanvas.Children.Add(aux);

            FirstCapture(img);

            Info_Init();

            Logo_Init();

            PlayNStop_Init();

            CapturesListBox.SelectionChanged += new SelectionChangedEventHandler(listBoxClicked);

            speed = 1;
        }
        // Capture starting and finished handlers
        internal void CaptureFinished()
        {
            CapturePreviews.DecrementCaptures();
            finishedCapture.Background = Brushes.Green;
            RunningLabel.Content       = "Capture Process Finished";
            running = false;

            StopButton.Visibility = Visibility.Hidden;

            if (!aw.getPicker().countAnalysis)
            {
                file.BuildAndSave();
            }
        }
        // UI Closing handling

        private void CaptureWindow_Closing(object sender, CancelEventArgs e)
        {
            if (MainWindow.killRequest)
            {
                newCaptureThread.Abort();
                e.Cancel = false;
                aw.Close();
            }
            else
            {
                if (running)
                {
                    string msg = "Kill capture process?";

                    MessageBoxResult res =
                        MessageBox.Show(
                            msg,
                            "Closing Dialog",
                            MessageBoxButton.YesNo,
                            MessageBoxImage.Warning);

                    if (res == MessageBoxResult.No)
                    {
                        e.Cancel = true;
                        this.Hide();
                    }
                    else
                    {
                        e.Cancel = false;
                        CapturePreviews.DecrementCaptures();
                        newCaptureThread.Abort();
                        cp.EraseFinishedCapture(Int32.Parse(this.Uid));
                        aw.requestClosing();
                        aw.Close();
                    }
                }
                else
                {
                    cp.EraseFinishedCapture(Int32.Parse(this.Uid));
                    e.Cancel = false;
                    aw.requestClosing();
                    aw.Close();
                }
                if (playing)
                {
                    playThread.Abort();
                }
            }
        }
Example #5
0
        // The interface is initialized blank until a scan is made
        public MainPage()
        {
            InitializeComponent();

            this.Width  = System.Windows.SystemParameters.PrimaryScreenWidth;
            this.Height = System.Windows.SystemParameters.PrimaryScreenHeight;

            objectShowStackPanel.Visibility = Visibility.Collapsed;

            parameters = new List <int[]>();

            counter = 1;

            cp              = new CapturePreviews(this);
            saveFolders     = new List <string>();
            capturesRunning = false;

            Logo_Init();
        }
Example #6
0
        // Closing management (triggered when closing MainPage or CapturePreview)
        private void MainWindow_Closing(object sender, CancelEventArgs e)
        {
            if (MainPage.capturesRunning)
            {
                string msg = "There are still captures running. Close anyways?";

                MessageBoxResult res =
                    MessageBox.Show(
                        msg,
                        "Closing Dialog",
                        MessageBoxButton.YesNo,
                        MessageBoxImage.Warning);

                if (res == MessageBoxResult.Yes)
                {
                    e.Cancel    = false;
                    killRequest = true;
                    CapturePreviews.killAllCaptures();

                    Directory.Delete(ToolBox.defaultFilePath, true);
                }
                else
                {
                    e.Cancel = true;
                }
            }
            else
            {
                try
                {
                    Directory.Delete(ToolBox.defaultFilePath, true);
                }catch (DirectoryNotFoundException notFound)
                {
                }
            }
        }
        // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        //      UI related functions
        // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

        // This window is responsble for handling the captures of the object that represents, and thus
        // manages the MainCapture thread and hosts capture taking functions
        public CaptureWindow(CapturePreviews capt, Image img, int[] param, string folder, bool[] analysis, string name, PcPhysicalPoint location, System.Drawing.Point size, bool moved, string map)
        {
            InitializeComponent();

            this.Width  = 1200;
            this.Height = 900;

            this.Left = 300;
            this.Top  = 100;


            cp = capt;

            cfs = new List <captureFramework>();

            // A task holds details for a capture process (See <Task> constructior definition)
            List <Uri> u = new List <Uri>();

            t = new Task(this, param[0], param[1], param[2], param[3], u, folder, analysis[0], analysis[1], name, location, size);

            aw = new AnalysisWindow(this, t.getCountAnalysis(), t.getClassAnalysis(), map, folder);

            Directory.CreateDirectory(folder);
            file = new LogFile(t.getFolder(), t.getIndex(), t.getName(), t.getNumberOfCaptures());

            titleLabel.Content = name;

            if (!analysis[0] && !analysis[1])
            {
                generalAnalysisBut.Visibility = Visibility.Hidden;
            }

            // Thread initialization for triggering the captures

            MainCapture newCapture = new MainCapture();

            newCaptureThread = new Thread(newCapture.StartCapture);
            newCaptureThread.SetApartmentState(ApartmentState.STA);
            newCaptureThread.Start(t);
            running = true;
            playing = false;

            // UI elements initialization

            StackPanel aux   = new StackPanel();
            Rectangle  frame = new Rectangle();

            frame.Visibility = Visibility.Hidden;
            frame.Width      = 575;
            frame.Height     = 400;

            frame.Stroke          = Brushes.Black;
            frame.StrokeThickness = 4;

            aux.Children.Add(frame);
            StackPanel.SetZIndex(aux, 10);

            ImagesCanvas.Children.Add(aux);

            StackPanel aux2   = new StackPanel();
            Rectangle  frame2 = new Rectangle();

            frame2.Width  = 500;
            frame2.Height = 120;

            frame2.Stroke          = Brushes.Black;
            frame2.StrokeThickness = 4;

            aux2.Children.Add(frame2);
            StackPanel.SetZIndex(aux2, 10);

            EventsCanvas.Children.Add(aux2);

            FirstCapture(img, moved);

            Info_Init();

            Logo_Init();

            PlayNStop_Init();

            CapturesListBox.SelectionChanged += new SelectionChangedEventHandler(listBoxClicked);

            EventsListBox.SelectionChanged += new SelectionChangedEventHandler(eventClicked);

            if (analysis[0])
            {
                EventsListBox.Visibility = Visibility.Visible; CountAnalysisBut.Visibility = Visibility.Visible; frame.Visibility = Visibility.Visible;
            }

            speed = 1;
        }