コード例 #1
0
        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));
        }
コード例 #2
0
        public void DesignerActionList_Ctor_IComponent(IComponent component)
        {
            var list = new DesignerActionList(component);

            Assert.Equal(component, list.Component);
            Assert.False(list.AutoShow);
        }
コード例 #3
0
 public MyTableLayoutPanelActionList(ControlDesigner designer,
                                     DesignerActionList actionList) : base(designer.Component)
 {
     this.designer   = designer;
     this.actionList = actionList;
     control         = (MyTableLayoutPanel)designer.Control;
 }
コード例 #4
0
        public void DesignerActionList_GetSortedActionItems_BaseClass_ReturnsEmpty()
        {
            var list = new DesignerActionList(null);
            DesignerActionItemCollection items = list.GetSortedActionItems();

            Assert.Empty(items);
        }
コード例 #5
0
        /// <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);
            }
        }
コード例 #6
0
 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);
 }
コード例 #7
0
        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));
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        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));
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        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);
        }
コード例 #16
0
        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);
        }
コード例 #17
0
        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));
            }
        }
コード例 #18
0
        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);
        }
コード例 #19
0
 /// <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);
             }
         }
     }
 }
コード例 #20
0
        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);
        }
コード例 #21
0
        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));
            }
        }
コード例 #22
0
 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));
 }
コード例 #23
0
        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));
        }
コード例 #24
0
 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 { }
     }
 }
コード例 #25
0
        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);
            }
        }
コード例 #26
0
        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));
        }
コード例 #27
0
 public ListViewActionListAdapter(ObjectListViewDesigner designer, DesignerActionList wrappedList)
     : base(wrappedList.Component)
 {
     this.designer    = designer;
     this.wrappedList = wrappedList;
 }
	public void Remove(DesignerActionList value) {}
コード例 #29
0
        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) {}
コード例 #34
0
 public DesignerActionMethodItem(DesignerActionList actionList, string memberName, string displayName, string category, string description)
     : base(displayName, category, "")
 {
     throw null;
 }
コード例 #35
0
 public DesignerActionMethodItem(DesignerActionList actionList, string memberName, string displayName, string category, bool includeAsDesignerVerb)
     : base(displayName, category, "")
 {
     throw null;
 }
コード例 #36
0
	public void Remove(DesignerActionList actionList) {}
コード例 #37
0
	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) {}