Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="worker"></param>
        /// <param name="optionSettings"></param>
        /// <param name="windowManager"></param>
        public MainViewModel(LongProcessWorker worker, OptionSettings optionSettings, IWindowManager windowManager)
        {
            this.worker = worker;
            this.optionSettings = optionSettings;
            Log = new ObservableCollection<LogEntry>();
            WindowManager = windowManager;

            Disposables.Add(Observable
                .FromEvent<EventHandler<LogEventArgs>, LogEventArgs>(h => (s, e) => h(e), h => worker.Logged += h, h => worker.Logged -= h)
                .ObserveOnDispatcher()
                .Subscribe(e => Log.Add(new LogEntry(e.DateTime, e.LogType, e.Message))));
            Disposables.Add(Observable
                .FromEvent<EventHandler<EventArgs>, EventArgs>(h => (s, e) => h(e), h => worker.ExecutingChanged += h, h => worker.ExecutingChanged -= h)
                .ObserveOnDispatcher()
                .Subscribe(e => Running = worker.Executing));
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="optionSettings"></param>
 public OptionViewModel(OptionSettings optionSettings)
 {
     OptionSettings = optionSettings;
 }