Exemplo n.º 1
0
        public MainViewModel(ITypographService serivce, ISettings settings)
        {
            _service = serivce;
            Settings = settings;
            _dispatcher = Dispatcher.CurrentDispatcher;

            ShowSettingsFlyout = new RelayCommand(() =>
            {
                _dispatcher.Invoke(() => IsSettingsFlyoutOpen = true);
            });

            Typographify = new RelayCommand(() =>
            {
                _dispatcher.Invoke(() => IsWorking = true);

                _service.Typographify(Text, (result, error) =>
                {
                    if (error != null)
                        _HandleException(error);

                    if (result != null)
                        _dispatcher.Invoke(() => Text = result);

                    _dispatcher.Invoke(() => IsWorking = false);
                });
            }
            , () => !string.IsNullOrWhiteSpace(Text) && !IsWorking);
        }