2 using System
.Collections
.Generic
;
3 using System
.ComponentModel
;
7 using System
.Windows
.Forms
;
12 public partial class StatusViewer
: UserControl
, ISelectable
15 Dictionary
<string, Git
.File
> m_files
;
16 ImageList m_imageList
;
17 public ImageList ImageList { get { return m_imageList; }
set { m_imageList = value; m_statusList.SmallImageList = m_imageList; }
}
19 protected FileUpdater m_updater
;
20 public FileUpdater FileUpdater
24 if (null != m_updater
)
26 m_updater
.FilesUpdated
-= OnFilesUpdated
;
27 m_updater
[m_toolbar
] = null;
30 m_updater
.FilesUpdated
+= OnFilesUpdated
;
31 m_updater
[m_toolbar
] = (ISelectable
)this;
35 protected int m_selectedTypes
= -1 & (int)~Git
.FileState
.Unknown
& (int)~Git
.FileState
.Normal
;
39 InitializeComponent();
40 m_toolbar
.Initialize(-1 & (int)~FileState
.Normal
, -1 & (int)~FileState
.Normal
& (int)~FileState
.Unknown
);
41 m_toolbar
.RefreshFiles
+= OnRefreshTree
;
42 m_toolbar
.StatesChanged
+= OnStatesChanged
;
43 m_toolbar
.Enabled
= false;
46 public void SetRepo(Repo repo
, bool bRefresh
)
49 m_currentRepo
.GetFilesMap(out m_files
, bRefresh
);
51 m_toolbar
.Enabled
= true;
54 protected void PopulateTable()
56 m_statusList
.BeginUpdate();
57 m_statusList
.Items
.Clear();
58 foreach (KeyValuePair
<string, Git
.File
> pair
in m_files
)
60 if (0 == (m_selectedTypes
& (int)pair
.Value
.State
))
64 ListViewItem item
= new ListViewItem( new string[] { pair.Key }
, Git
.File
.GetStateName(pair
.Value
.State
));
65 item
.Tag
= pair
.Value
;
67 m_statusList
.Items
.Add(item
);
69 m_statusList
.EndUpdate();
72 private void OnFilesUpdated(FileUpdater sender
, FilesUpdatedEvent evt
)
74 List
<Git
.File
> files
= evt
.FilesList
;
75 foreach (Git
.File f
in files
)
77 m_files
[f
.PathWithName
] = f
;
82 private void OnRefreshTree(object sender
, EventArgs e
)
84 if (null != m_currentRepo
)
86 m_currentRepo
.GetFilesMap(out m_files
, true);
91 private void OnStatesChanged(RepoToolStrip sender
, SelectedStatesChangedEvent e
)
93 m_selectedTypes
= e
.SelectedStates
;
97 public List
<File
> GetSelected()
99 List
<File
> files
= new List
<File
>();
100 foreach (ListViewItem i
in m_statusList
.SelectedItems
)
102 files
.Add((File
)i
.Tag
);