Example #1
0
        private static void Main(string[] args)
        {
            var file = new TreeNode(1, "File");
            file.Add(new TreeNode(2, "Save"));
            file.Add(new TreeNode(3, "End"));
            var edit = new TreeNode(4, "Edit") { new TreeNode(5, "Paste"), new TreeNode(6, "Copy") };
            file.Add(edit);

            Output(file);
            Output(edit);

            Console.ReadKey();
        }
Example #2
0
        public static TreeNode<int> BuildTreeFromUserInput()
        {
            Console.Write("Please enter nodes number N: ");
            var nodesNumber = int.Parse(Console.ReadLine());

            var nodes = new List<TreeNode<int>>();

            for (int i = 0; i < nodesNumber - 1; i++)
            {
                var pair = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                var parentValue = int.Parse(pair[0]);
                var childValue = int.Parse(pair[1]);

                if (nodes.Any(n => n.Value == parentValue) && nodes.Any(n => n.Value == childValue))
                {
                    var parent = nodes.Find(p => p.Value == parentValue);
                    var child = nodes.Find(c => c.Value == childValue);

                    parent.Add(child);
                    child.Parent = parent;
                }
                else if (nodes.Any(n => n.Value == parentValue))
                {
                    var parent = nodes.Find(p => p.Value == parentValue);
                    var child = new TreeNode<int>(childValue);

                    parent.Add(child);
                    child.Parent = parent;
                    nodes.Add(child);
                }
                else if (nodes.Any(n => n.Value == childValue))
                {
                    var parent = new TreeNode<int>(parentValue);
                    var child = nodes.Find(p => p.Value == childValue);

                    parent.Add(child);
                    child.Parent = parent;
                    nodes.Add(parent);
                }
                else
                {
                    var parent = new TreeNode<int>(parentValue);
                    var child = new TreeNode<int>(childValue);

                    parent.Add(child);
                    child.Parent = parent;

                    nodes.Add(parent);
                    nodes.Add(child);
                }
            }

            return nodes.FirstOrDefault(n => n.IsRoot);
        }
        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);


        }
