Exemplo n.º 1
0
        public UltraApplication(IHTMLElement e)
        {
            var Title = new IHTMLDiv
            {
            };

            new Browsers
            {
            }.Container.AttachTo(Title);

            new HTML.Images.FromBase64.twitter_small().AttachToDocument();
            new HTML.Images.FromBase64._troll__by_GirlFlash().AttachToDocument();

            var TitleLogo = new IHTMLImage("assets/ScriptCoreLib/jsc.png");
            var TitleText = new IHTMLSpan("UltraApplication");

            TitleText.style.fontFamily    = ScriptCoreLib.JavaScript.DOM.IStyle.FontFamilyEnum.Verdana;
            TitleText.style.paddingLeft   = "2em";
            TitleText.style.fontSize      = "xx-large";
            TitleLogo.style.verticalAlign = "middle";


            Title.appendChild(TitleLogo);
            Title.appendChild(TitleText);

            Title.style.height = "128px";

            Title.AttachToDocument();
            Title.FadeIn(2500, 1000,
                         delegate
            {
                1500.AtDelay(ContinueBuildingApplication);
            }
                         );
        }
        public void DrawTextToInfo(string text, Point p, Color c)
        {
            var box = new IHTMLSpan(text);

            box.style.SetLocation(p.X, p.Y);
            box.style.color = c;

            this.Layers.Info.appendChild(box);
        }
Exemplo n.º 3
0
        private static TreeNode ApplyLocalName(TreeNode t, XElement cc)
        {
            t.IsExpanded = true;
            t.Element.TextArea.Clear();
            var c = new IHTMLCode();

            t.Element.TextArea.Add(c);

            t.Element.ButtonArea.Hide();
            t.Element.IconArea.Hide();

            Action <string, JSColor> Write =
                (Text, Color) =>
            {
                var cs = new IHTMLSpan {
                    innerText = Text
                };

                cs.style.color = Color;

                cs.AttachTo(c);
            };

            Write("<", JSColor.Blue);
            Write(cc.Name.LocalName, JSColor.FromRGB(0xa0, 0, 0));

            foreach (var item in cc.Attributes().ToArray())
            {
                Write(" ", JSColor.None);

                Write("foo", JSColor.Red);
                Write("='", JSColor.Blue);
                Write(item.Value, JSColor.Blue);
                Write("'", JSColor.Blue);
            }

            if (!cc.Elements().Any())
            {
                Write(">", JSColor.Blue);

                Write(cc.Value, JSColor.None);

                Write("</", JSColor.Blue);
                Write(cc.Name.LocalName, JSColor.FromRGB(0xa0, 0, 0));
                Write(">", JSColor.Blue);
            }
            else
            {
                Write("/>", JSColor.Blue);
            }

            return(t);
        }
Exemplo n.º 4
0
        public void Add <TResult>(Task <TResult> e)
        {
            // x:\jsc.svn\examples\javascript\xml\xclickcounter\xclickcounter\application.cs

            // X:\jsc.svn\examples\javascript\LINQ\ClickCounter\ClickCounter\Application.cs

            // what about implicit operators for other elements?
            // X:\jsc.svn\examples\javascript\async\AsyncHistoricActivities\AsyncHistoricActivities\Application.cs

            // Implementing Collection Initializers
            // http://msdn.microsoft.com/en-us/library/bb384062.aspx

            //var text = new ITextNode("");
            var text = new IHTMLSpan("");

            this.appendChild(text);



            var sw = Stopwatch.StartNew();

            e.ContinueWith(
                x =>
            {
                var xx = (__Task <object>)x;

                var Result = xx.Result;

                // if its xml would we want to do something special?

                var y = System.Convert.ToString(
                    xx.Result
                    );

                //TotalElapsedMilliseconds += sw.ElapsedMilliseconds;
                //text.title = new { TotalElapsedMilliseconds, sw.ElapsedMilliseconds }.ToString();


                if (y != text.innerText)
                {
                    text.innerText = y;
                }
            }
                );
        }
Exemplo n.º 5
0
            public GameOverMenu()
            {
                Func <string, Color, IHTMLSpan> GetText2 =
                    delegate(string text, Color color)
                {
                    var s = new IHTMLSpan(text);
                    s.style.color = color;
                    return(s);
                };

                Func <string, Color, string, IHTMLSpan> GetText =
                    delegate(string text, Color color, string size)
                {
                    var s = GetText2(text, color);

                    s.style.fontSize = size;

                    return(s);
                };

                Control.appendChild(GetText("GAME OVER", Color.Green, "44px"));
            }
Exemplo n.º 6
0
        public UltraApplication(IHTMLElement e)
        {
            var Title = new IHTMLDiv
            {
                innerHTML = @"
<img border='0' src='http://www.w3schools.com/images/compatible_ie.gif' width='31' height='30' alt='Internet Explorer' title='Internet Explorer' />
<img border='0' src='http://www.w3schools.com/images/compatible_firefox.gif' width='31' height='30' alt='Firefox' title='Firefox' />
<img border='0' src='http://www.w3schools.com/images/compatible_opera.gif' width='28' height='30' alt='Opera' title='Opera' />
<img border='0' src='http://www.w3schools.com/images/compatible_chrome.gif' width='31' height='30' alt='Google Chrome' title='Google Chrome' />
<img border='0' src='http://www.w3schools.com/images/compatible_safari.gif' width='28' height='30' alt='Safari' title='Safari' />
"
            };


            var TitleLogo = new IHTMLImage("assets/ScriptCoreLib/jsc.png");
            var TitleText = new IHTMLSpan("UltraApplication");

            TitleText.style.fontFamily    = ScriptCoreLib.JavaScript.DOM.IStyle.FontFamilyEnum.Verdana;
            TitleText.style.paddingLeft   = "2em";
            TitleText.style.fontSize      = "xx-large";
            TitleLogo.style.verticalAlign = "middle";


            Title.appendChild(TitleLogo);
            Title.appendChild(TitleText);

            Title.style.height = "128px";

            Title.AttachToDocument();
            Title.FadeIn(2500, 1000,
                         delegate
            {
                1500.AtDelay(ContinueBuildingApplication);
            }
                         );
        }
Exemplo n.º 7
0
        public void Add(Task <XElement> e)
        {
            // x:\jsc.svn\examples\javascript\xml\xclickcounter\xclickcounter\application.cs
            // placeholder.
            var text = new IHTMLSpan("");

            this.appendChild(text);


            e.ContinueWith(
                x =>
            {
                var Result = x.Result.AsHTMLElement();



                // DOM rewrite in process. is the caller trusted? is data trusted?
                this.replaceChild(
                    Result,
                    text
                    );
            }
                );
        }
Exemplo n.º 8
0
        public void Add(System.Func <Task <XElement> > e)
        {
            // X:\jsc.svn\examples\javascript\LINQ\ClickCounter\ClickCounter\Application.cs

            // what about implicit operators for other elements?
            // X:\jsc.svn\examples\javascript\async\AsyncHistoricActivities\AsyncHistoricActivities\Application.cs

            // Implementing Collection Initializers
            // http://msdn.microsoft.com/en-us/library/bb384062.aspx

            //var text = new ITextNode("");
            INode text = new IHTMLSpan("");

            this.appendChild(text);

            var TotalElapsedMilliseconds = 0L;

            new Timer(
                t =>
            {
                if (text.parentNode == null)
                {
                    System.Console.WriteLine("INode.Add timer stopped");
                    t.Stop();
                    return;
                }

                t.Enabled = false;

                var sw = Stopwatch.StartNew();

                e().ContinueWith(
                    x =>
                {
                    var Result = x.Result.AsHTMLElement();

                    // what if there is no data?
                    if (Result != null)
                    {
                        // DOM rewrite in process. is the caller trusted? is data trusted?
                        this.replaceChild(
                            Result,
                            text
                            );

                        text = Result;
                    }

                    t.Enabled = true;
                }
                    );


                // how many iterations before we stop the timer?
            },

                // time to attach to DOM
                duetime: 33,
                interval: 1000 / 15
                );
        }
Exemplo n.º 9
0
        private void AddType(IHTMLDiv parent, CompilationType type, Action <string> UpdateLocation)
        {
            var div = new IHTMLDiv().AttachTo(parent);

            div.style.marginTop  = "0.1em";
            div.style.fontFamily = ScriptCoreLib.JavaScript.DOM.IStyle.FontFamilyEnum.Verdana;
            div.style.whiteSpace = ScriptCoreLib.JavaScript.DOM.IStyle.WhiteSpaceEnum.nowrap;


            var i = default(IHTMLImage);

            if (type.IsInterface)
            {
                i = new PublicInterface();
            }
            else
            {
                i = new PublicClass();
            }

            i.AttachTo(div);

            i.style.verticalAlign = "middle";
            i.style.marginRight   = "0.5em";

            var s = new IHTMLAnchor {
                innerText = type.Name, title = "" + type.MetadataToken
            }.AttachTo(div);

            if (!string.IsNullOrEmpty(type.HTMLElement))
            {
                var c = new IHTMLCode();

                Action <string, JSColor> Write =
                    (Text, Color) =>
                {
                    var cs = new IHTMLSpan {
                        innerText = Text
                    };

                    cs.style.color = Color;

                    cs.AttachTo(c);
                };

                Write("<", JSColor.Blue);
                Write(type.HTMLElement, JSColor.FromRGB(0xa0, 0, 0));
                Write("/>", JSColor.Blue);

                //c.style.marginLeft = "1em";
                c.style.Float = ScriptCoreLib.JavaScript.DOM.IStyle.FloatEnum.right;

                c.AttachTo(s);
            }

            s.href = "#";
            s.style.textDecoration = "none";
            s.style.color          = JSColor.System.WindowText;

            Action onclick = delegate
            {
            };

            s.onclick +=
                e =>
            {
                e.PreventDefault();

                s.focus();

                if (TouchTypeSelected != null)
                {
                    TouchTypeSelected(type);
                }

                UpdateLocation(type.FullName + " - " + type.Summary + " - HTML:" + type.HTMLElement);

                onclick();
            };

            s.onfocus +=
                delegate
            {
                s.style.backgroundColor = JSColor.System.Highlight;
                s.style.color           = JSColor.System.HighlightText;
            };

            s.onblur +=
                delegate
            {
                s.style.backgroundColor = JSColor.None;
                s.style.color           = JSColor.System.WindowText;
            };



            onclick =
                delegate
            {
                var children = new IHTMLDiv().AttachTo(div);

                children.style.paddingLeft = "1em";

                Func <IHTMLDiv> Group = () => new IHTMLDiv().AttachTo(children);

                var Groups = new
                {
                    Nested       = Group(),
                    Constructors = Group(),
                    Methods      = Group(),
                    Events       = Group(),
                    Fields       = Group(),
                    Properties   = Group(),
                };


                type.GetNestedTypes().ForEach(
                    (Current, Next) =>
                {
                    AddType(Groups.Nested, Current, UpdateLocation);

                    ScriptCoreLib.Shared.Avalon.Extensions.AvalonSharedExtensions.AtDelay(
                        50,
                        Next
                        );
                }
                    );

                type.GetConstructors().ForEach(
                    (Current, Next) =>
                {
                    AddTypeConstructor(Groups.Constructors, Current, UpdateLocation);

                    ScriptCoreLib.Shared.Avalon.Extensions.AvalonSharedExtensions.AtDelay(
                        50,
                        Next
                        );
                }
                    );

                var HiddenMethods = new List <int>();

                Action <CompilationMethod> AddIfAny =
                    SourceMethod =>
                {
                    if (SourceMethod == null)
                    {
                        return;
                    }

                    HiddenMethods.Add(SourceMethod.MetadataToken);
                };

                Action AfterEvents = delegate
                {
                    type.GetMethods().ForEach(
                        (Current, Next) =>
                    {
                        if (!HiddenMethods.Contains(Current.MetadataToken))
                        {
                            AddTypeMethod(Groups.Methods, Current, UpdateLocation);
                        }

                        ScriptCoreLib.Shared.Avalon.Extensions.AvalonSharedExtensions.AtDelay(
                            50,
                            Next
                            );
                    }
                        );
                };

                Action AfterProperties = delegate
                {
                    type.GetEvents().ForEach(
                        (Current, Next) =>
                    {
                        AddIfAny(Current.GetAddMethod());
                        AddIfAny(Current.GetRemoveMethod());

                        AddTypeEvent(Groups.Events, Current, UpdateLocation);

                        ScriptCoreLib.Shared.Avalon.Extensions.AvalonSharedExtensions.AtDelay(
                            50,
                            Next
                            );
                    }
                        )(AfterEvents);
                };

                type.GetProperties().ForEach(
                    (Current, Next) =>
                {
                    AddIfAny(Current.GetSetMethod());
                    AddIfAny(Current.GetGetMethod());

                    AddTypeProperty(Groups.Properties, Current, UpdateLocation);

                    ScriptCoreLib.Shared.Avalon.Extensions.AvalonSharedExtensions.AtDelay(
                        50,
                        Next
                        );
                }
                    )(AfterProperties);



                type.GetFields().ForEach(
                    (Current, Next) =>
                {
                    AddTypeField(Groups.Fields, Current, UpdateLocation);

                    ScriptCoreLib.Shared.Avalon.Extensions.AvalonSharedExtensions.AtDelay(
                        50,
                        Next
                        );
                }
                    );



                var NextClickHide = default(Action);
                var NextClickShow = default(Action);

                NextClickHide =
                    delegate
                {
                    children.Hide();

                    onclick = NextClickShow;
                };

                NextClickShow =
                    delegate
                {
                    children.Show();

                    onclick = NextClickHide;
                };


                onclick = NextClickHide;
            };
        }
Exemplo n.º 10
0
            public MainMenu(EnemyDirectory MyEnemyDirectory, ImageResources gfx)
            {
                Func <string, Color, IHTMLSpan> GetText2 =
                    delegate(string text, Color color)
                {
                    var s = new IHTMLSpan(text);
                    s.style.color = color;
                    return(s);
                };

                Func <string, Color, string, IHTMLSpan> GetText =
                    delegate(string text, Color color, string size)
                {
                    var s = GetText2(text, color);

                    s.style.fontSize = size;

                    return(s);
                };


                Control.appendChild(
                    new IHTMLDiv(
                        gfx.cenemy.Clone(),
                        GetText("&nbsp;SPACE&nbsp;", Color.White, "48px"),
                        gfx.cenemy.Clone()
                        )
                    );

                Control.appendChild(
                    new IHTMLDiv(
                        gfx.aenemy.Clone(),
                        GetText("&nbsp;INVADERS&nbsp;", Color.Green, "48px"),
                        gfx.aenemy.Clone()
                        )
                    );


                Action DrawBreak =
                    delegate
                {
                    Control.appendChild(new IHTMLBreak());
                };


                DrawBreak();

                Control.appendChild(
                    GetText2("Press&nbsp;", Color.White),
                    GetText2("enter", Color.Green),
                    GetText2("&nbsp;to start game", Color.White)
                    );

                DrawBreak();
                DrawBreak();
                Action <EnemyInfo> DrawEnemyInfo =
                    delegate(EnemyInfo e)
                {
                    Control.appendChild(
                        new IHTMLDiv(
                            e.Image.Clone(),
                            GetText2("&nbsp;- " + e.Points + " points", Color.White)
                            )
                        );
                };

                DrawEnemyInfo(MyEnemyDirectory.A);
                DrawBreak();
                DrawEnemyInfo(MyEnemyDirectory.B);
                DrawBreak();
                DrawEnemyInfo(MyEnemyDirectory.C);
                DrawBreak();
                DrawEnemyInfo(MyEnemyDirectory.UFO);
                DrawBreak();
                DrawBreak();


                Control.appendChild(
                    new IHTMLDiv(
                        GetText2("Left/Right arrow", Color.Green),
                        GetText2(" - move, ", Color.White),
                        GetText2("SPACE", Color.Green),
                        GetText2(" - fire", Color.White)
                        )
                    );

                Control.appendChild(
                    new IHTMLDiv(
                        GetText2("Escape", Color.Green),
                        GetText2(" - quit, ", Color.White),
                        GetText2("'p'", Color.Green),
                        GetText2(" - pause", Color.White)
                        )
                    );

                DrawBreak();
                DrawBreak();


                Control.appendChild(
                    new IHTMLDiv(
                        new IHTMLAnchor("http://zproxy.wordpress.com/2007/03/03/jsc-space-invaders/", "post a comment")
                        ),
                    new IHTMLDiv(
                        new IHTMLAnchor("http://jsc.sourceforge.net", "powered by jsc")
                        )
                    );
            }
Exemplo n.º 11
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();
        }
