void mon_FocusChangedFromApp(WWAMonitor arg1, string arg2) { Trace.WriteLine(":: " + arg2); CurrentApp = null; // TODO hide }
public void DoDefaultInjection(WWAApp app) { if (!string.IsNullOrWhiteSpace(DefaultCss)) { Trace.WriteLine("Injecting default CSS..."); var css = app.AppDocument.createStyleSheet(); css.title = "_AccDefaultSheet" + counter; css.cssText = DefaultCss; } if (!string.IsNullOrWhiteSpace(DefaultHtml)) { Trace.WriteLine("Injecting default HTML..."); var div = app.AppDocument.createElement("div"); div.innerHTML = DefaultHtml; var body = (app.AppDocument.body as HTMLBody); body.appendChild(div as IHTMLDOMNode); } if (!string.IsNullOrWhiteSpace(DefaultJs)) { Trace.WriteLine("Injecting default JS..."); var script = app.AppDocument.createElement("script") as HTMLScriptElement; script.type = "text/javascript"; script.innerText = DefaultJs; var heads = app.AppDocument.getElementsByTagName("head"); var head = (heads.item(0, 0) as HTMLHeadElement); head.appendChild(script as IHTMLDOMNode); } }
void mon_AppStarted(WWAMonitor mon, WWAApp app) { // First time we've seen the app. Trace.WriteLine("App Start: " + app); CurrentApp = app; app.Initialize(); }
public void AppInteractionFailed(WWAApp app) { // If there is an error with the app, remove it. // We'll retry next time it jumps to the foreground. if (KnownWWAs.Contains(app)) { KnownWWAs.Remove(app); } }
private void OpenProfileWindow(WWAApp app, HTMLDocument doc, Profile p) { //Thread thread = new Thread(() => // { SliderWindow ct = new SliderWindow(app, doc, p); ct.Show(); // System.Windows.Threading.Dispatcher.Run(); // Trace.WriteLine("UI Thread Exiting"); //}); //thread.SetApartmentState(ApartmentState.STA); //thread.Start(); }
void FoundWWA(IntPtr hWnd) { var wwa = KnownWWAs.ToList().FirstOrDefault(w => w.hWnd == hWnd); if (wwa == null) { wwa = new WWAApp(hWnd); KnownWWAs.Add(wwa); AppStarted(this, wwa); } else { AppSwitched(this, wwa); } }
public SliderWindow(WWAApp app, HTMLDocument doc, Profile p) { this.app = app; this.p = p; this.doc = doc; Top = Left = 0; Topmost = true; InitializeComponent(); App.ViewModel.CurrentAppChanging += () => { this.Invoke(() => Close()); }; }
public void ApplyAction(WWAApp app, HTMLDocument Doc, string value) { if (!string.IsNullOrWhiteSpace(ActionCss)) { var sheet = HtmlHelper.GetSheet(Doc, "_AccActionSheet" + counter); sheet.cssText = ActionCss.Replace("[VALUE]", value); } if (!string.IsNullOrWhiteSpace(ActionJs)) { Trace.WriteLine("Injecting action JS..."); var script = Doc.createElement("script") as HTMLScriptElement; script.type = "text/javascript"; //script.innerText = ActionJs; script.SetProperty("innerText", ActionJs); var heads = Doc.getElementsByTagName("head"); var head = (heads.item(0, 0) as HTMLHeadElement); head.appendChild(script as IHTMLDOMNode); } }
void mon_AppSwitched(WWAMonitor mon, WWAApp app) { // User switched to a running app that we already know about. Trace.WriteLine("Switch: " + app); CurrentApp = app; }
internal static void EnableReaderMode(WWAApp app, HTMLDocument frame) { var f = app.Frames.Values.First(); var bodyx = f.GetProperty("body") as HTMLBody; var content = bodyx.innerHTML; int height = app.AppDocument.documentElement.offsetHeight; int width = app.AppDocument.documentElement.offsetWidth; height -= 128; width -= 96; var css = app.AppDocument.createStyleSheet(); css.cssText = @" #AccReaderControl { position: absolute; top: 80px; left: 32px; display: block; background: white; color: black; padding: 12px; font-size: 48px; font-family: Segoe UI; border-style: solid; border-width: 1px; font-size: 30px; overflow: scroll; width: " + width + @"px; height: " + height + @"px; z-index: 9999; } #AccReaderControl * { font-size: 30px; } .AccReaderButton { position: absolute; top: 20px; right: 0px; display: block; background: black; color: white; padding: 12px; font-size: 48px; font-family: Verdana; text-align: center; vertical-align: middle; border-style: solid; border-width: 1px; font-size: 30px; width: 80px; height: 30px; z-index: 9999; } "; var div = app.AppDocument.createElement("div"); div.innerHTML = @"<div id='AccReaderControl'>Loading Content...</div> <div class='AccReaderButton' id='AccReaderCloseButton'>Close</div> <div class='AccReaderButton' style='right: 100px' id='AccReaderPlusButton'>[ + ]</div> <div class='AccReaderButton' style='right: 200px' id='AccReaderMinButton'>[ - ]</div> "; var body = app.AppDocument.GetProperty("body") as HTMLBody; body.appendChild(div as IHTMLDOMNode); Trace.WriteLine("Injecting default JS..."); var script = app.AppDocument.createElement("script") as HTMLScriptElement; script.type = "text/javascript"; script.innerText = @" function getCssRule(m) { for (var i=0; i<document.styleSheets.length; i++) { var sheet = document.styleSheets[i]; var r = 0; var rule = false; do { rule = sheet.rules[r]; if (rule && rule.selectorText.toLowerCase()==m.toLowerCase()) { return rule; } r++; } while(rule) } return null; } function getCssRules(m, cb) { for (var i=0; i<document.styleSheets.length; i++) { var sheet = document.styleSheets[i]; var r = 0; var rule = false; do { rule = sheet.rules[r]; if (rule && rule.selectorText.toLowerCase()==m.toLowerCase()) { cb(rule); } r++; } while(rule) } } function allCssRules(cb) { for (var i=0; i<document.styleSheets.length; i++) { var sheet = document.styleSheets[i]; var r = 0; var rule = false; do { rule = sheet.rules[r]; if (rule) { cb(rule); } r++; } while(rule) } } function getFontSizeType(fontSize) { if (fontSize.indexOf('px') != -1) { return 'px'; } if (fontSize.indexOf('pt') != -1) { return 'pt'; } if (fontSize.indexOf('em') != -1) { return 'em'; } if (fontSize.indexOf('ex') != -1) { return 'ex'; } if (fontSize.indexOf('%') != -1) { return '%'; } return 'px'; } function getIncForfontSizeType(ty) { switch(ty) { case 'px': return 2; case 'px': return 2; case 'pt': return 1; case 'em': return 0.2; case 'ex': return 0.4; case '%': return 10; } return 1; } function addProperty(prop, multip) { var ty = getFontSizeType(prop); var inc = getIncForfontSizeType(ty); return (parseFloat(prop) + (inc * multip)) + ty; } function addFontSizeByRule(r, s) { var rule = getCssRule(r); if (rule != null) { rule.style.fontSize = addProperty(rule.style.fontSize, s); rule.style.lineHeight = addProperty(rule.style.lineHeight, s); } } document.getElementById('AccReaderCloseButton').addEventListener('click', function(){ element = document.getElementById('AccReaderControl'); element.parentNode.removeChild(element); element = document.getElementById('AccReaderPlusButton'); element.parentNode.removeChild(element); element = document.getElementById('AccReaderMinButton'); element.parentNode.removeChild(element); element = document.getElementById('AccReaderCloseButton'); element.parentNode.removeChild(element); }, false); document.getElementById('AccReaderPlusButton').addEventListener('click', function(){ addFontSizeByRule('#AccReaderControl', 1); addFontSizeByRule('#AccReaderControl *', 1); }, false); document.getElementById('AccReaderMinButton').addEventListener('click', function(){ addFontSizeByRule('#AccReaderControl', -1); addFontSizeByRule('#AccReaderControl *', -1); }, false); function b64_to_utf8( str ) { return decodeURIComponent(escape(window.atob( str ))); } document.getElementById('AccReaderControl').innerHTML = b64_to_utf8('" + Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(content)) + @"');"; (app.AppDocument.getElementsByTagName("head").item(0, 0) as HTMLHeadElement).appendChild(script as IHTMLDOMNode); //(MainDoc.body as HTMLBody).appendChild(script as IHTMLDOMNode); Trace.WriteLine(app.AppDocument.documentElement.innerHTML); }