Example #1
0
        public MainWindowModel(
            ISelectExecuteFileService selectExecuteFileService,
            IShortcutService shortcutService,
            IDialogService dialogService,
            IOpenExolorerService openExolorerService)
        {
            _selectExecuteFileService = selectExecuteFileService;
            _shortcutService          = shortcutService;
            _dialogService            = dialogService;
            _openExolorerService      = openExolorerService;

            _wathcer = new FileSystemWatcher(StartupPath, "*.*")
            {
                EnableRaisingEvents = true
            };
            StartupShortcuts = new[]
            {
                _wathcer.CreatedAsObservable(),
                    _wathcer.ChangedAsObservable(),
                    _wathcer.DeletedAsObservable(),
                    _wathcer.RenamedAsObservable()
            }
            .Merge()
            .Select(_ => GetStartupShorcuts())
            .ToReadOnlyReactivePropertySlim(GetStartupShorcuts());
        }
Example #2
0
        private static async Task Main()
        {
            var conf = ReadConfig.Instance.Config;

            using (var pool = new BartenderPool(conf.BtwFilePath, conf.ProcessRefreshInterval))
            {
                var datafiles = Directory.GetFiles(conf.ScanFolder, conf.FileMatchPattern, SearchOption.TopDirectoryOnly);

                if (datafiles.Any())
                {
                    foreach (var item in datafiles)
                    {
                        await pool.Print(item);

                        File.Delete(item);
                    }
                }

                var watcher = new FileSystemWatcher()
                {
                    Path         = conf.ScanFolder,
                    Filter       = conf.FileMatchPattern,
                    NotifyFilter = NotifyFilters.FileName
                };

                watcher.CreatedAsObservable()
                .Subscribe(async x =>
                {
                    var textFiles = Directory.GetFiles(conf.ScanFolder, conf.FileMatchPattern, SearchOption.TopDirectoryOnly)
                                    .OrderBy(File.GetLastWriteTimeUtc).ToArray();

                    foreach (var item in textFiles)
                    {
                        await pool.Print(item);
                        File.Delete(item);
                    }
                });

                // 監視開始
                watcher.EnableRaisingEvents = true;

                // 待ち
                Console.ReadLine();
                watcher.Dispose();
            }
        }