コード例 #1
0
        private async void ExportBtn_Click(object sender, RoutedEventArgs e)
        {
            if (currentSelection == null)
            {
                return;
            }

            string outDir = OpenFolder("Select where to save extracted files");

            if (outDir == null)
            {
                return;
            }

            Sprite sprite = (Sprite)currentSelection.Asset;

            ProgressWindow progressWindow = new ProgressWindow(sprite.FrameNum)
            {
                Title = "Exporting...",
                Owner = GetWindow(this)
            };

            progressWindow.Show();
            IProgress <double> progress = new Progress <double>(i => { progressWindow.IncrementProgress(i); });

            try
            {
                await sprite.ExportFrames(outDir, progressWindow.CancelToken, progress);
            }
            catch (OperationCanceledException)
            {
                // Cancelled
                Console.WriteLine("successfully cancelled export!");
            }

            progressWindow.Close();
        }