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 public ListView
.SelectedListViewItemCollection SelectedItems { get { return m_statusList.SelectedItems; }
}
21 public bool Multiselect { get { return m_statusList.MultiSelect; }
set { m_statusList.MultiSelect = value; }
}
23 protected FileUpdater m_updater
;
24 public FileUpdater FileUpdater
28 if (null != m_updater
)
30 m_updater
.FilesUpdated
-= OnFilesUpdated
;
31 m_updater
[m_toolbar
] = null;
32 m_updater
[m_opMenu
] = null;
35 m_updater
.FilesUpdated
+= OnFilesUpdated
;
36 m_updater
[m_toolbar
] = (ISelectable
)this;
37 m_updater
[m_opMenu
] = (ISelectable
)this;
41 protected int m_selectedTypes
= -1 & (int)~Git
.FileState
.Unknown
& (int)~Git
.FileState
.Normal
;
45 InitializeComponent();
46 m_toolbar
.Initialize(-1 & (int)~FileState
.Normal
, -1 & (int)~FileState
.Normal
& (int)~FileState
.Unknown
);
47 m_toolbar
.RefreshFiles
+= OnRefreshTree
;
48 m_toolbar
.StatesChanged
+= OnStatesChanged
;
49 m_toolbar
.Enabled
= false;
52 public void SetRepo(Repo repo
, bool bRefresh
)
55 m_currentRepo
.GetFilesMap(out m_files
, bRefresh
);
57 m_toolbar
.Enabled
= true;
60 protected void PopulateTable()
62 m_statusList
.BeginUpdate();
63 m_statusList
.Items
.Clear();
64 foreach (KeyValuePair
<string, Git
.File
> pair
in m_files
)
66 if (0 == (m_selectedTypes
& (int)pair
.Value
.State
))
70 ListViewItem item
= new ListViewItem( new string[] { pair.Key }
, Git
.File
.GetStateName(pair
.Value
.State
));
71 item
.Tag
= pair
.Value
;
73 m_statusList
.Items
.Add(item
);
75 m_statusList
.EndUpdate();
78 private void OnFilesUpdated(FileUpdater sender
, FilesUpdatedEvent evt
)
80 List
<Git
.File
> files
= evt
.FilesList
;
81 foreach (Git
.File f
in files
)
83 m_files
[f
.PathWithName
] = f
;
88 private void OnRefreshTree(object sender
, EventArgs e
)
90 if (null != m_currentRepo
)
92 m_currentRepo
.GetFilesMap(out m_files
, true);
97 private void OnStatesChanged(RepoToolStrip sender
, SelectedStatesChangedEvent e
)
99 m_selectedTypes
= e
.SelectedStates
;
103 public List
<File
> GetSelected()
105 List
<File
> files
= new List
<File
>();
106 foreach (ListViewItem i
in m_statusList
.SelectedItems
)
108 files
.Add((File
)i
.Tag
);
113 private void OnRowClicked(object sender
, MouseEventArgs e
)
115 if (e
.Button
== MouseButtons
.Right
)
117 ListViewItem i
= m_statusList
.GetItemAt(e
.X
, e
.Y
);
118 m_statusList
.SelectedItems
.Clear();
120 m_opMenu
.Show(m_statusList
, e
.X
, e
.Y
);