/// <summary> /// 指定されたファイルについて検査 /// </summary> /// <param name="files"></param> /// <param name="relatedFiles"></param> /// <param name="prospectedTags"></param> /// <returns></returns> public async Task <bool> CheckFolderUpdateAsync( string[] files, PropertiesLevel level, IReadOnlyDictionary <string, Record> relatedFiles, ConcurrentDictionary <string, ConcurrentBag <TagManager> > prospectedTags) { var folder = this.Config.GetFolderContainer(this.Path); var count = await folder.EnumerateFilesAsync (files, default(CancellationToken), false); var options = new LoadingOptions() { LightMode = true, ContainsChildren = false, Level = level,// PropertiesLevel.Basic, }; this.FileEnumerated?.Invoke(0); this.FileLoaded?.Invoke(0); await this.DoForAllFilesAsync(folder, options, relatedFiles, prospectedTags); var detected = new HashSet <string>(this.DetectedFiles); this.RemovedFiles = relatedFiles .AsParallel() .Where(x => !detected.Contains(x.Key)) .ToDictionary(x => x.Key, x => x.Value); return(true); }
private void Loading() { LoadingOptions loadingOptions = new LoadingOptions(); loadingOptions.ShowLoader = true; Chameleon.ShowLoading(loadingOptions); }
public static void DisplayLoadingWindow(LoadingOptions loadingOption, Func <int> progress, Func <int> total, string generalMessage) { Console.WriteLine(generalMessage); int maxBarSpace = 22; int barLenth = 4; CyclingBar cyclingBar = new CyclingBar(barLenth, maxBarSpace); SideToSideBar sideToSideBar = new SideToSideBar(barLenth, maxBarSpace); int maxDots = 8; int dotCount = 0; Console.CursorVisible = false; while (progress() < total()) { Console.CursorLeft = 0; Console.Write(progress() + "/" + total()); Console.CursorLeft += 2; if (loadingOption == LoadingOptions.CyclingBar) { cyclingBar.MoveBar(); } else if (loadingOption == LoadingOptions.SideToSideBar) { sideToSideBar.MoveBar(); } else if (loadingOption == LoadingOptions.Dots) { Thread.Sleep(200); Console.Write(new string('.', dotCount) + new string(' ', maxDots - dotCount)); dotCount = dotCount > maxDots - 1 ? 0 : dotCount + 1; } } Console.CursorLeft = 0; Console.Write(progress() + "/" + total()); Console.ForegroundColor = ConsoleColor.Green; Console.Write(" ---> DONE" + new string(' ', Math.Max(maxDots, maxBarSpace))); Thread.Sleep(1500); }
/// <summary> /// フォルダ内の全ファイルに対して処理 /// </summary> /// <param name="folder"></param> /// <param name="options"></param> /// <param name="library"></param> /// <param name="prospectedTags"></param> /// <returns></returns> private Task <IEnumerable <bool> > DoForAllFilesAsync( IFolderContainer folder, LoadingOptions options, IReadOnlyDictionary <string, Record> library, ConcurrentDictionary <string, ConcurrentBag <TagManager> > prospectedTags) { var loadCount = 0; return(folder.DoForAllFilesAsync(path => { if (options.LightMode && library.ContainsKey(path)) { this.DetectedFiles.Add(path); } else { this.CheckImage(folder.GetImage(path, options.Level), library, prospectedTags); } this.FileLoaded?.Invoke(++loadCount); return true; })); }
/// <summary> /// フォルダ内のファイルを列挙 /// </summary> /// <param name="information"></param> /// <param name="relatedFiles"></param> /// <param name="completely"></param> /// <param name="level"></param> /// <param name="prospectedTags"></param> /// <returns></returns> public async Task <bool> ListupFilesAsync(FolderInformation information, IReadOnlyDictionary <string, Record> relatedFiles, bool completely, PropertiesLevel level, ConcurrentDictionary <string, ConcurrentBag <TagManager> > prospectedTags) { this.Path = PathUtility.WithPostSeparator(information.Path); this.TopPath = this.Path; var exists = await this.Config.IsFolderExistsAsync(information); //フォルダ取得に失敗 if (!exists) { this.RemovedFiles = relatedFiles.ToDictionary(x => x.Key, x => x.Value); information.RefreshEnable = false; return(false); } //ファイル検索オプション var options = new LoadingOptions() { LightMode = (information.Mode == FolderCheckMode.Light) ? true : (information.Mode == FolderCheckMode.Detail) ? false : !completely, ContainsChildren = !information.IsTopDirectoryOnly, Level = level,//PropertiesLevel.Basic, }; this.ChildFolderLoaded?.Invoke(this.Path); this.FileEnumerated?.Invoke(0); this.FileLoaded?.Invoke(0); var folder = this.Config.GetFolderContainer(this.Path); var count = await folder.EnumerateFilesAsync (x => this.FileEnumerated?.Invoke(x), options.ContainsChildren, default(CancellationToken), false); await this.DoForAllFilesAsync(folder, options, relatedFiles, prospectedTags); this.FileLoaded?.Invoke((int)count); //旧ライブラリに存在するのに検査して見つからなかったファイルを //削除された(可能性のある)ファイルとしてリストアップしておく var detected = new HashSet <string>(this.DetectedFiles); this.RemovedFiles = relatedFiles .AsParallel() .Where(x => !detected.Contains(x.Key)) .ToDictionary(x => x.Key, x => x.Value); information.RefreshEnable = false; return(true); }
public GLTexture(Bitmap Image, MemoryLocation StackOrHeap, params DuringLoad[] LoadingOptions) { StackOrHeap = MemoryLocation.Heap; if (Image == null) { throw new ArgumentNullException(); } byte[] SourceArray = GetBytesFromBitmap(Image, out stride, out Width, out Height); size = SourceArray.Length; WidthStride = stride * Width; int readstride = stride; if (SourceArray.Length != Width * Height * stride) { throw new Exception("uhhh this exception should not trigger"); } if (SourceArray.Length % stride != 0) { throw new Exception("uhhh this exception should not trigger"); } int allocSize = SourceArray.Length; bool copyAlpha = LoadingOptions.Contains(DuringLoad.CopyAlpha); if (copyAlpha & stride == 3) { throw new Exception("Cannot copy alpha for a 24bpp image"); } if (stride != 3 & stride != 4) { throw new Exception("Only 24bpp or 32bpp images are supported!"); } if (LoadingOptions.Contains(DuringLoad.ConvertTo32bpp)) { allocSize = Width * Height * 4; stride = 4; WidthStride = Width * stride; } if (StackOrHeap == MemoryLocation.Heap) { STORED_ON_STACK = false; HEAP_ptr = Marshal.AllocHGlobal(allocSize); ptr = (byte *)HEAP_ptr; } else { STORED_ON_STACK = true; T = new Thread(() => ThreadMethod(out ptr, allocSize), allocSize + 1000); T.Start(); while (ptr == null) { Thread.Sleep(10); } } if (LoadingOptions.Contains(DuringLoad.Flip)) { for (int w = 0; w < Width; w++) { for (int h = 0; h < Height; h++) { ptr[h * WidthStride + w * stride] = SourceArray[((Height - 1) - h) * WidthStride + w * stride]; ptr[h * WidthStride + w * stride + 1] = SourceArray[((Height - 1) - h) * WidthStride + w * stride + 1]; ptr[h * WidthStride + w * stride + 2] = SourceArray[((Height - 1) - h) * WidthStride + w * stride + 2]; if (copyAlpha) { ptr[h * WidthStride + w * stride + 3] = SourceArray[((Height - 1) - h) * WidthStride + w * stride + 3]; } } } } else { for (int i = 0; i < Width * Height; i++) { ptr[i * stride] = SourceArray[i * readstride]; ptr[i * stride + 1] = SourceArray[i * readstride + 1]; ptr[i * stride + 2] = SourceArray[i * readstride + 2]; if (copyAlpha) { ptr[i * stride + 3] = SourceArray[i * readstride + 3]; } } } }