Exemplo n.º 12
0
        /// <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)
        {
            #region hr
            Action hr = delegate
            {
                //new IHTMLElement(IHTMLElement.HTMLElementEnum.hr).AttachToDocument();
                new IHTMLHorizontalRule().AttachToDocument();
            };
            #endregion


            {
                var x = new IHTMLSpan {
                    "hello world"
                }.AttachToDocument();
            }
            hr();

            {
                var x = new IHTMLSpan {
                    "hello world"
                }.AttachToDocument();


                x.css.before.contentText = "look we are using ::before content string";
            }
            hr();

            {
                var x = new IHTMLSpan {
                    "hello world"
                }.AttachToDocument();

                //x.css.before.contentText = "look we are using ::before content string";
                //x.createShadowRoot(

                x.shadow.appendChild("this is a shadow fragment");
            }
            hr();

            {
                var x = new IHTMLSpan {
                    "hello world"
                }.AttachToDocument();

                // is it visible if there is shadow defined?
                x.css.before.contentText = "[::before content string with shadow] ";

                //x.createShadowRoot(

                x.shadow.appendChild("this is a shadow fragment");
            }
            hr();



            {
                var x = new IHTMLSpan {
                    "hello world"
                }.AttachToDocument();

                // is it visible if there is shadow defined?
                x.css.before.contentText = "[::before content string with shadow] ";

                //x.createShadowRoot(


                // what about multiple shadows?
                x.shadow.appendChild("this is a shadow fragment with content: ");

                // can we style the content ? no
                new IHTMLContent {
                }.AttachTo(x.shadow).style.border = "1px solid red";
            }
            hr();
        }
Exemplo n.º 13
0
        public __ToolStripButton()
        {
            (this.InternalElement.style.display as dynamic).display = "table-cell";

            var InternalElementSpan = new IHTMLSpan().AttachTo(InternalElement);

            //InternalElementSpan.style.verticalAlign = "baseline";

            this.InternalElement.style.font = Control.DefaultFont.ToCssString();


            //this.Font = DefaultFont;

            this.InternalImageChanged +=
                delegate
            {
                if (this.InternalImage == null)
                {
                    return;
                }

                var i = ((__Bitmap)(object)this.InternalImage).InternalImage;

                // https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align
                //i.style.verticalAlign = "baseline";

                this.InternalElement.insertBefore(
                    i,
                    InternalElementSpan
                    );

                if (this.DisplayStyle == ToolStripItemDisplayStyle.Image)
                {
                    i.InvokeOnComplete(
                        delegate
                    {
                        InternalElementSpan.Hide();
                    }
                        );
                }
            };

            this.InternalElement.onclick +=
                delegate
            {
                this.RaiseClick();
            };

            this.TextChanged += delegate
            {
                InternalElementSpan.innerText = this.InternalText;
            };

            this.InternalAfterSetOwner +=
                delegate
            {
                __ToolStrip o = this.Owner;

                // or contaner?
                InternalElement.AttachTo(o.InternalElement);
            };
        }
Exemplo n.º 14
0
        public void Add <TResult>(System.Func <Task <TResult> > e)
        {
            // X:\jsc.svn\examples\javascript\LINQ\ClickCounter\ClickCounter\Application.cs

            // what about implicit operators for other elements?
            // X:\jsc.svn\examples\javascript\async\AsyncHistoricActivities\AsyncHistoricActivities\Application.cs

            // Implementing Collection Initializers
            // http://msdn.microsoft.com/en-us/library/bb384062.aspx

            //var text = new ITextNode("");
            var text = new IHTMLSpan("");

            this.appendChild(text);

            var TotalElapsedMilliseconds = 0L;

            new Timer(
                t =>
            {
                if (text.parentNode == null)
                {
                    System.Console.WriteLine("INode.Add timer stopped");
                    t.Stop();
                    return;
                }

                t.Enabled = false;

                var sw = Stopwatch.StartNew();

                e().ContinueWith(
                    x =>
                {
                    var xx = (__Task <object>)x;

                    var Result = xx.Result;


                    var y = System.Convert.ToString(
                        xx.Result
                        );

                    TotalElapsedMilliseconds += sw.ElapsedMilliseconds;
                    text.title = new { TotalElapsedMilliseconds, sw.ElapsedMilliseconds }.ToString();


                    if (y != text.innerText)
                    {
                        text.innerText = y;
                    }

                    t.Enabled = true;
                }
                    );


                // how many iterations before we stop the timer?
            },

                // time to attach to DOM
                duetime: 33,
                interval: 1000 / 15
                );
        }
Exemplo n.º 15
0
 private void InternalDisableAutoSize()
 {
     this.InternalTextField_ShadowContainer.Orphanize();
     this.InternalTextField_ShadowContainer = null;
     this.InternalTextField_Shadow          = null;
 }
Exemplo n.º 16
0
        // change: C:\util\xampplite\apache\conf\httpd.conf

        // http://localhost/jsc/FlashBrowserDocument/FlashBrowserDocument.htm

        /*
         * Alias /jsc/FlashBrowserDocument "C:\work\jsc.svn\examples\actionscript\FlashBrowserDocument\FlashBrowserDocument\bin\Release\web"
         * <Directory "C:\work\jsc.svn\examples\actionscript\FlashBrowserDocument\FlashBrowserDocument\bin\Release\web">
         *     Options Indexes FollowSymLinks ExecCGI
         *     AllowOverride All
         *     Order allow,deny
         *     Allow from all
         * </Directory>
         */

        /// <summary>
        /// Default constructor
        /// </summary>
        public FlashBrowserDocument()
        {
            ConsoleFormPackageExperience.Initialize();

            Console.WriteLine("ConsoleFormPackageExperience");

            var t = new TextField
            {
                defaultTextFormat = new TextFormat {
                    font = "Courier"
                },
                backgroundColor = 0x303030,
                textColor       = 0xffff00,
                text            = "powered by jsc",
                background      = true,
                x = 0,
                y = 0,
                alwaysShowSelection = true,
                width  = DefaultWidth,
                height = DefaultHeight
            }.AttachTo(this);

            // you should be running within the browser
            //SecurityError: Error #2060: Security sandbox violation: ExternalInterface caller file:///C:/work/jsc.svn/examples/actionscript/FlashBrowserDocument/FlashBrowserDocument/bin/Release/web/FlashBrowserDocument.swf cannot access file:///C:/work/jsc.svn/examples/actionscript/FlashBrowserDocument/FlashBrowserDocument/bin/Release/web/FlashBrowserDocument.htm.
            //    at flash.external::ExternalInterface$/_initJS()
            //    at flash.external::ExternalInterface$/addCallback()
            //    at Extensions::ExternalExtensions$/External_100668292()
            //    at DOM::ExternalContext()
            //    at DOM::ExternalContext$/ExternalAuthentication_100663321()
            //    at FlashBrowserDocument.ActionScript::FlashBrowserDocument()

            t.text = "before ExternalAuthentication";
            try
            {
                Console.WriteLine("before ExternalAuthentication");
                ExternalContext.ExternalAuthentication(
                    context =>
                {
                    Console.WriteLine("at ExternalAuthentication");
                    t.text = "after ExternalAuthentication";

                    context.Document.body.style.backgroundColor = "#afafff";
                    context.Document.body.style.color           = "#000080";

                    t.appendText("\nflash element was found within html document");

                    context.Document.title = "hello world";

                    #region hide/show flash element
                    var HideFlashButtonCounter = 0;
                    var HideFlashButton        = new IHTMLButton {
                        innerHTML = "hide flash element"
                    };

                    HideFlashButton.AttachTo(context);
                    HideFlashButton.onclick +=
                        delegate
                    {
                        if (HideFlashButtonCounter % 2 == 0)
                        {
                            t.appendText("\nflash element hidden");
                            context.Element.width     = 0;
                            context.Element.height    = 0;
                            HideFlashButton.innerHTML = "show flash element";
                        }
                        else
                        {
                            t.appendText("\nflash element shown");
                            context.Element.width     = DefaultWidth;
                            context.Element.height    = DefaultHeight;
                            HideFlashButton.innerHTML = "hide flash element";
                        }

                        HideFlashButtonCounter++;
                    };
                    #endregion

                    var Content = @"
					<hr />
					<blockqoute>
						<h1>This application was written in c# and was compiled to actionscript with <a href='http://jsc.sf.net'>jsc compiler</a>.</h1>
						<h2>Currently supported browsers:</h2>
						<ul>
							<li><img src='http://www.w3schools.com/images/compatible_firefox.gif' />Firefox</li>
							<li><img src='http://www.w3schools.com/images/compatible_chrome.gif' />Google Chrome</li>
							<li><img src='http://www.w3schools.com/images/compatible_safari.gif' />Safari</li>
							<li><img src='http://www.w3schools.com/images/compatible_opera.gif' />Opera</li>
						</ul>
					</blockqoute>
					"                    .AttachAsDiv(context);

                    var DynamicChild = new IHTMLSpan {
                        innerHTML = "hello world"
                    }.AttachTo(Content);

                    DynamicChild.style.color = "red";
                    DynamicChild.innerHTML   = "click on the image to remove it!";

                    var DynamicChildImage = new IHTMLImage
                    {
                        title = "jsc diagram",
                        src   = "http://jsc.sourceforge.net/jsc.png"
                    }.AttachTo(DynamicChild);

                    DynamicChildImage.style.backgroundColor = "white";

                    DynamicChildImage.onclick +=
                        delegate
                    {
                        Console.WriteLine("at DynamicChildImage onclick");

                        DynamicChild.removeChild(DynamicChildImage);
                        DynamicChild.innerHTML = "you have removed that image!";

                        var Undo = new IHTMLButton {
                            innerHTML = "undo"
                        }.AttachTo(DynamicChild);

                        Undo.onclick +=
                            delegate
                        {
                            DynamicChildImage.AttachTo(DynamicChild);
                            DynamicChild.removeChild(Undo);
                        };
                    };

                    DynamicChild.onclick +=
                        delegate
                    {
                        Console.WriteLine("at DynamicChild onclick");
                    };
                }
                    );
            }
            catch (Exception ex)
            {
                t.text = "error " + new { ex };
            }
        }
Exemplo n.º 17
0
        /// <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)
        {
            var n = new MyEditor();

            n.Container.AttachToDocument();

            //var a = new IHTMLAnchor(
            //    "http://sketchup.google.com/3dwarehouse/search?q=stargate",
            //    "Open 3dwarehouse in another window"
            //);
            //a.style.fontSize = "large-xx";
            //a.AttachToDocument();



            //ii.setAttribute("src", "http://sketchup.google.com/3dwarehouse/");


            IHTMLDiv Control = new IHTMLDiv();

            n.Edit1.parentNode.replaceChild(Control, n.Edit1);

            //n.Logo.src = "assets/TextEditorDemo2/Preview.png";

            //Control.AttachToDocument();


            var text = new TextEditor(Control);


            text.InnerHTML = "Drag images to this frame!<hr />";

            // IE error

            text.Height = 200;
            text.Width  = 400;
            //text.InnerHTML = n.Edit1.value;

            text.IsFadeEnabled = false;

            //var i = new IHTMLImage(21, 20) { src = "assets/TextEditorDemo2/cal.png" };

            var CurrentList = new List <InternalExtensions.GoogleThreeDWarehouseImage>();

            n.ToLarge.onclick += e =>
            {
                CurrentList.ForEach(k => k.AnimationZoom = 4);
            };

            n.ToMedium.onclick += e =>
            {
                CurrentList.ForEach(k => k.AnimationZoom = 1);
            };
            n.ToSmall.onclick += e =>
            {
                CurrentList.ForEach(k => k.AnimationZoom = 0.5);
            };

            Action <string[], IHTMLButton> ToPreview =
                (data, button) =>
            {
                var ii = new IHTMLImage(40, 30)
                {
                    src = data[0]
                };
                ii.style.verticalAlign = "middle";

                var sp = new IHTMLSpan();
                sp.style.marginLeft = "1em";
                sp.AttachTo(button);

                ii.AttachTo(button).ToGoogleThreeDWarehouseImage().Animate();
            };

            n.Nasa.onclick +=
                delegate
            {
                text.InnerHTML = NasaSource.Text;
            };


            //n.Houses.onclick +=
            //    delegate
            //    {
            //        text.InnerHTML = Pages.Houses.Static.HTML;

            //    };

            n.CnC.onclick +=
                delegate
            {
                text.InnerHTML = CnCSource.Text;
            };

            n.Ships.onclick +=
                delegate
            {
                text.InnerHTML = ShipsSource.Text;
            };

            //ToPreview(Ships..Images, n.Ships);
            //ToPreview(CnC.Static.Images, n.CnC);
            ////ToPreview(Houses.Static.Images, n.Houses);
            //ToPreview(Nasa.Static.Images, n.Nasa);


            //i.AttachToDocument();
            n.OK.onclick +=
                delegate
            {
                n.ContainerForImages.removeChildren();
                CurrentList.Clear();
                //text.Document.getElementsByTagName("img").ToGoogleThreeDWarehouseImages().Animate();

                var clones = text.Document.GetClonedImages();
                foreach (IHTMLImage iii in clones)
                {
                    var w = iii.AttachTo(n.ContainerForImages).ToGoogleThreeDWarehouseImage();

                    w.Animate();

                    CurrentList.Add(w);
                }
            };
            //);

            //OK.Control.style.paddingLeft = "1em";
            //text.BottomToolbarContainer.appendChild(OK.Control);

            text.TopToolbarContainer.Hide();
            text.BottomToolbarContainer.Hide();
        }
