예제 #1
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            const TextFormatFlags flags = TextFormatFlags.Left | TextFormatFlags.VerticalCenter;

            if (e.Index >= 0)
            {
                if (Items.Count == 0)
                {
                    return;
                }
                e.DrawBackground();
                ModListing m = (ModListing)Items[e.Index];
                if (m.HasIcon)
                {
                    e.Graphics.DrawImage(m.Icon, 2, e.Bounds.Y + 2, 64, 64);
                }
                else
                {
                    e.Graphics.DrawRectangle(System.Drawing.Pens.Red, 2, e.Bounds.Y + 2, 64, 64); // Simulate an icon.
                }
                var textRect = e.Bounds;
                textRect.X     += 70;
                textRect.Width -= 20;
                string itemText = DesignMode ? "ListBoxMods" : Items[e.Index].ToString();
                TextRenderer.DrawText(e.Graphics, itemText, e.Font, textRect, e.ForeColor, flags);
                e.DrawFocusRectangle();
            }
        }
예제 #2
0
파일: FormMods.cs 프로젝트: aphadeon/BotM
        private void button4_Click(object sender, EventArgs e)
        {
            //uninstall mod
            if (listBoxInstalled.SelectedItem == null)
            {
                return;
            }
            try
            {
                ModListing ml = (ModListing)listBoxInstalled.SelectedItem;

                //do uninstall
                List <InstallAction> actions = ml.m.InstallActions;
                if (actions != null)
                {
                    foreach (var a in actions)
                    {
                        switch (a.Action)
                        {
                        case "Overwrite":
                            if (a.Parameters.Length != 2)
                            {
                                MessageBox.Show("Wrong number of parameters for install action: " + a.Action);
                                continue;
                            }
                            UnOverwrite(ml.m, a.Parameters[1]);
                            break;

                        default:
                            MessageBox.Show("Unknown install action:\n" + a.Action);
                            continue;
                        }
                    }
                }

                File.Move(ml.m.ModFile, Path.Combine(MainForm.Settings.NotInstalledModsDirectory, Path.GetFileName(ml.m.ModFile)));
                MessageBox.Show("Mod successfully uninstalled.");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error occured while uninstalling mod:\n" + ex.Message);
            }
        }