Пример #1
0
 public IActionResult DecompressGraphsNodes([FromBody] GraphRaw raw)
 {
     try
     {
         var decompressed = GraphCompression.DecompressGraphData(raw.JsonData);
         return(Ok(new
         {
             decompressed,
             hash = GraphCompression.GetUniqueGraphHash(raw.WalletIdentifier, raw.JsonData)
         }));
     }
     catch (Exception error)
     {
         logger.Error(error);
         return(StatusCode(500));
     }
 }
        /// <summary>
        ///     Caches the graph to a RenderTarget2D and updates the sprite's image.
        /// </summary>
        private void CacheGraph(GameTime gameTime)
        {
            if (Graph != null && !ForceRecaching)
            {
                return;
            }

            try
            {
                GameBase.Game.SpriteBatch.End();
            }
            catch (Exception e)
            {
                // ignored
            }

            var game = GameBase.Game as QuaverGame;

            game?.ScheduledRenderTargetDraws.Add(() =>
            {
                var(pixelWidth, pixelHeight) = GraphRaw.AbsoluteSize * WindowManager.ScreenScale;

                var renderTarget = new RenderTarget2D(GameBase.Game.GraphicsDevice, (int)pixelWidth, (int)pixelHeight, false,
                                                      GameBase.Game.GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.None);

                GameBase.Game.GraphicsDevice.SetRenderTarget(renderTarget);
                GameBase.Game.GraphicsDevice.Clear(Color.Transparent);

                GraphRaw.SpriteBatchOptions = new SpriteBatchOptions {
                    BlendState = BlendState.Opaque
                };
                GraphRaw.Draw(gameTime);
                GameBase.Game.SpriteBatch.End();

                Texture2D outputTexture = renderTarget;

                GameBase.Game.GraphicsDevice.SetRenderTarget(null);

                if (ForceRecaching && Graph != null)
                {
                    Graph.Image    = outputTexture;
                    ForceRecaching = false;
                }
                else
                {
                    Graph = new ImageButton(outputTexture)
                    {
                        Parent             = Ruleset.Screen.View.Container,
                        Size               = GraphRaw.Size,
                        SpriteBatchOptions = new SpriteBatchOptions {
                            BlendState = BlendState.AlphaBlend
                        },
                        DestroyIfParentIsNull = false
                    };

                    var view = Ruleset.Screen.View as EditorScreenView;

                    Graph.Height = GraphRaw.Height - view.MenuBar.Height;


                    var children = Ruleset.Screen.View.Container.Children;

                    // Make sure the navbar appears over the graph, so that the hover tooltips are on top.
                    // ListHelper.Swap(Ruleset.Screen.View.Container.Children, children.IndexOf(view?.NavigationBar), children.IndexOf(Graph));

                    CreateProgressSeekBar();
                }

                SetGraphXPos();
            });
        }
 /// <inheritdoc />
 /// <summary>
 /// </summary>
 public void Dispose()
 {
     Graph?.Destroy();
     GraphRaw?.Destroy();
 }
 /// <inheritdoc />
 /// <summary>
 /// </summary>
 public void Destroy()
 {
     GraphRaw.Destroy();
     Graph.Destroy();
 }