Exemplo n.º 1
0
        private void PackImagesClicked(object sender, RoutedEventArgs e)
        {
            try
            {
                string[]       files      = null;
                string         outFile    = string.Empty;
                OpenFileDialog inFileDiag = new OpenFileDialog
                {
                    Title       = "Select PNG images to pack",
                    DefaultExt  = "png",
                    Filter      = "PNG Image (*.png)|*.png",
                    Multiselect = true
                };

                if (inFileDiag.ShowDialog() == true)
                {
                    files = inFileDiag.FileNames;
                }

                if (files == null || files.Length == 0)
                {
                    return;
                }

                OpenFileDialog outFileDiag = new OpenFileDialog
                {
                    Title       = "Select Luna Nights data.win file",
                    DefaultExt  = "win",
                    Filter      = "Data.win (*.win)|*.win",
                    Multiselect = false
                };
                if (outFileDiag.ShowDialog() == true)
                {
                    outFile = outFileDiag.FileName;
                }

                if (string.IsNullOrWhiteSpace(outFile) || files == null || files.Length == 0)
                {
                    return;
                }

                Task.Run(() => _imagePacker.PackImagesIntoData(files, outFile));
            }
            catch (Exception ex)
            {
                _syncContext.Post((s) => ErrorTracker.CurrentError = ex.Message, null);
            }
        }