Exemple #1
0
 private void FileStatusListView_SizeChanged(object sender, EventArgs e)
 {
     NoFiles.Location = new Point(5, 5);
     NoFiles.Size     = new Size(Size.Width - 10, Size.Height - 10);
     Refresh();
     FileStatusListView.BeginUpdate();
     FileStatusListView.Columns[0].Width = FileStatusListView.ClientSize.Width;
     FileStatusListView.EndUpdate();
 }
Exemple #2
0
        private void FileStatusListView_SizeChanged(object sender, EventArgs e)
        {
            NoFiles.Size = new Size(Size.Width - 10, Size.Height - 10);
            Refresh();
            FileStatusListView.BeginUpdate();

            FileStatusListView.AutoResizeColumn(0,
                                                ColumnHeaderAutoResizeStyle.HeaderSize);
            FileStatusListView.EndUpdate();
        }
        private void FileStatusListView_SizeChanged(object sender, EventArgs e)
        {
            if (_itemsChanging)
            {
                return;
            }

            NoFiles.Location = new Point(5, 5);
            NoFiles.Size     = new Size(Size.Width - 10, Size.Height - 10);
            Refresh();
            FileStatusListView.BeginUpdate();

            FileStatusListView.AutoResizeColumn(0,
                                                ColumnHeaderAutoResizeStyle.HeaderSize);
            FileStatusListView.EndUpdate();
        }
        private void UpdateFileStatusListView(bool updateCausedByFilter = false)
        {
            if (_itemsDictionary == null || !_itemsDictionary.Any())
            {
                HandleVisibility_NoFilesLabel_FilterComboBox(filesPresent: false);
            }
            else
            {
                EnsureSelectedIndexChangeSubscription();
                HandleVisibility_NoFilesLabel_FilterComboBox(filesPresent: true);
            }
            FileStatusListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);

            var previouslySelectedItems = new List <GitItemStatus>();

            if (updateCausedByFilter)
            {
                foreach (ListViewItem Item in FileStatusListView.SelectedItems)
                {
                    previouslySelectedItems.Add((GitItemStatus)Item.Tag);
                }

                if (DataSourceChanged != null)
                {
                    DataSourceChanged(this, new EventArgs());
                }
            }

            FileStatusListView.BeginUpdate();
            FileStatusListView.ShowGroups = _itemsDictionary != null && _itemsDictionary.Count > 1;
            FileStatusListView.Groups.Clear();
            FileStatusListView.Items.Clear();
            if (_itemsDictionary != null)
            {
                var list = new List <ListViewItem>();
                foreach (var pair in _itemsDictionary)
                {
                    ListViewGroup group = null;
                    if (!String.IsNullOrEmpty(pair.Key))
                    {
                        var groupName = "";
                        if (pair.Key == CombinedDiff.Text)
                        {
                            groupName = CombinedDiff.Text;
                        }
                        else
                        {
                            string shortHash = pair.Key.Length > 8 ? pair.Key.Substring(0, 8) : pair.Key;
                            groupName = _DiffWithParent.Text + " " + shortHash;
                        }

                        group     = new ListViewGroup(groupName);
                        group.Tag = pair.Key;
                        FileStatusListView.Groups.Add(group);
                    }
                    foreach (var item in pair.Value)
                    {
                        if (_filter.IsMatch(item.Name))
                        {
                            var listItem = new ListViewItem(item.Name, group);
                            listItem.ImageIndex = GetItemImageIndex(item);
                            if (item.SubmoduleStatus != null && !item.SubmoduleStatus.IsCompleted)
                            {
                                var capturedItem = item;
                                item.SubmoduleStatus.ContinueWith((task) => listItem.ImageIndex = GetItemImageIndex(capturedItem),
                                                                  CancellationToken.None,
                                                                  TaskContinuationOptions.OnlyOnRanToCompletion,
                                                                  TaskScheduler.FromCurrentSynchronizationContext());
                            }
                            if (previouslySelectedItems.Contains(item))
                            {
                                listItem.Selected = true;
                            }
                            listItem.Tag = item;
                            list.Add(listItem);
                        }
                    }
                }
                FileStatusListView.Items.AddRange(list.ToArray());
            }
            if (updateCausedByFilter == false)
            {
                FileStatusListView_SelectedIndexChanged();
                if (DataSourceChanged != null)
                {
                    DataSourceChanged(this, new EventArgs());
                }
                if (SelectFirstItemOnSetItems)
                {
                    SelectFirstVisibleItem();
                }
            }
            FileStatusListView_SizeChanged(null, null);
            FileStatusListView.SetGroupState(ListViewGroupState.Collapsible);
            FileStatusListView.EndUpdate();
        }
 public void EndUpdate()
 {
     FileStatusListView.EndUpdate();
 }
