本文整理汇总了C#中Util.GetImageSize方法的典型用法代码示例。如果您正苦于以下问题:C# Util.GetImageSize方法的具体用法?C# Util.GetImageSize怎么用?C# Util.GetImageSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Util
的用法示例。
在下文中一共展示了Util.GetImageSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetWebApp
//.........这里部分代码省略.........
HtmlNode body_node = root.SelectSingleNode("//body");
StringBuilder functions = new StringBuilder();
if ((bool)State["IsProduction"] == false && State["SelectedAppType"].ToString() == Constants.HYBRID_APP_TYPE)
{
//add first function to go to login page
StringBuilder settings_actions = new StringBuilder("$('#viziapps_login_button').bind('tap',function(event){\n");
settings_actions.Append("\t\twindow.plugins.vsettings.login(null,null);\n");
settings_actions.Append("\t\tevent.stopPropagation();\n");
settings_actions.Append("\t});\n");
functions.Append(settings_actions.ToString());
}
bool isFirstPage = true;
foreach (XmlNode page_node in page_node_list)
{
ArrayList dialogs_in_page = new ArrayList();
HtmlNode html_page_node = htmlDoc.CreateElement("div");
html_page_node.Attributes.Append(htmlDoc.CreateAttribute("data-role", "page"));
html_page_node.Attributes.Append(htmlDoc.CreateAttribute("id", page_node.SelectSingleNode("name").InnerText));
if (device_type == Constants.IPAD || device_type == Constants.ANDROID_TABLET)
html_page_node.Attributes.Append(htmlDoc.CreateAttribute("style", "background-image: none; background-color:" + x_util.GetBackgroundColor(State)));
HtmlNode content_node = htmlDoc.CreateElement("div");
content_node.Attributes.Append(htmlDoc.CreateAttribute("data-role", "content"));
content_node.Attributes.Append(htmlDoc.CreateAttribute("style", "background-image:none;background-color:transparent"));
html_page_node.AppendChild(content_node);
//create separate background image for phones
if (device_type != Constants.IPAD)
{
HtmlNode field_node = htmlDoc.CreateElement("div");
Size size = util.GetImageSize(backgroundUrl);
if (size != null)
{
double background_width = Convert.ToDouble(size.Width) * x_size_factor;
double background_height = Convert.ToDouble(size.Height) * y_size_factor;
field_node.Attributes.Append(htmlDoc.CreateAttribute("style", "z-index:1;position:absolute;left:0px;top:0px; width:" + background_width.ToString() + "px;height:" + background_height.ToString() + "px;"));
}
x_util.AddImageNode(htmlDoc, field_node, backgroundUrl);
content_node.AppendChild(field_node);
}
XmlNode fields_node = page_node.SelectSingleNode("fields");
if (fields_node == null)
continue;
XmlNodeList field_list = page_node.SelectSingleNode("fields").ChildNodes;
foreach (XmlNode field in field_list)
{
Hashtable field_map = x_util.ParseXmlToHtml(field);
HtmlNode field_node = null;
switch (field.Name)
{
case "text_field":
case "hidden_field":
field_node = htmlDoc.CreateElement("input");
break;
case "map":
case "photo":
case "gps":
continue;
case "alert":
case "button":
示例2: GetAppPage
public string GetAppPage(Hashtable State, string page_name)
{
try
{
XmlDocument xmlDoc = GetStagingAppXml(State);
//get background image
XmlNode configuration_node = xmlDoc.SelectSingleNode("//configuration");
XmlNode background_node = configuration_node.SelectSingleNode("background");
if (background_node == null)
{
background_node = CreateNode(xmlDoc, configuration_node, "background");
}
XmlNode background_image_node = background_node.SelectSingleNode("image_source");
if (background_image_node == null)
{
background_image_node = CreateNode(xmlDoc, background_node, "image_source", "https://s3.amazonaws.com/MobiFlexImages/apps/images/backgrounds/standard_w_header_iphone.jpg");
}
string background_image = background_image_node.InnerText;
if (background_image.Contains("s3.amazonaws.com"))
{
if (State["SelectedDeviceType"].ToString() == Constants.ANDROID_PHONE)
background_image = background_image.Replace("_iphone.", "_android.");
State["BackgroundImageUrl"] = background_image;
}
else
{
background_image = background_image.Substring(background_image.LastIndexOf("/") + 1);
if (State["SelectedDeviceType"].ToString() == Constants.ANDROID_PHONE)
background_image = background_image.Replace("_iphone.", "_android.");
State["BackgroundImageUrl"] = "https://s3.amazonaws.com/MobiFlexImages/apps/images/backgrounds/" + background_image;
}
XmlNode page_name_node = xmlDoc.SelectSingleNode("//pages/page/name[. ='" + page_name + "']");
if (page_name_node == null)
return "";
double y_factor = 1.0D;
Util util = new Util();
//if (State["SelectedDeviceType"].ToString() != State["SelectedDeviceView"].ToString())
//{
// y_factor = util.GetYFactor(State);
// }
XmlNode page_node = page_name_node.ParentNode;
XmlNode fields_node = page_node.SelectSingleNode("fields");
if(fields_node == null)
return "";
XmlNodeList field_list = page_node.SelectSingleNode("fields").ChildNodes;
HtmlDocument htmlDoc = new HtmlDocument();
HtmlNode root = htmlDoc.DocumentNode;
foreach (XmlNode field in field_list)
{
try
{
//restrict certain cross use fields
if (State["SelectedAppType"].ToString() == Constants.NATIVE_APP_TYPE)
{
if (field.Name == "html_panel")
continue;
}
HtmlNode new_node = htmlDoc.CreateElement("div");
Hashtable field_map = ParseXmlToHtml(field);
SetCommonHtmlAttributes(htmlDoc, new_node, field_map, y_factor, field.Name);
HtmlAttribute title_attr = htmlDoc.CreateAttribute("title");
switch (field.Name)
{
case "image"://"<div title=\"MobiFlex Image\" id=\"{0}\" type=\"get\" style=\"{2}\" ><img src=\"{1}\" style=\"height:100%;width:100%;\"/></div>"
title_attr.Value = "MobiFlex Image";
string image_url = field_map["image_source"].ToString();
if (!field_map.ContainsKey("width")) //the xml does not have the width and height so use the width and height of the actual image
{
Size size = util.GetImageSize(image_url);
if (size != null)
{
new_node.Attributes["style"].Value += "width:" + size.Width.ToString() + "px;height:" + size.Height.ToString() + "px;";
}
}
AddImageNode(htmlDoc, new_node, image_url);
break;
case "audio"://<div title=\"MobiFlex Audio\" id=\"{0}\" source=\"{1}\" style=\"{2}\" ><img src=\"images/editor_images/audio_field.png\" style=\"height:100%;width:100%;\"/></div>"
title_attr.Value = "MobiFlex Audio";
HtmlAttribute audio_source_attr = htmlDoc.CreateAttribute("source", field_map["audio_source"].ToString());
new_node.Attributes.Append(audio_source_attr);
AddImageNode(htmlDoc, new_node, "images/editor_images/audio_field.png");
break;
case "label": //"<div title=\"MobiFlex Label\" id=\"{0}\" style=\"{2}\" >{1}<img class=\"spacer\" src=\"images/spacer.gif\" style=\"position:relative;top:-16px;width:100%;height:100%\" /></div>"
title_attr.Value = "MobiFlex Label";
new_node.InnerHtml = field_map["text"].ToString();
//<img class=\"spacer\" src=\"images/spacer.gif\" style=\"position:relative;top:-16px;width:100%;height:100%\" />
HtmlNode label_img_node = htmlDoc.CreateElement("img");
HtmlAttribute label_img_src_attr = htmlDoc.CreateAttribute("src", "images/spacer.gif");
label_img_node.Attributes.Append(label_img_src_attr);
int label_font_size = -Convert.ToInt32(field_map["font_size"].ToString());
HtmlAttribute label_img_style_attr = htmlDoc.CreateAttribute("style", "position:relative;top:" + label_font_size.ToString() + "px;width:100%;height:100%");
//.........这里部分代码省略.........