private void YouTube_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Graphic g = sender as Graphic; bool isWideScrn = ("widescreen".Equals(g.Attributes["aspectRaito"])); string mediaUrl = g.Attributes["contentUrl"] as string; int videoWidth, videoHeight; switch (widgetConfig.YouTubePlayerSize) { case "Small": videoWidth = 320; break; case "Medium": videoWidth = 640; break; case "Large": videoWidth = 854; break; case "HD720": videoWidth = 1024; break; default: videoWidth = 640; break; //Medium by default } videoHeight = (isWideScrn) ? videoWidth * 9 / 16 : videoWidth * 3 / 4; if (this.CurrentApp.IsWindowless && "Javascript".Equals(widgetConfig.YouTubePlayerWindow, StringComparison.CurrentCultureIgnoreCase)) { HtmlPage.Window.Invoke("openYouTubePlayerWindow", new object[] { mediaUrl, videoWidth, videoHeight }); } else { System.Windows.Browser.HtmlPopupWindowOptions winOptions = new System.Windows.Browser.HtmlPopupWindowOptions() { Resizeable = false, Width = videoWidth, Height = videoHeight }; System.Windows.Browser.HtmlWindow win = System.Windows.Browser.HtmlPage.PopupWindow(new Uri(mediaUrl), "_blank", winOptions); } }
/// <summary> /// Initializes a new instance of the <see cref="ClipboardHelper"/> class. /// </summary> /// <param name="AttachedUIElements">The attached UI elements. These elements have copy/paste functionality.</param> public ClipboardHelper(params UIElement[] AttachedUIElements) { CheckBrowserCompatibility(); _window = HtmlPage.Window; if (_browserSupported) { if (AttachedUIElements != null) { _attachedUIElements = AttachedUIElements; foreach (UIElement element in AttachedUIElements) { element.KeyDown += new KeyEventHandler(UIElement_KeyDown); element.KeyUp += new KeyEventHandler(UIElement_KeyUp); } } } else { throw (new InvalidOperationException("Browser not supported")); } }
public ScriptableTest () { plugin = HtmlPage.Plugin; window = HtmlPage.Window; content = plugin.GetProperty ("Content") as ScriptObject; //bool ispopupon = HtmlPage.IsPopupWindowAllowed; //HtmlWindow popup = HtmlPage.PopupWindow (new Uri ("about:blank"), "_blank", new HtmlPopupWindowOptions ()); calc = new Calculator (); scriptable = new Scriptable (); scriptabletype = new ScriptableType (); HtmlPage.RegisterScriptableObject ("calc", calc); HtmlPage.RegisterScriptableObject ("scriptable", scriptable); HtmlPage.RegisterScriptableObject ("scriptabletype", scriptabletype); HtmlPage.RegisterCreateableType ("createable", typeof (CreateableType)); if (Environment.OSVersion.Platform == PlatformID.Unix) strplugin = "document.getElementById('silverlight')"; else strplugin = "document.getElementById('silverlightControlHost').getElementsByTagName('object')[0]"; }
public MainPage(IDictionary<string, string> initParams) { InitializeComponent(); window = HtmlPage.Window; HtmlPage.RegisterScriptableObject("MediaElementJS", this); _codec = String.Empty; // add events media.BufferingProgressChanged += new RoutedEventHandler(media_BufferingProgressChanged); media.DownloadProgressChanged += new RoutedEventHandler(media_DownloadProgressChanged); media.CurrentStateChanged += new RoutedEventHandler(media_CurrentStateChanged); media.MediaEnded += new RoutedEventHandler(media_MediaEnded); media.MediaFailed += new EventHandler<ExceptionRoutedEventArgs>(media_MediaFailed); media.MediaOpened += new RoutedEventHandler(media_MediaOpened); media.MouseLeftButtonDown += new MouseButtonEventHandler(media_MouseLeftButtonDown); CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering); // get parameters if (initParams.ContainsKey("id")) _htmlid = initParams["id"]; if (initParams.ContainsKey("file")) _mediaUrl = initParams["file"]; if (initParams.ContainsKey("jsinitfunction")) _jsInitFunction = initParams["jsinitfunction"]; if (initParams.ContainsKey("jscallbackfunction")) _jsCallbackFunction = initParams["jscallbackfunction"]; if (initParams.ContainsKey("autoplay") && initParams["autoplay"] == "true") _autoplay = true; if (initParams.ContainsKey("debug") && initParams["debug"] == "true") _debug = true; if (initParams.ContainsKey("controls") && initParams["controls"] == "true") _controls = true; if (initParams.ContainsKey("preload")) _preload = initParams["preload"].ToLower(); else _preload = ""; if (!(new string[] { "none", "metadata", "auto" }).Contains(_preload)){ _preload = "none"; } if (initParams.ContainsKey("width")) Int32.TryParse(initParams["width"], out _width); if (initParams.ContainsKey("height")) Int32.TryParse(initParams["height"], out _height); if (initParams.ContainsKey("timerate")) Int32.TryParse(initParams["timerrate"], out _timerRate); if (initParams.ContainsKey("startvolume")) Double.TryParse(initParams["startvolume"], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _volume); if (_timerRate == 0) _timerRate = 250; if (!_controls) transportControls.Visibility = System.Windows.Visibility.Collapsed; else transportControls.Visibility = System.Windows.Visibility.Visible; // timer _timer = new System.Windows.Threading.DispatcherTimer(); _timer.Interval = new TimeSpan(0, 0, 0, 0, _timerRate); // 200 Milliseconds _timer.Tick += new EventHandler(timer_Tick); _timer.Stop(); //_mediaUrl = "http://local.mediaelement.com/media/jsaddington.mp4"; //_autoplay = true; // set stage and media sizes if (_width > 0) LayoutRoot.Width = media.Width = this.Width = _width; if (_height > 0) LayoutRoot.Height = media.Height = this.Height = _height; // debug textBox1.Visibility = (_debug) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed; textBox1.IsEnabled = false; textBox1.Text = "id: " + _htmlid + "\n" + "file: " + _mediaUrl + "\n"; media.AutoPlay = _autoplay; media.Volume = _volume; if (!String.IsNullOrEmpty(_mediaUrl)) { setSrc(_mediaUrl, _codec); if (_autoplay || _preload != "none") loadMedia(); } media.MouseLeftButtonUp += new MouseButtonEventHandler(media_MouseLeftButtonUp); // full screen settings Application.Current.Host.Content.FullScreenChanged += new EventHandler(DisplaySizeInformation); Application.Current.Host.Content.Resized += new EventHandler(DisplaySizeInformation); //FullscreenButton.Visibility = System.Windows.Visibility.Collapsed; // send out init call //HtmlPage.Window.Invoke("html5_MediaPluginBridge_initPlugin", new object[] {_htmlid}); try { HtmlPage.Window.Eval(_jsInitFunction + "('" + _htmlid + "');"); } catch { } }
/// <summary> /// Initializes a new instance of the <see cref="ClipboardHelper"/> class. /// </summary> public ClipboardHelper() { CheckBrowserCompatibility(); _window = HtmlPage.Window; }
/** * Constructs a BakedGoods Object. * @param paramWindow the HtmlWindow which represents the browser window that the * application containing the to-be-constructed object is embedded in */ public BakedGoods(HtmlWindow paramWindow) { Window = paramWindow; }
public static void SetMember(HtmlWindow win, string name, object value) { HtmlObjectExtension.SetMember(win, name, value); }
public static object GetBoundMember(HtmlWindow win, string name) { return HtmlObjectExtension.GetBoundMember(win, name); }
private void IntializeHandlersHtml() { if (!_iframeInitialized) { if (_htmlIframeWindow == null && _htmlIframeEditorElement != null) _htmlIframeWindow = _htmlIframeEditorElement.GetProperty("contentWindow") as HtmlWindow; if (_htmlIframeWindow == null || _htmlIframeWindow.GetProperty("IsReady") == null) return; if (_htmlIframeDocument == null) _htmlIframeDocument = _htmlIframeWindow.GetProperty("document") as HtmlDocument; _htmlIframeDocument.AttachEvent("keydown", HandleHtmlKeyDown); if (this.IsBrowserIE) { _htmlIframeWindow.AttachEvent("focus", HandleHtmlFocus); _htmlIframeWindow.AttachEvent("blur", HandleHtmlBlur); } else { _htmlIframeDocument.AttachEvent("focus", HandleHtmlFocus); _htmlIframeDocument.AttachEvent("blur", HandleHtmlBlur); } _iframeInitialized = true; } }
private void RemoveHtml() { RemoveHandlersHtml(); Application.Current.RootVisual.MouseMove -= new MouseEventHandler(RootVisual_MouseMove); //System.Windows.Browser.HtmlPage.Document.Body.RemoveChild(_htmlDivContainerElement); if (_htmlDivContainerElement != null) HtmlContainer.RemoveChild(_htmlDivContainerElement); _htmlAnchorFocusElement = null; _htmlIframeDocument = null; _htmlIframeWindow = null; _htmlIframeEditorElement = null; _htmlDivContainerElement = null; }