Example #1
0
        private async void LoadPathWindowsFromSettings()
        {
            var stopwatch = Stopwatch.StartNew();
            await SettingsController.LoadDataDir();

            await DownloadController.CleanUp();

            List <Task> tasks = new List <Task>();

            try
            {
                foreach (var dir in DirectoryController.Dirs)
                {
                    pws.Add(dir.FullPath, new PathWindow(dir.FullPath));
                    var pw = pws[dir.FullPath];
                    WindowsComponents.Children.Add(pw);
                    tasks.Add(PathWindow.SetInfoLabel(pw, dir));
                }

                await Task.WhenAll(tasks);
            }
            catch (Exception ex)
            {
                LoggerController.PrintException(ex);
            }

            stopwatch.Stop();
            Console.WriteLine($"Loading paths from setings finished in {stopwatch.ElapsedMilliseconds}ms");

            Instance = this;
        }
Example #2
0
        public static void Update(PathWindow Component, string fileFullPath, bool increament = true)
        {
            if (Component is null || fileFullPath is null)
            {
                return;
            }

            int  count    = (increament) ? 1 : -1;
            long filesize = new FileInfo(fileFullPath).Length;
            long size     = (increament) ? filesize : -filesize;

            Component.DirSizeLabel.Content       = (int)Component.DirSizeLabel.Content + count;
            Component.DirCountFilesLabel.Content = DirectoryModel.CalcBytes((int)Component.DirCountFilesLabel.Content + size);
        }
Example #3
0
 public static void PrintStatistic(string filepath)
 {
     Console.WriteLine(filepath);
     Instance.Dispatcher.Invoke(new Action(() =>
     {
         try
         {
             var element = (pws[filepath] is null) ? null : pws[filepath];
             PathWindow.Update(element);
         }
         catch (Exception ex)
         {
             LoggerController.PrintException(ex);
         }
     }));
 }
Example #4
0
        /// <summary>
        /// Set Label info about directory
        /// </summary>
        /// <param name="Component">Component to set info</param>
        /// <param name="Directory">Directory assigned to the component</param>
        /// <returns></returns>
        public static async Task SetInfoLabel(PathWindow Component, DirectoryModel Directory)
        {
            if (Component == null || Directory == null)
            {
                return;
            }

            Directory.Files = 0;
            Directory.Size  = 0;

            Component.DirSizeLabel.Content       = "Loading...";
            Component.DirCountFilesLabel.Content = "Loading...";
            Component.pathdialog.Text            = Directory.FullPath;

            await Task.Run(() => Directory.GetAsyncInfo());

            Component.DirSizeLabel.Content       = Directory.Files;
            Component.DirName.Text               = Directory.Name;
            Component.DirCountFilesLabel.Content = DirectoryModel.CalcBytes(Directory.Size);
        }