Example #1
0
 private void ReinsertFakeItems(IGraphBuilder<Revision> builder)
 {
     int fakeItems = 0;
     int graphLength = 0;
     if(_stagedItem != null)
     {
         if(_currentIndex != -1)
         {
             Items.Insert(_currentIndex, _stagedItem);
             ++_currentIndex;
             _stagedItem.Graph = builder.AddGraphLineToTop(_currentRevisionItem.Graph);
             graphLength = _stagedItem.Graph.Length;
             ++fakeItems;
         }
         else if(_repository.IsEmpty)
         {
             Items.Insert(0, _stagedItem);
             _stagedItem.Graph = builder.AddGraphLineToTop(null);
             graphLength = _stagedItem.Graph.Length;
             ++fakeItems;
         }
         else
         {
             _stagedItem = null;
         }
     }
     if(_unstagedItem != null)
     {
         if(_currentIndex != -1)
         {
             if(_stagedItem != null)
             {
                 Items.Insert(_currentIndex - 1, _unstagedItem);
             }
             else
             {
                 Items.Insert(_currentIndex, _unstagedItem);
             }
             ++_currentIndex;
             if(_unstagedItem != null && _stagedItem != null)
             {
                 _unstagedItem.Graph = builder.AddGraphLineToTop(_stagedItem.Graph);
             }
             else
             {
                 if(_currentRevisionItem != null)
                 {
                     _unstagedItem.Graph = builder.AddGraphLineToTop(_currentRevisionItem.Graph);
                 }
                 else
                 {
                     _unstagedItem.Graph = builder.AddGraphLineToTop(null);
                 }
             }
             if(_unstagedItem.Graph.Length > graphLength)
             {
                 graphLength = _unstagedItem.Graph.Length;
             }
             ++fakeItems;
         }
         else if(_repository.IsEmpty)
         {
             Items.Insert(0, _unstagedItem);
             if(_unstagedItem != null && _stagedItem != null)
             {
                 _unstagedItem.Graph = builder.AddGraphLineToTop(_stagedItem.Graph);
             }
             else
             {
                 if(_currentRevisionItem != null)
                 {
                     _unstagedItem.Graph = builder.AddGraphLineToTop(_currentRevisionItem.Graph);
                 }
                 else
                 {
                     _unstagedItem.Graph = builder.AddGraphLineToTop(null);
                 }
             }
             if(_unstagedItem.Graph.Length > graphLength)
             {
                 graphLength = _unstagedItem.Graph.Length;
             }
             ++fakeItems;
         }
         else
         {
             _unstagedItem = null;
         }
     }
     if(fakeItems != 0)
     {
         graphLength *= 21;
         var graphColumn = GraphColumn;
         if(graphColumn != null)
         {
             if(graphColumn.Width < graphLength)
             {
                 graphColumn.Width = graphLength;
             }
             else
             {
                 graphColumn.AutoSize();
             }
         }
     }
 }
