Ejemplo n.º 1
0
        internal void lbVersions_MouseDown(object sender, MouseEventArgs e)
        {
            var locate = new Point((sender as Control).Location.X + e.Location.X, (sender as Control).Location.Y + e.Location.Y + pnTopPanel.Height);

            if (sideversionForm.lbVersions.SelectedIndex == -1)
            {
                if (e.Button == MouseButtons.Right)
                {
                    var columnsMenu = new Components.BuildContextMenu();
                    columnsMenu.Items.Add("Install from Zip file", null, new EventHandler((ob, ev) => InstallFromZip()));
                    columnsMenu.Show(this, locate);
                }
            }
            else
            {
                var version = sideversionForm.lbVersions.SelectedItem.ToString();
                if (!Directory.Exists(launcherDir + Path.DirectorySeparatorChar + "VERSIONS" + Path.DirectorySeparatorChar + version))
                {
                    return;
                }

                if (e.Button == MouseButtons.Right)
                {
                    var columnsMenu = new Components.BuildContextMenu();
                    columnsMenu.Items.Add("Open Folder", null, new EventHandler((ob, ev) => OpenFolder()));
                    columnsMenu.Items.Add(new ToolStripSeparator());
                    columnsMenu.Items.Add("Delete", null, new EventHandler((ob, ev) => DeleteSelected()));
                    columnsMenu.Items.Add(new ToolStripSeparator());
                    columnsMenu.Items.Add("Install from Zip file", null, new EventHandler((ob, ev) => InstallFromZip()));
                    columnsMenu.Show(this, locate);
                }
            }
        }
Ejemplo n.º 2
0
        internal void SuggestInstallZip(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 + pnTopPanel.Height);

                var columnsMenu = new Components.BuildContextMenu();
                columnsMenu.Items.Add("Install from Zip file", null, new EventHandler((ob, ev) => InstallFromZip()));
                columnsMenu.Show(this, locate);
            }
        }
Ejemplo n.º 3
0
        private void SidebarVersionsPanel_MouseDown(object sender, MouseEventArgs e)
        {
            var locate = new Point((sender as Control).Location.X + e.Location.X, (sender as Control).Location.Y + e.Location.Y);

            if (!lbVersions.Visible)
            {
                if (e.Button == MouseButtons.Right)
                {
                    var columnsMenu = new Components.BuildContextMenu();
                    columnsMenu.Items.Add("Install from Zip file", null, new EventHandler((ob, ev) => MainForm.mf.InstallFromZip()));
                    columnsMenu.Show(this, locate);
                }
            }
        }
Ejemplo n.º 4
0
        public void DisplayVersion()
        {
            var folderPath = Path.Combine(MainForm.launcherDir, "VERSIONS", MainForm.SelectedVersion);

            if (!Directory.Exists(folderPath))
            {
                return;
            }

            Size?btnSize = null;

            HiddenButtons.Clear();

            foreach (var lcji in lc.Items) //.Where(it => !it.HideItem))
            {
                Bitmap btnImage;
                using (var bmpTemp = new Bitmap(Path.Combine(lc.LauncherAssetLocation, lcji.ImageName)))
                {
                    btnImage = new Bitmap(bmpTemp);
                    if (btnSize == null)
                    {
                        btnSize = new Size(btnImage.Width + 1, btnImage.Height + 1);
                    }
                }

                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;
                newButton.Name      = lcji.FolderName;
                newButton.Size      = (Size)btnSize;
                newButton.TabIndex  = 134;
                newButton.TabStop   = false;
                newButton.Tag       = lcji;
                newButton.Text      = string.Empty;
                newButton.UseVisualStyleBackColor = false;

                if (lcji.ImageName == "Add.png")
                {
                    newButton.AllowDrop  = true;
                    newButton.MouseDown += AddButton_MouseDown;
                    newButton.DragEnter += AddButton_DragEnter;
                    newButton.DragDrop  += AddButton_DragDrop;
                }
                else
                {
                    newButton.Click += this.btnBatchfile_Click;
                }

                newButton.MouseEnter += NewButton_MouseEnter;
                newButton.MouseLeave += NewButton_MouseLeave;

                var isAddon        = !string.IsNullOrWhiteSpace(lcji.DownloadVersion);
                var AddonInstalled = false;

                if (isAddon)
                {
                    AddonInstalled = Directory.Exists(Path.Combine(lc.VersionLocation, lcji.FolderName));

                    newButton.MouseDown += (sender, 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 Components.BuildContextMenu();
                            columnsMenu.Items.Add("Delete Addon", null, (ob, ev) => DeleteAddon(lcji)).Enabled = (lcji.IsAddon || AddonInstalled);
                            columnsMenu.Items.Add("Open Folder in Explorer", null, (ob, ev) =>
                            {
                                var addonFolderPath = Path.Combine(MainForm.launcherDir, "VERSIONS", lc.Version, lcji.FolderName);

                                if (Directory.Exists(addonFolderPath))
                                {
                                    Process.Start(addonFolderPath);
                                }
                            }).Enabled = AddonInstalled;
                            columnsMenu.Show(this, locate);
                        }
                    };
                }

                if (isAddon)
                {
                    var p = new Pen((AddonInstalled ? Color.FromArgb(57, 255, 20) : Color.Red), 1);
                    var b = new System.Drawing.SolidBrush((AddonInstalled ? Color.FromArgb(57, 255, 20) : Color.Red));

                    var x1 = 2;
                    var y1 = btnImage.Height - 6;
                    var x2 = 4;
                    var y2 = 4;
                    // Draw line to screen.
                    using (var graphics = Graphics.FromImage(btnImage))
                    {
                        graphics.FillRectangle(b, x1, y1, x2, y2);
                    }
                }

                newButton.Image = btnImage;

                if (!AddonInstalled && lcji.HideItem)
                {
                    newButton.Size     = new Size(0, 0);
                    newButton.Location = new Point(0, 0);

                    HiddenButtons.Add(newButton);
                    continue;
                }

                newButton.Visible = true;
                flowLayoutPanel1.Controls.Add(newButton);
            }

            lbSelectedVersion.Text    = lc.Version;
            lbSelectedVersion.Visible = true;
        }