Exemplo n.º 1
0
        private async void DataGrid1_OnDrop(object sender, DragEventArgs e)
        {
            _mainWindowViewModel.StatusString = string.Empty;
            if (!(e.Data.GetData(DataFormats.FileDrop) is string[] urls))
            {
                return;
            }
            var oldList = _fileInfos.Select(info => info.GeneralInfo.FullPath).ToList();
            var ret     = await Utils.Load(urls, url => oldList.Contains(url), url => _mainWindowViewModel.StatusString = Path.GetFileName(url));

            _fileInfos.AddItems(ret.info);
            _mainWindowViewModel.StatusString = $"Total time cost: {ret.duration}ms";
        }
Exemplo n.º 2
0
        public IAudioStream CreateAudioStream()
        {
            IAudioStream stream = null;

            if (MultiFile)
            {
                stream = new ConcatenationStream(FileInfos.Select(fi => AudioStreamFactory.FromFileInfoIeee32(fi)).ToArray());
            }
            else
            {
                stream = AudioStreamFactory.FromFileInfoIeee32(FileInfo);
            }
            return(new TimeWarpStream(stream, timeWarps));
        }
Exemplo n.º 3
0
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            ButonsEnable = false;

            var selectedPath       = string.Empty;
            var folderBowserDialog = new FolderBrowserDialog();

            if (folderBowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                selectedPath = folderBowserDialog.SelectedPath;
            }

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            int directionaryCounter = 0;

            await Task.Run(() =>
            {
                FileInfos.Select(x => new
                {
                    x.LastWriteTime.Year,
                    x.LastWriteTime.Month
                }).Distinct().OrderBy(x => x.Month).ToList().ForEach(y =>
                {
                    var filesFromSpecificTimeRange = FileInfos.Where(f => f.CreationTime.Year.Equals(y.Year) && f.CreationTime.Month.Equals(y.Month)).ToList();

                    var createdDirectionary = Directory.CreateDirectory(String.Format(@"{0}\{1:yyyy MMMM}", selectedPath, new DateTime(y.Year, y.Month, 1)));

                    directionaryCounter++;
                    filesFromSpecificTimeRange.ForEach(ftr =>
                    {
                        File.Copy(ftr.FullName, string.Format(@"{0}\{1}", createdDirectionary.FullName, ftr.Name));
                    });
                });
            }).ConfigureAwait(false);

            stopWatch.Stop();
            TimeSpan ts          = stopWatch.Elapsed;
            string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);

            System.Windows.MessageBox.Show(string.Format("Zakończono kopiowanie. Utworzono: {0} katalogów{1} Czas Twania to: {2}", directionaryCounter, Environment.NewLine, elapsedTime), "Info",
                                           MessageBoxButton.OK, MessageBoxImage.Information);

            ButonsEnable = true;
            Process.Start("explorer.exe", selectedPath);
        }
Exemplo n.º 4
0
        protected string GeneratePeakFileName()
        {
            string name = GenerateName();

            if (MultiFile)
            {
                // When the track consists of multiple files, we take the default track name and append a hash
                // value calculated from all files belonging to this track. This results in a short name while
                // avoiding file name collisions when different sets of concatenated files start with the same file (name).
                string concatenatedNames = FileInfos.Select(fi => fi.Name).Aggregate((s1, s2) => s1 + "+" + s2);
                using (var sha = SHA1.Create()) {
                    byte[] hash       = sha.ComputeHash(Encoding.UTF8.GetBytes(concatenatedNames));
                    string hashString = BitConverter.ToString(hash).Replace("-", "").ToLower();

                    // append Git-style shorted hash
                    name += "[" + hashString.Substring(0, 6) + "]";
                }
            }
            return(name);
        }