Exemplo n.º 18
0
        //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 SimpleRollover()
        {
            // wallpapers at http://labnol.blogspot.com/2006/11/download-windows-vista-wallpapers.html

            // * broken at the moment
            #region AnimateCharacterColors
            System.Func <string, INode> AnimateCharacterColors =
                (text) =>
            {
                var s = new IHTMLSpan();

                var l = new global::System.Collections.Generic.List <IHTMLSpan>();

                foreach (char c in text)
                {
                    var y = new string(c, 1);
                    var x = new IHTMLSpan(y);

                    if (y == " ")
                    {
                        s.appendChild(" ");
                    }
                    else
                    {
                        l.Add(x);


                        s.appendChild(x);
                    }
                }



                new Timer(
                    t =>
                {
                    var len = l.Count + 40;

                    if (t.Counter % len < l.Count)
                    {
                        if (t.Counter % (len * 2) < l.Count)
                        {
                            l[t.Counter % len].style.visibility = IStyle.VisibilityEnum.hidden;
                        }
                        else
                        {
                            l[t.Counter % len].style.visibility = IStyle.VisibilityEnum.visible;
                        }
                    }
                }, 6000, 200);


                return(s);
            };
            #endregion
            // */

            var u = new IHTMLDiv();

            //u.style.backgroundColor = Color.Green;
            u.style.position = IStyle.PositionEnum.absolute;
            u.style.left     = "0";
            u.style.top      = "0";
            u.style.height   = "100%";
            u.style.width    = "100%";
            u.style.overflow = IStyle.OverflowEnum.auto;

            var styles = new XStyles
            {
                dark         = new IStyleSheet(),
                light        = new IStyleSheet(),
                switchbutton = new IHTMLAnchor("", "day/night"),
                counter      = 0
            };



            styles.switchbutton.onclick +=
                ev =>
            {
                ev.PreventDefault();

                styles.counter++;


                if (styles.counter % 2 == 1)
                {
                    styles.dark.disabled  = false;
                    styles.light.disabled = true;
                }
                else
                {
                    styles.dark.disabled  = true;
                    styles.light.disabled = false;
                }
            };


            var ad = new IHTMLDiv(
                new IHTMLSpan(
                    AnimateCharacterColors(
                        "this application was written in c# and then translated to javascript by jsc to run in your browser"
                        )
                    ),
                new IHTMLAnchor("http://zproxy.wordpress.com", "visit blog"),
                new IHTMLAnchor("http://jsc.sf.net", "get more examples"),
                styles.switchbutton
                )
            {
                className = "ad1"
            };

            u.appendChild(ad);

            var sheet = new IStyleSheet();

            sheet.AddRule(".ad1",
                          r =>
            {
                r.style.marginTop  = "1em";
                r.style.color      = Color.White;
                r.style.fontFamily = IStyle.FontFamilyEnum.Verdana;
            }
                          );


            sheet.AddRule(".ad1 > *",
                          r =>
            {
                r.style.padding = "1em";

                r.style.marginTop = "1em";
            }
                          );

            sheet.AddRule(".ad1 > span",
                          r =>
            {
                r.style.Float = IStyle.FloatEnum.right;
            }
                          );

            sheet.AddRule(".ad1 > a",
                          r =>
            {
                r.style.Float = IStyle.FloatEnum.left;
                r.style.color = Color.White;

                r.style.textDecoration = "none";
            }
                          );

            sheet.AddRule(".ad1 a:hover",
                          r =>
            {
                r.style.color = Color.Yellow;
            }
                          );



            sheet.AddRule("html",
                          r =>
            {
                r.style.overflow = IStyle.OverflowEnum.hidden;
            }
                          );

            sheet.AddRule("body",
                          r =>
            {
                r.style.overflow = IStyle.OverflowEnum.hidden;

                r.style.padding = "0";
                r.style.margin  = "0";

                //r.style.backgroundImage = "url(assets/vista.jpg)";
            }
                          );


            styles.dark.AddRule("body").style.backgroundColor    = JSColor.Black;
            styles.dark.AddRule("body").style.backgroundPosition = "center top";

            styles.light.AddRule("body").style.backgroundColor    = JSColor.Black;
            styles.light.AddRule("body").style.backgroundPosition = "center top";


            new global::SimpleRollover.HTML.Images.FromAssets.vistax().ToBackground(
                styles.dark.AddRule("body").style, false
                );

            new global::SimpleRollover.HTML.Images.FromAssets.vista().ToBackground(
                styles.dark.AddRule(".effect1").style
                );

            styles.dark.AddRule(".moon1").style.backgroundColor = Color.Yellow;

            new global::SimpleRollover.HTML.Images.FromAssets.vista().ToBackground(
                styles.light.AddRule("body").style, false
                );

            new global::SimpleRollover.HTML.Images.FromAssets.vistax().ToBackground(
                styles.light.AddRule(".effect1").style
                );
            styles.light.AddRule(".moon1").style.backgroundColor = Color.Red;


            sheet.AddRule(".special1",
                          r =>
            {
                r.style.background = "none";
                r.style.border     = "0";
                r.style.width      = "100%";
                r.style.marginTop  = "4em";
            }
                          );

            sheet.AddRule(".content1",
                          r =>
            {
                r.style.backgroundColor = Color.White;

                r.style.padding     = "1em";
                r.style.marginLeft  = "4em";
                r.style.marginRight = "4em";
                r.style.Opacity     = 0.5;
                r.style.border      = "1px solid gray";
            }
                          );

            sheet.AddRule(".special1 img", "border: 0", 0);
            sheet.AddRule(".special1:hover", "background: url(" + new global::SimpleRollover.HTML.Images.FromAssets.Untitled_3().src + ") repeat-x", 1);

            sheet.AddRule(".special1 .hot").style.display       = IStyle.DisplayEnum.none;
            sheet.AddRule(".special1:hover .hot").style.display = IStyle.DisplayEnum.inline;

            sheet.AddRule(".special1 .cold", "display: inline;", 1);
            sheet.AddRule(".special1:hover .cold", "display: none;", 1);


            var states = new XState[] { }.AsEnumerable();

            //    new XState {
            //        Show = default(System.Action),
            //        Hide = default(System.Action),
            //        Selected = false }
            //}.Where(p => false);


            Action <IHTMLImage, IHTMLImage, string> Spawn =
                async(icold, ihot, i2) =>
            {
                var cold = await icold;
                var hot  = await ihot;

                //((IHTMLImage)i[0]).InvokeOnComplete(cold =>
                //((IHTMLImage)i[1]).InvokeOnComplete(hot =>
                //     {
                cold.className = "cold";
                hot.className  = "hot";


                var btn = new IHTMLButton()
                {
                    className = "special1"
                };

                btn.appendChild(cold, hot);

                var content = new IHTMLElement(IHTMLElement.HTMLElementEnum.pre);

                content.innerHTML = "...";
                content.className = "content1";

                var tween     = new TweenDataDouble();
                var tween_max = 16;

                tween.ValueChanged +=
                    delegate
                {
                    content.style.Opacity = tween.Value / tween_max;
                    content.style.height  = tween.Value + "em";

                    content.style.overflow = IStyle.OverflowEnum.hidden;
                };

                tween.Done += delegate
                {
                    if (tween.Value > 0)
                    {
                        content.style.overflow = IStyle.OverflowEnum.auto;
                    }
                };

                tween.Value = 0;

                var state = new XState
                {
                    Show = (System.Action)(() =>
                    {
                        tween.Value = tween_max;
                    }
                                           ),
                    Hide     = (System.Action)(() => tween.Value = 0),
                    Selected = false
                };

                //try
                //{
                //    new IXMLHttpRequest(HTTPMethodEnum.GET, i[2],
                //       request => content.innerHTML = request.responseText
                //    );
                //}
                //catch
                //{
                content.innerText = i2;
                //}

                states = states.Concat(new[] { state });

                btn.onclick +=
                    delegate
                {
                    foreach (var v in states)
                    {
                        if (v == state)
                        {
                            v.Selected = !v.Selected;

                            if (v.Selected)
                            {
                                v.Show();
                            }
                            else
                            {
                                v.Hide();
                            }
                        }
                        else
                        {
                            v.Selected = false;
                            v.Hide();
                        }
                    }
                };

                u.appendChild(btn, content);
            };


            SpawnCursor();


            u.AttachToDocument();

            Spawn(
                new global::SimpleRollover.HTML.Images.FromAssets.Untitled_1_03(),
                new global::SimpleRollover.HTML.Images.FromAssets.Untitled_2_03(),
                "This application was written in C#."
                );

            Spawn(
                new global::SimpleRollover.HTML.Images.FromAssets.Untitled_1_07(),
                new global::SimpleRollover.HTML.Images.FromAssets.Untitled_2_07(),

                "This application was cross compiled into JavaScript."
                );
        }
        public SolutionFileDesigner()
        {
            var ToolbarHeight = "1.3em";
            var Container     = new IHTMLDiv();

            this.Container = Container;

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

            var Content = new IHTMLDiv().AttachTo(Container);

            this.Content = Content;

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


            var Toolbar = new IHTMLDiv().AttachTo(Container);

            Toolbar.style.backgroundColor = Color.FromGray(0xef);
            Toolbar.style.position        = IStyle.PositionEnum.absolute;
            Toolbar.style.left            = "0px";
            Toolbar.style.height          = ToolbarHeight;
            Toolbar.style.right           = "0px";
            Toolbar.style.bottom          = "0px";

            this.Tabs = new BindingList <SolutionFileDesignerTab>().WithEvents(
                NewTab =>
            {
                var span = new IHTMLSpan {
                    innerText = NewTab.Text
                };

                span.style.paddingLeft  = "1.5em";
                span.style.paddingRight = "0.3em";

                var a = new IHTMLAnchor
                {
                    NewTab.Image, span
                };
                NewTab.TabElement = a;

                NewTab.Image.style.verticalAlign = "middle";
                NewTab.Image.border         = 0;
                NewTab.Image.style.position = IStyle.PositionEnum.absolute;

                a.style.backgroundColor = Color.FromGray(0xef);
                a.style.color           = Color.Black;
                a.style.textDecoration  = "none";
                a.style.fontFamily      = IStyle.FontFamilyEnum.Tahoma;

                a.href = "javascript: void(0);";

                NewTab.Activated +=
                    delegate
                {
                    (from k in this.Tabs.Source
                     where k != NewTab
                     select(Action) k.RaiseDeactivated).Invoke();
                };

                a.onclick +=
                    delegate
                {
                    NewTab.RaiseActivated();
                };
                a.style.display = IStyle.DisplayEnum.inline_block;
                a.style.height  = "100%";


                a.onmousemove +=
                    delegate
                {
                    a.style.backgroundColor = Color.FromGray(0xff);
                };

                a.onmouseout +=
                    delegate
                {
                    a.style.backgroundColor = Color.FromGray(0xef);
                };

                Toolbar.Add(a);

                return(delegate
                {
                    a.Orphanize();
                });
            }
                );
        }
        private IHTMLDiv InitializeSuggestMovie(ExternalContext Context, List <MovieItemWithPoster> KnownMovies, IHTMLDiv Toolbar, IHTMLDiv Shadow)
        {
            #region SuggestMovie
            var SuggestionDialog = new IHTMLDiv().AttachTo(Context);

            SuggestionDialog.style.position        = "absolute";
            SuggestionDialog.style.left            = "50%";
            SuggestionDialog.style.top             = "50%";
            SuggestionDialog.style.marginLeft      = (-400 - -40) + "px";
            SuggestionDialog.style.marginTop       = (-300 - -40) + "px";
            SuggestionDialog.style.backgroundColor = "black";
            SuggestionDialog.style.width           = (800 + -40 * 2) + "px";
            SuggestionDialog.style.height          = (600 + -40 * 2) + "px";

            SuggestionDialog.style.color   = "white";
            SuggestionDialog.style.display = "none";

            SuggestionDialog.style.overflow = "auto";


            var InputSection = new IHTMLDiv {
                innerHTML = "<h2>What do you like to do?</h2>"
            }.AttachTo(SuggestionDialog);
            var OuputSection = new IHTMLDiv {
                innerHTML = "<h2>Here what I think!</h2>"
            }.AttachTo(SuggestionDialog);

            var Reasonbox = new IHTMLDiv().AttachTo(OuputSection);

            OuputSection.style.display = "none";

            var GroupSelectedOptionChanged = default(Action);
            var GroupSelectedOptions       = new List <Func <MovieItem, bool> >();

            var Reasoning = new List <Func <string> >();

            #region AddSuggestionGroup
            Func <Func <string, string, Func <MovieItem, bool>, Action> > AddSuggestionGroup =
                () =>
            {
                var Group = new IHTMLDiv {
                    innerHTML = "<h3>Step " + (GroupSelectedOptions.Count + 1) + "</h3>"
                }.AttachTo(InputSection);


                var GroupContent        = new IHTMLDiv().AttachTo(InputSection);
                var GroupSelectedOption = default(Func <MovieItem, bool>);

                var CurrentReason = "";

                Reasoning.Add(() => CurrentReason);
                GroupSelectedOptions.Add(k => GroupSelectedOption(k));

                GroupContent.style.marginLeft = "3em";

                var GroupSelectedOptionButton = default(IHTMLButton);

                Func <string, string, Func <MovieItem, bool>, Action> GroupOption =
                    (text, reason, filter) =>
                {
                    var btn = new IHTMLButton {
                        innerHTML = text
                    }.AttachTo(GroupContent);

                    btn.style.display = "block";

                    Action a =
                        delegate
                    {
                        CurrentReason = reason;

                        if (GroupSelectedOptionButton != null)
                        {
                            GroupSelectedOptionButton.style.color = "";
                        }

                        GroupSelectedOptionButton             = btn;
                        GroupSelectedOptionButton.style.color = "blue";

                        GroupSelectedOption = filter;

                        if (GroupSelectedOptionChanged != null)
                        {
                            GroupSelectedOptionChanged();
                        }
                    };

                    btn.onclick += a;
                    return(a);
                };


                return(GroupOption);
            };
            #endregion

            AddSuggestionGroup().Apply(
                g =>
            {
                var ForChildren = new[] { "Animation" };
                var ForFamily   = new[] { "Animation", "Comedy", "Family", "Fantasy" };
                var ForAdults   = new[] { "Adventure", "Drama", "Fantasy", "Mystery", "Thriller", "Action", "Crime" };

                g(
                    "There are some kids over here",
                    "Kids love cartoons.",
                    k => ForChildren.Any(x => k.IMDBGenres.ToLower().Contains(x.ToLower()))
                    );
                g(
                    "My family is in the room, keep it decent",
                    "You can feel comfortable watching comedy with your family.",
                    k => ForFamily.Any(x => k.IMDBGenres.ToLower().Contains(x.ToLower()))
                    );
                g(
                    "There are only some dudes in the room",
                    "A beer and a thriller - just for you.",
                    k => ForAdults.Any(x => k.IMDBGenres.ToLower().Contains(x.ToLower()))
                    );
                g(
                    "Neither",
                    "Cartoons and horror movies coming straight up!",
                    k => true
                    )();
            }
                );

            AddSuggestionGroup().Apply(
                g =>
            {
                var Year      = DateTime.Now.Year;
                var ForGeeks  = new[] { "" + (Year), "" + (Year + 1), };
                var ForRecent =
                    new[] {
                    "" + (Year + 1),
                    "" + (Year),
                    "" + (Year - 1),
                    "" + (Year - 2),
                };

                g(
                    "I am looking for new stuff",
                    "You should only be interested in new movies.",
                    k => ForGeeks.Any(x => k.SmartTitle.ToLower().Contains(x.ToLower()))
                    );

                g(
                    "I haven't watched that much tv recently!",
                    "You should only be interested in recent movies.",
                    k => ForRecent.Any(x => k.SmartTitle.ToLower().Contains(x.ToLower()))
                    );

                g(
                    "I do not like recent movies at all!",
                    "You like older movies!",
                    k => ForRecent.Any(x => !k.SmartTitle.ToLower().Contains(x.ToLower()))
                    );


                g(
                    "Neither",
                    "It does not matter to you how old the movie is.",
                    k => true
                    )();
            }
                );

            AddSuggestionGroup().Apply(
                g =>
            {
                g("I am looking for having a good time",
                  "I guess you do not like movies without story? Me too! They are a waste of my and your time!",
                  k => k.Raiting > 0.65
                  );
                g(
                    "I want to suggest someething really bad to a friend",
                    "Why watch something great if you could watch something really bad?",
                    k => k.Raiting < 0.7
                    );
                g(
                    "I cannot decide between options above",
                    "You don't trust others raiting the movies and would like to do it yourself.",
                    k => true
                    )();
            }
                );



            AddSuggestionGroup().Apply(
                g =>
            {
                g("I cannot watch tv very long", "TV shows are known to be short so thats what you get.", k => k.SmartTitle.ToLower().StartsWith("tv show:"));
                g("30 minutes is not enough for me", "You are going to skip the TV shows and see the movies.", k => k.SmartTitle.ToLower().StartsWith("movie:"));
                g("I cannot decide between options above", "You are going to watch tv shows and movies.", k => true)();
            }
                );

            new IHTMLDiv {
                innerHTML = "<hr />"
            }.AttachTo(InputSection);

            var NextButton = new IHTMLButton {
                innerHTML = "Next &raquo;"
            }.AttachTo(InputSection);
            NextButton.onclick +=
                delegate
            {
                GroupSelectedOptionChanged();

                InputSection.style.display = "none";
                OuputSection.style.display = "block";
            };


            new IHTMLDiv {
                innerHTML = "<hr />"
            }.AttachTo(OuputSection);

            var BackButton = new IHTMLButton {
                innerHTML = "&laquo; Back"
            }.AttachTo(OuputSection);
            BackButton.onclick +=
                delegate
            {
                OuputSection.style.display = "none";
                InputSection.style.display = "block";
            };

            var CloseButton = new IHTMLButton {
                innerHTML = "Hide this dialog"
            }.AttachTo(OuputSection);
            CloseButton.onclick +=
                delegate
            {
                SuggestionDialog.style.display = "none";
                Shadow.style.display           = "none";
            };

            this.KnownMoviesFilter = k => GroupSelectedOptions.All(x => x(k));

            GroupSelectedOptionChanged +=
                delegate
            {
                var w = new StringBuilder();
                Reasoning.ForEach(i => w.AppendLine(i()));

                var c = KnownMovies.Count(k => this.KnownMoviesFilter(k.Movie));

                if (c > 0)
                {
                    if (c > 1)
                    {
                        w.AppendLine("There are " + c + " things I am able to suggest you.");
                    }
                    else
                    {
                        w.AppendLine("There is only one thing I was able to suggest you.");
                    }

                    w.AppendLine("I might be interested in " + KnownMovies.Random(k => this.KnownMoviesFilter(k.Movie)).Movie.SmartTitle);
                }
                else
                {
                    w.AppendLine("Oops. There are no such things here at this time. Maybe later? Maybe change your anwsers instead?");
                }

                Reasonbox.innerHTML = w.ToString();

                foreach (var k in KnownMovies)
                {
                    if (this.KnownMoviesFilter(k.Movie))
                    {
                        k.Poster.style.display = "";
                    }
                    else
                    {
                        k.Poster.style.display = "none";
                    }
                }
            };
            GroupSelectedOptionChanged();

            var SuggestMovie = new IHTMLSpan {
                innerHTML = "&raquo; suggest a movie"
            }.AttachTo(Toolbar);

            SuggestMovie.style.Apply(
                s =>
            {
                s.border          = "1px dotted white";
                s.cursor          = "pointer";
                s.backgroundColor = "black";
                s.color           = "white";
                s.marginLeft      = "1em";
            }
                );

            SuggestMovie.onclick +=
                delegate
            {
                // clear if any and return

                Shadow.style.display           = "block";
                SuggestionDialog.style.display = "block";
            };
            #endregion
            return(SuggestionDialog);
        }
