示例#1
0
        public __GroupBox()
        {
            fieldset = new IHTMLElement(IHTMLElement.HTMLElementEnum.fieldset);
            fieldset.style.padding = "0";
            fieldset.style.margin  = "0";

            legend = new IHTMLElement(IHTMLElement.HTMLElementEnum.legend);
            legend.style.marginLeft = "0.5em";

            fieldset.appendChild(legend);

            this.InternalContainer = new IHTMLDiv();
            fieldset.appendChild(this.InternalContainer);

            this.InternalSetDefaultFont();
        }
示例#2
0
        public __GroupBox()
        {
            fieldset = new IHTMLElement(IHTMLElement.HTMLElementEnum.fieldset);
			fieldset.style.padding = "0";
			fieldset.style.margin = "0";

            legend = new IHTMLElement(IHTMLElement.HTMLElementEnum.legend);
			legend.style.marginLeft = "0.5em";

            fieldset.appendChild(legend);

			this.InternalContainer = new IHTMLDiv();
			fieldset.appendChild(this.InternalContainer);

			this.InternalSetDefaultFont();
        }
示例#3
0
        public static string ToHtml(string e)
        {
            IHTMLElement d = new IHTMLElement();

            d.appendChild(e);

            return(d.innerHTML);
        }
示例#4
0
        private static IHTMLElement Dump(object xs, IHTMLElement to, object diff)
        {
            var c = new IHTMLDiv();

            c.style.backgroundColor = Color.White;
            c.style.border          = "1px solid gray";
            c.style.padding         = "1em";
            c.style.fontFamily      = IStyle.FontFamilyEnum.Consolas;

            var ttx = new IHTMLDiv(xs.ToString());

            c.appendChild(ttx);

            var dx = Expando.Of(diff);

            foreach (var v in Expando.Of(xs).GetMembers())
            {
                var tt = default(IHTMLDiv);
                var ok = true;

                if (dx != null)
                {
                    if (dx.Contains(v.Name))
                    {
                        if (dx[v.Name] == v.Self)
                        {
                            ok = false;
                        }
                    }
                }

                if (ok)
                {
                    if (v.Self.IsFunction)
                    {
                        tt             = new IHTMLDiv(v.Self.TypeString + " " + v.Name);
                        tt.style.color = Color.Red;
                    }
                    else if (v.Self.IsObject)
                    {
                        tt             = new IHTMLDiv(v.Self.TypeString + " " + v.Name + " = " + v.Self.ToString());
                        tt.style.color = Color.Blue;
                    }
                    else
                    {
                        tt = new IHTMLDiv(v.Self.TypeString + " " + v.Name + " = " + v.Self.ToString());
                    }

                    c.appendChild(tt);
                }
            }

            to.appendChild(c);

            return(to);
        }
