2 using System
.Collections
.Generic
;
3 using System
.ComponentModel
;
7 using System
.Windows
.Forms
;
8 using System
.Diagnostics
;
14 public partial class Form1
: Form
16 protected OutputTextWriter m_outputWriter
;
17 Prefs m_prefs
= new Prefs();
19 ImageList m_imageList
= new ImageList();
21 public FileUpdater m_fileUpdater
;
25 InitializeComponent();
26 //TextWriter stdout = System.Console.Out;
27 //OutputTextWriter m_outputWriter = new OutputTextWriter(m_outputArea, stdout);
28 //System.Console.SetOut(m_outputWriter);
29 m_fileUpdater
= new FileUpdater(m_prefs
);
31 Executioner
.BinaryDirPath
= m_prefs
.GitDir
;
34 m_repoViewer
.FileUpdater
= m_fileUpdater
;
35 m_repoViewer
.ImageList
= m_imageList
;
36 m_statusViewer
.FileUpdater
= m_fileUpdater
;
37 m_statusViewer
.ImageList
= m_imageList
;
41 protected void PopulateImageList()
43 System
.Reflection
.Assembly a
= System
.Reflection
.Assembly
.GetExecutingAssembly();
44 System
.Resources
.ResourceManager m
= new System
.Resources
.ResourceManager("Widgit.Properties.Resources", a
);
45 Image im
= (System
.Drawing
.Image
)m
.GetObject("folder");
46 m_imageList
.Images
.Add("folder", im
);
48 im
= (System
.Drawing
.Image
)m
.GetObject("page");
49 m_imageList
.Images
.Add("normal", im
);
50 im
= (System
.Drawing
.Image
)m
.GetObject("page_edit");
51 m_imageList
.Images
.Add("modified", im
);
52 im
= (System
.Drawing
.Image
)m
.GetObject("page_add");
53 m_imageList
.Images
.Add("added", im
);
54 im
= (System
.Drawing
.Image
)m
.GetObject("page_delete");
55 m_imageList
.Images
.Add("delete", im
);
56 im
= (System
.Drawing
.Image
)m
.GetObject("page_error");
57 m_imageList
.Images
.Add("unmerged", im
);
58 im
= (System
.Drawing
.Image
)m
.GetObject("disconnect");
59 m_imageList
.Images
.Add("unknown", im
);
61 im
= (System
.Drawing
.Image
)m
.GetObject("page_error");
62 m_imageList
.Images
.Add("broken", im
);
63 im
= (System
.Drawing
.Image
)m
.GetObject("page_lightning");
64 m_imageList
.Images
.Add("modechanged", im
);
65 im
= (System
.Drawing
.Image
)m
.GetObject("page_copy");
66 m_imageList
.Images
.Add("copied", im
);
67 im
= (System
.Drawing
.Image
)m
.GetObject("page_go");
68 m_imageList
.Images
.Add("renamed", im
);
70 m_imageList
.Images
.Add("empty", new Bitmap(16, 16));
75 if (m_prefs
.Repos
== null)
77 m_prefs
.Repos
= new System
.Collections
.Specialized
.StringCollection();
79 object o
= m_reposCombo
.SelectedItem
;
80 m_reposCombo
.Items
.Clear();
81 foreach (string s
in m_prefs
.Repos
)
83 m_reposCombo
.Items
.Add(s
);
85 m_reposCombo
.SelectedItem
= o
;
89 void PreferencesUpdated()
91 Executioner
.BinaryDirPath
= m_prefs
.GitDir
;
95 protected bool UpdateTags()
97 throw new NotImplementedException();
100 protected bool UpdateBranches()
102 m_branchesCombo
.Items
.Clear();
103 foreach (Branch b
in m_currentRepo
.Branches
)
105 m_branchesCombo
.Items
.Add(b
.Name
);
107 m_branchesCombo
.SelectedItem
= m_currentRepo
.CurrentBranch
.Name
;
111 private void OnPreferencesClicked(object sender
, EventArgs e
)
113 PreferencesEditor p
= new PreferencesEditor(m_prefs
);
115 PreferencesUpdated();
118 private void OnManageRepos(object sender
, EventArgs e
)
120 RepoManager m
= new RepoManager(m_prefs
);
125 private void OnRepoChanged(object sender
, EventArgs e
)
127 if (m_reposCombo
.SelectedIndex
> -1)
129 m_currentRepo
= new Repo(m_reposCombo
.SelectedItem
.ToString());
130 m_fileUpdater
.SetRepo(m_currentRepo
);
131 m_repoViewer
.SetRepo(m_currentRepo
);
134 m_commitTable
.SetRepo(m_currentRepo
);
135 m_statusViewer
.SetRepo(m_currentRepo
, false);
139 MessageBox
.Show("Select a repo.", "Error", MessageBoxButtons
.OK
, MessageBoxIcon
.Error
);
143 private void OnBranchChanged(object sender
, EventArgs e
)
145 if (m_branchesCombo
.SelectedIndex
> -1)
147 if (m_currentRepo
.CurrentBranch
.Name
!= m_branchesCombo
.SelectedItem
.ToString())
149 foreach (Branch b
in m_currentRepo
.Branches
)
151 if (b
.Name
== m_branchesCombo
.SelectedItem
.ToString())
153 m_currentRepo
.Checkout(b
);
156 m_repoViewer
.SetRepo(m_currentRepo
);
161 MessageBox
.Show("Select a branch.", "Error", MessageBoxButtons
.OK
, MessageBoxIcon
.Error
);
165 private void OnCreateBranch(object sender
, EventArgs e
)
170 private void OnMergeBranch(object sender
, EventArgs e
)
175 private void OnDeleteBranch(object sender
, EventArgs e
)
180 private void OnExit(object sender
, EventArgs e
)
185 private void OnResetHard(object sender
, EventArgs e
)
187 DialogResult r
= MessageBox
.Show("Are you sure you want to revert everything you have in your working directory?",
188 "Widgit", MessageBoxButtons
.YesNo
, MessageBoxIcon
.Warning
);
189 if (r
== DialogResult
.Yes
)
191 m_currentRepo
.Reset(null);
192 m_repoViewer
.SetRepo(m_currentRepo
);