private void Main_Load(object sender, EventArgs e) { //Initialize the GUI driveSelectionBox.Items.AddRange(allDrives); quickSearchCheckBox.Checked = true; //Load the signature library DriveScanner = new DriveScanner(); int loadResult = DriveScanner.LoadSignatureLibrary(Application.StartupPath + "\\signatures.xml"); if(loadResult != 0) { switch (loadResult) { case 1: MessageBox.Show("Signature library file not found. Application will now quit."); break; case 2: MessageBox.Show("Invalid signature library file detected. Application will now quit."); break; case 3: MessageBox.Show("Error while processing the signature library. Application will now quit."); break; } Application.Exit(); } }
private async void SetDrive(object sender, RoutedEventArgs e) { var info = (DriveInfo)((Button)(sender)).DataContext; _scanner = new DriveScanner(); Progress.Text = "0"; Ready.Visibility = Visibility.Hidden; Processing.Visibility = Visibility.Visible; ItemsControl.IsEnabled = false; _refresher.Start(); await Task.Run(() => { App.Current.Context.StatisticsRoot = _scanner.ScanDrive(info.Name.Substring(0, 2)); App.Current.Context.Problematic.Clear(); App.Current.Context.Problematic.AddRange(_scanner.Inaccessible); }); _refresher.Stop(); ItemsControl.IsEnabled = true; Processing.Visibility = Visibility.Hidden; Ready.Visibility = Visibility.Visible; }
private void cmdScan_Click(object sender, EventArgs e) { if (driveScanner == null || !driveScanner.Scanning) { string dir = ""; using (var fbd = new FolderBrowserDialog()) { DialogResult result = fbd.ShowDialog(); if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath)) { dir = fbd.SelectedPath; } } driveScanner = new DriveScanner(dir); driveScanner.onPercChanged += onScanPercChanged; driveScanner.onScanComplete += onScanComplete; driveScanner.scan(true); cmdScan.Text = "Scanning..\r\n(" + Math.Round(driveScanner.CompletePercentage, 2) + "%)\r\n[Cancel]"; } else { driveScanner.cancelScan(); cmdScan.Text = "Scan"; } }
private async void LoadDrive(ToolStripItem sender) { var target = sender.Text.Substring(0, 2); _scanner = new DriveScanner(); toolStrip1.Enabled = false; timer1.Start(); var root = await Task.Run(() => _scanner.ScanDrive(target)); listBox1.Items.Clear(); listBox1.Items.AddRange(_scanner.Inaccessible.Cast <object>().ToArray()); _totals.Clear(); chart1.BeginInit(); chart1.ChartAreas.Clear(); chart1.Series.Clear(); label2.Text = Humanize.Size(root.Items[1].Size); var percent = 0.0025f * toolStripComboBox2.SelectedIndex; if (toolStripComboBox1.SelectedIndex == 1) { root.Items.RemoveRange(0, 2); _filterThreshold = _scanner.GetDisplayThreshold(percent, false); } else { _filterThreshold = _scanner.GetDisplayThreshold(percent, true); } LoadChartDataCollection(0, root, 0); AlignDoughnuts(); chart1.EndInit(); timer1.Stop(); toolStripProgressBar1.Value = 0; toolStripLabel2.Text = string.Empty; toolStrip1.Enabled = true; }
static void Main() { var scanner = new DriveScanner(); FsItem root; var worker = new Thread(() => root = scanner.ScanDirectory("Z:\\Backup\\Mike", CancellationToken.None)); var s = System.Diagnostics.Stopwatch.StartNew(); worker.Start(); while (worker.IsAlive) { Console.WriteLine($"Current: {scanner.CurrentScanned}"); Thread.Sleep(100); } s.Stop(); Console.WriteLine($"Elapsed: {s.ElapsedMilliseconds / 1000.0} seconds."); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
public MainForm(bool devMode) { this.mp = new MusicPlayer.MusicPlayer(); this.loop = false; this.musicTrackbarScrolling = false; this.Running = true; this.lastMouseX = 0; trackNameToPathIndices = null; InitializeComponent(); this.FormBorderStyle = FormBorderStyle.FixedSingle; this.MaximizeBox = false; if (!devMode) { cmdShowGrapher.Hide(); cmdToggleMatcher.Hide(); cmdSaveCsv.Hide(); cmdViewDB.Hide(); } onPlayingChange += playingChanged; onSongComplete += songComplete; AutoPick = true; seekLabel.Text = ""; txtMusicProgress.Text = ""; updateMusicTrackbarThread = new Thread(new ThreadStart(updateMusicTrackbar)); grapherForm = new Grapher(this); vm = new VolumeMixer(); vm.OnPeakChanged += onPeakChanged; loweredVolume = false; dbAdapter = new DatabaseAdapter(ConfigurationManager.ConnectionStrings["GamingMusicPlayer.Properties.Settings.SongsDBConnectionString"].ConnectionString); matcherForm = new SongMatcher(this, dbAdapter); settingsForm = new SettingsForm(this); overlayForm = new OverlayForm(this, 200, 0); driveScanner = null; ToolTip vpToggleTooltip = new ToolTip(); vpToggleTooltip.ToolTipIcon = ToolTipIcon.None; vpToggleTooltip.IsBalloon = true; vpToggleTooltip.ShowAlways = true; vpToggleTooltip.AutoPopDelay = 20000; vpToggleTooltip.SetToolTip(cmdVp, "Voice Prioritization Feature"); ToolTip songMatchToggleTooltip = new ToolTip(); songMatchToggleTooltip.ToolTipIcon = ToolTipIcon.None; songMatchToggleTooltip.IsBalloon = true; songMatchToggleTooltip.ShowAlways = true; songMatchToggleTooltip.AutoPopDelay = 20000; songMatchToggleTooltip.SetToolTip(cmdSongMatchToggle, "Automatic Song Matching Feature"); dbListBox.SelectionMode = SelectionMode.MultiExtended; songsToAdd = new List <Track>(); addSongsToDbThread = new Thread(delegate() { SignalProcessing.SignalProcessor sp = new SignalProcessing.SignalProcessor(); while (true) { int c = 0; lock (songsToAdd) { c = songsToAdd.Count; } while (c > 0) { Track t = songsToAdd[0]; sp.ComputeBPM(t.Data, (t.Length / 1000), false, false); t.BPM = sp.BPM; sp.computeTimbre(t.Data, t.Length / 1000, false); t.ZCR = sp.ZCR; t.SpectralIrregularity = sp.SpectralIrregularity; lock (dbAdapter) { dbAdapter.addTrack(t); } updateSettings(true); sp.clearMemory(); lock (songsToAdd) { songsToAdd.RemoveAt(0); c = songsToAdd.Count; } matcherForm.updateTrackList(mp.LoadedPlaylist.TrackList); } Thread.Sleep(1000); } }); addSongsToDbThread.Start(); }