Пример #1
0
        private void OnAilmentUpdate(object source, PlayerAilmentEventArgs args)
        {
            if (ConstantAilment == null)
            {
                // Minimalistic widget might not have it
                return;
            }
            Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(() =>
            {
                if (args.AilmentType == PlayerAilment.None)
                {
                    ConstantAilment.Icon       = null;
                    ConstantAilment.Visibility = Visibility.Collapsed;
                    return;
                }
                else
                {
                    ConstantAilment.Visibility = Visibility.Visible;
                    ImageSource icon           = TryFindResource($"ICON_{args.AilmentType.ToString().ToUpperInvariant()}") as ImageSource;
                    ConstantAilment.Icon       = icon;
                }

                ConstantAilment.TimerEndAngle = Arc.ConvertPercentageIntoAngle(args.AilmentTimer / Math.Max(1, args.AilmentMaxTimer));
            }));
        }
Пример #2
0
        private void CompositionTarget_Rendering(object sender, System.EventArgs e)
        {
            // no update needed
            if (!this.WidgetHasContent)
            {
                return;
            }

            // update timer
            var elapsed = this.sw.ElapsedMilliseconds;

            TimerArc.EndAngle = Arc.ConvertPercentageIntoAngle(1 - elapsed / (float)timeout);

            // update text if needed
            if (!isChanged)
            {
                return;
            }
            this.isChanged = false;
            DamageText     = damage.ToString();
        }