public __RadioButton() { // http://msdn2.microsoft.com/en-us/library/system.windows.forms.radiobutton.aspx /* Use the Checked property to get or set the state of a RadioButton. * The option button's appearance can be altered to appear as a toggle-style * button or as a standard option button by setting the Appearance property. */ // http://javascript.about.com/library/blradio2.htm /* The solution here is to give all of the radio buttons within the group * the same name but different values. Here is the code used to code just * radio button themselves on the previous page that shows you how this is done. */ // http://www.thescripts.com/forum/thread468483.html // IE support // http://www.gtalbot.org/DHTMLSection/DynamicallyCreateRadioButtons.html HTMLTarget = new IHTMLDiv(); HTMLTarget.style.whiteSpace = ScriptCoreLib.JavaScript.DOM.IStyle.WhiteSpaceEnum.nowrap; button = new IHTMLInput(ScriptCoreLib.Shared.HTMLInputTypeEnum.radio); label = new IHTMLLabel("", button); HTMLTarget.appendChild(button, label); }
internal static IHTMLLabel InternalConstructor(string e) { IHTMLLabel n = new IHTMLLabel(); n.appendChild(e); return n; }
internal static IHTMLLabel InternalConstructor(string e, IHTMLElement f) { IHTMLLabel n = new IHTMLLabel(e); n.htmlForElement = f; return n; }
internal static IHTMLLabel InternalConstructor(string e, IHTMLElement f) { IHTMLLabel n = new IHTMLLabel(e); n.htmlForElement = f; return(n); }
internal static IHTMLLabel InternalConstructor(string e) { IHTMLLabel n = new IHTMLLabel(); n.appendChild(e); return(n); }
public __TextBlock() { this.InternalContainer = new IHTMLDiv(); this.InternalContainer.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute; this.InternalContainer.name = "__TextBlock"; this.InternalContainer.style.left = "0px"; this.InternalContainer.style.top = "0px"; this.InternalElement = new IHTMLLabel(); this.InternalElement.AttachTo(this.InternalContainer); }
/// <summary> /// This is a javascript application. /// </summary> /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param> public Application(IDefault page) { IHTMLDiv Control = new IHTMLDiv(); Control.AttachToDocument(); Control.appendChild(new IHTMLElement(IHTMLElement.HTMLElementEnum.h1, "This page will ask you to confirm in order to unload the page")); var check = new IHTMLInput(HTMLInputTypeEnum.checkbox).AttachToDocument(); var label = new IHTMLLabel("Bypass check", check).AttachToDocument(); Native.window.onbeforeunload += delegate (IWindow.Confirmation ev) { Timer.DoAsync( delegate { Native.document.body.style.backgroundColor = JSColor.Red; new Timer((t) => Native.document.body.style.backgroundColor = JSColor.White, 500, 0); } ); if (check.@checked) return; ev.Text = "This is a secure website, do you want to leave?"; }; var anchor = new IHTMLAnchor("http://example.com", "example.com"); anchor.target = "_self"; Control.appendChild(anchor); }
public __Label() { this.HTMLTargetContainer = new IHTMLDiv(); this.InternalLabel = new IHTMLLabel().AttachTo(this.HTMLTargetContainer); this.InternalLabel.style.position = IStyle.PositionEnum.absolute; this.InternalLabel.style.left = "0"; this.InternalLabel.style.right = "0"; this.InternalLabel.style.bottom = "0"; this.InternalLabel.style.top = "0"; this.InternalLabel.style.whiteSpace = DOM.IStyle.WhiteSpaceEnum.pre; this.InternalLabel.style.display = IStyle.DisplayEnum.inline_block; this.HTMLTarget = this.InternalLabel; this.Size = new global::System.Drawing.Size(100, 18); this.InternalSetDefaultFont(); }
/// <summary> /// This is a javascript application. /// </summary> /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param> public Application(IApp page) { Func<IHTMLAudio, Action<double>> loop = snd => { Action iloop = null; var r = new IHTMLInput(); var label = new IHTMLLabel(snd.src, r).AttachToDocument(); dynamic rr = r; rr.type = "range"; r.AttachToDocument(); Action newvolume = delegate { snd.volume = int.Parse(r.value) / 100; }; r.onchange += delegate { newvolume(); }; iloop = delegate { Console.WriteLine("at canplaythrough " + new { snd.duration }); newvolume(); snd.play(); snd.onended += delegate { Console.WriteLine("at onended"); }; //var xsnd = snd; var xsnd = new IHTMLAudio { src = snd.src }; xsnd.autobuffer = true; new ScriptCoreLib.JavaScript.Runtime.Timer( delegate { snd.volume = snd.volume * 0.5; Console.WriteLine("at timer " + new { snd.currentTime, snd.duration }); snd = xsnd; iloop(); } ).StartTimeout((int)(1000 * snd.duration - 0.8)); xsnd.load(); }; snd.autobuffer = true; // http://areweplayingyet.org/event-canplaythrough Console.WriteLine("waiting for canplaythrough"); snd.addEventListener( "canplaythrough", new Action( delegate { iloop(); } ) ); new IHTMLBreak().AttachToDocument(); return nextvolume => { r.value = "" + (int)(nextvolume * 100); newvolume(); }; }; //loop(new helicopter1wav()); var r0 = loop(new dieselloop()); var r1 = loop(new dieselloopm5()); var r2 = loop(new dieselloopm5m5()); // we need SIN var zero = 0; var lookup = new[] { new double [] {zero, 0, 0}, new double [] {0, 0, 1}, new double [] {0, 1, 0}, new double [] {1, 0, 0}, }; var tween_r0 = NumericEmitter.OfDouble( (x, y) => { r0(x); } ); var tween_r1 = NumericEmitter.OfDouble( (x, y) => { r1(x); } ); var tween_r2 = NumericEmitter.OfDouble( (x, y) => { r2(x); } ); Action masterswitchchanged = delegate { var masterswitch = int.Parse(page.masterswitch.value); Console.WriteLine( new { masterswitch } ); lookup[masterswitch].With( x => { tween_r0(x[0], 0); tween_r1(x[1], 0); tween_r2(x[2], 0); } ); }; page.masterswitch.onchange += delegate { masterswitchchanged(); }; page.masterswitch.value = "" + (lookup.Length - 1); masterswitchchanged(); }
/// <summary> /// Creates a new control /// </summary> /// <param name="DataElement">The hidden data element</param> public SimpleFilmstrip() { IHTMLDiv Control = new IHTMLDiv(); Control.style.position = IStyle.PositionEnum.absolute; new filmstrip().ToBackground(Control, false); //Control.style.background = "url(assets/SimpleFilmstrip/filmstrip.png) no-repeat"; Control.style.height = "600px"; Control.style.width = "326px"; var index = 0; var t_icount = default(int); var t_interval = default(int); var t_iwidth = default(int); var t_iheight = default(int); var t_feed = default(string); var Restart = default(Action); var feed = new IHTMLInput(HTMLInputTypeEnum.text, new veh_cy().src ); var iwidth = new IHTMLInput(HTMLInputTypeEnum.text, "48"); var iheight = new IHTMLInput(HTMLInputTypeEnum.text, "48"); var icount = new IHTMLInput(HTMLInputTypeEnum.text, "32"); var interval = new IHTMLInput(HTMLInputTypeEnum.text, "50"); var fps = new IHTMLInput(HTMLInputTypeEnum.text, "24"); feed.onchange += delegate { Restart(); }; iwidth.onchange += delegate { Restart(); }; iheight.onchange += delegate { Restart(); }; interval.onchange += delegate { int v = int.Parse(interval.value); if (v == 0) return; fps.value = "" + (1000 / v); Restart(); }; icount.onchange += delegate { Restart(); }; fps.onchange += delegate { int v = int.Parse(fps.value); if (v == 0) return; interval.value = "" + (1000 / v); Restart(); }; var fieldset = new IHTMLElement(IHTMLElement.HTMLElementEnum.fieldset); fieldset.style.width = "30em"; fieldset.appendChild(new IHTMLElement(IHTMLElement.HTMLElementEnum.legend, "Properties")); Func<string, IHTMLElement, IHTMLDiv> AsLabel = (string text, IHTMLElement control) => { var label = new IHTMLLabel(text, control); control.style.position = IStyle.PositionEnum.absolute; control.style.left = "8em"; return new IHTMLDiv(label, control); }; fieldset.appendChild(AsLabel("feed:", feed)); fieldset.appendChild(AsLabel("width:", iwidth)); fieldset.appendChild(AsLabel("height:", iheight)); fieldset.appendChild(AsLabel("count:", icount)); fieldset.appendChild(AsLabel("interval:", interval)); fieldset.appendChild(AsLabel("fps:", fps)); fieldset.style.position = IStyle.PositionEnum.absolute; fieldset.style.top = "320px"; var image = new IHTMLDiv(); image.style.position = IStyle.PositionEnum.absolute; image.style.top = "52px"; image.style.left = "32px"; var t = new Timer(); t.Tick += delegate { image.style.backgroundPosition = "-" + (index * t_iwidth) + "px 0px"; index = (index + 1) % t_icount; }; Restart = delegate { t_icount = int.Parse(icount.value); t_interval = int.Parse(interval.value); t_iwidth = int.Parse(iwidth.value); t_iheight = int.Parse(iheight.value); t_feed = feed.value; image.style.background = "url(" + t_feed + ") no-repeat"; image.style.width = t_iwidth + "px"; image.style.height = t_iheight + "px"; t.StartInterval(t_interval); }; Restart(); Control.appendChild(image, fieldset); Control.AttachToDocument(); }
public __CheckBox() { HTMLTarget = new IHTMLDiv(); HTMLTarget.style.whiteSpace = ScriptCoreLib.JavaScript.DOM.IStyle.WhiteSpaceEnum.nowrap; InternalInputElement = new IHTMLInput(ScriptCoreLib.Shared.HTMLInputTypeEnum.checkbox, ""); InternalInputElement.style.margin = "0"; InternalInputElement.style.verticalAlign = "middle"; InternalInputElement.style.width = "auto"; label = new IHTMLLabel("", InternalInputElement); label.style.verticalAlign = "middle"; label.style.marginLeft = "0.5em"; label.style.display = DOM.IStyle.DisplayEnum.inline; label.onmousedown += e => { e.preventDefault(); }; this.CheckStateChanged += delegate { if (this.ThreeState) { // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#dom-input-indeterminate this.InternalInputElement.indeterminate = (this.InternalCheckState == global::System.Windows.Forms.CheckState.Indeterminate); } }; this.InternalInputElement.onchange += e => { // http://shamsmi.blogspot.com/2008/12/tri-state-checkbox-using-javascript.html if (this.ThreeState) { if (this.InternalCheckState == global::System.Windows.Forms.CheckState.Checked) { // http://jsfiddle.net/chriscoyier/mGg85/2/ // http://jsfiddle.net/ysangkok/UhQc8/ //e.preventDefault(); //e.stopPropagation(); // next step is to go from checked to unchecked! this.InternalInputElement.@checked = true; this.CheckState = global::System.Windows.Forms.CheckState.Indeterminate; return; } } if (this.InternalCheckState == global::System.Windows.Forms.CheckState.Unchecked) { this.CheckState = global::System.Windows.Forms.CheckState.Checked; return; } this.CheckState = global::System.Windows.Forms.CheckState.Unchecked; }; HTMLTarget.appendChild(InternalInputElement, label); this.InternalSetDefaultFont(); }
private void ContinueBuildingApplication() { var note1 = new IHTMLPre { innerHTML = @"Notice: If flash does not respond to events, you need to clear your cache. + Chrome flash in 'localhost' on Cassini always fails? - If so Try http://127.0.0.1 or http://COMPUTERNAME + Opera does not pass delegates? + IE cannot return from javascript to flash + Web page could be delivered within flash package + Javascript rewrite could omit unused types and methods " }.AttachToDocument(); note1.style.whiteSpace = ScriptCoreLib.JavaScript.DOM.IStyle.WhiteSpaceEnum.pre; note1.style.fontSize = "small"; note1.style.color = Color.Red; var s = new UltraSprite(); s.AttachSpriteToDocument(); var SayHello = new IHTMLButton { innerText = "Say Hello to flash!" }.AttachToDocument(); SayHello.onclick += delegate { s.AppendLine("Hello from javascript"); s.WhenReady( delegate { s.AppendLine("What about using the web service?"); } ); }; s.AppendLine("This call is delayed until flash is loaded (1)"); s.AppendLine("This call is delayed until flash is loaded (2)"); s.AppendLine("This call is delayed until flash is loaded (3)"); s.WhenReady( delegate { s.AppendLine("What about using the web service?"); } ); // passing the interface to flash is delayed until it is loaded, using the getter will fault s.WebService = new AlphaWebService(); s.WebServiceEnabled = this; s.AppendLine("This call is delayed until flash is loaded (4)"); new IHTMLBreak().AttachToDocument(); this.WebServiceEnabled = new IHTMLInput(ScriptCoreLib.Shared.HTMLInputTypeEnum.checkbox); var WebServiceEnabledLabel = new IHTMLLabel("WebService is enabled for flash", this.WebServiceEnabled); new IHTMLDiv( WebServiceEnabledLabel, WebServiceEnabled ).AttachToDocument(); ButtonsForWebService(); }