/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Creates and initializes a new instance of the <c>ProgressTracker</c> class. /// </summary> /// <param name="parentPage">Parent page for status panel.</param> /// <param name="type">Import objects type.</param> /// <param name="canceler">Operation canceler interface (can be NULL).</param> public ProgressInformer(AppPages.Page parentPage, ImportType type, ICanceler canceler) { Debug.Assert(null != parentPage); // created // store context _parentPage = parentPage; _canceler = canceler; // initialize state _InitStrings(type); _InitStatusStack(); }
public MacroPanelViewModel(IMacroService macro, IMacroPool pool, ICanceler canceler, IWorkSituation work, ISwitchClock clock, ISerialPortService serialPort, ICancellationRequest cancelRequest, IGameCapture gameCapture) { m_macro = macro; m_macroCanceler = canceler; m_macroPool = pool; IsConnected = serialPort.ObserveProperty(p => p.IsOpen).ToReactiveProperty().AddTo(Disposables); IsBusy = work.ObserveProperty(w => w.IsBusy).ToReactiveProperty().AddTo(Disposables); Clock = clock.ToReactivePropertyAsSynchronized(m => m.DateTime).AddTo(Disposables); Clock.Value = DateTime.Now; DrawLotoIdCommand = CreateExecuteMacroCommand <DrawLotoIdMacro>(); GainWattsCommand = CreateExecuteMacroCommand <GainWattsMacro>(); BattleMaxRaidCommand = CreateExecuteMacroCommand <BattleMaxRaidMacro>(); //SeekPokemonCommand = CreateExecuteMacroCommand<SeekPokemonMacro>(); RapidTimeTravelCommand = CreateExecuteMacroCommand <RapidTimeTravelMacro>(); RapidTimeTravelDays = clock.ToReactivePropertyAsSynchronized(m => m.DaysCount).AddTo(Disposables); RapidTimeTravelDays.Value = 0; ThreeDaysTravelCommand = CreateExecuteMacroCommand <ThreeDaysTravelMacro>(); CanGoNextThreeDays = (m_macroPool.Get <ThreeDaysTravelMacro>() as ThreeDaysTravelMacro).ObserveProperty(m => m.CanGoNext).ToReactiveProperty().AddTo(Disposables); ThreeDaysTravelNextCommand = CanGoNextThreeDays.ToReactiveCommand().AddTo(Disposables); ThreeDaysTravelNextCommand.Subscribe(() => { using (var wait = new EventWaitHandle(false, EventResetMode.ManualReset, "WAIT_NEXT_3_DAYS")) { wait.Set(); } }); MashAButtonCommand = CreateExecuteMacroCommand <MashAButtonMacro>(); IsCanceling = cancelRequest.ObserveProperty(c => c.IsCancellationRequested).ToReactiveProperty().AddTo(Disposables); CancelCommand = new[] { IsBusy, IsCanceling }.CombineLatest(x => x[0] && !x[1]).ToReactiveCommand().AddTo(Disposables); CancelCommand.Subscribe(m_macroCanceler.Cancel); SaveImageCommand = new ReactiveCommand().AddTo(Disposables); SaveImageCommand.Subscribe(() => gameCapture.SaveFrame(null)); }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Deletes created cursors. /// </summary> public void Dispose() { _buttonCancel.Click -= _ButtonCancel_Click; _statusPanel = null; _statusLabel = null; _buttonCancel = null; _statusPanel = null; _canceler = null; }