示例#5
0
        //async Task __buttryfly()
        //{ 
        //    //Task.Factory.
        //}

        //async 
        void Spawn(IHTMLElement e)
        {


            Native.Document.body.style.margin = "0px";
            Native.Document.body.style.padding = "0px";
            Native.Document.body.style.overflow = IStyle.OverflowEnum.hidden;

            e.style.position = IStyle.PositionEnum.absolute;
            e.style.left = "0px";
            e.style.top = "0px";
            e.style.right = "0px";
            e.style.bottom = "0px";

            e.style.backgroundColor = Color.FromRGB(209, 245, 245);

            IHTMLElement loading = new IHTMLElement(IHTMLElement.HTMLElementEnum.code, "loading...");

            loading.style.SetLocation(64, 64, 200, 64);

            e.appendChild(loading);

            //await __buttryfly();

            new global::ButterFlyWithInteractiveInt32Offset.HTML.Images.FromAssets.buttryfly().InvokeOnComplete(
                img =>
                {
                    loading.FadeOut();

                    try
                    {
                        //IStyleSheet.Default.AddRule("*", "cursor: none, url('" + new global::ButterFlyWithInteractiveInt32Offset.HTML.Images.FromAssets.nocursor().src + "'), auto;", 0);
                        //IStyleSheet.Default.AddRule("*", "cursor: none;", 0);
                    }
                    catch (Exception exc)
                    {
                        new IHTMLElement(IHTMLElement.HTMLElementEnum.pre, exc.Message).AttachToDocument();
                    }


                    e.style.backgroundImage = "url(" + img.src + ")";
                    e.style.backgroundRepeat = "no-repeat";



                    e.DisableContextMenu();


                    var x = 0;
                    var y = 0;


                    var overlay = new IHTMLDiv();
                    overlay.style.border = "1px solid red";
                    overlay.style.SetSize(64, 64);
                    overlay.AttachToDocument();

                   Native.window.onframe +=
                        delegate
                        {
                            e.style.backgroundPosition = x + "px " + y + "px";

                            overlay.style.SetLocation(
                                // how does this work with the background compiler?
                                // once browser clicks save, visual studio asks if
                                // to accept, and bacground compiler
                                // starts a new compilation
                                // so, the running app could first be able
                                // to inspect, whats new?
                                // and if only the same constant was changed,
                                // it can be discarded. same with comments.
                                x + 67.ToInteractiveInt32Form(),
                                y + 2.ToInteractiveInt32Form()
                            );

                        };

                    e.onmousemove +=
                        delegate(IEvent i)
                        {


                            #region where is the cursor?
                            if (Native.Document.pointerLockElement == e)
                            {
                                x += i.movementX;
                                y += i.movementY;
                            }
                            else
                            {
                                x = i.CursorX;
                                y = i.CursorY;
                            }

                            if (x < -img.width / 2)
                                x += Native.window.Width;

                            if (y < -img.height / 2)
                                y += Native.window.Height;

                            x = x % Native.window.Width;
                            y = y % Native.window.Height;
                            #endregion



                        };

                    e.onclick +=
                        delegate
                        {
                            e.requestPointerLock();
                        };
                });

        }
        public static void GenerateView(string[] lines)
        {
            string Status = "";

            var c = new IHTMLElement(IHTMLElement.HTMLElementEnum.center, "");
            var cursor = Native.Document.createElement("blink");
            cursor.innerText = "_";

            var index = 0;
            var index_char = 0;

            var span = new IHTMLSpan();

            var delay_delayed = false;

            Status = "creating actions";
            var Delay = default(System.Action<System.Action, int>);

            Delay = (h, due) => new Timer(

            delegate
            {

                if (delay_delayed)
                    Delay(h, due);
                else
                    h();

            }, due, 0);

            System.Func<string> CurrentLineString = () => (1 + index) + ". " + lines[index].Trim();

            var DeleteChar = default(System.Action);
            var PrintChar = default(System.Action);
            var ChooseLine = default(System.Action);

            DeleteChar =
                () =>
                {
                    index_char--;

                    span.innerText = CurrentLineString().Substring(0, index_char);

                    if (index_char == 0)
                    {
                        ChooseLine();
                    }
                    else
                    {
                        Delay(DeleteChar, 30);
                    }
                };

            PrintChar =
                () =>
                {
                    index_char++;

                    if (index_char < CurrentLineString().Length)
                    {
                        var x = 100;
                        var y = CurrentLineString()[index_char];


                        if (",. \t\n".Contains("" + y))
                            x = 200;


                        if (index_char > 1)
                            span.style.color = Color.None;

                        span.innerText = CurrentLineString().Substring(0, index_char);
                        Delay(PrintChar, x);
                    }
                    else
                    {
                        Delay(DeleteChar, 3000);
                    }
                };

            ChooseLine =
                () =>
                {
                    index = new System.Random().Next() % lines.Length;
                    index_char = 0;
                    span.innerText = "";
                    span.style.color = Color.White;

                    PrintChar();
                };

            Status = "adding to document";

            c.onmouseover +=
                delegate
                {
                    c.style.color = Color.Yellow;
                    delay_delayed = true;
                };

            c.onmouseout +=
                delegate
                {
                    c.style.color = Color.None;
                    delay_delayed = false;
                };


            c.appendChild(span, cursor);
            c.AttachToDocument();

            ChooseLine();
        }
        private static IHTMLElement Dump(object xs, IHTMLElement to, object diff)
        {

            var c = new IHTMLDiv();

            c.style.backgroundColor = Color.White;
            c.style.border = "1px solid gray";
            c.style.padding = "1em";
            c.style.fontFamily = IStyle.FontFamilyEnum.Consolas;

            var ttx = new IHTMLDiv(xs.ToString());

            c.appendChild(ttx);

            var dx = Expando.Of(diff);

            foreach (var v in Expando.Of(xs).GetMembers())
            {
                var tt = default(IHTMLDiv);
                var ok = true;

                if (dx != null)
                {
                    if (dx.Contains(v.Name))
                    {
                        if (dx[v.Name] == v.Self)
                            ok = false;
                    }
                }

                if (ok)
                {
                    if (v.Self.IsFunction)
                    {
                        tt = new IHTMLDiv(v.Self.TypeString + " " + v.Name);
                        tt.style.color = Color.Red;

                    }
                    else if (v.Self.IsObject)
                    {
                        tt = new IHTMLDiv(v.Self.TypeString + " " + v.Name + " = " + v.Self.ToString());
                        tt.style.color = Color.Blue;
                    }
                    else
                        tt = new IHTMLDiv(v.Self.TypeString + " " + v.Name + " = " + v.Self.ToString());

                    c.appendChild(tt);
                }
            }

            to.appendChild(c);

            return to;

        }
        //public const string Alias = "Class1";
        //public const string DefaultData = "Class1Data";

        /// <summary>
        /// Creates a new control
        /// </summary>
        /// <param name="DataElement">The hidden data element</param>
        public GoogleGearsSimple()
        {
            // this ctor creates a new div which has a text and a button element
            // on mouseover over the color text is changed
            // on pressing the button the next message in text element is displayed
            IHTMLDiv Control = new IHTMLDiv();

            Control.AttachToDocument();

            Func <string, string, IHTMLElement> link = (href, text) => new IHTMLDiv(new IHTMLAnchor(href, text));


            Control.appendChild(link("http://gears.google.com/", "Google Gears"));
            Control.appendChild(link("http://code.google.com/apis/gears/samples/hello_world_database.html", "Google Example # 1"));

            Control.appendChild(new IHTMLElement(IHTMLElement.HTMLElementEnum.h3, "This page uses Google Gears to record your entries on the local disk. If you navigate away and revisit this page, all your data will still be here. Try it!"));

            // http://code.google.com/apis/gears/samples/hello_world_database.html

            GoogleGearsFactory.Database db = null;

            try
            {
                db = new GoogleGearsFactory.Database();
            }
            catch (Exception exc)
            {
                var err = new IHTMLCode(exc.Message);

                err.style.color = Color.Red;


                Control.appendChild(err);
            }

            IStyleSheet.Default.AddRule(".odd").style.backgroundColor  = Color.FromGray(0xa0);
            IStyleSheet.Default.AddRule(".even").style.backgroundColor = Color.FromGray(0xef);

            if (db != null)
            {
                db.open("demo1");
                db.execute(@"
    create table if not exists Demo
    (Phrase varchar(255), Timestamp int)
            ");

                var textfield = new IHTMLInput(HTMLInputTypeEnum.text, "text1", "");

                var btnadd     = new IHTMLButton("Add new entry");
                var btnrefresh = new IHTMLButton("Refresh");
                var btnclear   = new IHTMLButton("Clear");

                Control.appendChild(textfield, btnadd, btnclear, btnrefresh,

                                    new IHTMLCode(GoogleGearsFactory.Default.getBuildInfo())

                                    );



                var list = new IHTMLElement(IHTMLElement.HTMLElementEnum.ol);

                Control.appendChild(list);

                var read = default(Action);

                read = delegate
                {
                    //from i in Demo
                    //select new { Phrase, Timestamp }
                    //order by Timestamp desc

                    list.removeChildren();

                    Func <string, IHTMLElement> AddItem =
                        text => new IHTMLElement(IHTMLElement.HTMLElementEnum.li, text).Aggregate(v => list.appendChild(v));



                    // this could be rewritten as an expression once they are supported by jsc

                    int counter = 0;

                    var query = from Data in db.AsEnumerable <DemoDataEntity>(
                        "select * from Demo order by Timestamp desc",
                        typeof(DemoDataEntity)
                        )
                                // let ListItem = AddItem(Data.Timestamp + " - " + Data.Phrase)
                                select new __Type2 {
                        ListItem = AddItem(Data.Timestamp + " - " + Data.Phrase), Data = Data
                    };

                    foreach (var v in query)
                    {
                        counter++;
                        var vx = v;


                        if (counter % 2 == 0)
                        {
                            v.ListItem.className = "odd";
                        }
                        else
                        {
                            v.ListItem.className = "even";
                        }

                        #region -
                        var btndel = new IHTMLButton("-");

                        btndel.style.color = Color.Red;

                        btndel.onclick +=
                            delegate
                        {
                            db.execute("delete from Demo where Timestamp = ?", vx.Data.Timestamp);

                            read();
                        };
                        #endregion

                        #region +
                        var btnclone = new IHTMLButton("+");

                        btnclone.style.color = Color.Blue;

                        btnclone.onclick +=
                            delegate
                        {
                            db.Insert("Demo", vx.Data);


                            read();
                        };
                        #endregion

                        v.ListItem.insertBefore(btnclone, v.ListItem.firstChild);
                        v.ListItem.insertBefore(btndel, v.ListItem.firstChild);
                    }


                    #region raw
                    //var rs = db.execute("select * from Demo order by Timestamp desc");

                    //while (rs.isValidRow())
                    //{
                    //    var xt = typeof(DemoDataEntity);
                    //    var xx = (DemoDataEntity)Activator.CreateInstance(xt);

                    //    for (int i = 0; i < rs.fieldCount(); i++)
                    //    {
                    //        xt.GetField(rs.fieldName(i)).SetValue(xx, rs.field(i));
                    //    }

                    //    AddItem(xx.Timestamp + " - " + xx.Phrase);

                    //    rs.next();
                    //}

                    //rs.close();
                    #endregion
                };

                btnclear.onclick +=
                    delegate
                {
                    db.execute("delete from Demo");

                    read();
                };

                btnadd.onclick +=
                    delegate
                {
                    db.Insert("Demo",
                              new DemoDataEntity
                    {
                        Phrase    = textfield.value,
                        Timestamp = IDate.Now.getTime()
                    }
                              );

                    //db.execute("insert into Demo (Phrase, Timestamp) values (?, ?)", textfield.value, IDate.Now.getTime());

                    textfield.value = "";

                    read();
                };

                btnrefresh.onclick +=
                    delegate
                {
                    read();
                };

                read();
            }


            // not array
            // is object
            // no prototype
        }
示例#9
0
        //async Task __buttryfly()
        //{
        //    //Task.Factory.
        //}

        //async
        void Spawn(IHTMLElement e)
        {
            Native.Document.body.style.margin   = "0px";
            Native.Document.body.style.padding  = "0px";
            Native.Document.body.style.overflow = IStyle.OverflowEnum.hidden;

            e.style.position = IStyle.PositionEnum.absolute;
            e.style.left     = "0px";
            e.style.top      = "0px";
            e.style.right    = "0px";
            e.style.bottom   = "0px";

            e.style.backgroundColor = Color.FromRGB(209, 245, 245);

            IHTMLElement loading = new IHTMLElement(IHTMLElement.HTMLElementEnum.code, "loading...");

            loading.style.SetLocation(64, 64, 200, 64);

            e.appendChild(loading);

            //await __buttryfly();

            new global::ButterFlyWithInteractiveInt32Offset.HTML.Images.FromAssets.buttryfly().InvokeOnComplete(
                img =>
            {
                loading.FadeOut();

                try
                {
                    //IStyleSheet.Default.AddRule("*", "cursor: none, url('" + new global::ButterFlyWithInteractiveInt32Offset.HTML.Images.FromAssets.nocursor().src + "'), auto;", 0);
                    //IStyleSheet.Default.AddRule("*", "cursor: none;", 0);
                }
                catch (Exception exc)
                {
                    new IHTMLElement(IHTMLElement.HTMLElementEnum.pre, exc.Message).AttachToDocument();
                }


                e.style.backgroundImage  = "url(" + img.src + ")";
                e.style.backgroundRepeat = "no-repeat";



                e.DisableContextMenu();


                var x = 0;
                var y = 0;


                var overlay          = new IHTMLDiv();
                overlay.style.border = "1px solid red";
                overlay.style.SetSize(64, 64);
                overlay.AttachToDocument();

                Native.window.onframe +=
                    delegate
                {
                    e.style.backgroundPosition = x + "px " + y + "px";

                    overlay.style.SetLocation(
                        // how does this work with the background compiler?
                        // once browser clicks save, visual studio asks if
                        // to accept, and bacground compiler
                        // starts a new compilation
                        // so, the running app could first be able
                        // to inspect, whats new?
                        // and if only the same constant was changed,
                        // it can be discarded. same with comments.
                        x + 67.ToInteractiveInt32Form(),
                        y + 2.ToInteractiveInt32Form()
                        );
                };

                e.onmousemove +=
                    delegate(IEvent i)
                {
                    #region where is the cursor?
                    if (Native.Document.pointerLockElement == e)
                    {
                        x += i.movementX;
                        y += i.movementY;
                    }
                    else
                    {
                        x = i.CursorX;
                        y = i.CursorY;
                    }

                    if (x < -img.width / 2)
                    {
                        x += Native.window.Width;
                    }

                    if (y < -img.height / 2)
                    {
                        y += Native.window.Height;
                    }

                    x = x % Native.window.Width;
                    y = y % Native.window.Height;
                    #endregion
                };

                e.onclick +=
                    delegate
                {
                    e.requestPointerLock();
                };
            });
        }
示例#10
0
        private static void Spawn()
        {
            // this ctor creates a new div which has a text and a button element
            // on mouseover over the color text is changed
            // on pressing the button the next message in text element is displayed


            IStyleSheet.Default.AddRule("img.fx1",
                                        r =>
            {
                r.style.position = IStyle.PositionEnum.absolute;
                r.style.top      = "0";
                r.style.border   = "0";
            });


            Native.css.style.cursorImage = new HTML.Images.FromAssets.cursor01();

            //IStyleSheet.Default.AddRule("*", "cursor: url('" + new HTML.Images.FromAssets.cursor01().src + "'), auto;", 0);

            var img = new HTML.Images.FromAssets._99851426_7f408a6cc3_o_gray {
                className = "fx1"
            };

            var img_up = new HTML.Images.FromAssets.up {
                className = "fx1"
            };
            var img_up_neg = new HTML.Images.FromAssets.up_neg {
                className = "fx1"
            };
            var img_down = new HTML.Images.FromAssets.down {
                className = "fx1"
            };



            img.AttachToDocument();
            img_up.AttachToDocument();
            img_up_neg.AttachToDocument();


            var info_size = new XSize
            {
                width  = 350,
                height = 200
            };

            var info_bg = new IHTMLDiv();

            info_bg.style.SetLocation(60, 60, info_size.width, info_size.height);
            info_bg.style.Opacity = 0.2;
            info_bg.style.zIndex  = 1;
            info_bg.AttachToDocument();

            var info_borders = new IHTMLDiv();

            info_borders.style.SetLocation(60 - 4, 60 - 4, info_size.width + 8, info_size.height + 8);
            info_borders.style.Opacity = 0.2;
            info_borders.style.zIndex  = 4;
            info_borders.AttachToDocument();

            var info_drag_tween = new TweenDataDouble();

            var info_bg_useimage_cookie = new Cookie("setting1");

            var info_bg_useimage = new DynamicProperty <bool>(
                p =>
            {
                info_bg_useimage_cookie.BooleanValue = p.Value;

                if (p.Value)
                {
                    new HTML.Images.FromAssets.up_neg().ToBackground(info_borders.style);
                    new HTML.Images.FromAssets.up_neg().ToBackground(info_bg.style);
                }
                else
                {
                    info_borders.style.backgroundImage = "";
                    info_bg.style.backgroundImage      = "";
                }

                info_drag_tween.Value = 0.5;
            }
                )
            {
                Value = info_bg_useimage_cookie.BooleanValue
            };



            var info_drag = new DragHelper(info_borders);

            info_drag_tween.Value         = 0;
            info_drag_tween.ValueChanged +=
                delegate
            {
                var i = ScriptCoreLib.JavaScript.Runtime.Convert.ToInteger(255 * info_drag_tween.Value);

                if (!info_bg_useimage.Value)
                {
                    info_bg.style.backgroundColor      = Color.FromRGB(i, i, 0);
                    info_borders.style.backgroundColor = Color.FromRGB(i, i, 0);
                }
                else
                {
                    if (i < 1)
                    {
                        i = 1;
                    }

                    info_bg.style.Opacity      = i / 255;
                    info_borders.style.Opacity = i / 255 * 0.5;
                }
            };

            info_borders.style.cursor = IStyle.CursorEnum.move;

            info_borders.onmouseover +=
                delegate
            {
                if (info_drag.IsDrag)
                {
                    return;
                }

                info_drag_tween.Value = 1;
            };



            info_borders.onmouseout +=
                delegate
            {
                if (info_drag.IsDrag)
                {
                    return;
                }

                info_drag_tween.Value = 0;
            };



            var info = new IHTMLDiv();

            info.onmouseover +=
                delegate
            {
                if (info_drag.IsDrag)
                {
                    return;
                }

                info_drag_tween.Value = 0.5;
            };



            info.onmouseout +=
                delegate
            {
                if (info_drag.IsDrag)
                {
                    return;
                }

                info_drag_tween.Value = 0;
            };

            info.style.color      = Color.White;
            info.style.fontFamily = IStyle.FontFamilyEnum.Tahoma;

            Func <string, IHTMLElement> par = texty => new IHTMLElement(IHTMLElement.HTMLElementEnum.p, texty);


            Native.Document.title = "HotPolygon";

            info.innerHTML = @"<h1>HotPolygon</h1>";

            //var preview = new IHTMLImage("assets/HotPolygon/Preview.png");

            //preview.style.Float = IStyle.FloatEnum.right;
            //preview.style.margin = "1em";

            info.appendChild(
                //preview,
                par("This example demonstrates the use of custom cursors, map, area, timed animation, cookies and a custom dialog."),
                par("You can change the background of this page by hovering above the tree or one of the clouds."),
                par("And yes you can drag this dialog at the borders :)"),

                new IHTMLDiv(
                    @"
                    <ul>
                        <li>visit <a href='http://jsc.sf.net/'>jsc homepage</a></li>
                        <li>visit <a href='http://zproxy.wordpress.com/'>blog</a></li>
                    </ul>
                                ")
                );



            var info_option       = new IHTMLInput(HTMLInputTypeEnum.checkbox);
            var info_option_label = new IHTMLLabel("Alternative background", info_option);


            info.appendChild(new IHTMLElement(IHTMLElement.HTMLElementEnum.p, info_option, info_option_label));



            info_option.onclick += i => info_bg_useimage.Value = info_option.@checked;
            info_option.@checked = info_bg_useimage.Value;

            info.style.overflow = IStyle.OverflowEnum.auto;

            info.style.SetLocation(70, 70, info_size.width - 20, info_size.height - 20);
            info.style.zIndex = 5;
            info.AttachToDocument();

            info_drag.DragMove +=
                delegate
            {
                if (info_bg_useimage.Value)
                {
                    info_borders.style.backgroundPosition = (-(info_drag.Position.X - 4)) + "px " + (-(info_drag.Position.Y - 4)) + "px";
                    info_bg.style.backgroundPosition      = (-info_drag.Position.X) + "px " + (-info_drag.Position.Y) + "px";
                }

                info_borders.style.SetLocation(info_drag.Position.X - 4, info_drag.Position.Y - 4);
                info_bg.style.SetLocation(info_drag.Position.X, info_drag.Position.Y);
                info.style.SetLocation(info_drag.Position.X + 10, info_drag.Position.Y + 10);
            };

            info_drag.Position = new Point(60, 60);
            info_drag.Enabled  = true;

            // 416 x 100

            var img_here_src_off =
                new IHTMLImage[]
            {
                new HTML.Images.FromAssets.here0(),
                new HTML.Images.FromAssets.here1(),
                new HTML.Images.FromAssets.here2(),
                new HTML.Images.FromAssets.here3(),
                new HTML.Images.FromAssets.here4(),
                new HTML.Images.FromAssets.here5(),
            };

            var img_here_src_on =
                new IHTMLImage[]
            {
                new HTML.Images.FromAssets.here0(),
                new HTML.Images.FromAssets.here1(),
                new HTML.Images.FromAssets.here2(),
                new HTML.Images.FromAssets.here3(),
                new HTML.Images.FromAssets.here4(),
                new HTML.Images.FromAssets.here5(),
            }.Reverse().ToArray();



            var img_here = new IHTMLDiv();

            img_here.style.SetSize(416, 100);

            Action <Action, int> Wait =
                (done, time) =>
            {
                new Timer(t => done(), time, 0);
            };


            ActionParams <Action, Action> DelayFrames =
                (done, h) =>
            {
                int i = 0;

                var next = default(Action);

                next = () =>
                {
                    if (i < h.Length)
                    {
                        var v = h[i];
                        i++;

                        Wait(() => { if (v != null)
                                     {
                                         v();
                                     }
                                     next(); }, 1000 / 24);
                    }
                    else
                    {
                        Wait(done, 1000 / 24);
                    }
                };

                next();
            };


            var AnimationOn       = default(Action);
            var AnimationOff      = default(Action);
            var AnimationRandomOn = default(Action);


            AnimationOff =
                () =>
            {
                DelayFrames(
                    () =>
                {
                    img_here.style.display = IStyle.DisplayEnum.none;

                    Wait(() =>
                    {
                        AnimationRandomOn();
                    }, 5000);
                }
                    ,
                    img_here_src_off.Select <IHTMLImage, Action>(i => () => i.ToBackground(img_here.style)).ToArray()
                    );
            };

            AnimationOn =
                () =>
            {
                img_here.style.display = IStyle.DisplayEnum.block;

                DelayFrames(
                    () => Wait(AnimationOff, 3000),
                    img_here_src_on.Select <IHTMLImage, Action>(i => () => i.ToBackground(img_here.style)).ToArray()
                    );
            };

            AnimationRandomOn =
                () =>
            {
                try
                {
                    if (new System.Random().NextDouble() > 0.5)
                    {
                        img_here.SetCenteredLocation(589, 509);
                    }
                    else
                    {
                        img_here.SetCenteredLocation(686, 141);
                    }

                    Wait(AnimationOn, new System.Random().Next() % 15000);
                }
                catch
                {
                }
            };


            img_here.style.SetLocation(100, 100);
            img_here.style.zIndex = 1;

            AnimationRandomOn();


            img_here.AttachToDocument();

            img_down.AttachToDocument();

            img_up.style.Opacity     = 0;
            img_up_neg.style.Opacity = 0;

            var tw_up = new TweenDataDouble();

            tw_up.Value         = 0;
            tw_up.ValueChanged += delegate { img_up.style.Opacity = tw_up.Value; };

            var tw_up_neg = new TweenDataDouble();

            tw_up_neg.Value         = 0;
            tw_up_neg.ValueChanged += delegate { img_up_neg.style.Opacity = tw_up_neg.Value; };



            var map = new IHTMLElement(IHTMLElement.HTMLElementEnum.map);

            map.id   = "map1";
            map.name = "map1";

            var area1 = new IHTMLArea
            {
                shape  = ShapeEnum.polygon,
                coords = "477, 178, 515, 144, 557, 160, 576, 194, 614, 181, 629, 206, 648, 209, 659, 163, 719, 154, 730, 103, 845, 118, 891, 168, 949, 213, 917, 246, 931, 266, 859, 300, 787, 302, 756, 274, 721, 294, 658, 282, 615, 257, 537, 239, 492, 230, 470, 195"
            };

            area1.onmouseover += i =>
            {
                System.Console.WriteLine("over");
                tw_up_neg.Value = 1;                          /*tw_down.Value = 0.2;*/
            };
            area1.onmouseout += i =>
            {
                try
                {
                    System.Console.WriteLine("out");
                    tw_up_neg.Value = 0;                        /* tw_down.Value = 1;*/
                }
                catch
                {
                }
            };


            var area2 = new IHTMLArea
            {
                shape  = ShapeEnum.polygon,
                coords = "677, 556, 718, 551, 747, 570, 758, 594, 756, 613, 729, 625, 688, 629, 663, 604, 657, 585"
            };



            area2.onmouseover += i =>
            {
                System.Console.WriteLine("over");
                tw_up.Value = 1;                          /*tw_down.Value = 0.2;*/
            };
            area2.onmouseout += i =>
            {
                try
                {
                    System.Console.WriteLine("out");
                    tw_up.Value = 0;                        /* tw_down.Value = 1;*/
                }
                catch
                {
                }
            };

            img_down.onclick += i => System.Console.WriteLine(i.CursorPosition);

            //area1.href = "http://google.com";
            //area1.target = "_blank";

            map.appendChild(area1);
            map.appendChild(area2);

            map.AttachToDocument();


            img_down.style.zIndex = 2;
            img_down.setAttribute("useMap", "#map1");


            //img_overlay.style.backgroundColor = Color.Red;
        }
示例#11
0
        //async Task __buttryfly()
        //{ 
        //    //Task.Factory.
        //}

        //async 
        void Spawn(IHTMLElement e)
        {


            Native.Document.body.style.margin = "0px";
            Native.Document.body.style.padding = "0px";
            Native.Document.body.style.overflow = IStyle.OverflowEnum.hidden;

            e.style.position = IStyle.PositionEnum.absolute;
            e.style.left = "0px";
            e.style.top = "0px";
            e.style.right = "0px";
            e.style.bottom = "0px";

            e.style.backgroundColor = Color.FromRGB(209, 245, 245);

            IHTMLElement loading = new IHTMLElement(IHTMLElement.HTMLElementEnum.code, "loading...");

            loading.style.SetLocation(64, 64, 200, 64);

            e.appendChild(loading);

            //await __buttryfly();

            new global::ButterFly.HTML.Images.FromAssets.buttryfly().InvokeOnComplete(
                img =>
                {
                    loading.FadeOut();

                    try
                    {
                        //IStyleSheet.Default.AddRule("*", "cursor: none, url('" + new global::ButterFly.HTML.Images.FromAssets.nocursor().src + "'), auto;", 0);
                        IStyleSheet.Default.AddRule("*", "cursor: none;", 0);
                    }
                    catch (Exception exc)
                    {
                        new IHTMLElement(IHTMLElement.HTMLElementEnum.pre, exc.Message).AttachToDocument();
                    }


                    e.style.backgroundImage = "url(" + img.src + ")";
                    e.style.backgroundRepeat = "no-repeat";



                    e.DisableContextMenu();


                    var x = 0;
                    var y = 0;

                    Action update =
                        delegate
                        {
                            e.style.backgroundPosition = x + "px " + y + "px";
                        };

                    e.onmousemove +=
                        delegate(IEvent i)
                        {


                            #region where is the cursor?
                            if (Native.Document.pointerLockElement == e)
                            {
                                x += i.movementX;
                                y += i.movementY;
                            }
                            else
                            {
                                x = i.CursorX;
                                y = i.CursorY;
                            }

                            if (x < -img.width / 2)
                                x += Native.window.Width;

                            if (y < -img.height / 2)
                                y += Native.window.Height;

                            x = x % Native.window.Width;
                            y = y % Native.window.Height;
                            #endregion


                            update();

                        };

                    e.onclick +=
                        delegate
                        {
                            e.requestPointerLock();
                        };
                });

        }
示例#12
0
        public static T AttachToContainer <T>(this T e, IHTMLElement c) where T : global::System.Windows.Controls.Panel
        {
            c.appendChild(e.ToHTMLElement());

            return(e);
        }
示例#13
0
        //async Task __buttryfly()
        //{
        //    //Task.Factory.
        //}

        //async
        void Spawn(IHTMLElement e)
        {
            Native.Document.body.style.margin   = "0px";
            Native.Document.body.style.padding  = "0px";
            Native.Document.body.style.overflow = IStyle.OverflowEnum.hidden;

            e.style.position = IStyle.PositionEnum.absolute;
            e.style.left     = "0px";
            e.style.top      = "0px";
            e.style.right    = "0px";
            e.style.bottom   = "0px";

            e.style.backgroundColor = Color.FromRGB(209, 245, 245);

            IHTMLElement loading = new IHTMLElement(IHTMLElement.HTMLElementEnum.code, "loading...");

            loading.style.SetLocation(64, 64, 200, 64);

            e.appendChild(loading);

            //await __buttryfly();

            new global::ButterFly.HTML.Images.FromAssets.buttryfly().InvokeOnComplete(
                img =>
            {
                loading.FadeOut();

                try
                {
                    //IStyleSheet.Default.AddRule("*", "cursor: none, url('" + new global::ButterFly.HTML.Images.FromAssets.nocursor().src + "'), auto;", 0);
                    IStyleSheet.Default.AddRule("*", "cursor: none;", 0);
                }
                catch (Exception exc)
                {
                    new IHTMLElement(IHTMLElement.HTMLElementEnum.pre, exc.Message).AttachToDocument();
                }


                e.style.backgroundImage  = "url(" + img.src + ")";
                e.style.backgroundRepeat = "no-repeat";



                e.DisableContextMenu();


                var x = 0;
                var y = 0;

                Action update =
                    delegate
                {
                    e.style.backgroundPosition = x + "px " + y + "px";
                };

                e.onmousemove +=
                    delegate(IEvent i)
                {
                    #region where is the cursor?
                    if (Native.Document.pointerLockElement == e)
                    {
                        x += i.movementX;
                        y += i.movementY;
                    }
                    else
                    {
                        x = i.CursorX;
                        y = i.CursorY;
                    }

                    if (x < -img.width / 2)
                    {
                        x += Native.window.Width;
                    }

                    if (y < -img.height / 2)
                    {
                        y += Native.window.Height;
                    }

                    x = x % Native.window.Width;
                    y = y % Native.window.Height;
                    #endregion


                    update();
                };

                e.onclick +=
                    delegate
                {
                    e.requestPointerLock();
                };
            });
        }
示例#14
0
        public static void GenerateView(string[] lines)
        {
            string Status = "";

            var c      = new IHTMLElement(IHTMLElement.HTMLElementEnum.center, "");
            var cursor = Native.Document.createElement("blink");

            cursor.innerText = "_";

            var index      = 0;
            var index_char = 0;

            var span = new IHTMLSpan();

            var delay_delayed = false;

            Status = "creating actions";
            var Delay = default(System.Action <System.Action, int>);

            Delay = (h, due) => new Timer(

                delegate
            {
                if (delay_delayed)
                {
                    Delay(h, due);
                }
                else
                {
                    h();
                }
            }, due, 0);

            System.Func <string> CurrentLineString = () => (1 + index) + ". " + lines[index].Trim();

            var DeleteChar = default(System.Action);
            var PrintChar  = default(System.Action);
            var ChooseLine = default(System.Action);

            DeleteChar =
                () =>
            {
                index_char--;

                span.innerText = CurrentLineString().Substring(0, index_char);

                if (index_char == 0)
                {
                    ChooseLine();
                }
                else
                {
                    Delay(DeleteChar, 30);
                }
            };

            PrintChar =
                () =>
            {
                index_char++;

                if (index_char < CurrentLineString().Length)
                {
                    var x = 100;
                    var y = CurrentLineString()[index_char];


                    if (",. \t\n".Contains("" + y))
                    {
                        x = 200;
                    }


                    if (index_char > 1)
                    {
                        span.style.color = Color.None;
                    }

                    span.innerText = CurrentLineString().Substring(0, index_char);
                    Delay(PrintChar, x);
                }
                else
                {
                    Delay(DeleteChar, 3000);
                }
            };

            ChooseLine =
                () =>
            {
                index            = new System.Random().Next() % lines.Length;
                index_char       = 0;
                span.innerText   = "";
                span.style.color = Color.White;

                PrintChar();
            };

            Status = "adding to document";

            c.onmouseover +=
                delegate
            {
                c.style.color = Color.Yellow;
                delay_delayed = true;
            };

            c.onmouseout +=
                delegate
            {
                c.style.color = Color.None;
                delay_delayed = false;
            };


            c.appendChild(span, cursor);
            c.AttachToDocument();

            ChooseLine();
        }
示例#15
0
        public Application(IApp page)
        {
            __that = this;

            this.yield = message =>
            {
                Native.window.alert("hello! " + new { message });
            };


            //((IHTMLElement)Native.document.body.parentNode).style.borderTop = "1em yellow yellow";

            //IStyleSheet.Default["html"].style.borderTop = "1em yellow yellow";


            IStyleSheet.Default["body"].style.borderLeft = "0em yellow solid";

            // activate all animations?
            IStyleSheet.Default["body"].style.transition = "border-left 300ms linear";
            IStyleSheet.Default["body"].style.borderLeft = "3em yellow solid";

            new IHTMLDiv
            {
                innerHTML = @"
<style>
html {
    transition: border-top 500ms linear;
    border-top: 4em solid cyan;
}

</style>"
            }.With(
           async div =>
           {
               //await Native.window.requestAnimationFrameAsync;

               // wont work for html?
               await Task.Delay(100);

               div.AttachToDocument();
           }
       );

            #region proof we can still find our element by id even if on a sub page
            new IHTMLTextArea { }.AttachTo(Native.document.body.parentNode).With(
                async area =>
                {
                    area.style.position = IStyle.PositionEnum.absolute;
                    area.style.right = "1em";
                    area.style.bottom = "1em";
                    area.style.zIndex = 1000;
                    area.readOnly = true;


                    Action colors = async delegate
                    {
                        for (int i = 0; i < 3; i++)
                        {

                            area.style.backgroundColor = "red";
                            await Task.Delay(200);
                            area.style.backgroundColor = "yellow";
                            await Task.Delay(200);
                        }
                        await Native.window.requestAnimationFrameAsync;
                        area.style.transition = "background-color 10000ms linear";

                        await Native.window.requestAnimationFrameAsync;

                        area.style.backgroundColor = "white";
                    };


                    colors();




                    var st = new Stopwatch();
                    st.Start();

                    while (true)
                    {
                        // proof we can still find our element by id even if on a sub page
                        area.value = page.message.innerText + "\n" + st.ToString();

                        await Task.Delay(500);
                    }
                }
            );
            #endregion





            //page.Location = Native.document.location.hash;

            // #/OtherPage.htm

            Console.WriteLine(new { Native.document.location.pathname });


            #region GoThirdPage
            Action GoThirdPage = delegate
            {
                //IStyleSheet.Default["body"].style.borderLeft = "0em yellow solid";

                //await Task.Delay(300);

                // Console.WriteLine("pushState");
                // Native.window.history.pushState(
                //    null,
                //    null,
                //     //"/thirdpage.htm"
                //    "/third-page"
                //);

                Console.WriteLine("replaceState");
                Native.window.history.pushState(
                    //"/third-page",
                    new { },
                    "/third-page",
                    async scope =>
                    {
                        // did the server prerender our page?
                        Console.WriteLine("at replaceState");

                        var xtitle = Native.document.title;

                        // { nodeName = #text } 
                        var hidden = (IHTMLElement)Native.document.body.querySelectorAll("hidden-body").FirstOrDefault();
                        Console.WriteLine("replaceState " + new { hidden });
                        var layout = default(IThirdPage);

                        if (hidden == null)
                        {
                            hidden = new IHTMLElement("hidden-body");
                            hidden.style.display = IStyle.DisplayEnum.none;

                            layout = new ThirdPage();
                            Native.document.title = layout.title.innerText;

                            var page_body = Native.document.body;

                            layout.body.appendChild(hidden);
                            page_body.parentNode.replaceChild(layout.body, page_body);

                            // we can also keep it memory
                            hidden.appendChild(page_body);
                        }
                        else
                        {
                            //{ nodeName = YDOB } 
                            var page_ydob = (IElement)hidden.querySelectorAll("ydob").FirstOrDefault();
                            if (page_ydob != null)
                            {
                                // chrome will skip body. have to repair on the client

                                var page_body = new IHTMLBody();

                                page_ydob.attributes.ToArray().WithEach(a => { page_ydob.removeAttribute(a.name); page_body.setAttribute(a.name, a.value); });
                                page_ydob.childNodes.ToArray().WithEach(a => { page_ydob.removeChild(a); page_body.appendChild(a); });

                                hidden.replaceChild(page_body, page_ydob);

                            }

                            layout = new ThirdPage.FromDocument();
                        }

                        // ready!

                        // one wait works half time only
                        //await Native.window.requestAnimationFrameAsync;
                        //await Native.window.requestAnimationFrameAsync;

                        //await Task.Delay(11);

                        var xthat = __that;
                        __that = null;
                        var x = new ThirdPageApplication(
                            layout,
                            xthat,
                            "pushState"
                        );

                        await scope;
                        __that = xthat;
                        Console.WriteLine("restore state!"); ;
                        Native.document.title = xtitle;

                        //Native.document.body.parentNode.replaceChild(hidden.querySelectorAll("body")[0], Native.document.body);
                        Native.document.body.parentNode.replaceChild(hidden.querySelectorAll("body").First(), Native.document.body);
                    }
                );
            };
            #endregion



            page.GoThirdPageViaCode.WhenClicked(
                  async button =>
                {
                    GoThirdPage();
                }
            );

            page.GoThirdPageViaLocation.WhenClicked(
                  async button =>
                  {
                      Native.document.location.href = "/third-page";
                  }
              );

            //if (Native.document.location.hash.StartsWith("#/"))
            //{
            //    Native.window.history.replaceState(
            //        new { foo = 1 },
            //        "",
            //        Native.document.location.hash.Substring(1)
            //    );

            //    //Native.window.history.replaceState(
            //    //    new { foo = 1 },
            //    //    scope =>
            //    //    {
            //    //        Native.document.body.style.backgroundColor = "yellow";
            //    //    }
            //    //);
            //}


            #region /third-page
            new[] { "ThirdPage.htm", "third-page" }.WithEach(
                async uri =>
                {
                    await Native.window.requestAnimationFrameAsync;

                    var selector = "a[href='" + uri + "']";


                    IStyleSheet.Default[selector].style.color = "red";


                    Native.document.body.querySelectorAll(IHTMLAnchor.HTMLElementEnum.a).WithEach(
                        xx =>
                        {
                            var x = (IHTMLAnchor)xx;


                            if (Native.document.location.href + uri != x.href)
                                return;

                            //Console.WriteLine(new { a = x.href, uri, Native.document.location.href });
                            // { a = http://192.168.43.252:13445/ThirdPage.htm, uri = ThirdPage.htm, href = http://192.168.43.252:13445/ } 

                            x.onclick +=
                                e =>
                                {
                                    e.preventDefault();
                                    GoThirdPage();
                                };
                        }
                    );

                    if (__that != null)
                        if (Native.document.location.pathname == "/" + uri)
                        {
                            //Native.window.history.replaceState(
                            //     null,
                            //     null,
                            //    //"/thirdpage.htm"
                            //    "/ThirdPage.htm"
                            //    //"/third-page"
                            // );


                            var layout = new ThirdPage.FromDocument();

                            new ThirdPageApplication(layout, __that, ".ctor");
                        }
                }
            );
            #endregion





            #region GoSearchPage
            Action GoSearchPage = delegate
            {
                //IStyleSheet.Default["body"].style.borderLeft = "0em yellow solid";

                //await Task.Delay(300);

                // Console.WriteLine("pushState");
                // Native.window.history.pushState(
                //    null,
                //    null,
                //     //"/thirdpage.htm"
                //    "/third-page"
                //);

                Console.WriteLine("replaceState");
                Native.window.history.pushState(
                    //"/third-page",
                    new { },
                    "/s",
                    async scope =>
                    {
                        // did the server prerender our page?
                        Console.WriteLine("at replaceState");

                        var xtitle = Native.document.title;

                        // { nodeName = #text } 
                        var hidden = (IHTMLElement)Native.document.body.querySelectorAll("hidden-body").FirstOrDefault();
                        Console.WriteLine("replaceState " + new { hidden });
                        var layout = default(ISearchPage);

                        if (hidden == null)
                        {
                            hidden = new IHTMLElement("hidden-body");
                            hidden.style.display = IStyle.DisplayEnum.none;

                            layout = new SearchPage();
                            Native.document.title = layout.title.innerText;

                            var page_body = Native.document.body;

                            layout.body.appendChild(hidden);
                            page_body.parentNode.replaceChild(layout.body, page_body);

                            // we can also keep it memory
                            hidden.appendChild(page_body);
                        }
                        else
                        {
                            //{ nodeName = YDOB } 
                            var page_ydob = (IElement)hidden.querySelectorAll("ydob").FirstOrDefault();
                            if (page_ydob != null)
                            {
                                // chrome will skip body. have to repair on the client

                                var page_body = new IHTMLBody();

                                page_ydob.attributes.ToArray().WithEach(a => { page_ydob.removeAttribute(a.name); page_body.setAttribute(a.name, a.value); });
                                page_ydob.childNodes.ToArray().WithEach(a => { page_ydob.removeChild(a); page_body.appendChild(a); });

                                hidden.replaceChild(page_body, page_ydob);

                            }

                            layout = new SearchPage.FromDocument();
                        }

                        // ready!

                        // one wait works half time only
                        //await Native.window.requestAnimationFrameAsync;
                        //await Native.window.requestAnimationFrameAsync;

                        //await Task.Delay(11);

                        var xthat = __that;
                        __that = null;
                        var x = new SearchPageApplication(
                            layout,
                            xthat
                        );

                        await scope;
                        __that = xthat;
                        Console.WriteLine("restore state!"); ;
                        Native.document.title = xtitle;
                        //Native.document.body.parentNode.replaceChild(hidden.querySelectorAll("body")[0], Native.document.body);
                        Native.document.body.parentNode.replaceChild(hidden.querySelectorAll("body").First(), Native.document.body);
                    }
                );
            };
            #endregion


            #region /s
            new[] { "SearchPage.htm", "s" }.WithEach(
              async uri =>
              {
                  await Native.window.requestAnimationFrameAsync;

                  var selector = "a[href='" + uri + "']";


                  IStyleSheet.Default[selector].style.color = "orange";

                  Native.document.body.querySelectorAll(IHTMLAnchor.HTMLElementEnum.a).WithEach(
                        xx =>
                        {
                            var x = (IHTMLAnchor)xx;


                            if (Native.document.location.href + uri != x.href)
                                return;

                            x.style.borderBottom = "1px dashed blue";

                            x.onclick +=
                                e =>
                                {
                                    e.preventDefault();
                                    GoSearchPage();
                                };
                        }
                  );

                  if (__that != null)
                      if (Native.document.location.pathname == "/" + uri)
                      {
                          var layout = new SearchPage.FromDocument();

                          new SearchPageApplication(layout, this);
                      }
              }
          );
            #endregion

        }
        /// <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();

        }
示例#17
0
        /// <summary>
        /// Creates a new control
        /// </summary>
        /// <param name="DataElement">The hidden data element</param>
        public ImageZoomer()
        {
            var Control = new IHTMLElement(IHTMLElement.HTMLElementEnum.center);

            Control.AttachToDocument();

            Control.appendChild( new IHTMLDiv("A simple image zoomer example") );
            Control.appendChild(new IHTMLAnchor("http://valid.tjp.hu/tjpzoom/", "based on tjpZoom"));
            Control.appendChild(new IHTMLElement(IHTMLElement.HTMLElementEnum.p, "Use your mouse wheel to zoom!"));
            Control.appendChild(new IHTMLElement(IHTMLElement.HTMLElementEnum.hr));

            System.Action<string, string> Spawn =
                (src, zoom_src) =>
                {
                    var i = new IHTMLImage(src);

                    i.style.margin = "2px";

                    Control.appendChild(i);

                    // note: image should be loeaded before attaching events on it!


                    i.InvokeOnComplete(
                        (img) => MyMagnifier.CreateClickableMagnifier(i, zoom_src)
                    );
                };

            System.Action<string, string> SpawnFreezable =
                (src, zoom_src) =>
                {
                    var i = new IHTMLImage(src);

                    i.style.margin = "2px";

                    Control.appendChild(i);

                    i.InvokeOnComplete(
                        (img) => MyMagnifier.CreateFreezableMagnifier(i, zoom_src)
                    );
                };

            Control.appendChild(new IHTMLElement(IHTMLElement.HTMLElementEnum.p, "Click to disable or re-enable the magnifier!"));
            new[] {
                "assets/ImageZoomer/boat.jpg",
                "assets/ImageZoomer/boat2.jpg",
                "assets/ImageZoomer/tea.jpg",
                "assets/ImageZoomer/town.jpg",
            }.ForEach( src => Spawn(src, src) );

            Control.appendChild(new IHTMLElement(IHTMLElement.HTMLElementEnum.p, "Click to freeze the magnifier!"));

            SpawnFreezable("assets/ImageZoomer/belchite_bw.jpg", "assets/ImageZoomer/belchite.jpg");
            SpawnFreezable("assets/ImageZoomer/belchite.jpg", "assets/ImageZoomer/belchite_bw_neg.jpg");
            
        }
        //public const string Alias = "Class1";
        //public const string DefaultData = "Class1Data";

        /// <summary>
        /// Creates a new control
        /// </summary>
        /// <param name="DataElement">The hidden data element</param>
        public GoogleGearsSimple()
        {
            // this ctor creates a new div which has a text and a button element
            // on mouseover over the color text is changed
            // on pressing the button the next message in text element is displayed
            IHTMLDiv Control = new IHTMLDiv();

            Control.AttachToDocument();

            Func<string, string, IHTMLElement> link = (href, text) => new IHTMLDiv(new IHTMLAnchor(href, text));


            Control.appendChild(link("http://gears.google.com/", "Google Gears"));
            Control.appendChild(link("http://code.google.com/apis/gears/samples/hello_world_database.html", "Google Example # 1"));

            Control.appendChild(new IHTMLElement(IHTMLElement.HTMLElementEnum.h3, "This page uses Google Gears to record your entries on the local disk. If you navigate away and revisit this page, all your data will still be here. Try it!"));

            // http://code.google.com/apis/gears/samples/hello_world_database.html

            GoogleGearsFactory.Database db = null;

            try
            {
                db = new GoogleGearsFactory.Database();
            }
            catch (Exception exc)
            {
                var err = new IHTMLCode(exc.Message);

                err.style.color = Color.Red;


                Control.appendChild(err);
            }

            IStyleSheet.Default.AddRule(".odd").style.backgroundColor = Color.FromGray(0xa0);
            IStyleSheet.Default.AddRule(".even").style.backgroundColor = Color.FromGray(0xef);

            if (db != null)
            {
                db.open("demo1");
                db.execute(@"
    create table if not exists Demo
    (Phrase varchar(255), Timestamp int)
            ");

                var textfield = new IHTMLInput(HTMLInputTypeEnum.text, "text1", "");

                var btnadd = new IHTMLButton("Add new entry");
                var btnrefresh = new IHTMLButton("Refresh");
                var btnclear = new IHTMLButton("Clear");

                Control.appendChild(textfield, btnadd, btnclear, btnrefresh,
                    
                    new IHTMLCode(GoogleGearsFactory.Default.getBuildInfo())
                        
                        );



                var list = new IHTMLElement(IHTMLElement.HTMLElementEnum.ol);

                Control.appendChild(list);

                var read = default(Action);

                read = delegate
                {
                    //from i in Demo
                    //select new { Phrase, Timestamp }
                    //order by Timestamp desc

                    list.removeChildren();

                    Func<string, IHTMLElement> AddItem = 
                        text => new IHTMLElement(IHTMLElement.HTMLElementEnum.li, text).Aggregate(v => list.appendChild(v));



                    // this could be rewritten as an expression once they are supported by jsc

                    int counter = 0;

                    var query = from Data in db.AsEnumerable<DemoDataEntity>(
                                                "select * from Demo order by Timestamp desc",
                                                typeof(DemoDataEntity)
                                            )
                                // let ListItem = AddItem(Data.Timestamp + " - " + Data.Phrase)
                                select new __Type2 { ListItem = AddItem(Data.Timestamp + " - " + Data.Phrase), Data  = Data};

                    foreach (var v in query)
                    {
                        counter++;
                        var vx = v;


                        if (counter % 2 == 0)
                            v.ListItem.className = "odd";
                        else
                            v.ListItem.className = "even";

                        #region -
                        var btndel = new IHTMLButton("-");

                        btndel.style.color = Color.Red;

                        btndel.onclick +=
                            delegate
                            {
                                db.execute("delete from Demo where Timestamp = ?", vx.Data.Timestamp);

                                read();
                            };
                        #endregion

                        #region +
                        var btnclone = new IHTMLButton("+");

                        btnclone.style.color = Color.Blue;

                        btnclone.onclick +=
                            delegate
                            {
                                db.Insert("Demo", vx.Data);


                                read();
                            };
                        #endregion

                        v.ListItem.insertBefore(btnclone, v.ListItem.firstChild);
                        v.ListItem.insertBefore(btndel, v.ListItem.firstChild);

                    }


                    #region raw
                    //var rs = db.execute("select * from Demo order by Timestamp desc");

                    //while (rs.isValidRow())
                    //{
                    //    var xt = typeof(DemoDataEntity);
                    //    var xx = (DemoDataEntity)Activator.CreateInstance(xt);

                    //    for (int i = 0; i < rs.fieldCount(); i++)
                    //    {
                    //        xt.GetField(rs.fieldName(i)).SetValue(xx, rs.field(i));
                    //    }

                    //    AddItem(xx.Timestamp + " - " + xx.Phrase);

                    //    rs.next();
                    //}

                    //rs.close();
                    #endregion

                };

                btnclear.onclick +=
                    delegate
                    {
                        db.execute("delete from Demo");

                        read();
                    };

                btnadd.onclick +=
                    delegate
                    {
                        db.Insert("Demo",
                            new DemoDataEntity
                            {
                                Phrase = textfield.value,
                                Timestamp = IDate.Now.getTime()
                            }
                        );

                        //db.execute("insert into Demo (Phrase, Timestamp) values (?, ?)", textfield.value, IDate.Now.getTime());

                        textfield.value = "";

                        read();
                    };

                btnrefresh.onclick +=
                    delegate
                    {
                        read();
                    };

                read();

            }


            // not array
            // is object
            // no prototype
        }
示例#19
0
        /// <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 GuessingGame(IHTMLElement e)
        {
            // 
            e.innerHTML = @"<h1>
                Try to guess a 5-figure integer 
                </h1>
                ";

            e.appendChild(HintControl, StatusControl, NumberBar);

            
            StatusControl.style.color = Color.Blue;
            
            Control = e;

            ResetButton.onclick +=
                delegate
                {
                    new GuessingGame(Control);
                };

            MyGame.Changed +=
                delegate
                {
                    HintControl.innerHTML = "<h2>You have guessed " + MyGame.GuessedValues.length + " times";



                    StatusControl.innerHTML = MyGame.MaskedValue;

                    if (MyGame.Done)
                    {
                        NumberBar.FadeOut();

                        StatusControl.innerHTML += "<hr /> game over";
              
                        Control.appendChild(ResetButton);
                    }
                };

            MyGame.RaiseChanged();

            for (int i = 0; i < 10; i++)
            {
                IHTMLButton btn = new IHTMLButton(i + "");

                int ux = i;

                btn.onclick +=
                    delegate
                    {
                        MyGame.Guessed(ux);

                        btn.FadeOut();
                    };

                NumberBar.appendChild(btn);
            }


            Style.textAlign = IStyle.TextAlignEnum.center;
            Style.backgroundColor = Color.System.ButtonFace;
            Style.borderColor = Color.Gray;
            Style.borderWidth = "1px";
            Style.borderStyle = "dotted";
            Style.padding = "8px";
        }
示例#21
0
        public GuessingGame(IHTMLElement e)
        {
            //
            e.innerHTML = @"<h1>
                Try to guess a 5-figure integer 
                </h1>
                ";

            e.appendChild(HintControl, StatusControl, NumberBar);


            StatusControl.style.color = Color.Blue;

            Control = e;

            ResetButton.onclick +=
                delegate
            {
                new GuessingGame(Control);
            };

            MyGame.Changed +=
                delegate
            {
                HintControl.innerHTML = "<h2>You have guessed " + MyGame.GuessedValues.length + " times";



                StatusControl.innerHTML = MyGame.MaskedValue;

                if (MyGame.Done)
                {
                    NumberBar.FadeOut();

                    StatusControl.innerHTML += "<hr /> game over";

                    Control.appendChild(ResetButton);
                }
            };

            MyGame.RaiseChanged();

            for (int i = 0; i < 10; i++)
            {
                IHTMLButton btn = new IHTMLButton(i + "");

                int ux = i;

                btn.onclick +=
                    delegate
                {
                    MyGame.Guessed(ux);

                    btn.FadeOut();
                };

                NumberBar.appendChild(btn);
            }


            Style.textAlign       = IStyle.TextAlignEnum.center;
            Style.backgroundColor = Color.System.ButtonFace;
            Style.borderColor     = Color.Gray;
            Style.borderWidth     = "1px";
            Style.borderStyle     = "dotted";
            Style.padding         = "8px";
        }