Exemple #1
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)
        {
            var controls = new[] {
                content.vjLogoComponent4,
                content.vjLogoComponent5
            };

            foreach (Component item in controls)
            {
                (item as ImageLinkComponent).With(
                    c =>
                {
                    var a = new IHTMLAnchor {
                        href = c.href
                    }.AttachToDocument();

                    c.img.AttachTo(a);

                    //a.style.SetLocation(c.Left, c.Top);
                }
                    );
            }

            //content.AttachControlTo(page.Content);
            //content.AutoSizeControlTo(page.ContentSize);
            @"Hello world".ToDocumentTitle();
            // Send data from JavaScript to the server tier
            service.WebMethod2(
                @"A string from JavaScript.",
                value => value.ToDocumentTitle()
                );
        }
        public __LinkLabel()
        {
            // X:\jsc.svn\examples\javascript\forms\Test\TestHyperlink\TestHyperlink\ApplicationControl.cs

            this.InternalAnchor = new IHTMLAnchor {
            }.AttachTo(this.HTMLTargetContainer);

            this.InternalLabel.Orphanize().AttachTo(this.InternalAnchor);

            this.HTMLTarget = this.InternalAnchor;

            // should the rules be static?
            this.InternalAnchor.css.hover.style.textDecoration = "underline";

            this.css_active             = this.InternalAnchor.css.active;
            this.css_active.style.color = "red";

            // script: error JSC1000: No implementation found for this native method, please implement [System.Windows.Forms.LinkLabel.set_LinkColor(System.Drawing.Color)]

            this.css = this.InternalAnchor.css;

            this.css.style.color  = "blue";
            this.css.style.cursor = DOM.IStyle.CursorEnum.pointer;

            // script: error JSC1000: No implementation found for this native method, please implement [System.Windows.Forms.LinkLabel.set_ActiveLinkColor(System.Drawing.Color)]


            // we might use a real A element instead
            //this.HTMLTargetRef.style.color = ScriptCoreLib.JavaScript.Runtime.JSColor.Blue;

            // http://www.w3schools.com/Css/pr_text_text-decoration.asp
            //this.HTMLTargetRef.style.textDecoration = "underline";
            //this.HTMLTargetRef.style.cursor = ScriptCoreLib.JavaScript.DOM.IStyle.CursorEnum.pointer;

            this.InternalAnchor.onclick +=
                delegate
            {
                // we could do a lazy bind here instead
                // but we assume a link will have a handler anyway

                if (this.LinkClicked != null)
                {
                    this.LinkClicked(this, new LinkLabelLinkClickedEventArgs(null));
                }
            };
        }
Exemple #3
0
        public override IHTMLOrderedList VisualizedWorkItems(FileInfo[] a)
        {
            var o = new IHTMLOrderedList();

            foreach (var f in a)
            {
                var k = new BasicPirateBaySearch.SearchEntry().FromFile(f);

                var WorkItem = new IHTMLAnchor
                {
                    URL       = f.FullName.ToRelativePath(),
                    innerHTML = k.Name
                }.ToString() + " - <b>" + k.SmartName.ToString() + "</b>";

                o.innerHTML += (IHTMLListItem)WorkItem;
            }

            return(o);
        }
Exemple #4
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)
        {
            IHTMLDiv Control = new IHTMLDiv();


            Control.AttachToDocument();

            Control.appendChild(new IHTMLElement(IHTMLElement.HTMLElementEnum.h1, "This page will ask you to confirm in order to unload the page"));

            var check = new IHTMLInput(HTMLInputTypeEnum.checkbox).AttachToDocument();
            var label = new IHTMLLabel("Bypass check", check).AttachToDocument();



            Native.window.onbeforeunload +=
                delegate(IWindow.Confirmation ev)
            {
                Timer.DoAsync(
                    delegate
                {
                    Native.document.body.style.backgroundColor = JSColor.Red;


                    new Timer((t) => Native.document.body.style.backgroundColor = JSColor.White, 500, 0);
                }
                    );

                if (check.@checked)
                {
                    return;
                }

                ev.Text = "This is a secure website, do you want to leave?";
            };

            var anchor = new IHTMLAnchor("http://example.com", "example.com");

            anchor.target = "_self";

            Control.appendChild(anchor);
        }
Exemple #5
0
        private static void AddTypeProperty(
            IHTMLDiv parent,
            CompilationProperty 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 = new PublicProperty().AttachTo(div);

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

            var s = new IHTMLAnchor {
                innerText = type.Name
            }.AttachTo(div);


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

            Action onclick = delegate
            {
            };

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

                s.focus();

                UpdateLocation(type.Name);

                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 = "2em";

                AddTypeMethod(children, type.GetGetMethod(), UpdateLocation);
                AddTypeMethod(children, type.GetSetMethod(), UpdateLocation);


                //a.GetTypes().ForEach(
                //    (Current, Next) =>
                //    {
                //        AddType(GetNamespaceContainer(children, Current), 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;
            };
        }
