Esempio n. 1
0
        private void MBtn_Click(object sender, EventArgs e)
        {
            // Remove Selected rows
            if (_selectedCheckBoxCount > 0)
            {
                if (MetroMessageBox.Show(this, "Are you sure you want to delete these record(s) ?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    for (int index = mGrid.Rows.Count - 1; index >= 0; index--)
                    {
                        if ((bool)mGrid.Rows[index].Cells[0].FormattedValue)
                        {
                            gitTrayTableBindingSource.RemoveAt(index);
                            _selectedCheckBoxCount--;
                        }
                    }

                    if (_changeIcon == true)
                    {
                        this.mAddBtn.Visible   = false;
                        this.mAddBtn.TileImage = global::GitTray.Properties.Resources.add;
                        this.mAddBtn.Visible   = true;

                        _changeIcon = false;
                    }
                }
            }

            //Add local repo
            else
            {
                var odir = new RepositoryExplorerUI
                {
                    Owner = this
                };
                odir.ShowDialog(this);

                if (odir.SubModules != null && odir.SubModules.Count > 0)
                {
                    foreach (var submodule in odir.SubModules)
                    {
                        var fullPath = String.Format(@"{0}/{1}", odir.Path, submodule);
                        GitTrayDataSet.GitTrayTableRow newItem = CreateTabEntry(fullPath);
                        this.gitTrayDataSet.GitTrayTable.AddGitTrayTableRow(newItem);
                        gitTrayTableBindingSource.MoveLast();
                    }
                }
                else if (!string.IsNullOrEmpty(odir.Path))
                {
                    GitTrayDataSet.GitTrayTableRow newItem = CreateTabEntry(odir.Path);

                    this.gitTrayDataSet.GitTrayTable.AddGitTrayTableRow(newItem);
                    gitTrayTableBindingSource.MoveLast();
                }
            }
        }
Esempio n. 2
0
        private void GitTrayNotification(object source, ElapsedEventArgs e)
        {
            TrayTimer.Stop();

            for (int index = 0; index < gitTrayDataSet.GitTrayTable.Rows.Count; index++)
            {
                if (IsTableRefreshed == true)
                {
                    IsTableRefreshed = false; //Reset the flag
                    _statusHolder.Clear();    //Remove all entries
                    break;                    // break the loop
                }

                if (_trayStatus == GitTrayStatusType.Stopped || _trayStatus == GitTrayStatusType.Sleep)
                {
                    break; // break the loop
                }

                GitTrayDataSet.GitTrayTableRow currRow = (GitTrayDataSet.GitTrayTableRow)gitTrayDataSet.GitTrayTable.Rows[index];

                string gitFetchResult = string.Empty;
                string gitStatus      = string.Empty;
                string gerritResult   = string.Empty;

                currRow.Activity = "Running"; /* Start Processing the row */

                #region Setup Threads
                Thread gitThread = new Thread(() => gitFetchResult = GitExtensions.ProcessGitRepo(ref gitStatus, currRow.Path))
                {
                    IsBackground = true
                };
                #endregion

                gitThread.Start();

                #region Git Status
                gitThread.Join();
                currRow.Git_Status = gitStatus;
                if (!string.IsNullOrEmpty(gitFetchResult) && IsTableRefreshed == false)
                {
                    bool isPresent = false;
                    if (_statusHolder.ContainsKey(currRow.Path))
                    {
                        if (gitFetchResult.Equals(_statusHolder[currRow.Path][0]))
                        {
                            isPresent = true;
                        }
                        else
                        {
                            _statusHolder[currRow.Path][0] = gitFetchResult;
                        }
                    }

                    if (isPresent == false && gitFetchResult.Contains("fatal:"))
                    {
                        //GitTray.ShowBalloonTip(1000, "Error", gitFetchResult, ToolTipIcon.Error);
                    }
                    else if (isPresent == false)
                    {
                        GitTray.ShowBalloonTip(1000, "New Software Available!", gitFetchResult, ToolTipIcon.Info);
                    }
                    else
                    {
                        //skip
                    }
                }
                #endregion

                currRow.Activity = "Sleeping"; /* Processing completed */

                if (!_statusHolder.ContainsKey(currRow.Path))
                {
                    _statusHolder.Add(currRow.Path, new List <string> {
                        gitFetchResult, gerritResult
                    });
                }
            }

            if (_trayStatus == GitTrayStatusType.Running)
            {
                //Restart the timer if user has not requested to stop/halt
                TrayTimer.Start();
            }
            else
            {
                _trayStatus = GitTrayStatusType.Sleep;
            }
        }