private static void FindRoot(IAnkhServiceProvider context, Uri selectedUri, CheckoutProject dlg)
        {
            AnkhAction ds = delegate
            {
                using (SvnClient client = context.GetService <ISvnClientPool>().GetClient())
                {
                    string value;
                    if (client.TryGetProperty(selectedUri, AnkhSccPropertyNames.ProjectRoot, out value))
                    {
                        if (dlg.IsHandleCreated)
                        {
                            dlg.Invoke((AnkhAction) delegate
                            {
                                try
                                {
                                    dlg.ProjectTop = new Uri(selectedUri, value);
                                }
                                catch { };
                            });
                        }
                    }
                }
            };

            ds.BeginInvoke(null, null);
        }
示例#2
0
        public int ScheduleAt(DateTime time, AnkhAction action)
        {
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            if (time.Kind == DateTimeKind.Utc)
            {
                time = time.ToLocalTime();
            }

            lock (_actions)
            {
                while (_actions.ContainsKey(time))
                {
                    time = time.Add(TimeSpan.FromMilliseconds(1));
                }

                ActionItem ai = new ActionItem(unchecked (++_nextActionId), action);

                _actions.Add(time, ai);

                Reschedule();
                return(ai.Id);
            }
        }
示例#3
0
            public void Dispose()
            {
                AnkhAction runner = _runner;

                _runner = null;
                runner();
            }
示例#4
0
        void ShowAddUriDialog()
        {
            Uri dirUri;

            /*
             * using (AddRepositoryRootDialog dlg = new AddRepositoryRootDialog())
             * {
             *  if (dlg.ShowDialog(Context) != DialogResult.OK || dlg.Uri == null)
             *      return;
             *
             *  dirUri = dlg.Uri;
             * }
             */
            using (RepositorySelectionWizard dialog = new RepositorySelectionWizard(Context))
            {
                DialogResult result = dialog.ShowDialog(Context);
                if (result != DialogResult.OK)
                {
                    return;
                }
                dirUri = dialog.GetSelectedRepositoryUri();
            }
            AnkhAction action = delegate
            {
                CheckResult(dirUri, true);
            };

            action.BeginInvoke(null, null);
        }
示例#5
0
        /// <summary>
        /// Enqueus a task for processing in the UI thread. All tasks will run in the same order as in which they are enqueued
        /// </summary>
        /// <param name="task"></param>
        void Enqueue(AnkhAction task)
        {
            if (task == null)
            {
                return;
            }

            lock (_todo)
            {
                _todo.Add(task);

                try
                {
                    if (!_queued && IsHandleCreated)
                    {
                        BeginInvoke(new AnkhAction(RunQueue));
                        _queued = true;
                    }
                }
                catch
                {
                    // Don't kill svn on a failed begin invoke
                }
            }
        }
示例#6
0
        void ProcessOk()
        {
            UpdateDirectories();

            string fileText = fileNameBox.Text;

            if (string.IsNullOrEmpty(fileText))
            {
                return;
            }

            Uri dirUri;
            Uri fileUri;

            if (Uri.TryCreate(urlBox.Text, UriKind.Absolute, out dirUri) && Uri.TryCreate(fileText, UriKind.Relative, out fileUri))
            {
                Uri combined = SvnTools.AppendPathSuffix(dirUri, SvnTools.UriPartToPath(fileText));

                AnkhAction fill = delegate()
                {
                    CheckResult(combined);
                };
                fill.BeginInvoke(null, null);
            }
        }
示例#7
0
 public DelegateRunner(AnkhAction runner)
 {
     if (runner == null)
     {
         throw new ArgumentNullException("runner");
     }
     _runner = runner;
 }
示例#8
0
        void PostCheck()
        {
            AnkhAction pt = delegate()
            {
                Thread.Sleep(50);
                SyncContext.Post(TryRelease, null);
            };

            pt.BeginInvoke(null, null);
        }
示例#9
0
        void PostCheck()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            AnkhAction pt = delegate()
            {
                Thread.Sleep(50);
                SyncContext.Post(TryRelease, null);
            };

            pt.BeginInvoke(null, null);
        }
示例#10
0
        public void PostIdleAction(AnkhAction action)
        {
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            lock (_idleActions)
            {
                _idleActions.Enqueue(action);
            }
        }
示例#11
0
        private void RefreshBox(Uri uri)
        {
            _currentUri = uri;
            dirView.Items.Clear();

            if (_walking.ContainsKey(uri))
            {
                List <ListViewItem> items = _walking[uri];

                if (items != null)
                {
                    SetView(items.ToArray());
                }
                else
                {
                    dirView.Items.Add("<loading>");
                }
            }
            else
            {
                dirView.Items.Add("<loading>");
            }


            lock (_running)
            {
                if (_running.ContainsKey(uri))
                {
                    return;
                }

                _running[uri] = uri; // Mark as walking

                if (!_loading)
                {
                    if (_busy == null)
                    {
                        _busy = new BusyOverlay(dirView, AnchorStyles.Right | AnchorStyles.Top);
                    }

                    _loading = true;
                    _busy.Show();
                }
            }

            AnkhAction fill = delegate()
            {
                OnFill(uri);
            };

            fill.BeginInvoke(null, null);
        }
示例#12
0
 public void Dispose()
 {
     using (_dlg) // Closes dialog if needed
     {
         while (_closers.Count > 0)
         {
             AnkhAction action = _closers.Pop();
             try
             {
                 action();
             }
             catch { }
         }
     }
 }
示例#13
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (Context != null)
            {
                foreach (string url in Context.GetService <IAnkhConfigurationService>().GetRecentReposUrls())
                {
                    this.urlComboBox.Items.Add(url);
                }
            }
            this.urlComboBox.Select();
            AnkhAction populateProviders = new AnkhAction(InitializeProviders);

            BeginInvoke(populateProviders);
        }
