public bool Execute() { //_index = ((ICollectionView)_collectionView).CurrentPosition; if (_result.FirstFile.Equals(_forSaveInfo)) { _forDeleteInfo = _result.SecondFile; } else if (_result.SecondFile.Equals(_forSaveInfo)) { _forDeleteInfo = _result.FirstFile; } else { throw new ArgumentException("Не знаем что удалять!"); } _pathWithTempExtension = _forDeleteInfo.Path + Const.ForDeleteEXTENSION; File.Move(_forDeleteInfo.Path, _pathWithTempExtension); _resultList.RemoveAt(_index); string res = Application.Current.Resources["desc_deleteOtherFromPair"] as string; _description = String.Format(res, _forSaveInfo.Path); return(true); }
public ImageInfoClass LoadInfo(ImageClass imgHandler) { ImageInfoClass info = new ImageInfoClass(); FileInfo fileInfo = new FileInfo(imgHandler.FilePath); info.Name = fileInfo.Name.Replace(fileInfo.Extension, ""); info.Extension = fileInfo.Extension; string _label13_ori = fileInfo.DirectoryName; if (_label13_ori.Length > 50) { _label13_ori = _label13_ori.Substring(0, 10) + "..." + _label13_ori.Substring(_label13_ori.LastIndexOf("\\")); } info.Directory = _label13_ori; info.Dimension = (int)imgHandler.Image.Width + "x" + (int)imgHandler.Image.Height; info.Size = (fileInfo.Length / 1024.0).ToString("0.0") + "KB"; info.CreateOn = fileInfo.CreationTime.ToString("dddd MMMM, yyyy"); if (imgHandler.Image.Width > imgHandler.Image.Height) { info.GlobalScale = 340 / (float)imgHandler.Image.Height; } else { info.GlobalScale = 340 / (float)imgHandler.Image.Width; } return(info); }
public bool Execute() { GroupHelper.ConvertToGroup(_groups, _resultsForDeleteCopy); foreach (DuplicateGroup group in _groups) { ImageInfoClass bestImageInfo = GetBestImage(group); foreach (var image in group.FileList) { if (!image.Equals(bestImageInfo)) { Rename(image); } } } foreach (var item in _resultsForDeleteCopy) { _sourceResultList.Remove(item); } string res = Application.Current.Resources["desc_deleteFiles"] as string; _description = String.Format(res, _renamedFiles.Count); return(true); }
public DeleteOtherFromPairCommand(ImageInfoClass currentInfo, DuplPairViewModel result, ObservableCollection <DuplPairViewModel> resultList, IEditableCollectionView collectionView, int index) { _forSaveInfo = currentInfo; _result = result; _resultList = resultList; _collectionView = collectionView; _index = index; }
public DeleteOtherFromGroupCommand(ImageInfoClass currentInfo, ObservableCollection <DuplicateGroup> groups, ICollectionView groupsView) { _forSaveInfo = currentInfo; _groups = groups; _groupsView = groupsView; _forDeleteList = new List <RenamedImage>(); }
private ImageInfoClass LoadInfo2(ImageClass im) { ImageInfoClass info = new ImageInfoClass(); info.Name = "TEST NAME"; info.Extension = "TEST NAME2"; info.Directory = "TEST NAME3"; info.Dimension = "TEST NAME4"; info.Size = "TEST NAME5"; info.CreateOn = "TEST NAME6"; return(info); }
private void Rename(ImageInfoClass image) { if (File.Exists(image.Path)) { Renamed renamed = new Renamed(); renamed.ImageInfo = image; renamed.PathWithTempExtension = image.Path + Const.ForDeleteEXTENSION; _renamedFiles.Add(renamed); //IsFileLocked(renamed.ImageInfo.Path); File.Move(image.Path, renamed.PathWithTempExtension); } }
private static string GetText(bool showFullPath, ImageInfoClass imageInfoClass) { if (imageInfoClass != null) { if (showFullPath) { return(imageInfoClass.Path); } else { return(System.IO.Path.GetFileName(imageInfoClass.Path)); } } return(""); }
/*public void StartReader() * { * myThread = new Thread(Read); * myThread.Name = "Читатель 1"; * myThread.Start(); * * Thread myThread2 = new Thread(Read); * myThread2.Name = "Читатель 2"; * myThread2.Start(); * * Thread myThread3 = new Thread(Read); * myThread3.Name = "Читатель 3"; * myThread3.Start(); * } * * public void Read() * { * while (count > 0) * { * sem.WaitOne(); * * Debug.WriteLine("{0} входит в библиотеку", Thread.CurrentThread.Name); * * Debug.WriteLine("{0} читает", Thread.CurrentThread.Name); * Thread.Sleep(1000); * * Debug.WriteLine("{0} покидает библиотеку", Thread.CurrentThread.Name); * * sem.Release(); * * count--; * Thread.Sleep(1000); * } * }*/ /// <summary> /// добавляем элемент /// </summary> /// <param name="path"></param> public void Enqueue(ImageInfoClass item) { lock (_queue) { //if (!_queue.Any(i => i.Path == item.Path)) //{ //Debug.WriteLine("Ставим в очередь " + item.Path); _queue.Enqueue(item); //_queue.Push(item); //} //else // Debug.WriteLine("В очереди на эскиз уже есть " + item.Path); } wh.Set(); }
private ImageInfoClass GetBestImage(DuplicateGroup group) { ImageInfoClass bestImageInfo = null; foreach (var image in group.FileList) { if (bestImageInfo == null) { bestImageInfo = image; continue; } if (image.UtilityIndex > bestImageInfo.UtilityIndex) { bestImageInfo = image; } } return(bestImageInfo); }
public DuplPairViewModel(Core.CoreDll.adResultW a) { FirstFile = new ImageInfoClass(); SecondFile = new ImageInfoClass(); FolderAreDiffrent = false; FirstFile.Path = a.first.path; FirstFile.JpegQuality = a.first.blockiness; FirstFile.Sharpness = a.first.blurring; FirstFile.FileSize = a.first.size; FirstFile.Width = a.first.width; FirstFile.Height = a.first.height; SecondFile.Path = a.second.path; SecondFile.JpegQuality = a.second.blockiness; SecondFile.Sharpness = a.second.blurring; SecondFile.FileSize = a.second.size; SecondFile.Width = a.second.width; SecondFile.Height = a.second.height; //SaatiHelper.CalculateIndex(this, _configuration); //FillFolderAreDiffrent(); //SetNeighboursFileNames(); }
public ImageInfoViewModel() { Console.WriteLine("Jump to constructor 1"); ImgInfoClass = LoadInfo2(_imgHandler); }
private void ThumbnailLoader() { while (true) { ImageInfoClass task = null; lock (_queue) { if (_queue.Count > 0) { task = _queue.Dequeue(); //task = _queue.Pop(); if (task == null) { return; } } } if (task != null) { if (!_thumbnailCache.HasThumbnail(task.Path)) { //Debug.WriteLine("В кеше нет эскиза для " + task.Path); try { if (File.Exists(task.Path)) { Debug.WriteLine(String.Format("ThumbnailProvider load {0}", task.Path)); using (Stream stream = File.OpenRead(task.Path)) { var image = new BitmapImage(); image.BeginInit(); image.CreateOptions = BitmapCreateOptions.IgnoreColorProfile; image.CacheOption = BitmapCacheOption.OnLoad; //image.DecodePixelWidth = Const.IMAGE_WIDTH; image.DecodePixelWidth = _configuration.ThumbnailWidth; //image.DecodePixelHeight = Const.IMAGE_HEIGHT; image.StreamSource = stream; image.EndInit(); image.Freeze(); GC.Collect(GC.MaxGeneration); //Debug.WriteLine("Добавляем в кеше эскиз для " + task.Path); _thumbnailCache.AddThumbnail(task.Path, image); Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (Action) delegate { task.Image = image; }); } Debug.WriteLine(String.Format("ThumbnailProvider loaded {0}", task.Path)); } } catch (NotSupportedException nsex) { Console.WriteLine(nsex.Message); } } else { //Debug.WriteLine("В кеше есть эскиз для " + task.Path); var image = _thumbnailCache.GetThumbnail(task.Path); Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (Action) delegate { task.Image = image; }); } //Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, // (Action)delegate // { lock (_queue) { ThumbnailCacheStatus = string.Format("Thumbnail Cached {0}/{1}, queue {2}", _thumbnailCache.Cached, _configuration.MaxCachedThumbnail, _queue.Count); // }); } } else { wh.WaitOne(); // Больше задач нет, ждем сигнала... } } }
public RenameImageCommand(ImageInfoClass iic, string newPath) { _imageInfo = iic; _newPath = newPath; }
public ImageInfoViewModel(ImageClass im) { Console.WriteLine("Jump to constructor 2"); ImgHandler = im; ImgInfoClass = LoadInfo(_imgHandler); }
public JsonOCRClass(ImageClass inp, ImageInfoClass inf, Dictionary <SolidColorBrush, List <Rectangle> > reg) { jsonInput = inp; jsonInfo = inf; jsonOutputRegion = reg; }
public RenamedImage(ImageInfoClass item) { ImageInfo = item; PathWithTempExtension = item.Path + Const.ForDeleteEXTENSION; }