public void MalformatTest6() { WebColorConverter conv; conv = new WebColorConverter(); Assert.AreEqual(Color.Fuchsia, conv.ConvertFrom(null, null, "#Fuchsia"), "M6"); }
public void MalformatTest7() { WebColorConverter conv; conv = new WebColorConverter(); Assert.AreEqual(Color.FromArgb(255, 254, 254, 254), conv.ConvertFrom(null, null, "garbage"), "M7"); }
public void MalformatTest4() { WebColorConverter conv; conv = new WebColorConverter(); Assert.AreEqual(Color.FromArgb(255, 1, 2, 3), conv.ConvertFrom(null, null, "#010203 Garbage"), "M4"); }
public void MalformatTest1() { WebColorConverter conv; conv = new WebColorConverter(); Assert.AreEqual(Color.Fuchsia, conv.ConvertFrom(null, null, "\rFuchsi\na\n"), "M1"); }
public void MalformatTest5() { WebColorConverter conv; conv = new WebColorConverter(); // Overflow Assert.AreEqual(Color.FromArgb(255, 254, 254, 254), conv.ConvertFrom(null, null, "4294901502"), "M5"); }
public void RoundTrip() { WebColorConverter wcc = new WebColorConverter(); Color c = (Color)wcc.ConvertFrom(null, null, " captiontext "); Assert.AreEqual("ActiveCaptionText", wcc.ConvertTo(null, null, c, typeof(string)), "#1"); }
public void Basic() { WebColorConverter conv; Color c; conv = new WebColorConverter(); Assert.AreEqual(true, conv.CanConvertFrom(null, typeof(string)), "B1"); Assert.AreEqual(true, conv.CanConvertTo(null, typeof(string)), "B2"); Assert.AreEqual(false, conv.CanConvertFrom(null, typeof(int)), "B3"); Assert.AreEqual(false, conv.CanConvertTo(null, typeof(int)), "B4"); c = Color.Fuchsia; Assert.AreEqual("Fuchsia", conv.ConvertTo(null, null, c, typeof(string)), "B5"); c = Color.FromArgb(1, 2, 3); Assert.AreEqual("#010203", conv.ConvertTo(null, null, c, typeof(string)), "B6"); c = Color.FromArgb(5, 1, 2, 3); Assert.AreEqual("#010203", conv.ConvertTo(null, null, c, typeof(string)), "B7"); c = Color.FromArgb(254, 253, 252); Assert.AreEqual("#FEFDFC", conv.ConvertTo(null, null, c, typeof(string)), "B8"); c = Color.FromKnownColor(KnownColor.BlanchedAlmond); Assert.AreEqual("BlanchedAlmond", conv.ConvertTo(null, null, c, typeof(string)), "B9"); c = Color.FromName("OingoBoingo"); Assert.AreEqual("#000000", conv.ConvertTo(null, null, c, typeof(string)), "B10"); Assert.AreEqual(Color.FromArgb(0, 0, 79, 80), conv.ConvertFrom(null, null, "020304"), "B11"); Assert.AreEqual(Color.FromArgb(0, 0, 79, 80), conv.ConvertFrom(null, null, "20304"), "B12"); Assert.AreEqual(Color.FromArgb(127, 255, 255, 255), conv.ConvertFrom(null, null, "2147483647"), "B13"); Assert.AreEqual(Color.FromArgb(128, 0, 0, 1), conv.ConvertFrom(null, null, "-2147483647"), "B14"); Assert.AreEqual(Color.FromArgb(255, 2, 3, 4), conv.ConvertFrom(null, null, "#FF020304"), "B15"); Assert.AreEqual(Color.FromArgb(2, 3, 4), conv.ConvertFrom(null, null, "#020304"), "B16"); Assert.AreEqual(Color.FromArgb(0, 2, 3, 4), conv.ConvertFrom(null, null, "#20304"), "B17"); Assert.AreEqual(Color.Fuchsia, conv.ConvertFrom(null, null, "Fuchsia"), "B18"); Assert.AreEqual(Color.FromArgb(0, 0, 2, 52), conv.ConvertFrom(null, null, "#234"), "B19"); // Garbage/whitespace tests c = Color.FromName("\rGarbage\n"); Assert.AreEqual("#000000", conv.ConvertTo(null, null, c, typeof(string)), "B20"); Assert.AreEqual(Color.Fuchsia, conv.ConvertFrom(null, null, "\rFuchsia\n"), "B21"); Assert.AreEqual(Color.FromArgb(255, 1, 2, 3), conv.ConvertFrom(null, null, "#010203"), "B22"); Assert.AreEqual(Color.Empty, conv.ConvertFrom(null, null, ""), "B23"); Assert.AreEqual(Color.FromArgb(0, 0, 0, 1), conv.ConvertFrom(null, null, "#1"), "B24"); Assert.AreEqual(Color.FromArgb(0, 0, 0, 0x12), conv.ConvertFrom(null, null, "#12"), "B25"); Assert.AreEqual(Color.FromArgb(0, 0, 1, 0x23), conv.ConvertFrom(null, null, "#123"), "B26"); Assert.AreEqual(Color.FromArgb(0, 0, 0x12, 0x34), conv.ConvertFrom(null, null, "#1234"), "B27"); Assert.AreEqual(Color.FromArgb(0, 1, 0x23, 0x45), conv.ConvertFrom(null, null, "#12345"), "B28"); Assert.AreEqual(Color.FromArgb(0xff, 0x12, 0x34, 0x56), conv.ConvertFrom(null, null, "#123456"), "B29"); Assert.AreEqual(Color.FromArgb(0x1, 0x23, 0x45, 0x67), conv.ConvertFrom(null, null, "#1234567"), "B30"); Assert.AreEqual(Color.FromArgb(0x12, 0x34, 0x56, 0x78), conv.ConvertFrom(null, null, "#12345678"), "B31"); }
public void NamedColorsCSS2() { WebColorConverter wcc = new WebColorConverter(); Color c; c = (Color)wcc.ConvertFrom(null, null, "ActiveBorder"); Assert.IsTrue(c.IsKnownColor, "#A1"); Assert.AreEqual("ActiveBorder", c.Name, "#A1-1"); c = (Color)wcc.ConvertFrom(null, null, "ActiveCaption"); Assert.IsTrue(c.IsKnownColor, "#A2"); Assert.AreEqual("ActiveCaption", c.Name, "#A2-1"); c = (Color)wcc.ConvertFrom(null, null, "AppWorkspace"); Assert.IsTrue(c.IsKnownColor, "#A3"); Assert.AreEqual("AppWorkspace", c.Name, "#A3-1"); c = (Color)wcc.ConvertFrom(null, null, "Background"); Assert.IsTrue(c.IsKnownColor, "#A4"); Assert.AreEqual("Desktop", c.Name, "#A1-4"); c = (Color)wcc.ConvertFrom(null, null, "ButtonFace"); Assert.IsTrue(c.IsKnownColor, "#A5"); Assert.AreEqual("Control", c.Name, "#A5-1"); c = (Color)wcc.ConvertFrom(null, null, "ButtonHighlight"); Assert.IsTrue(c.IsKnownColor, "#A6"); Assert.AreEqual("ControlLightLight", c.Name, "#A6-1"); c = (Color)wcc.ConvertFrom(null, null, "ButtonShadow"); Assert.IsTrue(c.IsKnownColor, "#A7"); Assert.AreEqual("ControlDark", c.Name, "#A7-1"); c = (Color)wcc.ConvertFrom(null, null, "ButtonText"); Assert.IsTrue(c.IsKnownColor, "#A8"); Assert.AreEqual("ControlText", c.Name, "#A8-1"); c = (Color)wcc.ConvertFrom(null, null, "CaptionText"); Assert.IsTrue(c.IsKnownColor, "#A9"); Assert.AreEqual("ActiveCaptionText", c.Name, "#A9-1"); c = (Color)wcc.ConvertFrom(null, null, "GrayText"); Assert.IsTrue(c.IsKnownColor, "#A10"); Assert.AreEqual("GrayText", c.Name, "#A10-1"); c = (Color)wcc.ConvertFrom(null, null, "Highlight"); Assert.IsTrue(c.IsKnownColor, "#A11"); Assert.AreEqual("Highlight", c.Name, "#A11-1"); c = (Color)wcc.ConvertFrom(null, null, "HighlightText"); Assert.IsTrue(c.IsKnownColor, "#A12"); Assert.AreEqual("HighlightText", c.Name, "#A12-1"); c = (Color)wcc.ConvertFrom(null, null, "InactiveBorder"); Assert.IsTrue(c.IsKnownColor, "#A13"); Assert.AreEqual("InactiveBorder", c.Name, "#A13-1"); c = (Color)wcc.ConvertFrom(null, null, "InactiveCaption"); Assert.IsTrue(c.IsKnownColor, "#A14"); Assert.AreEqual("InactiveCaption", c.Name, "#A14-1"); c = (Color)wcc.ConvertFrom(null, null, "InactiveCaptionText"); Assert.IsTrue(c.IsKnownColor, "#A15"); Assert.AreEqual("InactiveCaptionText", c.Name, "#A15-1"); c = (Color)wcc.ConvertFrom(null, null, "InfoBackground"); Assert.IsTrue(c.IsKnownColor, "#A16"); Assert.AreEqual("Info", c.Name, "#A16-1"); c = (Color)wcc.ConvertFrom(null, null, "InfoText"); Assert.IsTrue(c.IsKnownColor, "#A17"); Assert.AreEqual("InfoText", c.Name, "#A17-1"); c = (Color)wcc.ConvertFrom(null, null, "Menu"); Assert.IsTrue(c.IsKnownColor, "#A18"); Assert.AreEqual("Menu", c.Name, "#A18-1"); c = (Color)wcc.ConvertFrom(null, null, "MenuText"); Assert.IsTrue(c.IsKnownColor, "#A19"); Assert.AreEqual("MenuText", c.Name, "#A19-1"); c = (Color)wcc.ConvertFrom(null, null, "ScrollBar"); Assert.IsTrue(c.IsKnownColor, "#A20"); Assert.AreEqual("ScrollBar", c.Name, "#A20-1"); c = (Color)wcc.ConvertFrom(null, null, "ThreeDDarkShadow"); Assert.IsTrue(c.IsKnownColor, "#A21"); Assert.AreEqual("ControlDarkDark", c.Name, "#A21-1"); c = (Color)wcc.ConvertFrom(null, null, "ThreeDFace"); Assert.IsTrue(c.IsKnownColor, "#A22"); Assert.AreEqual("Control", c.Name, "#A22-1"); c = (Color)wcc.ConvertFrom(null, null, "ThreeDHighlight"); Assert.IsTrue(c.IsKnownColor, "#A23"); Assert.AreEqual("ControlLight", c.Name, "#A23-1"); c = (Color)wcc.ConvertFrom(null, null, "ThreeDLightShadow"); Assert.IsTrue(c.IsKnownColor, "#A24"); Assert.AreEqual("ControlLightLight", c.Name, "#A24-1"); Exception ex = null; try { c = (Color)wcc.ConvertFrom(null, null, "ThreeDShadow"); } catch (Exception e) { ex = e; } Assert.IsNotNull(ex, "#A25"); c = (Color)wcc.ConvertFrom(null, null, "Window"); Assert.IsTrue(c.IsKnownColor, "#A26"); Assert.AreEqual("Window", c.Name, "#A26-1"); c = (Color)wcc.ConvertFrom(null, null, "WindowFrame"); Assert.IsTrue(c.IsKnownColor, "#A27"); Assert.AreEqual("WindowFrame", c.Name, "#A27-1"); c = (Color)wcc.ConvertFrom(null, null, "WindowText"); Assert.IsTrue(c.IsKnownColor, "#A28"); Assert.AreEqual("WindowText", c.Name, "#A28-1"); }
protected void rptCartItems_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { bool isCartItem = (e.Item.DataItem is CartItem); if (!isCartItem) { return; } var item = e.Item.DataItemAs <CartItem>(); var trHeader = new TableRow(); var converter = new WebColorConverter(); trHeader.BackColor = (Color)converter.ConvertFrom("#" + AppLogic.AppConfig("LightCellColor")); // headers.. var tdItemNameHeader = new TableCell(); tdItemNameHeader.Width = Unit.Percentage(30); var lblItemNameHeader = new Label(); lblItemNameHeader.Text = string.Format("<b>{0}</b>", AppLogic.GetString("shoppingcart.cs.1", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)); tdItemNameHeader.Controls.Add(lblItemNameHeader); trHeader.Cells.Add(tdItemNameHeader); var tdShipHeader = new TableCell(); tdShipHeader.Width = Unit.Percentage(70); var lblShipHeader = new Label(); lblShipHeader.Text = string.Format("<b>{0}</b>", AppLogic.GetString("shoppingcart.cs.24", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)); tdShipHeader.Controls.Add(lblShipHeader); trHeader.Cells.Add(tdShipHeader); e.Item.Controls.Add(trHeader); // details var trDetail = new TableRow(); var tdDetailCaption = new TableCell() { Width = Unit.Percentage(30), VerticalAlign = VerticalAlign.Top, }; trDetail.Cells.Add(tdDetailCaption); var lblItemName = new Label() { Text = item.DisplayName }; tdDetailCaption.Controls.Add(lblItemName); var tdDetailAddNew = new TableCell() { Width = Unit.Percentage(70), VerticalAlign = VerticalAlign.Top }; trDetail.Cells.Add(tdDetailAddNew); e.Item.Controls.Add(trDetail); if (item.IsDownload || item.IsService) { var lblNoShippingRequired = new Label() { Text = AppLogic.GetString("checkoutshippingmult.aspx.7", ThisCustomer.SkinID, ThisCustomer.LocaleSetting) }; tdDetailAddNew.Controls.Add(lblNoShippingRequired); tdDetailAddNew.Controls.Add(new LiteralControl("<br />")); tdDetailAddNew.Controls.Add(new LiteralControl("<br />")); } else { var ctrlAddressSelector = new AddressSelectorControl() { ID = "ctrlAddressSelector" }; var availableAddresses = new List <Address>(); availableAddresses.AddRange(ThisCustomer.ShippingAddresses); bool shouldNotContainingTheSameAddressId = !ThisCustomer.ShippingAddresses.Any(addressItem => addressItem.AddressID == item.m_ShippingAddressID && !item.GiftRegistryID.HasValue); if (item.GiftRegistryID.HasValue && shouldNotContainingTheSameAddressId) { var registryBillingAddress = ThisCustomer.GetRegistryItemShippingAddress(item.m_ShippingAddressID, item.GiftRegistryID); availableAddresses.Add(registryBillingAddress); availableAddresses.Reverse(); } ctrlAddressSelector.AddressesDataSource = availableAddresses; ctrlAddressSelector.SelectedAddressID = item.m_ShippingAddressID; tdDetailAddNew.Controls.Add(ctrlAddressSelector); var script = new StringBuilder(); script.Append("<script type=\"text/javascript\" language=\"Javascript\" >\n"); script.Append("$add_windowLoad(\n"); script.Append(" function() { \n"); script.AppendFormat(" var row = new ise.Controls.CheckOutShippingMultiItemRowControl();\n"); script.AppendFormat(" row.setAddressSelectorcontrolId('{0}');\n", ctrlAddressSelector.ClientID); script.Append(" }\n"); script.Append(");\n"); script.Append("</script>\n"); Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), script.ToString()); } } }