private void OnExtractClick(object sender, EventArgs e) { SaveSettings(); txt_Info.Text = ""; cmd_Extract.Enabled = false; try { var lFileNameTp4 = txt_FileNameTp4.Text.Trim(); var lOutputDirectory = txt_OutputDirectory.Text.Trim(); // Folder => Filename without extension if (lOutputDirectory == "$") { lOutputDirectory = ""; } var lTp4File = new TP4File(lFileNameTp4, lOutputDirectory); lTp4File.Extract(); // Javascrip: config.js var lConfig = string.Format(Resources.Config, txt_ConnHost.Text, num_ConnPort.Value.ToString()); if (string.IsNullOrWhiteSpace(lOutputDirectory)) { lOutputDirectory = Path.GetDirectoryName(lFileNameTp4) + @"\" + Path.GetFileNameWithoutExtension(lFileNameTp4); } var lFileNameConfig = string.Format(@"{0}\config.js", lOutputDirectory); File.WriteAllText(lFileNameConfig, lConfig); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "TP4Unzip", MessageBoxButtons.OK, MessageBoxIcon.Error); } cmd_Extract.Enabled = true; }
private void OnExtractClick(object sender, EventArgs e) { txt_Info.Text = ""; cmd_Extract.Enabled = false; try { var lOutputDirectory = txt_OutputDirectory.Text.Trim(); // Folder => Filename without extension if (lOutputDirectory == "$") { lOutputDirectory = ""; } var lTp4File = new TP4File(txt_FileNameTp4.Text.Trim(), lOutputDirectory) { XmlStyleSheetHtmlFileName = txt_FileNameXsltHtml.Text.Trim(), CreateJson = ckb_CreateJson.Checked, CreateJsonJs = ckb_CreateJsonJs.Checked }; if (ckb_XSL.Checked) { lTp4File.XmlStyleSheetElement = txt_XmlStyleSheetElement.Text.Trim(); } lTp4File.Extract(); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "TP4Unzip", MessageBoxButtons.OK, MessageBoxIcon.Error); } cmd_Extract.Enabled = true; }
static void Main(string[] args) { var lSettings = Settings.Default; // Add the event handler for handling UI thread exceptions to the event. Application.ThreadException += OnThreadException; // Set the unhandled exception mode to force for all Windows Forms errors. Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); // Add the event handler for handling non-UI thread exceptions to the event. AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; // Set default settings ... if (string.IsNullOrWhiteSpace(lSettings.OutputFolder)) { lSettings.OutputFolder = "$"; } if (string.IsNullOrWhiteSpace(lSettings.ConnHost)) { lSettings.ConnHost = "127.0.0.1"; } if (lSettings.ConnPort == 0 || lSettings.ConnPort > 65535) { Settings.Default.ConnPort = 80; } if (string.IsNullOrWhiteSpace(lSettings.JsFileName)) { lSettings.JsFileName = "project.js"; } if (string.IsNullOrWhiteSpace(lSettings.JsVariableName)) { lSettings.JsVariableName = "Proj"; } if (args.Length > 0) { EventService.Instance.OnMessage += OnMessage; foreach (var lArg in args) { Console.WriteLine("Verarbeite Datei: {0}", lArg); Console.WriteLine("================================================================================"); try { var lTp4File = new TP4File(lArg); lTp4File.Extract(); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.WriteLine("================================================================================"); } Console.WriteLine("Fertig"); // Console.ReadLine(); return; } var lPtr = GetConsoleWindow(); // Konsole ausblenden ShowWindow(lPtr, SW_HIDE); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new AppMain()); }