Beispiel #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - Width,
                                 Screen.PrimaryScreen.WorkingArea.Height - Height);
            LogTextBox = logTextBox;
            _logger    = new Logger(this);
            _logger.LogC($"版本 {Version}, 由 Nutr1t07 (Nelson Xiao) 制作");

            _cfg            = Config.ParseConfig("WBAData\\config.txt", _logger);
            _infos          = new List <UsbInfo>(UsbInfo.ReadBasicInfos());
            _copier         = new Copier(_logger, ref _cfg, ref _infos);
            _autoPlay       = new AutoPlay(_logger);
            _desktopArrange = new DesktopArrange(_copier, _logger);
            _wallpaper      = new WallpaperMain(_logger, _copier);
            _recentFiles    = new List <FileWatcher.RecentFile>(FileWatcher.RecentFile.ReadRecentFiles());
            _fileWatcher    = new FileWatcher(_copier, _cfg, _logger, _recentFiles);
            _fileWatcher.RecentFileAdded += FileWatcherOnRecentFileAdded;
            _keyboardDetect = new KeyboardDetect(_cfg, _logger);


            if (!Directory.Exists("WBAData"))
            {
                Directory.CreateDirectory("WBAData");
                Directory.CreateDirectory("WBAData\\log");
            }

            if (_cfg.RefreshWallpaper)
            {
                Task.Factory.StartNew(() => _wallpaper.PickWallIfTimePermit());
            }
            if (_cfg.AutoPlayFtp)
            {
                Task.Factory.StartNew(() => new AutoPlay(_logger).CheckFtp(this));
            }
            if (_cfg.AutoPlayEnAudio)
            {
                Task.Factory.StartNew(() =>
                                      AutoPlay.CheckEnglishAudio(_cfg.AutoPlayEnAudioUnit, _cfg.AutoPlayEnAudioFileName));
            }

            Task.Factory.StartNew(() => _copier.StartCopierListen());
            Task.Factory.StartNew(() => _fileWatcher.Listen());
            _keyboardDetect.StartHook();

            InitialConfigPage();
            RefreshUsbInfos();
            InitRecentFileListViewUi();

            _copier.UsbChange += (insert, info) => RefreshUsbInfos();
        }