forked from yysun/Git-Source-Control-Provider
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPendingChangesToolWindow.cs
More file actions
88 lines (69 loc) · 3.35 KB
/
PendingChangesToolWindow.cs
File metadata and controls
88 lines (69 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using Microsoft.Win32;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using IServiceProvider = System.IServiceProvider;
using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
using Microsoft.VisualStudio;
using System.Collections.Generic;
namespace GitScc
{
/// <summary>
/// Summary description for SccProviderToolWindow.
/// </summary>
[Guid("75EDECF4-68D8-4B7B-92A9-5915461DA6D9")]
public class PendingChangesToolWindow : ToolWindowPane
{
private PendingChangesView control;
public PendingChangesToolWindow()
: base(null)
{
// set the window title
this.Caption = Resources.ResourceManager.GetString("PendingChangesToolWindowCaption");
//// set the CommandID for the window ToolBar
this.ToolBar = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.imnuPendingChangesToolWindowToolbarMenu);
// set the icon for the frame
this.BitmapResourceID = CommandId.ibmpToolWindowsImages; // bitmap strip resource ID
this.BitmapIndex = CommandId.iconSccProviderToolWindow; // index in the bitmap strip
control = new PendingChangesView();
// This is the user control hosted by the tool window; Note that, even if this class implements IDisposable,
// we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on
// the object returned by the Content property.
base.Content = control;
OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
var cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdPendingChangesCommit);
var menu = new MenuCommand(new EventHandler(OnCommitCommand), cmd);
mcs.AddCommand(menu);
cmd = new CommandID(GuidList.guidSccProviderCmdSet, CommandId.icmdPendingChangesAmend);
menu = new MenuCommand(new EventHandler(OnAmendCommitCommand), cmd);
mcs.AddCommand(menu);
var sccProviderService = BasicSccProvider.GetServiceEx<SccProviderService>();
if (sccProviderService != null)
{
Refresh(sccProviderService.CurrentTracker);
}
}
private void OnCommitCommand(object sender, EventArgs e)
{
control.Commit();
}
private void OnAmendCommitCommand(object sender, EventArgs e)
{
control.AmendCommit();
}
internal void Refresh(GitFileStatusTracker tracker)
{
//if (((IVsWindowFrame)this.Frame).IsVisible() == VSConstants.S_FALSE) return;
control.Refresh(tracker);
var repository = (tracker == null || !tracker.HasGitRepository) ? " (no repository)" :
string.Format(" - {1} - ({0})", tracker.CurrentBranch, tracker.GitWorkingDirectory);
this.Caption = Resources.ResourceManager.GetString("PendingChangesToolWindowCaption") + repository;
}
}
}