Beispiel #1
0
        public void AddResult(ICycleGANresult result)
        {
            //If the guid was encoded in the path (outputfolder = standard), get that guid and use it
            //If not, create a new guid
            string guid;

            if (result is CycleGANSingleResult)
            {
                guid = (result as CycleGANSingleResult).ImagePath.AbsoluteUri.Split('/').Last().Trim();
            }
            else
            {
                guid = (result as CycleGANBatchResult).FolderPath.AbsoluteUri.Split('/').Last().Trim();
            }

            if (!Guid.TryParse(guid, out Guid id))
            {
                result.Id = GetNewGuid();
            }
            else
            {
                result.Id = id;
            }

            Results.Add(result);
        }
        public void OnPost()
        {
            if (Id == Guid.Empty)
            {
                return;
            }
            ICycleGANresult found = results.Results.FirstOrDefault(r => r.Id == Id);

            if (found == null)
            {
                return;
            }
            results.Results.Remove(found);
            if (found is CycleGANSingleResult)
            {
                Directory.Delete(Uri.UnescapeDataString((found as CycleGANSingleResult).ImagePath.AbsolutePath), true);
            }
            else if (found is CycleGANBatchResult)
            {
                Directory.Delete(Uri.UnescapeDataString((found as CycleGANBatchResult).FolderPath.AbsolutePath), true);
            }
        }