forked from yysun/Git-Source-Control-Provider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SccOnIdleEvent.cs
77 lines (66 loc) · 2.83 KB
/
SccOnIdleEvent.cs
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
using System;
using Microsoft.VisualStudio.OLE.Interop;
using System.Runtime.InteropServices;
namespace GitScc
{
// ------------------------------------------------------------------------
// IOleComponent OnIdle trigger
// ------------------------------------------------------------------------
public delegate void OnIdleEvent();
class SccOnIdleEvent : IOleComponent
{
uint _wComponentID = 0;
IOleComponentManager _cmService = null;
public event OnIdleEvent OnIdleEvent;
public void RegisterForIdleTimeCallbacks(IOleComponentManager cmService)
{
_cmService = cmService;
if (_cmService != null)
{
OLECRINFO[] pcrinfo = new OLECRINFO[1];
pcrinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO));
pcrinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime |
(uint)_OLECRF.olecrfNeedPeriodicIdleTime;
pcrinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal |
(uint)_OLECADVF.olecadvfRedrawOff |
(uint)_OLECADVF.olecadvfWarningsOff;
pcrinfo[0].uIdleTimeInterval = 100;
_cmService.FRegisterComponent(this, pcrinfo, out _wComponentID);
}
}
public void UnRegisterForIdleTimeCallbacks()
{
if (_cmService != null)
_cmService.FRevokeComponent(_wComponentID);
}
public virtual int FContinueMessageLoop(uint uReason, IntPtr pvLoopData, MSG[] pMsgPeeked)
{ return 1; }
/// <summary>
/// Idle processing trigger method
/// </summary>
public virtual int FDoIdle(uint grfidlef)
{
if (OnIdleEvent != null)
OnIdleEvent();
return 0;
}
public virtual int FPreTranslateMessage(MSG[] pMsg)
{ return 0; }
public virtual int FQueryTerminate(int fPromptUser)
{ return 1; }
public virtual int FReserved1(uint dwReserved, uint message, IntPtr wParam, IntPtr lParam)
{ return 0; }
public virtual IntPtr HwndGetWindow(uint dwWhich, uint dwReserved)
{ return IntPtr.Zero; }
public virtual void OnActivationChange(IOleComponent pic, int fSameComponent, OLECRINFO[] pcrinfo, int fHostIsActivating, OLECHOSTINFO[] pchostinfo, uint dwReserved)
{ ; }
public virtual void OnAppActivate(int fActive, uint dwOtherThreadID)
{ ; }
public virtual void OnEnterState(uint uStateID, int fEnter)
{ ; }
public virtual void OnLoseActivation()
{ ; }
public virtual void Terminate()
{ ; }
}
}