Exemple #1
0
 public ClsFaceFile(string filepath, ClsFace face)
 {
     this.FilePath  = filepath;
     this.Name      = Path.GetFileName(filepath);
     this.DateAdded = DateTime.Now;
     this.Update(face);
 }
Exemple #2
0
        private void FaceSelectionChanged()
        {
            using var Trace = new Trace();  //This c# 8.0 using feature will auto dispose when the function is done.
            try
            {
                if (this.FOLV_Faces.SelectedObjects != null && this.FOLV_Faces.SelectedObjects.Count > 0)
                {
                    //set current selected object
                    ClsFace face = (ClsFace)this.FOLV_Faces.SelectedObjects[0];

                    string mainface = Path.Combine(face.FaceStoragePath, $"{face.Name}.jpg");
                    if (File.Exists(mainface))
                    {
                        pictureBoxCurrentFace.BackgroundImage = Image.FromFile(mainface);
                    }
                    else
                    {
                        pictureBoxCurrentFace.BackgroundImage = null;
                    }

                    Global_GUI.UpdateFOLV(FOLV_FaceFiles, face.Files.Values.ToList(), FullRefresh: true);
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                AITOOL.Log($"Error: {ex.Msg()}");
            }
        }
        public bool TryAddFile(string filename, string face = "")
        {
            if (filename.IsEmpty())
            {
                return(false);
            }

            if (face.IsEmpty())
            {
                face = "Unknown";
            }

            ClsFace FoundFace = new ClsFace(face);

            int fnd = this.Faces.IndexOf(FoundFace);

            if (fnd > -1)
            {
                FoundFace = this.Faces[fnd];
            }
            else
            {
                this.Faces.Add(FoundFace);
            }

            bool added = FoundFace.TryAddFile(filename, out string Outfilename);

            //delete from unknown folder if it was originally from there and it moved
            if (added && filename.Has("\\unknown\\") && !Outfilename.Has("\\unknown\\"))
            {
                Global.SafeFileDelete(filename);
            }

            return(added);
        }
Exemple #4
0
        public bool TryAddFaceFile(ClsImageQueueItem CurImg, string face = "")
        {
            if (!CurImg.IsValid())
            {
                return(false);
            }

            if (face.IsEmpty())
            {
                face = "Unknown";
            }

            if (face.EqualsIgnoreCase("face"))
            {
                face = "Unknown";
            }

            if (face.EqualsIgnoreCase("unknown"))
            {
                if (!this.SaveUnknownFaces)
                {
                    return(false);
                }
            }
            else
            {
                if (!this.SaveKnownFaces)
                {
                    return(false);
                }
            }

            ClsFace FoundFace = this.TryAddFace(face);

            bool added = FoundFace.TryAddFaceFile(CurImg, out string Outfilename, this.MaxFilesPerFace, this.MaxFileAgeDays);

            //delete from unknown folder if it was originally from there and it moved
            if (added)
            {
                this.NeedsSaving.WriteFullFence(true);

                if (CurImg.image_path.Has("\\unknown\\") && !Outfilename.Has("\\unknown\\") &&
                    CurImg.image_path.Has("\\face\\") && !Outfilename.Has("\\face\\"))
                {
                    Global.SafeFileDelete(CurImg.image_path, "TryAddFaceFile");
                }
            }

            return(added);
        }
Exemple #5
0
        public ClsFace TryAddFace(string face)
        {
            if (face.Contains("\\"))
            {
                face = Path.GetFileName(face);
            }

            ClsFace FoundFace = new ClsFace(face);

            bool added = this.FacesDic.TryAdd(face.ToLower(), FoundFace);

            if (added)
            {
                this.NeedsSaving.WriteFullFence(true);
            }

            return(FoundFace);
        }
Exemple #6
0
        public void Update(ClsFace face)
        {
            //first make sure path is correct
            string curpath = Path.GetDirectoryName(this.FilePath);

            if (!curpath.EqualsIgnoreCase(face.FaceStoragePath))
            {
                string filename = Path.GetFileName(this.FilePath);
                this.FilePath = Path.Combine(face.FaceStoragePath, filename);
            }

            if (File.Exists(this.FilePath))
            {
                this.Exists           = true;
                this.DateFileModified = new FileInfo(this.FilePath).LastWriteTime;
            }
            else
            {
                this.Exists = false;
            }
        }
Exemple #7
0
        public ClsFace TryAddFace(string face)
        {
            ClsFace FoundFace = new ClsFace(face);

            int fnd = this.Faces.IndexOf(FoundFace);

            if (fnd > -1)
            {
                FoundFace = this.Faces[fnd];
            }
            else
            {
                lock (FaceLock)
                {
                    this.Faces.Add(FoundFace);
                    this.NeedsSaving = true;
                }
            }

            return(FoundFace);
        }