Exemplo n.º 21
0
        public StudioView()
        {
            Content.style.position = IStyle.PositionEnum.absolute;
            Content.style.left     = "0px";
            Content.style.right    = "0px";
            Content.style.top      = "0px";
            Content.style.bottom   = "0px";

            new TwentyTenWorkspace().ToBackground(Content.style, true);

            var WorkspaceHeader = default(IHTMLSpan);

            @"jsc-solutions.net studio".ToDocumentTitle().With(
                title =>
            {
                WorkspaceHeader = new IHTMLSpan {
                    innerText = title
                };

                WorkspaceHeader.AttachTo(Content);
                WorkspaceHeader.style.SetLocation(16, 8);
                WorkspaceHeader.style.color = Color.White;

                // http://www.quirksmode.org/css/textshadow.html
                WorkspaceHeader.style.textShadow = "#808080 4px 2px 2px";
            }
                );

            // em + px :)
            var Workspace0 = new IHTMLDiv().With(
                div =>
            {
                div.style.position = IStyle.PositionEnum.absolute;
                div.style.left     = "0px";
                div.style.right    = "0px";
                div.style.bottom   = "0px";
                div.style.top      = "3em";
            }
                ).AttachTo(Content);

            // workspace contains the split views
            var Workspace = new IHTMLDiv().With(
                div =>
            {
                div.style.position = IStyle.PositionEnum.absolute;
                div.style.left     = "6px";
                div.style.right    = "6px";
                div.style.bottom   = "6px";
                div.style.top      = "6px";
            }
                ).AttachTo(Workspace0);


            Action <HorizontalSplit> ApplyStyle =
                t =>
            {
                t.Split.Splitter.style.backgroundColor = Color.None;
                t.SplitImageContainer.Orphanize();
                t.SplitArea.Target.style.borderLeft  = "0";
                t.SplitArea.Target.style.borderRight = "0";
                t.SplitArea.Target.style.width       = "6px";
                t.SplitArea.Target.style.Opacity     = 0.7;

                // should we obselete JSColor already?
                t.SelectionColor = JSColor.Black;
            };

            var Split = new HorizontalSplit
            {
                Minimum = 0,
                Maximum = 1,
                Value   = 0.2,
            };

            Split.With(ApplyStyle);

            Split.Split.Splitter.style.backgroundColor = Color.None;

            Split.Container.AttachTo(Workspace);



            var SolutionToolbox = new SolutionDockWindowPage();

            SolutionToolbox.HeaderText.innerText          = "Toolbox";
            SolutionToolbox.Content.style.backgroundColor = Color.White;
            SolutionToolbox.Content.style.padding         = "2px";
            SolutionToolbox.Content.style.overflow        = IStyle.OverflowEnum.auto;
            SolutionToolbox.Content.Clear();


            var vv = new SolutionToolboxListView();

            vv.Container.AttachTo(SolutionToolbox.Content);

            var items = new StockToolboxTabsForHTMLDocument();

            items.WithEach(vv.Add);


            var Viewer = new SolutionDocumentViewer();
            SolutionDocumentViewerTab AboutTab = "About";

            Viewer.Add(AboutTab);

            var CurrentDesigner = new SolutionFileDesigner();



            var HTMLDesigner = new SolutionFileDesignerHTMLElementTabs();

            CurrentDesigner.Add(HTMLDesigner);

            #region CodeSource
            var CodeSourceTab =
                new SolutionFileDesignerTab
            {
                Image = new ScriptCoreLib.Ultra.Components.HTML.Images.FromAssets.ClassViewer(),
                Text  = "XDefaultPage"
            };

            var CodeSourceView = new SolutionFileView();


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

            CodeSourceView.Container.style.display = IStyle.DisplayEnum.none;
            CodeSourceView.Container.AttachTo(CurrentDesigner.Content);

            CodeSourceTab.Deactivated +=
                delegate
            {
                CodeSourceView.Container.style.display = IStyle.DisplayEnum.none;
            };

            CodeSourceTab.Activated +=
                delegate
            {
                HTMLDesigner.HTMLDesignerContent.WhenContentReady(
                    body =>
                {
                    var CodeSourceFile = new SolutionFile();

                    var Type = new SolutionProjectLanguageType
                    {
                        Namespace   = "HTML.Pages",
                        Name        = "IDefaultPage",
                        IsInterface = true,
                    };

                    (from n in body.AsXElement().DescendantsAndSelf()
                     let id = n.Attribute("id")
                              where id != null
                              select new { n, id }
                    ).WithEach(
                        k =>
                    {
                        Type.Properties.Add(
                            new SolutionProjectLanguageProperty
                        {
                            Name         = k.id.Value,
                            GetMethod    = new SolutionProjectLanguageMethod(),
                            SetMethod    = new SolutionProjectLanguageMethod(),
                            PropertyType = new SolutionProjectLanguageType
                            {
                                Namespace = "ScriptCoreLib.JavaScript.DOM.HTML",
                                Name      = "IHTMLElement"
                            }
                        }
                            );
                    }
                        );

                    KnownLanguages.VisualCSharp.WriteType(CodeSourceFile, Type, null);

                    CodeSourceView.File = CodeSourceFile;

                    CodeSourceView.Container.style.display = IStyle.DisplayEnum.empty;
                }
                    );
            };


            #endregion


            CurrentDesigner.Add(CodeSourceTab);



            CurrentDesigner.First().RaiseActivated();

            AboutTab.Activated +=
                delegate
            {
                Viewer.Content.ReplaceContentWith(CurrentDesigner.Container);
            };

            Viewer.First().Activate();

            Split.Split.LeftScrollable  = SolutionToolbox.Container;
            Split.Split.RightScrollable = Viewer.Container;
        }
Exemplo n.º 22
0
        /// <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(IDefaultPage page)
        {
            new JSCSolutionsNETImage().ToBackground(page.Item1.style, false);
            new JSCSolutionsNETImage().ToBackground(page.Item2.style, false);


            // Update document title
            // http://do.jsc-solutions.net/Update-document-title

            @"Hello world".ToDocumentTitle();
            // Send xml to server
            // http://do.jsc-solutions.net/Send-xml-to-server

            var v = new SolutionFileView();

            var f = new SolutionFile();

            f.WriteHTMLElement(StockPageDefault.Element);

            v.File = f;

            var Container = new IHTMLDiv();

            Container.style.position = IStyle.PositionEnum.relative;
            Container.style.display  = IStyle.DisplayEnum.inline_block;
            Container.style.width    = "600px";
            Container.style.height   = "400px";
            Container.style.border   = "1px solid gray";

            var ToolbarHeight = "1.3em";
            var Content       = new IHTMLDiv().AttachTo(Container);

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


            var Toolbar = new IHTMLDiv().AttachTo(Container);

            Toolbar.style.backgroundColor = Color.FromGray(0xef);
            Toolbar.style.position        = IStyle.PositionEnum.absolute;
            Toolbar.style.left            = "0px";
            Toolbar.style.height          = ToolbarHeight;
            Toolbar.style.right           = "0px";
            Toolbar.style.bottom          = "0px";

            Action <IHTMLImage, string, Action> AddToolbarButton =
                (img, text, handler) =>
            {
                var span = new IHTMLSpan {
                    innerText = text
                };

                span.style.paddingLeft  = "1.5em";
                span.style.paddingRight = "0.3em";

                var a = new IHTMLAnchor
                {
                    img, span
                };

                img.style.verticalAlign = "middle";
                img.border         = 0;
                img.style.position = IStyle.PositionEnum.absolute;

                a.style.backgroundColor = Color.FromGray(0xef);
                a.style.color           = Color.Black;
                a.style.textDecoration  = "none";
                a.style.fontFamily      = IStyle.FontFamilyEnum.Tahoma;

                a.href     = "javascript: void(0);";
                a.onclick +=
                    delegate
                {
                    handler();
                };
                a.style.display = IStyle.DisplayEnum.inline_block;
                a.style.height  = "100%";


                a.onmousemove +=
                    delegate
                {
                    a.style.backgroundColor = Color.FromGray(0xff);
                };

                a.onmouseout +=
                    delegate
                {
                    a.style.backgroundColor = Color.FromGray(0xef);
                };

                Toolbar.Add(a);
            };


            v.Container.style.height = "100%";
            v.Container.AttachTo(Content);


            Content.Add(v.Container);

            var i = CreateEditor();

            i.AttachTo(Content);



            var ii = new IHTMLPre().AttachTo(Content);

            ii.style.position   = IStyle.PositionEnum.absolute;
            ii.style.left       = "0px";
            ii.style.top        = "0px";
            ii.style.right      = "0px";
            ii.style.bottom     = "0px";
            ii.style.overflow   = IStyle.OverflowEnum.auto;
            ii.style.padding    = "0px";
            ii.style.margin     = "0px";
            ii.style.whiteSpace = IStyle.WhiteSpaceEnum.normal;

            v.Container.style.display = IStyle.DisplayEnum.none;
            i.style.display           = IStyle.DisplayEnum.empty;
            ii.style.display          = IStyle.DisplayEnum.none;

            AddToolbarButton(new RTA_mode_design(), "Design",
                             delegate
            {
                v.Container.style.display = IStyle.DisplayEnum.none;
                ii.style.display          = IStyle.DisplayEnum.none;
                i.style.display           = IStyle.DisplayEnum.empty;
            }
                             );

            AddToolbarButton(new RTA_mode_html(), "Source",
                             delegate
            {
                v.Container.style.display = IStyle.DisplayEnum.empty;
                ii.style.display          = IStyle.DisplayEnum.none;
                i.style.display           = IStyle.DisplayEnum.none;

                f.Clear();

                i.WhenContentReady(
                    body =>
                {
                    f.WriteHTMLElement(body.AsXElement());

                    // update
                    v.File = f;
                }
                    );
            }
                             );

            AddToolbarButton(new RTA_mode_html(), "Source raw",
                             delegate
            {
                v.Container.style.display = IStyle.DisplayEnum.none;
                ii.style.display          = IStyle.DisplayEnum.empty;
                i.style.display           = IStyle.DisplayEnum.none;



                i.WhenContentReady(
                    body =>
                {
                    ii.innerText = body.AsXElement().ToString();
                }
                    );
            }
                             );

            page.PageContainer.Add(Container);

            new ApplicationWebService().WebMethod2(
                new XElement(@"Document",
                             new object[] {
                new XElement(@"Data",
                             new object[] {
                    @"Hello world"
                }
                             ),
                new XElement(@"Client",
                             new object[] {
                    @"Unchanged text"
                }
                             )
            }
                             ),
                delegate(XElement doc)
            {
                // Show server message as document title
                // http://do.jsc-solutions.net/Show-server-message-as-document-title

                doc.Element(@"Data").Value.ToDocumentTitle();
            }
                );
        }
Exemplo n.º 23
0
        public StudioView(Action <IHTMLElement, Action <ISaveAction> > AddSaveButton)
        {
            Content.style.position = IStyle.PositionEnum.absolute;
            Content.style.left     = "0px";
            Content.style.right    = "0px";
            Content.style.top      = "0px";
            Content.style.bottom   = "0px";

            new TwentyTenWorkspace().ToBackground(Content.style, true);

            var WorkspaceHeader = default(IHTMLSpan);

            @"jsc-solutions.net studio".ToDocumentTitle().With(
                title =>
            {
                WorkspaceHeader = new IHTMLSpan {
                    innerText = title
                };

                WorkspaceHeader.AttachTo(Content);
                WorkspaceHeader.style.SetLocation(16, 8);
                WorkspaceHeader.style.color = Color.White;

                // http://www.quirksmode.org/css/textshadow.html
                WorkspaceHeader.style.textShadow = "#808080 4px 2px 2px";
            }
                );

            // em + px :)
            var Workspace0 = new IHTMLDiv().With(
                div =>
            {
                div.style.position = IStyle.PositionEnum.absolute;
                div.style.left     = "0px";
                div.style.right    = "0px";
                div.style.bottom   = "0px";
                div.style.top      = "3em";
            }
                ).AttachTo(Content);

            // workspace contains the split views
            var Workspace = new IHTMLDiv().With(
                div =>
            {
                div.style.position = IStyle.PositionEnum.absolute;
                div.style.left     = "6px";
                div.style.right    = "6px";
                div.style.bottom   = "6px";
                div.style.top      = "6px";
            }
                ).AttachTo(Workspace0);

            // in this project we wont be having toolbox or toolbar yet

            Action <HorizontalSplit> ApplyStyle =
                t =>
            {
                t.Split.Splitter.style.backgroundColor = Color.None;
                t.SplitImageContainer.Orphanize();
                t.SplitArea.Target.style.borderLeft  = "0";
                t.SplitArea.Target.style.borderRight = "0";
                t.SplitArea.Target.style.width       = "6px";
                t.SplitArea.Target.style.Opacity     = 0.7;

                // should we obselete JSColor already?
                t.SelectionColor = JSColor.Black;
            };

            var EditorTreeSplit = new HorizontalSplit
            {
                Minimum = 0,
                Maximum = 1,
                Value   = 0.7,
            };

            EditorTreeSplit.With(ApplyStyle);

            EditorTreeSplit.Split.Splitter.style.backgroundColor = Color.None;

            var Viewer = new SolutionDocumentViewer();
            SolutionDocumentViewerTab AboutTab = "About";

            Viewer.Add(AboutTab);
            AboutTab.TabElement.style.Float = IStyle.FloatEnum.right;

            SolutionDocumentViewerTab File1 = "File1";

            Viewer.Add(File1);

            var File1Content = new IHTMLDiv();

            // location + design

            File1Content.style.left     = "0px";
            File1Content.style.top      = "1em";
            File1Content.style.right    = "0px";
            File1Content.style.bottom   = "1em";
            File1Content.style.position = IStyle.PositionEnum.absolute;


            var File1View = new SolutionFileView();

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

            File1Content.ReplaceContentWith(File1View.Container);

            var sln = new SolutionBuilder();

            var _Solution = new TreeNode(VistaTreeNodePage.Create);


            var _Project = _Solution.Add();

            var About = new AboutPage();

            Action UpdateFile1Text =
                delegate
            {
                if (File1View.File != null)
                {
                    File1.Text = File1View.File.Name.SkipUntilIfAny("/");
                }
                else
                {
                    File1.Text = sln.Name;
                }
            };
            Action Update =
                delegate
            {
                sln.Name = About.ProjectName.value;

                UpdateFile1Text();

                _Project.Clear();
                UpdateTree(sln, File1View, _Solution, _Project);
            };

            File1View.FileChanged +=
                delegate
            {
                if (File1View.File.Name.EndsWith(".htm"))
                {
                    File1Content.style.top    = "0px";
                    File1Content.style.bottom = "1em";
                    // show the design/source buttons
                }
                else if (File1View.File.Name.EndsWith(sln.Language.CodeFileExtension))
                {
                    File1Content.style.top    = "1em";
                    File1Content.style.bottom = "0px";
                    // show type outline / member
                }

                UpdateFile1Text();

                File1.Activate();
            };

            AddSaveButton(WorkspaceHeader, i => Save = i);

            About.ProjectName.value     = sln.Name;
            About.ProjectName.onchange +=
                delegate
            {
                Update();
            };


            AboutTab.Activated +=
                delegate
            {
                // our about page has dynamic size..
                Viewer.Content.ReplaceContentWith(About.Container);
            };

            File1.Activated +=
                delegate
            {
                // our about page has dynamic size..
                Viewer.Content.ReplaceContentWith(File1Content);
            };

            AboutTab.Activate();

            EditorTreeSplit.Split.LeftContainer = Viewer.Container;

            var SolutionExplorer = new SolutionDockWindowPage();

            SolutionExplorer.HeaderText.innerText          = "Solution Explorer";
            SolutionExplorer.Content.style.backgroundColor = Color.White;
            SolutionExplorer.Content.style.padding         = "2px";
            SolutionExplorer.Content.ReplaceContentWith(_Solution.Container);

            _Solution.Container.style.overflow        = IStyle.OverflowEnum.auto;
            _Solution.Container.style.height          = "100%";
            _Solution.Container.style.backgroundColor = Color.White;

            EditorTreeSplit.Split.RightContainer = SolutionExplorer.Container;

            EditorTreeSplit.Container.AttachTo(Workspace);


            Update();

            new Rules(File1View, sln, Update);
        }
