internal void showNextCapture()
        {
            Image img, clone = new Image();
            int   index = 0;

            foreach (object child in cf.getCapturePanel().Children)
            {
                img   = (Image)child;
                index = Int32.Parse(img.Uid);
            }

            for (int i = 0; i < cfs.Count; i++)
            {
                cfs.ElementAt(i).getBorder().Background = Brushes.White;
            }

            timeLabel.Content = "Capture taken at: " + cfs.ElementAt(index).getTime();

            if (index == cfs.Count - 1)
            {
                foreach (object child in cfs.ElementAt(0).getCapturePanel().Children)
                {
                    img          = (Image)child;
                    clone.Source = img.Source;
                    clone.Uid    = img.Uid;
                }
                cfs.ElementAt(0).getBorder().Background = Brushes.LightBlue;
                CapturesListBox.SelectedIndex           = 0;
                CapturesListBox.Focus();
            }
            else
            {
                foreach (object child in cfs.ElementAt(index + 1).getCapturePanel().Children)
                {
                    img          = (Image)child;
                    clone.Source = img.Source;
                    clone.Uid    = img.Uid;
                }

                cfs.ElementAt(index + 1).getBorder().Background = Brushes.LightBlue;
                CapturesListBox.SelectedIndex = index + 1;
                CapturesListBox.Focus();
            }

            cf.getCapturePanel().Children.Clear();
            cf.getCapturePanel().Children.Add(clone);
        }
        // Management of a new taken image

        public void DrawImage()
        {
            Image img1 = new Image();
            Image img2 = new Image();

            BitmapImage src1 = new BitmapImage();
            BitmapImage src2 = new BitmapImage();

            img1.Uid = cfs.Count.ToString();
            img2.Uid = cfs.Count.ToString();


            // Img acquisition

            src1.BeginInit();
            src1.UriSource   = t.getCaptures().ElementAt(t.getCaptures().Count - 1);
            src1.CacheOption = BitmapCacheOption.OnLoad;
            src1.EndInit();
            img1.Source  = src1;
            img1.Stretch = Stretch.Uniform;

            src2.BeginInit();
            src2.UriSource   = t.getCaptures().ElementAt(t.getCaptures().Count - 1);
            src2.CacheOption = BitmapCacheOption.OnLoad;
            src2.EndInit();
            img2.Source  = src1;
            img2.Stretch = Stretch.Uniform;

            double ratio = src1.Width / src1.Height;

            // Adding image to group

            cfs.Add(new captureFramework(img1, 120, ratio));

            ListBoxItem item          = new ListBoxItem();
            Grid        arrangingGrid = new Grid();

            arrangingGrid.Width = 560;
            ColumnDefinition c1 = new ColumnDefinition();

            c1.Width = new GridLength(150);
            ColumnDefinition c2 = new ColumnDefinition();

            c1.Width = new GridLength(350);
            ColumnDefinition c3 = new ColumnDefinition();

            c1.Width = new GridLength();

            arrangingGrid.ColumnDefinitions.Add(c1);
            arrangingGrid.ColumnDefinitions.Add(c2);
            arrangingGrid.ColumnDefinitions.Add(c3);

            Button commentBut = initializeButton(cfs.Count - 1);

            commentBut.HorizontalAlignment = HorizontalAlignment.Left;
            commentBut.Margin = new Thickness(30, 0, 0, 0);

            Label emptyLabel = new Label();

            emptyLabel.HorizontalAlignment = HorizontalAlignment.Center;
            emptyLabel.VerticalAlignment   = VerticalAlignment.Center;

            Grid.SetColumn(commentBut, 0);
            Grid.SetColumn(emptyLabel, 1);
            Grid.SetColumn(cfs.ElementAt(cfs.Count - 1).getCapturePanel(), 2);

            arrangingGrid.Children.Add(commentBut);
            arrangingGrid.Children.Add(emptyLabel);
            arrangingGrid.Children.Add(cfs.ElementAt(cfs.Count - 1).getCapturePanel());

            cfs.ElementAt(cfs.Count - 1).getCapturePanel().HorizontalAlignment = HorizontalAlignment.Right;
            cfs.ElementAt(cfs.Count - 1).setPosition(new Thickness(0, 0, 30, 0));


            item.Content = arrangingGrid;

            CapturesListBox.Items.Add(item);

            cfs.ElementAt(cfs.Count - 1).getCapturePanel().Uid  = (cfs.Count - 1).ToString();
            cfs.ElementAt(cfs.Count - 1).getBorder().Background = Brushes.LightBlue;

            for (int i = 0; i < cfs.Count - 1; i++)
            {
                cfs.ElementAt(i).getBorder().Background = Brushes.White;
            }

            // Adding image to last

            cf = new captureFramework(img2, 400, ratio);

            LastImageCanvas.Children.Clear();
            LastImageCanvas.Children.Add(cf.getBorder());
            LastImageCanvas.Children.Add(cf.getCapturePanel());

            ProjectButton.Visibility = Visibility.Visible;
            infoLabel.Visibility     = Visibility.Visible;

            timeLabel.Content    = "Capture taken at: " + cf.getTime();
            timeLabel.Visibility = Visibility.Visible;

            // Update info

            dataLabel.Content = "Capture of object " + t.getIndex() + Environment.NewLine +
                                "Captures taken each " + t.getInterval() + " minutes" + Environment.NewLine +
                                t.getNumberOfCaptures() + " captures to be taken" + Environment.NewLine +
                                (t.getNumberOfCaptures() + 1 - cfs.Count) + " captures to go";

            file.AppendData("\t Capture " + cfs.Count() + " taken at: " + cf.getTime());

            CapturesListBox.SelectedIndex = cfs.Count - 1;
            CapturesListBox.Focus();
        }
        // Management of a new taken image

        public void DrawImage(bool moved)
        {
            Image img1 = new Image();
            Image img2 = new Image();

            BitmapImage src1 = new BitmapImage();
            BitmapImage src2 = new BitmapImage();

            img1.Uid = cfs.Count.ToString();
            img2.Uid = cfs.Count.ToString();

            // Img acquisition

            src1.BeginInit();
            src1.UriSource   = t.getCaptures().ElementAt(t.getCaptures().Count - 1);
            src1.CacheOption = BitmapCacheOption.OnLoad;
            src1.EndInit();
            img1.Source  = src1;
            img1.Stretch = Stretch.Uniform;

            src2.BeginInit();
            src2.UriSource   = t.getCaptures().ElementAt(t.getCaptures().Count - 1);
            src2.CacheOption = BitmapCacheOption.OnLoad;
            src2.EndInit();
            img2.Source  = src1;
            img2.Stretch = Stretch.Uniform;

            double ratio = src1.Width / src1.Height;

            // Adding image to group

            cfs.Add(new captureFramework(img1, 120, ratio));

            ListBoxItem item          = new ListBoxItem();
            Grid        arrangingGrid = new Grid();

            arrangingGrid.Width = 560;
            ColumnDefinition c1 = new ColumnDefinition();

            c1.Width = new GridLength(150);
            ColumnDefinition c2 = new ColumnDefinition();

            c1.Width = new GridLength(350);
            ColumnDefinition c3 = new ColumnDefinition();

            c1.Width = new GridLength();

            arrangingGrid.ColumnDefinitions.Add(c1);
            arrangingGrid.ColumnDefinitions.Add(c2);
            arrangingGrid.ColumnDefinitions.Add(c3);

            Button commentBut = initializeButton(cfs.Count - 1);

            commentBut.HorizontalAlignment = HorizontalAlignment.Left;
            commentBut.Margin = new Thickness(30, 0, 0, 0);

            Label emptyLabel = new Label();

            emptyLabel.HorizontalAlignment = HorizontalAlignment.Center;
            emptyLabel.VerticalAlignment   = VerticalAlignment.Center;

            Grid.SetColumn(commentBut, 0);
            Grid.SetColumn(emptyLabel, 1);
            Grid.SetColumn(cfs.ElementAt(cfs.Count - 1).getCapturePanel(), 2);

            arrangingGrid.Children.Add(commentBut);
            arrangingGrid.Children.Add(emptyLabel);
            arrangingGrid.Children.Add(cfs.ElementAt(cfs.Count - 1).getCapturePanel());

            cfs.ElementAt(cfs.Count - 1).getCapturePanel().HorizontalAlignment = HorizontalAlignment.Right;
            cfs.ElementAt(cfs.Count - 1).setPosition(new Thickness(0, 0, 30, 0));


            item.Content = arrangingGrid;

            CapturesListBox.Items.Add(item);

            cfs.ElementAt(cfs.Count - 1).getCapturePanel().Uid  = (cfs.Count - 1).ToString();
            cfs.ElementAt(cfs.Count - 1).getBorder().Background = Brushes.LightBlue;

            for (int i = 0; i < cfs.Count - 1; i++)
            {
                cfs.ElementAt(i).getBorder().Background = Brushes.White;
            }

            // Adding image to last

            cf = new captureFramework(img2, 400, ratio);

            LastImageCanvas.Children.Clear();
            LastImageCanvas.Children.Add(cf.getBorder());
            LastImageCanvas.Children.Add(cf.getCapturePanel());

            ProjectButton.Visibility = Visibility.Visible;
            infoLabel.Visibility     = Visibility.Visible;

            timeLabel.Content    = "Capture taken at: " + cf.getTime();
            timeLabel.Visibility = Visibility.Visible;

            // Update info

            dataLabel.Content = "Capture of object " + t.getIndex() + Environment.NewLine +
                                "Captures taken each " + t.getInterval() + " minutes" + Environment.NewLine +
                                t.getNumberOfCaptures() + " captures to be taken" + Environment.NewLine +
                                (t.getNumberOfCaptures() + 1 - cfs.Count) + " captures to go";

            file.AppendData("\t Capture " + cfs.Count() + " taken at: " + cf.getTime());

            CapturesListBox.SelectedIndex = cfs.Count - 1;
            CapturesListBox.Focus();

            if (moved)
            {
                emptyLabel.Content = "Capture #" + (cfs.Count - 1) + " " + cf.getTime() + ": " + Environment.NewLine + "Object deplacement detected";
            }
            else
            {
                emptyLabel.Content = "Capture #" + (cfs.Count - 1) + " " + cf.getTime() + ": " + "Success capture";
            }

            // Set image into bitmap format to be analyzed

            if (t.getCountAnalysis())
            {
                MemoryStream     ms  = new MemoryStream();
                BmpBitmapEncoder bbe = new BmpBitmapEncoder();
                bbe.Frames.Add(BitmapFrame.Create(new Uri(img1.Source.ToString(), UriKind.RelativeOrAbsolute)));
                bbe.Save(ms);
                System.Drawing.Image bmpImg = System.Drawing.Image.FromStream(ms);

                System.Drawing.Bitmap cloneBmp = userClone(bmpImg);

                object[] param = new object[2];
                param[0] = cloneBmp;
                param[1] = this;

                Thread t = new Thread(aw.getCount().newStep);
                t.Start(param);

                bmpImg.Dispose();
            }
        }
        // This Window will be initialized with an image taken from CapturePreviews
        // featuring the state of the object to capture prior to the capture process
        private void FirstCapture(Image img)
        {
            Image clone1 = new Image();
            Image clone2 = new Image();

            clone1.Uid = "0";
            clone2.Uid = "0";

            clone1.Source = img.Source;
            clone2.Source = img.Source;

            double ratio = clone1.Source.Width / clone1.Source.Height;

            // Adding image to group
            cfs.Add(new captureFramework(clone1, 120, ratio));

            ListBoxItem item          = new ListBoxItem();
            Grid        arrangingGrid = new Grid();

            arrangingGrid.Width = 560;
            ColumnDefinition c1 = new ColumnDefinition();

            c1.Width = new GridLength(150);
            ColumnDefinition c2 = new ColumnDefinition();

            c1.Width = new GridLength(350);
            ColumnDefinition c3 = new ColumnDefinition();

            c1.Width = new GridLength();

            arrangingGrid.ColumnDefinitions.Add(c1);
            arrangingGrid.ColumnDefinitions.Add(c2);
            arrangingGrid.ColumnDefinitions.Add(c3);

            Button commentBut = initializeButton(cfs.Count - 1);

            commentBut.HorizontalAlignment = HorizontalAlignment.Left;
            commentBut.Margin = new Thickness(30, 0, 0, 0);

            Label emptyLabel = new Label();

            emptyLabel.HorizontalAlignment = HorizontalAlignment.Center;
            emptyLabel.VerticalAlignment   = VerticalAlignment.Center;

            Grid.SetColumn(commentBut, 0);
            Grid.SetColumn(emptyLabel, 1);
            Grid.SetColumn(cfs.ElementAt(cfs.Count - 1).getCapturePanel(), 2);

            arrangingGrid.Children.Add(commentBut);
            arrangingGrid.Children.Add(emptyLabel);
            arrangingGrid.Children.Add(cfs.ElementAt(cfs.Count - 1).getCapturePanel());

            cfs.ElementAt(cfs.Count - 1).getCapturePanel().HorizontalAlignment = HorizontalAlignment.Right;
            cfs.ElementAt(cfs.Count - 1).setPosition(new Thickness(0, 0, 30, 0));


            item.Content = arrangingGrid;

            CapturesListBox.Items.Add(item);

            cfs.ElementAt(cfs.Count - 1).getCapturePanel().Uid  = (cfs.Count - 1).ToString();
            cfs.ElementAt(cfs.Count - 1).getBorder().Background = Brushes.LightBlue;


            // Setting to last image
            cf = new captureFramework(clone2, 400, ratio);

            LastImageCanvas.Children.Clear();
            LastImageCanvas.Children.Add(cf.getBorder());
            LastImageCanvas.Children.Add(cf.getCapturePanel());

            ProjectButton.Visibility = Visibility.Visible;
            infoLabel.Visibility     = Visibility.Visible;

            timeLabel.Content    = "Capture taken at: " + cf.getTime();
            timeLabel.Visibility = Visibility.Visible;

            file.AppendData("\t First capture taken at :" + cf.getTime());

            file.AppendData("\t " + t.getDelay() + " minutes of delay waited");

            CapturesListBox.SelectedIndex = 0;
            CapturesListBox.Focus();
        }
        // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        //      Capture related functions
        // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


        // This Window will be initialized with an image taken from CapturePreviews
        // featuring the state of the object to capture prior to the capture process

        private void FirstCapture(Image img, bool moved)
        {
            Image clone1 = new Image();
            Image clone2 = new Image();

            clone1.Uid = "0";
            clone2.Uid = "0";

            clone1.Source = img.Source;
            clone2.Source = img.Source;

            double ratio = clone1.Source.Width / clone1.Source.Height;

            // Adding image to group

            cfs.Add(new captureFramework(clone1, 120, ratio));

            ListBoxItem item          = new ListBoxItem();
            Grid        arrangingGrid = new Grid();

            arrangingGrid.Width = 560;
            ColumnDefinition c1 = new ColumnDefinition();

            c1.Width = new GridLength(150);
            ColumnDefinition c2 = new ColumnDefinition();

            c1.Width = new GridLength(350);
            ColumnDefinition c3 = new ColumnDefinition();

            c1.Width = new GridLength();

            arrangingGrid.ColumnDefinitions.Add(c1);
            arrangingGrid.ColumnDefinitions.Add(c2);
            arrangingGrid.ColumnDefinitions.Add(c3);

            Button commentBut = initializeButton(cfs.Count - 1);

            commentBut.HorizontalAlignment = HorizontalAlignment.Left;
            commentBut.Margin = new Thickness(30, 0, 0, 0);

            Label emptyLabel = new Label();

            emptyLabel.HorizontalAlignment = HorizontalAlignment.Center;
            emptyLabel.VerticalAlignment   = VerticalAlignment.Center;

            Grid.SetColumn(commentBut, 0);
            Grid.SetColumn(emptyLabel, 1);
            Grid.SetColumn(cfs.ElementAt(cfs.Count - 1).getCapturePanel(), 2);

            arrangingGrid.Children.Add(commentBut);
            arrangingGrid.Children.Add(emptyLabel);
            arrangingGrid.Children.Add(cfs.ElementAt(cfs.Count - 1).getCapturePanel());

            cfs.ElementAt(cfs.Count - 1).getCapturePanel().HorizontalAlignment = HorizontalAlignment.Right;
            cfs.ElementAt(cfs.Count - 1).setPosition(new Thickness(0, 0, 30, 0));


            item.Content = arrangingGrid;

            CapturesListBox.Items.Add(item);

            cfs.ElementAt(cfs.Count - 1).getCapturePanel().Uid  = (cfs.Count - 1).ToString();
            cfs.ElementAt(cfs.Count - 1).getBorder().Background = Brushes.LightBlue;


            // Setting to last image

            cf = new captureFramework(clone2, 400, ratio);

            LastImageCanvas.Children.Clear();
            LastImageCanvas.Children.Add(cf.getBorder());
            LastImageCanvas.Children.Add(cf.getCapturePanel());

            ProjectButton.Visibility = Visibility.Visible;
            infoLabel.Visibility     = Visibility.Visible;

            timeLabel.Content    = "Capture taken at: " + cf.getTime();
            timeLabel.Visibility = Visibility.Visible;

            file.AppendData("\t First capture taken at: " + cf.getTime() + ". " + t.getDelay() + " minutes of delay waited.");

            CapturesListBox.SelectedIndex = 0;
            CapturesListBox.Focus();

            if (moved)
            {
                emptyLabel.Content = "Capture #0 " + cf.getTime() + ": " + Environment.NewLine + "Object deplacement detected";
            }
            else
            {
                emptyLabel.Content = "Capture #0 " + cf.getTime() + ": " + "Success capture";
            }

            // Set image into bitmap format to be analyzed

            if (t.getCountAnalysis())
            {
                MemoryStream     ms  = new MemoryStream();
                BmpBitmapEncoder bbe = new BmpBitmapEncoder();
                bbe.Frames.Add(BitmapFrame.Create(new Uri(img.Source.ToString(), UriKind.RelativeOrAbsolute)));
                bbe.Save(ms);
                System.Drawing.Image img2 = System.Drawing.Image.FromStream(ms);

                aw.getCount().setBackgound(img2);

                img2.Dispose();
            }
        }