Exemple #6
0
        private static void AddTypeEvent(
            IHTMLDiv parent,
            CompilationEvent 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 = new PublicEvent().AttachTo(div);

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

            var s = new IHTMLAnchor {
                innerText = type.Name
            }.AttachTo(div);


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

            Action onclick = delegate
            {
            };

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

                s.focus();

                UpdateLocation(type.Name);

                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 = "2em";

                AddTypeMethod(children, type.GetAddMethod(), UpdateLocation);
                AddTypeMethod(children, type.GetRemoveMethod(), UpdateLocation);



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

                NextClickHide =
                    delegate
                {
                    children.Hide();

                    onclick = NextClickShow;
                };

                NextClickShow =
                    delegate
                {
                    children.Show();

                    onclick = NextClickHide;
                };


                onclick = NextClickHide;
            };
        }
Exemple #7
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;
            };
        }
Exemple #8
0
        private static IHTMLDiv AddNamespace(IHTMLDiv parent, IHTMLDiv NextNamespaceOrDefault, string Namespace, Action <string> UpdateLocation)
        {
            var div = new IHTMLDiv();

            if (NextNamespaceOrDefault == null)
            {
                div.AttachTo(parent);
            }
            else
            {
                NextNamespaceOrDefault.insertPreviousSibling(div);
            }

            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 = new Namespace().AttachTo(div);

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

            if (Namespace == "")
            {
                Namespace = "<Module>";
            }

            var s = new IHTMLAnchor {
                innerText = Namespace
            }.AttachTo(div);


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

            Action onclick = delegate
            {
            };

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

                s.focus();

                UpdateLocation(Namespace);

                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;
            };

            var children = new IHTMLDiv().AttachTo(div);

            children.style.paddingLeft = "1em";
            children.Hide();


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

            NextClickHide =
                delegate
            {
                children.Hide();

                onclick = NextClickShow;
            };

            NextClickShow =
                delegate
            {
                children.Show();

                onclick = NextClickHide;
            };


            onclick = NextClickShow;

            return(children);
        }
Exemple #9
0
        private void RenderAssemblies(
            CompilationArchiveBase archive,
            IHTMLElement parent,
            Func <string, IHTMLDiv> AllTypes,
            Action <string> UpdateLocation,
            Action <Action <Action> > YieldLoadAction)
        {
            var Assemblies = archive.GetAssemblies();

            foreach (var Assembly in Assemblies)
            {
                Console.WriteLine(new { Assembly.Name });
            }

            var q = from a in Assemblies
                    where a.Name.StartsWith("ScriptCoreLib")
                    orderby a.Name
                    select a;

            // limit to only first one for speedup

            foreach (var item2 in q.Take(1))
            {
                var item = item2;

                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 = new Assembly().AttachTo(div);

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

                var s = new IHTMLAnchor {
                    innerText = item2.Name
                }.AttachTo(div);

                //s.style.color = JSColor.Gray;

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

                Action onclick = delegate
                {
                };

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

                    s.focus();

                    UpdateLocation(item.Name);

                    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;
                };

                var NamespaceLookup = new Dictionary <string, IHTMLDiv>();

                Func <IHTMLDiv, CompilationType, IHTMLDiv> GetNamespaceContainer =
                    (Container, SourceType) =>
                {
                    if (!NamespaceLookup.ContainsKey(SourceType.Namespace))
                    {
                        NamespaceLookup[SourceType.Namespace] = null;

                        var NextNamespaceOrDefault = default(IHTMLDiv);

                        //var NextNamespaceOrDefault = NamespaceLookup.Keys.OrderBy(k => k).SkipWhile(k => k == SourceType.Namespace).Select(k => NamespaceLookup[k]).FirstOrDefault();

                        NamespaceLookup[SourceType.Namespace] = AddNamespace(Container, NextNamespaceOrDefault, SourceType.Namespace, UpdateLocation);
                    }

                    return(NamespaceLookup[SourceType.Namespace]);
                };


                var children = new IHTMLDiv().AttachTo(div);

                children.style.paddingLeft = "1em";
                Action <Action> LoadAction =
                    done =>
                {
                    Console.WriteLine("enter LoadAction");

                    s.style.color = JSColor.System.Highlight;

                    Action done_ = delegate
                    {
                        done();
                    };



                    item.WhenReady(
                        a =>
                    {
                        Console.WriteLine("enter WhenReady");

                        s.style.color = JSColor.System.WindowText;

                        Console.WriteLine("before GetTypes ToArray");
                        var TypesArray = a.GetTypes().ToArray();


                        //Console.WriteLine("before TypesByName");

                        //var TypesByName = TypesArray.OrderBy(k => k.Name);

                        //Console.WriteLine("before TypesByName ToArray");
                        //// chokes on android?
                        //var TypesByNameArray = TypesByName.ToArray();

                        //Console.WriteLine("before ForEach");

                        TypesArray.ForEach(
                            (Current, Index, Next) =>
                        {
                            Console.WriteLine("AddType");

                            if (!Current.IsNested)
                            {
                                AddType(
                                    GetNamespaceContainer(children, Current),
                                    Current,
                                    UpdateLocation
                                    );

                                AddType(
                                    AllTypes(Current.Namespace),
                                    Current,
                                    UpdateLocation
                                    );
                            }


                            if (Index % 8 == 0)
                            {
                                ScriptCoreLib.Shared.Avalon.Extensions.AvalonSharedExtensions.AtDelay(
                                    7,
                                    Next
                                    );
                            }
                            else
                            {
                                Next();
                            }
                        }
                            )(done_);

                        Console.WriteLine("exit WhenReady");
                    }
                        );
                };

                Console.WriteLine("before YieldLoadAction");
                YieldLoadAction(LoadAction);
                Console.WriteLine("after YieldLoadAction");


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

                NextClickHide =
                    delegate
                {
                    children.Hide();

                    onclick = NextClickShow;
                };

                NextClickShow =
                    delegate
                {
                    children.Show();

                    onclick = NextClickHide;
                };


                NextClickHide();
            }
        }