Exemple #6
0
        private void UpdateFileStatusListView(bool updateCausedByFilter = false)
        {
            if (!GitItemStatuses.Any())
            {
                HandleVisibility_NoFilesLabel_FilterComboBox(filesPresent: false);
            }
            else
            {
                EnsureSelectedIndexChangeSubscription();
                HandleVisibility_NoFilesLabel_FilterComboBox(filesPresent: true);
            }

            FileStatusListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);

            var previouslySelectedItems = new List <GitItemStatus>();

            if (updateCausedByFilter)
            {
                foreach (ListViewItem Item in FileStatusListView.SelectedItems)
                {
                    previouslySelectedItems.Add(Item.Tag as GitItemStatus);
                }

                DataSourceChanged?.Invoke(this, new EventArgs());
            }

            FileStatusListView.BeginUpdate();
            FileStatusListView.ShowGroups = GitItemStatusesWithParents.Count > 1;
            FileStatusListView.Groups.Clear();
            FileStatusListView.Items.Clear();

            var clientSizeWidth  = AppSettings.TruncatePathMethod == "compact" || AppSettings.TruncatePathMethod == "trimstart";
            var fileNameOnlyMode = AppSettings.TruncatePathMethod == "fileNameOnly";

            var list = new List <ListViewItem>();

            foreach (var pair in GitItemStatusesWithParents)
            {
                ListViewGroup group = null;
                if (pair.Key != null)
                {
                    var groupName = "";
                    if (pair.Key.Guid == CombinedDiff.Text)
                    {
                        groupName = CombinedDiff.Text;
                    }
                    else
                    {
                        groupName = _DiffWithParent.Text + " " + GetDescriptionForRevision(pair.Key.Guid);
                    }

                    group     = new ListViewGroup(groupName);
                    group.Tag = pair.Key;
                    FileStatusListView.Groups.Add(group);
                }

                foreach (var item in pair.Value)
                {
                    if (_filter.IsMatch(item.Name))
                    {
                        var text = item.Name;
                        if (clientSizeWidth)
                        {
                            // list-item has client width, so we don't need horizontal scrollbar (which is determined by this text width)
                            text = string.Empty;
                        }
                        else if (fileNameOnlyMode)
                        {
                            // we need to put filename in list-item text -> then horizontal scrollbar
                            // will have proper width (by the longest filename, and not all path)
                            text = PathFormatter.FormatTextForFileNameOnly(item.Name, item.OldName);
                            text = AppendItemSubmoduleStatus(text, item);
                        }

                        var listItem = new ListViewItem(text, group);
                        listItem.ImageIndex = GetItemImageIndex(item);
                        if (item.SubmoduleStatus != null && !item.SubmoduleStatus.IsCompleted)
                        {
                            var capturedItem = item;
                            item.SubmoduleStatus.ContinueWith((task) => listItem.ImageIndex = GetItemImageIndex(capturedItem),
                                                              CancellationToken.None,
                                                              TaskContinuationOptions.OnlyOnRanToCompletion,
                                                              TaskScheduler.FromCurrentSynchronizationContext());
                        }

                        if (previouslySelectedItems.Contains(item))
                        {
                            listItem.Selected = true;
                        }

                        listItem.Tag = item;
                        list.Add(listItem);
                    }
                }
            }

            FileStatusListView.Items.AddRange(list.ToArray());

            if (updateCausedByFilter == false)
            {
                FileStatusListView_SelectedIndexChanged();
                DataSourceChanged?.Invoke(this, new EventArgs());
                if (SelectFirstItemOnSetItems)
                {
                    SelectFirstVisibleItem();
                }
            }

            FileStatusListView_SizeChanged(null, null);
            FileStatusListView.SetGroupState(ListViewGroupState.Collapsible);
            FileStatusListView.EndUpdate();
        }