private void cbNew_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Edit_CaptureImage capImg = new Edit_CaptureImage();
                capImg.SetSize();
                if (capImg.ShowDialog() == true)
                {
                    // Store the image back
                    // First, we should delete the existing image
                    // Then we should add the new one
                    // And finally assign it
                    try
                    {
                        SEG.Domain.Model.Image img = ImageHelper.SaveImage(ControlCenter.Instance.segR, ControlCenter.Instance.imgPopResult);
                        ImageHelper.FillImage(img);
                        DiagnosticsHelper.SaveDiagnosticsImage(ControlCenter.Instance.segR, dm.Id, img.Id);

                        ImageHolder ih = new ImageHolder();
                        ih.Width = 180;
                        ih.Height = 180;
                        ih.Initialize(img);
                        sPanel.Children.Add(ih);
                        imgHolders.Add(ih);

                        SelectImage(ih);
                    }
                    catch (Exception ex)
                    {
                        StreamWriter sw = new StreamWriter("capture-error.txt");
                        sw.WriteLine(ex.ToString());
                        sw.Close();
                    }
                }
            }
            catch (Exception ex2)
            {
                StreamWriter sw = new StreamWriter("capture-error.txt");
                sw.WriteLine(ex2.ToString());
                sw.Close();
            }
        }
        public void Update(double estimatedWidth)
        {
            // First, clean all the Children of the panel
            sPanel.Children.Clear();

            // Find the mechanical diagnostics
            dm = DiagnosticsHelper.GetMechanicalDiagnostics(ControlCenter.Instance.segR,
                                                                       ControlCenter.Instance.cAssetId);

            List<Diagnostics> electrical = DiagnosticsHelper.GetElectricalDiagnostics(ControlCenter.Instance.segR,
                                                                                      ControlCenter.Instance.cAssetId);

            if (electrical.Count > 0)
            {
                hasElectrical = true;
                labName_S3_0.Foreground = new SolidColorBrush(Colors.White);
            }
            else
            {
                hasElectrical = false;
                labName_S3_0.Foreground = new SolidColorBrush(Colors.Gray);
            }

            // Obtain all the images for the Diagnostics
            List<SEG.Domain.Model.Image> imgs = DiagnosticsHelper.GetDiagnosticsImages(ControlCenter.Instance.segR, dm.Id);
            imgHolders = new List<ImageHolder>();
            foreach(SEG.Domain.Model.Image img in imgs)
            {
                ImageHolder ih = new ImageHolder();
                ih.Width = 180;
                ih.Height = 180;
                ih.Initialize(img);
                sPanel.Children.Add(ih);
                imgHolders.Add(ih);
            }

            imgHolderSel = null;
            cbDelete.Background = new SolidColorBrush(Color.FromArgb(255, 224, 224, 224));
            lbDelete.Foreground = new SolidColorBrush(Colors.Silver);
            cbSet.Background = new SolidColorBrush(Color.FromArgb(255, 224, 224, 224));
            lbSet.Foreground = new SolidColorBrush(Colors.Silver);

            if(imgHolders.Count>0)
                SelectImage(imgHolders[0]);
            else
            {
                iMain.Source = null;
            }
        }