public VisualStudioView()
        {
            var ToolbarHeight = "24px";


            var Content = new IHTMLDiv();

            this.Container = Content;
            this.Container.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
            this.Container.style.width    = "100%";
            this.Container.style.height   = "100%";

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

            var EditorFrame = VisualStudioView.CreateEditor();

            var ToolbarContainerBackground = new IHTMLDiv().With(
                k =>
            {
                k.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
                k.style.left     = "0px";
                k.style.right    = "0px";
                k.style.top      = "0px";
                k.style.height   = ToolbarHeight;

                k.style.backgroundColor = Color.White;
                //k.style.Opacity = 0.5;
            }
                ).AttachTo(Content);

            var ToolbarContainer = new IHTMLDiv().With(
                k =>
            {
                k.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
                k.style.left     = "0px";
                k.style.right    = "0px";
                k.style.top      = "0px";
                k.style.height   = ToolbarHeight;
            }
                ).AttachTo(Content);

            var ToolbarContent = new IHTMLDiv().AttachTo(ToolbarContainer);

            ToolbarContent.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.relative;

            this.PriorityButtons         = new IHTMLSpan().AttachTo(ToolbarContent);
            this.ApplyToolbarButtonStyle =
                k =>
            {
                k.style.verticalAlign = "top";

                k.style.padding  = "0";
                k.style.margin   = "0";
                k.style.overflow = ScriptCoreLib.JavaScript.DOM.IStyle.OverflowEnum.hidden;
                k.style.SetSize(24, 24);

                VisualStudioView.ApplyMouseHoverStyle(k, Color.Transparent);
            };

            Func <IHTMLImage, IHTMLButton> AddButtonDummy =
                (img) =>
            {
                return(new IHTMLButton {
                    img.WithinContainer()
                }.With(k => ApplyToolbarButtonStyle(k)).AttachTo(ToolbarContent));
            };

            Func <IHTMLImage, Action, IHTMLButton> AddButtonAction =
                (img, command) =>
            {
                return(AddButtonDummy(img).With(
                           k =>
                {
                    k.onclick +=
                        delegate
                    {
                        command();
                    };
                }
                           ));
            };

            Func <IHTMLImage, string, IHTMLButton> AddButton =
                (img, command) =>
            {
                return(AddButtonAction(img, () =>
                                       EditorFrame.contentWindow.document.execCommand(
                                           command, false, null
                                           )
                                       ));
            };

            var RTAButtons = new Dictionary <string, IHTMLImage>
            {
                // http://trac.symfony-project.org/browser/plugins/dmCkEditorPlugin/web/js/ckeditor/_source/plugins?rev=27455

                { "Bold", new RTA_bold() },
                { "Underline", new RTA_underline() },
                { "Strikethrough", new RTA_strikethrough() },
                { "Italic", new RTA_italic() },
                { "JustifyLeft", new RTA_justifyleft() },
                { "JustifyCenter", new RTA_justifycenter() },
                { "JustifyRight", new RTA_justifyright() },
                { "JustifyFull", new RTA_justifyfull() },
                { "Indent", new RTA_indent() },
                { "Outdent", new RTA_outdent() },
                { "Superscript", new RTA_superscript() },
                { "Subscript", new RTA_sub() },
                { "Removeformat", new RTA_removeformat() },
                { "InsertOrderedList", new RTA_numberedlist() },
                { "InsertUnorderedList", new RTA_numberedlist() },
                { "undo", new RTA_undo() },
                { "redo", new RTA_redo() },
            }.ToDictionary(
                k => k.Key,
                k => AddButton(k.Value, k.Key)
                );

            var Workspace = new IHTMLDiv().With(
                div =>
            {
                div.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
                div.style.left     = "6px";
                div.style.right    = "6px";
                div.style.bottom   = "6px";
                div.style.top      = "30px";
            }
                ).AttachTo(Content);

            var ToolboxSplit = new HorizontalSplit
            {
                Minimum = 0.05,
                Maximum = 0.5,
                Value   = 0.15,
            };

            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;
                t.SelectionColor = JSColor.Black;
            };

            ToolboxSplit.With(ApplyStyle);

            var ToolboxContainer = ToolboxSplit.LeftContainer;

            ToolboxSplit.Split.Left.style.backgroundColor = Color.White;

            Action <string, string> AddGroup =
                (Header, Title) =>
            {
                #region group
                {
                    var s = new Section().ToSectionConcept();

                    s.Target.Header.style.marginLeft = "1em";
                    s.Header       = Header;
                    s.Header.title = Title;

                    s.Content.Clear();

                    CreateToolboxTo(s.Content);

                    s.IsExpanded = false;
                    s.Target.Container.AttachTo(ToolboxContainer);
                }
                #endregion
            };

            AddGroup("HTML", "For example a section or a split view");
            AddGroup("Flash Components", "For example an empty sprite or a visualization");
            AddGroup("Java Applets", "For example a calculator form or a visualization");
            AddGroup("General", "Snippets");

            var EditorTreeSplit = new HorizontalSplit
            {
                Minimum = 0.5,
                Maximum = 0.95,
                Value   = 0.6,
            };

            EditorTreeSplit.With(ApplyStyle);

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

            var EditorContainer = new IHTMLDiv {
                EditorFrame
            };

            EditorContainer.style.position        = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
            EditorContainer.style.top             = "1.3em";
            EditorContainer.style.left            = "0px";
            EditorContainer.style.right           = "0px";
            EditorContainer.style.bottom          = "0.3em";
            EditorContainer.style.backgroundColor = Color.White;

            var DocumentsContainer = EditorContainer.WithinContainer();

            new IHTMLDiv().With(
                div =>
            {
                div.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
                div.style.top      = "0px";
                div.style.height   = "1em";
                div.style.left     = "0px";
                div.style.right    = "0px";

                div.style.color = Color.White;

                div.Add("About.htm");
            }
                ).AttachTo(DocumentsContainer);

            new IHTMLDiv().With(
                div =>
            {
                div.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
                div.style.top      = "1em";
                div.style.height   = "0.3em";
                div.style.left     = "0px";
                div.style.right    = "0px";

                div.style.backgroundColor = Color.FromRGB(255, 232, 166);
            }
                ).AttachTo(DocumentsContainer);

            new IHTMLDiv().With(
                div =>
            {
                div.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
                div.style.bottom   = "0px";
                div.style.height   = "0.3em";
                div.style.left     = "0px";
                div.style.right    = "0px";

                div.style.backgroundColor = Color.FromRGB(255, 232, 166);
            }
                ).AttachTo(DocumentsContainer);


            EditorTreeSplit.Split.LeftScrollable = DocumentsContainer;
            EditorTreeSplit.Split.RightContainer = DemoTree().Container.WithinContainer().With(div => div.style.backgroundColor = Color.White);

            ToolboxSplit.Split.RightScrollable = EditorTreeSplit.Container;

            ToolboxSplit.Container.AttachTo(Workspace);
        }
        public StudioView(Action<IHTMLElement, Action<ISaveAction>> AddSaveButton = null)
        {
            Content.style.position = IStyle.PositionEnum.absolute;
            Content.style.left = "0px";
            Content.style.right = "0px";
            Content.style.top = "0px";
            Content.style.bottom = "0px";

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

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

                    div.style.padding = "0.5em";

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

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

                    div.style.padding = "0.5em";

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

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

                    div.style.padding = "0.5em";

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

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

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

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

            var WorkspaceHeaderTab0Text = default(IHTMLSpan);



            new DownloadSDK
            {

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

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

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

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

                }
            );


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

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

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

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

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

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

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

            EditorTreeSplit.With(ApplyStyle);

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


            EditorTreeSplit.Container.AttachTo(Workspace);



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

            Split.With(ApplyStyle);

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

            EditorTreeSplit.LeftContainer = Split.Container;



            var SolutionToolbox = new SolutionDockWindowPage();

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


            var vv = new SolutionToolboxListView();

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

            var items = new StockToolboxTabsForHTMLDocument();

            // jsc market components

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

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

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

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

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

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

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

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


            items.WithEach(vv.Add);




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

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

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

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

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

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


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

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


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


            var CurrentDesigner = new SolutionFileDesigner();




            var HTMLDesigner = new SolutionFileDesignerHTMLElementTabs();

            CurrentDesigner.Add(HTMLDesigner);


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




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

            var CodeSourceAView = new SolutionFileView();

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

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

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

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

                                Name = "Default.htm"
                            };

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

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

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

                            CodeSourceAView.File = CodeSourceFile;

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


            #endregion


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

            var CodeSourceBView = new SolutionFileView();

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

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

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

            CodeSourceBTab.Activated +=
                delegate
                {

                    CodeSourceBView.Container.style.display = IStyle.DisplayEnum.empty;
                };


            #endregion

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


            var CodeSourceFormsDesignerTabView = new SolutionFileView();

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

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

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


            CodeSourceFormsDesignerTabView.Container.AttachTo(CurrentDesigner.Content);

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

            CodeSourceFormsDesignerTab.Activated +=
                delegate
                {

                    CodeSourceFormsDesignerTabView.Container.style.display = IStyle.DisplayEnum.empty;
                };


            #endregion

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




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

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

            //wLeftScrollable.Show();

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


            //wLeftScrollable.PopupInsteadOfClosing();

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

            // ...





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

            sln.Interactive.GenerateApplicationExpressions +=
                Add =>
                {


                    // page.PageContainer.ReplaceWith(
                    GetPages().WithEach(
                        k =>
                        {
                            var id = k.Attribute("id").Value;

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

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

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

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

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

            sln.Interactive.GenerateHTMLFiles +=
                Add =>
                {

                    GetPages().WithEach(
                        k =>
                        {
                            var id = k.Attribute("id").Value;

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


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

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

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

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

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

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

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

                                Add(
                                    UserControl2
                                );

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


            var _Solution = new TreeNode(VistaTreeNodePage.Create);


            var _Project = _Solution.Add();

            var About = new About();

            #region UpdateFile1Text
            Action UpdateFile1Text =
                delegate
                {

                    if (CodeSourceBView.File != null)
                    {
                        File7Tab.Text = CodeSourceBView.File.Name.SkipUntilLastIfAny("/");
                    }
                    else
                    {
                        File7Tab.Text = sln.Name;
                    }


                };
            #endregion



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

                    UpdateFile1Text();

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


            var PreviousVersion = default(string);

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

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

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


                                sln.ApplicationPage = x;

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

                                    }
                                ).StartTimeout(700);
                            }
                        };

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

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

                            //HTMLDesignerContentDirty.StartInterval(700);
                        };

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

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

                        };
                }
            );
            #endregion

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


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

                    CodeSourceFormsDesignerTab.TabElement.Hide();

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

                        HTMLDesigner.HTMLDesignerTab.RaiseActivated();

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

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

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

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

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

                                }

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

                                }
                            }
                        );

                    }


                };
            #endregion


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

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



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

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



            Viewer.First().Activate();

            //var SolutionExplorer = new SolutionDockWindowPage();

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


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

            };

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

            fSolutionExplorer.AttachFormTo(EditorTreeSplit.Split.RightScrollable);

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

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

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

            EditorTreeSplit.Container.AttachTo(Workspace);

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

            Update();

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

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

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

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


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

            var ListOfCreateProjectTypeButton = new List<IHTMLButton>();

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

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

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

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

                                  Handler();
                              };

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

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


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

                            Update();
                        }
                    );
                };
            #endregion

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


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

               }
            );

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


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

               }
            );
            #endregion

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

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

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

            ToSpecificProjectType("Applet App",
              delegate
              {
                  sln.WithJavaApplet();
              }
            );
        }
        public ApplicationContent(
            IApp page,
            Abstractatech.JavaScript.FileStorage.IApplicationWebServiceX service,
            bool DisableBackground = false

            )
        {


            FormStyler.AtFormCreated = FormStylerLikeFloat.LikeFloat;

            if (!DisableBackground)
            {
                #region  I want animated background!

                WebGLClouds.Application.Loaded +=
                    a =>
                    {
                        Native.Document.body.parentNode.insertBefore(
                             a.container.Orphanize(),
                              Native.Document.body
                        );
                        a.container.style.position = IStyle.PositionEnum.@fixed;

                    };


                new WebGLClouds.Application();
                #endregion
            }

            //var minsize = new IHTMLDiv().AttachToDocument();

            //minsize.style.SetSize(4000, 2000);




            var f = new Form
            {
                Text = "My Files",
                StartPosition = FormStartPosition.Manual,
                SizeGripStyle = SizeGripStyle.Hide
            };

            #region w
            var ff = new Form
            {
                StartPosition = FormStartPosition.Manual,
                SizeGripStyle = SizeGripStyle.Hide

            };

            var w = new WebBrowser
            {
                Dock = DockStyle.Fill
            }.AttachTo(ff);
            w.GetHTMLTarget().name = "view";

            w.Navigating +=
                delegate
                {
                    ff.Text = "Navigating";


                    if (Native.window.Width < 1024)
                        // docked?
                        if (ff.GetHTMLTarget().parentNode != null)
                            Native.window.scrollTo(ff.Left - 8, ff.Top - 8, TimeSpan.FromMilliseconds(300));

                };



            w.Navigated +=
                delegate
                {
                    if (w.Url.ToString() == "about:blank")
                    {

                        Native.window.scrollTo(0, 0, TimeSpan.FromMilliseconds(200));

                        ff.Text = "...";

                        "Web Files".ToDocumentTitle();

                        return;
                    }

                    //ff.Text = w.DocumentTitle;
                    ff.Text = Native.window.unescape(
                        w.Url.ToString().SkipUntilLastIfAny("/").TakeUntilLastIfAny(".")
                        );

                    ff.Text.ToDocumentTitle();


                };

            ff.FormClosing +=
                (sender, e) =>
                {
                    Console.WriteLine(new { e.CloseReason });

                    if (e.CloseReason == CloseReason.UserClosing)
                    {
                        e.Cancel = true;

                        w.Navigate("about:blank");
                    }

                };
            #endregion



            var content = f.GetHTMLTargetContainer();




            var hh = new HorizontalSplit
            {
                Minimum = 0.05,
                Maximum = 0.95,
                Value = 0.4,
            };

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

            hh.Split.Splitter.style.backgroundColor = "rgba(0,0,0,0.0)";


            #region AtResize
            Action AtResize = delegate
           {
               Native.Document.getElementById("feedlyMiniIcon").Orphanize();

               Native.Document.body.style.minWidth = "";

               if (ff.GetHTMLTarget().parentNode == null)
               {
                   Native.window.scrollTo(0, 0);
                   f.MoveTo(8, 8).SizeTo(Native.window.Width - 16, Native.window.Height - 16);

                   return;
               }

               if (f.GetHTMLTarget().parentNode == null)
               {
                   Native.window.scrollTo(0, 0);
                   ff.MoveTo(8, 8).SizeTo(Native.window.Width - 16, Native.window.Height - 16);

                   return;
               }

               if (Native.window.Width < 1024)
               {
                   Native.Document.body.style.minWidth = (Native.window.Width * 2) + "px";


                   f.MoveTo(8, 8).SizeTo(Native.window.Width - 16, Native.window.Height - 16);

                   ff.MoveTo(Native.window.Width + 8, 8).SizeTo(Native.window.Width - 16, Native.window.Height - 16);

                   // already scrolled...
                   if (w.Url.ToString() != "about:blank")
                       // docked?
                       if (ff.GetHTMLTarget().parentNode != null)
                           Native.window.scrollTo(ff.Left - 8, ff.Top - 8);

                   return;
               }




               f.MoveTo(16, 64).SizeTo(hh.LeftContainer.clientWidth - 32, Native.window.Height - 128);


               ff.MoveTo(
                   Native.window.Width - hh.RightContainer.clientWidth + 16

                   , 64).SizeTo(hh.RightContainer.clientWidth - 32, Native.window.Height - 128);

               //Console.WriteLine("LeftContainer " + new { hh.LeftContainer.clientWidth });
               //Console.WriteLine("RightContainer " + new { hh.RightContainer.clientWidth });
           };

            hh.ValueChanged +=
          delegate
          {
              AtResize();
          };

            Native.window.onresize +=
             delegate
             {
                 AtResize();
             };

            Native.window.requestAnimationFrame +=
        delegate
        {
            AtResize();
        };
            #endregion


            //hh.Split.LeftScrollable = new IHTMLDiv { className = "SidebarForButtons" };


            ff.Show();
            f.Show();

            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20160108
            //f.PopupInsteadOfClosing(SpecialNoMovement: true, NotifyDocked: AtResize);
            //ff.PopupInsteadOfClosing(SpecialNoMovement: true, HandleFormClosing: false, NotifyDocked: AtResize);


            var layout = new Abstractatech.JavaScript.FileStorage.HTML.Pages.App();

            layout.Container.AttachTo(content);

            Abstractatech.JavaScript.FileStorage.ApplicationContent.Target = "view";


            new Abstractatech.JavaScript.FileStorage.ApplicationContent(
                layout,
                service
            );







            "Web Files".ToDocumentTitle();
        }
		private static void AddSection4(IApplicationLoader pp)
		{
			var s = new Section().ToSectionConcept();

			s.Header = "Horizontal split";
			var Content = new IHTMLDiv().With(
				k =>
				{
					k.style.border = "1px solid gray";
					k.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.relative;
					k.style.width = "100%";
					k.style.height = "4em";
				}
			);

			var hh = new HorizontalSplit
			{
				Minimum = 0.05,
				Maximum = 0.95,
				Value = 0.7
			};

			hh.Container.AttachTo(Content);

			s.Content = Content;

			s.IsExpanded = false;
			s.Target.Container.AttachTo(pp.Content);
		}
		public VisualStudioView()
		{
			var ToolbarHeight = "24px";


			var Content = new IHTMLDiv();

			this.Container = Content;
			this.Container.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
			this.Container.style.width = "100%";
			this.Container.style.height = "100%";

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

			var EditorFrame = VisualStudioView.CreateEditor();

			var ToolbarContainerBackground = new IHTMLDiv().With(
				k =>
				{
					k.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
					k.style.left = "0px";
					k.style.right = "0px";
					k.style.top = "0px";
					k.style.height = ToolbarHeight;

					k.style.backgroundColor = Color.White;
					//k.style.Opacity = 0.5;
				}
			).AttachTo(Content);

			var ToolbarContainer = new IHTMLDiv().With(
				k =>
				{
					k.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
					k.style.left = "0px";
					k.style.right = "0px";
					k.style.top = "0px";
					k.style.height = ToolbarHeight;


				}
			).AttachTo(Content);

			var ToolbarContent = new IHTMLDiv().AttachTo(ToolbarContainer);

			ToolbarContent.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.relative;

			this.PriorityButtons = new IHTMLSpan().AttachTo(ToolbarContent);
			this.ApplyToolbarButtonStyle =
				k =>
				{
					k.style.verticalAlign = "top";

					k.style.padding = "0";
					k.style.margin = "0";
					k.style.overflow = ScriptCoreLib.JavaScript.DOM.IStyle.OverflowEnum.hidden;
					k.style.SetSize(24, 24);

					VisualStudioView.ApplyMouseHoverStyle(k, Color.Transparent);
				};

			Func<IHTMLImage, IHTMLButton> AddButtonDummy =
				(img) =>
				{
					return new IHTMLButton { img.WithinContainer() }.With(k => ApplyToolbarButtonStyle(k)).AttachTo(ToolbarContent);
				};

			Func<IHTMLImage, Action, IHTMLButton> AddButtonAction =
				(img, command) =>
				{
					return AddButtonDummy(img).With(
						k =>
						{
							k.onclick +=
								delegate
								{
									command();
								};

						}
					);
				};

			Func<IHTMLImage, string, IHTMLButton> AddButton =
				(img, command) =>
				{
					return AddButtonAction(img, () =>
						EditorFrame.contentWindow.document.execCommand(
							command, false, null
						)
					);
				};

			var RTAButtons = new Dictionary<string, IHTMLImage>
			{
				// http://trac.symfony-project.org/browser/plugins/dmCkEditorPlugin/web/js/ckeditor/_source/plugins?rev=27455

				{"Bold", new RTA_bold()},
				{"Underline", new RTA_underline()},
				{"Strikethrough", new RTA_strikethrough()},
				{"Italic", new RTA_italic()},
				{"JustifyLeft", new RTA_justifyleft()},
				{"JustifyCenter", new RTA_justifycenter()},
				{"JustifyRight", new RTA_justifyright()},
				{"JustifyFull", new RTA_justifyfull()},
				{"Indent", new RTA_indent()},
				{"Outdent", new RTA_outdent()},
				{"Superscript", new RTA_superscript()},
				{"Subscript", new RTA_sub()},
				{"Removeformat", new RTA_removeformat()},
				{"InsertOrderedList", new RTA_numberedlist()},
				{"InsertUnorderedList", new RTA_numberedlist()},
				{"undo", new RTA_undo()},
				{"redo", new RTA_redo()},
			}.ToDictionary(
				k => k.Key,
				k => AddButton(k.Value, k.Key)
			);

			var Workspace = new IHTMLDiv().With(
				div =>
				{
					div.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
					div.style.left = "6px";
					div.style.right = "6px";
					div.style.bottom = "6px";
					div.style.top = "30px";
				}
			).AttachTo(Content);

			var ToolboxSplit = new HorizontalSplit
			{
				Minimum = 0.05,
				Maximum = 0.5,
				Value = 0.15,
			};

			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;
					t.SelectionColor = JSColor.Black;
				};

			ToolboxSplit.With(ApplyStyle);

			var ToolboxContainer = ToolboxSplit.LeftContainer;

			ToolboxSplit.Split.Left.style.backgroundColor = Color.White;

			Action<string, string> AddGroup =
				(Header, Title) =>
				{
					#region group
					{
						var s = new Section().ToSectionConcept();

						s.Target.Header.style.marginLeft = "1em";
						s.Header = Header;
						s.Header.title = Title;

						s.Content.Clear();

						CreateToolboxTo(s.Content);

						s.IsExpanded = false;
						s.Target.Container.AttachTo(ToolboxContainer);
					}
					#endregion
				};

			AddGroup("HTML", "For example a section or a split view");
			AddGroup("Flash Components", "For example an empty sprite or a visualization");
			AddGroup("Java Applets", "For example a calculator form or a visualization");
			AddGroup("General", "Snippets");

			var EditorTreeSplit = new HorizontalSplit
			{
				Minimum = 0.5,
				Maximum = 0.95,
				Value = 0.6,
			};

			EditorTreeSplit.With(ApplyStyle);

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

			var EditorContainer = new IHTMLDiv { EditorFrame };

			EditorContainer.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
			EditorContainer.style.top = "1.3em";
			EditorContainer.style.left = "0px";
			EditorContainer.style.right = "0px";
			EditorContainer.style.bottom = "0.3em";
			EditorContainer.style.backgroundColor = Color.White;

			var DocumentsContainer = EditorContainer.WithinContainer();

			new IHTMLDiv().With(
				div =>
				{
					div.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
					div.style.top = "0px";
					div.style.height = "1em";
					div.style.left = "0px";
					div.style.right = "0px";

					div.style.color = Color.White;

					div.Add("About.htm");
				}
			).AttachTo(DocumentsContainer);

			new IHTMLDiv().With(
				div =>
				{
					div.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
					div.style.top = "1em";
					div.style.height = "0.3em";
					div.style.left = "0px";
					div.style.right = "0px";

					div.style.backgroundColor = Color.FromRGB(255, 232, 166);

				}
			).AttachTo(DocumentsContainer);

			new IHTMLDiv().With(
				div =>
				{
					div.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
					div.style.bottom = "0px";
					div.style.height = "0.3em";
					div.style.left = "0px";
					div.style.right = "0px";

					div.style.backgroundColor = Color.FromRGB(255, 232, 166);

				}
			).AttachTo(DocumentsContainer);


			EditorTreeSplit.Split.LeftScrollable = DocumentsContainer;
			EditorTreeSplit.Split.RightContainer = DemoTree().Container.WithinContainer().With(div => div.style.backgroundColor = Color.White);

			ToolboxSplit.Split.RightScrollable = EditorTreeSplit.Container;

			ToolboxSplit.Container.AttachTo(Workspace);
		}
		private static void AddSection7(Action<string, IHTMLDiv> AddSection)
		{

			var Content = new IHTMLDiv().With(
				k =>
				{
					k.style.border = "1px solid gray";
					k.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.relative;
					k.style.width = "100%";
					k.style.height = "15em";
				}
			);



			var ToolboxSplit = new HorizontalSplit
			{
				Minimum = 0.05,
				Maximum = 0.5,
				Value = 0.15,
			};

			var ToolboxContainer = ToolboxSplit.LeftContainer;

			Action<string, string> AddGroup =
				(Header, Title) =>
				{
					#region group
					{
						var s = new Section().ToSectionConcept();

						s.Target.Header.style.marginLeft = "1em";
						s.Header = Header;
						s.Header.title = Title;

						s.Content.Clear();

						VisualStudioView.CreateToolboxTo(s.Content);

						s.IsExpanded = false;
						s.Target.Container.AttachTo(ToolboxContainer);
					}
					#endregion
				};

			AddGroup("HTML Components", "For example a section or a split view");
			AddGroup("Flash Components", "For example an empty sprite or a visualization");
			AddGroup("Java Applets", "For example a calculator form or a visualization");

			var EditorTreeSplit = new HorizontalSplit
			{
				Minimum = 0.5,
				Maximum = 0.95,
				Value = 0.6,
			};

			EditorTreeSplit.Split.LeftScrollable = VisualStudioView.CreateEditor().WithinContainer();
			EditorTreeSplit.Split.RightContainer = VisualStudioView.DemoTree().Container;

			ToolboxSplit.Split.RightScrollable = EditorTreeSplit.Container;

			ToolboxSplit.Container.AttachTo(Content);

			AddSection(
				"Horizontal split with tree and sub split reversed",
				Content
			);
		}
		private static void AddSection5(Action<string, IHTMLDiv> AddSection)
		{

			var Content = new IHTMLDiv().With(
				k =>
				{
					k.style.border = "1px solid gray";
					k.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.relative;
					k.style.width = "100%";
					k.style.height = "6em";
				}
			);



			var hh = new HorizontalSplit
			{
				Minimum = 0.05,
				Maximum = 0.95,
				Value = 0.7,
				RightContainer = VisualStudioView.DemoTree().Container,
			};

			hh.Split.LeftScrollable = new IHTMLDiv();

			hh.Split.LeftScrollable.style.position = ScriptCoreLib.JavaScript.DOM.IStyle.PositionEnum.absolute;
			hh.Split.LeftScrollable.style.width = "100%";
			hh.Split.LeftScrollable.style.height = "100%";


			var edit = VisualStudioView.CreateEditor();

			edit.AttachTo(hh.Split.LeftScrollable);

			hh.Container.AttachTo(Content);

			AddSection(
				"Horizontal split with tree",
				Content
			);
		}
		public StudioView()
		{
			Content.style.position = IStyle.PositionEnum.absolute;
			Content.style.left = "0px";
			Content.style.right = "0px";
			Content.style.top = "0px";
			Content.style.bottom = "0px";

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

			var WorkspaceHeader = default(IHTMLSpan);

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

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

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

				}
			);

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

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


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

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

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

			Split.With(ApplyStyle);

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

			Split.Container.AttachTo(Workspace);



			var SolutionToolbox = new SolutionDockWindowPage();

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


			var vv = new SolutionToolboxListView();

			vv.Container.AttachTo(SolutionToolbox.Content);

			var items = new StockToolboxTabsForHTMLDocument();

			items.WithEach(vv.Add);


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

			var CurrentDesigner = new SolutionFileDesigner();




			var HTMLDesigner = new SolutionFileDesignerHTMLElementTabs();

			CurrentDesigner.Add(HTMLDesigner);

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

			var CodeSourceView = new SolutionFileView();


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

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

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

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

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

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

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

							CodeSourceView.File = CodeSourceFile;

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


			#endregion


			CurrentDesigner.Add(CodeSourceTab);




			CurrentDesigner.First().RaiseActivated();

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

			Viewer.First().Activate();

			Split.Split.LeftScrollable = SolutionToolbox.Container;
			Split.Split.RightScrollable = Viewer.Container;
		}
        /// <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)
        {
            // localStorage not available on android webview!
            //E/Web Console( 3751): Uncaught TypeError: Cannot set property '20130329 Hello world' of null at http://192.168.1.107:25459/view-source:32300


            FormStyler.AtFormCreated = FormStylerLikeFloat.LikeFloat;

            new GrayPatternBackground.HTML.Images.FromAssets.background().ToDocumentBackground();

            Console.WriteLine("serial 57770");

            "My Notez (loading...)".ToDocumentTitle();


            service.AtPendingActions +=
                count =>
                {
                    if (service.ServicePending.ElapsedMilliseconds > 500)
                    {
                        if (service.ServicePending.ElapsedMilliseconds > 4000)
                        {
                            "My Notez (offline)".ToDocumentTitle();
                            return;
                        }

                        "My Notez (pending)".ToDocumentTitle();
                        return;
                    }

                    "My Notez".ToDocumentTitle();
                };

            Native.window.onbeforeunload +=
                e =>
                {
                    if (service.ServicePending.IsRunning)
                        e.Text = "The changes made here have not yet made it to the server.";
                };

            var storage = new MyLocalStorage
            {

                AtRemove =
                    x => service.remove_LocalStorage(x),

                AtSetItem =
                    (key, value) =>
                    {
                        service.set_LocalStorage(key, value);
                    }
            };

            Console.WriteLine("Do we have localStorage? [2]");

            Native.window.localStorage.With(
                localStorage =>
                {
                    Console.WriteLine("This browser has localStorage. Lets sync with that. [2]");

                    for (uint i = 0; i < localStorage.length; i++)
                    {
                        var key = localStorage.key(i);
                        var value = localStorage[key];

                        storage[key] = value;
                    }

                    // jsc why aint ths working?
                    //storage.AtRemove += localStorage.removeItem;
                    storage.AtRemove += key => localStorage.removeItem(key);
                    storage.AtSetItem += (key, value) => { localStorage[key] = value; };

                }
            );

            #region done
            Action done = delegate
                {



                    var hh = new HorizontalSplit
                    {
                        Minimum = 0.05,
                        Maximum = 0.95,
                        Value = 0.4,
                    };


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

                    hh.Split.Splitter.style.backgroundColor = "rgba(0,0,0,0.0)";


                    //var vv = new VerticalSplit
                    var f = new Form
                    {
                        StartPosition = FormStartPosition.Manual,
                        SizeGripStyle = SizeGripStyle.Hide,

                        Text = "Entries"
                    };

                    var f1 = new Form
                    {
                        StartPosition = FormStartPosition.Manual,
                        SizeGripStyle = SizeGripStyle.Hide,

                        Text = "My Files"
                    };

                    f1.Show();


                    var f2 = new Form
                    {
                        StartPosition = FormStartPosition.Manual,
                        SizeGripStyle = SizeGripStyle.Hide,

                        Text = "..."
                    };

                    f2.Show();

                    var w = new WebBrowser
                    {
                        Dock = DockStyle.Fill
                    };
                    w.GetHTMLTarget().name = "viewer";
                    w.AttachTo(f2);

                    w.Navigating +=
                        delegate
                        {
                            f2.Text = "Navigating";

                        };

                    w.Navigated +=
                       delegate
                       {
                           if (w.Url.ToString() == "about:blank")
                           {

                               f2.Text = "...";


                               return;
                           }

                           //ff.Text = w.DocumentTitle;
                           f2.Text = Native.window.unescape(
                               w.Url.ToString().SkipUntilLastIfAny("/").TakeUntilLastIfAny(".")
                               );



                       };

                    Native.window.requestAnimationFrame +=
                        delegate
                        {

                            var layout = new Abstractatech.JavaScript.FileStorage.HTML.Pages.App();

                            layout.Container.AttachTo(f1.GetHTMLTargetContainer());

                            Abstractatech.JavaScript.FileStorage.ApplicationContent.Target = w.GetHTMLTarget().name;


                            new Abstractatech.JavaScript.FileStorage.ApplicationContent(
                                layout,
                                service.service
                            );

                        };


                    var LeftScrollable = new IHTMLDiv { className = "SidebarForButtons" }.AttachTo(f.GetHTMLTargetContainer());

                    LeftScrollable.style.backgroundColor = "white";

                    var CreateNew = new IHTMLButton { innerText = "+ create new", className = "SidebarButton" }.AttachTo(
                      LeftScrollable
                     );

                    var ff = new Form
                    {
                        StartPosition = FormStartPosition.Manual,
                        SizeGripStyle = SizeGripStyle.Hide

                    };



                    f.Show();
                    ff.Show();




                    //var text = new TextEditor(hh.Split.RightScrollable);
                    var text = new TextEditor(ff.GetHTMLTargetContainer());

                    text.ContainerForBorders.style.border = "";

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


                    //Native.Window.onresize +=
                    //    delegate
                    //    {
                    //        var TopToolbarHeight = text.TopToolbar.clientHeight;

                    //        //Console.WriteLine(new { TopToolbarHeight });

                    //        text.DesignerContainer.style.top = (TopToolbarHeight + 4) + "px";
                    //        text.SourceContainer.style.top = (TopToolbarHeight + 4) + "px";

                    //    };


                    #region DesignerContainer
                    text.DesignerContainer.style.position = IStyle.PositionEnum.absolute;
                    text.DesignerContainer.style.left = "0px";
                    text.DesignerContainer.style.top = "3em";
                    text.DesignerContainer.style.right = "0px";
                    text.DesignerContainer.style.bottom = "3em";
                    text.DesignerContainer.style.height = "";

                    text.Frame.style.position = IStyle.PositionEnum.absolute;
                    text.Frame.style.left = "0px";
                    text.Frame.style.top = "0px";
                    //text.Frame.style.right = "0px";
                    //text.Frame.style.bottom = "0px";
                    text.Frame.style.width = "100%";
                    text.Frame.style.height = "100%";
                    #endregion


                    #region SourceContainer
                    text.SourceContainer.style.position = IStyle.PositionEnum.absolute;
                    text.SourceContainer.style.left = "0px";
                    text.SourceContainer.style.top = "3em";
                    text.SourceContainer.style.right = "0px";
                    text.SourceContainer.style.bottom = "3em";
                    text.SourceContainer.style.height = "";

                    text.TextArea.style.position = IStyle.PositionEnum.absolute;
                    text.TextArea.style.left = "0px";
                    text.TextArea.style.top = "0px";
                    //text.Frame.style.right = "0px";
                    //text.Frame.style.bottom = "0px";
                    text.TextArea.style.width = "100%";
                    text.TextArea.style.height = "100%";
                    #endregion

                    text.BottomToolbarContainer.style.position = IStyle.PositionEnum.absolute;
                    text.BottomToolbarContainer.style.left = "0px";
                    text.BottomToolbarContainer.style.right = "0px";
                    text.BottomToolbarContainer.style.bottom = "0px";

                    var oldtitle = "";

                    Action DoRefresh = delegate { };

                    #region DoCreateNew
                    Action DoCreateNew = delegate
                    {
                        oldtitle = "";

                        #region default text
                        var now = DateTime.Now;


                        var yyyy = now.Year;
                        var mm = now.Month;
                        var dd = now.Day;


                        var yyyymmdd = yyyy
                            + mm.ToString().PadLeft(2, '0')
                            + dd.ToString().PadLeft(2, '0');

                        string header = yyyymmdd + @" New Header " + storage.Keys.Count();


                        text.InnerHTML = @"
<div><font face='Verdana' size='5' color='#0000fc'>" + header + @"</font></div><div><br /></div><blockquote style='margin: 0 0 0 40px; border: none; padding: 0px;'></blockquote><font face='Verdana'>This is your content.</font>
            ";
                        #endregion



                        DoRefresh();
                    };

                    CreateNew.onclick +=
                        delegate
                        {
                            DoCreateNew();
                        };
                    #endregion




                    var buttons = new List<IHTMLButton>();

                    Action EitherCreateNewOrSelectFirst = delegate
                    {
                        if (buttons.Count == 0)
                        {
                            DoCreateNew();
                        }
                        else
                        {
                            if (buttons.Any(k => k.innerText == oldtitle))
                            {
                                //already selected
                            }
                            else
                            {
                                oldtitle = buttons.First().innerText;

                                text.InnerHTML = storage[oldtitle];
                            }
                        }
                    };


                    #region Remove this document
                    var remove = text.AddButton(null, "Remove this document",
                          delegate
                          {
                              var button = buttons.FirstOrDefault(k => k.innerText == oldtitle);

                              if (button == null)
                                  return;

                              //Native.Window.localStorage.removeItem(button.innerText);
                              storage.Remove(button.innerText);


                              button.Orphanize();
                              buttons.Remove(button);

                              EitherCreateNewOrSelectFirst();
                          }
                      );
                    #endregion


                    IHTMLElement remove_element = remove;
                    remove_element.style.Float = IStyle.FloatEnum.right;

                    text.BottomToolbar.appendChild(remove_element);

                    #region new_SidebarButton
                    Func<IHTMLButton> new_SidebarButton =
                        delegate
                        {
                            var button = new IHTMLButton { className = "SidebarButton" }.AttachTo(
                                           LeftScrollable
                                        );

                            button.onclick +=
                                delegate
                                {
                                    oldtitle = "";
                                    text.InnerHTML = storage[button.innerText];
                                    DoRefresh();

                                };

                            button.oncontextmenu +=
                               e =>
                               {
                                   e.preventDefault();

                                   storage.Remove(button.innerText);


                                   button.Orphanize();
                                   buttons.Remove(button);

                                   EitherCreateNewOrSelectFirst();
                               };

                            buttons.Add(button);

                            return button;
                        };
                    #endregion

                    #region DoRefresh
                    DoRefresh = delegate
                   {
                       // what has changed
                       // text not default anymore?
                       // title change?


                       // document unloaded?
                       if (text.Document == null)
                           return;

                       var xml = text.Document.body.AsXElement();

                       // script: error JSC1000: No implementation found for this native method, please implement [static System.String.IsNullOrWhiteSpace(System.String)]

                       xml.Elements().FirstOrDefault(k => !string.IsNullOrWhiteSpace(k.Value)).With(
                           TitleElement =>
                           {
                               // take no action for no title
                               if (string.IsNullOrWhiteSpace(TitleElement.Value))
                                   return;

                               // is there a buttn with old title?


                               var button = buttons.FirstOrDefault(
                                   k =>
                                   {
                                       if (oldtitle == "")
                                       {
                                           return k.innerText == TitleElement.Value;
                                       }

                                       return k.innerText == oldtitle;
                                   }
                               );

                               if (button == null)
                               {
                                   button = new_SidebarButton();
                               }

                               button.innerText = TitleElement.Value;

                               buttons.WithEach(
                                   x => x.setAttribute("data-active", x == button)
                               );


                               if (oldtitle != "")
                               {
                                   if (oldtitle != TitleElement.Value)
                                       storage.Remove(oldtitle);


                               }

                               ff.Text = TitleElement.Value;

                               // src="http://192.168.1.100:5763/

                               var innerHTML = text.InnerHTML;

                               var href = Native.Document.location.href.TakeUntilLastOrEmpty("/");

                               // keep only relative paths to current host
                               var xinnerHTML = innerHTML.Replace("src=\"" + href + "/", "src=\"/");

                               if (innerHTML != xinnerHTML)
                               {
                                   text.InnerHTML = xinnerHTML;
                               }

                               storage[TitleElement.Value] = xinnerHTML;
                               oldtitle = TitleElement.Value;
                               //Console.WriteLine("TitleElement: " + TitleElement.Value);
                           }
                       );

                       // whats the title?
                   };
                    #endregion



                    foreach (var button_text in storage.Keys)
                    {
                        new_SidebarButton().innerText = button_text;
                    }



                    new ScriptCoreLib.JavaScript.Runtime.Timer(
                        t =>
                        {
                            DoRefresh();



                        }
                    ).StartInterval(500);


                    EitherCreateNewOrSelectFirst();








                    #region AtResize
                    Action AtResize = delegate
                    {
                        Native.Document.getElementById("feedlyMiniIcon").Orphanize();

                        Native.Document.body.style.minWidth = "";

                        //if (ff.GetHTMLTarget().parentNode == null)
                        //{
                        //    Native.Window.scrollTo(0, 0);
                        //    f.MoveTo(8, 8).SizeTo(Native.Window.Width - 16, Native.Window.Height - 16);

                        //    return;
                        //}

                        //if (f.GetHTMLTarget().parentNode == null)
                        //{
                        //    Native.Window.scrollTo(0, 0);
                        //    ff.MoveTo(8, 8).SizeTo(Native.Window.Width - 16, Native.Window.Height - 16);

                        //    return;
                        //}

                        //if (Native.Window.Width < 1024)
                        //{
                        //    Native.Document.body.style.minWidth = (Native.Window.Width * 2) + "px";


                        //    f.MoveTo(8, 8).SizeTo(Native.Window.Width - 16, Native.Window.Height - 16);

                        //    ff.MoveTo(Native.Window.Width + 8, 8).SizeTo(Native.Window.Width - 16, Native.Window.Height - 16);

                        //    // already scrolled...
                        //    if (w.Url.ToString() != "about:blank")
                        //        // docked?
                        //        if (ff.GetHTMLTarget().parentNode != null)
                        //            Native.Window.scrollTo(ff.Left - 8, ff.Top - 8);

                        //    return;
                        //}




                        f.MoveTo(16, 16).SizeTo(hh.LeftContainer.clientWidth - 32, Native.window.Height / 3 - 16 - 4);
                        f1.MoveTo(16, Native.window.Height / 3 + 4).SizeTo(hh.LeftContainer.clientWidth - 32, Native.window.Height / 3 - 8);
                        f2.MoveTo(16, Native.window.Height / 3 * 2 + 4).SizeTo(hh.LeftContainer.clientWidth - 32, Native.window.Height / 3 - 16);


                        ff.MoveTo(
                            Native.window.Width - hh.RightContainer.clientWidth + 16

                            , 16).SizeTo(hh.RightContainer.clientWidth - 32, Native.window.Height - 32);

                        //Console.WriteLine("LeftContainer " + new { hh.LeftContainer.clientWidth });
                        //Console.WriteLine("RightContainer " + new { hh.RightContainer.clientWidth });
                    };

                    hh.ValueChanged +=
                  delegate
                  {
                      AtResize();
                  };

                    Native.window.onresize +=
                     delegate
                     {
                         AtResize();
                     };

                    Native.window.requestAnimationFrame +=
                delegate
                {
                    AtResize();
                };
                    #endregion

                    ff.PopupInsteadOfClosing(SpecialNoMovement: true, NotifyDocked: AtResize);
                    f.PopupInsteadOfClosing(SpecialNoMovement: true, NotifyDocked: AtResize);
                    f1.PopupInsteadOfClosing(SpecialNoMovement: true, NotifyDocked: AtResize);
                    f2.PopupInsteadOfClosing(SpecialNoMovement: true, NotifyDocked: AtResize);


                };
            #endregion

            var tt = default(ScriptCoreLib.JavaScript.Runtime.Timer);

            Action done_timeout = delegate
            {
                if (done == null)
                    return;

                tt.Stop();
                done();
                done = null;
            };


            service.get_LocalStorage(
                //add_localStorage: (key, value) => Native.Window.localStorage[key] = value,
                add_localStorage:
                    (key, value) =>
                    {
                        // what if we are resuming from offline edit.
                        // merge?


                        // keep the one we got from localStorage, because it has longer entry?
                        if (storage[key].Length > value.Length)
                            return;

                        storage[key] = value;
                    },

                done: done_timeout
            );


            // either server responds in 2000 or we consider us offline...
            tt = new ScriptCoreLib.JavaScript.Runtime.Timer(
                delegate
                {
                    done_timeout();
                }
            );

            tt.StartTimeout(3000);

        }
