public async void AssociateIt(int selectedWorkItemId, object mm) { await ParentSection.RefreshAsync(); IPendingChangesExt pendingChangesExt = ParentSection.GetService <IPendingChangesExt>(); var model = pendingChangesExt.GetType().GetField("m_workItemsSection", BindingFlags.NonPublic | BindingFlags.Instance); var modelType = model.FieldType; var workItemSection = model.GetValue(pendingChangesExt); var selectedWil = workItemSection.GetType().GetProperty("SelectedWorkItems").GetValue(workItemSection) as ObservableCollection <WorkItemValueProvider>; var availablWil = workItemSection.GetType().GetProperty("WorkItemsListProvider").GetValue(workItemSection) as WorkItemsListProvider; try { while (!availablWil.WorkItems.Where(x => x.Id == selectedWorkItemId).Any()) { await System.Threading.Tasks.Task.Delay(25); } selectedWil.Clear(); selectedWil.Add(availablWil.WorkItems.Where(x => x.Id == selectedWorkItemId).First()); EnvDTE80.DTE2 dte2 = Package.GetGlobalService(typeof(DTE)) as DTE2; dte2.ExecuteCommand("TeamFoundationContextMenus.WorkItemActionLink.TfsContextPendingChangesPageWorkItemActionLinkAssociate"); selectedWil.Clear(); } catch (Exception ex) { ParentSection.ShowNotification(ex.ToString(), NotificationType.Error); } }
public override bool ContainsPoint(double x, double y) { double span = line.LineWidth / 2 + 8; Cairo.PointD p1 = ParentSection.AbsolutePointByLocalPoint(line.Location.X, line.Location.Y); Cairo.PointD p2 = ParentSection.AbsolutePointByLocalPoint(line.End.X, line.End.Y); Cairo.PointD hitPoint = new Cairo.PointD(x, y); if (hitPoint.X >= (Math.Max(p1.X, p2.X) + span) || hitPoint.X <= (Math.Min(p1.X, p2.X) - span) || hitPoint.Y >= (Math.Max(p1.Y, p2.Y) + span) || hitPoint.Y <= (Math.Min(p1.Y, p2.Y) - span)) { return(false); } if (p1.X == p2.X || p1.Y == p2.Y) { return(true); } double y1, y2, x1, x2; double m, b; double ny; if (Math.Abs(p1.Y - p2.Y) <= Math.Abs(p1.X - p2.X)) { y1 = p1.Y; y2 = p2.Y; x1 = p1.X; x2 = p2.X; } else { y1 = p1.X; y2 = p2.X; x1 = p1.Y; x2 = p2.Y; double tmp = hitPoint.Y; hitPoint.Y = hitPoint.X; hitPoint.X = tmp; } m = (y2 - y1) / (x2 - x1); b = y1 - m * x1; ny = (m * ((double)hitPoint.X) + b) + 0.5; if (Math.Abs(hitPoint.Y - ny) > span) { return(false); } return(true); }
private void AddWorkItem(bool associate = false) { try { var item = this.workItemList.SelectedItem; if (item == null) { return; } var propertyId = item.GetType().GetProperty("Id"); if (propertyId == null) { return; } int selectedWorkItemId = (int)propertyId.GetValue(item); IPendingChangesExt pendingChangesExt = ParentSection.GetService <IPendingChangesExt>(); var workItemSection = pendingChangesExt.GetType().GetField("m_workItemsSection", BindingFlags.NonPublic | BindingFlags.Instance); var modelType = workItemSection.FieldType; var model = workItemSection.GetValue(pendingChangesExt); var m = modelType.GetMethod("AddWorkItemById", BindingFlags.NonPublic | BindingFlags.Instance); m.Invoke(model, new object[] { selectedWorkItemId }); if (associate) { AssociateIt(selectedWorkItemId, model); } var workItem = ParentSection.RecentWorkItems.FirstOrDefault(wi => wi.Id == selectedWorkItemId); if (workItem != null) { ParentSection.RecentWorkItems.Remove(workItem); } } catch (Exception ex) { ParentSection.ShowNotification(ex.ToString(), NotificationType.Error); } }
private void TermBox_TextChanged(object sender, TextChangedEventArgs e) { var caller = ((TextBox)sender); if (ParentSection == null) // avoid running on initialize { return; } if (!string.IsNullOrEmpty(caller.Text) && caller.Text.Length < 3) { return; } ParentSection.SearchTerm = caller.Text; ParentSection.RefreshAsync(); }
private void OnAddWorkItem(object sender, RoutedEventArgs e) { try { var item = this.workItemList.SelectedItem; if (item == null) { return; } var selectedWorkItem = item as AssociatedWorkItemInfo; if (selectedWorkItem == null) { return; } int selectedWorkItemId = selectedWorkItem.Id; var pc = ParentSection.GetService <IPendingChangesExt>(); var model = pc.GetType().GetField("m_workItemsSection", BindingFlags.NonPublic | BindingFlags.Instance); var t = model.FieldType; var mm = model.GetValue(pc); var m = t.GetMethod("AddWorkItemById", BindingFlags.NonPublic | BindingFlags.Instance); m.Invoke(mm, new object[] { selectedWorkItemId }); var workItem = ParentSection.RecentWorkItems.FirstOrDefault(wi => wi.Id == selectedWorkItemId); if (workItem != null) { ParentSection.RecentWorkItems.Remove(workItem); } } catch (Exception ex) { ParentSection.ShowNotification(ex.ToString(), NotificationType.Error); } }
void Start() { parentSection = this; }