public static SolutionBuilder WithAdobeFlash(this SolutionBuilder sln) { Func <StockSpriteType> GetType = () => new StockSpriteType(sln.Name, "ApplicationSprite"); var sprite = default(SolutionProjectLanguageField); sln.Interactive.GenerateTypes += AddType => { var ApplicationSprite = GetType(); sprite = ApplicationSprite.ToInitializedField("sprite"); sprite.DeclaringType = sln.Interactive.ApplicationType; AddType(ApplicationSprite); }; sln.Interactive.GenerateApplicationExpressions += AddCode => { AddCode(new CreateMySprite(GetType(), sprite)); }; return(sln); }
public void WriteTo(SolutionFile File, SolutionProjectLanguage Language, SolutionBuilder Context) { // X:\jsc.svn\examples\javascript\test\Test4IfNotNullIfFalse\Test4IfNotNullIfFalse\Class1.cs // X:\jsc.svn\core\ScriptCoreLib.Ultra.Library\ScriptCoreLib.Ultra.Library\Ultra\Studio\SolutionFileComment.cs // broken in roslyn? if (this.IsActiveFilter != null) { if (!this.IsActiveFilter(Context)) { return; } } if (Comment != null) { File.WriteIndent(); Language.WriteCommentLine(File, Comment); } if (Link != null) { File.WriteIndent(); Language.WriteLinkCommentLine(File, Link); } this.MarginBottom.Times(File.WriteLine); }
public static SolutionBuilder WithForms(this SolutionBuilder sln) { return(Internal(sln, IsApplet: false, ApplcationWebServiceAsComponent: true )); }
public static ZIPFile WriteToArchive(this SolutionBuilder that) { var zip = new ZIPFile(); that.WriteTo( f => zip.Add(f.Name, f.Content) ); return(zip); }
static void Main(string[] args) { var sln = new SolutionBuilder { Name = "VisualCSharpProject1", Language = new VisualFSharpLanguage() }.WithAdobeFlashWithFlare3D(); sln.Interactive.GenerateApplicationExpressions += Add => { //Add( // new StockReplaceWithNewPageExpression("Page1") //); //Add( // new StockReplaceWithNewUserControlExpression(sln.Name + ".Components", "UserControl1") //); }; //sln.Interactive.GenerateTypes += // Add => // { // var Namespace = sln.Name + ".Components"; // //var Name = "UserControl1"; // Add( // new StockAppletType(Namespace, "Applet1") // ); // }; //sln.Interactive.GenerateHTMLFiles += // Add => // { // var Content = new XElement(StockPageDefault.Page); // Content.Element("head").Element("title").Value = "Page1"; // Add( // new SolutionProjectHTMLFile // { // Name = "Design/Page1.htm", // Content = Content // } // ); // }; sln.WriteToConsole(); Debugger.Break(); }
public Application(IAbout a) { var s = new InternalSaveActionSprite(); s.AttachSpriteTo(a.Content); s.WebService = new ApplicationWebService(); var pp = new ProjectNameInput(); pp.AttachControlTo(a.Content); var Files = new IHTMLDiv().AttachTo(a.Content); s.WhenReady( i => { Action Update = delegate { var sln = new SolutionBuilder { Name = pp.ProjectName.Text }; i.FileName = sln.Name + ".zip"; i.Clear(); Files.Clear(); sln.WriteTo( (SolutionFile f) => { new IHTMLPre { innerText = f.Name }.AttachTo(Files); i.Add(f.Name, f.Content); } ); }; pp.UpdateButton.TextChanged += delegate { }; pp.UpdateButton.Click += delegate { Update(); }; Update(); } ); }
public static SolutionBuilder WithAdobeFlashCamera(this SolutionBuilder sln) { Func <StockSpriteType> GetType = () => new StockSpriteType(sln.Name, "ApplicationSprite"); var sprite = default(SolutionProjectLanguageField); sln.Interactive.GenerateTypes += AddType => { var ApplicationSprite = GetType(); sprite = ApplicationSprite.ToInitializedField("sprite"); sprite.DeclaringType = sln.Interactive.ApplicationType; #region video <- new Video(500, 400) var VideoType = new KnownStockTypes.ScriptCoreLib.ActionScript.flash.media.Video(); var video = VideoType.ToInitializedField("video"); video.FieldConstructor.ParameterExpressions = new[] { (PseudoInt32ConstantExpression)ScriptApplicationEntryPointAttribute.DefaultWidth, (PseudoInt32ConstantExpression)ScriptApplicationEntryPointAttribute.DefaultHeight }; ApplicationSprite.Fields.Add(video); #endregion var Camera_getCamera = new KnownStockTypes.ScriptCoreLib.ActionScript.flash.media.Camera.getCamera().ToCallExpression(); var LinqExtensions_With = new KnownStockTypes.ScriptCoreLib.Extensions.LinqExtensions.With().ToCallExpression( Camera_getCamera, new StockMethodInitializeCamera(video) ); ApplicationSprite.Constructor.Code.Add(LinqExtensions_With); AddType(ApplicationSprite); }; sln.Interactive.GenerateApplicationExpressions += AddCode => { AddCode(new CreateMySprite(GetType(), sprite)); }; return(sln); }
public static SolutionBuilder WithJavaApplet(this SolutionBuilder that) { Func <StockAppletType> GetType = () => new StockAppletType(that.Name, "ApplicationApplet"); that.Interactive.GenerateTypes += AddType => { AddType(GetType()); }; that.Interactive.GenerateApplicationExpressions += AddCode => { AddCode(new CreateMyApplet(GetType())); }; return(that); }
public void WriteTo(SolutionFile File, SolutionProjectLanguage Language, SolutionBuilder Context) { // X:\jsc.svn\examples\javascript\test\Test4IfNotNullIfFalse\Test4IfNotNullIfFalse\Class1.cs // X:\jsc.svn\core\ScriptCoreLib.Ultra.Library\ScriptCoreLib.Ultra.Library\Ultra\Studio\SolutionFileComment.cs // broken in roslyn? if (this.IsActiveFilter != null) if (!this.IsActiveFilter(Context)) return; if (Comment != null) { File.WriteIndent(); Language.WriteCommentLine(File, Comment); } if (Link != null) { File.WriteIndent(); Language.WriteLinkCommentLine(File, Link); } this.MarginBottom.Times(File.WriteLine); }
abstract public void WritePseudoExpression(SolutionFile File, object Parameter, SolutionBuilder Context);
static SolutionBuilder InternalWithCanvas(SolutionBuilder sln, Action<SolutionProjectLanguageField> NotifyContent = null ) { // should we make an Undo available? sln.ApplicationPage = StockPageDefault.CanvasDefaultPage; var content = default(SolutionProjectLanguageField); sln.Interactive.GenerateTypes += AddType => { #region ApplicationCanvas var ApplicationCanvas = new StockCanvasType(sln.Name, "ApplicationCanvas"); // in Canvas applications we want to focus only the canvas // to do that we hide other implementation detail classes sln.Interactive.ApplicationWebServiceType.DependentUpon = ApplicationCanvas; sln.Interactive.ApplicationType.DependentUpon = ApplicationCanvas; sln.Interactive.ProgramType.DependentUpon = ApplicationCanvas; AddType(ApplicationCanvas); content = ApplicationCanvas.ToInitializedField("content"); content.DeclaringType = sln.Interactive.ApplicationType; // we are adding a field. does it show up in the source code later? // SolutionProjectLanguage.WriteType makes it happen! if (NotifyContent != null) NotifyContent(content); var Code = sln.Interactive.ProgramType_MainMethod.Code; sln.Interactive.ProgramType_MainMethod.Code = new SolutionProjectLanguageCode { new PseudoIfExpression { IsConditionalCompilationDirective = true, Expression = ("DEBUG"), FalseCase = Code, TrueCase = new SolutionProjectLanguageCode { new KnownStockTypes.ScriptCoreLib.Desktop.Extensions.DesktopAvalonExtensions.Launch().ToCallExpression( null, new SolutionProjectLanguageMethod { ReturnType = ApplicationCanvas, Code = new SolutionProjectLanguageCode { ApplicationCanvas.GetDefaultConstructor() } } ) } } }; #endregion }; sln.Interactive.GenerateApplicationExpressions += AddCode => { // our content has been removed... if (content.DeclaringType != sln.Interactive.ApplicationType) return; var page_get_Content = new PseudoCallExpression { // Application(page) Object = "page", Method = new SolutionProjectLanguageMethod { IsProperty = true, Name = "get_Content", ReturnType = new KnownStockTypes.ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement() } }; var page_get_ContentSize = new PseudoCallExpression { // Application(page) Object = "page", Method = new SolutionProjectLanguageMethod { IsProperty = true, Name = "get_ContentSize", ReturnType = new KnownStockTypes.ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement() } }; AddCode( new KnownStockTypes.ScriptCoreLib.JavaScript.Extensions.AvalonExtensions.AttachToContainer().ToCallExpression( content, page_get_Content ) ); AddCode( new KnownStockTypes.ScriptCoreLib.JavaScript.Extensions.AvalonUltraExtensions.AutoSizeTo().ToCallExpression( content, page_get_ContentSize ) ); }; return sln; }
private static void UpdateTree(SolutionBuilder sln, SolutionFileView v, TreeNode _Solution, TreeNode _Project) { _Solution.Text = "Solution '" + sln.Name + "' (1 project)"; _Solution.IsExpanded = true; _Solution.WithIcon(() => new SolutionTwentyTen()); _Project.Text = sln.Name; _Project.IsExpanded = true; // Or my project? var _Properties = _Project.Add("Properties"); _Properties.IsExpanded = true; _Properties.WithIcon(() => new SolutionProjectProperties()); var _References = _Project.Add("References"); _References.IsExpanded = false; _References.WithIcon(() => new References()); foreach (var item in sln.References.ToArray()) { var _Reference = _References.Add(item.Attribute("Include").Value.TakeUntilIfAny(",")); _Reference.IsExpanded = true; _Reference.WithIcon(() => new Assembly()); } var FolderLookup = new Dictionary<string, TreeNode>(); var FileLookup = new Dictionary<SolutionFile, TreeNode>(); FolderLookup[_Properties.Text] = _Properties; var files = sln.ToFiles(); files.WithEach( f => { var ProjectInclude = f.Name.SkipUntilIfAny("/").SkipUntilIfAny("/"); var Folder = ProjectInclude.TakeUntilLastOrEmpty("/"); if (!string.IsNullOrEmpty(Folder)) { if (!FolderLookup.ContainsKey(Folder)) FolderLookup[Folder] = _Project.Add(Folder); } } ); files.WithEach( (SolutionFile f) => { var n = default(TreeNode); var Extension = "." + f.Name.SkipUntilLastIfAny("."); if (Extension == ".sln") { n = _Solution; } else if (Extension == sln.Language.ProjectFileExtension) { n = _Project; n.Element.TextArea.style.fontWeight = "bold"; } else { var ProjectInclude = f.Name.SkipUntilIfAny("/").SkipUntilIfAny("/"); var Folder = ProjectInclude.TakeUntilLastOrEmpty("/"); var Parent = _Project; if (!string.IsNullOrEmpty(Folder)) { Parent = FolderLookup[Folder]; } if (f.DependentUpon != null) { Parent = FileLookup[f.DependentUpon]; Parent.IsExpanded = false; } n = Parent.Add(ProjectInclude.SkipUntilLastIfAny("/")); FileLookup[f] = n; } if (Extension == ".cs") n.WithIcon(() => new VisualCSharpCode()); else if (Extension == ".csproj") n.WithIcon(() => new VisualCSharpProject()); else if (Extension == ".vb") n.WithIcon(() => new VisualBasicCode()); else if (Extension == ".vbproj") n.WithIcon(() => new VisualBasicProject()); else if (Extension == ".fs") n.WithIcon(() => new VisualFSharpCode()); else if (Extension == ".fsproj") n.WithIcon(() => new VisualFSharpProject()); else if (Extension == ".htm") n.WithIcon(() => new HTMLDocument()); if (f.DependentUpon != null) { n.WithIcon(() => new SolutionProjectDependentUpon()); } n.IsExpanded = true; n.Click += delegate { v.File = f; }; // somebody refreshed the solution. if (v.File == null) { if (f.Name.SkipUntilLastIfAny("/").TakeUntilLastIfAny(".") == "Application") v.File = f; } else { // we may not care about the file extensions, will we see a glitch? :) if (v.File.Name.SkipUntilLastIfAny("/").TakeUntilLastIfAny(".") == f.Name.SkipUntilLastIfAny("/").TakeUntilLastIfAny(".")) v.File = f; } } ); }
abstract public void WriteMethodBody(SolutionFile File, SolutionProjectLanguageCode Code, SolutionBuilder Context);
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(); } ); }
void UpdateTree(SolutionBuilder sln, SolutionFileView v, TreeNode _Solution, TreeNode _Project) { _Solution.Text = "Solution '" + sln.Name + "' (1 project)"; _Solution.IsExpanded = true; _Solution.WithIcon(() => new SolutionTwentyTen()); _Project.Text = sln.Name; _Project.IsExpanded = true; // Or my project? var PropertiesFolderName = "Properties"; if (sln.Language == KnownLanguages.VisualBasic) PropertiesFolderName = "My Project"; var _Properties = _Project.Add(PropertiesFolderName); _Properties.IsExpanded = true; _Properties.WithIcon(() => new SolutionProjectProperties()); var _References = _Project.Add("References"); _References.IsExpanded = false; _References.WithIcon(() => new References()); RenderReferences(sln, _References); var FolderLookup = new Dictionary<string, TreeNode>(); var FileLookup = new Dictionary<SolutionFile, TreeNode>(); FolderLookup[_Properties.Text] = _Properties; var files = sln.ToFiles(); files.WithEach( f => { var ProjectInclude = f.Name.SkipUntilIfAny("/").SkipUntilIfAny("/"); var Folder = ProjectInclude.TakeUntilLastOrEmpty("/"); if (!string.IsNullOrEmpty(Folder)) { if (!FolderLookup.ContainsKey(Folder)) { var _Folder = _Project.Add(Folder); FolderLookup[Folder] = _Folder; _Folder.IsExpanded = true; } } } ); files.WithEach( (SolutionFile f) => { var n = default(TreeNode); var Extension = "." + f.Name.SkipUntilLastIfAny("."); if (Extension == ".sln") { n = _Solution; } else if (Extension == sln.Language.ProjectFileExtension) { n = _Project; n.Element.TextArea.style.fontWeight = "bold"; } else { var ProjectInclude = f.Name.SkipUntilIfAny("/").SkipUntilIfAny("/"); var Folder = ProjectInclude.TakeUntilLastOrEmpty("/"); var Parent = _Project; if (!string.IsNullOrEmpty(Folder)) { Parent = FolderLookup[Folder]; } if (sln.Language.SupportsDependentUpon()) if (f.DependentUpon != null) { Parent = FileLookup[f.DependentUpon]; Parent.IsExpanded = false; } n = Parent.Add(ProjectInclude.SkipUntilLastIfAny("/")); FileLookup[f] = n; } if (Extension == KnownLanguages.VisualCSharp.CodeFileExtension) n.WithIcon(() => new VisualCSharpCode()); else if (Extension == KnownLanguages.VisualCSharp.ProjectFileExtension) n.WithIcon(() => new VisualCSharpProject()); else if (Extension == KnownLanguages.VisualBasic.CodeFileExtension) n.WithIcon(() => new VisualBasicCode()); else if (Extension == KnownLanguages.VisualBasic.ProjectFileExtension) n.WithIcon(() => new VisualBasicProject()); else if (Extension == KnownLanguages.VisualFSharp.CodeFileExtension) n.WithIcon(() => new VisualFSharpCode()); else if (Extension == KnownLanguages.VisualFSharp.ProjectFileExtension) n.WithIcon(() => new VisualFSharpProject()); else if (Extension == ".htm") n.WithIcon(() => new HTMLDocument()); else if (Extension == ".config") n.WithIcon(() => new ScriptCoreLib.Ultra.Components.HTML.Images.FromAssets.HTMLDocument()); else if (Extension == ".css") n.WithIcon(() => new StyleSheetFile()); if (f.ContextType != null) { if (f.ContextType.BaseType != null) { if (f.ContextType.BaseType is KnownStockTypes.System.Windows.Forms.UserControl) n.WithIcon(() => new SolutionProjectFormsControl()); if (f.ContextType.BaseType is KnownStockTypes.System.ComponentModel.Component) n.WithIcon(() => new SolutionProjectComponentImage()); } } if (sln.Language.SupportsDependentUpon()) if (f.DependentUpon != null) { n.WithIcon(() => new SolutionProjectDependentUpon()); } n.IsExpanded = true; n.Click += delegate { v.File = f; }; // somebody refreshed the solution. if (v.File == null) { if (f.Name.SkipUntilLastIfAny("/").TakeUntilLastIfAny(".") == "Application") v.File = f; } else { // we may not care about the file extensions, will we see a glitch? :) if (v.File.Name.SkipUntilLastIfAny("/").TakeUntilLastIfAny(".") == f.Name.SkipUntilLastIfAny("/").TakeUntilLastIfAny(".")) v.File = f; } } ); if (this.Save != null) { this.Save.Clear(); this.Save.FileName = sln.Name + ".sln.zip"; files.WithEach(f => this.Save.Add(f.Name, f.Content)); } }
static SolutionBuilder Internal(SolutionBuilder sln, bool ApplcationWebServiceAsComponent = false, bool IsApplet = false, Action <SolutionProjectLanguageField> NotifyContent = null ) { // should we make an Undo available? sln.ApplicationPage = StockPageDefault.CanvasDefaultPage; var content = default(SolutionProjectLanguageField); sln.Interactive.GenerateTypes += AddType => { #region ApplicationCanvas var ApplicationCanvas = new StockUserControlType(sln.Name, "ApplicationControl"); // in Canvas applications we want to focus only the canvas // to do that we hide other implementation detail classes //sln.Interactive.ApplicationWebServiceType.DependentUpon = ApplicationCanvas; if (ApplcationWebServiceAsComponent) { sln.Interactive.ApplicationWebServiceType.With( ApplicationWebServiceType => { var ApplicationWebServiceDesignerType = new SolutionProjectLanguagePartialType { Name = ApplicationWebServiceType.Name + ".Designer", }; ApplicationWebServiceDesignerType.Type.Name = ApplicationWebServiceType.Name; ApplicationWebServiceType.NamespaceChanged += delegate { ApplicationWebServiceDesignerType.Type.Namespace = ApplicationWebServiceType.Namespace; }; #region components var components = new SolutionProjectLanguageField { IsPrivate = true, Name = "components", Summary = "Required designer variable.", FieldType = new KnownStockTypes.System.ComponentModel.IContainer() }; ApplicationWebServiceDesignerType.Type.Fields.Add(components); #endregion #region InitializeComponent var InitializeComponent = new SolutionProjectLanguageMethod { Summary = @"Required method for Designer support - do not modify the contents of this method with the code editor.", IsPrivate = true, DeclaringType = ApplicationWebServiceDesignerType.Type, Name = "InitializeComponent", Code = new SolutionProjectLanguageCode { //set_Name, //set_Size } }; ApplicationWebServiceDesignerType.Type.Methods.Add(InitializeComponent); #endregion #region ApplicationWebServiceDesignerTypeConstructor var ApplicationWebServiceDesignerTypeConstructor = new SolutionProjectLanguageMethod { DeclaringType = ApplicationWebServiceDesignerType.Type, Name = SolutionProjectLanguageMethod.ConstructorName, Code = new SolutionProjectLanguageCode { new PseudoCallExpression { Object = new PseudoThisExpression(), Method = InitializeComponent } } }; ApplicationWebServiceDesignerType.Type.Methods.Add(ApplicationWebServiceDesignerTypeConstructor); #endregion ApplicationWebServiceType.BaseType = new KnownStockTypes.System.ComponentModel.Component(); ApplicationWebServiceType.DependentPartialTypes = new[] { ApplicationWebServiceDesignerType }; ApplicationWebServiceDesignerType.Type.UsingNamespaces.Add("System.ComponentModel"); } ); } sln.Interactive.ApplicationType.DependentUpon = ApplicationCanvas; sln.Interactive.ProgramType.DependentUpon = ApplicationCanvas; AddType(ApplicationCanvas); content = ApplicationCanvas.ToInitializedField("content"); content.DeclaringType = sln.Interactive.ApplicationType; // we are adding a field. does it show up in the source code later? // SolutionProjectLanguage.WriteType makes it happen! if (NotifyContent != null) { NotifyContent(content); } var Code = sln.Interactive.ProgramType_MainMethod.Code; sln.Interactive.ProgramType_MainMethod.Code = new SolutionProjectLanguageCode { new PseudoIfExpression { IsConditionalCompilationDirective = true, Expression = ("DEBUG"), FalseCase = Code, TrueCase = new SolutionProjectLanguageCode { new KnownStockTypes.ScriptCoreLib.Desktop.Forms.Extensions.DesktopFormsExtensions.Launch().ToCallExpression( null, new SolutionProjectLanguageMethod { ReturnType = ApplicationCanvas, Code = new SolutionProjectLanguageCode { ApplicationCanvas.GetDefaultConstructor() } } ) } } }; #endregion }; sln.Interactive.GenerateApplicationExpressions += AddCode => { // our content has been removed... if (content.DeclaringType != sln.Interactive.ApplicationType) { return; } if (!IsApplet) { AddCode( new KnownStockTypes.ScriptCoreLib.JavaScript.FormExtensions.AttachControlToDocument().ToCallExpression( content ) ); return; } var page_get_Content = new PseudoCallExpression { // Application(page) Object = "page", Method = new SolutionProjectLanguageMethod { IsProperty = true, Name = "get_Content", ReturnType = new KnownStockTypes.ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement() } }; var page_get_ContentSize = new PseudoCallExpression { // Application(page) Object = "page", Method = new SolutionProjectLanguageMethod { IsProperty = true, Name = "get_ContentSize", ReturnType = new KnownStockTypes.ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement() } }; AddCode( new KnownStockTypes.ScriptCoreLib.JavaScript.Windows.Forms.WindowsFormsExtensions.AttachControlTo().ToCallExpression( content, page_get_Content ) ); AddCode( new KnownStockTypes.ScriptCoreLib.JavaScript.Windows.Forms.WindowsFormsExtensions.AutoSizeControlTo().ToCallExpression( content, page_get_ContentSize ) ); }; return(sln); }
static SolutionBuilder InternalWithCanvas(SolutionBuilder sln, Action <SolutionProjectLanguageField> NotifyContent = null ) { // should we make an Undo available? sln.ApplicationPage = StockPageDefault.CanvasDefaultPage; var content = default(SolutionProjectLanguageField); sln.Interactive.GenerateTypes += AddType => { #region ApplicationCanvas var ApplicationCanvas = new StockCanvasType(sln.Name, "ApplicationCanvas"); // in Canvas applications we want to focus only the canvas // to do that we hide other implementation detail classes sln.Interactive.ApplicationWebServiceType.DependentUpon = ApplicationCanvas; sln.Interactive.ApplicationType.DependentUpon = ApplicationCanvas; sln.Interactive.ProgramType.DependentUpon = ApplicationCanvas; AddType(ApplicationCanvas); content = ApplicationCanvas.ToInitializedField("content"); content.DeclaringType = sln.Interactive.ApplicationType; // we are adding a field. does it show up in the source code later? // SolutionProjectLanguage.WriteType makes it happen! if (NotifyContent != null) { NotifyContent(content); } var Code = sln.Interactive.ProgramType_MainMethod.Code; sln.Interactive.ProgramType_MainMethod.Code = new SolutionProjectLanguageCode { new PseudoIfExpression { IsConditionalCompilationDirective = true, Expression = ("DEBUG"), FalseCase = Code, TrueCase = new SolutionProjectLanguageCode { new KnownStockTypes.ScriptCoreLib.Desktop.Extensions.DesktopAvalonExtensions.Launch().ToCallExpression( null, new SolutionProjectLanguageMethod { ReturnType = ApplicationCanvas, Code = new SolutionProjectLanguageCode { ApplicationCanvas.GetDefaultConstructor() } } ) } } }; #endregion }; sln.Interactive.GenerateApplicationExpressions += AddCode => { // our content has been removed... if (content.DeclaringType != sln.Interactive.ApplicationType) { return; } var page_get_Content = new PseudoCallExpression { // Application(page) Object = "page", Method = new SolutionProjectLanguageMethod { IsProperty = true, Name = "get_Content", ReturnType = new KnownStockTypes.ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement() } }; var page_get_ContentSize = new PseudoCallExpression { // Application(page) Object = "page", Method = new SolutionProjectLanguageMethod { IsProperty = true, Name = "get_ContentSize", ReturnType = new KnownStockTypes.ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement() } }; AddCode( new KnownStockTypes.ScriptCoreLib.JavaScript.Extensions.AvalonExtensions.AttachToContainer().ToCallExpression( content, page_get_Content ) ); AddCode( new KnownStockTypes.ScriptCoreLib.JavaScript.Extensions.AvalonUltraExtensions.AutoSizeTo().ToCallExpression( content, page_get_ContentSize ) ); }; return(sln); }
public static SolutionBuilder WithCanvas(this SolutionBuilder sln) { return(InternalWithCanvas(sln)); }
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 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; }
abstract public void WritePseudoCallExpression(SolutionFile File, PseudoCallExpression Lambda, SolutionBuilder Context);
abstract public void WriteAssemblyAttribute(SolutionFile File, SolutionProjectLanguageAttribute Attribute, SolutionBuilder Context);
// to be used only on .net public static void WriteToConsole(this SolutionBuilder that) { var Lookup = new Dictionary <SolutionFileTextFragment, ConsoleColor> { { SolutionFileTextFragment.Comment, ConsoleColor.Green }, { SolutionFileTextFragment.Keyword, ConsoleColor.Cyan }, { SolutionFileTextFragment.None, ConsoleColor.Gray }, { SolutionFileTextFragment.String, ConsoleColor.Red }, { SolutionFileTextFragment.XMLAttributeName, ConsoleColor.Red }, { SolutionFileTextFragment.XMLAttributeValue, ConsoleColor.Blue }, { SolutionFileTextFragment.XMLComment, ConsoleColor.Green }, { SolutionFileTextFragment.XMLKeyword, ConsoleColor.Blue }, { SolutionFileTextFragment.Type, ConsoleColor.Yellow }, }; var zip = new ZIPFile(); that.WriteTo( SolutionFile => { Console.BackgroundColor = ConsoleColor.Blue; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(" " + SolutionFile.Name + " "); //if (SolutionFile.WriteHistory.Count > 1) foreach (var item in SolutionFile.WriteHistory) { if (item.Fragment == SolutionFileTextFragment.Indent) { Console.BackgroundColor = ConsoleColor.DarkGray; } else if (item.Fragment == SolutionFileTextFragment.XMLText) { Console.BackgroundColor = ConsoleColor.DarkCyan; } else { Console.BackgroundColor = ConsoleColor.Black; } if (Lookup.ContainsKey(item.Fragment)) { Console.ForegroundColor = Lookup[item.Fragment]; } else { Console.ForegroundColor = ConsoleColor.Gray; } Console.Write(item.Text); } Console.WriteLine(); zip.Add(SolutionFile.Name, SolutionFile.Content); } ); var Output = new FileInfo(that.Name).FullName + ".zip"; Console.WriteLine(Output); File.WriteAllBytes(Output, zip.ToBytes()); }
private static void RenderReferences(SolutionBuilder sln, TreeNode _References) { // why doesn't LINQ work anymore? var OrderedReferences = sln.References.Select( item => { var Include = item.Attribute("Include"); return Include.Value.TakeUntilIfAny(","); } ) .OrderBy(k => k) .ToArray(); foreach (var item in OrderedReferences) { var _Reference = _References.Add(item); _Reference.IsExpanded = true; if (sln.NuGetReferences.Any(k => k.id == item)) { // nuget pacages are special // cant we have .important rule group? _Reference.Element.TextArea.css.hover.style.setProperty( "color", "blue", "important" ); _Reference.Click += delegate { // go to jsc store // or id we link up to that other service? Native.window.open( "http://my.jsc-solutions.net/#" + item ); }; _Reference.WithIcon(() => new MergeAssemblyImage()); } else { //_Reference.Element.TextArea.style.color = "gray"; _Reference.WithIcon(() => new Assembly()); } } }
public static void WriteToArchiveFile(this SolutionBuilder that, FileInfo f) { var zip = that.WriteToArchive(); File.WriteAllBytes(f.FullName, zip.ToBytes()); }
abstract public void WriteMethod(SolutionFile File, SolutionProjectLanguageMethod Method, SolutionBuilder Context);
static SolutionBuilder Internal(SolutionBuilder sln, bool ApplcationWebServiceAsComponent = false, bool IsApplet = false, Action<SolutionProjectLanguageField> NotifyContent = null ) { // should we make an Undo available? sln.ApplicationPage = StockPageDefault.CanvasDefaultPage; var content = default(SolutionProjectLanguageField); sln.Interactive.GenerateTypes += AddType => { #region ApplicationCanvas var ApplicationCanvas = new StockUserControlType(sln.Name, "ApplicationControl"); // in Canvas applications we want to focus only the canvas // to do that we hide other implementation detail classes //sln.Interactive.ApplicationWebServiceType.DependentUpon = ApplicationCanvas; if (ApplcationWebServiceAsComponent) { sln.Interactive.ApplicationWebServiceType.With( ApplicationWebServiceType => { var ApplicationWebServiceDesignerType = new SolutionProjectLanguagePartialType { Name = ApplicationWebServiceType.Name + ".Designer", }; ApplicationWebServiceDesignerType.Type.Name = ApplicationWebServiceType.Name; ApplicationWebServiceType.NamespaceChanged += delegate { ApplicationWebServiceDesignerType.Type.Namespace = ApplicationWebServiceType.Namespace; }; #region components var components = new SolutionProjectLanguageField { IsPrivate = true, Name = "components", Summary = "Required designer variable.", FieldType = new KnownStockTypes.System.ComponentModel.IContainer() }; ApplicationWebServiceDesignerType.Type.Fields.Add(components); #endregion #region InitializeComponent var InitializeComponent = new SolutionProjectLanguageMethod { Summary = @"Required method for Designer support - do not modify the contents of this method with the code editor.", IsPrivate = true, DeclaringType = ApplicationWebServiceDesignerType.Type, Name = "InitializeComponent", Code = new SolutionProjectLanguageCode { //set_Name, //set_Size } }; ApplicationWebServiceDesignerType.Type.Methods.Add(InitializeComponent); #endregion #region ApplicationWebServiceDesignerTypeConstructor var ApplicationWebServiceDesignerTypeConstructor = new SolutionProjectLanguageMethod { DeclaringType = ApplicationWebServiceDesignerType.Type, Name = SolutionProjectLanguageMethod.ConstructorName, Code = new SolutionProjectLanguageCode { new PseudoCallExpression { Object = new PseudoThisExpression(), Method = InitializeComponent } } }; ApplicationWebServiceDesignerType.Type.Methods.Add(ApplicationWebServiceDesignerTypeConstructor); #endregion ApplicationWebServiceType.BaseType = new KnownStockTypes.System.ComponentModel.Component(); ApplicationWebServiceType.DependentPartialTypes = new[] { ApplicationWebServiceDesignerType }; ApplicationWebServiceDesignerType.Type.UsingNamespaces.Add("System.ComponentModel"); } ); } sln.Interactive.ApplicationType.DependentUpon = ApplicationCanvas; sln.Interactive.ProgramType.DependentUpon = ApplicationCanvas; AddType(ApplicationCanvas); content = ApplicationCanvas.ToInitializedField("content"); content.DeclaringType = sln.Interactive.ApplicationType; // we are adding a field. does it show up in the source code later? // SolutionProjectLanguage.WriteType makes it happen! if (NotifyContent != null) NotifyContent(content); var Code = sln.Interactive.ProgramType_MainMethod.Code; sln.Interactive.ProgramType_MainMethod.Code = new SolutionProjectLanguageCode { new PseudoIfExpression { IsConditionalCompilationDirective = true, Expression = ("DEBUG"), FalseCase = Code, TrueCase = new SolutionProjectLanguageCode { new KnownStockTypes.ScriptCoreLib.Desktop.Forms.Extensions.DesktopFormsExtensions.Launch().ToCallExpression( null, new SolutionProjectLanguageMethod { ReturnType = ApplicationCanvas, Code = new SolutionProjectLanguageCode { ApplicationCanvas.GetDefaultConstructor() } } ) } } }; #endregion }; sln.Interactive.GenerateApplicationExpressions += AddCode => { // our content has been removed... if (content.DeclaringType != sln.Interactive.ApplicationType) return; if (!IsApplet) { AddCode( new KnownStockTypes.ScriptCoreLib.JavaScript.FormExtensions.AttachControlToDocument().ToCallExpression( content ) ); return; } var page_get_Content = new PseudoCallExpression { // Application(page) Object = "page", Method = new SolutionProjectLanguageMethod { IsProperty = true, Name = "get_Content", ReturnType = new KnownStockTypes.ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement() } }; var page_get_ContentSize = new PseudoCallExpression { // Application(page) Object = "page", Method = new SolutionProjectLanguageMethod { IsProperty = true, Name = "get_ContentSize", ReturnType = new KnownStockTypes.ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement() } }; AddCode( new KnownStockTypes.ScriptCoreLib.JavaScript.Windows.Forms.WindowsFormsExtensions.AttachControlTo().ToCallExpression( content, page_get_Content ) ); AddCode( new KnownStockTypes.ScriptCoreLib.JavaScript.Windows.Forms.WindowsFormsExtensions.AutoSizeControlTo().ToCallExpression( content, page_get_ContentSize ) ); }; return sln; }
abstract public void WriteType(SolutionFile File, SolutionProjectLanguageType Type, SolutionBuilder Context);
public Rules(SolutionFileView v, SolutionBuilder sln, Action Update) { #region AtLink Action<Uri, Action<int>> AtLink = (Link, Handler) => { var Counter = 0; v.LinkCommentClick += uri => { if (uri == Link) { Counter++; Handler(Counter); } }; }; #endregion 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(); } ); Action<InteractiveComment> AtInteractiveComment = c => { AtLink(c, vv => { c.RaiseClick(); Update(); } ); }; sln.Interactive.Comments.WithEach(AtInteractiveComment); }
public static SolutionBuilder WithFormsApplet(this SolutionBuilder sln) { var content = default(SolutionProjectLanguageField); var sprite = default(SolutionProjectLanguageField); Internal(sln, IsApplet: true, ApplcationWebServiceAsComponent: false, NotifyContent: value => content = value); sln.Interactive.GenerateTypes += AddType => { var ApplicationSprite = new StockAppletType(sln.Name, "ApplicationApplet", content); ApplicationSprite.DependentUpon = content.FieldType; content.DeclaringType = ApplicationSprite; sprite = ApplicationSprite.ToInitializedField("applet"); sprite.DeclaringType = sln.Interactive.ApplicationType; AddType(ApplicationSprite); }; sln.Interactive.GenerateApplicationExpressions += AddCode => { var page_get_Content = new PseudoCallExpression { // Application(page) Object = "page", Method = new SolutionProjectLanguageMethod { IsProperty = true, Name = "get_Content", ReturnType = new KnownStockTypes.ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement() } }; var page_get_ContentSize = new PseudoCallExpression { // Application(page) Object = "page", Method = new SolutionProjectLanguageMethod { IsProperty = true, Name = "get_ContentSize", ReturnType = new KnownStockTypes.ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement() } }; AddCode( new KnownStockTypes.ScriptCoreLib.JavaScript.Extensions.AppletExtensions.AutoSizeAppletTo().ToCallExpression( sprite, page_get_ContentSize ) ); AddCode( new KnownStockTypes.ScriptCoreLib.JavaScript.Extensions.AppletExtensions.AttachAppletTo().ToCallExpression( sprite, page_get_Content ) ); }; return(sln); }
public static void WriteToArchiveFile(this SolutionBuilder that) { that.WriteToArchiveFile(new FileInfo(that.Name + ".zip")); }
public static SolutionBuilder WithAdobeFlashWithFlare3D(this SolutionBuilder sln) { Func <StockSpriteType> GetType = () => new StockSpriteType(sln.Name, "ApplicationSprite"); var sprite = default(SolutionProjectLanguageField); sln.Interactive.GenerateTypes += AddType => { var ApplicationSprite = GetType(); sprite = ApplicationSprite.ToInitializedField("sprite"); sprite.DeclaringType = sln.Interactive.ApplicationType; // as per X:\jsc.svn\market\synergy\actionscript\Flare3DWaterShipComponent\Flare3DWaterShipComponent\ApplicationSprite.cs // jsc does not like field initializers to properties in anonymous type? var Types_ship = new SolutionProjectLanguageType { Namespace = "Flare3DWaterShipComponent", Name = "ship" }; var Types_Viewer3D = new SolutionProjectLanguageType { Namespace = "flare.basic", Name = "Viewer3D" }; var Types_Camera3D = new SolutionProjectLanguageType { Namespace = "flare.core", Name = "Camera3D" }; var Methods_set_scene = new SolutionProjectLanguageMethod { Name = "set_scene", IsProperty = true, DeclaringType = ApplicationSprite }; var Methods_set_camera = new SolutionProjectLanguageMethod { Name = "set_camera", IsProperty = true, DeclaringType = Types_Viewer3D }; var Methods_setPosition = new SolutionProjectLanguageMethod { Name = "setPosition", DeclaringType = Types_Camera3D }; var Methods_lookAt = new SolutionProjectLanguageMethod { Name = "lookAt", DeclaringType = Types_Camera3D }; var Methods_addChild = new SolutionProjectLanguageMethod { Name = "addChild", DeclaringType = Types_Viewer3D, ReturnType = Types_Viewer3D }; var this_camera = Types_Camera3D.ToInitializedField("camera"); var this_ship = Types_ship.ToInitializedField("ship"); var this_scene = new SolutionProjectLanguageField { FieldType = Types_Viewer3D, Name = "scene", IsReadOnly = true }; //ApplicationSprite.Fields.Add(this_ship); ApplicationSprite.Fields.Add(this_camera); ApplicationSprite.Fields.Add(this_scene); var newobj_Viewer3D = new PseudoCallExpression { Method = Types_Viewer3D.GetDefaultConstructorDefinition(), ParameterExpressions = new object[] { new PseudoThisExpression() } }; var set_scene_to_newobj_Viewer3D = Methods_set_scene.ToCallExpression( new PseudoThisExpression(), newobj_Viewer3D ); ApplicationSprite.Constructor.Code.Add(set_scene_to_newobj_Viewer3D); var this_camera_setPosition = Methods_setPosition.ToCallExpression(this_camera, (PseudoDoubleConstantExpression)120.0, (PseudoDoubleConstantExpression)40.0, (PseudoDoubleConstantExpression)(-30.0) ); ApplicationSprite.Constructor.Code.Add(this_camera_setPosition); var this_camera_lookAt = Methods_lookAt.ToCallExpression(this_camera, (PseudoDoubleConstantExpression)0.0, (PseudoDoubleConstantExpression)0.0, (PseudoDoubleConstantExpression)0.0 ); ApplicationSprite.Constructor.Code.Add(this_camera_lookAt); ApplicationSprite.Constructor.Code.Add( Methods_set_camera.ToCallExpression(this_scene, this_camera) ); ApplicationSprite.Constructor.Code.Add( Methods_addChild.ToCallExpression(this_scene, Types_ship.GetDefaultConstructor()) ); AddType(ApplicationSprite); }; sln.Interactive.GenerateApplicationExpressions += AddCode => { AddCode(new CreateMySprite(GetType(), sprite)); }; // ..\packages\Flare3D.1.0.0.0\lib\Flare3D.dll sln.NuGetReferences.Add( new ScriptCoreLib.Ultra.Studio.SolutionBuilder.package { id = "Flare3D" } ); sln.NuGetReferences.Add( new ScriptCoreLib.Ultra.Studio.SolutionBuilder.package { id = "Flare3DWaterShipComponent" } ); return(sln); }
public static void Write(this SolutionFile File, SolutionProjectLanguage Language, SolutionBuilder Context, SolutionFileComment[] Comments) { if (Comments != null) { File.Region( delegate { foreach (var item in Comments) { item.WriteTo(File, Language, Context); } } ); } }