Exemple #1
0
        } /* LoadClassList */

        private void  ValidateSourceDirectory()
        {
            errorProvider1.SetError(SourceDirectory, null);
            if (String.IsNullOrEmpty(SourceDirectory.Text))
            {
                errorProvider1.SetError(SourceDirectory, "Can not leave Source Directory blank");
                validationErrorsFound = true;
            }
            else
            {
                DirectoryInfo di = null;
                try  { di = new DirectoryInfo(SourceDirectory.Text); }
                catch (Exception e)
                {
                    errorProvider1.SetError(SourceDirectory, "Error getting directory information.  " + e.ToString());
                    validationErrorsFound = true;
                    di = null;
                }
                if ((di != null) && (!di.Exists))
                {
                    errorProvider1.SetError(SourceDirectory, "Directory does not exist.");
                    validationErrorsFound = true;
                }

                if ((SourceDirectory.Text.CompareTo(lastDirectoryValidated) != 0) && (!validationErrorsFound))
                {
                    config = new PicesTrainingConfigManaged(di, runLog);
                    LoadClassList();
                    ModelName.Text = OSservices.GetRootNameOfDirectory(SourceDirectory.Text);
                }
            }

            lastDirectoryValidated = SourceDirectory.Text;
        } /* ValidateSourceDirectory */
        private void  StartReconciliationThread()
        {
            String   rootName    = OSservices.GetRootNameOfDirectory(SourceDirectory.Text);
            DateTime d           = DateTime.Now;
            String   logFileName = OSservices.AddSlash(PicesSipperVariables.TempDirectory()) + rootName + "_ReconcileImageNames_" +
                                   d.ToString("yyyyMMdd-HHmmss") + ".txt";

            // Any images that are not in the Database that are to be removed will be moved to the subdirectory structure below.
            removalDestRootDir = "c:\\Temp\\PicesDatabaseImageReconciliationRemovedImages\\" + rootName;
            OSservices.CreateDirectoryPath(removalDestRootDir);

            reconcilingRunLog = new PicesRunLog(logFileName);


            Start.Enabled                 = false;
            SourceDirectory.ReadOnly      = true;
            SourceDirectoryBrowse.Enabled = false;
            reconcilingThread             = new Thread(new ThreadStart(ReconciliationThread));
            reconcilingThread.Start();
            Cancel.Enabled        = true;
            RunStatsTimer.Enabled = true;
        } /* StartReconciliationThread */
Exemple #3
0
        public DisplayPicesImages(String _dir,
                                  String _dir2,
                                  ProbNamePair[]  _nameList
                                  )
        {
            InitializeComponent();

            dir  = OSservices.AddSlash(_dir);
            dir2 = OSservices.AddSlash(_dir2);

            nameList = _nameList;

            Text = dir;

            if (!String.IsNullOrEmpty(dir) && !String.IsNullOrEmpty(dir2))
            {
                Text = OSservices.GetRootNameOfDirectory(dir) + " vs " + OSservices.GetRootNameOfDirectory(dir2);
            }

            thumbNails = new List <FlowLayoutPanel> ();

            DirectoryInfo di = null;

            try  { di = new DirectoryInfo(dir); }
            catch (Exception)  { di = null; }
            if (di == null)
            {
                return;
            }

            try  { files = di.GetFiles("*.*"); }  catch (Exception)  { files = null; }
            files = ReduceToImageFiles(files);
            if (files != null)
            {
                UpdateDisplayTimer.Enabled = true;
            }
        }
Exemple #4
0
        } /* LocateRootName */

        private void  LoadNextImageFromNameList()
        {
            if (nameList == null)
            {
                return;
            }

            if (lastImageIndexLoaded >= nameList.Length)
            {
                UpdateDisplayTimer.Enabled = false;
                return;
            }

            String rootName    = nameList[lastImageIndexLoaded].name;
            double probability = nameList[lastImageIndexLoaded].probability;

            lastImageIndexLoaded++;

            String fullName = LocateRootName(rootName);

            if (fullName == null)
            {
                return;
            }

            String subDir = OSservices.GetPathPartOfFile(fullName);

            FileInfo fi = new FileInfo(fullName);

            Bitmap image = null;

            try  { image = new Bitmap(fi.FullName); }
            catch (Exception) { image = null; }
            if (image == null)
            {
                return;
            }

            float ratio  = 1.0f;
            int   maxDim = Math.Max(image.Height, image.Width);

            if (maxDim > 150)
            {
                ratio = 150.0f / (float)maxDim;
            }

            PictureBox pb = new PictureBox();

            pb.BorderStyle = BorderStyle.FixedSingle;

            int h = (int)((float)image.Height * ratio);
            int w = (int)((float)image.Width * ratio);

            Font font = new System.Drawing.Font("Courier New", 8.0f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

            pb.Height            = h + 2;
            pb.Width             = w + 2;
            pb.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(ThumbNail_MouseDoubleClick);
            pb.Name              = fi.FullName;

            //ContextMenuStrip cms = new ContextMenuStrip ();
            //String  menuItemStr = "Remove " + rootName + " From Training Library";
            //cms.Items.Add (menuItemStr, null, RemoveImageFromTrainigLibray);
            //pb.ContextMenuStrip = cms;

            Image thumbNail = image.GetThumbnailImage(w, h, GetThumbnailImageAbort, thumbNailCallBackData);

            pb.Image = thumbNail;

            FlowLayoutPanel pan = new FlowLayoutPanel();

            pan.Size = new Size(Math.Max(170, w + 10), 260);
            //pan.Height = h + 80;
            //pan.Width  = Math.Max (160, w + 10);

            pan.Controls.Add(pb);
            TextBox tb = new TextBox();

            tb.Width = pan.Width - 8;
            tb.Text  = rootName;
            tb.Font  = font;

            pan.Controls.Add(tb);

            tb       = new TextBox();
            tb.Width = pan.Width - 8;
            tb.Text  = OSservices.GetRootNameOfDirectory(subDir);
            tb.Font  = font;
            pan.Controls.Add(tb);

            tb       = new TextBox();
            tb.Width = pan.Width - 8;
            tb.Text  = probability.ToString("p2");
            tb.Font  = font;
            pan.Controls.Add(tb);

            Button b = new Button();

            b.Text    = "Delete";
            b.Name    = rootName;
            b.Enabled = true;
            b.TabStop = false;
            b.Click  += new EventHandler(RemoveImageFromTrainigLibray);
            pan.Controls.Add(b);

            pan.BorderStyle = BorderStyle.FixedSingle;

            thumbNails.Add(pan);

            ImageDisplayPanel.Controls.Add(pan);
        } /* LoadNextImageFromDir */