private void PerformAction(bool export) { try { SetCancelEnabled(true); if (export) { string extension = System.IO.Path.GetExtension(SaveFileName); if (extension.Equals(".rm2", StringComparison.OrdinalIgnoreCase)) { RM2Export.SaveToFile(SaveFileName, Document, this); } else if (extension.Equals(".rmesh", StringComparison.OrdinalIgnoreCase)) { RMeshExport.SaveToFile(SaveFileName, Document, this); } else if (extension.Equals(".fbx", StringComparison.OrdinalIgnoreCase) || extension.Equals(".obj", StringComparison.OrdinalIgnoreCase) || extension.Equals(".dae", StringComparison.OrdinalIgnoreCase) || extension.Equals(".stl", StringComparison.OrdinalIgnoreCase) || extension.Equals(".ply", StringComparison.OrdinalIgnoreCase)) { GenericExport.SaveToFile(SaveFileName, Document, this, extension.Substring(1)); } else { throw new Exception($"Unknown file extension ({extension})"); } } else { Lightmap.Lightmapper.Render(Document, this, out _, out _); } } catch (ThreadAbortException) { foreach (Thread thread in (Lightmap.Lightmapper.FaceRenderThreads ?? Enumerable.Empty <Thread>())) { if (thread.IsAlive) { thread.Abort(); } } ProgressLog.Invoke((MethodInvoker)(() => ProgressLog.AppendText("\nCancelled by the user"))); ProgressBar.Invoke((MethodInvoker)(() => ProgressBar.Value = 0)); } catch (Exception e) { ProgressLog.Invoke((MethodInvoker)(() => { ProgressLog.SelectionStart = ProgressLog.TextLength; ProgressLog.SelectionLength = 0; ProgressLog.SelectionColor = Color.Red; ProgressLog.AppendText("\nError: " + e.Message + "\n" + e.StackTrace); ProgressLog.SelectionColor = ProgressLog.ForeColor; })); ProgressBar.Invoke((MethodInvoker)(() => ProgressBar.Value = 0)); } finally { SetCancelEnabled(false); } }
private void ContinueDoingShit() { MOTD = MOTDTextBox.Text; Seed = SeedBox.Text; WorldType = WorldTypeDropdown.Text; ProgressLog.AppendText("\r\n" + ProgressLogLang[1]); File.WriteAllText(Path.Combine(rootDir, "start.bat"), "@echo off\r\njava -Xmx1024M -Xms1024M -jar " + paperJar + " nogui\r\npause"); ProgressLog.AppendText("\r\n" + ProgressLogLang[2]); File.WriteAllText(Path.Combine(rootDir, "eula.txt"), "eula=true"); ProgressLog.AppendText("\r\n" + ProgressLogLang[3]); File.WriteAllText(Path.Combine(rootDir, "server.properties"), "motd=" + MOTD + "\r\nspawn-protection=0" + "\r\nlevel-seed=" + Seed + "\r\nlevel-type=" + WorldType); ProgressLog.AppendText("\r\n" + ProgressLogLang[4]); ResizedServerIcon.Save(Path.Combine(rootDir, "server-icon.png"), ImageFormat.Png); string SerOpsJson = DoOpsJsonShit(); File.WriteAllText(Path.Combine(rootDir, "ops.json"), SerOpsJson); if (CopyIPCheckbox.Checked) { ProgressLog.AppendText("\r\n" + ProgressLogLang[5]); WebClient web = new WebClient(); web.DownloadStringCompleted += (s, ev) => { string IP = ev.Result; Clipboard.SetText(IP); ProgressLog.AppendText(ProgressLogLang[6] + IP); }; web.DownloadStringAsync(new Uri("https://api.ipify.org")); web.Dispose(); } MessageBox.Show(ProgressLogLang[7]); }
private void CreateButton_Click(object sender, EventArgs e) { rootDir = FolderPathTextBox.Text; MCVersion = PaperVersion.Text; TabControl.Enabled = false; CreateButton.Enabled = false; bool rootDirEmpty = IsDirectoryEmpty(rootDir); if (!rootDirEmpty) { DialogResult dialogueResult = MessageBox.Show("Directory is not empty! Are you sure you want to install paper there? (Pressing no will close the application)", "Directory not empty!", MessageBoxButtons.YesNo); if (dialogueResult == DialogResult.No) { Application.Exit(); } } if (!SkipPaperDownload.Checked) { ProgressLog.AppendText(ProgressLogLang[0]); } DownloadPaper(MCVersion, rootDir, progressBar); }