public void SetResizeProperties(ResizeProperties resizeProperties) { string arg = resizeProperties.ToString(); string js = string.Format("mraid.setResizeProperties({0});", arg); EvalJS(js); }
public bool ParseRequest(Uri uri) { if (uri.Scheme != Const.Scheme) return false; string command = uri.Host; string query = uri.Query.Trim(new char[] { '?' }); Dictionary<string, string> args = new Dictionary<string, string>(); if (string.IsNullOrEmpty(query) == false) { string[] queryItems = query.Split(new char[] { '&' }); foreach (string queryItem in queryItems) { string[] keyValue = queryItem.Split(new char[] { '=' }); if (keyValue.Length == 2) { string key = Uri.UnescapeDataString(keyValue[0]); string value = Uri.UnescapeDataString(keyValue[1]); // TODO: This was done on iOS to preserve formatting, but it looks like // URL/Uri formats here will be escaped as needed by the runtime. //if (key != Const.CommandArgUrl) // value = Uri.UnescapeDataString(value); args[key] = value; } } } switch (command) { case Const.CommandClose: this.handler.mraidClose(this); break; case Const.CommandOpen: { string url = null; args.TryGetValue(Const.CommandArgUrl, out url); this.handler.mraidOpen(this, url); } break; case Const.CommandUpdateCurrentPosition: this.handler.mraidUpdateCurrentPosition(this); break; case Const.CommandExpand: { string url = null; args.TryGetValue(Const.CommandArgUrl, out url); this.handler.mraidExpand(this, url); } break; case Const.CommandResize: this.handler.mraidResize(this); break; case Const.CommandSetExpandProperties: { ExpandProperties expandProperties = ExpandProperties.PropertiesFromArgs(args); this.expandProperties = expandProperties; this.handler.mraidUpdatedExpandProperties(this); } break; case Const.CommandSetResizeProperties: { ResizeProperties resizeProperties = ResizeProperties.PropertiesFromArgs(args); this.resizeProperties = resizeProperties; this.handler.mraidUpdatedResizeProperties(this); } break; case Const.CommandSetOrientationProperties: { OrientationProperties orientationProperties = OrientationProperties.PropertiesFromArgs(args); this.orientationProperties = orientationProperties; this.handler.mraidUpdatedOrientationProperties(this); } break; case Const.CommandPlayVideo: { string url = null; args.TryGetValue(Const.CommandArgUrl, out url); this.handler.mraidPlayVideo(this, url); } break; case Const.CommandCreateCalendarEvent: { string calendarEvent = null; args.TryGetValue(Const.CommandArgEvent, out calendarEvent); this.handler.mraidCreateCalendarEvent(this, calendarEvent); } break; case Const.CommandStorePicture: { string url = null; args.TryGetValue(Const.CommandArgUrl, out url); this.handler.mraidStorePicture(this, url); } break; } return true; }
public static ResizeProperties PropertiesFromArgs(Dictionary<string, string> args) { ResizeProperties properties = new ResizeProperties(); string value = null; double dValue = 0; if ((args.TryGetValue("width", out value)) && (double.TryParse(value, out dValue))) { properties.width = dValue; } if ((args.TryGetValue("height", out value)) && (double.TryParse(value, out dValue))) { properties.height = dValue; } if (args.TryGetValue("customClosePosition", out value)) { switch (value) { case Const.ResizePropertiesCCPositionTopLeft: properties.customClosePosition = CustomClosePosition.TopLeft; break; case Const.ResizePropertiesCCPositionTopCenter: properties.customClosePosition = CustomClosePosition.TopCenter; break; case Const.ResizePropertiesCCPositionTopRight: properties.customClosePosition = CustomClosePosition.TopRight; break; case Const.ResizePropertiesCCPositionCenter: properties.customClosePosition = CustomClosePosition.Center; break; case Const.ResizePropertiesCCPositionBottomLeft: properties.customClosePosition = CustomClosePosition.BottomLeft; break; case Const.ResizePropertiesCCPositionBottomCenter: properties.customClosePosition = CustomClosePosition.BottomCenter; break; case Const.ResizePropertiesCCPositionBottomRight: properties.customClosePosition = CustomClosePosition.BottomRight; break; } } if ((args.TryGetValue("offsetX", out value)) && (double.TryParse(value, out dValue))) { properties.offsetX = dValue; } if ((args.TryGetValue("offsetY", out value)) && (double.TryParse(value, out dValue))) { properties.offsetY = dValue; } if ((args.TryGetValue("allowOffscreen", out value)) && (value == Const.True)) { properties.allowOffscreen = true; } else { properties.allowOffscreen = false; } return properties; }
public static ResizeProperties PropertiesFromArgs(Dictionary <string, string> args) { ResizeProperties properties = new ResizeProperties(); string value = null; double dValue = 0; if ((args.TryGetValue("width", out value)) && (double.TryParse(value, out dValue))) { properties.width = dValue; } if ((args.TryGetValue("height", out value)) && (double.TryParse(value, out dValue))) { properties.height = dValue; } if (args.TryGetValue("customClosePosition", out value)) { switch (value) { case Const.ResizePropertiesCCPositionTopLeft: properties.customClosePosition = CustomClosePosition.TopLeft; break; case Const.ResizePropertiesCCPositionTopCenter: properties.customClosePosition = CustomClosePosition.TopCenter; break; case Const.ResizePropertiesCCPositionTopRight: properties.customClosePosition = CustomClosePosition.TopRight; break; case Const.ResizePropertiesCCPositionCenter: properties.customClosePosition = CustomClosePosition.Center; break; case Const.ResizePropertiesCCPositionBottomLeft: properties.customClosePosition = CustomClosePosition.BottomLeft; break; case Const.ResizePropertiesCCPositionBottomCenter: properties.customClosePosition = CustomClosePosition.BottomCenter; break; case Const.ResizePropertiesCCPositionBottomRight: properties.customClosePosition = CustomClosePosition.BottomRight; break; } } if ((args.TryGetValue("offsetX", out value)) && (double.TryParse(value, out dValue))) { properties.offsetX = dValue; } if ((args.TryGetValue("offsetY", out value)) && (double.TryParse(value, out dValue))) { properties.offsetY = dValue; } if ((args.TryGetValue("allowOffscreen", out value)) && (value == Const.True)) { properties.allowOffscreen = true; } else { properties.allowOffscreen = false; } return(properties); }
public bool ParseRequest(Uri uri) { if (uri.Scheme != Const.Scheme) { return(false); } string command = uri.Host; string query = uri.Query.Trim(new char[] { '?' }); Dictionary <string, string> args = new Dictionary <string, string>(); if (string.IsNullOrEmpty(query) == false) { string[] queryItems = query.Split(new char[] { '&' }); foreach (string queryItem in queryItems) { string[] keyValue = queryItem.Split(new char[] { '=' }); if (keyValue.Length == 2) { string key = Uri.UnescapeDataString(keyValue[0]); string value = Uri.UnescapeDataString(keyValue[1]); // TODO: This was done on iOS to preserve formatting, but it looks like // URL/Uri formats here will be escaped as needed by the runtime. //if (key != Const.CommandArgUrl) // value = Uri.UnescapeDataString(value); args[key] = value; } } } switch (command) { case Const.CommandClose: this.handler.mraidClose(this); break; case Const.CommandOpen: { string url = null; args.TryGetValue(Const.CommandArgUrl, out url); this.handler.mraidOpen(this, url); } break; case Const.CommandUpdateCurrentPosition: this.handler.mraidUpdateCurrentPosition(this); break; case Const.CommandExpand: { string url = null; args.TryGetValue(Const.CommandArgUrl, out url); this.handler.mraidExpand(this, url); } break; case Const.CommandResize: this.handler.mraidResize(this); break; case Const.CommandSetExpandProperties: { ExpandProperties expandProperties = ExpandProperties.PropertiesFromArgs(args); this.expandProperties = expandProperties; this.handler.mraidUpdatedExpandProperties(this); } break; case Const.CommandSetResizeProperties: { ResizeProperties resizeProperties = ResizeProperties.PropertiesFromArgs(args); this.resizeProperties = resizeProperties; this.handler.mraidUpdatedResizeProperties(this); } break; case Const.CommandSetOrientationProperties: { OrientationProperties orientationProperties = OrientationProperties.PropertiesFromArgs(args); this.orientationProperties = orientationProperties; this.handler.mraidUpdatedOrientationProperties(this); } break; case Const.CommandPlayVideo: { string url = null; args.TryGetValue(Const.CommandArgUrl, out url); this.handler.mraidPlayVideo(this, url); } break; case Const.CommandCreateCalendarEvent: { string calendarEvent = null; args.TryGetValue(Const.CommandArgEvent, out calendarEvent); this.handler.mraidCreateCalendarEvent(this, calendarEvent); } break; case Const.CommandStorePicture: { string url = null; args.TryGetValue(Const.CommandArgUrl, out url); this.handler.mraidStorePicture(this, url); } break; } return(true); }