public CommandEventArgs(VisualGitCommand command, VisualGitContext context, object argument, bool promptUser, bool dontPromptUser) : this(command, context) { _argument = argument; _promptUser = promptUser; _dontPromptUser = dontPromptUser; }
public bool TryGetParameterList(VisualGitCommand command, out string definition) { EnsureLoaded(); CommandMapItem item; if (_map.TryGetValue(command, out item)) { definition = item.ArgumentDefinition; return !string.IsNullOrEmpty(definition); } else definition = null; return false; }
public int Schedule(TimeSpan timeSpan, VisualGitCommand command) { return ScheduleAt(DateTime.Now + timeSpan, CreateHandler(command)); }
public CommandUpdateEventArgs(VisualGitCommand command, VisualGitContext context) : base(command, context) { }
public CommandAttribute(VisualGitCommand command, VisualGitCommandContext context) : this(command) { _context = context; }
bool IsTickCommand(VisualGitCommand c) { if (c < VisualGitCommand.TickFirst || c >= VisualGitCommand.TickLast) return false; return true; }
public void SafePostTickCommand(ref bool tick, VisualGitCommand command) { if (tick) return; tick = true; lock (_delayTasks) { _delayedCommands.Add((int)command); } }
public void PostIdleCommand(VisualGitCommand command, object args) { PostIdleAction( delegate() { DirectlyExecCommand(command, args); }); }
/// <summary> /// Installs a visual studio command handler for the specified control /// </summary> /// <param name="context">The context.</param> /// <param name="control">The control.</param> /// <param name="command">The command.</param> /// <param name="handler">The handler.</param> public static void Install(IVisualGitServiceProvider context, Control control, VisualGitCommand command, ICommandHandler handler) { Install(context, control, command, delegate(object sender, CommandEventArgs e) { handler.OnExecute(e); }, delegate(object sender, CommandUpdateEventArgs e) { handler.OnUpdate(e); }); }
/// <summary> /// Installs a visual studio command handler for the specified control /// </summary> /// <param name="context">The context.</param> /// <param name="control">The control.</param> /// <param name="command">The command.</param> /// <param name="handler">The handler.</param> public static void Install(IVisualGitServiceProvider context, Control control, VisualGitCommand command, EventHandler<CommandEventArgs> handler) { Install(context, control, command, handler, null); }
/// <summary> /// Installs a visual studio command handler for the specified control /// </summary> /// <param name="context">The context.</param> /// <param name="control">The control.</param> /// <param name="command">The command.</param> /// <param name="handler">The handler.</param> /// <param name="updateHandler">The update handler.</param> public static void Install(IVisualGitServiceProvider context, Control control, VisualGitCommand command, EventHandler<CommandEventArgs> handler, EventHandler<CommandUpdateEventArgs> updateHandler) { Install(context, control, new CommandID(VisualGitId.CommandSetGuid, (int)command), handler, updateHandler); }
/// <summary> /// Initializes a new instance of the <see cref="CommandMapItem"/> class. /// </summary> /// <param name="command">The command.</param> public CommandMapItem(VisualGitCommand command) { _command = command; }
internal void HandleEvent(VisualGitCommand command) { List<GitProject> dirtyProjects; HybridCollection<string> dirtyCheck; HybridCollection<string> maybeAdd; bool forceFullRefresh; VisualGitSccProvider provider = Context.GetService<VisualGitSccProvider>(); lock (_lock) { _posted = false; _onIdle = false; if (provider == null) return; dirtyProjects = _dirtyProjects; dirtyCheck = _dirtyCheck; maybeAdd = _maybeAdd; forceFullRefresh = _forceFullRefresh; _dirtyProjects = null; _dirtyCheck = null; _maybeAdd = null; _forceFullRefresh = false; } using (new FileStatusRefreshHint(forceFullRefresh)) { if (dirtyCheck != null) foreach (string file in dirtyCheck) { DocumentTracker.CheckDirty(file); } if (dirtyProjects != null) { foreach (GitProject project in dirtyProjects) { if (project.RawHandle == null) { if (project.IsSolution) provider.UpdateSolutionGlyph(); continue; // All IVsSccProjects have a RawHandle } try { project.RawHandle.SccGlyphChanged(0, null, null, null); } catch { } } } if (maybeAdd != null) { using (GitClient cl = GetService<IGitClientPool>().GetNoUIClient()) { foreach (string file in maybeAdd) { GitItem item = Cache[file]; // Only add // * files // * that are unversioned // * that are addable // * that are not ignored // * and just to be sure: that are still part of the solution if (item.IsFile && !item.IsVersioned && item.IsVersionable && !item.IsIgnored && item.InSolution) { GitAddArgs aa = new GitAddArgs(); aa.ThrowOnError = false; // Just ignore errors here; make the user add them themselves aa.AddParents = true; cl.Add(item.FullPath, aa); } } } } } }
/// <summary> /// Gets the <see cref="CommandMapItem"/> for the specified command /// </summary> /// <param name="command"></param> /// <returns>The <see cref="CommandMapItem"/> or null if the command is not valid</returns> public CommandMapItem this[VisualGitCommand command] { get { CommandMapItem item; if (_map.TryGetValue(command, out item)) return item; else { item = new CommandMapItem(command); _map.Add(command, item); return item; } } }
public bool PostExecCommand(VisualGitCommand command, object args, CommandPrompt prompt) { return PostExecCommand(new CommandID(VisualGitId.CommandSetGuid, (int)command), args, prompt); }
public CommandResult DirectlyExecCommand(VisualGitCommand command) { return DirectlyExecCommand(command, null, CommandPrompt.DoDefault); }
public void PostIdleCommand(VisualGitCommand command) { PostIdleCommand(command, null); }
public CommandResult DirectlyExecCommand(VisualGitCommand command, object args) { return DirectlyExecCommand(command, args, CommandPrompt.DoDefault); }
/// <summary> /// Posts the tick command. /// </summary> /// <param name="tick">if set to <c>true</c> [tick].</param> /// <param name="command">The command.</param> /// <returns></returns> public bool PostTickCommand(ref bool tick, VisualGitCommand command) { if (IsTickCommand(command)) _ticks[command - VisualGitCommand.TickFirst] = 1; if (tick) return false; tick = true; bool ok = false; try { return ok = PostExecCommand(command); } finally { if (!ok) tick = false; } }
public CommandResult DirectlyExecCommand(VisualGitCommand command, object args, CommandPrompt prompt) { // TODO: Assert that we are in the UI thread CommandMapper mapper = GetService<CommandMapper>(); if (mapper == null) return new CommandResult(false, null); CommandEventArgs e = new CommandEventArgs(command, VisualGitContext, args, prompt == CommandPrompt.Always, prompt == CommandPrompt.Never); bool ok = mapper.Execute(command, e); return new CommandResult(ok, e.Result); }
public void TockCommand(VisualGitCommand visualGitCommand) { if (IsTickCommand(visualGitCommand)) _ticks[visualGitCommand - VisualGitCommand.TickFirst] = 0; }
public CommandResult ExecCommand(VisualGitCommand command) { // The commandhandler in the package always checks enabled; no need to do it here return ExecCommand(command, false); }
/// <summary> /// Defines the class or function as a handler of the specified <see cref="VisualGitCommand"/> /// </summary> /// <param name="command">The command.</param> public CommandAttribute(VisualGitCommand command) { _command = command; }
public CommandResult ExecCommand(VisualGitCommand command, bool verifyEnabled) { // The commandhandler in the package always checks enabled; no need to do it here return ExecCommand(new CommandID(VisualGitId.CommandSetGuid, (int)command), verifyEnabled); }
public CommandUpdateEventArgs(VisualGitCommand command, VisualGitContext context, TextQueryType textQuery) : this(command, context) { _queryType = textQuery; }
public bool PostExecCommand(VisualGitCommand command) { return PostExecCommand(command, null, CommandPrompt.DoDefault); }
VisualGitAction CreateHandler(VisualGitCommand command) { return delegate { if (Commands != null) Commands.PostExecCommand(command); }; }
public bool PostExecCommand(VisualGitCommand command, object args) { return PostExecCommand(command, args, CommandPrompt.DoDefault); }
public int ScheduleAt(DateTime time, VisualGitCommand command) { return ScheduleAt(time, CreateHandler(command)); }
public bool PerformUpdate(VisualGitCommand command, CommandUpdateEventArgs e) { EnsureLoaded(); CommandMapItem item; if (_map.TryGetValue(command, out item)) { if (!item.AlwaysAvailable && !e.State.SccProviderActive) e.Enabled = false; else try { e.Prepare(item); item.OnUpdate(e); } catch (Exception ex) { IVisualGitErrorHandler eh = GetService<IVisualGitErrorHandler>(); if (eh != null && eh.IsEnabled(ex)) { eh.OnError(ex, e); return false; } throw; } if (item.HiddenWhenDisabled && !e.Enabled) e.Visible = false; if (item.DynamicMenuEnd) e.DynamicMenuEnd = true; return item.IsHandled; } else if (_defined.Contains(command)) { e.Enabled = e.Visible = false; return true; } return false; }