Exemplo n.º 1
0
        public MainWindowViewModel()
        {
            Op = new Operator(this);

            // Add event listeners.
            if (!Designer.IsInDesignMode)             // AddListener source may be null in Design mode.
            {
                _fileListPropertyChangedListener = new PropertyChangedEventListener(FileListPropertyChanged);
                PropertyChangedEventManager.AddListener(FileListCore, _fileListPropertyChangedListener, string.Empty);

                _settingsPropertyChangedListener = new PropertyChangedEventListener(ReactSettingsPropertyChanged);
                PropertyChangedEventManager.AddListener(Settings.Current, _settingsPropertyChangedListener, string.Empty);

                _operatorPropertyChangedListener = new PropertyChangedEventListener(ReactOperatorPropertyChanged);
                PropertyChangedEventManager.AddListener(Op, _operatorPropertyChangedListener, string.Empty);
            }

            // Subscribe event handlers.
            Subscription.Add(Observable.FromEvent
                             (
                                 handler => _currentFrameSizeChanged += handler,
                                 handler => _currentFrameSizeChanged -= handler
                             )
                             .Throttle(TimeSpan.FromMilliseconds(50))
                             .ObserveOn(SynchronizationContext.Current)
                             .Subscribe(_ => SetCurrentImage()));

            Subscription.Add(Observable.FromEvent
                             (
                                 handler => _autoCheckIntervalChanged += handler,
                                 handler => _autoCheckIntervalChanged -= handler
                             )
                             .Throttle(TimeSpan.FromMilliseconds(200))
                             .ObserveOn(SynchronizationContext.Current)
                             .Subscribe(_ => Op.ResetAutoTimer()));

            Subscription.Add(Observable.FromEvent
                             (
                                 handler => _targetConditionChanged += handler,
                                 handler => _targetConditionChanged -= handler
                             )
                             .Throttle(TimeSpan.FromMilliseconds(200))
                             .ObserveOn(SynchronizationContext.Current)
                             .Subscribe(_ =>
            {
                FileListCoreView.Refresh();
                Op.UpdateProgress();
            }));

            Subscription.Add(Observable.FromEventPattern
                             (
                                 handler => Op.ActivateRequested += handler,
                                 handler => Op.ActivateRequested -= handler
                             )
                             .ObserveOn(SynchronizationContext.Current)
                             .Subscribe(_ => ActivateRequested?.Invoke(this, EventArgs.Empty)));

            SetSample(1);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Shows a toast to notify completion of copying.
        /// </summary>
        private async Task ShowToastAsync()
        {
            if (!OsVersion.IsEightOrNewer || (_copyFileCount <= 0) || (DateTime.Now - CopyStartTime < _copyToastShortestDuration))
            {
                return;
            }

            var request = new ToastRequest
            {
                ToastHeadline          = Resources.ToastHeadline_CopyCompleted,
                ToastBody              = Resources.ToastBody_CopyCompleted,
                ToastBodyExtra         = string.Format(Resources.ToastBodyExtra_CopyCompleted, _copyFileCount, (int)(DateTime.Now - CopyStartTime).TotalSeconds),
                ShortcutFileName       = Properties.Settings.Default.ShortcutFileName,
                ShortcutTargetFilePath = Assembly.GetExecutingAssembly().Location,
                AppId = Properties.Settings.Default.AppId
            };

            var result = await ToastManager.ShowAsync(request);

            if (result == ToastResult.Activated)
            {
                ActivateRequested?.Invoke(this, EventArgs.Empty);
            }
        }