private void lbOnlineVersions_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { var locate = new Point(((Control)sender).Location.X + e.Location.X, ((Control)sender).Location.Y + e.Location.Y); var columnsMenu = new BuildContextMenu(); columnsMenu.Items.Add("Download", null, new EventHandler((ob, ev) => btnDownloadVersion_Click(sender, e))); columnsMenu.Show(this, locate); } }
private void BuildList_MouseClick(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { ListViewItem item = BuildList.GetItemAt(e.X, e.Y); if (item != null) { var proj = SolutionParser.ProjTable[item.Text]; item.Selected = true; BuildContextMenu.Items[0].Enabled = proj.HasLog; BuildContextMenu.Items[1].Enabled = !builder.IsBuilding && proj.IsBuilt; BuildContextMenu.Show(BuildList, e.Location); } } }
private void AddButton_MouseDown(object sender, MouseEventArgs e) { //if (e.Button == MouseButtons.Right) //{ var locate = new Point((sender as Control).Location.X + e.Location.X, (sender as Control).Location.Y + e.Location.Y); var columnsMenu = new BuildContextMenu(); var allControls = new List <Control>(); allControls.AddRange(flowLayoutPanel1.Controls.Cast <Control>()); allControls.AddRange(HiddenButtons); foreach (var ctrl in allControls) { if (ctrl is Button btn) { if (btn.Tag is LauncherConfJsonItem lcji && lcji.FolderName != null) { var AddonInstalled = Directory.Exists(Path.Combine(lc.VersionLocation, lcji.FolderName)); if (lcji.HideItem && !AddonInstalled) { columnsMenu.Items.Add(lcji.ItemName, null, new EventHandler((ob, ev) => btnBatchfile_Click(btn, e))); } } } } if (columnsMenu.Items.Count == 0) { columnsMenu.Items.Add("No available addons", null, new EventHandler((ob, ev) => { })).Enabled = false; } columnsMenu.Items.Add(new ToolStripSeparator()); columnsMenu.Items.Add("Load Custom Package..", null, new EventHandler((ob, ev) => InstallCustomPackages())); var title = new ToolStripMenuItem("Extra addons for this RTC version") { Enabled = false }; var sep = new ToolStripSeparator(); columnsMenu.Items.Insert(0, sep); columnsMenu.Items.Insert(0, title); columnsMenu.Show(this, locate); }
public void DisplayVersion() { Size?btnSize = null; var folderPath = Path.Combine(MainForm.launcherDir, "VERSIONS", MainForm.SelectedVersion); if (!Directory.Exists(folderPath)) { return; } foreach (LauncherConfItem lci in lc.items) { var newButton = new Button { BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(32)))), ((int)(((byte)(32))))) }; newButton.FlatAppearance.BorderSize = 0; newButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; newButton.Font = new System.Drawing.Font("Segoe UI Semibold", 8F, System.Drawing.FontStyle.Bold); newButton.ForeColor = System.Drawing.Color.Black; Bitmap btnImage; using (var bmpTemp = new Bitmap(lci.imageLocation)) { btnImage = new Bitmap(bmpTemp); } if (btnSize == null) { //The first image sets the parameters for display btnSize = new Size(btnImage.Width + 1, btnImage.Height + 1); } newButton.Name = "btnDefaultSize"; newButton.Size = (Size)btnSize; newButton.TabIndex = 134; newButton.TabStop = false; newButton.Tag = lci.line; newButton.Text = string.Empty; newButton.UseVisualStyleBackColor = false; newButton.Click += new System.EventHandler(this.btnBatchfile_Click); var isAddon = !string.IsNullOrWhiteSpace(lci.downloadVersion); var AddonInstalled = false; if (isAddon) { AddonInstalled = Directory.Exists(lci.folderLocation); newButton.MouseDown += new MouseEventHandler((sender, e) => { if (e.Button == MouseButtons.Right) { var locate = new Point((sender as Control).Location.X + e.Location.X, (sender as Control).Location.Y + e.Location.Y); var columnsMenu = new BuildContextMenu(); columnsMenu.Items.Add("Delete", null, new EventHandler((ob, ev) => DeleteAddon(lci.folderName))).Enabled = AddonInstalled; columnsMenu.Show(this, locate); } return; }); } if (isAddon) { var p = new Pen((AddonInstalled ? Color.FromArgb(57, 255, 20) : Color.Red), 2); var x1 = 8; var y1 = btnImage.Height - 8; var x2 = 24; var y2 = btnImage.Height - 8; // Draw line to screen. using (var graphics = Graphics.FromImage(btnImage)) { graphics.DrawLine(p, x1, y1, x2, y2); } } newButton.Image = btnImage; newButton.Visible = true; flowLayoutPanel1.Controls.Add(newButton); } lbSelectedVersion.Text = lc.version; lbSelectedVersion.Visible = true; }