Ejemplo n.º 1
0
 private async void CmdLife_LifeChanged(object sender, LifeChangedEventArgs e)
 {
     if (!Dispatcher.HasThreadAccess)
     {
         await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { CmdLife_LifeChanged(sender, e); });
     }
     else
     {
         await LifeControl.UpdateLifeTotalAsync(e.Lifechanged *-1);
     }
 }
Ejemplo n.º 2
0
        private async void LifeControl_LifeChanged(object sender, LifeChangedEventArgs e)
        {
            if (!Dispatcher.HasThreadAccess)
            {
                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { LifeControl_LifeChanged(sender, e); });
            }
            else
            {
                if (viewModel.CounterType != CustomCounterType.LifeHistory)
                {
                    _cancelToken?.Cancel();
                    btnCounterType.Visibility = Visibility.Visible;
                    btnCounterType.Opacity    = 1.0;
                    // imgCountertype.Source = new BitmapImage();
                    _lastCounterType      = viewModel.CounterType;
                    viewModel.CounterType = CustomCounterType.LifeHistory;
                }

                if (e.Lifechanged == int.MinValue)
                {
                    _cancelToken?.Cancel();

                    btnCounterType.Visibility = Visibility.Visible;
                    btnCounterType.Opacity    = 1.0;

                    viewModel.CounterType = _lastCounterType;
                    _cancelToken          = new System.Threading.CancellationTokenSource();

                    FadeOut(btnCounterType, _cancelToken.Token);
                    //btnCounterType.Visibility = Visibility.Collapsed;

                    //imgCountertype.Source = new BitmapImage(new Uri("ms-appx:///" + CounterTypeHelper.CounterTypeImage(viewModel.CounterType)));
                }

                _LifeHistory = e.Lifechanged;

                UpdateCustomType();
            }
        }