public void DesignerActionListCollection_Item_Set_GetReturnsExpected() { var collection = new DesignerActionListCollection(); var value1 = new DesignerActionList(null); var value2 = new DesignerActionList(null); collection.Add(value1); Assert.Same(value1, Assert.Single(collection)); collection[0] = value2; Assert.Same(value2, Assert.Single(collection)); Assert.Same(value2, collection[0]); Assert.False(collection.Contains(value1)); Assert.Equal(-1, collection.IndexOf(value1)); Assert.True(collection.Contains(value2)); Assert.Equal(0, collection.IndexOf(value2)); collection[0] = null; Assert.Null(Assert.Single(collection)); Assert.Null(collection[0]); Assert.False(collection.Contains(value2)); Assert.Equal(-1, collection.IndexOf(value2)); Assert.True(collection.Contains(null)); Assert.Equal(0, collection.IndexOf(null)); }
public void DesignerActionList_Ctor_IComponent(IComponent component) { var list = new DesignerActionList(component); Assert.Equal(component, list.Component); Assert.False(list.AutoShow); }
public MyTableLayoutPanelActionList(ControlDesigner designer, DesignerActionList actionList) : base(designer.Component) { this.designer = designer; this.actionList = actionList; control = (MyTableLayoutPanel)designer.Control; }
public void DesignerActionList_GetSortedActionItems_BaseClass_ReturnsEmpty() { var list = new DesignerActionList(null); DesignerActionItemCollection items = list.GetSortedActionItems(); Assert.Empty(items); }
/// <summary>Indicates that a comonents value is in the process of changing.</summary> public static void Change_Begin(DesignerActionList designer) { IComponentChangeService service = UIDesigner_Service.IComponentChangeService_FromActionList(designer); if (service != null) { service.OnComponentChanging(designer, null); } }
public SmartTagTransactions(string transactionname, DesignerActionList list, Control ctrl) { this.actionList = list; this.ctrl = ctrl; host = (IDesignerHost)this.actionList.GetService(typeof(IDesignerHost)); this.transaction = host.CreateTransaction(transactionname); changeService = (IComponentChangeService)this.actionList.GetService(typeof(IComponentChangeService)); changeService.OnComponentChanging(ctrl, null); }
public void DesignerActionListCollection_IndexOf_NoSuchValue_ReturnsNegativeOne() { var collection = new DesignerActionListCollection(); var value = new DesignerActionList(null); collection.Add(value); Assert.Equal(-1, collection.IndexOf(new DesignerActionList(null))); Assert.Equal(-1, collection.IndexOf(null)); }
public void DesignerActionListCollection_Contains_NoSuchValue_ReturnsFalse() { var collection = new DesignerActionListCollection(); var value = new DesignerActionList(null); collection.Add(value); Assert.False(collection.Contains(new DesignerActionList(null))); Assert.False(collection.Contains(null)); }
public void DesignerActionItemCollection_Insert_Contains_IndexOf() { DesignerActionListCollection underTest = CreateNewCollectionOfItems(5); Button button = new Button(); DesignerActionList list = new DesignerActionList(button); underTest.Insert(3, list); Assert.True(underTest.Contains(list)); Assert.Equal(3, underTest.IndexOf(list)); }
public void DesignerActionItemCollection_Remove() { DesignerActionListCollection underTest = CreateNewCollectionOfItems(5); Button button = new Button(); DesignerActionList list = new DesignerActionList(button); underTest.Insert(3, list); underTest.Remove(list); Assert.False(underTest.Contains(list)); Assert.Equal(5, underTest.Count); }
public void DesignerActionListCollection_CopyTo_Invoke_Success() { var collection = new DesignerActionListCollection(); var value = new DesignerActionList(null); collection.Add(value); var array = new DesignerActionList[3]; collection.CopyTo(array, 1); Assert.Equal(new DesignerActionList[] { null, value, null }, array); }
public void DesignerActionList_AutoShow_Set_GetReturnsExpected(bool value) { var list = new DesignerActionList(new Component()) { AutoShow = value }; Assert.Equal(value, list.AutoShow); // Set same. list.AutoShow = value; Assert.Equal(value, list.AutoShow); }
DesignerActionItem IActionGetItem.GetItem(DesignerActionList actions, MemberInfo mbr) { var ret = new DesignerActionMethodItem(actions, mbr.Name, DisplayName, Category, Description, IncludeAsDesignerVerb) { AllowAssociate = AllowAssociate }; if (!string.IsNullOrEmpty(Condition)) { ret.Properties.Add("Condition", Condition); } ret.Properties.Add("Order", DisplayOrder); return(ret); }
DesignerActionItem IActionGetItem.GetItem(DesignerActionList actions, System.Reflection.MemberInfo mbr) { var ret = new DesignerActionPropertyItem(mbr.Name, DisplayName, Category, Description) { AllowAssociate = AllowAssociate }; if (!string.IsNullOrEmpty(Condition)) { ret.Properties.Add("Condition", Condition); } ret.Properties.Add("Order", DisplayOrder); return(ret); }
public void DesignerActionListCollection_Clear_Success() { var collection = new DesignerActionListCollection(); var value = new DesignerActionList(null); collection.Add(value); collection.Clear(); Assert.Empty(collection); // Clear again. collection.Clear(); Assert.Empty(collection); }
private DesignerActionListCollection CreateNewCollectionOfItems(int numberOfItems = 1) { Button button = new Button(); DesignerActionList[] list = new DesignerActionList[] { new DesignerActionList(button) }; DesignerActionListCollection underTest = new DesignerActionListCollection(list); for (int i = 1; i < numberOfItems; i++) { underTest.Add(new DesignerActionList(button)); } return(underTest); }
public static IEnumerable <DesignerActionItem> GetAllAttributedActionItems(this DesignerActionList actionList) { var fullAIList = new List <DesignerActionItem>(); foreach (var mbr in actionList.GetType().GetMethods(allInstBind)) { foreach (IActionGetItem attr in mbr.GetCustomAttributes(typeof(DesignerActionMethodAttribute), true)) { if (mbr.ReturnType == typeof(void) && mbr.GetParameters().Length == 0) { fullAIList.Add(attr.GetItem(actionList, mbr)); } else { throw new FormatException("DesignerActionMethodAttribute must be applied to a method returning void and having no parameters."); } } } foreach (var mbr in actionList.GetType().GetProperties(allInstBind)) { if (mbr.GetIndexParameters().Length > 0) { throw new FormatException("DesignerActionPropertyAttribute must be applied to non-indexed properties."); } foreach (IActionGetItem attr in mbr.GetCustomAttributes(typeof(DesignerActionPropertyAttribute), true)) { fullAIList.Add(attr.GetItem(actionList, mbr)); } } fullAIList.Sort(CompareItems); return(fullAIList); int CompareItems(DesignerActionItem a, DesignerActionItem b) { var c = string.Compare(a?.Category ?? string.Empty, b?.Category ?? string.Empty, true); if (c != 0) { return(c); } c = (int)(a?.Properties["Order"] ?? 0) - (int)(b?.Properties["Order"] ?? 0); if (c != 0) { return(c); } return(string.Compare(a?.DisplayName, b?.DisplayName, true)); } }
public void DesignerActionMethodItem_Ctor_DesignerActionList_String_String(DesignerActionList actionList, string memberName, string displayName, string expectedDisplayName) { var item = new DesignerActionMethodItem(actionList, memberName, displayName); Assert.Equal(memberName, item.MemberName); Assert.Equal(expectedDisplayName, item.DisplayName); Assert.Null(item.Category); Assert.Null(item.Description); Assert.False(item.IncludeAsDesignerVerb); Assert.False(item.AllowAssociate); Assert.Empty(item.Properties); Assert.Same(item.Properties, item.Properties); Assert.IsType <HybridDictionary>(item.Properties); Assert.True(item.ShowInSourceView); Assert.Null(item.RelatedComponent); }
/// <summary> /// Removes the duplicate DockingActionList added by this designer to the <see cref="DesignerActionService"/>. /// </summary> /// <remarks> /// <see cref="ControlDesigner.Initialize"/> adds an internal DockingActionList : 'Dock/Undock in Parent Container'. /// But the default designer has already added that action list. So we need to remove one. /// </remarks> private void RemoveDuplicateDockingActionList() { // This is a true hack -- in a class that is basically a huge hack itself. // Reach into the bowel of our base class, get a private field, and use that fields value to // remove an action from the designer. // In ControlDesigner, there is "private DockingActionList dockingAction;" // Don't you just love Reflector?! FieldInfo fi = typeof(ControlDesigner).GetField("dockingAction", BindingFlags.Instance | BindingFlags.NonPublic); if (fi != null) { DesignerActionList dockingAction = (DesignerActionList)fi.GetValue(this); if (dockingAction != null) { DesignerActionService service = (DesignerActionService)GetService(typeof(DesignerActionService)); if (service != null) { service.Remove(this.Control, dockingAction); } } } }
public void DesignerActionItemCollection_Add_AddRange() { DesignerActionListCollection underTest = CreateNewCollectionOfItems(5); Assert.Equal(5, underTest.Count); Button button = new Button(); DesignerActionList list = new DesignerActionList(button); underTest.Add(list); Assert.Equal(6, underTest.Count); DesignerActionListCollection other = CreateNewCollectionOfItems(3); underTest.AddRange(other); Assert.Equal(9, underTest.Count); }
private DesignerActionMethodItem CreateDesignerActionMethodItem(string memberName, string displayName, string category, string description, bool includeAsDesignerVerb) { Button button = new Button(); DesignerActionList actionList = new DesignerActionList(button); if (category == null && description == null) { return(new DesignerActionMethodItem(actionList, memberName, displayName, includeAsDesignerVerb)); } else if (description == null) { return(new DesignerActionMethodItem(actionList, memberName, displayName, category, includeAsDesignerVerb)); } else { return(new DesignerActionMethodItem(actionList, memberName, displayName, category, description, includeAsDesignerVerb)); } }
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { string[] values = null; if (context != null) { WebFormsRootDesigner designer = null; IDesignerHost service = (IDesignerHost)context.GetService(typeof(IDesignerHost)); if (service != null) { IComponent rootComponent = service.RootComponent; if (rootComponent != null) { designer = service.GetDesigner(rootComponent) as WebFormsRootDesigner; } } if ((designer != null) && !designer.IsDesignerViewLocked) { IComponent instance = context.Instance as IComponent; if (instance == null) { DesignerActionList list = context.Instance as DesignerActionList; if (list != null) { instance = list.Component; } } IList <IComponent> allComponents = ControlHelper.GetAllComponents(instance, new ControlHelper.IsValidComponentDelegate(this.IsValidDataSource)); List <string> list3 = new List <string>(); foreach (IComponent component3 in allComponents) { Control control = component3 as Control; if (((control != null) && !string.IsNullOrEmpty(control.ID)) && !list3.Contains(control.ID)) { list3.Add(control.ID); } } list3.Sort(StringComparer.OrdinalIgnoreCase); list3.Insert(0, System.Design.SR.GetString("DataSourceIDChromeConverter_NoDataSource")); list3.Add(System.Design.SR.GetString("DataSourceIDChromeConverter_NewDataSource")); values = list3.ToArray(); } } return(new TypeConverter.StandardValuesCollection(values)); }
public void DesignerActionListCollection_Remove_Invoke_Success() { var collection = new DesignerActionListCollection(); var value = new DesignerActionList(null); collection.Add(value); Assert.Same(value, Assert.Single(collection)); collection.Remove(value); Assert.Empty(collection); Assert.False(collection.Contains(value)); Assert.Equal(-1, collection.IndexOf(value)); collection.Add(null); collection.Remove(null); Assert.Empty(collection); Assert.False(collection.Contains(null)); Assert.Equal(-1, collection.IndexOf(null)); }
private void CacheColumnEditingActionList(IComponent component) { if (designerActionService != null && columnEditing == null) { try { DesignerActionListCollection designerActionList = designerActionService.GetComponentActions(component, ComponentActionsType.Component); foreach (System.ComponentModel.Design.DesignerActionList dList in designerActionList) { if (dList.GetType().Name.Equals("DataGridViewColumnEditingActionList")) { this.columnEditing = dList; break; } } } catch { } } }
public static DesignerActionItemCollection GetFilteredActionItems(this DesignerActionList actionList, IEnumerable <DesignerActionItem> fullAIList) { var col = new DesignerActionItemCollection(); foreach (var ai in fullAIList) { if (CheckCondition(ai)) { col.Add(ai); } } // Add header items for displayed items string cat = null; for (var i = 0; i < col.Count; i++) { var curCat = col[i].Category; if (string.Compare(curCat, cat, true) != 0) { col.Insert(i++, new DesignerActionHeaderItem(curCat)); cat = curCat; } } return(col); bool CheckCondition(DesignerActionItem ai) { if (ai.Properties["Condition"] != null) { var p = actionList.GetType().GetProperty((string)ai.Properties["Condition"], allInstBind, null, typeof(bool), Type.EmptyTypes, null); if (p != null) { return((bool)p.GetValue(actionList, null)); } } return(true); } }
public void DesignerActionListCollection_Add_DesignerActionList_Success() { var collection = new DesignerActionListCollection(); var value1 = new DesignerActionList(null); collection.Add(value1); Assert.Same(value1, Assert.Single(collection)); Assert.Same(value1, collection[0]); Assert.True(collection.Contains(value1)); Assert.Equal(0, collection.IndexOf(value1)); var value2 = new DesignerActionList(null); collection.Add(value2); Assert.Equal(new object[] { value1, value2 }, collection.Cast <object>()); Assert.True(collection.Contains(value2)); Assert.Equal(1, collection.IndexOf(value2)); collection.Add(null); Assert.Equal(new object[] { value1, value2, null }, collection.Cast <object>()); Assert.True(collection.Contains(null)); Assert.Equal(2, collection.IndexOf(null)); }
public ListViewActionListAdapter(ObjectListViewDesigner designer, DesignerActionList wrappedList) : base(wrappedList.Component) { this.designer = designer; this.wrappedList = wrappedList; }
public void Remove(DesignerActionList value) {}
public void DesignerActionList_GetService_Invoke_ReturnsExpected(Component component, object expected) { var list = new DesignerActionList(component); Assert.Equal(expected, list.GetService(typeof(int))); }
public void CopyTo(DesignerActionList[] array, int index) {}
public DesignerActionListCollection(DesignerActionList[] value) {}
public DesignerActionMethodItem(DesignerActionList actionList, string memberName, string displayName, string category, bool includeAsDesignerVerb) {}
public void AddRange(DesignerActionList[] value) {}
public DesignerActionMethodItem(DesignerActionList actionList, string memberName, string displayName, string category, string description) : base(displayName, category, "") { throw null; }
public DesignerActionMethodItem(DesignerActionList actionList, string memberName, string displayName, string category, bool includeAsDesignerVerb) : base(displayName, category, "") { throw null; }
public void Remove(DesignerActionList actionList) {}
public void Add(System.ComponentModel.IComponent comp, DesignerActionList actionList) {}
public bool Contains(DesignerActionList value) {}
// Methods public int Add(DesignerActionList value) {}
public DesignerActionMethodItem(DesignerActionList actionList, string memberName, string displayName) {}
public int IndexOf(DesignerActionList value) {}
public DesignerActionMethodItem(DesignerActionList actionList, string memberName, string displayName, string category, string description) {}
public void Insert(int index, DesignerActionList value) {}