Example #1
0
        public static void DownloadFile(string desc, string link, string path)
        {
            DownloadForm form = new DownloadForm();

            form.descLabel.Text = desc;
            form.client.DownloadFileAsync(new Uri(link), path);
            form.ShowDialog();
        }
Example #2
0
        private async void button1_Click(object sender, EventArgs e)
        {
            if (Program.MainForm.CurrentProject.SampCtlData.dependencies.Contains(PackagesList.SelectedItem.ToString()))
            {
                ActionButton.Enabled = false;
                ActionButton.Text    = translations.PackagesForm_button1_Click_Uninstalling;
                PackagesList.Enabled = false;
                ControlBox           = false;

                DownloadForm frm = new DownloadForm
                {
                    progressBar1 = { Style = ProgressBarStyle.Marquee },
                    descLabel    = { Text = translations.PackagesForm_button1_Click_Removing_package___ }
                };
                frm.Show();
                Enabled = false;
                await SampCtl.SendCommand(Application.StartupPath + "/sampctl.exe",
                                          Program.MainForm.CurrentProject.ProjectPath, "p uninstall " + PackagesList.SelectedItem);

                Program.MainForm.CurrentProject.LoadSampCtlData();
                frm.Close();
                Enabled = true;

                ActionButton.Text    = translations.PackagesForm_button1_Click_InstallPackage;
                ActionButton.Enabled = true;
                PackagesList.Enabled = true;
                ControlBox           = true;
            }
            else
            {
                ActionButton.Enabled = false;
                ActionButton.Text    = translations.PackagesForm_button1_Click_Installing;
                PackagesList.Enabled = false;
                ControlBox           = false;

                DownloadForm frm = new DownloadForm
                {
                    progressBar1 = { Style = ProgressBarStyle.Marquee },
                    descLabel    = { Text = translations.PackagesForm_button1_Click_Downloading_package___ }
                };
                frm.Show();
                Enabled = false;
                await SampCtl.SendCommand(Application.StartupPath + "/sampctl.exe",
                                          Program.MainForm.CurrentProject.ProjectPath, "p install " + PackagesList.SelectedItem);

                frm.Close();
                Enabled = true;


                Program.MainForm.CurrentProject.LoadSampCtlData();

                ActionButton.Text    = translations.PackagesForm_button1_Click_UninstallPackage;
                ActionButton.Enabled = true;
                PackagesList.Enabled = true;
                ControlBox           = true;
            }
        }
Example #3
0
        public static string DownloadString(string desc, string link)
        {
            DownloadForm form = new DownloadForm();

            form.descLabel.Text = desc;
            form.client.DownloadStringAsync(new Uri(link));
            form.ShowDialog();
            return(form.result);
        }
Example #4
0
        private void PackagesForm_Load(object sender, EventArgs e)
        {
            string allPackages = DownloadForm.DownloadString("Downloading plugin list...", @"https://api.sampctl.com");

            _tmppcks = JsonConvert.DeserializeObject <Package[]>(allPackages);
            _pcks    = _tmppcks;

            //Only show 20
            for (int i = 0; i < Math.Min(MaxItemsPerPage, _pcks.Length); i++)
            {
                PackagesList.Items.Add($"{_pcks[i].user}/{_pcks[i].repo}");
            }
            _lastIndex             = Math.Min(MaxItemsPerPage, _pcks.Length);
            PreviousButton.Enabled = false;
            NPages.Text            = $@"{_page}/{Math.Ceiling(_pcks.Length/(double)MaxItemsPerPage)}";
        }