Example #2
0
 private void VerifyFakeItemsAfterStatusUpdate(Status status)
 {
     if(_showStatusItems && (_currentIndex != -1 || status.Repository.IsEmpty))
     {
         var builder = GlobalBehavior.GraphBuilderFactory.CreateGraphBuilder<Revision>();
         bool showStaged = status.StagedFiles.Count != 0;
         bool showUnstaged = status.UnstagedFiles.Count != 0;
         int changes = 0;
         if(showUnstaged)
         {
             if(_unstagedItem == null) ++changes;
         }
         else
         {
             if(_unstagedItem != null) ++changes;
         }
         if(showStaged)
         {
             if(_stagedItem == null) ++changes;
         }
         else
         {
             if(_stagedItem != null) ++changes;
         }
         if(changes != 0)
         {
             BeginUpdate();
             if(showStaged)
             {
                 if(_stagedItem == null)
                 {
                     _stagedItem = new FakeRevisionListItem(status.Repository, FakeRevisionItemType.StagedChanges);
                     if(_currentIndex >= 0)
                     {
                         Items.Insert(_currentIndex, _stagedItem);
                         ++_currentIndex;
                     }
                     else
                     {
                         if(showUnstaged && _unstagedItem != null)
                         {
                             Items.Insert(1, _stagedItem);
                         }
                         else
                         {
                             Items.Insert(0, _stagedItem);
                         }
                     }
                 }
                 if(showUnstaged)
                 {
                     if(_unstagedItem == null)
                     {
                         _unstagedItem = new FakeRevisionListItem(status.Repository, FakeRevisionItemType.UnstagedChanges);
                         if(_currentIndex >= 0)
                         {
                             Items.Insert(_currentIndex - 1, _unstagedItem);
                             ++_currentIndex;
                         }
                         else
                         {
                             Items.Insert(0, _unstagedItem);
                         }
                     }
                 }
                 else
                 {
                     if(_unstagedItem != null)
                     {
                         _unstagedItem.Remove();
                         _unstagedItem = null;
                         if(_currentIndex != -1)
                         {
                             --_currentIndex;
                         }
                     }
                 }
             }
             else
             {
                 if(_stagedItem != null)
                 {
                     _stagedItem.Remove();
                     _stagedItem = null;
                     if(_currentIndex != -1)
                     {
                         --_currentIndex;
                     }
                 }
                 if(showUnstaged)
                 {
                     if(_unstagedItem == null)
                     {
                         _unstagedItem = new FakeRevisionListItem(status.Repository, FakeRevisionItemType.UnstagedChanges);
                         if(_currentIndex >= 0)
                         {
                             Items.Insert(_currentIndex, _unstagedItem);
                             ++_currentIndex;
                         }
                         else
                         {
                             Items.Insert(0, _unstagedItem);
                         }
                     }
                 }
                 else
                 {
                     if(_unstagedItem != null)
                     {
                         _unstagedItem.Remove();
                         _unstagedItem = null;
                         if(_currentIndex != -1)
                         {
                             --_currentIndex;
                         }
                     }
                 }
             }
             int fakeitems = 0;
             if(_stagedItem != null) ++fakeitems;
             if(_unstagedItem != null) ++fakeitems;
             if(_currentIndex != -1)
             {
                 if(_currentIndex == fakeitems)
                 {
                     builder.CleanGraph(_currentRevisionItem.Graph);
                 }
                 else
                 {
                     var prev = ((RevisionListItem)Items[_currentIndex - fakeitems - 1]).Graph;
                     var next = ((RevisionListItem)Items[_currentIndex]).Graph;
                     builder.CleanGraph(prev, next);
                 }
             }
             if(_stagedItem != null)
             {
                 _stagedItem.Graph = builder.AddGraphLineToTop(
                     _currentRevisionItem == null ? null : _currentRevisionItem.Graph);
                 if(_unstagedItem != null)
                 {
                     _unstagedItem.Graph = builder.AddGraphLineToTop(_stagedItem.Graph);
                 }
             }
             else
             {
                 if(_unstagedItem != null)
                 {
                     _unstagedItem.Graph = builder.AddGraphLineToTop(
                         _currentRevisionItem == null ? null : _currentRevisionItem.Graph);
                 }
             }
             var graphColumn = GraphColumn;
             if(graphColumn != null)
             {
                 graphColumn.AutoSize();
             }
             EndUpdate();
         }
     }
 }
Example #3
0
 private int CheckNeedOfFakeItems()
 {
     bool needStaged = false;
     bool needUnstaged = false;
     if(_repository != null && _showStatusItems)
     {
         if(_currentRevisionItem != null || _repository.IsEmpty)
         {
             if(_repository.Status.StagedFiles.Count != 0)
             {
                 needStaged = true;
             }
             if(_repository.Status.UnstagedFiles.Count != 0)
             {
                 needUnstaged = true;
             }
         }
     }
     int count = 0;
     if(needStaged)
     {
         if(_stagedItem == null)
         {
             _stagedItem = new FakeRevisionListItem(_repository, FakeRevisionItemType.StagedChanges);
         }
         ++count;
     }
     else
     {
         _stagedItem = null;
     }
     if(needUnstaged)
     {
         if(_unstagedItem == null)
         {
             _unstagedItem = new FakeRevisionListItem(_repository, FakeRevisionItemType.UnstagedChanges);
         }
         ++count;
     }
     else
     {
         _unstagedItem = null;
     }
     return count;
 }