Example #4
0
        private static TreeNode<string, FXRegisterReadAddrItem> GetFXReadAddrList(XmlNode attributeNode, Dictionary<string, FXRegister> registerDict)
        {
            TreeNode<string, FXRegisterReadAddrItem> rootNode = new TreeNode<string, FXRegisterReadAddrItem>();
            XmlNodeList registerNodeList = attributeNode.SelectSingleNode("RegisterReadAddrList").ChildNodes;
            foreach (XmlNode registerNode in registerNodeList)              //第一层循环,解出寄存器类型,这一层只有寄存器名称
            {
                if(registerNode.NodeType == XmlNodeType.Element)
                {
                    FXRegisterReadAddrItem item1Level = new FXRegisterReadAddrItem();
                    item1Level.Register = registerNode.Attributes["name"].Value;
                    TreeNode<string, FXRegisterReadAddrItem> item1LevelNode = new TreeNode<string, FXRegisterReadAddrItem>();
                    item1LevelNode.Key = item1Level.Register;
                    rootNode.Add(item1LevelNode.Key, item1LevelNode);                   //添加树的第一层子节点
                    if (registerDict.ContainsKey(item1LevelNode.Key))              //有这个寄存器类型才添加
                    {
                        FXRegister register = registerDict[item1LevelNode.Key];
                        XmlNodeList readAddrNodeList = registerNode.ChildNodes;
                        foreach (XmlNode readAddrNode in readAddrNodeList)      //第二层循环,解出FXRegisterReadAddrType列出的所有类型地址
                        {
                            if (readAddrNode.NodeType == XmlNodeType.Element)
                            {
                                FXRegisterReadAddrItem item2Level = new FXRegisterReadAddrItem();
                                item2Level.Register = item1LevelNode.Key;
                                item2Level.IsOutputItem = false;
                                item2Level.NameFormatType = register.NameFormatType;
                                item2Level.Type = Convert.ToInt32(readAddrNode.Attributes["type"].Value);
                                if (readAddrNode.Attributes["bitmask"] != null)
                                    item2Level.Bitmask = Convert.ToInt32(readAddrNode.Attributes["bitmask"].Value);
                                if (readAddrNode.Attributes["from"] != null)
                                    item2Level.From = Convert.ToInt32(readAddrNode.Attributes["from"].Value);
                                TreeNode<string, FXRegisterReadAddrItem> item2LevelNode = new TreeNode<string, FXRegisterReadAddrItem>();
                                item2LevelNode.Key = item2Level.Type.ToString();
                                item2LevelNode.Value = item2Level;
                                item1LevelNode.Add(item2LevelNode.Key, item2LevelNode);             //添加树的第二层子节点

                                XmlNodeList readAddrOutputNodeList = readAddrNode.ChildNodes;
                                if (readAddrOutputNodeList != null&&readAddrOutputNodeList.Count>0)             //如果是output类型的节点,那么执行第三层循环
                                {
                                    foreach (XmlNode readAddrOutputNode in readAddrOutputNodeList)      //第三层循环,解出FXRegisterReadAddrOutputType列出的所有输出类型地址
                                    {
                                        if (readAddrOutputNode.NodeType == XmlNodeType.Element)
                                        {
                                            FXRegisterReadAddrItem item3Level = new FXRegisterReadAddrItem();
                                            item3Level.Register = item1LevelNode.Key;
                                            item3Level.IsOutputItem = true;
                                            item3Level.NameFormatType = register.NameFormatType;
                                            item3Level.Type = Convert.ToInt32(readAddrOutputNode.Attributes["type"].Value);
                                            item3Level.From = Convert.ToInt32(readAddrOutputNode.Attributes["from"].Value);
                                            item3Level.Bitmask = Convert.ToInt32(readAddrOutputNode.Attributes["bitmask"].Value);
                                            TreeNode<string, FXRegisterReadAddrItem> item3LevelNode = new TreeNode<string, FXRegisterReadAddrItem>();
                                            item3LevelNode.Key = item3Level.Type.ToString();
                                            item3LevelNode.Value = item3Level;
                                            item2LevelNode.Add(item3LevelNode.Key, item3LevelNode);             //添加树的第三层子节点
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return rootNode;
        }
Example #5
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);
        }
Example #6
0
        void UpdateTree(
            SolutionBuilder sln, SolutionFileView v, TreeNode _Solution, TreeNode _Project)
        {
            _Solution.Text       = "Solution '" + sln.Name + "' (1 project)";
            _Solution.IsExpanded = true;

            _Solution.WithIcon(() => new SolutionTwentyTen());

            _Project.Text       = sln.Name;
            _Project.IsExpanded = true;

            // Or my project?
            var _Properties = _Project.Add("Properties");

            _Properties.IsExpanded = true;
            _Properties.WithIcon(() => new SolutionProjectProperties());

            var _References = _Project.Add("References");

            _References.IsExpanded = false;
            _References.WithIcon(() => new References());


            foreach (var item in sln.References.ToArray())
            {
                var _Reference = _References.Add(item.Attribute("Include").Value.TakeUntilIfAny(","));
                _Reference.IsExpanded = true;
                _Reference.WithIcon(() => new Assembly());
            }


            var FolderLookup = new Dictionary <string, TreeNode>();
            var FileLookup   = new Dictionary <SolutionFile, TreeNode>();

            FolderLookup[_Properties.Text] = _Properties;



            var files = sln.ToFiles();

            files.WithEach(
                f =>
            {
                var ProjectInclude = f.Name.SkipUntilIfAny("/").SkipUntilIfAny("/");

                var Folder = ProjectInclude.TakeUntilLastOrEmpty("/");

                if (!string.IsNullOrEmpty(Folder))
                {
                    if (!FolderLookup.ContainsKey(Folder))
                    {
                        var _Folder          = _Project.Add(Folder);
                        FolderLookup[Folder] = _Folder;
                        _Folder.IsExpanded   = true;
                    }
                }
            }
                );

            files.WithEach(
                (SolutionFile f) =>
            {
                var n = default(TreeNode);

                var Extension = "." + f.Name.SkipUntilLastIfAny(".");

                if (Extension == ".sln")
                {
                    n = _Solution;
                }
                else if (Extension == sln.Language.ProjectFileExtension)
                {
                    n = _Project;

                    n.Element.TextArea.style.fontWeight = "bold";
                }
                else
                {
                    var ProjectInclude = f.Name.SkipUntilIfAny("/").SkipUntilIfAny("/");

                    var Folder = ProjectInclude.TakeUntilLastOrEmpty("/");

                    var Parent = _Project;

                    if (!string.IsNullOrEmpty(Folder))
                    {
                        Parent = FolderLookup[Folder];
                    }

                    if (f.DependentUpon != null)
                    {
                        Parent            = FileLookup[f.DependentUpon];
                        Parent.IsExpanded = false;
                    }

                    n = Parent.Add(ProjectInclude.SkipUntilLastIfAny("/"));

                    FileLookup[f] = n;
                }

                if (Extension == ".cs")
                {
                    n.WithIcon(() => new VisualCSharpCode());
                }
                else if (Extension == ".csproj")
                {
                    n.WithIcon(() => new VisualCSharpProject());
                }
                else if (Extension == ".vb")
                {
                    n.WithIcon(() => new VisualBasicCode());
                }
                else if (Extension == ".vbproj")
                {
                    n.WithIcon(() => new VisualBasicProject());
                }
                else if (Extension == ".fs")
                {
                    n.WithIcon(() => new VisualFSharpCode());
                }
                else if (Extension == ".fsproj")
                {
                    n.WithIcon(() => new VisualFSharpProject());
                }
                else if (Extension == ".htm")
                {
                    n.WithIcon(() => new HTMLDocument());
                }

                if (f.DependentUpon != null)
                {
                    n.WithIcon(() => new SolutionProjectDependentUpon());
                }

                n.IsExpanded = true;


                n.Click +=
                    delegate
                {
                    v.File = f;
                };

                // somebody refreshed the solution.
                if (v.File == null)
                {
                    if (f.Name.SkipUntilLastIfAny("/").TakeUntilLastIfAny(".") == "Application")
                    {
                        v.File = f;
                    }
                }
                else
                {
                    // we may not care about the file extensions, will we see a glitch? :)
                    if (v.File.Name.SkipUntilLastIfAny("/").TakeUntilLastIfAny(".") == f.Name.SkipUntilLastIfAny("/").TakeUntilLastIfAny("."))
                    {
                        v.File = f;
                    }
                }
            }
                );

            if (this.Save != null)
            {
                this.Save.Clear();

                files.WithEach(f => this.Save.Add(f.Name, f.Content));
            }
        }
        /// <summary>
        /// Contrói a árvore de factores.
        /// </summary>
        /// <param name="multiFactorLiftingStatus">Contém a factorização que se pretende elevar.</param>
        /// <param name="modularField">O corpo modular sobre o qual são efectuadas as operações.</param>
        /// <returns>A árvore.</returns>
        private Tree <LinearLiftingStatus <CoeffType> > MountFactorTree(
            MultiFactorLiftingStatus <CoeffType> multiFactorLiftingStatus,
            IModularField <CoeffType> modularField)
        {
            var tree             = new Tree <LinearLiftingStatus <CoeffType> >();
            var currentNodes     = new List <TreeNode <LinearLiftingStatus <CoeffType> > >();
            var factorEnumerator = multiFactorLiftingStatus.Factorization.Factors.GetEnumerator();

            if (factorEnumerator.MoveNext())
            {
                var factor = factorEnumerator.Current;
                if (!modularField.IsMultiplicativeUnity(multiFactorLiftingStatus.Factorization.IndependentCoeff))
                {
                    factor = factor.Multiply(multiFactorLiftingStatus.Factorization.IndependentCoeff, modularField);
                }

                currentNodes.Add(new TreeNode <LinearLiftingStatus <CoeffType> >(
                                     new LinearLiftingStatus <CoeffType>(factor, modularField.Module),
                                     tree,
                                     null));

                while (factorEnumerator.MoveNext())
                {
                    factor = factorEnumerator.Current;
                    currentNodes.Add(new TreeNode <LinearLiftingStatus <CoeffType> >(
                                         new LinearLiftingStatus <CoeffType>(factor, modularField.Module),
                                         tree,
                                         null));
                }
            }

            if (currentNodes.Count < 2)
            {
                return(null);
            }
            else
            {
                var temporaryNodes = new List <TreeNode <LinearLiftingStatus <CoeffType> > >();
                var count          = 0;
                while (currentNodes.Count > 1)
                {
                    temporaryNodes.Clear();
                    var i = 0;
                    while (i < currentNodes.Count)
                    {
                        var parentNode = default(TreeNode <LinearLiftingStatus <CoeffType> >);
                        var first      = currentNodes[i];
                        ++i;
                        if (i < currentNodes.Count)
                        {
                            var second  = currentNodes[i];
                            var product = first.NodeObject.Polynom.Multiply(
                                second.NodeObject.Polynom,
                                modularField);

                            var liftingStatus = new LinearLiftingStatus <CoeffType>(
                                product,
                                first.NodeObject.Polynom,
                                second.NodeObject.Polynom,
                                modularField.Module);

                            parentNode = new TreeNode <LinearLiftingStatus <CoeffType> >(
                                liftingStatus,
                                tree,
                                null);

                            first.InternalParent  = parentNode;
                            second.InternalParent = parentNode;
                            parentNode.Add(first);
                            parentNode.Add(second);
                            ++i;
                        }
                        else
                        {
                            parentNode = first;
                        }

                        temporaryNodes.Add(parentNode);
                    }

                    var swap = currentNodes;
                    currentNodes   = temporaryNodes;
                    temporaryNodes = swap;
                    ++count;
                }

                var lastNode = currentNodes[0];
                tree.InternalRootNode = lastNode;
                return(tree);
            }
        }
Example #8
0
        public void TestFindNotExistingElementWithIterativeDeepening()
        {
            var root = new TreeNode<int>(1);
            root.Add(2);
            root.Add(3);
            root.Add(4);
            root.Children.ElementAt(0).Add(5);
            root.Children.ElementAt(1).Add(6);
            root.Children.ElementAt(2).Add(7);
            var actual = root.Contains(8, SearchMode.IterativeDeepening);

            Assert.IsFalse(actual);
        }
Example #9
0
        public void TestRemoveExistingNodeThatIsNotRoot()
        {
            var root = new TreeNode<int>(1);
            root.Add(2);
            root.Add(3);
            root.Add(4);
            root.Children.ElementAt(0).Add(5);
            root.Children.ElementAt(1).Add(6);
            root.Children.ElementAt(2).Add(7);
            bool removalResult = root.Remove(6);
            int[] expected = { 1, 2, 3, 4, 5, 7 };
            var bfEnumerator = root.GetEnumerator(VisitType.BreadthFirst);
            var elements = new List<int>();

            while (bfEnumerator.MoveNext())
            {
                elements.Add(bfEnumerator.Current);
            }

            var actual = elements.ToArray();

            Assert.IsTrue(removalResult);
            Assert.AreEqual(expected.Length, actual.Length);
            Assert.AreEqual(expected.Length, root.Count);

            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
Example #10
0
        public void TestFindExistingElementWithBFS()
        {
            var root = new TreeNode<int>(1);
            root.Add(2);
            root.Add(3);
            root.Add(4);
            root.Children.ElementAt(0).Add(5);
            root.Children.ElementAt(1).Add(6);
            root.Children.ElementAt(2).Add(7);
            var actual = root.Contains(7, SearchMode.BreadthFirstSearch);

            Assert.IsTrue(actual);
        }
Example #11
0
        public void TestFindNotExistingElementWithDFS()
        {
            var root = new TreeNode<int>(1);
            root.Add(2);
            root.Add(3);
            root.Add(4);
            root.Children.ElementAt(0).Add(5);
            root.Children.ElementAt(1).Add(6);
            root.Children.ElementAt(2).Add(7);
            var actual = root.Contains(8, SearchMode.DepthFirstSearch);

            Assert.IsFalse(actual);
        }
Example #12
0
        public void TestTreeNodeElementAddition()
        {
            var root = new TreeNode<int>(4);
            root.Add(5);
            root.Add(6);
            root.Children.ElementAt(0).Add(7);

            Assert.AreEqual(4, root.Count);
            Assert.AreEqual(2, root.Children.Count());
            Assert.AreEqual(root, root.Children.ElementAt(0).Parent);
            Assert.AreEqual(root, root.Children.ElementAt(1).Parent);
        }
        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);
        }
Example #14
0
        public override void DeserializeData(byte[] rawData, string srdiPath, string srdvPath)
        {
            using BinaryReader reader = new BinaryReader(new MemoryStream(rawData));

            uint maxTreeDepth = reader.ReadUInt32();

            Unknown14 = reader.ReadUInt16();
            ushort totalEntryCount = reader.ReadUInt16();

            Unknown18 = reader.ReadUInt16();
            ushort totalEndpointCount     = reader.ReadUInt16();
            uint   unknownFloatListOffset = reader.ReadUInt32();

            // Read and parse tree data
            int stringDataStart = -1;

            for (int i = 0; i < totalEntryCount; ++i)
            {
                // Read raw tree entry data
                uint stringOffset = reader.ReadUInt32();

                if (stringDataStart == -1)
                {
                    stringDataStart = (int)stringOffset;
                }

                uint endpointOffset       = reader.ReadUInt32();
                byte currentEndpointCount = reader.ReadByte();
                byte nodeDepth            = reader.ReadByte();
                byte unknown0A            = reader.ReadByte();
                byte unknown0B            = reader.ReadByte();
                uint unknown0C            = reader.ReadUInt32();

                // Seek to the string data and read it, then seek back
                long lastPos = reader.BaseStream.Position;
                reader.BaseStream.Seek(stringOffset, SeekOrigin.Begin);
                TreeNode node = new TreeNode(Utils.ReadNullTerminatedString(reader, Encoding.ASCII));
                reader.BaseStream.Seek(lastPos, SeekOrigin.Begin);

                // Read and append any endpoints
                if (endpointOffset != 0)
                {
                    long lastPos2 = reader.BaseStream.Position;
                    reader.BaseStream.Seek(endpointOffset, SeekOrigin.Begin);
                    for (int ep = 0; ep < currentEndpointCount; ++ep)
                    {
                        // Seek to the string data and read it, then seek back
                        uint endpointStringOffset = reader.ReadUInt32();
                        uint unknown04            = reader.ReadUInt32();
                        long lastPos3             = reader.BaseStream.Position;
                        reader.BaseStream.Seek(endpointStringOffset, SeekOrigin.Begin);
                        TreeNode endpoint = new TreeNode(Utils.ReadNullTerminatedString(reader, Encoding.ASCII));
                        node.Add(endpoint);
                        reader.BaseStream.Seek(lastPos3, SeekOrigin.Begin);
                    }
                    reader.BaseStream.Seek(lastPos2, SeekOrigin.Begin);
                }

                // If this is the first node, it is the root of our tree
                if (i == 0)
                {
                    RootNode = node;
                }
                else
                {
                    // Seek to the end of the node tree at the current depth
                    TreeNode parentNode = RootNode;
                    for (int depth = 0; depth < (nodeDepth - 1); ++depth)
                    {
                        parentNode = parentNode.Last();
                    }

                    // Assign this node as a child to the parent
                    parentNode.Add(node);
                }
            }

            // Read the unknown 4x4 matrix
            reader.BaseStream.Seek(unknownFloatListOffset, SeekOrigin.Begin);
            while (reader.BaseStream.Position < stringDataStart)
            {
                UnknownMatrix.M11 = reader.ReadSingle();
                UnknownMatrix.M12 = reader.ReadSingle();
                UnknownMatrix.M13 = reader.ReadSingle();
                UnknownMatrix.M14 = reader.ReadSingle();
                UnknownMatrix.M21 = reader.ReadSingle();
                UnknownMatrix.M22 = reader.ReadSingle();
                UnknownMatrix.M23 = reader.ReadSingle();
                UnknownMatrix.M24 = reader.ReadSingle();
                UnknownMatrix.M31 = reader.ReadSingle();
                UnknownMatrix.M32 = reader.ReadSingle();
                UnknownMatrix.M33 = reader.ReadSingle();
                UnknownMatrix.M34 = reader.ReadSingle();
                UnknownMatrix.M41 = reader.ReadSingle();
                UnknownMatrix.M42 = reader.ReadSingle();
                UnknownMatrix.M43 = reader.ReadSingle();
                UnknownMatrix.M44 = reader.ReadSingle();
            }
        }
    private void RearrangeNodes(ref TreeNode node)
    {
        TreeNode BrokenNode = node.LeftNode;
        if (node.RightNode != null)
        {
            node = node.RightNode;

            if (BrokenNode != null)
            {
                foreach (int number in BrokenNode)
                {
                    node.Add(number);
                }
            }
        }
        else
        {
            node = BrokenNode;
        }
    }
Example #16
0
        public void TestRemoveExistingNodeThatIsRoot()
        {
            var root = new TreeNode<int>(1);
            root.Add(2);
            root.Add(3);
            root.Add(4);
            root.Children.ElementAt(0).Add(5);
            root.Children.ElementAt(1).Add(6);
            root.Children.ElementAt(2).Add(7);
            bool removeResult = root.Remove(1);

            // the removal of the root element is not allowed
            Assert.IsFalse(removeResult);
        }
Example #17
0
 public static TreeNode<string> ParseTreeBracketsComma(this string toParse)
 {
     //Console.WriteLine("parsing {0}");
     int funcsep = toParse.IndexOf('(');
     if(funcsep < 0x00) {
         funcsep = toParse.Length;
     }
     int b = 0x00;
     int last = funcsep+0x01;
     char c;
     TreeNode<string> result = new TreeNode<string>(toParse.Substring(0x00, funcsep));
     for(int i = funcsep+0x01; i < toParse.Length; i++) {
         c = toParse[i];
         if(c == '(') {
             b++;
         }
         else if(c == ')') {
             b--;
             if(b < 0x00) {
                 result.Add(ParseTreeBracketsComma(toParse.Substring(last, i-last)));
                 return result;
             }
         }
         else if(c == ',') {
             if(b <= 0x00) {
                 result.Add(ParseTreeBracketsComma(toParse.Substring(last, i-last)));
                 last = i+0x01;
             }
         }
     }
     return result;
 }
Example #18
0
        protected override void InitializeCore()
        {
            ShowDebug = true;

            _stage = new Stage(Context.GraphicsDevice);
            Context.Input.Processor = _stage;

            Skin skin = new Skin(Context.GraphicsDevice, "Data/uiskin.json");

            Table table = new Table();

            table.SetFillParent(true);
            _stage.AddActor(table);

            Tree tree = new Tree(skin);

            TreeNode node1 = new TreeNode(new TextButton("moo1", skin));
            TreeNode node2 = new TreeNode(new TextButton("moo2", skin));
            TreeNode node3 = new TreeNode(new TextButton("moo3", skin));
            TreeNode node4 = new TreeNode(new TextButton("moo4", skin));
            TreeNode node5 = new TreeNode(new TextButton("moo5", skin));

            tree.Add(node1);
            tree.Add(node2);
            node2.Add(node3);
            node3.Add(node4);
            tree.Add(node5);

            Label label = new Label("", skin, "default");

            tree.SelectionChanged += (sender, e) => {
                if (e.AddedItems.Count == 0)
                {
                    return;
                }

                StringBuilder txt = new StringBuilder();
                foreach (TreeNode node in e.AddedItems)
                {
                    TextButton button = node.Actor as TextButton;
                    txt.Append(button.Text + ", ");
                }

                label.Text = txt.ToString();
                label.Invalidate();
            };

            (node5.Actor as Button).Clicked += (sender, e) => {
                tree.Remove(node4);
            };

            //node5.Actor.AddListener(new DispatchClickListener() {
            //    OnClicked = (ev, x, y) => { tree.Remove(node4); }
            //});

            table.Add(tree).Configure.Fill().Expand();
            table.Row();
            table.Add(label).Configure.Fill().Expand();

            //Debugger.Launch();
        }