public static EditTemplate Open(TemplateSet template) { var window = GetWindow<EditTemplate>(); window.Init(template); return window; }
public override void ExportProject(Dictionary <string, FileOutput> output, IList <LibraryForExport> libraries, ResourceDatabase resourceDatabase, Options options) { Dictionary <string, string> replacements = this.GenerateReplacementDictionary(options, resourceDatabase); TemplateReader templates = new TemplateReader(new PkgAwareFileUtil(), this); TemplateSet vmTemplates = templates.GetVmTemplates(); string functions = vmTemplates.GetText("functions.php"); string structs = vmTemplates.GetText("structs.php"); string byteCode = ConvertStringToVariableSetterFile(resourceDatabase.ByteCodeFile.TextContent, "_CRAYON_BYTE_CODE"); string resourceManifest = ConvertStringToVariableSetterFile(resourceDatabase.ResourceManifestFile.TextContent, "_CRAYON_RESOURCE_MANIFEST"); output["crayon_gen/bytecode.php"] = FileOutput.OfString(byteCode); output["crayon_gen/resource_manifest.php"] = FileOutput.OfString(resourceManifest); output["crayon_gen/functions.php"] = FileOutput.OfString(functions); output["crayon_gen/structs.php"] = FileOutput.OfString(structs); output["index.php"] = FileOutput.OfString(this.LoadTextResource("Resources/index.php", replacements)); output[".htaccess"] = FileOutput.OfString(this.LoadTextResource("Resources/htaccess.txt", replacements)); List <string> libsIncluder = new List <string>() { "<?php" }; foreach (LibraryForExport library in libraries.Where(lib => lib.HasNativeCode)) { foreach (string key in library.ExportEntities.Keys) { foreach (ExportEntity entity in library.ExportEntities[key]) { switch (key) { case "COPY_CODE": string target = entity.Values["target"]; string fileContent = entity.FileOutput.TextContent; int lastLine = fileContent.LastIndexOf('\n'); fileContent = fileContent.Substring(0, lastLine); // trim off '?>' fileContent = fileContent.TrimEnd() + string.Join("\n", new string[] { "", "", "\t$_CRAYON_LIBS['" + library.Name + "'] = crayon_generateFunctionLookup('CrayonLibWrapper_" + library.Name + "');", "?>", }); output["crayon_gen/" + target] = FileOutput.OfString(fileContent); libsIncluder.Add("\trequire 'crayon_gen/" + target + "';"); break; default: throw new System.NotImplementedException(); } } } } libsIncluder.Add("?>"); output["crayon_gen/libs.php"] = FileOutput.OfString(string.Join("\n", libsIncluder)); }
private protected override IFrameFrame GetAssociatedFrame(IFrameInner <IFrameBrowsingChildIndex> inner) { IFocusNodeState Owner = ((IFocusInner <IFocusBrowsingChildIndex>)inner).Owner; IFocusNodeStateView StateView = (IFocusNodeStateView)StateViewTable[Owner]; IList <FocusFrameSelectorList> SelectorStack = StateView.GetSelectorStack(); IFocusFrame AssociatedFrame = TemplateSet.InnerToFrame((IFocusInner <IFocusBrowsingChildIndex>)inner, SelectorStack) as IFocusFrame; return(AssociatedFrame); }
private void GUI4SelectTempalte(TemplateSet template) { EditorGUILayout.BeginHorizontal(); template.Extension = EditorGUILayout.TextField("Extension: ", template.Extension); if(GUILayout.Button("Select")) { EditTemplate.Open(template); } EditorGUILayout.EndHorizontal(); }
protected override void Arrange() { _assemblyData = new AssemblyData { AssemblyName = "testAssembly", Path = "testFolder", TemplateSet = "standard" }; _templateSet = new TemplateSet { Name = "Entities.mustache", Driver = "Entities", OutputPath = "Models\\Entities\\Entities.generated.cs" }; var templates = new List <TemplateSet> { _templateSet }; var model = new object(); _templateContext = new TemplateContext(); _templateWriter = Stub <ITemplateWriter>(); _codeRepositoryProvider = Stub <ICodeRepositoryProvider>(); _templateSetProvider = Stub <ITemplateSetProvider>(); _templateContextProvider = Stub <ITemplateContextProvider>(); _generator = Stub <IGenerator>(); _generatorProvider = Stub <IGeneratorProvider>(); A.CallTo(() => _codeRepositoryProvider.GetResolvedCodeRepositoryByName(A <string> ._, A <string> ._)) .Returns("testRepo\\testFolder"); A.CallTo(() => _templateSetProvider.GetTemplatesByName(A <string> ._)) .Returns(templates); A.CallTo(() => _templateContextProvider.Create(A <AssemblyData> ._)) .Returns(_templateContext); A.CallTo(() => _generator.Generate(A <TemplateContext> ._)) .Returns(model); A.CallTo(() => _generatorProvider.GetGeneratorByDriverName(A <string> ._)) .Returns(_generator); _templateProcessor = new TemplateProcessor( _generatorProvider, _templateWriter, _templateSetProvider, _templateContextProvider); }
private void GetLibraryCode( TemplateReader templateReader, string baseDir, LibraryForExport library, List <LangCSharp.DllFile> dllsOut, HashSet <string> dotNetRefs, Dictionary <string, FileOutput> filesOut) { string libraryName = library.Name; TemplateSet libTemplates = templateReader.GetLibraryTemplates(library); List <string> libraryLines = new List <string>(); string libraryDir = baseDir + "Libraries/" + libraryName; foreach (string structKey in libTemplates.GetPaths("gen/structs/")) { string structFileName = structKey.Substring(structKey.LastIndexOf('/') + 1); string structName = System.IO.Path.GetFileNameWithoutExtension(structFileName); filesOut[libraryDir + "/" + structName + ".cs"] = new FileOutput() { Type = FileOutputType.Text, TextContent = libTemplates.GetText(structKey), }; } foreach (string helperFile in libTemplates.GetPaths("source/")) { filesOut[libraryDir + "/" + helperFile.Substring("source/".Length)] = new FileOutput() { Type = FileOutputType.Text, TextContent = libTemplates.GetText(helperFile), }; } filesOut[libraryDir + "/LibraryWrapper.cs"] = new FileOutput() { Type = FileOutputType.Text, TextContent = libTemplates.GetText("gen/LibraryWrapper.cs"), }; foreach (ExportEntity dllFile in library.ExportEntities["DOTNET_DLL"]) { dllsOut.Add(new LangCSharp.DllFile(dllFile)); } foreach (ExportEntity dotNetRef in library.ExportEntities["DOTNET_REF"]) { dotNetRefs.Add(dotNetRef.StringValue); } }
/// <summary> /// Create a Template Set with Picklist Values /// </summary> /// <param name="user_dc">User data category name</param> /// <param name="tbx_dc">User data category name</param> /// <returns>Template Set with Picklist values</returns> private TemplateSet createTemplateSet(string user_dc, string tbx_dc) { (string target, string eltAtt) = getEltTgtEltAtt(tbx_dc); TemplateSet ts = new TemplateSet(); Dictionary <string, string> sub = new Dictionary <string, string>(); TBXContentMap cm = mappingDict.getTBXContentMap(user_dc); PicklistMap pm = mappingDict.getPicklistMap(user_dc); foreach (string content in cm?.Keys) { if (cm[content] == tbx_dc) { sub.Add(content, pm[content]); } } ((ts[0] as KeyList)[0] as Teasp).setAll(target, eltAtt, sub); return(ts); }
private void ExportInterpreter( TemplateReader templateReader, string baseDir, Dictionary <string, FileOutput> output) { TemplateSet vmTemplates = templateReader.GetVmTemplates(); foreach (string structKey in vmTemplates.GetPaths("structs/")) { string structFileName = structKey.Substring(structKey.LastIndexOf('/') + 1); string structName = System.IO.Path.GetFileNameWithoutExtension(structFileName); output[baseDir + "Structs/" + structName + ".cs"] = new FileOutput() { Type = FileOutputType.Text, TextContent = vmTemplates.GetText(structKey), }; } output[baseDir + "Vm/CrayonWrapper.cs"] = new FileOutput() { Type = FileOutputType.Text, TextContent = vmTemplates.GetText("CrayonWrapper.cs"), }; }
public override void ExportProject( Dictionary <string, FileOutput> output, IList <LibraryForExport> libraries, ResourceDatabase resourceDatabase, Options options) { List <string> jsExtraHead = new List <string>() { options.GetStringOrEmpty(ExportOptionKey.JS_HEAD_EXTRAS) }; if (options.GetBool(ExportOptionKey.JS_FULL_PAGE)) { jsExtraHead.Add( "<script type=\"text/javascript\">" + "C$common$globalOptions['fullscreen'] = true;" + "</script>"); } options.SetOption(ExportOptionKey.JS_HEAD_EXTRAS, string.Join("\n", jsExtraHead)); Dictionary <string, string> replacements = this.GenerateReplacementDictionary(options, resourceDatabase); TemplateReader templateReader = new TemplateReader(new PkgAwareFileUtil(), this); TemplateSet vmTemplates = templateReader.GetVmTemplates(); output["vm.js"] = new FileOutput() { Type = FileOutputType.Text, TextContent = vmTemplates.GetText("vm.js"), }; List <LibraryForExport> librariesWithCode = new List <LibraryForExport>(); foreach (LibraryForExport library in libraries.Where(lib => lib.HasNativeCode)) { string libraryName = library.Name; TemplateSet libTemplates = templateReader.GetLibraryTemplates(library); List <string> libraryLines = new List <string>(); libraryLines.Add(libTemplates.GetText("gen/lib_" + libraryName.ToLowerInvariant() + ".js")); libraryLines.Add(""); libraryLines.Add("C$common$scrapeLibFuncNames('" + libraryName.ToLowerInvariant() + "');"); libraryLines.Add(""); // add helper functions after the scrape. foreach (string jsHelperFile in libTemplates.GetPaths("source/", ".js")) { libraryLines.Add(libTemplates.GetText(jsHelperFile)); libraryLines.Add(""); } output["libs/lib_" + libraryName.ToLowerInvariant() + ".js"] = new FileOutput() { Type = FileOutputType.Text, TextContent = string.Join(this.NL, libraryLines), }; librariesWithCode.Add(library); } Dictionary <string, string> htmlReplacements = new Dictionary <string, string>(replacements); replacements["JS_LIB_INCLUSIONS"] = GenerateJsLibInclusionHtml(output.Keys); this.CopyResourceAsText(output, "index.html", "Resources/HostHtml.txt", replacements); this.CopyResourceAsText(output, "test_server.py", "Resources/TestServerPy.txt", replacements); this.CopyResourceAsText(output, "common.js", "Resources/Common.txt", replacements); System.Text.StringBuilder resourcesJs = new System.Text.StringBuilder(); foreach (FileOutput textResource in resourceDatabase.TextResources) { resourcesJs.Append("C$common$addTextRes("); resourcesJs.Append(StringTokenUtil.ConvertStringValueToCode(textResource.CanonicalFileName)); resourcesJs.Append(", "); resourcesJs.Append(StringTokenUtil.ConvertStringValueToCode(textResource.TextContent)); resourcesJs.Append(");\n"); } foreach (FileOutput fontResource in resourceDatabase.FontResources) { resourcesJs.Append("C$common$addBinaryRes("); resourcesJs.Append(StringTokenUtil.ConvertStringValueToCode(fontResource.CanonicalFileName)); resourcesJs.Append(", '"); resourcesJs.Append(Base64.ToBase64(fontResource.GetFinalBinaryContent())); resourcesJs.Append("');\n"); } FileOutput imageSheetManifest = resourceDatabase.ImageSheetManifestFile; resourcesJs.Append("C$common$addTextRes('image_sheets.txt', "); resourcesJs.Append(imageSheetManifest == null ? "''" : StringTokenUtil.ConvertStringValueToCode(imageSheetManifest.TextContent)); resourcesJs.Append(");\n"); resourcesJs.Append("C$common$resourceManifest = "); resourcesJs.Append(StringTokenUtil.ConvertStringValueToCode(resourceDatabase.ResourceManifestFile.TextContent)); resourcesJs.Append(";\n"); string filePrefix = options.GetStringOrNull(ExportOptionKey.JS_FILE_PREFIX); if (filePrefix != null) { resourcesJs.Append("C$common$jsFilePrefix = "); resourcesJs.Append(StringTokenUtil.ConvertStringValueToCode(filePrefix)); resourcesJs.Append(";\n"); } output["resources.js"] = new FileOutput() { Type = FileOutputType.Text, TextContent = resourcesJs.ToString(), }; output["bytecode.js"] = new FileOutput() { Type = FileOutputType.Text, TextContent = "C$bytecode = " + StringTokenUtil.ConvertStringValueToCode(resourceDatabase.ByteCodeFile.TextContent) + ";", }; foreach (string imageResourceFile in resourceDatabase.ImageSheetFiles.Keys) { FileOutput file = resourceDatabase.ImageSheetFiles[imageResourceFile]; output["resources/images/" + imageResourceFile] = file; } foreach (FileOutput audioResourceFile in resourceDatabase.AudioResources) { output["resources/audio/" + audioResourceFile.CanonicalFileName] = audioResourceFile; } // TODO: minify JavaScript across all of output dictionary }
public override void ExportProject( Dictionary <string, FileOutput> output, IList <LibraryForExport> libraries, ResourceDatabase resourceDatabase, Options options) { Dictionary <string, string> replacements = this.GenerateReplacementDictionary(options, resourceDatabase); string srcPath = "src"; string srcPackagePath = srcPath + "/" + replacements["JAVA_PACKAGE"].Replace('.', '/') + "/"; List <string> imports = new List <string>() { "import java.util.ArrayList;", "import java.util.HashMap;", "import org.crayonlang.interpreter.Interpreter;", "import org.crayonlang.interpreter.TranslationHelper;", "import org.crayonlang.interpreter.ResourceReader;", "import org.crayonlang.interpreter.structs.*;", }; imports.Sort(); TemplateReader templateReader = new TemplateReader(new PkgAwareFileUtil(), this); foreach (LibraryForExport library in libraries.Where(t => t.HasNativeCode)) { TemplateSet libraryTemplates = templateReader.GetLibraryTemplates(library); string libraryPath = srcPath + "/org/crayonlang/libraries/" + library.Name.ToLowerInvariant(); foreach (string templatePath in libraryTemplates.GetPaths("gen/").Concat(libraryTemplates.GetPaths("source/"))) { string code = libraryTemplates.GetText(templatePath); string realPath = templatePath.Substring(templatePath.IndexOf('/') + 1); output[libraryPath + "/" + realPath] = new FileOutput() { Type = FileOutputType.Text, TextContent = code, TrimBomIfPresent = realPath.EndsWith(".java"), }; } } TemplateSet vmTemplates = templateReader.GetVmTemplates(); output["src/org/crayonlang/interpreter/vm/CrayonWrapper.java"] = new FileOutput() { Type = FileOutputType.Text, TextContent = vmTemplates.GetText("CrayonWrapper.java"), TrimBomIfPresent = true, }; foreach (string structKey in vmTemplates.GetPaths("structs/")) { string structName = System.IO.Path.GetFileNameWithoutExtension(structKey); string structCode = vmTemplates.GetText(structKey); output["src/org/crayonlang/interpreter/structs/" + structName + ".java"] = new FileOutput() { Type = FileOutputType.Text, TextContent = structCode, TrimBomIfPresent = true, }; } // common Java helper files this.CopyResourceAsText(output, "src/org/crayonlang/interpreter/LibraryInstance.java", "Resources/LibraryInstance.java", replacements); this.CopyResourceAsText(output, "src/org/crayonlang/interpreter/TranslationHelper.java", "Resources/TranslationHelper.java", replacements); this.CopyResourceAsText(output, "src/org/crayonlang/interpreter/PlatformTranslationHelper.java", "Resources/PlatformTranslationHelper.java", replacements); // java-app specific files this.CopyResourceAsText(output, "src/org/crayonlang/interpreter/LibraryLoader.java", "Resources/LibraryLoader.java", replacements); this.CopyResourceAsText(output, "src/org/crayonlang/interpreter/ResourceReader.java", "Resources/ResourceReader.java", replacements); this.CopyResourceAsText(output, srcPackagePath + "/Main.java", "Resources/Main.java", replacements); this.CopyResourceAsText(output, "build.xml", "Resources/Build.xml", replacements); output["resources/manifest.txt"] = resourceDatabase.ResourceManifestFile; output["resources/bytecode.txt"] = resourceDatabase.ByteCodeFile; if (resourceDatabase.ImageSheetManifestFile != null) { output["resources/imagesheetmanifest.txt"] = resourceDatabase.ImageSheetManifestFile; } foreach (string imageSheetFileName in resourceDatabase.ImageSheetFiles.Keys) { FileOutput imageSheetFile = resourceDatabase.ImageSheetFiles[imageSheetFileName]; output["resources/images/" + imageSheetFileName] = imageSheetFile; } foreach (FileOutput audioResource in resourceDatabase.AudioResources) { output["resources/audio/" + audioResource.CanonicalFileName] = audioResource; } foreach (FileOutput textResource in resourceDatabase.TextResources) { output["resources/text/" + textResource.CanonicalFileName] = textResource; } foreach (FileOutput fontResource in resourceDatabase.FontResources) { output["resources/ttf/" + fontResource.CanonicalFileName] = fontResource; } IEnumerable <FileOutput> javaFiles = output.Keys .Where(filename => filename.ToLowerInvariant().EndsWith(".java")) .Select(filename => output[filename]); foreach (FileOutput file in javaFiles) { file.TrimBomIfPresent = true; } }
public AdvancedComboBox() { this.OnChangeHandler = new OnChangeDelegate(this.OnChangeSafe); this.OnItemRemovedHandler = new OnItemRemovedDelegate(this.OnItemRemovedSafe); base.AutoScroll = false; base.Size = new Size(100, 0x12); this.m_dbConnector = new Resco.Controls.AdvancedComboBox.DataConnector(); this.m_connector = this.m_dbConnector; this.m_bKeyNavigation = true; this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.m_list = new AdvancedList(this); this.m_list.Capture = false; this.m_list.Visible = false; this.m_list.TouchScrolling = false; this.m_list.BorderStyle = this.BorderStyle;//.set_BorderStyle(this.BorderStyle); this.m_list.Size = new Size(0, 0); this.m_list.ItemSelect += new ItemEventHandler(this.OnItemSelect); this.m_list.Changed += new ComboBoxEventHandler(this.OnChange); this.SelectedIndexChanged = null; this.SelectedValueChanged = null; this.ValueMemberChanged = null; this.DisplayMemberChanged = null; this.m_items = new ItemCollection(this); this.m_items.Changed += new ComboBoxEventHandler(this.OnChange); this.m_iExpectedItems = -1; this.m_nItemsLoaded = 0; this.m_nItemsInserted = 0; this.m_selectedItemIndex = -1; this.m_iSelectedCellIndex = -1; this.m_valueMember = ""; this.m_displayMember = ""; this.m_tsCurrent = new TemplateSet(); this.m_tsCurrent.Parent = this; this.m_tsCurrent.Changed += new ComboBoxEventHandler(this.OnChange); this.m_textBoxTemplateIndex = 0; this.m_templateIndex = 0; this.m_selectedTemplateIndex = 0; this.m_alternateTemplateIndex = -1; this.m_grBackBuffer = null; this.m_backBuffer = null; this.m_colorKey = Color.FromArgb(0xff, 0, 0xff); this.m_brushKey = new SolidBrush(this.m_colorKey); this.m_imgAttr = new ImageAttributes(); this.m_imgAttr.SetColorKey(this.m_colorKey, this.m_colorKey); this.UpdateDoubleBuffering(); base.BackColor = SystemColors.ControlLight; this.m_BackColor = new SolidBrush(this.BackColor); this.m_Timer = new Timer(); this.m_Timer.Enabled = false; this.m_Timer.Interval = 500; this.m_Timer.Tick += new EventHandler(this.OnTimerTick); this.m_bShowingToolTip = false; point1 = new Point(0, 0); point2 = new Point(0, -TooltipWidth); point3 = new Point(-TooltipWidth, 0); this.CalculateTextBoxArea(); }
public override void ExportProject( Dictionary <string, FileOutput> output, IList <LibraryForExport> libraries, ResourceDatabase resourceDatabase, Options options) { Dictionary <string, string> replacements = this.GenerateReplacementDictionary(options, resourceDatabase); TemplateReader templates = new TemplateReader(new PkgAwareFileUtil(), this); TemplateSet vmTemplates = templates.GetVmTemplates(); output["code/vm.py"] = new FileOutput() { Type = FileOutputType.Text, TextContent = string.Join(this.NL, new string[] { this.LoadTextResource("Resources/header.txt", replacements), this.LoadTextResource("Resources/TranslationHelper.txt", replacements), this.LoadTextResource("Resources/LibraryRegistry.txt", replacements), this.LoadTextResource("Resources/ResourceReader.txt", replacements), vmTemplates.GetText("vm.py"), }), }; foreach (LibraryForExport library in libraries) { if (library.HasNativeCode) { TemplateSet libTemplates = new TemplateReader(new PkgAwareFileUtil(), this).GetLibraryTemplates(library); string libraryName = library.Name; List <string> libraryLines = new List <string>(); libraryLines.Add("import math"); libraryLines.Add("import os"); libraryLines.Add("import random"); libraryLines.Add("import sys"); libraryLines.Add("import time"); libraryLines.Add("import inspect"); libraryLines.Add("from code.vm import *"); libraryLines.Add(""); foreach (string genCodePath in libTemplates.GetPaths("gen/")) { libraryLines.Add(libTemplates.GetText(genCodePath)); libraryLines.Add(""); } libraryLines.Add(""); libraryLines.Add("_moduleInfo = ('" + libraryName + "', dict(inspect.getmembers(sys.modules[__name__])))"); libraryLines.Add(""); foreach (string genCodePath in libTemplates.GetPaths("source/")) { libraryLines.Add(libTemplates.GetText(genCodePath)); libraryLines.Add(""); } output["code/lib_" + libraryName.ToLowerInvariant() + ".py"] = new FileOutput() { Type = FileOutputType.Text, TextContent = string.Join(this.NL, libraryLines), }; } } output["main.py"] = new FileOutput() { Type = FileOutputType.Text, TextContent = this.LoadTextResource("Resources/main.txt", replacements), }; output["code/__init__.py"] = new FileOutput() { Type = FileOutputType.Text, TextContent = "", }; output["res/bytecode.txt"] = resourceDatabase.ByteCodeFile; output["res/resource_manifest.txt"] = resourceDatabase.ResourceManifestFile; if (resourceDatabase.ImageSheetManifestFile != null) { output["res/image_sheet_manifest.txt"] = resourceDatabase.ImageSheetManifestFile; } foreach (FileOutput image in resourceDatabase.ImageResources) { output["res/images/" + image.CanonicalFileName] = image; } foreach (string imageSheetFile in resourceDatabase.ImageSheetFiles.Keys) { output["res/images/" + imageSheetFile] = resourceDatabase.ImageSheetFiles[imageSheetFile]; } foreach (FileOutput sound in resourceDatabase.AudioResources) { output["res/audio/" + sound.CanonicalFileName] = sound; } foreach (FileOutput textResource in resourceDatabase.TextResources) { output["res/text/" + textResource.CanonicalFileName] = textResource; } foreach (FileOutput fontResource in resourceDatabase.FontResources) { output["res/ttf/" + fontResource.CanonicalFileName] = fontResource; } }
internal ItemTemplate GetTemplate(TemplateSet ts) { int currentTemplateIndex = this.CurrentTemplateIndex; if ((currentTemplateIndex < 0) || (currentTemplateIndex >= ts.Count)) { if ((this.m_parent != null) && (this.m_parent.Parent != null)) { return this.m_parent.Parent.DefaultTemplates[this.Selected ? 1 : 0]; } return null; } return ts[currentTemplateIndex]; }
internal int GetHeight(TemplateSet ts) { int currentTemplateIndex = this.CurrentTemplateIndex; if ((currentTemplateIndex < 0) || (currentTemplateIndex >= ts.Count)) { if ((this.m_parent != null) && (this.m_parent.Parent != null)) { return this.m_parent.Parent.DefaultTemplates[this.Selected ? 1 : 0].Height; } return -1; } return ts[currentTemplateIndex].GetHeight(this); }
public override void ExportProject( Dictionary <string, FileOutput> output, BuildData buildData, ExportProperties exportProperties) { List <string> jsExtraHead = new List <string>() { exportProperties.JsHeadExtras ?? "" }; if (exportProperties.JsFullPage) { jsExtraHead.Add( "<script type=\"text/javascript\">" + "C$common$globalOptions['fullscreen'] = true;" + "</script>"); } if (buildData.UsesU3) { Dictionary <string, FileOutput> u3Files = new Dictionary <string, FileOutput>(); foreach (string file in noriFiles) { this.CopyResourceAsText(u3Files, file, "ResourcesU3/" + file, new Dictionary <string, string>()); } List <string> newFile = new List <string>(); foreach (string file in noriFiles) { newFile.Add("// From " + file); newFile.Add(u3Files[file].TextContent.Trim()); } output["u3.js"] = new FileOutput() { Type = FileOutputType.Text, TextContent = string.Join("\n", newFile), }; jsExtraHead.Add("<script src=\"u3.js\"></script>"); } exportProperties.JsHeadExtras = string.Join("\n", jsExtraHead); ResourceDatabase resDb = buildData.CbxBundle.ResourceDB; Dictionary <string, string> replacements = this.GenerateReplacementDictionary(exportProperties, buildData); TemplateReader templateReader = new TemplateReader(new PkgAwareFileUtil(), this, null); TemplateSet vmTemplates = templateReader.GetVmTemplates(); output["vm.js"] = new FileOutput() { Type = FileOutputType.Text, TextContent = vmTemplates.GetText("vm.js"), }; Dictionary <string, string> htmlReplacements = new Dictionary <string, string>(replacements); this.CopyResourceAsText(output, "index.html", "Resources/HostHtml.txt", replacements); this.CopyResourceAsText(output, "test_server.py", "Resources/TestServerPy.txt", replacements); this.CopyResourceAsText(output, "common.js", "Resources/Common.txt", replacements); System.Text.StringBuilder resourcesJs = new System.Text.StringBuilder(); string[] fileNames = resDb.FlatFileNames; FileOutput[] files = resDb.FlatFiles; for (int i = 0; i < files.Length; i++) { FileOutput file = files[i]; string name = fileNames[i]; if (file.Type == FileOutputType.Text) { resourcesJs.Append("C$common$addTextRes("); resourcesJs.Append(ConvertStringValueToCode(name)); resourcesJs.Append(", "); resourcesJs.Append(ConvertStringValueToCode(file.TextContent)); resourcesJs.Append(");\n"); } else if (name.EndsWith(".png") || name.EndsWith(".jpg")) { output["resources/" + name] = file; } else if (name.EndsWith(".wav") || name.EndsWith(".ogg") || name.EndsWith(".mp3")) { output["resources/" + name] = file; } else { resourcesJs.Append("C$common$addBinaryRes("); resourcesJs.Append(ConvertStringValueToCode(name)); resourcesJs.Append(", '"); resourcesJs.Append(System.Convert.ToBase64String(file.GetFinalBinaryContent())); resourcesJs.Append("');\n"); } } resourcesJs.Append("C$common$resourceManifest = "); resourcesJs.Append(ConvertStringValueToCode(resDb.ResourceManifestFile.TextContent)); resourcesJs.Append(";\n"); string filePrefix = exportProperties.JsFilePrefix; if (filePrefix != null) { resourcesJs.Append("C$common$jsFilePrefix = "); resourcesJs.Append(ConvertStringValueToCode(filePrefix)); resourcesJs.Append(";\n"); } string imageManifest = resDb.ImageResourceManifestFile.TextContent; imageManifest = ConvertStringValueToCode(imageManifest); resourcesJs.Append("C$common$imageManifest = " + imageManifest + ";\n"); output["resources.js"] = new FileOutput() { Type = FileOutputType.Text, TextContent = resourcesJs.ToString(), }; output["bytecode.js"] = new FileOutput() { Type = FileOutputType.Text, TextContent = "C$bytecode = " + ConvertStringValueToCode(buildData.CbxBundle.ByteCode) + ";", }; if (exportProperties.HasIcon) { this.GenerateIconFile(output, "favicon.ico", exportProperties); } // TODO: minify JavaScript across all of output dictionary }
private void Init(TemplateSet template) { if(template == null) { this.Close(); } this.previousLabel = template.label; this.template = template; Action repaint = () => this.Repaint(); this.ignores = new StringListField("Paths that ignore", repaint, this.template.ignores); this.considers = new StringListField("Paths that consider", repaint, this.template.considers); this.functions = new ListField<ExecutorFunctionSet>("Executor functions", (index, value) => this.GUI4ExecutorFunction(index, value), repaint, this.template.functions); this.functions.ShowHorizontalScrollBar = false; this.efpath = Getters4Editor.GetExecutorFunctionsPath(MetadataHolder.Instance); this.efobject = Getters4Editor.GetExecutorFunctionsObject(MetadataHolder.Instance); this.titleContent.text = "Edit Template"; this.titleContent.tooltip = "Edit Template Window"; }
protected override void Dispose(bool disposing) { if (sBrushes != null) { sBrushes.Clear(); } sBrushes = null; if (disposing && (this.m_list != null)) { this.m_list.Dispose(); this.m_list = null; } this.m_items = null; this.m_tsCurrent = null; if (this.m_alLinks != null) { this.m_alLinks.Clear(); } this.m_alLinks = null; if (this.m_alTooltips != null) { this.m_alTooltips.Clear(); } this.m_alTooltips = null; if (this.m_alButtons != null) { this.m_alButtons.Clear(); } this.m_alButtons = null; if (this.m_dbConnector != null) { this.m_dbConnector.Dispose(); this.m_dbConnector = null; } this.ButtonClick = null; this.CellClick = null; this.LinkClick = null; this.DropDown = null; this.DropDownClosed = null; this.SelectedIndexChanged = null; this.SelectedValueChanged = null; this.ValueMemberChanged = null; this.DisplayMemberChanged = null; Utility.Dispose(); Links.Dispose(); Resco.Controls.AdvancedComboBox.Mapping.DisposeEmptyMapping(); ImageCache.GlobalCache.Clear(); GC.Collect(); base.Dispose(disposing); }
internal int GetHeight(int i, TemplateSet ts) { if ((i < 0) || (i >= base.List.Count)) { return 0; } ListItem item = (ListItem) base.InnerList[i]; int height = this.GetTemplate(item).GetHeight(item); if (this.Parent.List.GridLines) { height++; } return height; }
internal int Draw(Graphics gr, TemplateSet ts, int width, int ymax, int iItem, int iItemOffset, ref bool resetScrollbar) { int num = (((this.Parent != null) && this.Parent.RightToLeft) && this.Parent.List.ScrollbarVisible) ? this.Parent.List.ClientScrollbarWidth : 0; int yOffset = iItemOffset; int count = base.List.Count; this.LastDrawnItemOffset = yOffset; this.LastDrawnItem = iItem; while (this.LastDrawnItem < count) { ListItem item = null; if ((this.LastDrawnItem >= 0) && (this.LastDrawnItem < base.InnerList.Count)) { item = base.InnerList[this.LastDrawnItem] as ListItem; } if (item != null) { ItemTemplate template = item.GetTemplate(ts); int height = 0; int num5 = -1; if (template.CustomizeCells(item)) { num5 = template.GetHeight(item); item.ResetCachedBounds(); } height = template.GetHeight(item); if ((num5 >= 0) && (height != num5)) { resetScrollbar = true; } if ((yOffset + height) >= 0) { template.Draw(gr, 0, yOffset, item, width, height); } this.LastDrawnItemOffset = yOffset; yOffset += height; if (this.Parent.List.GridLines) { gr.DrawLine(this.m_penBorder, num, yOffset, width + num, yOffset); yOffset++; } if (yOffset > ymax) { return yOffset; } } this.LastDrawnItem++; } this.LastDrawnItemOffset = yOffset; return yOffset; }