コード例 #1
0
        /// <summary>
        /// Shows the log viewer and sets the revision cell value to the selected revision
        /// </summary>
        /// <param name="row"></param>
        private void SelectRevision(DataGridViewRow row)
        {
            IAnkhServiceProvider context = Context;

            if (context != null)
            {
                string selectedUriString = row.Cells[0].Value as string;

                Uri selectedUri;
                if (!string.IsNullOrEmpty(selectedUriString) &&
                    Uri.TryCreate(selectedUriString, UriKind.Absolute, out selectedUri)
                    )
                {
                    Uri repoRoot = string.Equals(_lastUsedUriString, selectedUriString) ? _lastRepositoryRoot : null;
                    if (repoRoot == null)
                    {
                        if (context.GetService <IProgressRunner>().RunModal(
                                PropertyEditStrings.RetrievingRepositoryRoot,
                                delegate(object sender, ProgressWorkerArgs a)
                        {
                            repoRoot = a.Client.GetRepositoryRoot(selectedUri);
                        }).Succeeded)
                        {
                            //cache the last used repo uri string and the fetched repository root uri
                            _lastRepositoryRoot = repoRoot;
                            _lastUsedUriString  = selectedUriString;
                        }
                    }
                    if (repoRoot != null)
                    {
                        try
                        {
                            // set the current revision value as the initial selection
                            string             rev       = row.Cells[2].Value as string;
                            SvnRevision        rr        = string.IsNullOrEmpty(rev) ? SvnRevision.None : long.Parse(rev);
                            SvnUriTarget       svnTarget = new SvnUriTarget(selectedUri, rr);
                            Ankh.Scc.SvnOrigin origin    = new Ankh.Scc.SvnOrigin(svnTarget, repoRoot);
                            using (Ankh.UI.SvnLog.LogViewerDialog dlg = new Ankh.UI.SvnLog.LogViewerDialog(origin))
                            {
                                if (dlg.ShowDialog(Context) == DialogResult.OK)
                                {
                                    Ankh.Scc.ISvnLogItem li = EnumTools.GetSingle(dlg.SelectedItems);
                                    rev = li == null ? null : li.Revision.ToString();
                                    //set the revision cell value to the selection revision
                                    row.Cells[2].Value = rev ?? string.Empty;
                                }
                            }
                        }
                        catch
                        {
                            // clear cache in case of error
                            _lastUsedUriString  = null;
                            _lastRepositoryRoot = null;
                        }
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Shows the log viewer and sets the revision cell value to the selected revision
        /// </summary>
        /// <param name="row"></param>
        private void SelectRevision(DataGridViewRow row)
        {
            IAnkhServiceProvider context = Context;
            if (context != null)
            {
                string selectedUriString = row.Cells[0].Value as string;

                Uri selectedUri;
                if (!string.IsNullOrEmpty(selectedUriString)
                    && Uri.TryCreate(selectedUriString, UriKind.Absolute, out selectedUri)
                    )
                {
                    Uri repoRoot = string.Equals(_lastUsedUriString, selectedUriString) ? _lastRepositoryRoot : null;
                    if (repoRoot == null)
                    {
                        if (context.GetService<IProgressRunner>().RunModal(
                            "Retrieving Repository Root",
                            delegate(object sender, ProgressWorkerArgs a)
                            {
                                repoRoot = a.Client.GetRepositoryRoot(selectedUri);

                            }).Succeeded)
                        {
                            //cache the last used repo uri string and the fetched repository root uri
                            _lastRepositoryRoot = repoRoot;
                            _lastUsedUriString = selectedUriString;
                        }
                    }
                    if (repoRoot != null)
                    {
                        try
                        {
                            // set the current revision value as the initial selection
                            string rev = row.Cells[2].Value as string;
                            SvnRevision rr = string.IsNullOrEmpty(rev) ? SvnRevision.None : long.Parse(rev);
                            SvnUriTarget svnTarget = new SvnUriTarget(selectedUri, rr);
                            Ankh.Scc.SvnOrigin origin = new Ankh.Scc.SvnOrigin(svnTarget, repoRoot);
                            using (Ankh.UI.SvnLog.LogViewerDialog dlg = new Ankh.UI.SvnLog.LogViewerDialog(origin))
                            {
                                if (dlg.ShowDialog(Context) == DialogResult.OK)
                                {
                                    Ankh.Scc.ISvnLogItem li = EnumTools.GetSingle(dlg.SelectedItems);
                                    rev = li == null ? null : li.Revision.ToString();
                                    //set the revision cell value to the selection revision
                                    row.Cells[2].Value = rev ?? string.Empty;
                                }
                            }
                        }
                        catch
                        {
                            // clear cache in case of error
                            _lastUsedUriString = null;
                            _lastRepositoryRoot = null;
                        }
                    }
                }
            }
        }