コード例 #1
0
        private static void PollingTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            var wndTitles = new List <string>();

            Win32API.EnumWindows((IntPtr hWnd, IntPtr lparam) =>
            {
                var wndTextLen = Win32API.GetWindowTextLength(hWnd);
                if (0 < wndTextLen)
                {
                    var wndText = new StringBuilder(wndTextLen + 1);
                    Win32API.GetWindowText(hWnd, wndText, wndText.Capacity);
                    wndTitles.Add(wndText.ToString());
                }
                return(true);
            }, IntPtr.Zero);

            var latestTgitStatus = new TGitWndStatus
            {
                ExistsCommitWnd   = wndTitles.Any(title => Regex.IsMatch(title, @" - Commit - TortoiseGit$")),
                ExistsProgressWnd = wndTitles.Any(title => Regex.IsMatch(title, @" - Git Command Progress - TortoiseGit$"))
            };

            var statusChanged = !latestTgitStatus.Equals(CurrentTGitWndStatus);

            if (statusChanged)
            {
                TGitWndStatusChanged?.Invoke(null, new TGitWndStatusChangedEventArgs(CurrentTGitWndStatus, latestTgitStatus));
                CurrentTGitWndStatus = latestTgitStatus;
            }
        }
コード例 #2
0
 public TGitWndStatusChangedEventArgs(TGitWndStatus prevStatus, TGitWndStatus currentStatus)
 {
     this.PrevStatus    = prevStatus;
     this.CurrentStatus = currentStatus;
 }