예제 #1
0
 // ------------------------------------------------------------------------
 // status item sorter callback routine
 // ------------------------------------------------------------------------
 public int compareInfoItem(HGLib.HGFileStatusInfo a, HGLib.HGFileStatusInfo b)
 {
     if (_SortOrder == SortOrder.Ascending)
     {
         if (_previouslySortedColumn <= 0)
         {
             return(a.fileName.CompareTo(b.fileName));
         }
         else if (_previouslySortedColumn == 1)
         {
             return(a.fullPath.CompareTo(b.fullPath));
         }
     }
     else
     {
         if (_previouslySortedColumn <= 0)
         {
             return(b.fileName.CompareTo(b.fileName));
         }
         else if (_previouslySortedColumn == 1)
         {
             return(b.fullPath.CompareTo(b.fullPath));
         }
     }
     return(0);
 }
예제 #2
0
        // ------------------------------------------------------------------------
        // Manages the cache. ListView calls this when it might need a
        // cache refresh.
        // ------------------------------------------------------------------------
        void this_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e)
        {
            //We've gotten a request to refresh the cache.
            //First check if it's really neccesary.
            if (_cache != null && e.StartIndex >= _firstItem && e.EndIndex <= _firstItem + _cache.Length)
            {
                //If the newly requested cache is a subset of the old cache,
                //no need to rebuild everything, so do nothing.
                return;
            }

            // now we need to rebuild the cache.
            _firstItem = e.StartIndex;
            int length = e.EndIndex - e.StartIndex + 1; //indexes are inclusive

            _cache = new ListViewItem[length];

            for (int i = 0; i < length; i++)
            {
                int index = (i + _firstItem);
                if (index < _list.Count)
                {
                    HGLib.HGFileStatusInfo info = _list[index];
                    ListViewItem           item = new ListViewItem(info.fileName);
                    item.ImageIndex = GetStateIcon(info.status);
                    item.SubItems.Add(info.fullPath);
                    _cache[i] = item;
                }
            }
        }
예제 #3
0
 // ------------------------------------------------------------------------
 // annotate selected file
 // ------------------------------------------------------------------------
 private void OnAnnotateSelectedFile(object sender, EventArgs e)
 {
     if (_pendingItemsListView.SelectedIndices.Count == 1)
     {
         int index = _pendingItemsListView.SelectedIndices[0];
         HGLib.HGFileStatusInfo info = _pendingItemsListView._list[index];
         SccProvider.Provider.HgAnnotateDlg(info.fullPath);
     }
 }
예제 #4
0
 // ------------------------------------------------------------------------
 // store current selected items to a map
 // ------------------------------------------------------------------------
 void StoreSelection(out Dictionary <string, int> selection)
 {
     selection = new Dictionary <string, int>();
     foreach (int index in SelectedIndices)
     {
         HGLib.HGFileStatusInfo info = _list[index];
         selection.Add(info.fullPath, 0);
     }
 }
예제 #5
0
        // ------------------------------------------------------------------------
        // revert dialog for selected files
        // ------------------------------------------------------------------------
        private void OnRevertSelectedFile(object sender, EventArgs e)
        {
            List <string> array = new List <string>();

            foreach (int index in _pendingItemsListView.SelectedIndices)
            {
                HGLib.HGFileStatusInfo info = _pendingItemsListView._list[index];
                array.Add(info.fullPath);
            }

            SccProvider.Provider.HgRevertFileDlg(array.ToArray());
        }
예제 #6
0
        // ------------------------------------------------------------------------
        // commit dialog for selected files
        // ------------------------------------------------------------------------
        private void OnCommitSelectedFiles(object sender, EventArgs e)
        {
            List <string> array = new List <string>();

            foreach (int index in _pendingItemsListView.SelectedIndices)
            {
                HGLib.HGFileStatusInfo info = _pendingItemsListView._list[index];
                array.Add(info.fullPath);
            }

            SccProvider.Provider.CommitDialog(array);
        }
예제 #7
0
 // ------------------------------------------------------------------------
 // open selected files in the editor
 // ------------------------------------------------------------------------
 void OpenSelectedFiles()
 {
     foreach (int index in _pendingItemsListView.SelectedIndices)
     {
         HGLib.HGFileStatusInfo info = _pendingItemsListView._list[index];
         try
         {
             VsShellUtilities.OpenDocument(SccProvider.Provider, info.fullPath);
         }
         catch (Exception e)
         {
             MessageBox.Show(e.Message, "Open File failed");
         }
     }
 }
예제 #8
0
 // ------------------------------------------------------------------------
 // Dynamically returns a ListViewItem with the required properties;
 // ------------------------------------------------------------------------
 void this_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
 {
     //check to see if the requested item is currently in the cache
     if (_cache != null && e.ItemIndex >= _firstItem && e.ItemIndex < _firstItem + _cache.Length)
     {
         //A cache hit, so get the ListViewItem from the cache instead of making a new one.
         e.Item = _cache[e.ItemIndex - _firstItem];
     }
     else
     {
         //A cache miss, so create a new ListViewItem and pass it back.
         if (e.ItemIndex < _list.Count)
         {
             HGLib.HGFileStatusInfo info = _list[e.ItemIndex];
             e.Item            = new ListViewItem(info.fileName);
             e.Item.ImageIndex = GetStateIcon(info.status);
             e.Item.SubItems.Add(info.fullPath);
         }
     }
 }
예제 #9
0
        // ------------------------------------------------------------------------
        // update menu flags on list selection changed event
        private void _pendingItemsListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            // enable menu commands
            bool singleSel = false;

            HGLib.HGFileStatus status = HGLib.HGFileStatus.scsUncontrolled;
            if (_pendingItemsListView.SelectedIndices.Count > 0)
            {
                singleSel = (_pendingItemsListView.SelectedIndices.Count == 1) ? true : false;
                int index = _pendingItemsListView.SelectedIndices[0];
                HGLib.HGFileStatusInfo info = _pendingItemsListView._list[index];
                status = info.status;
            }

            annotateFileToolStripMenuItem.Visible = singleSel && status != HGLib.HGFileStatus.scsAdded &&
                                                    status != HGLib.HGFileStatus.scsRemoved &&
                                                    status != HGLib.HGFileStatus.scsRenamed;
            diffToolStripMenuItem.Visible = singleSel && status != HGLib.HGFileStatus.scsRemoved &&
                                            status != HGLib.HGFileStatus.scsAdded;
            historyToolStripMenuItem.Visible = singleSel && status != HGLib.HGFileStatus.scsAdded &&
                                               status != HGLib.HGFileStatus.scsRenamed;
            openInEditorToolStripMenuItem.Visible = status != HGLib.HGFileStatus.scsRemoved;
        }