Exemplo n.º 24
0
        public StudioView(Action <IHTMLElement, Action <ISaveAction> > AddSaveButton = null)
        {
            Content.style.position = IStyle.PositionEnum.absolute;
            Content.style.left     = "0px";
            Content.style.right    = "0px";
            Content.style.top      = "0px";
            Content.style.bottom   = "0px";

            new TwentyTenWorkspace().ToBackground(Content.style, true);

            var WorkspaceHeaderTab0 = new IHTMLDiv().With(
                div =>
            {
                div.style.position = IStyle.PositionEnum.absolute;
                div.style.top      = "0px";
                div.style.left     = "0px";
                div.style.width    = "14em";
                div.style.height   = "6em";

                div.style.padding = "0.5em";

                new Glow1().ToBackground(div.style, false);
            }
                ).AttachTo(Content);

            var WorkspaceHeaderTab1 = new IHTMLDiv().With(
                div =>
            {
                div.style.position = IStyle.PositionEnum.absolute;
                div.style.top      = "0px";
                div.style.left     = "14em";
                div.style.width    = "20em";
                div.style.height   = "6em";

                div.style.padding = "0.5em";

                new Glow1().ToBackground(div.style, false);
            }
                ).AttachTo(Content);

            var WorkspaceHeaderTab2 = new IHTMLDiv().With(
                div =>
            {
                div.style.position = IStyle.PositionEnum.absolute;
                div.style.top      = "0px";
                div.style.left     = "34em";
                div.style.right    = "6em";
                div.style.height   = "6em";

                div.style.padding = "0.5em";

                new Glow1().ToBackground(div.style, false);
            }
                ).AttachTo(Content);

            var WorkspaceHeaderTab7 = new IHTMLDiv().With(
                div =>
            {
                div.style.position = IStyle.PositionEnum.absolute;
                div.style.top      = "0px";
                div.style.width    = "6em";
                div.style.right    = "0px";
                div.style.height   = "6em";

                //div.style.padding = "0.5em";

                new Glow1().ToBackground(div.style, false);
            }
                ).AttachTo(Content);

            var WorkspaceHeaderTab0Text = default(IHTMLSpan);



            new DownloadSDK
            {
            }.AttachTo(
                new IHTMLAnchor
            {
                title = "Download JSC SDK!",
                href  = "http://download.jsc-solutions.net"
            }.AttachTo(WorkspaceHeaderTab7)
                );

            @"studio.jsc-solutions.net".ToDocumentTitle().With(
                title =>
            {
                WorkspaceHeaderTab0Text = new IHTMLSpan {
                    innerText = title
                };

                WorkspaceHeaderTab0Text.AttachTo(WorkspaceHeaderTab0);
                //WorkspaceHeaderTab0Text.style.SetLocation(16, 8);
                WorkspaceHeaderTab0Text.style.fontFamily = IStyle.FontFamilyEnum.Tahoma;
                WorkspaceHeaderTab0Text.style.color      = Color.White;
                WorkspaceHeaderTab0Text.style.display    = IStyle.DisplayEnum.block;

                // http://www.quirksmode.org/css/textshadow.html
                WorkspaceHeaderTab0Text.style.textShadow = "#808080 4px 2px 2px";
            }
                );


            if (AddSaveButton != null)
            {
                AddSaveButton(WorkspaceHeaderTab0Text, i => Save = i);
            }

            // em + px :)
            var Workspace0 = new IHTMLDiv().With(
                div =>
            {
                div.style.position = IStyle.PositionEnum.absolute;
                div.style.left     = "0px";
                div.style.right    = "0px";
                div.style.bottom   = "0px";
                div.style.top      = "6em";
            }
                ).AttachTo(Content);

            // workspace contains the split views
            var Workspace = new IHTMLDiv().With(
                div =>
            {
                div.style.position = IStyle.PositionEnum.absolute;
                div.style.left     = "6px";
                div.style.right    = "6px";
                div.style.bottom   = "6px";
                div.style.top      = "6px";
            }
                ).AttachTo(Workspace0);

            // in this project we wont be having toolbox or toolbar yet

            Action <HorizontalSplit> ApplyStyle =
                t =>
            {
                t.Split.Splitter.style.backgroundColor = Color.None;
                t.SplitImageContainer.Orphanize();
                t.SplitArea.Target.style.borderLeft  = "0";
                t.SplitArea.Target.style.borderRight = "0";
                t.SplitArea.Target.style.width       = "6px";
                t.SplitArea.Target.style.Opacity     = 0.7;

                // should we obselete JSColor already?
                t.SelectionColor = JSColor.Black;
            };

            var EditorTreeSplit = new HorizontalSplit
            {
                Minimum = 0,
                Maximum = 1,
                Value   = 0.7,
            };

            EditorTreeSplit.With(ApplyStyle);

            EditorTreeSplit.Split.Splitter.style.backgroundColor = Color.None;


            EditorTreeSplit.Container.AttachTo(Workspace);



            var Split = new HorizontalSplit
            {
                Minimum = 0,
                Maximum = 1,
                Value   = 0.3,
            };

            Split.With(ApplyStyle);

            Split.Split.Splitter.style.backgroundColor = Color.None;

            EditorTreeSplit.LeftContainer = Split.Container;



            var SolutionToolbox = new SolutionDockWindowPage();

            SolutionToolbox.HeaderText.innerText          = "Toolbox";
            SolutionToolbox.Content.style.backgroundColor = Color.White;
            SolutionToolbox.Content.style.padding         = "2px";
            SolutionToolbox.Content.style.overflow        = IStyle.OverflowEnum.auto;
            SolutionToolbox.Content.Clear();


            var vv = new SolutionToolboxListView();

            vv.Container.style.color = Color.Black;
            //vv.Container.AttachTo(SolutionToolbox.Content);

            var items = new StockToolboxTabsForHTMLDocument();

            // jsc market components

            vv.Add(
                new SolutionToolboxListViewTab
            {
                DataType = "DataTable",

                Name  = "DataTable",
                Title = "DataTable",
                Text  = "DataTable",
                Icon  = new DataTableImage()
            }
                );

            vv.Add(
                new SolutionToolboxListViewTab
            {
                DataType = "SpiralDataType",

                Name  = "Spiral1",
                Title = "Spiral",
                Text  = "Spiral",
                Icon  = new Spiral()
            }
                );

            // can we drag this into
            // code ?
            // msvs gets the image link
            //http://192.168.43.252:11924/assets/ScriptCoreLib.Ultra.Components/StockToolboxImageTransparent64.png?data-jsc-type=DAETruck
            vv.Add(
                new SolutionToolboxListViewTab
            {
                DataType = "DAETruck",

                Name  = "DAETruck",
                Title = "DAETruck",
                Text  = "DAETruck",
                Icon  = new DAETruck()
            }
                );

            vv.Add(
                new SolutionToolboxListViewTab
            {
                DataType = "WebGLEarthByBjorn",

                Name  = "WebGLEarthByBjorn",
                Title = "WebGLEarthByBjorn",
                Text  = "WebGLEarthByBjorn",
                Icon  = new WebGLEarthByBjorn()
            }
                );


            items.WithEach(vv.Add);



            var Viewer = new SolutionDocumentViewer();
            SolutionDocumentViewerTab File7Tab = "Design/App.htm";

            Viewer.Add(File7Tab);

            #region OutputFile
            var OutputFile       = new SolutionFile();
            var OutputFileViewer = new SolutionFileView();

            // fullscreen! :)
            OutputFileViewer.Container.style.height = "100%";

            OutputFile.IndentStack.Push(
                delegate
            {
                OutputFile.Write(SolutionFileTextFragment.Comment, "" + DateTime.Now);
                OutputFile.WriteSpace();
            }
                );

            Action <string> OutputWriteLine =
                n =>
            {
                // Would we want to rewire System.Out? Console.WriteLine?
                OutputFile.WriteIndent();
                OutputFile.WriteLine(n);

                // we could have a resume feature? now we just go and clear...
                OutputFileViewer.File = OutputFile;
            };


            OutputWriteLine("studio.jsc-solutions.net ready!");
            #endregion

            SolutionDocumentViewerTab OutputTab = "Output";
            Viewer.Add(OutputTab);
            OutputTab.TabElement.style.Float = IStyle.FloatEnum.right;


            SolutionDocumentViewerTab AboutTab = "Project";
            Viewer.Add(AboutTab);
            AboutTab.TabElement.style.Float = IStyle.FloatEnum.right;


            var CurrentDesigner = new SolutionFileDesigner();



            var HTMLDesigner = new SolutionFileDesignerHTMLElementTabs();

            CurrentDesigner.Add(HTMLDesigner);


            // undoable?
            var sln = new SolutionBuilder();



            #region CodeSourceA
            var CodeSourceATab =
                new SolutionFileDesignerTab
            {
                Image = new RTA_mode_html(),
                Text  = "Generated Code"
            };

            var CodeSourceAView = new SolutionFileView();

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

            CodeSourceAView.Container.style.display = IStyle.DisplayEnum.none;
            CodeSourceAView.Container.AttachTo(CurrentDesigner.Content);

            CodeSourceATab.Deactivated +=
                delegate
            {
                CodeSourceAView.Container.style.display = IStyle.DisplayEnum.none;
            };

            CodeSourceATab.Activated +=
                delegate
            {
                HTMLDesigner.HTMLDesignerContent.WhenContentReady(
                    body =>
                {
                    var CodeSourceFile = new SolutionFile
                    {
                        Name = "Default.htm"
                    };

                    var Type = new SolutionProjectLanguageType
                    {
                        Comments    = new SolutionFileComment[] { "This type was generated from the HTML file." },
                        Namespace   = sln.Name + ".HTML.Pages",
                        Name        = "IDefaultPage",
                        IsInterface = true,
                    };

                    (from n in body.AsXElement().DescendantsAndSelf()
                     let id = n.Attribute("id")
                              where id != null
                              select new { n, id }
                    ).WithEach(
                        k =>
                    {
                        Type.Properties.Add(
                            new KnownStockTypes.ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement().ToAutoProperty(k.id.Value)
                            );
                    }
                        );

                    sln.Language.WriteType(CodeSourceFile, Type, null);

                    CodeSourceAView.File = CodeSourceFile;

                    CodeSourceAView.Container.style.display = IStyle.DisplayEnum.empty;
                }
                    );
            };


            #endregion


            #region CodeSourceB
            var CodeSourceBTab =
                new SolutionFileDesignerTab
            {
                Image = new RTA_mode_html(),
                // all source code, not just html?
                Text = "Source"
            };

            var CodeSourceBView = new SolutionFileView();

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

            CodeSourceBView.Container.style.display = IStyle.DisplayEnum.none;
            CodeSourceBView.Container.AttachTo(CurrentDesigner.Content);

            CodeSourceBTab.Deactivated +=
                delegate
            {
                CodeSourceBView.Container.style.display = IStyle.DisplayEnum.none;
            };

            CodeSourceBTab.Activated +=
                delegate
            {
                CodeSourceBView.Container.style.display = IStyle.DisplayEnum.empty;
            };


            #endregion

            #region CodeSourceFormsDesignerTab
            var CodeSourceFormsDesignerTab =
                new SolutionFileDesignerTab
            {
                Image = new RTA_mode_design(),
                // all source code, not just html?
                Text = "Designer"
            };


            var CodeSourceFormsDesignerTabView = new SolutionFileView();

            CodeSourceFormsDesignerTabView.Container.style.With(
                style =>
            {
                style.position = IStyle.PositionEnum.absolute;
                style.left     = "0px";
                style.right    = "0px";
                style.top      = "0px";
                style.bottom   = "0px";

                style.display = IStyle.DisplayEnum.none;
            }
                );

            new IHTMLDiv().With(
                div =>
            {
                div.style.position        = IStyle.PositionEnum.absolute;
                div.style.left            = "16px";
                div.style.top             = "16px";
                div.style.width           = "400px";
                div.style.height          = "300px";
                div.style.backgroundColor = Color.FromGray(0xe0);
                div.style.border          = "1px solid gray";
                div.AttachTo(CodeSourceFormsDesignerTabView.Container);
            }
                );


            CodeSourceFormsDesignerTabView.Container.AttachTo(CurrentDesigner.Content);

            CodeSourceFormsDesignerTab.Deactivated +=
                delegate
            {
                CodeSourceFormsDesignerTabView.Container.style.display = IStyle.DisplayEnum.none;
            };

            CodeSourceFormsDesignerTab.Activated +=
                delegate
            {
                CodeSourceFormsDesignerTabView.Container.style.display = IStyle.DisplayEnum.empty;
            };


            #endregion

            CurrentDesigner.Add(CodeSourceFormsDesignerTab);
            CurrentDesigner.Add(CodeSourceBTab);
            CurrentDesigner.Add(CodeSourceATab);



            var wLeftScrollable = new System.Windows.Forms.Form
            {
                BackColor  = global::System.Drawing.Color.White,
                Text       = "Toolbox",
                ControlBox = false,
                ShowIcon   = false,
                AutoScroll = true
            };

            vv.Container.AttachTo(
                wLeftScrollable.GetHTMLTargetContainer()
                );

            //wLeftScrollable.Show();

            Split.Split.LeftScrollable.style.zIndex = 0;
            wLeftScrollable.AttachFormTo(Split.Split.LeftScrollable);


            //wLeftScrollable.PopupInsteadOfClosing();

            //Split.Split.LeftScrollable = (IHTMLDiv)(object)SolutionToolbox.body;
            Split.Split.RightScrollable = Viewer.Container;

            // ...



            #region dynamic content
            Func <IEnumerable <XElement> > GetPages = delegate
            {
                return(from n in sln.ApplicationPage.DescendantsAndSelf()
                       let type = n.Attribute(SolutionBuilderInteractive.DataTypeAttribute)
                                  where type != null
                                  let id = n.Attribute("id")
                                           where id != null
                                           select n);
            };

            sln.Interactive.GenerateApplicationExpressions +=
                Add =>
            {
                // page.PageContainer.ReplaceWith(
                GetPages().WithEach(
                    k =>
                {
                    var id = k.Attribute("id").Value;

                    if (id == "Page1")
                    {
                        Add(
                            new StockReplaceWithNewPageExpression(id)
                            );
                    }

                    if (id == "UserControl1")
                    {
                        Add(
                            new StockReplaceWithNewUserControlExpression(sln.Name + ".Components", id)
                            );
                    }

                    if (id == "Applet1")
                    {
                        Add(
                            new StockReplaceWithNewAppletExpression(sln.Name + ".Components", id)
                            );
                    }

                    if (id == "Sprite1")
                    {
                        Add(
                            new StockReplaceWithNewSpriteExpression(sln.Name + ".Components", id)
                            );
                    }

                    if (id == "AppletUserControl1")
                    {
                        Add(
                            new StockReplaceWithNewAppletExpression(sln.Name + ".Components", id)
                            );
                    }
                }
                    );
            };

            sln.Interactive.GenerateHTMLFiles +=
                Add =>
            {
                GetPages().WithEach(
                    k =>
                {
                    var id = k.Attribute("id").Value;

                    if (id == "Page1")
                    {
                        var __Content = new XElement(StockPageDefault.Page);


                        __Content.Element("head").Element("title").Value = id;

                        Add(
                            new SolutionProjectHTMLFile
                        {
                            Name    = "Design/" + id + ".htm",
                            Content = __Content
                        }
                            );
                    }
                }
                    );
            };

            sln.Interactive.GenerateTypes +=
                Add =>
            {
                GetPages().WithEach(
                    k =>
                {
                    var id = k.Attribute("id").Value;

                    if (id == "UserControl1")
                    {
                        Add(
                            new StockUserControlType(sln.Name + ".Components", id)
                            );
                    }

                    if (id == "Applet1")
                    {
                        Add(
                            new StockAppletType(sln.Name + ".Components", id)
                            );
                    }

                    if (id == "Sprite1")
                    {
                        Add(
                            new StockSpriteType(sln.Name + ".Components", id)
                            );
                    }

                    if (id == "AppletUserControl1")
                    {
                        var UserControl2 = new StockUserControlType(sln.Name + ".Components", "UserControl2");

                        Add(
                            UserControl2
                            );

                        Add(
                            new StockUserControlAppletType(sln.Name + ".Components", id, UserControl2)
                            );
                    }
                }
                    );
            };
            #endregion


            var _Solution = new TreeNode(VistaTreeNodePage.Create);


            var _Project = _Solution.Add();

            var About = new About();

            #region UpdateFile1Text
            Action UpdateFile1Text =
                delegate
            {
                if (CodeSourceBView.File != null)
                {
                    File7Tab.Text = CodeSourceBView.File.Name.SkipUntilLastIfAny("/");
                }
                else
                {
                    File7Tab.Text = sln.Name;
                }
            };
            #endregion



            #region Update
            Action Update =
                delegate
            {
                sln.Name = About.ProjectName.value;

                UpdateFile1Text();

                _Project.Clear();
                UpdateTree(sln, CodeSourceBView, _Solution, _Project);
            };
            #endregion


            var PreviousVersion = default(string);

            #region HTMLDesigner.HTMLDesignerContent
            HTMLDesigner.HTMLDesignerContent.WhenContentReady(
                body =>
            {
                if (PreviousVersion == null)
                {
                    var x           = new XElement(body.AsXElement());
                    var y           = x.ToString();
                    PreviousVersion = y;
                }

                Action <bool> HTMLDesignerContentCheck =
                    DoUpdate =>
                {
                    var x = new XElement(body.AsXElement());
                    var y = x.ToString();

                    if (PreviousVersion != y)
                    {
                        PreviousVersion = y;


                        sln.ApplicationPage = x;

                        // allow any blur causing action to complete first
                        // we get reselected for some odd reason, why?
                        new Timer(
                            delegate
                        {
                            if (DoUpdate)
                            {
                                OutputWriteLine("Designer has caused an update.");
                                Update();
                            }
                            else
                            {
                                OutputWriteLine("Designer will cause an update.");
                            }
                        }
                            ).StartTimeout(700);
                    }
                };

                var HTMLDesignerContentDirty = new Timer(
                    delegate
                {
                    HTMLDesignerContentCheck(false);
                }
                    );

                HTMLDesigner.HTMLDesignerContent.contentWindow.onfocus +=
                    delegate
                {
                    OutputWriteLine("Designer activated.");
                    //"focus".ToDocumentTitle();

                    //HTMLDesignerContentDirty.StartInterval(700);
                };

                HTMLDesigner.HTMLDesignerContent.contentWindow.onblur +=
                    delegate
                {
                    //HTMLDesignerContentDirty.Stop();

                    OutputWriteLine("Designer deactivated.");
                    //"blur".ToDocumentTitle();
                    HTMLDesignerContentCheck(true);
                };
            }
                );
            #endregion

            #region CodeSourceBView.FileChanged
            CodeSourceBView.FileChanged +=
                delegate
            {
                UpdateFile1Text();


                OutputWriteLine("Select: " + CodeSourceBView.File.Name);

                CodeSourceFormsDesignerTab.TabElement.Hide();

                // hack :)
                if (CodeSourceBView.File.Name.EndsWith("/App.htm"))
                {
                    // currently we only have one element :)

                    HTMLDesigner.HTMLDesignerTab.RaiseActivated();

                    HTMLDesigner.HTMLDesignerTab.TabElement.style.display = IStyle.DisplayEnum.inline_block;
                    HTMLDesigner.HTMLSourceTab.TabElement.style.display   = IStyle.DisplayEnum.none;
                    CodeSourceATab.TabElement.style.display = IStyle.DisplayEnum.inline_block;
                    CodeSourceBTab.TabElement.style.display = IStyle.DisplayEnum.inline_block;

                    HTMLDesigner.HTMLDesignerContent.WhenContentReady(
                        body =>
                    {
                        HTMLDesigner.HTMLDesignerContent.contentWindow.focus();
                    }
                        );

                    // show the design/source buttons
                }
                else if (CodeSourceBView.File.Name.EndsWith(".sln"))
                {
                    AboutTab.Activate();
                }
                else if (CodeSourceBView.File.Name.EndsWith(sln.Language.ProjectFileExtension))
                {
                    AboutTab.Activate();
                }
                else if (CodeSourceBView.File.Name.EndsWith(sln.Language.CodeFileExtension))
                {
                    // show type outline / member
                    CodeSourceBTab.RaiseActivated();

                    HTMLDesigner.HTMLDesignerTab.TabElement.style.display = IStyle.DisplayEnum.none;
                    HTMLDesigner.HTMLSourceTab.TabElement.style.display   = IStyle.DisplayEnum.none;
                    CodeSourceATab.TabElement.style.display = IStyle.DisplayEnum.none;
                    CodeSourceBTab.TabElement.style.display = IStyle.DisplayEnum.inline_block;

                    CodeSourceBView.File.ContextType.BaseType.With(
                        BaseType =>
                    {
                        if (BaseType is KnownStockTypes.System.Windows.Forms.UserControl)
                        {
                            CodeSourceFormsDesignerTab.TabElement.Show();
                            CodeSourceFormsDesignerTab.RaiseActivated();
                        }

                        if (BaseType is KnownStockTypes.System.ComponentModel.Component)
                        {
                            CodeSourceFormsDesignerTab.TabElement.Show();
                            CodeSourceFormsDesignerTab.RaiseActivated();
                        }
                    }
                        );
                }
            };
            #endregion


            //AddSaveButton(WorkspaceHeader, i => Save = i);

            About.ProjectName.value     = sln.Name;
            About.ProjectName.onchange +=
                delegate
            {
                OutputWriteLine("Project name has changed.");
                Update();
            };



            Viewer.Content.Clear();
            Viewer.Content.Add(About.Container);
            Viewer.Content.Add(CurrentDesigner.Container);
            Viewer.Content.Add(OutputFileViewer.Container);

            AboutTab.WhenActivated(About.Container);
            File7Tab.WhenActivated(CurrentDesigner.Container);
            OutputTab.WhenActivated(OutputFileViewer.Container);



            Viewer.First().Activate();

            //var SolutionExplorer = new SolutionDockWindowPage();

            //SolutionExplorer.HeaderText.innerText = "Solution Explorer";
            //SolutionExplorer.Content.style.backgroundColor = Color.White;
            //SolutionExplorer.Content.style.padding = "2px";
            //SolutionExplorer.Content.ReplaceContentWith(_Solution.Container);


            var fSolutionExplorer = new System.Windows.Forms.Form
            {
                BackColor  = global::System.Drawing.Color.White,
                Text       = "Solution Explorer",
                ControlBox = false,
                ShowIcon   = false
            };

            EditorTreeSplit.Split.RightScrollable.style.zIndex   = 0;
            EditorTreeSplit.Split.RightScrollable.style.position = IStyle.PositionEnum.relative;

            fSolutionExplorer.AttachFormTo(EditorTreeSplit.Split.RightScrollable);

            _Solution.Container.AttachTo(fSolutionExplorer.GetHTMLTargetContainer());

            _Solution.Container.style.overflow        = IStyle.OverflowEnum.auto;
            _Solution.Container.style.height          = "100%";
            _Solution.Container.style.backgroundColor = Color.White;

            //EditorTreeSplit.Split.RightContainer = (IHTMLDiv)(object)SolutionExplorer.Container;

            EditorTreeSplit.Container.AttachTo(Workspace);

            //CurrentDesigner.First().RaiseActivated();

            Update();

            #region CreateLanguageButton
            Action <IHTMLImage, string, SolutionProjectLanguage, string> CreateLanguageButton =
                (Icon, Text, Language, Name) =>
            {
                var span = new IHTMLSpan(Text);

                span.style.marginLeft  = "0.7em";
                span.style.marginRight = "0.7em";

                new IHTMLButton {
                    Icon                   /*, span */
                }.AttachTo(WorkspaceHeaderTab1).With(
                    btn =>
                {
                    btn.onclick +=
                        delegate
                    {
                        sln.Language = Language;
                        sln.Name     = Language.LanguageSpelledName.Replace(" ", "") + "Project1";
                        Update();
                    };

                    //btn.style.display = IStyle.DisplayEnum.block;
                }
                    );
            };
            #endregion


            CreateLanguageButton(new VisualCSharpProject(), "C#", KnownLanguages.VisualCSharp, "VisualCSharpProject1");
            CreateLanguageButton(new VisualFSharpProject(), "F#", KnownLanguages.VisualFSharp, "VisualFSharpProject1");
            CreateLanguageButton(new VisualBasicProject(), "Visual Basic", KnownLanguages.VisualBasic, "VisualBasicProject1");

            var ListOfCreateProjectTypeButton = new List <IHTMLButton>();

            #region CreateProjectTypeButton
            Action <string, Action> CreateProjectTypeButton =
                (Text, Handler) =>
            {
                var span = new IHTMLSpan(Text);

                span.style.marginLeft  = "0.7em";
                span.style.marginRight = "0.7em";

                new IHTMLButton {
                    span
                }.AttachTo(WorkspaceHeaderTab2).With(
                    btn =>
                {
                    ListOfCreateProjectTypeButton.Add(btn);

                    btn.onclick +=
                        delegate
                    {
                        ListOfCreateProjectTypeButton.WithEach(n => n.disabled = true);

                        Handler();
                    };

                    //btn.style.display = IStyle.DisplayEnum.block;
                }
                    );
            };
            #endregion

            #region ToSpecificProjectType
            Action <string, Action> ToSpecificProjectType =
                (Text, Handler) =>
            {
                CreateProjectTypeButton(Text,
                                        delegate
                {
                    Handler();


                    HTMLDesigner.HTMLDesignerContent.WhenDocumentReady(
                        document =>
                    {
                        document.WithContent(sln.ApplicationPage);
                        // we should now also lock the designer!
                        document.DesignMode = false;
                    }
                        );

                    Update();
                }
                                        );
            };
            #endregion

            #region Avalon, Forms
            ToSpecificProjectType("Avalon App",
                                  delegate
            {
                sln.WithCanvas();
            }
                                  );


            ToSpecificProjectType("Avalon Flash App",
                                  delegate
            {
                sln.WithCanvasAdobeFlash();
            }
                                  );

            ToSpecificProjectType("Forms App",
                                  delegate
            {
                sln.WithForms();
            }
                                  );


            ToSpecificProjectType("Forms Applet App",
                                  delegate
            {
                sln.WithFormsApplet();
            }
                                  );
            #endregion

            ToSpecificProjectType("Flash App",
                                  delegate
            {
                sln.WithAdobeFlash();
            }
                                  );

            ToSpecificProjectType("Flash Camera App",
                                  delegate
            {
                sln.WithAdobeFlashCamera();
            }
                                  );

            ToSpecificProjectType("Flash Flare3D App",
                                  delegate
            {
                sln.WithAdobeFlashWithFlare3D();
            }
                                  );

            ToSpecificProjectType("Applet App",
                                  delegate
            {
                sln.WithJavaApplet();
            }
                                  );
        }