示例#14
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            syncView.Context             = Context;
            syncView.ColumnWidthChanged += new ColumnWidthChangedEventHandler(syncView_ColumnWidthChanged);
            IDictionary <string, int> widths = ConfigurationService.GetColumnWidths(GetType());

            syncView.SetColumnWidths(widths);

            _recentChangesAction = new AnkhAction(DoRefresh);

            // if solution is not open, don't auto-refresh
            IAnkhCommandStates commandState = Context.GetService <IAnkhCommandStates>();

            _solutionExists = (commandState != null && commandState.SolutionExists);
            RefreshIntervalConfigModified();
            HookHandlers();
        }
示例#15
0
 public BatchUpdateDisposer(AnkhAction action)
 {
     _action = action;
 }
示例#16
0
        internal void BrowseItem(Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            if (DesignMode)
            {
                return;
            }

            Uri nUri = SvnTools.GetNormalizedUri(uri);

            if (_running.Contains(nUri))
            {
                return;
            }

            _running.Add(nUri);

            if (_running.Count == 1)
            {
                OnRetrievingChanged(EventArgs.Empty);
            }

            AnkhAction d = delegate()
            {
                bool ok = false;
                try
                {
                    SvnListArgs la = new SvnListArgs();
                    la.RetrieveEntries = RetrieveItems;
                    la.RetrieveLocks   = RetrieveLocks;
                    la.Depth           = SvnDepth.Children;
                    la.ThrowOnError    = false;

                    Collection <SvnListEventArgs> items;
                    using (SvnClient client = Context.GetService <ISvnClientPool>().GetClient())
                    {
                        client.GetList(uri, la, out items);
                    }

                    AnkhAction addItems = (AnkhAction) delegate()
                    {
                        if (items != null && items.Count > 0)
                        {
                            bool first = true;
                            foreach (SvnListEventArgs a in items)
                            {
                                if (first)
                                {
                                    if (a.RepositoryRoot != null)
                                    {
                                        EnsureRoot(a.RepositoryRoot);
                                    }
                                }

                                AddItem(a, a.RepositoryRoot);
                                first = false;
                            }

                            MaybeExpand(uri);
                        }

                        _running.Remove(nUri);

                        if (_running.Count == 0)
                        {
                            OnRetrievingChanged(EventArgs.Empty);
                        }
                    };

                    if (IsHandleCreated)
                    {
                        BeginInvoke(addItems);
                    }
                    else
                    {
                        addItems();
                    }

                    ok = true;
                }
                finally
                {
                    if (!ok)
                    {
                        BeginInvoke((AnkhAction) delegate()
                        {
                            _running.Remove(nUri);

                            if (_running.Count == 0)
                            {
                                OnRetrievingChanged(EventArgs.Empty);
                            }
                        });
                    }
                }
            };

            d.BeginInvoke(null, null);
        }
示例#17
0
 public int Schedule(TimeSpan timeSpan, AnkhAction action)
 {
     return ScheduleAt(DateTime.Now + timeSpan, action);
 }
示例#18
0
        /// <summary>
        /// Enqueus a task for processing in the UI thread. All tasks will run in the same order as in which they are enqueued
        /// </summary>
        /// <param name="task"></param>
        void Enqueue(AnkhAction task)
        {
            if (task == null)
                return;

            lock (_todo)
            {
                _todo.Add(task);

                try
                {
                    if (!_queued && IsHandleCreated)
                    {
                        BeginInvoke(new AnkhAction(RunQueue));
                        _queued = true;
                    }
                }
                catch
                {
                    // Don't kill svn on a failed begin invoke
                }
            }
        }
示例#19
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            syncView.Context = Context;
            syncView.ColumnWidthChanged += new ColumnWidthChangedEventHandler(syncView_ColumnWidthChanged);
            IDictionary<string, int> widths = ConfigurationService.GetColumnWidths(GetType());
            syncView.SetColumnWidths(widths);

            _recentChangesAction = new AnkhAction(DoRefresh);

            // if solution is not open, don't auto-refresh
            IAnkhCommandStates commandState = Context.GetService<IAnkhCommandStates>();
            _solutionExists = (commandState != null && commandState.SolutionExists);
            RefreshIntervalConfigModified();
            HookHandlers();
        }
示例#20
0
 public IDisposable BatchUpdate(AnkhAction doneHandler)
 {
     return(new BatchUpdateDisposer(doneHandler));
 }
示例#21
0
 public int Schedule(TimeSpan timeSpan, AnkhAction action)
 {
     return(ScheduleAt(DateTime.Now + timeSpan, action));
 }
示例#22
0
 public ActionItem(int id, AnkhAction action)
 {
     Id = id;
     Action = action;
 }
示例#23
0
        public void PostIdleAction(AnkhAction action)
        {
            if (action == null)
                throw new ArgumentNullException("action");

            lock (_idleActions)
            {
                _idleActions.Enqueue(action);
            }
        }
示例#24
0
        public int ScheduleAt(DateTime time, AnkhAction action)
        {
            if (action == null)
                throw new ArgumentNullException("action");

            if (time.Kind == DateTimeKind.Utc)
                time = time.ToLocalTime();

            lock (_actions)
            {
                while (_actions.ContainsKey(time))
                    time = time.Add(TimeSpan.FromMilliseconds(1));

                ActionItem ai = new ActionItem(unchecked(++_nextActionId), action);

                _actions.Add(time, ai);

                Reschedule();
                return ai.Id;
            }
        }
示例#25
0
 public ActionItem(int id, AnkhAction action)
 {
     Id     = id;
     Action = action;
 }