public void TableLayoutSettings_SetRowSpan_MultipleTimes_GetReturnsExpected(TableLayoutSettings settings) { var control = new ScrollableControl(); settings.SetRowSpan(control, 1); Assert.Equal(1, settings.GetRowSpan(control)); settings.SetRowSpan(control, 2); Assert.Equal(2, settings.GetRowSpan(control)); }
public void TableLayoutSettings_SetRowSpan_ValidControl_GetReturnsExpected(TableLayoutSettings settings, int value) { var control = new ScrollableControl(); settings.SetRowSpan(control, value); Assert.Equal(value, settings.GetRowSpan(control)); }
public void TableLayoutSettingsTypeConverter_ConvertTo_HasStylesAndControls_ReturnsExpected() { var toolStrip = new ToolStrip { LayoutStyle = ToolStripLayoutStyle.Table }; toolStrip.Items.Add(new ToolStripLabel("text")); TableLayoutSettings settings = Assert.IsType <TableLayoutSettings>(toolStrip.LayoutSettings); settings.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 1)); settings.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 2)); settings.RowStyles.Add(new RowStyle(SizeType.AutoSize, 1)); settings.RowStyles.Add(new RowStyle(SizeType.Absolute, 2)); var control = new ScrollableControl(); settings.SetColumnSpan(control, 1); settings.SetRowSpan(control, 2); settings.SetColumn(control, 3); settings.SetRow(control, 4); var converter = new TableLayoutSettingsTypeConverter(); string result = Assert.IsType <string>(converter.ConvertTo(settings, typeof(string))); Assert.Equal(@"<?xml version=""1.0"" encoding=""utf-16""?><TableLayoutSettings><Controls /><Columns Styles=""AutoSize,1,Absolute,2"" /><Rows Styles=""AutoSize,1,Absolute,2"" /></TableLayoutSettings>", result); }
private int ParseControl(XmlDocument xmldoc, TableLayoutSettings settings) { int count = 0; foreach (XmlNode node in xmldoc.GetElementsByTagName("Control")) { if (node.Attributes["Name"] == null || string.IsNullOrEmpty(node.Attributes["Name"].Value)) { continue; } if (node.Attributes["Row"] != null) { settings.SetRow(node.Attributes["Name"].Value, GetValue(node.Attributes["Row"].Value)); count++; } if (node.Attributes["RowSpan"] != null) { settings.SetRowSpan(node.Attributes["Name"].Value, GetValue(node.Attributes["RowSpan"].Value)); } if (node.Attributes["Column"] != null) { settings.SetColumn(node.Attributes["Name"].Value, GetValue(node.Attributes["Column"].Value)); } if (node.Attributes["ColumnSpan"] != null) { settings.SetColumnSpan(node.Attributes["Name"].Value, GetValue(node.Attributes["ColumnSpan"].Value)); } } return(count); }
public void SetRowSpan(object target, int value) { if (TableLayoutSettings == null) { return; } TableLayoutSettings.SetRowSpan(target, value); }
public void TableLayoutSettings_SetRowSpan_InvalidControlStub_GetReturnsExpected() { var converter = new TableLayoutSettingsTypeConverter(); TableLayoutSettings settings = Assert.IsType <TableLayoutSettings>(converter.ConvertFrom(@"<?xml version=""1.0"" encoding=""utf-16""?><Root />")); settings.SetRowSpan("control", 1); Assert.Equal(1, settings.GetRowSpan("control")); }
public void TableLayoutSettings_SetRowSpan_InvalidControl_ThrowsNotSupportedException() { var toolStrip = new ToolStrip { LayoutStyle = ToolStripLayoutStyle.Table }; TableLayoutSettings settings = Assert.IsType <TableLayoutSettings>(toolStrip.LayoutSettings); Assert.Throws <NotSupportedException>(() => settings.SetRowSpan("control", 1)); }
public void TableLayoutSettings_SetRowSpan_InvalidValue_ThrowsArgumentOutOfRangeException(int value) { var toolStrip = new ToolStrip { LayoutStyle = ToolStripLayoutStyle.Table }; TableLayoutSettings settings = Assert.IsType <TableLayoutSettings>(toolStrip.LayoutSettings); Assert.Throws <ArgumentOutOfRangeException>("value", () => settings.SetRowSpan("control", value)); }
public void TableLayoutPanel_LayoutSettings_SetStubWithControls_Success() { var converter = new TableLayoutSettingsTypeConverter(); var panel = new TableLayoutPanel(); TableLayoutSettings settings = Assert.IsType <TableLayoutSettings>(converter.ConvertFrom(@"<?xml version=""1.0"" encoding=""utf-16""?><Root />")); var columnStyle = new ColumnStyle(SizeType.Percent, 1); var rowStyle = new RowStyle(SizeType.Percent, 1); settings.SetColumnSpan("name", 1); settings.SetRowSpan("name", 2); settings.SetColumn("name", 3); settings.SetRow("name", 4); settings.SetColumnSpan("noSuchName", 5); settings.SetRowSpan("noSuchName", 6); settings.SetColumn("noSuchName", 7); settings.SetRow("noSuchName", 8); settings.ColumnStyles.Add(columnStyle); settings.RowStyles.Add(rowStyle); var controlWithName = new ScrollableControl { Name = "name" }; var controlWithDefaultName = new ScrollableControl(); var controlWithoutName = new ControlWithoutName(); panel.Controls.Add(controlWithName); panel.Controls.Add(controlWithDefaultName); panel.Controls.Add(controlWithoutName); panel.LayoutSettings = settings; Assert.Equal(columnStyle, Assert.Single(panel.LayoutSettings.ColumnStyles)); Assert.Equal(rowStyle, Assert.Single(panel.LayoutSettings.RowStyles)); Assert.Equal(1, panel.LayoutSettings.GetColumnSpan(controlWithName)); Assert.Equal(2, panel.LayoutSettings.GetRowSpan(controlWithName)); Assert.Equal(3, panel.LayoutSettings.GetColumn(controlWithName)); Assert.Equal(4, panel.LayoutSettings.GetRow(controlWithName)); }
public void TableLayoutSettingsTypeConverter_ConvertTo_StubWithChildren_ReturnsExpected() { var converter = new TableLayoutSettingsTypeConverter(); TableLayoutSettings settings = Assert.IsType <TableLayoutSettings>(converter.ConvertFrom(@"<?xml version=""1.0"" encoding=""utf-16""?><Root />")); settings.SetColumnSpan("name", 1); settings.SetRowSpan("name", 2); settings.SetColumn("name", 3); settings.SetRow("name", 4); string result = Assert.IsType <string>(converter.ConvertTo(settings, typeof(string))); Assert.Equal(@"<?xml version=""1.0"" encoding=""utf-16""?><TableLayoutSettings><Controls><Control Name=""name"" Row=""4"" RowSpan=""2"" Column=""3"" ColumnSpan=""1"" /></Controls><Columns Styles="""" /><Rows Styles="""" /></TableLayoutSettings>", result); }
public void TableLayoutSettingsTypeConverter_ConvertTo_HasControlChildren_ReturnsExpected() { var panel = new TableLayoutPanel(); var control = new ScrollableControl(); TableLayoutSettings settings = Assert.IsType <TableLayoutSettings>(panel.LayoutSettings); panel.Controls.Add(control); settings.SetColumnSpan(control, 1); settings.SetRowSpan(control, 2); settings.SetColumn(control, 3); settings.SetRow(control, 4); var converter = new TableLayoutSettingsTypeConverter(); string result = Assert.IsType <string>(converter.ConvertTo(settings, typeof(string))); Assert.Equal(@"<?xml version=""1.0"" encoding=""utf-16""?><TableLayoutSettings><Controls><Control Name="""" Row=""4"" RowSpan=""2"" Column=""3"" ColumnSpan=""1"" /></Controls><Columns Styles="""" /><Rows Styles="""" /></TableLayoutSettings>", result); }
private void ParseControls(TableLayoutSettings settings, XmlNodeList controlXmlFragments) { foreach (XmlNode node in controlXmlFragments) { string attributeValue = this.GetAttributeValue(node, "Name"); if (!string.IsNullOrEmpty(attributeValue)) { int row = this.GetAttributeValue(node, "Row", -1); int num2 = this.GetAttributeValue(node, "RowSpan", 1); int column = this.GetAttributeValue(node, "Column", -1); int num4 = this.GetAttributeValue(node, "ColumnSpan", 1); settings.SetRow(attributeValue, row); settings.SetColumn(attributeValue, column); settings.SetRowSpan(attributeValue, num2); settings.SetColumnSpan(attributeValue, num4); } } }
private void ParseControls(TableLayoutSettings settings, XmlNodeList controlXmlFragments) { foreach (XmlNode controlXmlNode in controlXmlFragments) { string name = GetAttributeValue(controlXmlNode, "Name"); if (!string.IsNullOrEmpty(name)) { int row = GetAttributeValue(controlXmlNode, "Row", /*default*/ -1); int rowSpan = GetAttributeValue(controlXmlNode, "RowSpan", /*default*/ 1); int column = GetAttributeValue(controlXmlNode, "Column", /*default*/ -1); int columnSpan = GetAttributeValue(controlXmlNode, "ColumnSpan", /*default*/ 1); settings.SetRow(name, row); settings.SetColumn(name, column); settings.SetRowSpan(name, rowSpan); settings.SetColumnSpan(name, columnSpan); } } }
public void TableLayoutSettings_Serialize_Deserialize_Success() { var toolStrip = new ToolStrip { LayoutStyle = ToolStripLayoutStyle.Table }; TableLayoutSettings settings = Assert.IsType <TableLayoutSettings>(toolStrip.LayoutSettings); var columnStyle = new ColumnStyle(SizeType.Percent, 1); var rowStyle = new RowStyle(SizeType.Percent, 1); var controlWithName = new ScrollableControl { Name = "name" }; settings.SetColumnSpan(controlWithName, 1); settings.SetRowSpan(controlWithName, 2); settings.SetColumn(controlWithName, 3); settings.SetRow(controlWithName, 4); settings.ColumnStyles.Add(columnStyle); settings.RowStyles.Add(rowStyle); using (var stream = new MemoryStream()) { var formatter = new BinaryFormatter(); formatter.Serialize(stream, settings); stream.Seek(0, SeekOrigin.Begin); TableLayoutSettings result = Assert.IsType <TableLayoutSettings>(formatter.Deserialize(stream)); Assert.Equal(columnStyle.SizeType, ((ColumnStyle)Assert.Single(result.ColumnStyles)).SizeType); Assert.Equal(columnStyle.Width, ((ColumnStyle)Assert.Single(result.ColumnStyles)).Width); Assert.Equal(rowStyle.SizeType, ((RowStyle)Assert.Single(result.RowStyles)).SizeType); Assert.Equal(rowStyle.Height, ((RowStyle)Assert.Single(result.RowStyles)).Height); Assert.Equal(1, result.GetColumnSpan(controlWithName)); Assert.Equal(1, result.GetRowSpan(controlWithName)); Assert.Equal(-1, result.GetColumn(controlWithName)); Assert.Equal(-1, result.GetRow(controlWithName)); } }
private void ParseControls(TableLayoutSettings settings, XmlNodeList controlXmlFragments) { foreach (XmlNode controlXmlNode in controlXmlFragments) { string name = GetAttributeValue(controlXmlNode, "Name"); if (!string.IsNullOrEmpty(name)) { int row = GetAttributeValue(controlXmlNode, "Row", /*default*/-1); int rowSpan = GetAttributeValue(controlXmlNode, "RowSpan", /*default*/1); int column = GetAttributeValue(controlXmlNode, "Column", /*default*/-1); int columnSpan = GetAttributeValue(controlXmlNode, "ColumnSpan",/*default*/1); settings.SetRow(name, row); settings.SetColumn(name, column); settings.SetRowSpan(name, rowSpan); settings.SetColumnSpan(name, columnSpan); } } }
public void TableLayoutSettings_SetRowSpan_NullControl_ThrowsArgumentNullException(TableLayoutSettings settings) { Assert.Throws <ArgumentNullException>("control", () => settings.SetRowSpan(null, 1)); Assert.Throws <ArgumentNullException>("control", () => settings.SetRowSpan(null, 0)); }
private int ParseControl (XmlDocument xmldoc, TableLayoutSettings settings) { int count = 0; foreach (XmlNode node in xmldoc.GetElementsByTagName ("Control")) { if (node.Attributes["Name"] == null || string.IsNullOrEmpty(node.Attributes["Name"].Value)) continue; if (node.Attributes["Row"] != null) { settings.SetRow (node.Attributes["Name"].Value, GetValue (node.Attributes["Row"].Value)); count++; } if (node.Attributes["RowSpan"] != null) { settings.SetRowSpan (node.Attributes["Name"].Value, GetValue (node.Attributes["RowSpan"].Value)); } if (node.Attributes["Column"] != null) settings.SetColumn (node.Attributes["Name"].Value, GetValue (node.Attributes["Column"].Value)); if (node.Attributes["ColumnSpan"] != null) settings.SetColumnSpan (node.Attributes["Name"].Value, GetValue (node.Attributes["ColumnSpan"].Value)); } return count; }