public static void Apply(IntPtr windowHandle, BackgroundEffect effect) { var accent = new AccentPolicy(); int accentStructSize = Marshal.SizeOf(accent); accent.AccentState = effect switch { BackgroundEffect.SolidColor => AccentState.ACCENT_ENABLE_TRANSPARENTGRADIENT, BackgroundEffect.BlurBehind => AccentState.ACCENT_ENABLE_BLURBEHIND, BackgroundEffect.AcrylicMaterial => AccentState.ACCENT_ENABLE_ACRYLICBLURBEHIND, _ => AccentState.ACCENT_ENABLE_BLURBEHIND, }; //accent.AccentFlags = 0x20 | 0x40 | 0x80 | 0x100; //accent.GradientColor = 0x99FFFFFF; accent.GradientColor = 0x018B8B8B; var accentPtr = Marshal.AllocHGlobal(accentStructSize); Marshal.StructureToPtr(accent, accentPtr, false); var data = new WindowCompositionAttributeData { Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY, SizeOfData = accentStructSize, Data = accentPtr }; SetWindowCompositionAttribute(windowHandle, ref data); Marshal.FreeHGlobal(accentPtr); }
private async void StartGradientAnimation() { _cancellationTokenSource = new CancellationTokenSource(); var gradientStates = new List <(Color, Color)> { (Color.FromHex("#4A148C"), Color.FromHex("#D500F9")), (Color.FromHex("#FF6F00"), Color.FromHex("#FFC400")), (Color.FromHex("#1B5E20"), Color.FromHex("#00E676")), (Color.FromHex("#B71C1C"), Color.FromHex("#FF1744")) }; var state = 0; while (!_cancellationTokenSource.Token.IsCancellationRequested) { var fromColorStart = gradientStates[state].Item1; var fromColorEnd = gradientStates[state].Item2; var nextState = state + 1 > 3 ? 0 : state + 1; var toColorStart = gradientStates[nextState].Item1; var toColorEnd = gradientStates[nextState].Item2; var taskCompletionSource = new TaskCompletionSource <bool>(); new Animation { { 0, 1, new Animation(d => { BackgroundEffect.GetBackground(BackgroundView).GradientBrush.Gradients = new List <GradientStop> { new GradientStop(GetColor(d, fromColorStart, toColorStart), 0), new GradientStop(GetColor(d, fromColorEnd, toColorEnd), 1) }; }) } }.Commit(BackgroundView, "name", 16, 4000, Easing.Linear, (d, b) => taskCompletionSource.TrySetResult(true)); await taskCompletionSource.Task; if (_cancellationTokenSource.Token.IsCancellationRequested) { break; } state++; if (state > 3) { state = 0; } } }
private void SetVisualElement(VisualElement oldElement, VisualElement newElement) { if (oldElement != null) { _context = null; _nativeView = null; oldElement.PropertyChanged -= OnElementPropertyChanged; } if (newElement != null) { ResolveNativeView(); _context = _nativeView.Context; newElement.PropertyChanged += OnElementPropertyChanged; } IMaterialVisualElement oldMaterialVisualElement; IMaterialVisualElement newMaterialVisualElement; switch (oldElement) { case IBackgroundElement oldBackgroundElement: oldMaterialVisualElement = oldBackgroundElement.Background; break; case IMaterialVisualElement oldMaterialElement: oldMaterialVisualElement = oldMaterialElement; break; default: oldMaterialVisualElement = oldElement == null ? null : BackgroundEffect.GetBackground(oldElement); break; } switch (newElement) { case IBackgroundElement newBackgroundElement: newMaterialVisualElement = newBackgroundElement.Background; break; case IMaterialVisualElement newMaterialElement: newMaterialVisualElement = newMaterialElement; break; default: newMaterialVisualElement = newElement == null ? null : BackgroundEffect.GetBackground(newElement); break; } _visualElement = newElement; SetBackgroundElement(oldMaterialVisualElement, newMaterialVisualElement); }
private static IMaterialVisualElement GetMaterialVisualElement(VisualElement element) { switch (element) { case IBackgroundElement oldBackgroundElement: return(oldBackgroundElement.Background); case IMaterialVisualElement oldMaterialElement: return(oldMaterialElement); default: return(element == null ? null : BackgroundEffect.GetBackground(element)); } }
private void SetVisualElement(VisualElement oldElement, VisualElement newElement) { if (oldElement != null) { oldElement.PropertyChanged -= OnElementPropertyChanged; } if (newElement != null) { newElement.PropertyChanged += OnElementPropertyChanged; } IMaterialVisualElement oldMaterialVisualElement; IMaterialVisualElement newMaterialVisualElement; switch (oldElement) { case IBackgroundElement oldBackgroundElement: oldMaterialVisualElement = oldBackgroundElement.Background; break; case IMaterialVisualElement oldMaterialElement: oldMaterialVisualElement = oldMaterialElement; break; default: oldMaterialVisualElement = oldElement == null ? null : BackgroundEffect.GetBackground(oldElement); break; } switch (newElement) { case IBackgroundElement newBackgroundElement: newMaterialVisualElement = newBackgroundElement.Background; break; case IMaterialVisualElement newMaterialElement: newMaterialVisualElement = newMaterialElement; break; default: newMaterialVisualElement = newElement == null ? null : BackgroundEffect.GetBackground(newElement); break; } _visualElement = newElement; SetBackgroundElement(oldMaterialVisualElement, newMaterialVisualElement); }
void Start() { movement = 1.5f; headSpeed = 6.0f; handSpeed = 2.0f; music = GetComponent <AudioSource> (); bg = GameObject.Find("Background").GetComponent <BackgroundEffect> (); StartCoroutine(SpawnWaves()); gameScore = 0; multiplier = 1; killedShips = 5; lostShips = 5; hudTrack = GameObject.Find("HUD"); guiFunctions = hudTrack.GetComponent <UIScript> (); gameAlive = true; gameOverDisplayed = false; }
public DeferredRenderer(GraphicsDevice graphics, ContentManager content, GBufferInitParams p) { this.graphics = graphics; this.content = content; fullScreen = new FullScreenDraw(graphics); fillEffect = new FillGBufferEffect(content.Load <Effect>("FillGBuffer")); backgroundEffect = new BackgroundEffect(content.Load <Effect>("Background")); postEffect = content.Load <Effect>("PostProcess"); clearEffect = content.Load <Effect>("Clear"); targets = new GBuffer(graphics, p); lighting = new LightingStep(graphics, content, targets, fullScreen); downscaler = new Downscaler(graphics, content, targets, fullScreen); bloom = new Bloom(graphics, content, fullScreen); luminanceAverager = new Averager(graphics, content, fullScreen); drawStep.GraphicsDevice = graphics; }
void Responsive() { BackgroundEffect.StartAnimation(); if (Window.Current.Bounds.Width < 650) { VisualStateUtilities.GoToState(this, "Snap", false); } else { VisualStateUtilities.GoToState(this, "Wide", false); } if (Window.Current.Bounds.Height < 600) { //HeaderGrid.Height = 100; VisualStateUtilities.GoToState(this, "Tiny", false); } else { VisualStateUtilities.GoToState(this, "Tall", false); } }
public static T ApplyBackground <T>(this T element, Background background) where T : Element { BackgroundEffect.SetBackground(element, background); return(element); }
void Awake() { instance = this; }