Exemplo n.º 1
0
 /// <summary>
 /// This function will change the layout to be shown on the screen
 /// </summary>
 /// <param name="layoutName">Name of the layout that should be shown</param>
 void changeLayout(string layoutName)
 {
     currentLayout = layoutName;
     if (BackgroundSources.ContainsKey(layoutName))
     {
         BackgroundSource = BackgroundSources[layoutName];
     }
     else
     {
         BackgroundSources[layoutName] = "";
     }
     Messenger.Default.Send(layoutName, "reloadGrid");
 }
        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            var newBgSource = (BackgroundSources)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.BackgroundSource).Value;

            this._tolRGB       = newToken.GetProperty <Int32Property>(PropertyNames.ToleranceRGB).Value;
            this._tolHue       = newToken.GetProperty <Int32Property>(PropertyNames.ToleranceHue).Value;
            this._tolSat       = newToken.GetProperty <Int32Property>(PropertyNames.ToleranceSat).Value;
            this._tolVal       = newToken.GetProperty <Int32Property>(PropertyNames.ToleranceVal).Value;
            this._domColMaxDev = newToken.GetProperty <Int32Property>(PropertyNames.DominantColorMaxDeviation).Value;

            if (newBgSource != this._bgSource && (newBgSource == BackgroundSources.ClipboardAverage || newBgSource == BackgroundSources.ClipboardDominant))
            {
                this._clipboardSurface = Utils.GetSurfaceFromClipboard();
            }

            this._bgSource = newBgSource;

            if (this._bgSource == BackgroundSources.DominantColor)
            {
                this._taskBGColor = srcArgs.Surface.GetDominantColorAsync((byte)this._domColMaxDev, 100, this.EnvironmentParameters.GetSelectionScanlines(), this);
            }
            else if (this._bgSource == BackgroundSources.ClipboardDominant)
            {
                this._taskBGColor = this._clipboardSurface?.GetDominantColorAsync((byte)this._domColMaxDev, 100, null, this) ?? Task.FromResult <ArgusColor>(this.EnvironmentParameters.PrimaryColor);
            }
            else if (this._bgSource == BackgroundSources.ClipboardAverage)
            {
                this._taskBGColor = Task.Run(() => { return(this._clipboardSurface?.GetMeanAndStdDeviation(null, this).First ?? this.EnvironmentParameters.PrimaryColor); });
            }
            else if (this._bgSource == BackgroundSources.ColorWheel)
            {
                this._taskBGColor = Task.FromResult <ArgusColor>(ArgusColor.FromRGB(newToken.GetProperty <Int32Property>(PropertyNames.ColorWheel).Value));
            }
            else if (this._bgSource == BackgroundSources.SecondaryColor)
            {
                this._taskBGColor = Task.FromResult <ArgusColor>(this.EnvironmentParameters.SecondaryColor);
            }
            else
            {
                this._taskBGColor = Task.FromResult <ArgusColor>(this.EnvironmentParameters.PrimaryColor);
            }

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }