public async Task <bool> ForceReRender()
        {
            await TaskManager.Get.StartAsync((token) =>
            {
                Bitmap _renderedImage = RenderedImagePanel.RenderBitmapFromBlueprint(token, image, out int?textureSize);
                CalculatedTextureSize = textureSize ?? Constants.TextureSize;
                this.renderedImage.DisposeSafely();
                this.renderedImage = _renderedImage;
                TaskManager.SafeReport(0, "Finished.");
                this.InvokeEx((c) =>
                {
                    c.Refresh();
                });
            });

            return(true);
        }
Esempio n. 2
0
        public async Task RenderImageAndShowIt()
        {
            await TaskManager.Get.StartAsync((token) =>
            {
                TaskManager.SafeReport(0, "Optimizing...");

                PreRenderImage(false, token);

                if (this.PreRenderedImage != null)
                {
                    if (this.PreRenderedImage.Height > 256 && Options.Get.IsSideView)
                    {
                        MessageBox.Show("Minecraft cannot support images larger than 256 blocks in height.");
                        return;
                    }
                }
                TaskManager.SafeReport(0, "Getting Blueprint...");
                BlueprintPA blueprint = BlueprintPA.GetBluePrintAsync(token, this.PreRenderedImage).GetAwaiter().GetResult();
                TaskManager.SafeReport(0, "Rendering Blueprint...");
                Bitmap renderedImage = RenderedImagePanel.RenderBitmapFromBlueprint(token, blueprint, out int?textureSize);
                if (textureSize == null)
                {
                    return;
                }
                if (renderedImage == null)
                {
                    return;
                }

                try
                {
                    MainForm.Self.InvokeEx(x =>
                    {
                        x.LoadedBlueprint = blueprint;
                        x.ShowRenderedImagePanel();
                        x.renderedImagePanel.SetBluePrint(blueprint, renderedImage, textureSize);
                        TaskManager.SafeReport(0, "Finished.");
                    });
                }
                catch (OperationCanceledException) { }
            });
        }