本文整理汇总了C#中Image.RenderControl方法的典型用法代码示例。如果您正苦于以下问题:C# Image.RenderControl方法的具体用法?C# Image.RenderControl怎么用?C# Image.RenderControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image.RenderControl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderContents
protected internal override void RenderContents(HtmlTextWriter writer)
{
string imageUrl = this.ImageUrl;
if (!string.IsNullOrEmpty(imageUrl))
{
Image image = new Image {
ImageUrl = base.ResolveClientUrl(imageUrl)
};
string toolTip = this.ToolTip;
if (!string.IsNullOrEmpty(toolTip))
{
image.ToolTip = toolTip;
}
string text = this.Text;
if (!string.IsNullOrEmpty(text))
{
image.AlternateText = text;
}
image.Page = this.Page;
image.RenderControl(writer);
}
else
{
base.RenderContents(writer);
}
}
示例2: RenderContents
protected internal override void RenderContents(HtmlTextWriter writer) {
// Copied from HyperLink.RenderContents() and modified slightly
string imageUrl = ImageUrl;
if (!String.IsNullOrEmpty(imageUrl)) {
Image image = new Image();
// NOTE: The Url resolution happens right here, because the image is not parented
// and will not be able to resolve when it tries to do so.
image.ImageUrl = ResolveClientUrl(imageUrl);
string toolTip = ToolTip;
if (!String.IsNullOrEmpty(toolTip)) {
image.ToolTip = toolTip;
}
string text = Text;
if (!String.IsNullOrEmpty(text)) {
image.AlternateText = text;
}
image.Page = Page;
image.RenderControl(writer);
}
else {
base.RenderContents(writer);
}
}
示例3: GetDesignTimeHtml
public override string GetDesignTimeHtml()
{
AdRotator viewControl = (AdRotator) base.ViewControl;
StringWriter writer = new StringWriter(CultureInfo.CurrentCulture);
DesignTimeHtmlTextWriter writer2 = new DesignTimeHtmlTextWriter(writer);
HyperLink link = new HyperLink {
ID = viewControl.ID,
NavigateUrl = "",
Target = viewControl.Target,
AccessKey = viewControl.AccessKey,
Enabled = viewControl.Enabled,
TabIndex = viewControl.TabIndex
};
link.Style.Value = viewControl.Style.Value;
link.RenderBeginTag(writer2);
Image image = new Image();
image.ApplyStyle(viewControl.ControlStyle);
image.SetDesignMode();
image.ImageUrl = "";
image.AlternateText = viewControl.ID;
image.ToolTip = viewControl.ToolTip;
image.RenderControl(writer2);
link.RenderEndTag(writer2);
return writer.ToString();
}
示例4: RenderContents
protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
{
Image img = new Image();
img.CssClass = this.CssClass;
img.ImageUrl = RequestSettings.UrlBuilder(Data, Format, new System.Web.Routing.RouteValueDictionary(null));
img.RenderControl(writer);
}
示例5: Render
protected override void Render(HtmlTextWriter writer)
{
HyperLink hl = this.Control as HyperLink;
if (hl == null)
{
base.Render(writer);
return;
}
// This code is copied from HyperLink.RenderContents (using
// Reflector). References to "this" have been changed to
// "hl", and we have to render the begin and end tags.
string imageUrl = hl.ImageUrl;
if (imageUrl.Length > 0)
{
// Let the HyperLink render its begin tag
hl.RenderBeginTag(writer);
Image image = new Image();
// I think the next line is the bug. The URL gets
// resolved here, but the Image.UrlResolved property
// doesn't get set. So another attempt to resolve the
// URL is made in Image.AddAttributesToRender. It's in
// the callstack above that method that the exception
// or improperly resolved URL happens.
//image.ImageUrl = base.ResolveClientUrl(imageUrl);
image.ImageUrl = imageUrl;
imageUrl = hl.ToolTip;
if (imageUrl.Length != 0)
{
image.ToolTip = imageUrl;
}
imageUrl = hl.Text;
if (imageUrl.Length != 0)
{
image.AlternateText = imageUrl;
}
image.RenderControl(writer);
// Wrap up by letting the HyperLink render its end tag
hl.RenderEndTag(writer);
}
else
{
// HyperLink.RenderContents handles a couple of other
// cases if its ImageUrl property hasn't been set. We
// delegate to that behavior here.
base.Render(writer);
}
}
示例6: GetEmbedHTML
protected override void GetEmbedHTML(System.Web.UI.HtmlTextWriter writer)
{
Image image = new Image();
if (MaxWidth > 0)
{
image.Width = MaxWidth;
}
if (MaxHeight > 0)
{
image.Height = MaxHeight;
}
OEmbedResult result = GetEmbedResult(MaxWidth, MaxHeight);
if (result != null && !String.IsNullOrEmpty(result.thumbnail_url))
{
image.ImageUrl = result.thumbnail_url;
}
else
{
image.ImageUrl = DefaultImageUrl;
}
image.RenderControl(writer);
}
示例7: RenderContents
/// <summary>
///
/// </summary>
/// <param name="writer"></param>
/// <author>
/// Created by Iulian Iuga; 30 December, 2002
/// </author>
protected void RenderContents( HtmlTextWriter writer )
{
TableRow _tr = new TableRow();
TableCell _td = new TableCell();
_tr.RenderBeginTag( writer );
// apply CssClass for current element
if( _element.TreeWeb.DefaultElementCssClass.Length > 0 )
_td.CssClass = _element.TreeWeb.DefaultElementCssClass;
if( _element.CssClass.Length > 0 )
_td.CssClass = _element.CssClass;
//_td.Style.Add( "display", "none" );
_td.Attributes.Add( "nowrap", "yes" );
_td.RenderBeginTag( writer );
// render a at the begining of each element
writer.Write( " " );
// render element indentation based on element level
string _indentation = "";
int nIndentationPerStep = _element.TreeWeb.Indentation;
for( int index = 0; index < (_element.Level * nIndentationPerStep); index++ )
_indentation += _indentationStep;
writer.Write( _indentation );
// render the expand/collapse link if the element has child elements and is expandable.
if( _element.HasElements )
{
HyperLink _link = new HyperLink();
Image _image = new Image();
if( _element.TreeWeb.Expandable && _element.Expandable )
{
if( _element.IsExpanded )
{
_link.Text = _expcol[1];
if( _element.TreeWeb.ExpandedElementImage.Length > 0 )
_image.ImageUrl = _element.TreeWeb.ExpandedElementImage;
}
else
{
_link.Text = _expcol[0];
if( _element.TreeWeb.CollapsedElementImage.Length > 0 )
_image.ImageUrl = _element.TreeWeb.CollapsedElementImage;
}
}
string scriptCode = "javascript:";
scriptCode += _element.TreeWeb.Page.GetPostBackEventReference( _element.TreeWeb, _element.ID );
_link.NavigateUrl = scriptCode;
if( _image.ImageUrl.Length > 0 )
{
_link.RenderBeginTag( writer );
_image.RenderControl( writer );
_link.RenderEndTag( writer );
}
else
_link.RenderControl( writer );
_image = null;
_link = null;
writer.Write( " " );
}
// render checkbox
if( _element.TreeWeb.CheckBoxes || _element.CheckBox )
{
CheckBox _checkbox = new CheckBox();
_checkbox.ID = _element.ID + TreeElement._separator + TreeElement._checkboxIDSufix;
_checkbox.RenderControl( writer );
_checkbox = null;
// write a non-breaking space before the element text
writer.Write( " " );
}
// render element's image if it has one
if( _element.ImageIndex > -1 )
{
ElementImage _elementImage = _element.TreeWeb.ImageList[_element.ImageIndex];
if( _elementImage != null )
{
Image _image = new Image();
_image.ImageUrl = _elementImage.ImageUrl;
_image.RenderControl( writer );
_image = null;
//.........这里部分代码省略.........
示例8: RenderSpace
private void RenderSpace(HtmlTextWriter writer, Unit space, Orientation orientation)
{
Image image = new Image {
ImageUrl = this.Control.SpacerImageUrl,
GenerateEmptyAlternateText = true,
Page = base.Page
};
if (orientation == Orientation.Vertical)
{
image.Height = space;
image.Width = Unit.Pixel(1);
image.RenderControl(writer);
writer.WriteBreak();
}
else
{
image.Width = space;
image.Height = Unit.Pixel(1);
image.RenderControl(writer);
}
}
示例9: RenderItem
protected internal virtual void RenderItem(HtmlTextWriter writer, MenuItem item, int position)
{
bool flag4;
string str6;
Menu control = this.Control;
MenuItemStyle menuItemStyle = control.GetMenuItemStyle(item);
string imageUrl = item.ImageUrl;
int depth = item.Depth;
int num2 = depth + 1;
string toolTip = item.ToolTip;
string navigateUrl = item.NavigateUrl;
string text = item.Text;
bool isEnabled = item.IsEnabled;
bool selectable = item.Selectable;
MenuItemCollection childItems = item.ChildItems;
string staticTopSeparatorImageUrl = null;
if ((depth < control.StaticDisplayLevels) && (control.StaticTopSeparatorImageUrl.Length != 0))
{
staticTopSeparatorImageUrl = control.StaticTopSeparatorImageUrl;
}
else if ((depth >= control.StaticDisplayLevels) && (control.DynamicTopSeparatorImageUrl.Length != 0))
{
staticTopSeparatorImageUrl = control.DynamicTopSeparatorImageUrl;
}
if (staticTopSeparatorImageUrl != null)
{
new Image { ImageUrl = staticTopSeparatorImageUrl, GenerateEmptyAlternateText = true, Page = base.Page }.RenderControl(writer);
this.RenderBreak(writer);
}
if (((menuItemStyle != null) && !menuItemStyle.ItemSpacing.IsEmpty) && ((this._titleItem != null) || (position != 0)))
{
this.RenderSpace(writer, menuItemStyle.ItemSpacing, control.Orientation);
}
Panel panel = new SpanPanel {
Enabled = isEnabled,
Page = base.Page
};
if ((base.Page != null) && base.Page.SupportsStyleSheets)
{
string cssClassName = control.GetCssClassName(item, false);
if (cssClassName.Trim().Length > 0)
{
panel.CssClass = cssClassName;
}
}
else if (menuItemStyle != null)
{
panel.ApplyStyle(menuItemStyle);
}
if (item.ToolTip.Length != 0)
{
panel.ToolTip = item.ToolTip;
}
panel.RenderBeginTag(writer);
bool flag3 = (((position != 0) && (childItems.Count != 0)) && (num2 >= control.StaticDisplayLevels)) && (num2 < control.MaximumDepth);
if (((position != 0) && (depth > 0)) && ((control.StaticSubMenuIndent != Unit.Pixel(0)) && (depth < control.StaticDisplayLevels)))
{
Image image2 = new Image {
ImageUrl = control.SpacerImageUrl,
GenerateEmptyAlternateText = true
};
double num3 = control.StaticSubMenuIndent.Value * depth;
if (num3 < 32767.0)
{
image2.Width = new Unit(num3, control.StaticSubMenuIndent.Type);
}
else
{
image2.Width = new Unit(32767.0, control.StaticSubMenuIndent.Type);
}
image2.Height = Unit.Pixel(1);
image2.Page = base.Page;
image2.RenderControl(writer);
}
if ((imageUrl.Length > 0) && item.NotTemplated())
{
Image image3 = new Image {
ImageUrl = imageUrl
};
if (toolTip.Length != 0)
{
image3.AlternateText = toolTip;
}
else
{
image3.GenerateEmptyAlternateText = true;
}
image3.Page = base.Page;
image3.RenderControl(writer);
writer.Write(' ');
}
if ((base.Page != null) && base.Page.SupportsStyleSheets)
{
str6 = control.GetCssClassName(item, true, out flag4);
}
else
{
str6 = string.Empty;
flag4 = false;
}
//.........这里部分代码省略.........
示例10: Render
protected override void Render(HtmlTextWriter output)
{
var image = new Image();
image.ID = this.ClientID + "_Image";
image.AlternateText = this.Checked.ToString();
if (!this.ShowCheckBox)
{
base.Style.Add("display", "none");
}
if (this.Checked)
{
image.ImageUrl = this.ImageChecked;
}
else
{
image.ImageUrl = this.ImageUnchecked;
}
image.RenderControl(output);
base.Render(output);
}
示例11: RenderContents
protected override void RenderContents(HtmlTextWriter writer)
{
if (this.ImageUrl.Length > 0)
{
Image img = new Image();
img.ImageUrl = ResolveUrl(this.ImageUrl);
img.AlternateText = this.Text;
img.BorderWidth = new Unit(0, UnitType.Pixel);
img.RenderControl(writer);
}
else
{
writer.Write(Text);
}
}
示例12: RenderControl
public override void RenderControl(HtmlTextWriter writer)
{
// goal is to render this markup except with dynamic widths and images:
//<div class="slider-wrapper theme-default">
// <div id="slider" class="nivoSlider">
// <img src="images/toystory.jpg" alt="" />
// <img src="images/walle.jpg" alt="" />
// <img src="images/nemo.jpg" alt="" title="#htmlcaption" />
// </div>
//</div>
// add containing divs
writer.AddStyleAttribute(HtmlTextWriterStyle.Width, ImageWidth.ToString());
writer.AddAttribute(HtmlTextWriterAttribute.Class, "slider-wrapper theme-default");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.AddAttribute(HtmlTextWriterAttribute.Class, "nivoSlider");
writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
writer.RenderBeginTag(HtmlTextWriterTag.Div);
if (string.IsNullOrEmpty(ImageFolder))
{
writer.Write("No Image Folder Configured"); // TODO: localize?
}
else
{
// render images
string folderPath = Context.Server.MapPath(ImageFolder);
if (!Directory.Exists(folderPath))
throw new Exception("Invalid image folder path :" + imageFolder);
#if NET35
string[] files = Directory.GetFiles(folderPath);
#else
IEnumerable<string> files = System.IO.Directory.EnumerateFiles(folderPath);
#endif
if (!imageFolder.EndsWith("/")) { imageFolder += "/"; }
foreach (string file in files)
{
//filter out any files in the folder that are not images
string ext = Path.GetExtension(file);
if (!SiteUtils.IsAllowedUploadBrowseFile(ext, ".jpg|.gif|.png|.jpeg")) { continue; }
Image img = new Image();
img.EnableViewState = false;
// make path relative rather than absolute
img.ImageUrl = imageFolder + Path.GetFileName(file);
img.AlternateText = " ";
img.Width = imageWidth;
img.RenderControl(writer);
}
}
writer.RenderEndTag();
writer.RenderEndTag();
// add jquery onload function to start show
Page.ClientScript.RegisterStartupScript(this.GetType(), GetUniqueId("startSlider"), GetPageLoadScript(), true);
}
示例13: Render
protected override void Render (HtmlTextWriter writer)
{
HyperLink hLink = new HyperLink ();
Image adImage = new Image();
foreach (string current in Attributes.Keys)
hLink.Attributes [current] = Attributes [current];
if (ID != null && ID.Length > 0)
hLink.ID = ID;
hLink.Target = Target;
hLink.AccessKey = AccessKey;
hLink.Enabled = Enabled;
hLink.TabIndex = TabIndex;
if (navigateUrl != null && navigateUrl.Length != 0)
hLink.NavigateUrl = ResolveAdUrl (navigateUrl);
hLink.RenderBeginTag (writer);
if (ControlStyleCreated)
adImage.ApplyStyle(ControlStyle);
if(imageUrl!=null && imageUrl.Length > 0)
adImage.ImageUrl = ResolveAdUrl (imageUrl);
adImage.AlternateText = alternateText;
adImage.ToolTip = ToolTip;
adImage.RenderControl (writer);
hLink.RenderEndTag (writer);
}
示例14: RenderItem
protected virtual internal void RenderItem(HtmlTextWriter writer, MenuItem item, int position) {
Menu owner = Control;
MenuItemStyle mergedStyle = owner.GetMenuItemStyle(item);
string imageUrl = item.ImageUrl;
int depth = item.Depth;
int depthPlusOne = depth + 1;
string toolTip = item.ToolTip;
string navigateUrl = item.NavigateUrl;
string text = item.Text;
bool enabled = item.IsEnabled;
bool selectable = item.Selectable;
MenuItemCollection childItems = item.ChildItems;
// Top separator
string topSeparatorUrl = null;
if (depth < owner.StaticDisplayLevels && owner.StaticTopSeparatorImageUrl.Length != 0) {
topSeparatorUrl = owner.StaticTopSeparatorImageUrl;
}
else if (depth >= owner.StaticDisplayLevels && owner.DynamicTopSeparatorImageUrl.Length != 0) {
topSeparatorUrl = owner.DynamicTopSeparatorImageUrl;
}
if (topSeparatorUrl != null) {
Image separatorImage = new Image();
separatorImage.ImageUrl = topSeparatorUrl;
separatorImage.GenerateEmptyAlternateText = true; // XHtml compliance
separatorImage.Page = Page;
separatorImage.RenderControl(writer);
RenderBreak(writer);
}
// Don't render the top spacing if this is the first root item
if ((mergedStyle != null) && !mergedStyle.ItemSpacing.IsEmpty &&
((_titleItem != null) || (position != 0))) {
RenderSpace(writer, mergedStyle.ItemSpacing, owner.Orientation);
}
// Item span
Panel itemPanel = new SpanPanel();
itemPanel.Enabled = enabled;
itemPanel.Page = Page;
// Apply styles
if (Page != null && Page.SupportsStyleSheets) {
string styleClass = owner.GetCssClassName(item, false);
if (styleClass.Trim().Length > 0) {
itemPanel.CssClass = styleClass;
}
}
else if (mergedStyle != null) {
itemPanel.ApplyStyle(mergedStyle);
}
// Tooltip
if (item.ToolTip.Length != 0) {
itemPanel.ToolTip = item.ToolTip;
}
// Render item begin tag
itemPanel.RenderBeginTag(writer);
// If there is a navigation url on this item, set up the navigation stuff if:
// - the item is the current title item for this level
// - the item has no children
// - the item is a static item of depth + 1 < StaticDisplayLevels
bool clickOpensThisNode = !((position == 0) ||
(childItems.Count == 0) ||
(depthPlusOne < owner.StaticDisplayLevels) ||
(depthPlusOne >= owner.MaximumDepth));
// Indent
if (position != 0 &&
depth > 0 &&
owner.StaticSubMenuIndent != Unit.Pixel(0) &&
depth < owner.StaticDisplayLevels) {
Image spacerImage = new Image();
spacerImage.ImageUrl = owner.SpacerImageUrl;
spacerImage.GenerateEmptyAlternateText = true; // XHtml compliance
double indent = owner.StaticSubMenuIndent.Value * depth;
if (indent < Unit.MaxValue) {
spacerImage.Width = new Unit(indent, owner.StaticSubMenuIndent.Type);
}
else {
spacerImage.Width = new Unit(Unit.MaxValue, owner.StaticSubMenuIndent.Type);;
}
spacerImage.Height = Unit.Pixel(1);
spacerImage.Page = Page;
spacerImage.RenderControl(writer);
}
// Render out the item icon, if it is set and if the item is not templated (VSWhidbey 501618)
if (imageUrl.Length > 0 && item.NotTemplated()) {
Image newImage = new Image();
newImage.ImageUrl = imageUrl;
if (toolTip.Length != 0) {
newImage.AlternateText = toolTip;
}
else {
newImage.GenerateEmptyAlternateText = true; // XHtml compliance
}
//.........这里部分代码省略.........
示例15: RenderExpand
private void RenderExpand(HtmlTextWriter writer, MenuItem item, Menu owner) {
string expandImageUrl = item.GetExpandImageUrl();
if (expandImageUrl.Length > 0) {
Image expandImage = new Image();
expandImage.ImageUrl = expandImageUrl;
expandImage.GenerateEmptyAlternateText = true;
if (item.Depth < owner.StaticDisplayLevels) {
expandImage.AlternateText = String.Format(
CultureInfo.CurrentCulture,
owner.StaticPopOutImageTextFormatString,
item.Text);
}
else {
expandImage.AlternateText = String.Format(
CultureInfo.CurrentCulture,
owner.DynamicPopOutImageTextFormatString,
item.Text);
}
// expandImage.ImageAlign = ImageAlign.Right;
expandImage.ImageAlign = ImageAlign.AbsMiddle;
expandImage.Page = Page;
expandImage.RenderControl(writer);
}
else {
writer.Write(' ');
if (item.Depth < owner.StaticDisplayLevels &&
owner.StaticPopOutImageTextFormatString.Length != 0) {
writer.Write(HttpUtility.HtmlEncode(String.Format(
CultureInfo.CurrentCulture,
owner.StaticPopOutImageTextFormatString,
item.Text)));
}
else if (item.Depth >= owner.StaticDisplayLevels &&
owner.DynamicPopOutImageTextFormatString.Length != 0) {
writer.Write(HttpUtility.HtmlEncode(String.Format(
CultureInfo.CurrentCulture,
owner.DynamicPopOutImageTextFormatString,
item.Text)));
}
else {
writer.Write(HttpUtility.HtmlEncode(SR.GetString(SR.MenuAdapter_Expand, item.Text)));
}
}
}