示例#10
0
		public static HorizontalSplit CreateView()
		{
			var h = new HorizontalSplit
			{

			};


			var sln = new SolutionBuilder
			{
				Name = "VisualBasicProject1",
				Language = new VisualBasicLanguage()
			};

			var v = new SolutionFileView();



			v.Container.style.height = "100%";

			// phase 1 has only one project at once.

			var _Solution = new TreeNode(VistaTreeNodePage.Create);
			var _Project = _Solution.Add();





			h.LeftContainer = v.Container;
			h.RightContainer = _Solution.Container;

			h.Value = 0.7;

			#region AtLink
			Action<Uri, Action<int>> AtLink =
				(Link, Handler) =>
				{
					var Counter = 0;

					v.LinkCommentClick +=
						uri =>
						{
							if (uri == Link)
							{
								Counter++;
								Handler(Counter);
							}
						};
				};
			#endregion

			Action Update =
				delegate
				{
					_Project.Clear();
					UpdateTree(sln, v, _Solution, _Project);
				};

			AtLink(sln.Interactive.ToVisualCSharpLanguage,
				delegate
				{
					sln.Language = new VisualCSharpLanguage();
					sln.Name = "VisualCSharpProject1";
					Update();
				}
			);

			AtLink(sln.Interactive.ToVisualBasicLanguage,
				delegate
				{
					sln.Language = new VisualBasicLanguage();
					sln.Name = "VisualBasicProject1";
					Update();
				}
			);


			AtLink(sln.Interactive.ToVisualFSharpLanguage,
				delegate
				{
					sln.Language = new VisualFSharpLanguage();
					sln.Name = "VisualFSharpProject1";
					Update();
				}
			);



			AtLink(sln.Interactive.ApplicationToDocumentTitle.Comment,
				ApplicationToDocumentTitleVariation =>
				{
					var Now = DateTime.Now;


					if (ApplicationToDocumentTitleVariation % 2 == 0)
						sln.Interactive.ApplicationToDocumentTitle.Title.Value =
							"Time: " + Now.ToString();
					else
						sln.Interactive.ApplicationToDocumentTitle.Title.Value =
							sln.Name;

					Update();
				}
			);

			var WebMethod2_From = new[]
			{
				"IL",
				"C#",
				"Visual Basic",
				"F#",
			};

			var WebMethod2_To = new[]
			{
				"JavaScript",
				"ActionScript",
				"Java",
				"PHP",
			};

			AtLink(sln.Interactive.WebMethod2,
				Variation =>
				{

					sln.Interactive.WebMethod2.Title.Value =
						"jsc can convert " + WebMethod2_From.Random() + " to " + WebMethod2_To.Random();

					Update();
				}
			);


			v.LinkCommentClick +=
				uri =>
				{
					Native.Document.location.hash = uri.Fragment;
				};


			UpdateTree(sln, v, _Solution, _Project);
			return h;
		}
示例#11
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);
		}
        public DocumentationCompilationViewer()
        {


            var Split = new HorizontalSplit();

            Split.Container.style.With(
                style =>
                {
                    style.position = IStyle.PositionEnum.absolute;

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

                    style.right = "0px";
                    style.bottom = "0px";


                    style.width = "";
                    style.height = "";
                }
            );

            Split.Container.AttachToDocument();






            //var infocontent = new Lorem();
            //infocontent.Container.AttachTo(hs.RightContainer);

            //{
            var Section1 = new Section
            {

            }.ToSectionConcept("Summary");

            Section1.Target.Container.AttachTo(Split.RightContainer);
            //}

            //{
            //    var Section1 = new Section
            //    {

            //    }.ToSectionConcept("Syntax");

            //    Section1.Target.Container.AttachTo(infocontent.Sections);
            //}

            //{
            //    var Section1 = new Section
            //    {

            //    }.ToSectionConcept("Remarks");

            //    Section1.Target.Container.AttachTo(infocontent.Sections);
            //}


            //AttachLogoAnimation(infocontent);




            var c = new Compilation();

            RenderArchives(c, Split.LeftContainer,

                n => Section1.Content.innerText = n

            );




        }