Exemplo n.º 1
0
        public async Task Render()
        {
            const byte SHADE = 30;

            var bitmap = default(WriteableBitmap);
                                 var success = default(bool);
                                 var waveRenderInfo  = default(BitmapHelper.RenderInfo);
                                 var powerRenderInfo = default(BitmapHelper.RenderInfo);

                                 if (this.RendererData == null)
            {
                return;
            }

                                 await Windows.Invoke(() =>
            {
                bitmap  = this.Bitmap;
                success = bitmap.TryLock(LockTimeout);
                if (!success)
                {
                    return;
                }
                if (this.Rms.Value)
                {
                    var colors      = this.Color.ToPair(SHADE);
                    waveRenderInfo  = BitmapHelper.CreateRenderInfo(bitmap, colors[0]);
                    powerRenderInfo = BitmapHelper.CreateRenderInfo(bitmap, colors[1]);
                }
                else
                {
                    waveRenderInfo = BitmapHelper.CreateRenderInfo(bitmap, this.Color);
                }
            }).ConfigureAwait(false);

                                 if (!success)
            {
                //No bitmap or failed to establish lock.
                return;
            }

                                 Render(
                                     this.RendererData,
                                     waveRenderInfo,
                                     powerRenderInfo,
                                     this.Rms.Value,
                                     WaveBarBehaviourConfiguration.GetMode(this.Mode.Value)
                                     );

                                 await Windows.Invoke(() =>
            {
                bitmap.AddDirtyRect(new Int32Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight));
                bitmap.Unlock();
            }).ConfigureAwait(false);
        }
Exemplo n.º 2
0
 public void Update()
 {
     if (this.GeneratorData != null && this.RendererData != null)
     {
         Update(
             this.GeneratorData,
             this.RendererData,
             this.Rms.Value,
             WaveBarBehaviourConfiguration.GetMode(this.Mode.Value)
             );
     }
     var task = this.Render();
 }
Exemplo n.º 3
0
 public IEnumerable <ConfigurationSection> GetConfigurationSections()
 {
     return(WaveBarBehaviourConfiguration.GetConfigurationSections());
 }