/// <summary> /// Event Handler for the Preview Button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PreviewButton_Click(object sender, RoutedEventArgs e) { if (VTF_ListBox.Items.Count > 0) // Atleast 1 VTF loaded { VMTProperties vmt = GetVMTData(); int index = VTF_ListBox.SelectedIndex; if (index == -1) // No VTF selected { index = 0; } string vtfFile = (string)((ListBoxItem)VTF_ListBox.Items.GetItemAt(index)).Content; string vtfName = System.IO.Path.GetFileNameWithoutExtension(vtfFile); Preview_Box.Text = VMTUtils.GetVMTString(vmt, vtfName); } }
private string GenerateVMT(string vtfName) { StringBuilder sb = new StringBuilder(); string vmtFilePath = VMTUtils.GetVMTFilePath(OutputPath, vtfName); string vmtString = VMTUtils.GetVMTString(VMTData, vtfName); bool success = FilesUtils.TryWriteAllText(vmtFilePath, vmtString); if (success) { sb.Append($"Generated {vtfName}.vmt in \"{OutputPath}\""); } else { sb.Append($"Unable to create {vtfName}.vmt in \"{OutputPath}\""); } sb.AppendLine(); return(sb.ToString()); }