Exemple #10
0
        private static void AddTypeConstructor(IHTMLDiv parent, CompilationConstructor 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 = new PublicConstructor().AttachTo(div);

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

            var w = new StringBuilder();

            w.Append(type.DeclaringType.Name);

            w.Append("(");

            type.GetParameters().ForEach(
                (p, pi) =>
            {
                if (pi > 0)
                {
                    w.Append(", ");
                }

                w.Append(p.Name);
            }
                );

            w.Append(")");


            var s = new IHTMLAnchor {
                innerText = w.ToString()
            }.AttachTo(div);


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

            Action onclick = delegate
            {
            };

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

                s.focus();

                UpdateLocation(type.DeclaringType.Name + ".ctor");

                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 = "2em";

                //a.GetTypes().ForEach(
                //    (Current, Next) =>
                //    {
                //        AddType(GetNamespaceContainer(children, Current), 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;
            };
        }
        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();
                });
            }
                );
        }
Exemple #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(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();
            }
                );
        }
Exemple #13
0
            public void Animate()
            {
                //Image.title = "Loading ...";

                Image.InvokeOnComplete(
                    delegate
                {
                    _Width  = Image.width;
                    _Height = Image.height;

                    var details = new IHTMLAnchor("http://sketchup.google.com/3dwarehouse/details?mid=" + Token, "")
                    {
                        target = "_blank",
                        title  = Image.title
                    };

                    Image.border = 0;
                    Image.parentNode.replaceChild(details, Image);
                    details.appendChild(Image);
                    //details.style.display = IStyle.DisplayEnum.block;
                    //ApplyZoom(details);

                    details.onmousewheel +=
                        e =>
                    {
                        this.AnimationZoom += 0.1 * e.WheelDirection;
                    };
                    details.onmouseover +=
                        delegate
                    {
                        __Skip = true;
                    };

                    details.onmouseout +=
                        delegate
                    {
                        __Skip = false;
                    };

                    var c = Frames.Length;
                    foreach (var k_ in Frames)
                    {
                        var k = k_;
                        k.style.verticalAlign = Image.style.verticalAlign;
                        k.InvokeOnComplete(
                            delegate
                        {
                            ApplyZoom(k);

                            c--;
                            //Image.title = "Loading #" + c;

                            if (c == 0)
                            {
                                InternalAnimate();
                            }
                        }
                            );
                    }
                }
                    );
            }
