/// <summary> /// Take a screenshot and save it to a given path. /// </summary> /// <param name="path">Savepath.</param> public static void Capture(string path) { int w, h; Screen[] screens = Screen.AllScreens; w = screens.ToList().Sum(i => i.Bounds.Width); h = screens.ToList().Max(i => i.Bounds.Height); Bitmap screen = new Bitmap(w, h, PixelFormat.Format32bppArgb); Graphics gfx = Graphics.FromImage(screen); gfx.CopyFromScreen(0, 0, 0, 0, new Size(w, h), CopyPixelOperation.SourceCopy); try { if (String.IsNullOrEmpty(path)) { path = $@"{DateTime.Today.Day}_{DateTime.Today.Month}-{DateTime.Now.Hour}_{DateTime.Now.Minute}_{DateTime.Now.Second}.png"; } screen.Save($@"Data/User/{path}", AImageFormat.Png); } catch { Scripter.Execute($"error('Invalid path for screen.capture()! [Data/User/{path}]')"); } gfx.Dispose(); screen.Dispose(); }
private void packageCreateFolder_Click(object sender, EventArgs e) { List <TextBox> fields = new List <TextBox>() { PackageName, PackageAuthors, PackageDescription, PackageEntryPoint }; if (fields.All(x => !String.IsNullOrEmpty(x.Text))) { Dictionary <string, string> info = new Dictionary <string, string>() { ["Name"] = PackageName.Text, ["Authors"] = PackageAuthors.Text, ["Description"] = PackageDescription.Text, ["Contact"] = "", ["EntryPoint"] = PackageEntryPoint.Text }; Workshop.CreatePackage(PackageFolderSelectDialog.SelectedPath, info); InstalledPackagesList.Controls.Clear(); Workshop.GetInstalled().ToList().ForEach(x => { Dictionary <string, string> packageInfo = x.GetInfo(); PackageInfo i = new PackageInfo(); i.NameLabel.Text = packageInfo["Name"]; i.AuthorLabel.Text = packageInfo["Authors"]; i.DescLabel.Text = packageInfo["Description"]; i.Package = x; i.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left; InstalledPackagesList.Controls.Add(i); i.RunButton.Click += (ob, ed) => { Scripter.Execute(packageInfo["EntryPoint"], false); // x.Run(true,true); }; }); } else { Core.WriteLine(new ColorContainer(177, 31, 41), "Fill all fields before creating a package!"); } }