当前位置: 首页>>代码示例>>C#>>正文


C# Style.Reset方法代码示例

本文整理汇总了C#中System.Web.UI.WebControls.Style.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# Style.Reset方法的具体用法?C# Style.Reset怎么用?C# Style.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.WebControls.Style的用法示例。


在下文中一共展示了Style.Reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Style_GetStyleAttributes

		public void Style_GetStyleAttributes () {
			Style s;
			CssStyleCollection css;

			s = new Style ();
			css = s.GetStyleAttributes (null);
			Assert.AreEqual (0, css.Count, "GetStyleAttributes#1");

			s.Font.Bold = true;
			s.Font.Italic = true;
			s.Font.Size = 10;
			s.Font.Names = new string [] { "Arial", "Veranda" };
			s.Font.Overline = true;
			s.Font.Strikeout = true;
			s.Font.Underline = true;
			css = s.GetStyleAttributes (null);
			Assert.AreEqual ("bold", css ["font-weight"], "GetStyleAttributes#2");
			Assert.AreEqual ("italic", css ["font-style"], "GetStyleAttributes#3");
			Assert.AreEqual ("10pt", css ["font-size"], "GetStyleAttributes#4");
			Assert.AreEqual ("Arial,Veranda", css ["font-family"], "GetStyleAttributes#5");
			Assert.AreEqual (true, css ["text-decoration"].Contains ("overline"), "GetStyleAttributes#6");
			Assert.AreEqual (true, css ["text-decoration"].Contains ("line-through"), "GetStyleAttributes#7");
			Assert.AreEqual (true, css ["text-decoration"].Contains ("underline"), "GetStyleAttributes#8");

			s.Font.Names = null;
			css = s.GetStyleAttributes (null);
			Assert.AreEqual (null, css ["font-family"], "GetStyleAttributes#9");

			s.Font.Name = "Arial, Veranda";
			css = s.GetStyleAttributes (null);
			Assert.AreEqual ("Arial, Veranda", css ["font-family"], "GetStyleAttributes#10");

			s.Font.Name = "";
			css = s.GetStyleAttributes (null);
			Assert.AreEqual (null, css ["font-family"], "GetStyleAttributes#11");

			s.Font.Bold = false;
			s.Font.Italic = false;
			s.Font.Size = FontUnit.Empty;
			s.Font.Overline = false;
			s.Font.Strikeout = false;
			s.Font.Underline = false;
			css = s.GetStyleAttributes (null);
			Assert.AreEqual ("normal", css ["font-weight"], "GetStyleAttributes#12");
			Assert.AreEqual ("normal", css ["font-style"], "GetStyleAttributes#13");
			Assert.AreEqual (null, css ["font-size"], "GetStyleAttributes#14");
			Assert.AreEqual ("none", css ["text-decoration"], "GetStyleAttributes#15");

			s.Reset ();
			css = s.GetStyleAttributes (null);
			Assert.AreEqual (0, css.Count, "GetStyleAttributes#16");

			s.Reset ();
			s.Font.Underline = false;
			css = s.GetStyleAttributes (null);
			Assert.AreEqual ("none", css ["text-decoration"], "GetStyleAttributes#17");

			s.Reset ();
			s.BorderWidth = 1;
			s.BorderStyle = BorderStyle.Dashed;
			css = s.GetStyleAttributes (null);
			Assert.AreEqual ("Dashed", css ["border-style"], "GetStyleAttributes#18");
			Assert.AreEqual ("1px", css ["border-width"], "GetStyleAttributes#19");

			s.BorderStyle = BorderStyle.NotSet;
			css = s.GetStyleAttributes (null);
			Assert.AreEqual ("solid", css ["border-style"], "GetStyleAttributes#20");
			Assert.AreEqual ("1px", css ["border-width"], "GetStyleAttributes#21");

			s.BorderWidth = 0;
			css = s.GetStyleAttributes (null);
			Assert.AreEqual (null, css ["border-style"], "GetStyleAttributes#22");
			Assert.AreEqual ("0px", css ["border-width"], "GetStyleAttributes#23");
		}
开发者ID:nobled,项目名称:mono,代码行数:74,代码来源:StyleTest.cs


注:本文中的System.Web.UI.WebControls.Style.Reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。