Exemplo n.º 25
0
        public __TextBox()
        {
            #region InternalContainer
            //this.InternalContainer = new IHTMLDiv();
            this.InternalContainer = new IHTMLElement(ElementName);

            // are we excluding older browsers? does the app analyzer let the developer know what devices can be used now?
            this.InternalContainer_shadow = this.InternalContainer.createShadowRoot();
            // if we only create shadow, empty, other children dissapear dont they. as there are no insertion points

            this.InternalContainer.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;

            // in Forms we use typeof() because we see Component. WPF objects are more like XElements..
            this.InternalContainer.name = "__TextBox";

            this.InternalContainer.style.left = "0px";
            this.InternalContainer.style.top  = "0px";

            // do we create any new havoc?
            this.InternalContainer.style.zIndex = 0;
            #endregion


            #region InternalTextField_ShadowContainer

            // when is it attached?
            this.InternalTextField_ShadowContainer = new IHTMLDiv();


            this.InternalTextField_ShadowContainer.style.position = IStyle.PositionEnum.absolute;
            this.InternalTextField_ShadowContainer.style.overflow = IStyle.OverflowEnum.hidden;
            this.InternalTextField_ShadowContainer.style.SetSize(0, 0);

            this.InternalTextField_Shadow = new IHTMLSpan();
            this.InternalTextField_Shadow.AttachTo(this.InternalTextField_ShadowContainer);
            this.InternalTextField_Shadow.style.whiteSpace = IStyle.WhiteSpaceEnum.pre;
            this.InternalTextField_Shadow.style.display    = IStyle.DisplayEnum.inline_block;
            this.InternalTextField_Shadow.style.position   = IStyle.PositionEnum.absolute;
            #endregion

            #region InternalTextField
            this.InternalTextField = new IHTMLInput(ScriptCoreLib.Shared.HTMLInputTypeEnum.text)
            {
                //}.AttachTo(this.InternalContainer);
                // public static T AttachTo<T>(this T e, IHTMLElement c) where T : INodeConvertible<IHTMLElement>;
            }.AttachTo(this.InternalContainer_shadow);

            this.InternalSetDefaultFont();

            this.InternalTextField.style.position      = IStyle.PositionEnum.absolute;
            this.InternalTextField.style.margin        = "0";
            this.InternalTextField.style.paddingTop    = "0";
            this.InternalTextField.style.paddingBottom = "0";
            this.InternalTextField.style.border        = "1px solid gray";
            #endregion


            Action InternalAutoSizeUpdate =
                delegate
            {
                if (this.InternalTextField_Shadow == null)
                {
                    return;
                }

                InternalAutoSizeToText(this.InternalTextField.value);
            };

            this.InternalTextField.onchange +=
                delegate
            {
                InternalAutoSizeUpdate();
            };

            this.InternalTextField.onkeyup +=
                delegate
            {
                InternalAutoSizeUpdate();
            };
        }
Exemplo n.º 26
0
        /// <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)
        {
            // X:\jsc.svn\examples\javascript\async\AsyncWindowUncaughtError\AsyncWindowUncaughtError\ApplicationWebService.cs

            // intellitrace
            // a self debugging programe?
            // can we have buttons for debugging?
            // https://www.youtube.com/watch?v=4vtKRE9an_I
            // could we have live patching, remote debugging via udp?

            var Next = new IHTMLButton {
                "Next"
            }.AttachToDocument();

            Next.disabled = true;

            Func <Task> Next_onclick = async delegate
            {
                Next.disabled = false;
                await Next.async.onclick;
                Next.disabled = true;
            };

            trace trace = async(string filepath, int linenumber, string line) =>
            {
                // could we go backwards in time too?
                // like intellitrace?

                var debugged = new IHTMLPre {
                }.AttachToDocument();



                // should we allow chaning constants?
                // by patching const load opcodes?

                var l = new IHTMLSpan {
                    "" + linenumber
                }.AttachToDocument();



                l.title = filepath;

                l.style.marginRight = "2em";
                l.style.color       = "darkcyan";

                l.AttachTo(debugged);

                // could we use css to do syntax highlight?
                var prefixToHide = "await trace();";

                // perhaps the next step would be to send us the origina stack usage IL
                // we see in the jsc reflector?
                var c = new IHTMLSpan {
                    line.Replace(prefixToHide, "")
                };

                c.style.marginRight = "2em";
                //c.style.color = "blue";
                c.style.backgroundColor = "yellow";

                c.AttachTo(debugged);

                await Next_onclick();

                c.style.backgroundColor = "";
            };

            interactive <string> __string = async(string data, string filepath, int linenumber, string line) =>
            {
                var i = new IHTMLInput {
                    value = data
                }.AttachToDocument();

                await Next_onclick();

                return(i.value);
            };


            //Func<>
            Func <string, Task <string> > program =
                // a simulaton of a program
                async data =>
            {
                await trace(); new IHTMLPre {
                    await __string("hello")
                }.AttachToDocument();
                await trace(); new IHTMLPre {
                    await __string("world")
                }.AttachToDocument();


                await trace(); return("done!");
            };

            new IHTMLButton {
                "Step Into"
            }.AttachToDocument().onclick +=
                async e =>
            {
                new IHTMLHorizontalRule().AttachToDocument();

                e.Element.disabled = true;
                var value = await program("data");

                e.Element.disabled = false;

                new IHTMLPre {
                    new { value }
                }.AttachToDocument();
            };


            new IHTMLButton {
                "Run"
            }.AttachToDocument().onclick +=
                async e =>
            {
                // enum to string?
                new IHTMLHorizontalRule().AttachToDocument();

                var x = Next_onclick;
                // slow down the program
                Next_onclick = async delegate { await Task.Delay(300); };


                e.Element.disabled = true;
                var value = await program("data");

                e.Element.disabled = false;

                Next_onclick = x;

                new IHTMLPre {
                    new { value }
                }.AttachToDocument();
            };
        }
Exemplo n.º 27
0
        public SectionConcept(T Target, IHTMLImage TreeExpand, IHTMLImage TreeCollapse)
        {
            this.Target = Target;

            Content = new IHTMLDiv
            {
                Target.Content.childNodes
            };

            Header = new IHTMLSpan
            {
                Target.Header.childNodes
            };

            var Icon = new IHTMLSpan
            {
                TreeExpand,
                TreeCollapse
            };

            Icon.style.marginRight = "1em";

            Icon.AttachTo(Target.Header);
            Header.AttachTo(Target.Header);

            Content.AttachTo(Target.Content);

            Target.Header.style.cursor = ScriptCoreLib.JavaScript.DOM.IStyle.CursorEnum.pointer;



            TreeExpand.Hide();



            Action onclick = delegate { };

            Target.Header.onclick +=
                delegate
            {
                onclick();
            };


            this.NextClickHide =
                delegate
            {
                InternalIsExpanded = false;

                Target.Content.Hide();
                TreeExpand.Show();
                TreeCollapse.Hide();

                onclick = NextClickShow;
            };

            this.NextClickShow =
                delegate
            {
                InternalIsExpanded = true;

                Target.Content.Show();
                TreeExpand.Hide();
                TreeCollapse.Show();

                onclick = NextClickHide;
            };


            onclick = NextClickHide;
        }
