private void OnTreeViewShowContextMenu(object sender, MouseEventArgs e) { if (Context == null) { return; } Point screen; if (e.X == -1 && e.Y == -1) { screen = treeView.GetSelectionPoint(); if (screen.IsEmpty) { return; } } else { screen = e.Location; } IAnkhCommandService cs = Context.GetService <IAnkhCommandService>(); cs.ShowContextMenu(AnkhCommandMenu.RepositoryExplorerContextMenu, screen.X, screen.Y); }
void OnExited(object sender, EventArgs e) { Process process = sender as Process; IAnkhCommandService cmd = GetService <IAnkhCommandService>(); if (cmd != null) { cmd.PostIdleAction(Dispose); } else { Dispose(); } if (process != null && _resolvedExitCodes != null) { foreach (int ec in _resolvedExitCodes) { if (ec == process.ExitCode) { cmd.PostIdleAction(MarkResolved); break; } } } IFileStatusMonitor m = GetService <IFileStatusMonitor>(); if (m != null) { m.ScheduleSvnStatus(_toMonitor); } }
public override void OnShowContextMenu(MouseEventArgs e) { base.OnShowContextMenu(e); if (Context == null) { return; } Point screen; bool isHeaderContextMenu = false; if (e.X == -1 && e.Y == -1) { if (SelectedItems.Count > 0) { screen = PointToScreen(SelectedItems[SelectedItems.Count - 1].Position); } else { screen = PointToScreen(new Point(1, 1)); isHeaderContextMenu = true; } } else { isHeaderContextMenu = PointToClient(e.Location).Y < HeaderHeight; screen = e.Location; } IAnkhCommandService cs = Context.GetService <IAnkhCommandService>(); cs.ShowContextMenu(isHeaderContextMenu ? AnkhCommandMenu.ListViewHeader : AnkhCommandMenu.LogChangedPathsContextMenu, screen); }
private void OnContextMenuOpening(object sender, ContextMenuEventArgs e) { e.Handled = true; UIElement el = e.OriginalSource as UIElement ?? PendingChangesList; Point wp = el.PointToScreen(new Point(e.CursorLeft, e.CursorTop)); WinPoint p = new WinPoint((int)wp.X, (int)wp.Y); bool showSort = false; if (PendingChangesList.ContainerFromElement(el) == null) { showSort = true; } IAnkhCommandService mcs = Context.GetService <IAnkhCommandService>(); if (mcs != null) { if (showSort) { mcs.ShowContextMenu(AnkhCommandMenu.PendingCommitsHeaderContextMenu, p); } else { mcs.ShowContextMenu(AnkhCommandMenu.PendingCommitsContextMenu, p); } } }
private void ShowContextMenu() { Point p = MousePosition; if (_context != null) { IAnkhCommandService cs = _context.GetService <IAnkhCommandService>(); cs.ShowContextMenu(AnkhCommandMenu.AnnotateContextMenu, p.X, p.Y); } }
private static void AutoOpenCommand(CommandEventArgs e, SvnOrigin origin) { IAnkhCommandService svc = e.GetService <IAnkhCommandService>(); IAnkhSolutionSettings solutionSettings = e.GetService <IAnkhSolutionSettings>(); if (svc == null || solutionSettings == null) { return; } // Ok, we can assume we have a file string filename = origin.Target.FileName; string ext = Path.GetExtension(filename); if (string.IsNullOrEmpty(ext)) { // No extension -> Open as text svc.PostExecCommand(AnkhCommand.ViewInVsText); return; } foreach (string projectExt in solutionSettings.AllProjectExtensionsFilter.Split(';')) { if (projectExt.TrimStart('*').Trim().Equals(ext, StringComparison.OrdinalIgnoreCase)) { // We found a project or solution, use Open from Subversion to create a checkout svc.PostExecCommand(AnkhCommand.FileFileOpenFromSubversion, origin); return; } } bool odd = false; foreach (string block in solutionSettings.OpenFileFilter.Split('|')) { odd = !odd; if (odd) { continue; } foreach (string itemExt in block.Split(';')) { if (itemExt.TrimStart('*').Trim().Equals(ext, StringComparison.OrdinalIgnoreCase)) { svc.PostExecCommand(AnkhCommand.ViewInVsNet); return; } } } // Ultimate fallback: Just ask the user what to do (don't trust the repository!) svc.PostExecCommand(AnkhCommand.ViewInWindowsWith); }
public void OnExecute(CommandEventArgs e) { if (_commandService == null) _commandService = e.GetService<IAnkhCommandService>(); if (_projectNotifier == null) _projectNotifier = e.GetService<ProjectNotifier>(typeof(IFileStatusMonitor)); _commandService.TockCommand(e.Command); _projectNotifier.HandleEvent(e.Command); }
public void OnExecute(CommandEventArgs e) { if (_commandService == null) _commandService = e.GetService<IAnkhCommandService>(); if (_pendingChanges == null) _pendingChanges = e.GetService<PendingChangeManager>(typeof(IPendingChangesManager)); _commandService.TockCommand(e.Command); _pendingChanges.OnTickRefresh(); }
public void OnExecute(CommandEventArgs e) { if (_commandService == null) { _commandService = e.GetService <IAnkhCommandService>(); _pendingChanges = e.GetService <PendingChangeManager>(typeof(IPendingChangesManager)); } _commandService.TockCommand(e.Command); _pendingChanges.OnTickRefresh(); }
protected override void OnMouseDoubleClick(MouseEventArgs e) { base.OnMouseDoubleClick(e); Point mp = PointToClient(MousePosition); ListViewHitTestInfo info = HitTest(mp); PathListViewItem lvi = info.Item as PathListViewItem; if (lvi != null && Context != null) { IAnkhCommandService cmdSvc = Context.GetService <IAnkhCommandService>(); cmdSvc.PostExecCommand(AnkhCommand.LogShowChanges); } }
public void OnExecute(CommandEventArgs e) { if (_commandService == null) _commandService = e.GetService<IAnkhCommandService>(); if (_projectTracker == null) _projectTracker = e.GetService<ProjectTracker>(typeof(IAnkhProjectDocumentTracker)); if(_sccProvider == null) _sccProvider = e.GetService<AnkhSccProvider>(typeof(IAnkhSccService)); _commandService.TockCommand(e.Command); _projectTracker.OnSccCleanup(e); _sccProvider.OnSccCleanup(e); }
void RegisterForSccCleanup() { if (_registeredSccCleanup) { return; } IAnkhCommandService cmd = CommandService; if (cmd != null) { cmd.PostTickCommand(ref _registeredSccCleanup, AnkhCommand.SccFinishTasks); } }
void ScheduleUpdateNotify() { if (_scheduled) { return; } IAnkhCommandService cs = _context.GetService <IAnkhCommandService>(); if (cs != null) { cs.PostTickCommand(ref _scheduled, AnkhCommand.TickRefreshSvnItems); } }
public void OnExecute(CommandEventArgs e) { if (_commandService == null) _commandService = e.GetService<IAnkhCommandService>(); if (_fileCache == null) _fileCache = e.GetService<FileStatusCache>(typeof(IFileStatusCache)); _commandService.TockCommand(e.Command); if (e.Command == AnkhCommand.FileCacheFinishTasks) _fileCache.OnCleanup(); else _fileCache.BroadcastChanges(); }
public void OnExecute(CommandEventArgs e) { if (_commandService == null) { _commandService = e.GetService <IAnkhCommandService>(); } if (_projectNotifier == null) { _projectNotifier = e.GetService <ProjectNotifier>(typeof(IFileStatusMonitor)); } _commandService.TockCommand(e.Command); _projectNotifier.HandleEvent(e.Command); }
public void MaybeMigrate() { IAnkhPackage pkg = GetService <IAnkhPackage>(); IAnkhCommandService cs = GetService <IAnkhCommandService>(); if (pkg == null || cs == null) { return; } using (RegistryKey rkRoot = pkg.UserRegistryRoot) using (RegistryKey ankhMigration = rkRoot.CreateSubKey("AnkhSVN-Trigger")) { int migrateFrom = 0; object value = ankhMigration.GetValue(MigrateId, migrateFrom); if (value is int) { migrateFrom = (int)value; } else { ankhMigration.DeleteValue(MigrateId, false); } if (migrateFrom < 0) { migrateFrom = 0; } if (migrateFrom >= AnkhId.MigrateVersion) { return; // Nothing to do } try { if (cs.DirectlyExecCommand(AnkhCommand.MigrateSettings).Success) { ankhMigration.SetValue(MigrateId, AnkhId.MigrateVersion); } } catch { /* NOP: Don't fail here... ever! */ } } }
public override void OnShowContextMenu(MouseEventArgs e) { base.OnShowContextMenu(e); bool isHeaderContext = false; Point screen; if (e.X == -1 && e.Y == -1) { // Handle keyboard context menu if (SelectedItems.Count > 0) { screen = PointToScreen(SelectedItems[SelectedItems.Count - 1].Position); } else { isHeaderContext = true; screen = PointToScreen(new Point(0, 0)); } } else { screen = e.Location; isHeaderContext = PointToClient(e.Location).Y < HeaderHeight; } IAnkhCommandService sc = Context.GetService <IAnkhCommandService>(); AnkhCommandMenu menu; if (isHeaderContext) { Select(); // Must be the active control for the menu to work menu = AnkhCommandMenu.ListViewHeader; } else { menu = AnkhCommandMenu.WorkingCopyExplorerContextMenu; } sc.ShowContextMenu(menu, screen); }
public void OnExecute(CommandEventArgs e) { if (_commandService == null) { _commandService = e.GetService <IAnkhCommandService>(); } if (_projectTracker == null) { _projectTracker = e.GetService <ProjectTracker>(); } if (_sccProvider == null) { _sccProvider = e.GetService <SvnSccProvider>(typeof(IAnkhSccService)); } _commandService.TockCommand(e.Command); _projectTracker.OnSccCleanup(e); _sccProvider.OnSccCleanup(e); }
protected override void Dispose(bool disposing) { ThreadHelper.ThrowIfNotOnUIThread(); try { if (disposing) { if (_mergeHooked) { _mergeHooked = false; UnregisterHandler unregister = _unregister; IAnkhCommandService cs = GetService <IAnkhCommandService>(); if (cs != null) { cs.PostIdleAction(delegate { unregister(_mergeCookie); }); } } if (_frameHooked) { _frameHooked = false; _frame2.Unadvise(_frameCookie); } } // Unbreak possible circular dependency _frame = null; _frame2 = null; _unregister = null; } finally { base.Dispose(disposing); } }
public override void OnShowContextMenu(MouseEventArgs e) { base.OnShowContextMenu(e); Point p = e.Location; bool showSort = false; if (p != new Point(-1, -1)) { // Mouse context menu if (PointToClient(p).Y < HeaderHeight) { showSort = true; } } else { ListViewItem fi = FocusedItem; if (fi != null) { p = PointToScreen(fi.Position); } } IAnkhCommandService mcs = Context.GetService <IAnkhCommandService>(); if (mcs != null) { if (showSort) { mcs.ShowContextMenu(AnkhCommandMenu.PendingCommitsHeaderContextMenu, p); } else { mcs.ShowContextMenu(AnkhCommandMenu.PendingCommitsContextMenu, p); } } }
public void OnExecute(CommandEventArgs e) { if (_commandService == null) { _commandService = e.GetService <IAnkhCommandService>(); } if (_fileCache == null) { _fileCache = e.GetService <GitStatusCache>(typeof(IGitStatusCache)); } _commandService.TockCommand(e.Command); if (e.Command == AnkhCommand.GitCacheFinishTasks) { _fileCache.OnCleanup(); } else { _fileCache.BroadcastChanges(); } }
void OnExecuteFill(CommandEventArgs e) { if (ProjectRootUri != null) { e.Result = new string[] { ProjectRootUri.ToString(), "Other..." } } ; } void OnExecuteSet(CommandEventArgs e) { string value = (string)e.Argument; IAnkhCommandService cs = e.GetService <IAnkhCommandService>(); if (value != null && value == "Other...") { cs.PostExecCommand(AnkhCommand.SolutionSwitchDialog); } else { cs.PostExecCommand(AnkhCommand.SolutionSwitchDialog, new Uri(value)); } } void OnExecuteGet(CommandEventArgs e) { if (ProjectRootUri != null) { e.Result = ProjectRootUri.ToString(); } } void OnExecuteFilter(CommandEventArgs e) { // Not called on us; but empty handler would tell: pass through } }
public override void OnShowContextMenu(MouseEventArgs e) { base.OnShowContextMenu(e); Point screen; if (e.X == -1 && e.Y == -1) { screen = GetSelectionPoint(); if (screen.IsEmpty) { return; } } else { screen = e.Location; } IAnkhCommandService sc = Context.GetService <IAnkhCommandService>(); sc.ShowContextMenu(AnkhCommandMenu.WorkingCopyExplorerContextMenu, screen); }
private void OnResponse(IAsyncResult ar) { IAnkhConfigurationService config = Context.GetService <IAnkhConfigurationService>(); bool failed = true; string tag = null; try { WebRequest rq = ((WebRequest)ar.AsyncState); WebResponse wr; try { wr = rq.EndGetResponse(ar); } catch (WebException e) { HttpWebResponse hwr = e.Response as HttpWebResponse; if (hwr != null) { if (hwr.StatusCode == HttpStatusCode.NotFound) { failed = false; return; // File not found.. Update info not yet or no longer available } } return; } catch { return; } if (wr.ContentLength > 65536) // Not for us.. We expect a few hundred bytes max { return; } string body; using (Stream s = wr.GetResponseStream()) using (StreamReader sr = new StreamReader(s)) { body = sr.ReadToEnd().Trim(); } if (string.IsNullOrEmpty(body)) { failed = false; return; } if (body[0] != '<' || body[body.Length - 1] != '>') { return; // No valid xml or empty } failed = false; XmlDocument doc = new XmlDocument(); doc.LoadXml(body); string title = NodeText(doc, "/u/i/t"); string header = NodeText(doc, "/u/i/h") ?? title; string description = NodeText(doc, "/u/i/d"); string url = NodeText(doc, "/u/i/u"); string urltext = NodeText(doc, "/u/i/l"); string version = NodeText(doc, "/u/i/v"); string newVersion = NodeText(doc, "/u/i/n") ?? version; tag = NodeText(doc, "/u/g"); if (!string.IsNullOrEmpty(title) && !string.IsNullOrEmpty(description)) { if (!string.IsNullOrEmpty(version)) { Version v = new Version(version); if (v <= GetCurrentVersion(Context)) { return; } } if (!string.IsNullOrEmpty(tag)) { using (RegistryKey rk = config.OpenUserInstanceKey("UpdateCheck")) { string pTag = rk.GetValue("SkipTag") as string; if (pTag == tag) { return; } } } IAnkhCommandService cs = Context.GetService <IAnkhCommandService>(); cs.PostExecCommand(AnkhCommand.CheckForUpdates, new string[] { title, header, description, url, urltext, version, newVersion, tag }); } } finally { using (RegistryKey rk = config.OpenUserInstanceKey("UpdateCheck")) { object fails = rk.GetValue("Fails", 0); rk.DeleteValue("LastCheck", false); rk.DeleteValue("LastVersion", false); rk.DeleteValue("FailedChecks", false); rk.SetValue("LastCheck", DateTime.UtcNow.Ticks); rk.SetValue("LastVersion", GetCurrentVersion(Context).ToString()); if (tag != null) { rk.SetValue("LastTag", tag); } else { rk.DeleteValue("LastTag", false); } if (failed) { int f = 0; if (fails is int) { f = (int)fails + 1; } rk.SetValue("FailedChecks", f); } } } }
private void openSccSelectorLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { IAnkhCommandService cs = Context.GetService <IAnkhCommandService>(); cs.PostExecCommand(new CommandID(VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.ToolsOptions), "53544C4D-1D2D-44BD-8566-4FC149E23AAF"); }
void ShowPanel(PendingChangesPage page, bool select) { if (page == null) { throw new ArgumentNullException("page"); } else if (page == _currentPage) { return; } bool foundPage = false; foreach (PendingChangesPage p in contentPanel.Controls) { if (p != page) { p.Enabled = p.Visible = false; } else { foundPage = true; p.Enabled = p.Visible = true; if (!p._alreadyThemed) { ThemePage(p); } } } System.Diagnostics.Debug.Assert(foundPage); _currentPage = page; if (page != _activatePage) { _lastPage = page; } fileChangesButton.Checked = (_lastPage == _commitsPage); issuesButton.Checked = (_lastPage == _issuesPage); recentChangesButton.Checked = (_lastPage == _changesPage); conflictsButton.Checked = (_lastPage == _conflictsPage); if (select) { page.Select(); } if (Context != null) { IAnkhCommandService cmd = Context.GetService <IAnkhCommandService>(); if (cmd != null) { cmd.UpdateCommandUI(false); } UpdateCaption(); } }
public override void OnExecute(CommandEventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); SvnItem node = EnumTools.GetFirst(e.Selection.GetSelectedSvnItems(false)); IAnkhCommandService cmd = e.GetService <IAnkhCommandService>(); switch (e.Command) { case AnkhCommand.ItemSelectInRepositoryExplorer: if (node == null || node.Uri == null) { return; } if (cmd != null) { cmd.DirectlyExecCommand(AnkhCommand.RepositoryBrowse, node.FullPath); } break; case AnkhCommand.ItemSelectInWorkingCopyExplorer: if (node == null || !node.Exists) { return; } if (cmd != null) { cmd.DirectlyExecCommand(AnkhCommand.WorkingCopyBrowse, node.FullPath); } break; case AnkhCommand.ItemSelectInFileExplorer: if (node == null || !node.Exists) { return; } SelectInFileExplorer(node.FullPath); break; case AnkhCommand.ItemSelectInSolutionExplorer: if (node == null) { return; } IVsUIHierarchyWindow hierWindow = VsShellUtilities.GetUIHierarchyWindow(e.Context, new Guid(ToolWindowGuids80.SolutionExplorer)); IVsProject project = VsShellUtilities.GetProject(e.Context, node.FullPath) as IVsProject; if (hierWindow != null) { int found; uint id; VSDOCUMENTPRIORITY[] prio = new VSDOCUMENTPRIORITY[1]; if (project != null && VSErr.Succeeded(project.IsDocumentInProject(node.FullPath, out found, prio, out id)) && found != 0) { hierWindow.ExpandItem(project as IVsUIHierarchy, id, EXPANDFLAGS.EXPF_SelectItem); } else if (string.Equals(node.FullPath, e.Selection.SolutionFilename, StringComparison.OrdinalIgnoreCase)) { hierWindow.ExpandItem(e.GetService <IVsUIHierarchy>(typeof(SVsSolution)), VSItemId.Root, EXPANDFLAGS.EXPF_SelectItem); } // Now try to activate the solution explorer IVsWindowFrame solutionExplorer; Guid solutionExplorerGuid = new Guid(ToolWindowGuids80.SolutionExplorer); IVsUIShell shell = e.GetService <IVsUIShell>(typeof(SVsUIShell)); if (shell != null) { shell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fForceCreate, ref solutionExplorerGuid, out solutionExplorer); if (solutionExplorer != null) { solutionExplorer.Show(); } } } break; } }
private static void AutoOpenCommand(CommandEventArgs e, SvnItem item) { IProjectFileMapper pfm = e.GetService <IProjectFileMapper>(); IAnkhCommandService svc = e.GetService <IAnkhCommandService>(); IAnkhSolutionSettings solutionSettings = e.GetService <IAnkhSolutionSettings>(); if (pfm == null || svc == null || solutionSettings == null) { return; } // We can assume we have a file if (pfm.IsProjectFileOrSolution(item.FullPath)) { // Ok, the user selected the current solution file or an open project // Let's jump to it in the solution explorer svc.ExecCommand(AnkhCommand.ItemSelectInSolutionExplorer); return; } if (item.InSolution) { // The file is part of the solution, we can assume VS knows how to open it svc.ExecCommand(AnkhCommand.ItemOpenVisualStudio); return; } string filename = item.Name; string ext = item.Extension; if (string.IsNullOrEmpty(ext)) { // No extension -> Open as text svc.PostExecCommand(AnkhCommand.ItemOpenTextEditor); return; } foreach (string projectExt in solutionSettings.AllProjectExtensionsFilter.Split(';')) { if (projectExt.TrimStart('*').Trim().Equals(ext, StringComparison.OrdinalIgnoreCase)) { // We found a project or solution: Ask VS to open it e.GetService <IAnkhSolutionSettings>().OpenProjectFile(item.FullPath); return; } } bool odd = false; foreach (string block in solutionSettings.OpenFileFilter.Split('|')) { odd = !odd; if (odd) { continue; } foreach (string itemExt in block.Split(';')) { if (itemExt.TrimStart('*').Trim().Equals(ext, StringComparison.OrdinalIgnoreCase)) { VsShellUtilities.OpenDocument(e.Context, item.FullPath); return; } } } // Ultimate fallback: Just open the file as windows would svc.PostExecCommand(AnkhCommand.ItemOpenWindows); }