private void btnConvert_Click(object sender, EventArgs e) { string filepath = txtConvertFile.Text; if (File.Exists(filepath)) { if (File.Exists("bin\\texconv.exe")) { ConvertFormatItem formatItem = cmbConvertFormat.SelectedItem as ConvertFormatItem; if (formatItem == null) { return; } DXGIFormat format = formatItem.Format; filepath = Path.GetFullPath(filepath); string directory = Path.GetDirectoryName(filepath); bool backedUp = false; if (Path.GetExtension(filepath) == ".dds" && !File.Exists(filepath + ".bak")) { backedUp = true; File.Copy(filepath, filepath + ".bak"); } string args = string.Format("-f {0} -o \"{1}\" \"{2}\" -y", TPUP.PrintDXGIFormat(format), directory, filepath); ProcessStartInfo startInfo = new ProcessStartInfo("bin\\texconv.exe", args) { CreateNoWindow = true, UseShellExecute = false, RedirectStandardOutput = true }; Process texconv = Process.Start(startInfo); texconv.WaitForExit(); if (texconv.ExitCode == 0) { appendLog("Conversion successful!"); SystemSounds.Asterisk.Play(); } else { MessageBox.Show("Conversion failed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); if (backedUp) { File.Move(filepath + ".bak", filepath); } } } else { MessageBox.Show("texconv.exe not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("File to be converted does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public override string ToString() { return(TPUP.PrintDXGIFormat(Format)); }
private async void FormMain_Load(object sender, EventArgs e) { Text = "DSR Texture Packer & Unpacker " + System.Windows.Forms.Application.ProductVersion; Location = settings.WindowLocation; Size = settings.WindowSize; if (settings.WindowMaximized) { WindowState = FormWindowState.Maximized; } txtGameDir.Text = settings.GameDir; txtUnpackDir.Text = settings.UnpackDir; txtRepackDir.Text = settings.RepackDir; cbxPreserveConverted.Checked = settings.PreserveConverted; txtConvertFile.Text = settings.ConvertFile; tclMain.SelectedIndex = settings.TabSelected; spcLogs.SplitterDistance = settings.SplitterDistance; nudThreads.Maximum = Environment.ProcessorCount; if (settings.Threads == 0 || settings.Threads > Environment.ProcessorCount) { settings.Threads = Environment.ProcessorCount; } nudThreads.Value = settings.Threads; enableControls(true); // Force common formats to the top List <DXGIFormat> outOfOrder = new List <DXGIFormat> { DXGIFormat.BC1_UNorm, DXGIFormat.BC2_UNorm, DXGIFormat.BC3_UNorm, DXGIFormat.BC5_UNorm, DXGIFormat.BC7_UNorm, }; foreach (DXGIFormat format in outOfOrder) { cmbConvertFormat.Items.Add(new ConvertFormatItem(format)); } cmbConvertFormat.Items.Add("--------------------------------------------------"); List <DXGIFormat> inOrder = new List <DXGIFormat>(); foreach (DXGIFormat format in Enum.GetValues(typeof(DXGIFormat))) { if (!outOfOrder.Contains(format) && format != DXGIFormat.Unknown) { inOrder.Add(format); } } inOrder.Sort((f1, f2) => TPUP.PrintDXGIFormat(f1).CompareTo(TPUP.PrintDXGIFormat(f2))); foreach (DXGIFormat format in inOrder) { cmbConvertFormat.Items.Add(new ConvertFormatItem(format)); } cmbConvertFormat.SelectedIndex = 0; GitHubClient gitHubClient = new GitHubClient(new ProductHeaderValue("DSR-TPUP")); try { Release release = await gitHubClient.Repository.Release.GetLatest("JKAnderson", "DSR-TPUP"); if (SemVersion.Parse(release.TagName) > System.Windows.Forms.Application.ProductVersion) { lblUpdate.Visible = false; LinkLabel.Link link = new LinkLabel.Link(); link.LinkData = UPDATE_LINK; llbUpdate.Links.Add(link); llbUpdate.Visible = true; } else { lblUpdate.Text = "App up to date"; } } catch (Exception ex) when(ex is HttpRequestException || ex is ApiException || ex is ArgumentException) { lblUpdate.Text = "Update status unknown"; } }