Exemple #14
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)
        {
            //new IHTMLPre { () => "loaded at " + new { DateTime.Now } }.AttachToDocument();
            new IHTMLPre {
                "loaded at " + new { DateTime.Now }
            }.AttachToDocument();

            Native.css[IHTMLElement.HTMLElementEnum.a].style.display = IStyle.DisplayEnum.block;



            new { }.With(
                async delegate
            {
                var foo = new IHTMLAnchor {
                    href = "#foo", innerText = "#foo"
                }.AttachToDocument();

                var a = new AsyncHash {
                    hash = "#foo"
                };

                new IHTMLButton {
                    "go foo"
                }.AttachToDocument().onclick += delegate
                {
                    Native.document.location.hash = a.hash;
                };



                while (await a.onenter)
                {
                    new IHTMLPre {
                        "onenter"
                    }.AttachToDocument();
                    foo.style.backgroundColor = "yellow";


                    await a.onexit;

                    new IHTMLPre {
                        "onexit"
                    }.AttachToDocument();
                    foo.style.backgroundColor = "";
                }
            }
                );


            new { }.With(
                async delegate
            {
                var bar = new IHTMLAnchor {
                    href = "#bar", innerText = "#bar"
                }.AttachToDocument();

                var a = new AsyncHash {
                    hash = "#bar"
                };

                new IHTMLButton {
                    "go bar"
                }.AttachToDocument().onclick += delegate
                {
                    //Native.document.location.hash = a.hash;

                    a.Go();
                };



                while (await a.onenter)
                {
                    //new IHTMLPre { "onenter" }.AttachToDocument();
                    bar.style.backgroundColor = "cyan";


                    // using
                    var goback = new IHTMLButton {
                        "go back"
                    }.AttachToDocument();

                    goback.onclick += delegate
                    {
                        //Native.document.location.hash = a.hash;

                        //a.Go();

                        Native.window.history.back();
                    };

                    await a.onexit;

                    goback.Dispose();

                    //new IHTMLPre { "onexit" }.AttachToDocument();
                    bar.style.backgroundColor = "";
                }
            }
                );


            new IHTMLAnchor {
                href = "", innerText = "go home with reload"
            }.AttachToDocument();
            //new IHTMLAnchor { href = "/", innerText = "go home" }.AttachToDocument();
            new IHTMLAnchor {
                href = "#", innerText = "go home"
            }.AttachToDocument();

            Native.window.onhashchange += delegate
            {
                new IHTMLPre {
                    new { Native.document.location.hash }
                }.AttachToDocument();
            };


            // await hash of


            // await cancel
        }
        private void RenderWriteHistory(Dictionary <SolutionFileTextFragment, Color> Lookup, SolutionFile f, IHTMLElement Container)
        {
            Func <SolutionFileTextFragment, Color> LookupOrDefault =
                ff =>
            {
                if (this.Colors.ContainsKey(ff))
                {
                    return(this.Colors[ff]);
                }

                return(this.Colors[SolutionFileTextFragment.None]);
            };

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


            Content.style.position = IStyle.PositionEnum.relative;

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

            ViewBackground.style.position     = IStyle.PositionEnum.absolute;
            ViewBackground.style.left         = "0px";
            ViewBackground.style.top          = "0px";
            ViewBackground.style.width        = "4em";
            ViewBackground.style.borderRight  = "1px dotted gray";
            ViewBackground.style.paddingRight = "0.5em";

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

            ViewTrap.style.position = IStyle.PositionEnum.absolute;
            ViewTrap.style.left     = "0px";
            ViewTrap.style.top      = "0px";
            ViewTrap.style.right    = "0px";
            ViewTrap.style.bottom   = "0px";
            //ViewTrap.style.backgroundColor = Color.White;

            var ViewTrapContainer = new IHTMLDiv().AttachTo(ViewTrap);

            ViewTrapContainer.style.cursor      = IStyle.CursorEnum.text;
            ViewTrapContainer.style.position    = IStyle.PositionEnum.relative;
            ViewTrapContainer.style.paddingLeft = "5em";

            var View = new IHTMLDiv().AttachTo(ViewTrapContainer);



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

            var RegionStack  = new Stack <List <Action <bool> > >();
            var RegionGlobal = new List <Action <bool> >();

            RegionStack.Push(RegionGlobal);

            var Lines = new List <IHTMLDiv>();

            var CurrentLineDirty   = false;
            var CurrentLine        = default(IHTMLDiv);
            var CurrentLineContent = default(IHTMLDiv);

            Action NextLine = delegate
            {
                CurrentLineDirty = false;

                var c  = new IHTMLDiv();
                var cc = new IHTMLDiv();
                var cb = new IHTMLDiv();

                CurrentLine        = c.AttachTo(View);
                CurrentLineContent = cc.AttachTo(c);

                var CurrentRegion = RegionStack.Peek();

                RegionStack.WithEach(
                    k =>
                {
                    k.Add(
                        IsActive =>
                    {
                        // should we react when in a global region
                        if (k == RegionGlobal)
                        {
                            return;
                        }

                        if (IsActive)
                        {
                            cc.style.backgroundColor = Color.FromGray(0xf9);
                            cb.style.backgroundColor = Color.FromGray(0xf9);
                        }
                        else
                        {
                            cc.style.backgroundColor = Color.None;
                            cb.style.backgroundColor = Color.None;
                        }
                    }
                        );
                }
                    );

                CurrentLine.onmouseover +=
                    delegate
                {
                    CurrentRegion.Invoke(true);
                    cc.style.backgroundColor = Color.FromGray(0xf0);
                    cb.style.backgroundColor = Color.FromGray(0xf0);
                };

                CurrentLine.onmouseout +=
                    delegate
                {
                    CurrentRegion.Invoke(false);
                    cc.style.backgroundColor = Color.None;
                    cb.style.backgroundColor = Color.None;
                };


                Lines.Add(CurrentLine);
                //CurrentLineContent.style.marginLeft = "5em";

                var BCurrentLine = cb.AttachTo(ViewBackground);

                BCurrentLine.style.textAlign = IStyle.TextAlignEnum.right;

                var span = new IHTMLCode {
                    innerText = "" + Lines.Count
                };
                span.style.color = Lookup[SolutionFileTextFragment.Type];
                span.AttachTo(BCurrentLine);

                //Content.style.height = Lines.Count + "em";

                new IHTMLDiv {
                    new IHTMLCode {
                        innerText = Environment.NewLine
                    }
                }.AttachTo(ContentHeightDummy);
            };



            foreach (var item in f.WriteHistory.ToArray())
            {
                if (item is SolutionFileWriteArguments.BeginRegion)
                {
                    RegionStack.Push(new List <Action <bool> >());
                }

                if (item is SolutionFileWriteArguments.EndRegion)
                {
                    RegionStack.Pop();
                }

                if (CurrentLine == null)
                {
                    NextLine();
                }



                var innerText = item.Text;
                innerText = innerText.TakeUntilLastIfAny(Environment.NewLine);

                if (!string.IsNullOrEmpty(innerText))
                {
                    var span = new IHTMLCode {
                        innerText = innerText
                    };

                    if (item.Fragment == SolutionFileTextFragment.Indent)
                    {
                        span.style.width   = "2em";
                        span.style.display = IStyle.DisplayEnum.inline_block;

                        if (CurrentLineDirty)
                        {
                            span.style.borderLeft = "1px dotted #afafaf";
                        }
                    }


                    span.style.color = LookupOrDefault(item.Fragment);

                    CurrentLineDirty = true;
                    span.AttachTo(CurrentLineContent);

                    if (item.Tag != null)
                    {
                        span.style.cursor = ScriptCoreLib.JavaScript.DOM.IStyle.CursorEnum.pointer;
                        span.onmouseover +=
                            delegate
                        {
                            span.style.textDecoration = "underline";
                        };

                        span.onmouseout +=
                            delegate
                        {
                            span.style.textDecoration = "";
                        };



                        var Type = item.Tag as SolutionProjectLanguageType;
                        if (Type != null)
                        {
                            span.title = Type.FullName;
                        }

                        var Method = item.Tag as SolutionProjectLanguageMethod;
                        if (Method != null)
                        {
                            span.title = Method.Name;
                        }


                        var Uri = item.Tag as Uri;
                        if (Uri != null)
                        {
                            var a = new IHTMLAnchor();
                            a.style.color = LookupOrDefault(item.Fragment);

                            a.href   = Uri.ToString();
                            a.target = "_blank";
                            a.Add(span);
                            a.AttachTo(CurrentLineContent);

                            a.onclick +=
                                e =>
                            {
                                // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201511/20151103
                                e.preventDefault();

                                if (LinkCommentClick != null)
                                {
                                    LinkCommentClick(Uri);
                                }
                            };
                        }
                    }
                }

                if (item.Text.EndsWith(Environment.NewLine))
                {
                    if (!CurrentLineDirty)
                    {
                        var span = new IHTMLCode {
                            innerText = " "
                        };
                        span.AttachTo(CurrentLineContent);
                    }

                    CurrentLine = null;
                }
            }
        }
        public void __Application(IApplicationLoader app)
        {
            //app.LoadingAnimation.FadeOut();

            var DefaultTitle = "jsc solutions";


            Native.Document.title = DefaultTitle;

            StringActionAction GetTitleFromServer = new UltraWebService().GetTitleFromServer;



            GetTitleFromServer(
                n => Native.Document.title = n
                );

            var MyPagesBackground = new IHTMLDiv
            {
            };

            MyPagesBackground.style.overflow = IStyle.OverflowEnum.hidden;
            MyPagesBackground.style.position = IStyle.PositionEnum.absolute;
            MyPagesBackground.style.width    = "100%";
            MyPagesBackground.style.height   = "100%";
            MyPagesBackground.AttachToDocument();

            var MyPages = new IHTMLDiv
            {
            };

            MyPages.style.overflow = IStyle.OverflowEnum.auto;
            MyPages.style.position = IStyle.PositionEnum.absolute;
            MyPages.style.width    = "100%";
            MyPages.style.height   = "100%";
            MyPages.AttachToDocument();

            var MyPagesInternal = new IHTMLDiv();

            MyPagesInternal.style.margin = "4em";
            MyPagesInternal.AttachTo(MyPages);

            // http://www.google.com/support/forum/p/Google+Analytics/thread?tid=486a963e463df665&hl=en
            var gapathname = Native.Document.location.pathname;
            var gasearch   = Native.Document.location.search;
            var gahash     = Native.Window.escape(Native.Document.location.hash);
            var gapageview = gapathname + gasearch + gahash;

            var hash = Native.Document.location.hash;

            Action <string> Analytics = delegate { };

            #region logo
            {
                var IsStudio = Native.Document.location.hash.StartsWith("#/studio");

                if (Native.Document.location.host.StartsWith("studio."))
                {
                    IsStudio = true;
                }

                if (IsStudio)
                {
                    new StudioView(AddSaveButton).Content.AttachToDocument();
                }
                else if (Native.Document.location.hash.StartsWith("#/docs"))
                {
                    var view = new DocumentationCompilationViewer();

                    view.TouchTypeSelected +=
                        type =>
                    {
                        Native.Document.location.hash = "#/docs/" + type.FullName;

                        Analytics("#/docs/" + type.FullName);
                    };
                }
                else if (Native.Document.location.hash.StartsWith("#/warehouse"))
                {
                    new UltraWebService().ThreeDWarehouse(
                        y =>
                    {
                        Func <string, IHTMLAnchor> Build =
                            mid =>
                        {
                            var a = new IHTMLAnchor {
                                href = "http://sketchup.google.com/3dwarehouse/details?ct=hppm&mid=" + mid
                            }.AttachTo(MyPagesInternal);
                            var img = new IHTMLImage {
                                src = "http://sketchup.google.com/3dwarehouse/download?rtyp=st&ctyp=other&mid=" + mid
                            }.AttachTo(a);

                            return(a);
                        };

                        var imgs = Enumerable.ToArray(
                            from k in y.Elements()
                            select Build(k.Value)

                            );
                    }
                        );
                }

                else if (Native.Document.location.hash == "#/source")
                {
                    var sln = new TreeNode(() => new VistaTreeNodePage());

                    sln.Text       = "Solution";
                    sln.IsExpanded = true;

                    Action <TreeNode> AddReferences =
                        p =>
                    {
                        var r = p.Add("References", new References());

                        r.Add("System", new Assembly());
                        r.Add("System.Core", new Assembly());
                        r.Add("ScriptCoreLib", new Assembly());
                        r.Add("ScriptCoreLib.Ultra", new Assembly());
                        r.Add("ScriptCoreLib.Ultra.Library", new Assembly());
                        r.Add("ScriptCoreLib.Ultra.Controls", new Assembly());
                        r.Add("ScriptCoreLibJava", new Assembly());
                        r.Add("jsc.meta", new Assembly());
                    };

                    Action <TreeNode> AddUltraSource =
                        p =>
                    {
                        var my = p.Add("My.UltraSource");
                        my.Add("Default.htm", new HTMLDocument());
                        my.Add("jsc.png", new ImageFile());
                    };

                    {
                        var p = sln.Add("Visual C# Project", new VisualCSharpProject());


                        AddReferences(p);
                        AddUltraSource(p);



                        p.Add("Application.cs", new VisualCSharpCode());
                        p.Add("WebService.cs", new VisualCSharpCode());
                        p.Add("Program.cs", new VisualCSharpCode());
                    }

                    {
                        var p = sln.Add("Visual Basic Project", new VisualBasicProject());

                        AddReferences(p);
                        AddUltraSource(p);

                        p.Add("Application.vb", new VisualBasicCode());
                        p.Add("WebService.vb", new VisualBasicCode());
                        p.Add("Program.vb", new VisualBasicCode());
                    }


                    {
                        var p = sln.Add("Visual F# Project", new VisualFSharpProject());

                        AddReferences(p);
                        AddUltraSource(p);


                        p.Add("Application.fs", new VisualFSharpCode());
                        p.Add("WebService.fs", new VisualFSharpCode());
                        p.Add("Program.fs", new VisualFSharpCode());
                    }

                    sln.Container.style.Float = IStyle.FloatEnum.right;
                    sln.Container.AttachTo(MyPagesInternal);

                    new SourceEditorHeader().Container.AttachTo(MyPagesInternal);

                    //new IHTMLElement(IHTMLElement.HTMLElementEnum.h1, "Create your own Ultra Application project template").AttachTo(MyPagesInternal);

                    var n = new TextEditor(MyPagesInternal);

                    n.Width  = 600;
                    n.Height = 400;

                    //n.InnerHTML = "<p>Create your own <b>Ultra Application</b> Project Template</p>";


                    new DefaultPage1().Container.AttachTo(n.Document.body);

                    var m1 = new SimpleCodeView();

                    m1.Container.AttachTo(MyPagesInternal);
                    //m1.SelectType.onchange +=
                    //    delegate
                    //    {
                    //        m1.TypeName.innerText = m1.SelectType.value;
                    //    };

                    //m1.RunJavaScript.onclick +=
                    //    delegate
                    //    {
                    //        m1.RunJavaScript.style.color = JSColor.Blue;

                    //        try
                    //        {
                    //            Native.Window.eval(m1.Code1.value);

                    //            1000.AtDelay(
                    //                delegate
                    //                {
                    //                    m1.RunJavaScript.style.color = JSColor.None;
                    //                }
                    //            );
                    //        }
                    //        catch
                    //        {
                    //            m1.RunJavaScript.style.color = JSColor.Red;

                    //            1000.AtDelay(
                    //                delegate
                    //                {
                    //                    m1.RunJavaScript.style.color = JSColor.None;
                    //                }
                    //            );
                    //        }
                    //    };
                    new Compilation().GetArchives().SelectMany(k => k.GetAssemblies()).First(k => k.Name == "ScriptCoreLib").WhenReady(
                        ScriptCoreLib =>
                    {
                        // we do not have reflection in place for native wrappers :/

                        m1.SelectEvent.Clear();

                        var Element = ScriptCoreLib.GetTypes().Single(k => k.FullName == "ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement");
                        //var Element = ScriptCoreLib.GetTypes().Single(k => k.HTMLElement == "ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement");

                        Action <CompilationEvent> Add =
                            SourceEvent =>
                        {
                            m1.SelectEvent.Add(
                                new IHTMLOption {
                                innerText = SourceEvent.Name
                            }
                                );
                        };

                        Element.GetEvents().ForEach(Add);
                    }
                        );


                    m1.SelectEvent.onchange +=
                        delegate
                    {
                        m1.EventName.innerText = m1.SelectEvent.value;
                    };
                }
                else if (Native.Document.location.hash == "#/UltraApplicationWithAssets")
                {
                    new UltraApplicationWithAssets().Container.AttachToDocument();
                }
                else
                if (Native.Document.location.hash == "#/audio")
                {
                    Action AtTimer = delegate { };

                    (1000 / 15).AtInterval(
                        tt =>
                    {
                        AtTimer();
                    }
                        );

                    new SoundCloudBackground().Container.AttachTo(MyPagesBackground);
                    new SoundCloudHeader().Container.AttachTo(MyPagesInternal);

                    var page = 1;

                    var Tracks = new IHTMLDiv().AttachTo(MyPagesInternal);
                    Tracks.style.margin = "1em";

                    var More = new SoundCloudMore();

                    var AudioLinks = default(AudioLink);

                    var LoadCurrentPage = default(Action);

                    LoadCurrentPage = delegate
                    {
                        var loading = new SoundCloudLoading();

                        loading.Container.AttachTo(Tracks);


                        new UltraWebService().SoundCloudTracksDownload(
                            System.Convert.ToString(page),
                            ee =>
                        {
                            if (loading != null)
                            {
                                loading.Container.Orphanize();
                                loading = null;
                            }

                            var t = new SoundCloudTrack();

                            t.Content.ApplyToggleConcept(t.HideContent, t.ShowContent).Hide();

                            t.Title.innerHTML = ee.trackName;
                            t.Waveform.src    = ee.waveformUrl;

                            t.Audio.src        = ee.streamUrl;
                            t.Audio.autobuffer = true;


                            AudioLinks = new AudioLink
                            {
                                Audio = t.Audio,
                                Prev  = AudioLinks
                            };

                            var _AudioLinks = AudioLinks;

                            if (AudioLinks.Prev != null)
                            {
                                AudioLinks.Prev.Next = AudioLinks;
                            }
                            else
                            {
                                // we are the first  :)
                                t.Audio.play();
                            }

                            t.MoreButton.onclick +=
                                delegate
                            {
                                t.Audio.pause();

                                if (_AudioLinks.Next != null)
                                {
                                    _AudioLinks.Next.Audio.currentTime = 0;
                                    _AudioLinks.Next.Audio.play();

                                    if (_AudioLinks.Next.Next == null)
                                    {
                                        page++;
                                        LoadCurrentPage();
                                    }
                                }
                            };

                            t.Audio.onended +=
                                delegate
                            {
                                if (_AudioLinks.Next != null)
                                {
                                    _AudioLinks.Next.Audio.currentTime = 0;
                                    _AudioLinks.Next.Audio.play();

                                    if (_AudioLinks.Next.Next == null)
                                    {
                                        page++;
                                        LoadCurrentPage();
                                    }
                                }
                            };

                            t.Identity.innerText = ee.uid;

                            t.Play.onclick  += eee => { eee.PreventDefault(); t.Audio.play(); };
                            t.Pause.onclick += eee => { eee.PreventDefault(); t.Audio.pause(); };

                            t.Title.style.cursor = IStyle.CursorEnum.pointer;
                            t.Title.onclick     += eee =>
                            {
                                eee.PreventDefault();

                                var playing = true;

                                if (t.Audio.paused)
                                {
                                    playing = false;
                                }

                                if (t.Audio.ended)
                                {
                                    playing = false;
                                }

                                if (!playing)
                                {
                                    t.Audio.play();
                                }
                                else
                                {
                                    t.Audio.pause();
                                }
                            };

                            DoubleAction SetProgress1 = p =>
                            {
                                t.Gradient3.style.width = System.Convert.ToInt32(800 * p) + "px";
                                t.Gradient4.style.width = System.Convert.ToInt32(800 * p) + "px";
                            };

                            t.Gradient5.style.Opacity = 0.4;
                            t.Gradient6.style.Opacity = 0.4;

                            DoubleAction SetProgress2 = p =>
                            {
                                t.Gradient5.style.width = System.Convert.ToInt32(800 * p) + "px";
                                t.Gradient6.style.width = System.Convert.ToInt32(800 * p) + "px";
                            };

                            AtTimer +=
                                delegate
                            {
                                if (t.Audio.duration == 0)
                                {
                                    t.Play.Hide();
                                    t.Pause.Hide();
                                    return;
                                }
                                else
                                {
                                    var playing = true;

                                    if (t.Audio.paused)
                                    {
                                        playing = false;
                                    }

                                    if (t.Audio.ended)
                                    {
                                        playing = false;
                                    }

                                    if (!playing)
                                    {
                                        t.Title.style.color = Color.None;
                                    }
                                    else
                                    {
                                        t.Title.style.color = Color.Blue;
                                    }

                                    t.Play.Show(!playing);
                                    t.Pause.Show(playing);
                                }

                                var p = t.Audio.currentTime / t.Audio.duration;
                                SetProgress1(p);
                            };

                            t.Waveform.onmouseout +=
                                delegate
                            {
                                SetProgress2(0);
                            };

                            t.Waveform.onmousemove +=
                                eee =>
                            {
                                SetProgress2(eee.OffsetX / 800.0);
                            };

                            t.Waveform.onclick +=
                                eee =>
                            {
                                t.Audio.currentTime = t.Audio.duration * (eee.OffsetX / 800.0);
                                t.Audio.play();
                            };

                            t.Waveform.style.cursor = IStyle.CursorEnum.pointer;

                            SetProgress1(0);
                            SetProgress2(0);

                            t.Container.AttachTo(Tracks);
                        }
                            );


                        10000.AtDelay(
                            delegate
                        {
                            More.MoreButton.FadeIn(0, 1000, null);
                        }
                            );
                    };


                    More.MoreButton.Hide();
                    More.Container.AttachTo(MyPagesInternal);

                    More.MoreButton.onclick += eee =>
                    {
                        eee.PreventDefault();
                        More.MoreButton.FadeOut(1, 300,
                                                delegate
                        {
                            page++;
                            LoadCurrentPage();
                        }
                                                );
                    };

                    LoadCurrentPage();
                }
                else
                {
                    //new PromotionWebApplication1.HTML.Audio.FromAssets.Track1 { controls = true }.AttachToDocument();
                    //new PromotionWebApplication1.HTML.Audio.FromWeb.Track1 { controls = true, autobuffer = true }.AttachToDocument();

                    var IsAvalonJavaScript   = hash == "#/avalon.js";
                    var IsAvalonActionScript = hash == "#/avalon.as";
                    var IsAvalon             = IsAvalonActionScript || IsAvalonJavaScript;

                    //if (IsAvalon)
                    //{

                    //{
                    //    var ccc = new IHTMLDiv();

                    //    ccc.style.position = IStyle.PositionEnum.absolute;
                    //    ccc.style.left = "15%";
                    //    ccc.style.right = "15%";
                    //    ccc.style.top = "15%";


                    //    var Now = DateTime.Now;

                    //    var CountDown = new CountDownGadgetConcept(CountDownGadget.Create)
                    //    {
                    //        ShowOnlyDays = true,
                    //        Event = new DateTime(2010, 5, 24, 23, 59, 50),

                    //    };

                    //    CountDown.Element.GadgetContainer.style.color = "#808080";
                    //    CountDown.Element.GadgetContainer.style.textShadow = "#E0E0E0 1px 1px 1px";


                    //    CountDown.Element.GadgetContainer.AttachTo(ccc);
                    //    CountDown.Element.GadgetContainer.FadeIn(3000, 2000, null);

                    //    ccc.AttachToDocument();
                    //}

                    {
                        var ccc = new IHTMLDiv();

                        ccc.style.position   = IStyle.PositionEnum.absolute;
                        ccc.style.left       = "50%";
                        ccc.style.top        = "50%";
                        ccc.style.marginLeft = (-JSCSolutionsNETCarouselCanvas.DefaultWidth / 2) + "px";
                        ccc.style.marginTop  = (-JSCSolutionsNETCarouselCanvas.DefaultHeight / 2) + "px";

                        ccc.style.SetSize(JSCSolutionsNETCarouselCanvas.DefaultWidth, JSCSolutionsNETCarouselCanvas.DefaultHeight);

                        ccc.AttachToDocument();

                        if (IsAvalonActionScript)
                        {
                            var alof = new UltraSprite();
                            alof.ToTransparentSprite();
                            alof.AttachSpriteTo(ccc);
                        }
                        else
                        {
                            var alo = new JSCSolutionsNETCarouselCanvas();
                            alo.Container.AttachToContainer(ccc);

                            alo.AtLogoClick +=
                                delegate
                            {
                                //Native.Window.open("http://sourceforge.net/projects/jsc/", "_blank");
                                Native.Window.open("/download", "_blank");
                            };
                        }
                    }
                    //}
                    //else
                    //{
                    //    var cc = new HTML.Pages.FromAssets.Controls.Named.CenteredLogo_Kamma();

                    //    cc.Container.AttachToDocument();

                    //    // see: http://en.wikipedia.org/wiki/Perl_control_structures
                    //    // "Unless" == "if not"  ;)

                    //    IsMicrosoftInternetExplorer.YetIfNotThen(cc.TheLogoImage.BeginPulseAnimation).ButIfSoThen(cc.TheLogoImage.HideNowButShowAtDelay);
                    //}

                    var aa = new About();
                    aa.Service.innerText = gapageview;
                    aa.Container.AttachToDocument();
                }
            }
            #endregion


            Analytics =
                __hash =>
            {
                var __gahash     = Native.Window.escape(__hash);
                var __gapageview = gapathname + gasearch + __gahash;


                "UA-13087448-1".ToGoogleAnalyticsTracker(
                    pageTracker =>
                {
                    pageTracker._setDomainName(".jsc-solutions.net");
                    pageTracker._trackPageview(__gapageview);
                }
                    );
            };

            Analytics(Native.Document.location.hash);
        }