Beispiel #1
0
        protected override void OnExecute(object param)
        {
            var ib = new ImageBuilder();

            ib.BuildImageFile(new ImageBuilder.Settings
            {
                Surface               = _main.PreviewImage.ImageCanvas,
                OutputPath            = OutputPath,
                TransparentBackground = _main.TransparentBackground,
            });
        }
        protected override void OnExecute(object param)
        {
            if (Directory.Exists(OutputDir))
            {
                Directory.Delete(OutputDir, true);
            }

            Directory.CreateDirectory(OutputDir);

            var builder = new ImageBuilder();

            for (int i = 0; i < _main.StickerItems.Count; i++)
            {
                var item = _main.StickerItems[i];

                var outName = item.Emoji;
                foreach (var c in Path.GetInvalidPathChars())
                {
                    outName = outName.Replace(c.ToString(), "");
                }
                foreach (var c in Path.GetInvalidFileNameChars())
                {
                    outName = outName.Replace(c.ToString(), "");
                }
                outName = outName.Replace(" ", "_");

                var path    = Path.Combine(OutputDir, $"{i}_{outName}.png");
                var preview = new PreviewImage();
                preview.DataContext = new
                {
                    SelectedStickerItem = item,
                    SelectedTextFill    = _main.SelectedTextFill,
                };

                Application.Current.Dispatcher.Invoke(
                    DispatcherPriority.Background,
                    new Action(() =>
                {
                    builder.BuildImageFile(new ImageBuilder.Settings
                    {
                        Surface               = preview.ImageCanvas,
                        OutputPath            = path,
                        TransparentBackground = _main.TransparentBackground,
                    });
                })
                    );
            }
        }