Пример #1
0
        private void FileSelect_Click(object sender, RoutedEventArgs e)
        {
            MainViewModel mvm  = FindResource("mvm") as MainViewModel;
            string        file = mvm.GetFilePath(false, false);

            if (!string.IsNullOrEmpty(file))
            {
                string copy = "";
                if (new FileInfo(file).Extension.Contains("tga"))
                {
                    using (Process conv = new Process())
                    {
                        conv.StartInfo.UseShellExecute = false;
                        conv.StartInfo.CreateNoWindow  = true;
                        if (Directory.Exists(Path.Combine(tempPath, "image")))
                        {
                            Directory.Delete(Path.Combine(tempPath, "image"), true);
                        }
                        Directory.CreateDirectory(Path.Combine(tempPath, "image"));
                        conv.StartInfo.FileName  = Path.Combine(toolsPath, "tga2png.exe");
                        conv.StartInfo.Arguments = $"-i \"{file}\" -o \"{Path.Combine(tempPath, "image")}\"";

                        conv.Start();
                        conv.WaitForExit();

                        foreach (string sFile in Directory.GetFiles(Path.Combine(tempPath, "image"), "*.png"))
                        {
                            copy = sFile;
                        }
                    }
                }
                else
                {
                    copy = file;
                }
                try
                {
                    bi.TitleScreen = new Bitmap(copy);
                    b            = bi.Create(console);
                    Image.Source = BitmapToImageSource(b);
                }
                catch
                {
                    Custom_Message cm = new Custom_Message("Image Issue", "The image you're trying to use will not work, please try a different image.");
                    try
                    {
                        cm.Owner = mvm.mw;
                    }
                    catch (Exception)
                    {
                        //left empty on purpose
                    }
                    cm.ShowDialog();
                }
            }
            enOv_Click(null, null);
        }
        private void FileSelect_Click(object sender, RoutedEventArgs e)
        {
            MainViewModel mvm = FindResource("mvm") as MainViewModel;
            string file = mvm.GetFilePath(false, false);
            if (!string.IsNullOrEmpty(file))
            {

                string copy = "";
                if (new FileInfo(file).Extension.Contains("tga"))
                {
                    using (Process conv = new Process())
                    {

                        conv.StartInfo.UseShellExecute = false;
                        conv.StartInfo.CreateNoWindow = true;
                        if (Directory.Exists(Path.Combine(tempPath, "image")))
                        {
                            Directory.Delete(Path.Combine(tempPath, "image"), true);
                        }
                        Directory.CreateDirectory(Path.Combine(tempPath, "image"));
                        conv.StartInfo.FileName = Path.Combine(toolsPath, "tga2png.exe");
                        conv.StartInfo.Arguments = $"-i \"{file}\" -o \"{Path.Combine(tempPath, "image")}\"";

                        conv.Start();
                        conv.WaitForExit();

                        foreach (string sFile in Directory.GetFiles(Path.Combine(tempPath, "image"), "*.png"))
                        {
                            copy = sFile;
                        }
                    }
                }
                else
                {
                    copy = file;
                }
                bi.TitleScreen = new Bitmap(copy);
                b = bi.Create(console);
                Image.Source = BitmapToImageSource(b);
            }
            enOv_Click(null, null);
        }