Exemple #1
0
        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!");
            }
        }