PageRenderTime 56ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/GitUI/FormSelectMultipleBranches.cs

https://github.com/eisnerd/gitextensions
C# | 74 lines | 62 code | 11 blank | 1 comment | 5 complexity | 25c94a4f140969bb7d193775b83f6050 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using GitCommands;
  10. namespace GitUI
  11. {
  12. public partial class FormSelectMultipleBranches : GitExtensionsForm
  13. {
  14. // for translation only
  15. internal FormSelectMultipleBranches()
  16. {
  17. InitializeComponent();
  18. Translate();
  19. }
  20. public FormSelectMultipleBranches(IList<GitHead> branchesToSelect)
  21. {
  22. InitializeComponent();
  23. Translate();
  24. if (branchesToSelect.Count > 350)
  25. Branches.MultiColumn = true;
  26. Branches.DisplayMember = "Name";
  27. Branches.Items.AddRange(branchesToSelect.ToArray());
  28. }
  29. public void SelectBranch(string name)
  30. {
  31. int index = 0;
  32. foreach (object item in Branches.Items)
  33. {
  34. GitHead branch = item as GitHead;
  35. if (branch != null && branch.Name == name)
  36. {
  37. Branches.SetItemChecked(index, true);
  38. return;
  39. }
  40. index++;
  41. }
  42. }
  43. public IList<GitHead> GetSelectedBranches()
  44. {
  45. IList<GitHead> branches = new List<GitHead>();
  46. foreach (GitHead head in Branches.CheckedItems)
  47. branches.Add(head);
  48. return branches;
  49. }
  50. private void okButton_Click(object sender, EventArgs e)
  51. {
  52. Close();
  53. }
  54. private void FormSelectMultipleBranches_Load(object sender, EventArgs e)
  55. {
  56. RestorePosition("selectmultiplebranches");
  57. }
  58. private void FormSelectMultipleBranches_FormClosing(object sender, FormClosingEventArgs e)
  59. {
  60. SavePosition("selectmultiplebranches");
  61. }
  62. }
  63. }