本文整理汇总了C#中System.Web.UI.WebControls.Unit.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.ToString方法的具体用法?C# Unit.ToString怎么用?C# Unit.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.Unit
的用法示例。
在下文中一共展示了Unit.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PaddingRight
public HtmlAttributeManager PaddingRight(Unit padding)
{
return PaddingRight(padding.ToString());
}
示例2: SetUnitAttribute
protected internal void SetUnitAttribute(string attribute, Unit value)
{
if (value.IsEmpty)
{
this.RemoveAttribute(attribute);
}
else
{
UnitType type = value.Type;
if ((type != UnitType.Pixel) && (type != UnitType.Percentage))
{
throw new ArgumentException("Only pixel and percent values are allowed here.");
}
this.SetAttribute(attribute, value.ToString(CultureInfo.InvariantCulture));
}
}
示例3: InitRootTable
private static void InitRootTable(HtmlTable table, Unit width, Unit height)
{
table.CellPadding = 4;
table.CellSpacing = 0;
table.Style["width"] = width.ToString();
table.Style["height"] = height.ToString();
table.ID = "ContainerTable";
table.Attributes["class"] = "opinionListView";
}
示例4: RenderItemSpacing
private void RenderItemSpacing(HtmlTextWriter writer, Unit spacing, Orientation orientation) {
if (orientation == Orientation.Vertical) {
writer.AddStyleAttribute(HtmlTextWriterStyle.Height,
spacing.ToString(CultureInfo.InvariantCulture));
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.RenderEndTag();
writer.RenderEndTag();
}
else {
writer.AddStyleAttribute(HtmlTextWriterStyle.Width,
spacing.ToString(CultureInfo.InvariantCulture));
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.RenderEndTag();
}
}
示例5: ParseCultures
public void ParseCultures ()
{
// Test cultures where the decimal separator is not "."
CultureInfo ci = new CultureInfo ("es-ES", false);
Unit s1 = new Unit ("1,5cm", ci);
Assert.AreEqual (s1.Type, UnitType.Cm, "C1");
Assert.AreEqual (s1.Value, 1.5, "C2");
CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
CultureInfo currentUICulture = Thread.CurrentThread.CurrentUICulture;
try {
CultureInfo ciUS = CultureInfo.GetCultureInfo ("en-US");
Thread.CurrentThread.CurrentCulture = ciUS;
Thread.CurrentThread.CurrentUICulture = ciUS;
Assert.AreEqual (s1.ToString (), "1.5cm", "A54");
} finally {
Thread.CurrentThread.CurrentCulture = currentCulture;
Thread.CurrentThread.CurrentUICulture = currentUICulture;
}
Assert.AreEqual (s1.ToString (ci), "1,5cm", "A55");
}
示例6: Unit_IFormatProviderToString
public void Unit_IFormatProviderToString ()
{
MyFormatProvider mfp = new MyFormatProvider ();
Unit a1 = new Unit (1.0);
Assert.AreEqual ("1px", a1.ToString (mfp), "A1");
a1 = new Unit (1);
Assert.AreEqual ("1px", a1.ToString (mfp), "A2");
a1 = new Unit (32767);
Assert.AreEqual ("32767px", a1.ToString (mfp), "A3");
a1 = new Unit (-32768);
Assert.AreEqual ("-32768px", a1.ToString (mfp), "A4");
//
// String constructor
//
Unit s1 = new Unit ("-45cm");
Assert.AreEqual ("-45cm", s1.ToString (mfp), "A5");
s1 = new Unit ("\t-45cm");
Assert.AreEqual ("-45cm", s1.ToString (mfp), "A6");
s1 = new Unit ("45\tcm");
Assert.AreEqual ("45cm", s1.ToString (mfp), "A7");
s1 = new Unit (null);
Assert.AreEqual ("", s1.ToString (mfp), "A8");
s1 = new Unit ("-45");
Assert.AreEqual ("-45px", s1.ToString (mfp), "A9");
s1 = new Unit ("-45%");
Assert.AreEqual ("-45%", s1.ToString (mfp), "A10");
s1 = new Unit ("-45% \t ");
Assert.AreEqual ("-45%", s1.ToString (mfp), "A11");
s1 = new Unit ("-45 % \t ");
Assert.AreEqual ("-45%", s1.ToString (mfp), "A12");
s1 = new Unit ("45in");
Assert.AreEqual ("45in", s1.ToString (mfp), "A13");
s1 = new Unit ("45cm");
Assert.AreEqual ("45cm", s1.ToString (mfp), "A14");
s1 = new Unit ("45pt");
Assert.AreEqual ("45pt", s1.ToString (mfp), "A15");
s1 = new Unit ("45pc");
Assert.AreEqual ("45pc", s1.ToString (mfp), "A16");
s1 = new Unit ("45mm");
Assert.AreEqual ("45mm", s1.ToString (mfp), "A17");
s1 = new Unit ("45em");
Assert.AreEqual ("45em", s1.ToString (mfp), "A18");
s1 = new Unit ("45ex");
Assert.AreEqual ("45ex", s1.ToString (mfp), "A19");
s1 = new Unit ("45px");
Assert.AreEqual ("45px", s1.ToString (mfp), "A20");
s1 = new Unit ("1.75cm");
Assert.AreEqual ("1.75cm", s1.ToString (mfp), "A21");
s1 = new Unit ("1.75%");
Assert.AreEqual ("1.75%", s1.ToString (mfp), "A22");
s1 = new Unit (null);
Assert.AreEqual ("", s1.ToString (mfp), "A23");
s1 = new Unit ("");
Assert.AreEqual ("", s1.ToString (mfp), "A24");
s1 = new Unit ("45.75cm");
Assert.AreEqual ("45.75cm", s1.ToString (mfp), "A25");
a1 = new Unit (1.5);
Assert.AreEqual ("1px", a1.ToString (mfp), "A26");
}
示例7: Left
public HtmlAttributeManager Left(Unit position)
{
return Left(position.ToString());
}
示例8: RenderMenuItemSpacing
void RenderMenuItemSpacing (HtmlTextWriter writer, Unit itemSpacing, bool vertical) {
if (vertical) {
writer.AddStyleAttribute ("height", itemSpacing.ToString ());
writer.RenderBeginTag (HtmlTextWriterTag.Tr);
writer.RenderBeginTag (HtmlTextWriterTag.Td);
writer.RenderEndTag ();
writer.RenderEndTag ();
}
else {
writer.AddStyleAttribute ("width", itemSpacing.ToString ());
writer.RenderBeginTag (HtmlTextWriterTag.Td);
writer.RenderEndTag ();
}
}
示例9: Right
public HtmlAttributeManager Right(Unit position)
{
return Right(position.ToString());
}
示例10: Bottom
public HtmlAttributeManager Bottom(Unit position)
{
return Bottom(position.ToString());
}
示例11: Padding
public HtmlAttributeManager Padding(Unit padding)
{
return Style(HtmlTextWriterStyle.Padding, padding.ToString());
}
示例12: GetPopupDimension
private string GetPopupDimension(string name, Unit length, int min)
{
if (length.Type == UnitType.Pixel && length.Value >= min)
{
return length.ToString();
}
else
{
return min.ToString();
}
}
示例13: Test
private void Test(Type ctrlType)
{
Unit unit1;
try
{
this.GHTSubTestBegin(ctrlType, "Valid value");
unit1 = new Unit(120);
this.TestedControl.Width = unit1;
}
catch (Exception exception5)
{
// ProjectData.SetProjectError(exception5);
Exception exception1 = exception5;
this.GHTSubTestUnexpectedExceptionCaught(exception1);
// ProjectData.ClearProjectError();
}
try
{
this.GHTSubTestBegin(ctrlType, "Default value");
unit1 = this.TestedControl.Width;
this.GHTSubTestAddResult("Default width = " + unit1.ToString());
}
catch (Exception exception6)
{
// ProjectData.SetProjectError(exception6);
Exception exception2 = exception6;
this.GHTSubTestUnexpectedExceptionCaught(exception2);
// ProjectData.ClearProjectError();
}
this.GHTSubTestEnd();
try
{
this.GHTSubTestBegin(ctrlType, "Negative value");
unit1 = new Unit(-10);
this.TestedControl.Width = unit1;
this.GHTSubTestExpectedExceptionNotCaught("ArgumentException");
}
catch (ArgumentException exception7)
{
// ProjectData.SetProjectError(exception7);
// ArgumentException exception3 = exception7;
this.GHTSubTestAddResult("Test passed. Expected ArgumentException exception was caught.");
// ProjectData.ClearProjectError();
}
catch (Exception exception8)
{
// ProjectData.SetProjectError(exception8);
Exception exception4 = exception8;
this.GHTSubTestUnexpectedExceptionCaught(exception4);
// ProjectData.ClearProjectError();
}
this.GHTSubTestEnd();
}
示例14: WriteColumnHeader
/// <summary>
/// Write a new Column Header
/// </summary>
/// <param name="writer">HtmlTextWriter to write to </param>
/// <param name="cssClass">CssClass</param>
/// <param name="columnWidth">Column Width in Units</param>
/// <param name="headerText">Header text</param>
/// <param name="display">Should the header be displayed</param>
/// <param name="columnSpan">Column Span</param>
private static void WriteColumnHeader(HtmlTextWriter writer, string cssClass, Unit columnWidth, string headerText, bool display, int columnSpan)
{
// DrugDetails Column Header
writer.WriteBeginTag(HtmlTextWriterTag.Th.ToString());
if (columnSpan > 1)
{
writer.WriteAttribute("colspan", "3");
}
writer.WriteAttribute("class", cssClass);
writer.WriteAttribute("nowrap", "nowrap");
writer.Write(" style=\"");
writer.WriteStyleAttribute(HtmlTextWriterStyle.Width.ToString(), columnWidth.ToString());
if (!display)
{
writer.WriteStyleAttribute(HtmlTextWriterStyle.Display.ToString(), "none");
}
writer.Write(HtmlTextWriter.DoubleQuoteChar);
writer.Write(HtmlTextWriter.TagRightChar);
writer.WriteBeginTag(HtmlTextWriterTag.Div.ToString());
writer.Write(" style=\"");
writer.WriteStyleAttribute("white-space", "nowrap");
writer.WriteStyleAttribute("word-break", "none");
writer.Write(HtmlTextWriter.DoubleQuoteChar);
writer.Write(HtmlTextWriter.TagRightChar);
writer.Write(AntiXss.HtmlEncode(headerText));
writer.WriteEndTag(HtmlTextWriterTag.Div.ToString());
writer.WriteEndTag(HtmlTextWriterTag.Th.ToString());
}
示例15: Top
public HtmlAttributeManager Top(Unit position)
{
return Top(position.ToString());
}