public void EnabledShouldAffectChildControls(IContainerTypeInfo <Container> containerType, IControlTypeInfo <Control> controlType) { Invoke(() => { var enabledChild = controlType.CreateControl(); var disabledChild = controlType.CreateControl(); var neutralChild = controlType.CreateControl(); var childPanel = new TableLayout { Rows = { enabledChild, disabledChild, neutralChild } }; var container = containerType.CreateControl(childPanel); // load the control container.AttachNative(); var neutralEnabled = neutralChild.Enabled; // disabled child should always be disabled disabledChild.Enabled = false; enabledChild.Enabled = true; // default values Assert.IsTrue(container.Enabled, "#1.1"); Assert.IsTrue(enabledChild.Enabled, "#1.2"); Assert.IsFalse(disabledChild.Enabled, "#1.3"); Assert.AreEqual(neutralEnabled, neutralChild.Enabled, "#1.4"); // setting container to disabled container.Enabled = false; Assert.IsFalse(container.Enabled, "#2.1"); Assert.IsFalse(enabledChild.Enabled, "#2.2"); Assert.IsFalse(disabledChild.Enabled, "#2.3"); Assert.IsFalse(neutralChild.Enabled, "#2.4"); // set child to enabled when parent is disabled, should still stay disabled enabledChild.Enabled = true; Assert.IsFalse(container.Enabled, "#3.1"); Assert.IsFalse(enabledChild.Enabled, "#3.2"); Assert.IsFalse(disabledChild.Enabled, "#3.3"); Assert.IsFalse(neutralChild.Enabled, "#3.4"); // set container back to enabled container.Enabled = true; Assert.IsTrue(container.Enabled, "#4.1"); Assert.IsTrue(enabledChild.Enabled, "#4.2"); Assert.IsFalse(disabledChild.Enabled, "#4.3"); Assert.AreEqual(neutralEnabled, neutralChild.Enabled, "#4.4"); }); }
public void PanelPaddingBottomRightShouldWork(IContainerTypeInfo <Panel> type) { ManualForm( "There should be 40px padding at the bottom and right of the blue rectangle", form => { var panel = type.CreateControl(); Assert.IsNotNull(panel); panel.Padding = new Padding(0, 0, 40, 40); panel.Content = new Panel { BackgroundColor = Colors.Blue, Size = new Size(200, 200) }; return(type.CreateContainer(panel)); }); }
public static TypeClassification GetClassification(this Type type, IContainerTypeInfo containerInfo = null) { var ti = type.GetTypeInfo(); if (ti.IsPrimitive) { return(TypeClassification.Value); } if (ti.IsEnum) { return(TypeClassification.Value); } if (SystemValueClasses.Contains(type)) { return(TypeClassification.Value); } if (containerInfo == null) { containerInfo = type.GetContainerTypeInfo(); } if (containerInfo is DictionaryContainerTypeInfo) { return(TypeClassification.Dictionary); } if (containerInfo is CollectionContainerTypeInfo) { return(TypeClassification.Collection); } if (containerInfo is NullableContainerTypeInfo) { return(TypeClassification.Nullable); } return(TypeClassification.Complex); }
public static ArrayContainerTypeInfo AsArray(this IContainerTypeInfo container) { return(container as ArrayContainerTypeInfo); }
public static NullableContainerTypeInfo AsNullable(this IContainerTypeInfo container) { return(container as NullableContainerTypeInfo); }
public static DictionaryContainerTypeInfo AsDictionary(this IContainerTypeInfo container) { return(container as DictionaryContainerTypeInfo); }
public static CollectionContainerTypeInfo AsCollection(this IContainerTypeInfo container) { return(container as CollectionContainerTypeInfo); }
public void EnabledShouldAffectChildControlsWhenDynamicallyAdded(IContainerTypeInfo <Container> containerType, IControlTypeInfo <Control> controlType) { Invoke(() => { var enabledChild = controlType.CreateControl(); var disabledChild = controlType.CreateControl(); var neutralChild = controlType.CreateControl(); var childPanel = new Panel(); void addControls() => childPanel.Content = new TableLayout { Rows = { enabledChild, disabledChild, neutralChild } }; void removeControls() => childPanel.Content = null; var container = containerType.CreateControl(childPanel); // load the control (for virtual containers like Stack/Dynamic layouts) container.AttachNative(); var neutralEnabled = neutralChild.Enabled; // disabled child should always be disabled disabledChild.Enabled = false; enabledChild.Enabled = true; // default values Assert.IsTrue(container.Enabled, "#1.1"); Assert.IsTrue(enabledChild.Enabled, "#1.2"); Assert.IsFalse(disabledChild.Enabled, "#1.3"); Assert.AreEqual(neutralEnabled, neutralChild.Enabled, "#1.4"); addControls(); // default values after added to the container Assert.IsTrue(container.Enabled, "#2.1"); Assert.IsTrue(enabledChild.Enabled, "#2.2"); Assert.IsFalse(disabledChild.Enabled, "#2.3"); Assert.AreEqual(neutralEnabled, neutralChild.Enabled, "#2.4"); removeControls(); // setting container to disabled container.Enabled = false; // default values after removed from the container (and container set to disabled) Assert.IsTrue(enabledChild.Enabled, "#3.1"); Assert.IsFalse(disabledChild.Enabled, "#3.2"); Assert.AreEqual(neutralEnabled, neutralChild.Enabled, "#3.3"); addControls(); // values after adding back to the container Assert.IsFalse(container.Enabled, "#4.1"); Assert.IsFalse(enabledChild.Enabled, "#4.2"); Assert.IsFalse(disabledChild.Enabled, "#4.3"); Assert.IsFalse(neutralChild.Enabled, "#4.4"); // set child to enabled when parent is disabled, should still stay disabled enabledChild.Enabled = true; Assert.IsFalse(container.Enabled, "#5.1"); Assert.IsFalse(enabledChild.Enabled, "#5.2"); Assert.IsFalse(disabledChild.Enabled, "#5.3"); Assert.IsFalse(neutralChild.Enabled, "#5.4"); removeControls(); // default values after removed from the container (again) Assert.IsTrue(enabledChild.Enabled, "#6.1"); Assert.IsFalse(disabledChild.Enabled, "#6.2"); Assert.AreEqual(neutralEnabled, neutralChild.Enabled, "#6.3"); // set container back to enabled container.Enabled = true; addControls(); Assert.IsTrue(container.Enabled, "#7.1"); Assert.IsTrue(enabledChild.Enabled, "#7.2"); Assert.IsFalse(disabledChild.Enabled, "#7.3"); Assert.AreEqual(neutralEnabled, neutralChild.Enabled, "#7.4"); }); }
private static TypeClass GetTypeClass(Type type, IContainerTypeInfo containerInfo) { if (type.IsPrimitive) return TypeClass.Value; if (type.IsEnum) return TypeClass.Value; if (SystemValueClasses.Contains(type)) return TypeClass.Value; var dictionary = containerInfo as DictionaryContainerTypeInfo; if (dictionary != null) return TypeClass.Dictionary; var collection = containerInfo as CollectionContainerTypeInfo; if (collection != null) return TypeClass.Collection; var nullable = containerInfo as NullableContainerTypeInfo; if (nullable != null) return TypeClass.Nullable; return TypeClass.Complex; }