AcManager.Controls.Helpers.FancyBackgroundManager.UpdateBackground C# (CSharp) Метод

UpdateBackground() публичный статический Метод

public static UpdateBackground ( FrameworkElement anyElement, object &backgroundContent ) : void
anyElement System.Windows.FrameworkElement
backgroundContent object
Результат void
        public static void UpdateBackground(FrameworkElement anyElement, ref object backgroundContent) {
            if (!Instance.Enabled) {
                backgroundContent = ((FrameworkElement)backgroundContent)?.Tag ?? backgroundContent;
                return;
            }

            var rectangle = backgroundContent as Rectangle;
            var visualBrush = rectangle?.Fill as VisualBrush;

            if (visualBrush == null) {
                visualBrush = (VisualBrush)anyElement.FindResource(@"FancyBackgroundBrush");
                rectangle = new Rectangle {
                    Fill = visualBrush,
                    Tag = backgroundContent
                };

                backgroundContent = rectangle;
            }

            var frameworkElement = (FrameworkElement)visualBrush.Visual;
            var backgroundImage0 = (Image)LogicalTreeHelper.FindLogicalNode(frameworkElement, @"BackgroundImage0");
            var backgroundImage1 = (Image)LogicalTreeHelper.FindLogicalNode(frameworkElement, @"BackgroundImage1");
            if (backgroundImage0 == null || backgroundImage1 == null) return;

            var state = frameworkElement.Tag as int? ?? 0;
            (state == 0 ? backgroundImage1 : backgroundImage0).Source = UriToCachedImageConverter.Convert(Instance.BackgroundFilename);
            VisualStateManager.GoToElementState(backgroundImage1, @"State" + state, true);
            frameworkElement.Tag = 1 - state;
        }
    }