Exemplo n.º 28
0
        public __TextBoxBase()
        {
            #region InternalContainer
            this.InternalContainer = new IHTMLDiv();

            this.InternalContainer.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
            this.InternalContainer.name           = "__TextBox";

            this.InternalContainer.style.left = "0px";
            this.InternalContainer.style.top  = "0px";

            // do we create any new havoc?
            this.InternalContainer.style.zIndex = 0;
            #endregion


            #region InternalTextField_ShadowContainer
            this.InternalTextField_ShadowContainer = new IHTMLDiv();


            this.InternalTextField_ShadowContainer.style.position = IStyle.PositionEnum.absolute;
            this.InternalTextField_ShadowContainer.style.overflow = IStyle.OverflowEnum.hidden;
            this.InternalTextField_ShadowContainer.style.SetSize(0, 0);

            this.InternalTextField_Shadow = new IHTMLSpan();
            this.InternalTextField_Shadow.AttachTo(this.InternalTextField_ShadowContainer);
            this.InternalTextField_Shadow.style.whiteSpace = IStyle.WhiteSpaceEnum.pre;
            this.InternalTextField_Shadow.style.display    = IStyle.DisplayEnum.inline_block;
            this.InternalTextField_Shadow.style.position   = IStyle.PositionEnum.absolute;
            #endregion

            #region InternalTextField
            this.InternalTextField = new IHTMLInput(ScriptCoreLib.Shared.HTMLInputTypeEnum.text)
            {
            }.AttachTo(this.InternalContainer);

            // boxstyle. will it break layout?
            this.InternalTextField.style.padding = "0.4em";

            //Need to test/document
            this.InternalNameChanged += delegate
            {
                this.InternalTextField.name = InternalName;
                if (InternalName.ToUpper().Contains(("email").ToUpper()))
                {
                    this.InternalTextField.type = Shared.HTMLInputTypeEnum.email;
                }
                if (InternalName.ToUpper().Contains(("phone").ToUpper()))
                {
                    this.InternalTextField.type = Shared.HTMLInputTypeEnum.tel;
                }
            };

            this.InternalSetDefaultFont();

            this.InternalTextField.style.position      = IStyle.PositionEnum.absolute;
            this.InternalTextField.style.margin        = "0";
            this.InternalTextField.style.paddingTop    = "0";
            this.InternalTextField.style.paddingBottom = "0";

            // what about inheritance chain?
            // X:\jsc.svn\examples\javascript\forms\Test\CSSLastTextBox\CSSLastTextBox\Application.cs
            IStyleSheet.all[typeof(TextBox)][IHTMLElement.HTMLElementEnum.input].style.border = "1px solid gray";
            #endregion

            // what about padding?
            // X:\jsc.svn\examples\javascript\forms\Test\TestTextBoxPadding\TestTextBoxPadding\Application.cs
            // http://stackoverflow.com/questions/628500/can-i-stop-100-width-text-boxes-from-extending-beyond-their-containers/628912#628912

            //box-sizing: border-box;
            (this.InternalTextField.style as dynamic).boxSizing = "border-box";
            //this.InternalTextField.style.boxSizing = "border-box";
            this.InternalTextField.style.width  = "100%";
            this.InternalTextField.style.height = "100%";

            //this.ClientSizeChanged +=
            //    delegate
            //    {
            //        this.InternalTextField.style.width = this.ClientSize.Width + "px";
            //        this.InternalTextField.style.height = this.ClientSize.Height + "px";
            //    };

            #region InternalRaiseTextChanged
            Action InternalAutoSizeUpdate =
                delegate
            {
                if (this.InternalTextField_Shadow == null)
                {
                    return;
                }

                //InternalAutoSizeToText(this.InternalTextField.value);
            };

            this.InternalTextField.onchange +=
                delegate
            {
                InternalAutoSizeUpdate();
                this.InternalRaiseTextChanged();
            };

            this.InternalTextField.onkeyup +=
                delegate
            {
                InternalAutoSizeUpdate();
                this.InternalRaiseTextChanged();
            };
            #endregion



            this.Size = new global::System.Drawing.Size(100, 20);
        }
        public MatrixTransformBExample()
        {
            var x = 400;
            var y = 200;
            var w = 200;
            var h = 200;

            var ro_matrix = new IHTMLDiv();

            ro_matrix.style.backgroundColor = "#8080ff";
            ro_matrix.style.SetLocation(x, y);
            ro_matrix.AttachToDocument();
            //ro_matrix.style.paddingLeft = w + "px";
            //ro_matrix.style.paddingTop = h + "px";
            var ro_matric_content = new IHTMLDiv();

            ro_matric_content.style.backgroundColor = "#0000ff";
            ro_matric_content.style.SetSize(w, h);
            ro_matric_content.AttachTo(ro_matrix);


            var r_matrix = new IHTMLDiv();

            r_matrix.style.backgroundColor = "#80ff80";
            r_matrix.style.SetLocation(x, y);
            r_matrix.AttachToDocument();

            //r_matrix.style.paddingLeft = w + "px";
            //r_matrix.style.paddingTop = h + "px";
            var r_matric_content = new IHTMLDiv();

            r_matric_content.style.backgroundColor = "#00ff00";
            r_matric_content.style.SetSize(w, h);
            r_matric_content.AttachTo(r_matrix);


            #region blue rotation
            var jo = new IHTMLDiv();

            jo.style.background = "blue";
            jo.style.SetLocation(x - w / 2 - 4, y - h / 2 - 1, 8, 2);

            jo.AttachToDocument();

            var joh = new IHTMLDiv();

            joh.style.background = "blue";
            joh.style.SetLocation(x - w / 2 - 1, y - h / 2 - 4, 2, 8);

            joh.AttachToDocument();

            jo.BlinkAt(400);
            joh.BlinkAt(400);
            #endregion

            #region black origin
            var zo = new IHTMLDiv();

            zo.style.background = "black";
            zo.style.SetLocation(x - 4, y - 1, 8, 2);

            zo.AttachToDocument();

            var zoh = new IHTMLDiv();

            zoh.style.background = "black";
            zoh.style.SetLocation(x - 1, y - 4, 2, 8);

            zoh.AttachToDocument();
            #endregion



            var ro = new IHTMLDiv();

            ro.style.background = "red";
            ro.style.SetLocation(x, y, w, h);
            ro.style.Opacity = 0.3;
            ro.AttachToDocument();



            var info = new IHTMLSpan {
                innerText = "MatrixTransform"
            };


            info.style.SetLocation(x, y + h, w, h);

            info.AttachToDocument();

            var at = new IHTMLDiv();

            at.style.background = "yellow";
            at.style.SetLocation(x - w / 2, y - h / 2, w * 2, h * 2);
            at.style.Opacity = 0.5;
            at.AttachToDocument();



            var r = new IHTMLDiv();

            r.style.background = "black";
            r.style.SetLocation(x, y, w, h);
            r.style.Opacity = 0.3;

            r.AttachToDocument();
            r.style.cursor = IStyle.CursorEnum.pointer;

            #region blue origin
            var o = new IHTMLDiv();

            o.style.background = "blue";
            o.style.SetLocation(x + w / 2 - 4, y + h / 2 - 1, 8, 2);

            o.AttachToDocument();

            var oh = new IHTMLDiv();

            oh.style.background = "blue";
            oh.style.SetLocation(x + w / 2 - 1, y + h / 2 - 4, 2, 8);

            oh.AttachToDocument();
            #endregion



            #region black rotation
            var jzo = new IHTMLDiv();

            jzo.style.background = "black";
            jzo.style.SetLocation(x - w / 2 - 4, y - h / 2 - 1, 8, 2);

            jzo.AttachToDocument();

            var jzoh = new IHTMLDiv();

            jzoh.style.background = "black";
            jzoh.style.SetLocation(x - w / 2 - 1, y - h / 2 - 4, 2, 8);

            jzoh.AttachToDocument();


            jzo.BlinkAt(400);
            jzoh.BlinkAt(400);
            #endregion


            var m = new MatrixModifiers();

            var InteractiveSetOrigin_x = 0;
            var InteractiveSetOrigin_y = 0;

            var InteractiveSetRotation_x = 0;
            var InteractiveSetRotation_y = 0;


            Action <int, int> InteractiveSetRotation = null;

            Action <int, int> SetPadding =
                (ox, oy) =>
            {
                // -0 ... -w

                ox += w / 2;
                oy += h / 2;

                info.innerText = "padding x: " + ox + " y:" + oy;

                if (ox > 0)
                {
                    ro_matrix.style.paddingLeft  = ox * 2 + "px";
                    ro_matrix.style.paddingRight = 0 + "px";
                }
                else
                {
                    ro_matrix.style.paddingLeft  = 0 + "px";
                    ro_matrix.style.paddingRight = ox * -2 + "px";
                }

                if (oy > 0)
                {
                    ro_matrix.style.paddingTop    = oy * 2 + "px";
                    ro_matrix.style.paddingBottom = 0 + "px";
                }
                else
                {
                    ro_matrix.style.paddingTop    = 0 + "px";
                    ro_matrix.style.paddingBottom = oy * -2 + "px";
                }



                if (ox > 0)
                {
                    r_matrix.style.paddingLeft  = ox * 2 + "px";
                    r_matrix.style.paddingRight = 0 + "px";
                }
                else
                {
                    r_matrix.style.paddingLeft  = 0 + "px";
                    r_matrix.style.paddingRight = ox * -2 + "px";
                }

                if (oy > 0)
                {
                    r_matrix.style.paddingTop    = oy * 2 + "px";
                    r_matrix.style.paddingBottom = 0 + "px";
                }
                else
                {
                    r_matrix.style.paddingTop    = 0 + "px";
                    r_matrix.style.paddingBottom = oy * -2 + "px";
                }
            };

            m.Visual1.CheckedChanged +=
                delegate
            {
                r_matrix.Show(m.Visual1.Checked);
            };

            m.Visual2.CheckedChanged +=
                delegate
            {
                ro_matrix.Show(m.Visual2.Checked);
            };

            m.Debug1.CheckedChanged +=
                delegate
            {
                if (m.Debug1.Checked)
                {
                    ro_matrix.style.backgroundColor = "#8080ff";
                    r_matrix.style.backgroundColor  = "#80ff80";

                    return;
                }

                ro_matrix.style.backgroundColor = "";
                r_matrix.style.backgroundColor  = "";
            };

            Action <int, int> InteractiveSetOrigin =
                (ox, oy) =>
            {
                var dx = InteractiveSetOrigin_x - ox;
                var dy = InteractiveSetOrigin_y - oy;

                InteractiveSetOrigin_x = ox;
                InteractiveSetOrigin_y = oy;

                SetPadding(ox, oy);

                m.TranslateX.Text = "" + ox;
                m.TranslateY.Text = "" + oy;

                ro.style.SetLocation(x + ox, y + oy, w, h);
                ro_matrix.style.SetLocation(x + ox, y + oy /*, w, h*/);
                o.style.SetLocation(x - ox - 4, y - oy - 1, 8, 2);
                oh.style.SetLocation(x - ox - 1, y - oy - 4, 2, 8);

                InteractiveSetRotation(InteractiveSetRotation_x + dx, InteractiveSetRotation_y + dy);
            };

            InteractiveSetRotation =
                (ox, oy) =>
            {
                InteractiveSetRotation_x = ox;
                InteractiveSetRotation_y = oy;

                var ax = x - w / 2 + ox;
                var ay = y - h / 2 + oy;

                var bx = x - InteractiveSetOrigin_x;
                var by = y - InteractiveSetOrigin_y;

                var dx = ax - bx;
                var dy = ay - by;

                var rotation         = Extensions.GetRotation(dx, dy);
                var rotation_degrees = rotation.RadiansToDegrees();

                var costheta = Math.Cos(rotation);
                var sintheta = Math.Sin(rotation);

                var M11 = costheta;
                var M12 = -sintheta;
                var M21 = sintheta;
                var M22 = costheta;

                m.M11.Text = "" + M11;
                m.M12.Text = "" + M12;
                m.M21.Text = "" + M21;
                m.M22.Text = "" + M22;

                info.innerText = "rotation: " + rotation_degrees + "° x: " + InteractiveSetOrigin_x + " y:" + InteractiveSetOrigin_y;
                //Native.Document.title = new { ax, bx, dx, rotation_degrees }.ToString();

                joh.style.SetLocation(ax - 1, y - h / 2 + oy - 4, 2, 8);
                jo.style.SetLocation(x - w / 2 + ox - 4, ay - 1, 8, 2);

                jzoh.style.SetLocation(x + InteractiveSetOrigin_x - w / 2 + ox - 1, y + InteractiveSetOrigin_y - h / 2 + oy - 4, 2, 8);
                jzo.style.SetLocation(x + InteractiveSetOrigin_x - w / 2 + ox - 4, y + InteractiveSetOrigin_y - h / 2 + oy - 1, 8, 2);

                var mm = new[]
                {
                    M11, M21,
                    M12, M22,

                    0, 0
                    //0.838670551776886,0.5446390509605408,-0.5446390509605408,0.838670551776886,0,0
                };

                var code = @"
			q.style.filter = ""progid:DXImageTransform.Microsoft.Matrix(M11='"" + m[0] + ""',M12='"" + m[2] + ""',M21='"" + m[1] + ""', M22='"" + m[3] + ""', sizingmethod='auto expand');"";
	
			q.style.MozTransform = ""matrix("" + m[0] + "","" + m[1] + "","" + m[2] + "","" + m[3] + "","" + m[4] + "","" + m[5] + "")"";
			
			q.style.WebkitTransform = ""matrix("" + m[0] + "","" + m[1] + "","" + m[2] + "","" + m[3] + "","" + m[4] + "","" + m[5] + "")"";
				"                ;

                new IFunction("q", "m", code).apply(null, r_matrix, mm);
                new IFunction("q", "m", code).apply(null, ro_matrix, mm);


                var r_matrix_adj_x = (r_matrix.clientWidth - r_matrix.offsetWidth) / 2;
                var r_matrix_adj_y = (r_matrix.clientHeight - r_matrix.offsetHeight) / 2;

                var ro_matrix_adj_x = (ro_matrix.clientWidth - ro_matrix.offsetWidth) / 2;
                var ro_matrix_adj_y = (ro_matrix.clientHeight - ro_matrix.offsetHeight) / 2;



                r_matrix.style.SetLocation(x + r_matrix_adj_x, y + r_matrix_adj_y /*, w, h*/);
                ro_matrix.style.SetLocation(x + InteractiveSetOrigin_x + ro_matrix_adj_x, y + InteractiveSetOrigin_y + ro_matrix_adj_y /*, w, h*/);
            };



            #region bind InteractiveSetRotation
            at.onclick +=
                e =>
            {
                InteractiveSetRotation(e.OffsetX, e.OffsetY);
            };

            at.onmousemove +=
                e =>
            {
                InteractiveSetRotation(e.OffsetX, e.OffsetY);
            };

            at.onmouseover +=
                delegate
            {
                info.innerText = "Click to set rotation";
            };

            InteractiveSetRotation(0, 0);
            #endregion

            #region bind InteractiveSetOrigin
            m.ButtonClear.Click +=
                delegate
            {
                InteractiveSetOrigin(0, 0);
            };

            r.onclick +=
                e =>
            {
                // 0 0 is top left

                InteractiveSetOrigin(-e.OffsetX, -e.OffsetY);
            };

            r.onmouseover +=
                delegate
            {
                if (m.Debug1.Checked)
                {
                    info.innerText = "Click to set padding";
                    return;
                }
                info.innerText = "Click to set origin";
            };


            #endregion

            //InteractiveSetOrigin(0, 0);
            InteractiveSetOrigin(-w / 2, -h / 2);

            var f = new Form {
                Text = "MatrixModifier"
            };

            m.BackColor = System.Drawing.Color.White;

            f.Controls.Add(m);
            f.ClientSize = m.Size;

            f.GetHTMLTarget().AttachToDocument();
        }
        public void Initialize(ExternalContext Context)
        {
            KnownMoviesFilter = e => true;

            //Context.Document.title = "2 token: " + Context.PrivateKey;

            // wtf? we cannot modify body without resetting our flash
            // http://dojotoolkit.org/forum/dojo-core-dojo-0-9/dojo-core-support/firefox-reloads-flash-when-portion-page-refreshed-using-a
            //Context.Document.body.style.overflow = "hidden";
            //Context.Document.body.style.backgroundColor = "black";
            //Context.Document.body.style.color = "white";

            #region ContainerForPosters
            var ContainerForPosters = new IHTMLDiv().AttachTo(Context);

            ContainerForPosters.style.position = "absolute";
            ContainerForPosters.style.width    = "100%";
            ContainerForPosters.style.height   = "100%";
            //ContainerForPosters.style.background = "black url('http://www.stripegenerator.com/generators/generate_stripes.php?fore=000000&h=30&w=6&p=7&back1=333333&back2=ff0000&gt=0&d=0&shadow=0&')";
            ContainerForPosters.style.backgroundColor = "black";
            ContainerForPosters.style.color           = "white";
            ContainerForPosters.style.textAlign       = "center";
            ContainerForPosters.style.overflow        = "auto";
            #endregion

            var PostersGroup = new IHTMLDiv().AttachTo(ContainerForPosters);
            var FooterGroup  = new IHTMLDiv().AttachTo(ContainerForPosters);

            var ButtonsOnRightEdge = new IHTMLSpan().AttachTo(Context);

            ButtonsOnRightEdge.style.Apply(
                s =>
            {
                s.position   = "absolute";
                s.marginLeft = "-8em";
                s.marginTop  = "-2em";
                s.top        = "100%";
                s.left       = "100%";
            }
                );

            ButtonsOnRightEdge.innerHTML =
                Info.GoogleGadget.AddImage.ToImageMiddle().ToLink(Info.GoogleGadget.AddToYourWebPageLink) + "&nbsp;" +
                Info.RSSImage.ToImageMiddle().ToLink(Info.BuzzBlogPost);

            var Toolbar = new IHTMLDiv
            {
                innerHTML = ""
            }.AttachTo(Context);


            Toolbar.style.Apply(
                s =>
            {
                s.position  = "absolute";
                s.marginTop = "-2em";
                s.top       = "100%";
                s.left      = "1em";
            }
                );

            #region ToggleScrollbar
            var ToggleScrollbar = new IHTMLSpan {
                innerHTML = "&raquo; toggle scrollbar"
            }.AttachTo(Toolbar);

            ToggleScrollbar.style.Apply(
                s =>
            {
                s.border          = "1px dotted white";
                s.cursor          = "pointer";
                s.backgroundColor = "black";
                s.color           = "white";
                s.marginLeft      = "1em";
            }
                );

            var ToggleScrollbarCounter = 0;
            ToggleScrollbar.onclick +=
                delegate
            {
                ToggleScrollbarCounter++;

                if (ToggleScrollbarCounter % 2 == 0)
                {
                    ContainerForPosters.style.overflow = "auto";
                }
                else
                {
                    ContainerForPosters.style.overflow = "hidden";
                }
            };
            #endregion



            #region Shadow
            var Shadow = new IHTMLDiv().AttachTo(Context);

            Shadow.style.position = "absolute";
            Shadow.style.left     = "0px";
            Shadow.style.top      = "0px";
            Shadow.style.width    = "100%";
            Shadow.style.height   = "100%";



            // http://www.stripegenerator.com/generators/generate_stripes.php?fore=000000&h=30&w=1&p=18&back1=171313&back2=ff0000&gt=0&d=0&shadow=5&


            Shadow.style.overflow = "hidden";
            // chrome does not support opacity?
            #endregion

            Func <string, int, double, IHTMLDiv> AddContainerShadow =
                (color, margin, opacity) =>
            {
                var ContainerShadow = new IHTMLDiv().AttachTo(Shadow);

                ContainerShadow.style.position        = "absolute";
                ContainerShadow.style.left            = "50%";
                ContainerShadow.style.top             = "50%";
                ContainerShadow.style.marginLeft      = (-400 - margin) + "px";
                ContainerShadow.style.marginTop       = (-300 - margin) + "px";
                ContainerShadow.style.backgroundColor = color;
                ContainerShadow.style.width           = (800 + margin * 2) + "px";
                ContainerShadow.style.height          = (600 + margin * 2) + "px";

                Action <double> ContainerShadow_set_opacity =
                    value =>
                {
                    ContainerShadow.style.opacity = "" + value;
                    ContainerShadow.style.filter  = "Alpha(Opacity=" + Convert.ToInt32(value * 100) + ")";
                };

                if (opacity < 1.0)
                {
                    ContainerShadow_set_opacity(opacity);
                }

                return(ContainerShadow);
            };

            AddContainerShadow("#000000", 800, 0.5);
            for (int i = 0; i < 8; i++)
            {
                AddContainerShadow("#000000", i * 4, 0.4);
            }

            var SuggestionDialog = InitializeSuggestMovie(Context, KnownMovies, Toolbar, Shadow);

            #region ContainerForVideoPlayer
            var ContainerForVideoPlayer = new IHTMLDiv().AttachTo(Context);

            ContainerForVideoPlayer.style.position        = "absolute";
            ContainerForVideoPlayer.style.left            = "50%";
            ContainerForVideoPlayer.style.top             = "50%";
            ContainerForVideoPlayer.style.marginLeft      = "-400px";
            ContainerForVideoPlayer.style.marginTop       = "-300px";
            ContainerForVideoPlayer.style.backgroundColor = "black";
            ContainerForVideoPlayer.style.width           = "800px";
            ContainerForVideoPlayer.style.height          = "400px";
            #endregion

            #region ContainerForDetails
            var ContainerForDetails = new IHTMLDiv().AttachTo(Context);

            ContainerForDetails.style.position   = "absolute";
            ContainerForDetails.style.left       = "50%";
            ContainerForDetails.style.top        = "50%";
            ContainerForDetails.style.marginLeft = "-400px";
            ContainerForDetails.style.marginTop  = "120px";
            //ContainerForDetails.style.backgroundColor = "red";
            ContainerForDetails.style.width    = "800px";
            ContainerForDetails.style.height   = "180px";
            ContainerForDetails.style.overflow = "auto";
            ContainerForDetails.style.color    = "white";

            //            ContainerForDetails.innerHTML = @"
            //<a href='http://www.imdb.com/title/tt0421715/'  title='Movie: The Curious Case of Benjamin Button 2008'><img  src='http://tinyurl.com/dh5xay'  align='right'  /></a>
            //<h2><a href='http://piratebay.org/torrent/4710971/El.Curioso.Caso.De.Benjamin.Button.[2009].[Spanish].[DVD-Screene'>Movie: The Curious Case of Benjamin Button 2008</a></h2>
            //<div title='raiting'>8.2/10</div>
            //<div title='runtime'>166 min, 1.36 GiB</div>
            //<div title='tagline'>Life isn't measured in minutes, but in moments</div>
            //<div title='genres'>Drama, Fantasy, Mystery, Romance</div>
            //<div title='episode'></div>
            //<a href='http://tinyurl.com/cjhc2g'  title='Movie: The Curious Case of Benjamin Button 2008'><img  src='http://static.thepiratebay.org/img/dl.gif'    /> El.Curioso.Caso.De.Benjamin.Button.[2009].[Spanish].[DVD-Screene</a>
            //";
            #endregion


            YouTubePlayer.Create(ContainerForVideoPlayer, 0, 0,
                                 VideoPlayer =>
            {
                MovieItem CurrentVideo = null;

                #region ShowVideo
                Action <MovieItem> ShowVideo =
                    k =>
                {
                    if (k == null)
                    {
                        VideoPlayer.pauseVideo();

                        VideoPlayer.width  = 0;
                        VideoPlayer.height = 0;

                        ContainerForVideoPlayer.style.top = "-100%";
                        //ContainerForVideoPlayer.style.display = "none";
                        Shadow.style.display           = "none";
                        SuggestionDialog.style.display = "none";

                        ContainerForDetails.style.display = "none";
                        Context.Document.title            = "zmovies";
                        return;
                    }

                    //ContainerForVideoPlayer.style.display = "block";

                    ContainerForVideoPlayer.style.top = "50%";

                    VideoPlayer.width  = 800;
                    VideoPlayer.height = 400;

                    if (CurrentVideo == k)
                    {
                        VideoPlayer.playVideo();
                    }
                    else
                    {
                        CurrentVideo = k;
                        VideoPlayer.loadVideoById(k.YouTubeKey);
                    }

                    Context.Document.title = k.SmartTitle;

                    Shadow.style.display = "block";
                    ContainerForDetails.style.display = "block";

                    ContainerForDetails.innerHTML = k.ToDetails();
                };
                #endregion

                ShowVideo(null);


                Shadow.style.cursor = "pointer";
                Shadow.onclick     +=
                    delegate
                {
                    ShowVideo(null);
                };

                // document.getElementById('" + context.Element.id + "')['" + addfeeditem.Token + @"'](result.feed.entries[i].content);

                //{
                //      "title":"Movie: Yes Man 2008",
                //      "link":"http://feedproxy.google.com/~r/zmovies/~3/qVZESWhb0vQ/dfvlm8",
                //      "author":"",
                //      "publishedDate":"",
                //      "contentSnippet":"\n \n \n \n \n \n \n\n\nMovie: Yes Man 2008\n7.2/10\n104 min, 704.11 MiB\nOne word can change everything.\nComedy|Romance\n\n ...",
                //      "content":"\n \n \n \n \u003cembed src\u003d\"http://www.youtube.com/v/Q-Z_CUYh2Sk\u0026amp;hl\u003den\u0026amp;fs\u003d1\" allowScriptAccess\u003d\"never\" allowFullScreen\u003d\"true\" width\u003d\"640\" height\u003d\"385\" wmode\u003d\"transparent\" type\u003d\"application/x-shockwave-flash\"\u003e\u003c/embed\u003e\n \n \n\u003ca href\u003d\"http://www.youtube.com/v/Q-Z_CUYh2Sk\u0026amp;hl\u003den\u0026amp;fs\u003d1\"\u003e\u003cimg alt\u003d\"Q-Z_CUYh2Sk\" src\u003d\"http://img.youtube.com/vi/Q-Z_CUYh2Sk/0.jpg\" align\u003d\"left\"\u003e\u003c/a\u003e\n\u003ca href\u003d\"http://www.imdb.com/title/tt1068680/\" title\u003d\"Movie: Yes Man 2008\"\u003e\u003cimg src\u003d\"http://tinyurl.com/cuc2uo\" align\u003d\"right\"\u003e\u003c/a\u003e\n\u003ch2\u003e\u003ca href\u003d\"http://piratebay.org/torrent/4797620/Yes.Man.2009.DVDRip.XviD-NoRar_\"\u003eMovie: Yes Man 2008\u003c/a\u003e\u003c/h2\u003e\n\u003cdiv title\u003d\"raiting\"\u003e7.2/10\u003c/div\u003e\n\u003cdiv title\u003d\"runtime\"\u003e104 min, 704.11 MiB\u003c/div\u003e\n\u003cdiv title\u003d\"tagline\"\u003eOne word can change everything.\u003c/div\u003e\n\u003cdiv title\u003d\"genres\"\u003eComedy|Romance\u003c/div\u003e\n\u003cdiv title\u003d\"episode\"\u003e\u003c/div\u003e\n\u003ca href\u003d\"http://tinyurl.com/dfvlm8\" title\u003d\"Movie: Yes Man 2008\"\u003e\u003cimg src\u003d\"http://static.thepiratebay.org/img/dl.gif\"\u003e Yes.Man.2009.DVDRip.XviD-NoRar™\u003c/a\u003e\u003cimg src\u003d\"http://feeds2.feedburner.com/~r/zmovies/~4/qVZESWhb0vQ\" height\u003d\"1\" width\u003d\"1\"\u003e",
                //      "categories":[
                //         "Movies",
                //         "Comedy",
                //         "Romance"
                //      ]
                //   },



                VideoPlayer.onStateChange +=
                    state =>
                {
                    if (state == YouTubePlayer.States.ended)
                    {
                        ShowVideo(KnownMovies.Where(x => KnownMoviesFilter(x.Movie)).Random().Movie);
                    }
                };

                var PendingList = new List <MovieItem>();

                Action PendingListToPosters =
                    delegate
                {
                    while (PendingList.Count > 0)
                    {
                        var GroupLeader = PendingList.First();

                        PendingList.Remove(GroupLeader);

                        Func <MovieItem, bool> Filter = k => k.IMDBTagline == GroupLeader.IMDBTagline;

                        if (string.IsNullOrEmpty(GroupLeader.IMDBTagline))
                        {
                            Filter = k => k.SmartTitleWithoutQuotes == GroupLeader.SmartTitleWithoutQuotes;
                        }

                        var GroupMembers = PendingList.Where(Filter).ToArray();

                        GroupMembers.ForEach(k => PendingList.Remove(k));

                        var Group = new[] { GroupLeader }.Concat(GroupMembers).ToArray();

                        foreach (var n in Group)
                        {
                            var poster = new IHTMLImage
                            {
                                src   = n.PosterLink,
                                alt   = " ",
                                title = n.SmartTitleWithoutQuotes + " | " + n.TorrentName + " | " + n.FeedIndex + " of " + n.FeedCapacity
                            }.AttachTo(PostersGroup);

                            if (n != GroupLeader)
                            {
                                poster.style.marginLeft = "-3em";
                            }

                            KnownMovies.Add(
                                new MovieItemWithPoster
                            {
                                Movie  = n,
                                Poster = poster
                            }
                                );

                            poster.style.cursor = "pointer";
                            poster.onclick     +=
                                delegate
                            {
                                ShowVideo(n);
                            };
                        }
                    }
                };


                var GFeedReader = Context.ToExternal <object[]>(
                    data =>
                {
                    var Title        = (string)data[0];
                    var Link         = (string)data[1];
                    var Content      = (string)data[2];
                    var Categories   = (string[])data[3];
                    var FeedIndex    = (int)data[4];
                    var FeedCapacity = (int)data[5];

                    Content.ParseMovieItem(
                        n =>
                    {
                        // use feedburner link for stats
                        n.TorrentLink  = Link;
                        n.FeedIndex    = FeedIndex;
                        n.FeedCapacity = FeedCapacity;

                        PendingList.Add(n);

                        if (FeedIndex + 1 == FeedCapacity)
                        {
                            PendingListToPosters();
                        }
                    }
                        );
                }
                    );

                1.ExternalAtDelay(@"

window['piper'] = function (dummy, result)
{
    for (var i=0; i<result.feed.entries.length; i++) 
    {
		var _x = result.feed.entries[i];
       if (_x.content) 
	   {
			var _v = [_x.title, _x.link, _x.content, _x.categories, i, result.feed.entries.length];
			document.getElementById('"             + Context.Element.id + "')['" + GFeedReader + @"'](_v);
       }
    }
};

					"                    );

                // <script src='http://www.google.com/uds/Gfeeds?callback=piper&scoring=h&context=0&num=100&hl=en&output=json&q=http://feeds2.feedburner.com/zmovies&v=1.0&nocache=0'></script>

                // google seems to cache 250 items

                new IHTMLScript
                {
                    type = "text/javascript",
                    src  = "http://www.google.com/uds/Gfeeds?callback=piper&scoring=h&context=0&num=250&hl=en&output=json&q=http://feeds2.feedburner.com/zmovies&v=1.0&nocache=0"
                }.AttachTo(Context);

                // http://flagcounter.com/

                // rect (top, right, bottom, left)

                FooterGroup.innerHTML =
                    @"
					<div style='padding: 4em;'>

<center>
						<div style='width:420px;text-align:center;margin:0;padding:0;'>
							<embed src='http://widgets.amung.us/flash/v2map.swf' 
								quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' 
								wmode='transparent'
								allowScriptAccess='always' 
								allowNetworking='all' type='application/x-shockwave-flash' 
								flashvars='wausitehash=eop2ht6aucqf&map=heatmap&pin=star-blue&link=no' 
								width='420' height='210' />
							<div style='width:420px;height:210px;position:relative;margin:0 auto;margin-top:-210px;'><a href='http://whos.amung.us/stats/eop2ht6aucqf/'><img src='http://maps.amung.us/ping/eop2ht6aucqf.gif' border='0' width='420' height='210' /></a></div>
						</div>
</center>
<br />
						<div>
						<a href='http://s03.flagcounter.com/more/Y7bi'><img src='http://s03.flagcounter.com/count/Y7bi/bg=000000/txt=FFFFFF/border=CCCCCC/columns=8/maxflags=32/viewers=3/labels=0/pageviews=1/' alt='free counters' border='0'></a>
						</div>
					</div>
										"                                        ;
            }
                                 );
        }