private void Bind(ITypeDescriptorContext context, ISelectionContext selectionContext, object value, Func <object, ItemInfo, bool> getItemInfo) { splitContainer1.SuspendLayout(); m_treeControl = new TreeControl(TreeControl.Style.SimpleTree); m_treeControl.Dock = DockStyle.Fill; m_treeControl.SelectionMode = SelectionMode.One; m_treeControl.ImageList = ResourceUtil.GetImageList16(); m_treeControl.Location = new Point(comboBox1.Location.X, comboBox1.Location.Y + 2 * FontHeight); m_treeControl.Width = upButton.Location.X - m_treeControl.Location.X - Margin.Right - Margin.Left; m_treeControl.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom; m_treeControl.Height = splitContainer1.Panel1.Height - m_treeControl.Location.Y - (Margin.Bottom + Margin.Top); splitContainer1.Panel1.Controls.Add(m_treeControl); m_propertyGrid = new PropertyGrid(); m_defaultContext.SelectionContext = selectionContext; m_propertyGrid.Bind(m_defaultContext); m_propertyGrid.Dock = DockStyle.Fill; splitContainer1.Panel2.Controls.Add(m_propertyGrid); splitContainer1.ResumeLayout(); m_rootValue = value; m_collectionTreeView = new TreeView(context, value); m_collectionTreeView.GetItemInfo = getItemInfo; m_treeControlAdapter = new TreeControlAdapter(m_treeControl); m_collectionTreeView.SelectionChanged += collectionTreeView_SelectionChanged; m_treeControl.ShowRoot = false; m_treeControlAdapter.TreeView = m_collectionTreeView; m_context = context; UpdateAvailaibleTypes(new Path <object>(context.Instance)); }
void PropertyEditor_DocumentChanged(object sender, DocumentChangedEventArgs args) { ISelectionContext docBase = args.New as ISelectionContext; if (docBase != null) { docBase.SelectionChanged += docBase_SelectionChanged; if (docBase.SelectionCount != 0) { docBase_SelectionChanged(docBase, null); // EventArgs is unused } return; } Documents.IPropertyDocument pdoc = args.New as Documents.IPropertyDocument; if (pdoc != null) { pdoc.PropertyBoundChanged += pdoc_PropertyBoundChanged; sonygrid.Visible = true; sonygrid.Bind(pdoc.PropertyBound); return; } sonygrid.Bind(null); sonygrid.Visible = false; }
void PropertyTable_DocumentChanged(object sender, DocumentChangedEventArgs args) { ISelectionContext docBase = args.New as ISelectionContext; if (docBase != null) { docBase.SelectionChanged += docBase_SelectionChanged; } else { // If the active document is an IPropertyDocument then we'll bind all open documents "PropertyBound" attribute to the sheet if (args.New is Documents.IPropertyDocument) { List <Documents.IPropertyDocument> openDocs = DocumentManager.GetInst().GetList <Documents.IPropertyDocument>(args.New.GetType()); if (openDocs.Count > 0) { List <object> things = new List <object>(); foreach (Documents.IPropertyDocument doc in openDocs) { things.Add(doc.PropertyBound); } SetObject(things); return; } } } SetObject(null); }
/// <summary> /// Does a command</summary> /// <param name="commandTag">Command</param> void ICommandClient.DoCommand(object commandTag) { ISelectionContext selectionContext = m_contextRegistry.GetActiveContext <ISelectionContext>(); ITransactionContext transactionContext = m_contextRegistry.GetActiveContext <ITransactionContext>(); ILockingContext lockingContext = m_contextRegistry.GetActiveContext <ILockingContext>(); if (commandTag is StandardCommand) { switch ((StandardCommand)commandTag) { case StandardCommand.EditLock: transactionContext.DoTransaction(delegate { Lock(selectionContext.Selection, lockingContext); }, CommandInfo.EditLock.MenuText); break; case StandardCommand.EditUnlock: transactionContext.DoTransaction(delegate { Unlock(selectionContext.Selection, lockingContext); }, CommandInfo.EditUnlock.MenuText); break; } } }
protected virtual string GetDiff(IAnkhServiceProvider context, ISelectionContext selection) { return GetDiff( context, selection, null); }
private void Delete(string commandName) { OnDeleting(EventArgs.Empty); IInstancingContext instancingContext = m_contextRegistry.GetActiveContext <IInstancingContext>(); if (instancingContext != null && instancingContext.CanDelete()) { ITransactionContext transactionContext = instancingContext.As <ITransactionContext>(); transactionContext.DoTransaction( delegate { instancingContext.Delete(); ISelectionContext selectionContext = instancingContext.As <ISelectionContext>(); if (selectionContext != null) { selectionContext.Clear(); } }, commandName); } OnDeleted(EventArgs.Empty); }
protected void btnComplete_Click(object sender, EventArgs e) { string key = hfSelections.Value; bool completeAll = true; ISelectionService srv = SelectionServiceRequest.GetSelectionService(); ISelectionContext selectionContext = srv.GetSelectionContext(key); List <string> ids = selectionContext.GetSelectedIds(); foreach (string id in ids) { ILitRequest lit = EntityFactory.GetById <ILitRequest>(id); if (UserCalendar.CurrentUserCanEdit(lit.CreateUser)) { lit.CompleteLitRequest(); } else { completeAll = false; } } // this has to occur after the fulfillment is completed. The status needs to be updated before refresh is called. ScriptManager.RegisterStartupScript(this, typeof(SmartParts_TaskPane_LiteratureManagementTasks), "refreshList", "RefreshList();", true); if (!completeAll) { DialogService.ShowMessage(GetLocalResourceObject("Err_Complete").ToString(), 70, 400); } }
/// <summary> /// Checks if the client can do the command</summary> /// <param name="commandTag">Command</param> /// <returns>True if client can do the command</returns> bool ICommandClient.CanDoCommand(object commandTag) { if (commandTag is StandardCommand) { ISelectionContext selectionContext = m_contextRegistry.GetActiveContext <ISelectionContext>(); IEnumerableContext enumerableContext = m_contextRegistry.GetActiveContext <IEnumerableContext>(); switch ((StandardCommand)commandTag) { case StandardCommand.ViewHide: return(selectionContext != null && selectionContext.SelectionCount > 0); case StandardCommand.ViewShow: return(selectionContext != null && selectionContext.SelectionCount > 0); case StandardCommand.ViewShowLast: return(m_hideStack != null && m_hideStack.Count > 0); case StandardCommand.ViewShowAll: return(enumerableContext != null); case StandardCommand.ViewIsolate: return(selectionContext != null && selectionContext.SelectionCount > 0); } } return(false); }
/// <summary> /// Checks if the client can do the command</summary> /// <param name="commandTag">Command</param> /// <returns>True if client can do the command</returns> bool ICommandClient.CanDoCommand(object commandTag) { bool canDo = false; if (commandTag is StandardCommand) { ISelectionContext selectionContext = m_contextRegistry.GetActiveContext <ISelectionContext>(); IEnumerableContext enumerableContext = m_contextRegistry.GetActiveContext <IEnumerableContext>(); // This logic needs to be kept in sync with ActiveContextChanged() and SelectionChanged(). switch ((StandardCommand)commandTag) { case StandardCommand.EditDeselectAll: canDo = selectionContext != null && selectionContext.LastSelected != null; break; case StandardCommand.EditSelectAll: case StandardCommand.EditInvertSelection: // Doing an exact test to see if these commands are useful is expensive. // Let's enable them if there is a selection and enumerable context. canDo = selectionContext != null && enumerableContext != null; break; } } return(canDo); }
/// <summary> /// Checks if the client can do the command</summary> /// <param name="commandTag">Command</param> /// <returns>True if client can do the command</returns> bool ICommandClient.CanDoCommand(object commandTag) { bool canDo = false; if (commandTag is StandardCommand) { IViewingContext viewingContext = m_contextRegistry.GetActiveContext <IViewingContext>(); switch ((StandardCommand)commandTag) { case StandardCommand.ViewFrameSelection: ISelectionContext selectionContext = m_contextRegistry.GetActiveContext <ISelectionContext>(); if (viewingContext != null && selectionContext != null) { canDo = viewingContext.CanFrame(selectionContext.Selection); } break; case StandardCommand.ViewFrameAll: IEnumerableContext enumerableContext = m_contextRegistry.GetActiveContext <IEnumerableContext>(); if (viewingContext != null && enumerableContext != null) { canDo = viewingContext.CanFrame(enumerableContext.Items); } break; } } return(canDo); }
protected void btnFulfill_Click(object sender, EventArgs e) { StringBuilder labelIds = new StringBuilder(); string key = hfSelections.Value; ISelectionService srv = SelectionServiceRequest.GetSelectionService(); ISelectionContext selectionContext = srv.GetSelectionContext(key); List <string> ids = selectionContext.GetSelectedIds(); foreach (string id in ids) { if (hfLastFulfilledIds.Value.Contains(id)) { var lit = EntityFactory.GetById <ILitRequest>(id); if (lit != null) { labelIds.Append(string.Format("{0},", lit.Contact.Id)); lit.FulfillLitRequest(); } } } if (LabelsDropdown.SelectedIndex > 0) { string sPluginId = LabelsDropdown.SelectedValue; if (labelIds.ToString().EndsWith(",")) { labelIds = labelIds.Remove(labelIds.Length - 1, 1); } ScriptManager.RegisterStartupScript(this, typeof(SmartParts_TaskPane_LiteratureManagementTasks), "printLabels", string.Format("PrintLabels('{0}', '{1}');", sPluginId, labelIds), true); } // this has to occur after the fulfillment is completed. The status needs to be updated before refresh is called. ScriptManager.RegisterStartupScript(this, typeof(SmartParts_TaskPane_LiteratureManagementTasks), "refreshList", "RefreshList();", true); }
/// <summary> /// Removes multiple items from the selection</summary> /// <param name="selectionContext">Selection context</param> /// <param name="items">Items to remove</param> public static void RemoveRange(this ISelectionContext selectionContext, IEnumerable items) { if (selectionContext == null) { throw new ArgumentNullException("selectionContext"); } if (items == null) { throw new ArgumentNullException("items"); } var removed = new HashSet <object>(); foreach (object item in items) { removed.Add(item); } var newSelection = new List <object>(); foreach (object item in selectionContext.Selection) { if (!removed.Contains(item)) { newSelection.Add(item); } } selectionContext.Selection = newSelection; }
/// <summary> /// Adds multiple items to the selection</summary> /// <param name="selectionContext">Selection context</param> /// <param name="items">Items to add</param> public static void AddRange(this ISelectionContext selectionContext, IEnumerable items) { if (selectionContext == null) { throw new ArgumentNullException("selectionContext"); } if (items == null) { throw new ArgumentNullException("items"); } var newSelection = new List <object>(); // get items in selection that aren't being added var itemSet = new HashSet <object>(items.Cast <object>()); foreach (object item in selectionContext.Selection) { if (!itemSet.Contains(item)) { newSelection.Add(item); } } // append the added items newSelection.AddRange(items.Cast <object>()); selectionContext.Selection = newSelection; }
private IEnumerable <string> GetSelectedIds() { ISelectionService oSelectionService = SelectionServiceRequest.GetSelectionService(); if (oSelectionService == null) { ShowMessage("Err_SelectionService"); return(null); } ISelectionContext oSelectionContext = oSelectionService.GetSelectionContext(hfSelections.Value); if (oSelectionContext == null) { ShowMessage("Err_SelectionContext"); return(null); } var ids = oSelectionContext.GetSelectedIds(); if (ids.Count == 0) { ShowMessage("Err_Selection"); return(null); } return(ids); }
protected override bool ShouldSelect(MethodData method, ISelectionContext context) { Func <TypeData, bool> notInContext = type => !context.Types.Contains(type); return(method.GetOverridesAndImplements().Any( m => notInContext(m.DeclaringType) )); }
protected override bool ShouldSelect(MethodData value, ISelectionContext context) { var constructor = value.Inner as ConstructorInfo; return(constructor != null && constructor.GetParameters().Length == 0 && IsEmptyOrJustCallsBase(value)); }
public void AddItem() { ISelectionContext selC = SelectionContextMock.EmptyContext(); using (ServiceProviderHelper.AddService(typeof(ISelectionContext), selC)) { Assert.IsFalse(CommandTester.TestExecution(AnkhCommand.AddItem), "Add disabled with empty selection"); } }
public void AddWorkingCopyExplorerRootCommandWithPath() { ISelectionContext selC = SelectionContextMock.EmptyContext(); using (ServiceProviderHelper.AddService(typeof(ISelectionContext), selC)) { Assert.IsTrue(CommandTester.TestExecution(AnkhCommand.WorkingCopyBrowse, Path.GetTempPath())); } }
public void CopyReposExplorerUrl() { ISelectionContext selC = SelectionContextMock.EmptyContext(); using (ServiceProviderHelper.AddService(typeof(ISelectionContext), selC)) { Assert.That(CommandTester.TestExecution(AnkhCommand.CopyReposExplorerUrl), Is.False); } }
public void ViewInWindowsCommand() { ISelectionContext selC = SelectionContextMock.EmptyContext(); using (ServiceProviderHelper.AddService(typeof(ISelectionContext), selC)) { Assert.That(CommandTester.TestExecution(AnkhCommand.ViewInWindows), Is.False); } }
public void RemoveWorkingCopyRoot() { ISelectionContext selC = SelectionContextMock.EmptyContext(); using (ServiceProviderHelper.AddService(typeof(ISelectionContext), selC)) { Assert.That(CommandTester.TestExecution(AnkhCommand.RemoveWorkingCopyExplorerRoot), Is.False); } }
/// <summary> /// Clears the selection</summary> /// <param name="selectionContext">Selection context</param> public static void Clear(this ISelectionContext selectionContext) { if (selectionContext == null) { throw new ArgumentNullException("selectionContext"); } selectionContext.Selection = EmptyEnumerable <object> .Instance; }
public void MakeDirectoryCommand() { ISelectionContext selC = SelectionContextMock.EmptyContext(); using (ServiceProviderHelper.AddService(typeof(ISelectionContext), selC)) { Assert.That(CommandTester.TestExecution(AnkhCommand.NewFolder), Is.False); } }
public void DiffLocalItem() { ISelectionContext selC = SelectionContextMock.EmptyContext(); using (ServiceProviderHelper.AddService(typeof(ISelectionContext), selC)) { Assert.That(CommandTester.TestExecution(AnkhCommand.DiffLocalItem), Is.False); } }
public void UpdateItemCommand() { ISelectionContext selC = SelectionContextMock.EmptyContext(); using (ServiceProviderHelper.AddService(typeof(ISelectionContext), selC)) { Assert.That(CommandTester.TestExecution(AnkhCommand.UpdateItemSpecific), Is.False); } }
internal HashSet<IMemberData> FindUsedMembers(IEnumerable<IMemberData> members, ISelectionContext context) { var entryMembers = configuration.Entry.SelectFrom(members, context); entryMembers = entryMembers.Union( configuration.DefinitelyUsed.SelectFrom(members, context) ); return this.FindUsedMembers(entryMembers, members, context); }
/// <summary> /// Gets tags for context menu (right click) commands</summary> /// <param name="context">Context containing target object</param> /// <param name="target">Right clicked object, or null if none</param> /// <returns>Enumeration of command tags for context menu</returns> public IEnumerable <object> GetCommands(object context, object target) { EditingContext = context.As <IPropertyEditingContext>(); //ok if context is null Descriptor = target as ChildAttributePropertyDescriptor; m_multiPropertyDescriptor = null; // Check for MultiPropertyDescriptor in case multiple objects are selected. if (Descriptor == null) { var multi = target as MultiPropertyDescriptor; if (multi != null) { bool allAreGood = true; ChildAttributePropertyDescriptor oneDynamic = null; foreach (var single in multi.GetDescriptors()) { oneDynamic = single as ChildAttributePropertyDescriptor; if (oneDynamic == null) { allAreGood = false; break; } } if (allAreGood && oneDynamic != null) { Descriptor = oneDynamic; m_multiPropertyDescriptor = multi; } } } // Try to get a client-defined IPropertyEditingContext. if (EditingContext == null) { // Otherwise, try to get a client-defined ISelectionContext and adapt it. ISelectionContext selectionContext = context.As <ISelectionContext>(); DefaultContext.SelectionContext = selectionContext; if (selectionContext != null) { EditingContext = DefaultContext; } } if (CanDoCommand(Command.Add)) { yield return(Command.Add); } if (CanDoCommand(Command.Edit)) { yield return(Command.Edit); } if (CanDoCommand(Command.Remove)) { yield return(Command.Remove); } }
/// <summary> /// Deselects all objects in the given context</summary> /// <param name="selectionContext">Context holding selection</param> /// <returns>True iff all objects were deselected</returns> public bool DeselectAll(ISelectionContext selectionContext) { if (selectionContext != null) { selectionContext.Clear(); return true; } return false; }
public void BlameCommand() { ISelectionContext selC = SelectionContextMock.EmptyContext(); using (ServiceProviderHelper.AddService(typeof(ISelectionContext), selC)) { Assert.That(CommandTester.TestExecution(AnkhCommand.ItemAnnotate), Is.False, "Blame with empty selection doesn't execute"); } }
/// <summary> /// Initializes this dialog with the required and optional contexts</summary> /// <param name="selectionContext">Selection context -- required</param> /// <param name="namingContext">Naming context -- required</param> /// <param name="transactionContext">Transaction context -- optional</param> /// <remarks>Combine with the constructor? This separate Set() only makes sense if this dialog box /// is floating or dockable.</remarks> public void Set( ISelectionContext selectionContext, INamingContext namingContext, ITransactionContext transactionContext) { m_selectionContext = selectionContext; m_namingContext = namingContext; m_transactionContext = transactionContext; UpdatePreview(); }
public void CommitItemCommand() { ISelectionContext selC = SelectionContextMock.EmptyContext(); using (ServiceProviderHelper.AddService(typeof(ISelectionContext), selC)) { Assert.That(CommandTester.TestExecution(AnkhCommand.CommitItem), Is.False, "Commit doesn't run without selection"); } }
public void RevertItemCommand() { ISelectionContext selC = SelectionContextMock.EmptyContext(); using (ServiceProviderHelper.AddService(typeof(ISelectionContext), selC)) { Assert.That(CommandTester.TestExecution(AnkhCommand.RevertItem), Is.False, "Cannot revert empty selection"); } }
public void CheckoutCommand() { ISelectionContext selC = SelectionContextMock.EmptyContext(); using (ServiceProviderHelper.AddService(typeof(ISelectionContext), selC)) { Assert.That(CommandTester.TestExecution(AnkhCommand.Checkout), Is.False, "Checkout doesn't execute with empty selection"); } }
public void Refresh() { ISelectionContext selC = SelectionContextMock.EmptyContext(); using (ServiceProviderHelper.AddService(typeof(ISelectionContext), selC)) { Assert.That(CommandTester.TestExecution(AnkhCommand.Refresh), Is.True, "Refresh works with empty selection"); } }
/// <summary> /// Generates the diff from the current selection. /// </summary> /// <param name="context"></param> /// <param name="selection"></param> /// <param name="revisions"></param> /// <returns>The diff as a string.</returns> protected virtual string GetDiff(IAnkhServiceProvider context, ISelectionContext selection, SvnRevisionRange revisions) { return GetDiff( context, selection, revisions, delegate(SvnItem item) { return item.IsVersioned; }); }
/// <summary> /// Selects all enumerable objects in the given context</summary> /// <param name="selectionContext">Context holding selection</param> /// <param name="enumerableContext">Context holding enumeration of selectable objects</param> /// <returns>True iff all objects were selected</returns> public bool SelectAll(ISelectionContext selectionContext, IEnumerableContext enumerableContext) { if (selectionContext != null && enumerableContext != null) { selectionContext.SetRange(enumerableContext.Items); return true; } return false; }
/// <summary> /// Saves all dirty documents within the provided selection /// </summary> /// <param name="selection">The selection.</param> /// <param name="context">The context.</param> protected static void SaveAllDirtyDocuments(ISelectionContext selection, IAnkhServiceProvider context) { if (selection == null) throw new ArgumentNullException("selection"); if (context == null) throw new ArgumentNullException("context"); IAnkhOpenDocumentTracker tracker = context.GetService<IAnkhOpenDocumentTracker>(); if (tracker != null) tracker.SaveDocuments(selection.GetSelectedFiles(true)); }
void NativeDesignView_ContextChanged(object sender, EventArgs e) { if (m_selectionContext != null) { m_selectionContext.SelectionChanged -= new EventHandler(m_selectionContext_SelectionChanged); } m_selectionContext = Context.As<ISelectionContext>(); if (m_selectionContext != null) { m_selectionContext.SelectionChanged += new EventHandler(m_selectionContext_SelectionChanged); } }
/// <summary> /// Constructor</summary> /// <param name="selectionContext">Selection context. See <see cref="ISelectionContext"/>.</param> /// <param name="previous">Selection's previous state</param> /// <param name="next">Selection's next state</param> public SetSelectionCommand( ISelectionContext selectionContext, IEnumerable<object> previous, IEnumerable<object> next) : base("Set Selection".Localize()) { if (selectionContext == null) throw new ArgumentNullException("selectionContext"); m_selectionContext = selectionContext; m_previous = Snapshot(previous); // if previous is the same as next, then use the same array if (previous.SequenceEqual(next)) m_next = m_previous; else m_next = Snapshot(next); }
private static void UngroupGroups(CircuitEditingContext circuitEditingContext, ISelectionContext selectionContext) { var graphContainer = circuitEditingContext.CircuitContainer; var newSelection = new List<object>(); foreach (var group in selectionContext.Selection.AsIEnumerable<Group>()) { newSelection.AddRange(group.Elements); UngroupGroup(group, graphContainer); } selectionContext.SetRange(newSelection); }
internal HashSet<IMemberData> FindUsedMembers(IEnumerable<IMemberData> rootMembers, IEnumerable<IMemberData> members, ISelectionContext context) { var memberSet = members.ToSet(); var assemblySet = memberSet.Select(m => m.Assembly) .Distinct() .ToSet(); var methodsByBases = members.OfType<MethodData>().SelectMany( method => from baseMethod in method.GetOverridesAndImplements() where context.Types.Contains(baseMethod.DeclaringType) select new { BaseMethod = baseMethod, Method = method } ).ToLookup( x => x.BaseMethod, x => x.Method ); var usedMembers = rootMembers.Union( configuration.DefinitelyUsed.SelectFrom(members, context) ).ToArray(); var collector = new UsedMemberCollector( usedMembers, member => assemblySet.Contains(this.GetDeclaringAssembly(member)), methodsByBases ); collector.CollectAll(); var result = collector.Collected; result.IntersectWith(memberSet); return result; }
internal HashSet<IMemberData> LoadMembers(HashSet<TypeData> types, ISelectionContext context) { var actualTypes = types.Select(type => type.Inner).ToSet(); var members = new HashSet<IMemberData>( from type in types from member in type.GetAllMembers(false) where !(member is TypeData) && actualTypes.Contains(member.Inner.DeclaringType) select member ); return members; }
private IEnumerable<IMemberData> FindIgnored(IEnumerable<IMemberData> members, ISelectionContext context) { return configuration.Ignored.SelectFrom(members, context); }
/// <summary> /// Generates the diff from the current selection. /// </summary> /// <param name="context"></param> /// <param name="selection"></param> /// <param name="revisions"></param> /// <param name="visibleFilter"></param> /// <returns>The diff as a string.</returns> protected virtual string GetDiff(IAnkhServiceProvider context, ISelectionContext selection, SvnRevisionRange revisions, Predicate<SvnItem> visibleFilter) { if (selection == null) throw new ArgumentNullException("selection"); if (context == null) throw new ArgumentNullException("context"); IUIShell uiShell = context.GetService<IUIShell>(); bool foundModified = false; foreach (SvnItem item in selection.GetSelectedSvnItems(true)) { if (item.IsModified || item.IsDocumentDirty) { foundModified = true; break; // no need (yet) to keep searching } } PathSelectorInfo info = new PathSelectorInfo("Select items for diffing", selection.GetSelectedSvnItems(true)); info.VisibleFilter += visibleFilter; if (foundModified) info.CheckedFilter += delegate(SvnItem item) { return item.IsFile && (item.IsModified || item.IsDocumentDirty); }; info.RevisionStart = revisions == null ? SvnRevision.Base : revisions.StartRevision; info.RevisionEnd = revisions == null ? SvnRevision.Working : revisions.EndRevision; PathSelectorResult result; // should we show the path selector? if (!Shift && (revisions == null || !foundModified)) { result = uiShell.ShowPathSelector(info); if (!result.Succeeded) return null; } else result = info.DefaultResult; if (!result.Succeeded) return null; SaveAllDirtyDocuments(selection, context); return DoExternalDiff(context, result); }
private void DrawGroupsAndTracks(TimelinePath path, ITimeline timeline, bool expandedTimeline, ISelectionContext selection, Context c, TimelineLayout layout, RectangleF clipBounds) { RectangleF canvasBounds = clipBounds; //clipBounds minus the left-side header canvasBounds.X = HeaderWidth; canvasBounds.Width -= HeaderWidth; RectangleF bounds; foreach (IGroup group in timeline.Groups) { TimelinePath groupPath = path + group; if (!layout.TryGetBounds(groupPath, out bounds)) continue; if (bounds.IntersectsWith(clipBounds)) { DrawMode drawMode = DrawMode.Normal; if (selection.SelectionContains(groupPath)) drawMode |= DrawMode.Selected; if (expandedTimeline) Draw(group, bounds, drawMode, c); IList<ITrack> tracks = group.Tracks; bool collapsed = !expandedTimeline || (!group.Expanded && tracks.Count > 1); foreach (ITrack track in tracks) { TimelinePath trackPath = path + track; bounds = layout.GetBounds(trackPath); if (bounds.IntersectsWith(clipBounds)) { drawMode = DrawMode.Normal; if (selection.SelectionContains(trackPath)) drawMode |= DrawMode.Selected; if (collapsed) drawMode = DrawMode.Collapsed; Draw(track, bounds, drawMode, c); foreach (IInterval interval in track.Intervals) { TimelinePath intervalPath = path + interval; bounds = layout.GetBounds(intervalPath); if (bounds.IntersectsWith(canvasBounds)) { drawMode = DrawMode.Normal; if (selection.SelectionContains(intervalPath)) drawMode |= DrawMode.Selected; if (collapsed) drawMode = DrawMode.Collapsed; Draw(interval, bounds, drawMode, c); } } foreach (IKey key in track.Keys) { TimelinePath keyPath = path + key; bounds = layout.GetBounds(keyPath); if (bounds.IntersectsWith(canvasBounds)) { drawMode = DrawMode.Normal; if (selection.SelectionContains(keyPath)) drawMode |= DrawMode.Selected; if (collapsed) drawMode = DrawMode.Collapsed; Draw(key, bounds, drawMode, c); } } } } } } }
/// <summary> /// Inverts the selection in the given context (deselect all selected, and select all deselected objects)</summary> /// <param name="selectionContext">Context holding selection</param> /// <param name="enumerableContext">Context holding enumeration of selectable objects</param> /// <returns>True iff selection was inverted</returns> public bool InvertSelection(ISelectionContext selectionContext, IEnumerableContext enumerableContext) { if (selectionContext != null && enumerableContext != null) { HashSet<object> selected = new HashSet<object>(selectionContext.Selection); List<object> inverted = new List<object>(enumerableContext.Items); for (int i = 0; i < inverted.Count; ) { if (selected.Contains(inverted[i])) inverted.RemoveAt(i); else i++; } selectionContext.SetRange(inverted); } return false; }
private void CreateGroup(ISelectionContext selectionContext, ViewingContext viewingContext) { // build the group var newGroup = new DomNode(GroupType).As<Group>(); newGroup.DefaultPinOrder = DefaultPinOrderStyle; newGroup.DomNode.Type.SetTag<ICircuitElementType>(newGroup); newGroup.Id = "Group".Localize("a noun"); newGroup.Name = newGroup.Id; newGroup.ShowExpandedGroupPins = CircuitDefaultStyle.ShowExpandedGroupPins; var selected = selectionContext.LastSelected.As<DomNode>(); var doc = selected.GetRoot().Cast<DomDocument>(); var subGraphValidator = doc.Cast<CircuitValidator>(); subGraphValidator.Suspended = true; var circuitEditingContext = selected.Parent.Cast<CircuitEditingContext>(); // Place the circuit group before the elements get repositioned to the group's local coordinate system. if (Placement == PlacementMode.Center) { // position it at center of grouped modules Rectangle bounds = viewingContext.GetBounds(selectionContext.Selection.AsIEnumerable<Element>()); circuitEditingContext.Center(new object[] { newGroup }, new Point( bounds.X + bounds.Width / 2, bounds.Y + bounds.Height / 2)); } else { // find upper-left corner of the subnodes Point minLocation = new Point(int.MaxValue, int.MaxValue); foreach (var module in selectionContext.Selection.AsIEnumerable<Element>()) { if (minLocation.X > module.Bounds.Location.X) minLocation.X = module.Bounds.Location.X; if (minLocation.Y > module.Bounds.Location.Y) minLocation.Y = module.Bounds.Location.Y; } // position it at upper-left conner of grouped modules newGroup.Bounds = new Rectangle(minLocation.X, minLocation.Y, newGroup.Bounds.Width, newGroup.Bounds.Height); newGroup.Position = newGroup.Bounds.Location; } CreateGroup(newGroup, selectionContext.Selection, circuitEditingContext.CircuitContainer); if (CreationOptions == GroupCreationOptions.HideUnconnectedPins) { newGroup.UpdateGroupPinInfo(); foreach (var grpPin in newGroup.InputGroupPins) grpPin.Visible = grpPin.Info.ExternalConnected; foreach (var grpPin in newGroup.OutputGroupPins) grpPin.Visible = grpPin.Info.ExternalConnected; } // select the newly created group circuitEditingContext.Selection.Set(newGroup); subGraphValidator.Suspended = false; }
/// <summary> /// Creates NestedCollectionEditorForm</summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that can be used to gain additional context information</param> /// <param name="selectionContext">Selection context</param> /// <param name="value">An instance of the value being edited</param> /// <param name="getCollectionItemCreators">Callback for getting available types and constructor arguments (object []) /// to create and add to this collection and its sub-collections</param> /// <param name="getItemInfo">Callback for getting item's display information</param> /// <returns>NestedCollectionEditorForm</returns> protected virtual NestedCollectionEditorForm CreateForm(ITypeDescriptorContext context, ISelectionContext selectionContext, object value, Func<Path<object>, IEnumerable<Pair<Type, NestedCollectionEditor.CreateCollectionObject>>> getCollectionItemCreators, Func<object, ItemInfo, bool> getItemInfo) { return new NestedCollectionEditorForm(context, selectionContext, value, getCollectionItemCreators, getItemInfo); }
/// <summary> /// Draws the timeline to the display</summary> /// <param name="timeline">Timeline</param> /// <param name="selection">Selected timeline objects</param> /// <param name="activeGroup">Currently active group, or null</param> /// <param name="activeTrack">Currently active track, or null</param> /// <param name="transform">Transform taking timeline objects to display coordinates</param> /// <param name="clientRectangle">Bounds of displayed area of timeline, in screen space</param> /// <returns>Bounding rectangles for all timeline objects, organized in a dictionary of TimelinePath/RectangleF pairs</returns> public virtual TimelineLayout Draw( ITimeline timeline, ISelectionContext selection, TimelinePath activeGroup, TimelinePath activeTrack, Matrix transform, RectangleF clientRectangle) { Context c = new Context(this, transform, clientRectangle, m_graphics); TimelineLayout layout = Layout(timeline, c); c.ClearRecursionData(); try { if (m_printing) { transform.Translate(m_marginBounds.Left, m_marginBounds.Top, MatrixOrder.Append); m_graphics.PushAxisAlignedClip(m_marginBounds); } // Clear the header column. m_graphics.FillRectangle(new RectangleF(0, 0, HeaderWidth, c.ClientRectangle.Height), m_headerBrush); // Draw the main timeline and then any sub-timelines. DrawSubTimeline(null, timeline, false, true, selection, activeGroup, activeTrack, layout, c); foreach (TimelinePath path in D2dTimelineControl.GetHierarchy(timeline)) DrawSubTimeline(path, selection, activeGroup, activeTrack, layout, c); // Draw the dark vertical line on the header that separates the groups and tracks. m_graphics.DrawLine(new PointF(TrackIndent, m_timeScaleHeight), new PointF(TrackIndent, c.ClientRectangle.Height), m_headerLineBrush); // Draw the dark vertical line on the right-side of the header, separating it from the canvas. m_graphics.DrawLine(new PointF(HeaderWidth, m_timeScaleHeight), new PointF(HeaderWidth, c.ClientRectangle.Height), m_headerLineBrush); // draw scales, etc. if (m_printing) c.Graphics.TranslateTransform(0, m_marginBounds.Top); DrawEventOverlay(c); // Draw the dark horizontal line underneath the scale. m_graphics.DrawLine(new PointF(0, m_timeScaleHeight), new PointF(HeaderWidth, m_timeScaleHeight), m_scaleLineBrush); } finally { if (m_printing) m_graphics.PopAxisAlignedClip(); } // Give the Markers in the main timeline precedence over the scale and canvas RectangleF clipBounds = m_graphics.ClipBounds; clipBounds.X = HeaderWidth; //var clipBounds = new RectangleF(HeaderWidth, 0, m_graphics.Size.Width, m_graphics.Size.Height); DrawMarkers(null, timeline, selection, c, layout, clipBounds); return layout; }
private void DrawSubTimeline( TimelinePath path, ISelectionContext selection, TimelinePath activeGroup, TimelinePath activeTrack, TimelineLayout layout, Context c) { // Include the reference's offset into the Transform and InverseTransform properties. Matrix localToWorld = D2dTimelineControl.CalculateLocalToWorld(path); c.PushTransform(localToWorld, MatrixOrder.Prepend); // draw the row that has this timeline reference's name ITimelineReference reference = (ITimelineReference)path.Last; RectangleF clipBounds = m_graphics.ClipBounds; RectangleF bounds = layout.GetBounds(path); IHierarchicalTimeline timeline = reference.Target; if (bounds.IntersectsWith(clipBounds)) { DrawMode drawMode = DrawMode.Normal; if (selection.SelectionContains(path)) drawMode |= DrawMode.Selected; DrawTimelineReference(reference, bounds, drawMode, c); } // draw the timeline document as if it were the main document if (timeline != null) DrawSubTimeline(path, timeline, true, reference.Options.Expanded, selection, activeGroup, activeTrack, layout, c); c.PopTransform(); }
private void DrawSubTimeline( TimelinePath path, ITimeline timeline, bool subTimeline, bool expandedTimeline, ISelectionContext selection, TimelinePath activeGroup, TimelinePath activeTrack, TimelineLayout layout, Context c) { //if (c.TestRecursion(timeline)) // return; if (!subTimeline) m_offsetX = c.Transform.OffsetX; RectangleF clipBounds = m_graphics.ClipBounds; DrawGroupsAndTracks(path, timeline, expandedTimeline, selection, c, layout, clipBounds); // draw markers over keys, intervals, tracks, and group if (subTimeline) { // Give the Markers in the main timeline precedence; draw on top of everything. clipBounds.X = HeaderWidth; clipBounds.Width -= HeaderWidth; DrawMarkers(path, timeline, selection, c, layout, clipBounds); } // Draw the group and track handles only if the owning timeline is expanded. if (expandedTimeline) { if (m_printing) c.Graphics.TranslateTransform(m_marginBounds.Left, 0); RectangleF bounds; foreach (IGroup group in timeline.Groups) { IList<ITrack> tracks = group.Tracks; TimelinePath groupPath = path + group; bounds = layout.GetBounds(groupPath); bounds = GetGroupHandleRect(bounds, !group.Expanded); RectangleF groupLabelBounds = new RectangleF(bounds.X, bounds.Y, HeaderWidth, bounds.Height); // Draw group's move handle. DrawMoveHandle(bounds, selection.SelectionContains(groupPath), groupPath == activeGroup); // Draw expander? if (tracks.Count > 1) { RectangleF expanderRect = GetExpanderRect(bounds); m_graphics.DrawExpander( expanderRect.X, expanderRect.Y, expanderRect.Width, m_expanderBrush, group.Expanded); groupLabelBounds.X += TrackIndent; groupLabelBounds.Width -= TrackIndent; } // Draw tracks' move handles? if (group.Expanded || tracks.Count == 1) { foreach (ITrack track in tracks) { TimelinePath trackPath = path + track; bounds = layout.GetBounds(trackPath); bounds = GetTrackHandleRect(bounds); DrawMoveHandle(bounds, selection.SelectionContains(trackPath), trackPath == activeTrack); if (bounds.Width > 0f) m_graphics.DrawText(track.Name, m_trackTextFormat, bounds, m_nameBrush); } } // Draw group name. if (groupLabelBounds.Width > 0) m_graphics.DrawText(group.Name, c.TextFormat, groupLabelBounds, m_nameBrush); } if (m_printing) c.Graphics.TranslateTransform(-m_marginBounds.Left, 0); } return; }
private void DrawMarkers(TimelinePath path, ITimeline timeline, ISelectionContext selection, Context c, TimelineLayout layout, RectangleF clipBounds) { RectangleF bounds; foreach (IMarker marker in timeline.Markers) { TimelinePath markerPath = path + marker; if (!layout.TryGetBounds(markerPath, out bounds)) continue; if (bounds.IntersectsWith(clipBounds)) { DrawMode drawMode = DrawMode.Normal; if (selection.SelectionContains(markerPath)) drawMode |= DrawMode.Selected; Draw(marker, bounds, drawMode, c); } } }
internal static string GetDesc(this Record rec, ISelectionContext context) { string start = "[Record]" + Environment.NewLine + rec.GetBaseDesc(); string end; try { end = rec.GetExtendedDesc(context); } catch { end = "Warning: An error occurred while processing the record. It may not conform to the structure defined in RecordStructure.xml"; } if (end == null) { return start; } else { return start + Environment.NewLine + Environment.NewLine + "[Formatted information]" + Environment.NewLine + end; } }
/// <summary> /// Draws the timeline to the display</summary> /// <param name="timeline">Timeline</param> /// <param name="selection">Selected timeline objects</param> /// <param name="activeGroup">Currently active group, or null</param> /// <param name="activeTrack">Currently active track, or null</param> /// <param name="transform">Transform taking timeline objects to display coordinates</param> /// <param name="clientRectangle">Bounds of displayed area of timeline, in screen space</param> /// <param name="marginBounds">Page coordinate bounding rectangle for printing</param> public void Print( ITimeline timeline, ISelectionContext selection, TimelinePath activeGroup, TimelinePath activeTrack, Matrix transform, RectangleF clientRectangle, Rectangle marginBounds) { m_marginBounds = marginBounds; try { m_printing = true; Draw(timeline, selection, activeGroup, activeTrack, transform, clientRectangle); } finally { m_printing = false; } }
internal static string GetExtendedDesc(this Record rec, ISelectionContext selectContext) { var context = selectContext.Clone(); try { context.Record = rec; RecordStructure structure = rec.GetStructure(); if (structure == null) return string.Empty; var s = new StringBuilder(); s.AppendLine(structure.description); foreach (var subrec in rec.SubRecords) { if (subrec.Structure == null) { continue; } if (subrec.Structure.elements == null) { return s.ToString(); } if (subrec.Structure.notininfo) { continue; } s.AppendLine(); s.Append(subrec.GetFormattedData()); } return s.ToString(); } finally { context.Reset(); } }
/// <summary> /// Draws the timeline to the display</summary> /// <param name="timeline">Timeline</param> /// <param name="selection">Selected timeline objects</param> /// <param name="activeGroup">Currently active group, or null</param> /// <param name="activeTrack">Currently active track, or null</param> /// <param name="transform">Transform taking timeline objects to display coordinates</param> /// <param name="clientRectangle">Display coordinate bounding rectangle</param> /// <param name="g">Graphics object</param> /// <returns>Bounding rectangles for all timeline objects, organized in a dictionary of TimelinePath/RectangleF pairs</returns> public virtual TimelineLayout Draw( ITimeline timeline, ISelectionContext selection, TimelinePath activeGroup, TimelinePath activeTrack, Matrix transform, RectangleF clientRectangle, Graphics g) { if (m_printing) { transform.Translate(m_marginBounds.Left, m_marginBounds.Top, MatrixOrder.Append); g.SetClip(m_marginBounds); } Context c = new Context(this, transform, clientRectangle, g); TimelineLayout layout = Layout(timeline, c); c.ClearRecursionData(); // Clear the header column. g.FillRectangle(SystemBrushes.Control, 0, 0, m_headerWidth, c.ClientRectangle.Height); // Draw the main timeline and then any sub-timelines. DrawSubTimeline(null, timeline, false, true, selection, activeGroup, activeTrack, layout, c); foreach (TimelinePath path in TimelineControl.GetHierarchy(timeline)) DrawSubTimeline(path, selection, activeGroup, activeTrack, layout, c); // Draw the dark vertical line on the header that separates the groups and tracks. g.DrawLine(SystemPens.ControlDark, TrackIndent, m_timeScaleHeight, TrackIndent, c.ClientRectangle.Height); // Draw the dark vertical line on the right-side of the header, separating it from the canvas. g.DrawLine(SystemPens.ControlDark, m_headerWidth, m_timeScaleHeight, m_headerWidth, c.ClientRectangle.Height); // draw scales, etc. if (m_printing) c.Graphics.TranslateTransform(0, m_marginBounds.Top); DrawEventOverlay(c); // Draw the dark horizontal line underneath the scale. g.DrawLine(SystemPens.ControlDark, 0, m_timeScaleHeight, m_headerWidth, m_timeScaleHeight); // Give the Markers in the main timeline precedence over the scale and canvas RectangleF clipBounds = g.ClipBounds; clipBounds.X = m_headerWidth; DrawMarkers(null, timeline, selection, c, layout, clipBounds); return layout; }
private static IEnumerable<SvnProject> GetSelection(ISelectionContext iSelectionContext) { bool foundOne = false; foreach (SvnProject pr in iSelectionContext.GetSelectedProjects(true)) { yield return pr; foundOne = true; } if (foundOne) yield break; foreach (SvnProject pr in iSelectionContext.GetOwnerProjects()) { yield return pr; } }
private static void RemoveUnSelectedRows(ISelectionContext selectionContext, DataTable table) { if (selectionContext == null || selectionContext.SelectionInfo.Mode == "selectAll") return; // Clean up the table to include only our client side selections bool keep; IList<string> selections = selectionContext.GetSelectedIds(); int i = 1; foreach (DataRow row in table.Rows) { keep = false; foreach (string id in selections) { if (row[0].ToString() == id) { keep = true; continue; } } if (!keep) { row.Delete(); } i++; } table.AcceptChanges(); }
public new bool ShouldSelect(MethodData method, ISelectionContext context) { return base.ShouldSelect(method, context); }
private string GetExtendedDesc(ISelectionContext selectContext) { var context = selectContext.Clone(); try { context.Record = this; RecordStructure rec; if (!RecordStructure.Records.TryGetValue(Name, out rec)) { return string.Empty; } var s = new StringBuilder(); s.AppendLine(rec.description); foreach (var subrec in this.SubRecords) { if (subrec.Structure == null) { continue; } if (subrec.Structure.elements == null) { return s.ToString(); } if (subrec.Structure.notininfo) { continue; } s.AppendLine(); s.Append(subrec.GetFormattedData()); } return s.ToString(); } finally { context.Reset(); } }