public override void GleanInformationFromPreviouslyExportedProject(ExportProperties exportProperties, string outputDirectory) { bool skipWorkspaceXml = FileUtil.FileExists(outputDirectory + "/.idea/workspace.xml"); exportProperties.SkipAndroidWorkspaceXml = skipWorkspaceXml; exportProperties.AndroidSdkLocation = this.GetAndroidSdkLocation(outputDirectory); }
public ExportProperties(ExportProperties other) : this(assimp_swigPINVOKE.new_ExportProperties__SWIG_1(ExportProperties.getCPtr(other)), true) { if (assimp_swigPINVOKE.SWIGPendingException.Pending) { throw assimp_swigPINVOKE.SWIGPendingException.Retrieve(); } }
public override void GleanInformationFromPreviouslyExportedProject(ExportProperties exportProperties, string outputDirectory) { string pbxproj = FileUtil.JoinPath( outputDirectory, exportProperties.ProjectID ?? "", (exportProperties.ProjectID ?? "") + ".xcodeproj", "project.pbxproj"); if (FileUtil.FileExists(pbxproj)) { string contents = FileUtil.ReadFileText(pbxproj); int devTeam = contents.IndexOf("DevelopmentTeam = "); if (devTeam != -1) { devTeam += "DevelopmentTeam = ".Length; int devTeamEnd = contents.IndexOf(';', devTeam); if (devTeamEnd != -1) { string value = contents.Substring(devTeam, devTeamEnd - devTeam).Trim(); if (value.Length > 0 && !value.Contains("\n")) { exportProperties.IosDevTeamId = value; } } } } }
public override Dictionary <string, string> GenerateReplacementDictionary( ExportProperties exportProperties, BuildData buildData) { return(MiscUtil.MergeDictionaries( this.ParentPlatform.GenerateReplacementDictionary(exportProperties, buildData), new Dictionary <string, string>() { { "PROJECT_TITLE", exportProperties.ProjectTitle }, { "FAVICON", exportProperties.HasIcon ? "<link rel=\"shortcut icon\" href=\"" + exportProperties.JsFilePrefix + "favicon.ico\">" : "" }, { "CSS_EXTRA", exportProperties.JsFullPage ? ("#crayon_host { background-color:#000; text-align:left; width: 100%; height: 100%; }\n" + "body { overflow:hidden; }") : "" }, { "JS_EXTRA_HEAD", exportProperties.JsHeadExtras }, })); }
public static ExportResponse Run( Platform.AbstractPlatform platform, string projectDirectory, string outputDirectory, BuildData buildData) { if (platform == null) { throw new InvalidOperationException("Unrecognized platform. See usage."); } if (!Path.IsAbsolute(outputDirectory)) { outputDirectory = FileUtil.JoinPath(projectDirectory, outputDirectory); } outputDirectory = FileUtil.GetCanonicalizeUniversalPath(outputDirectory); FileOutputExporter exporter = new FileOutputExporter(outputDirectory); Dictionary <string, FileOutput> result = new Dictionary <string, FileOutput>(); ExportProperties exportProperties = buildData.ExportProperties; platform.GleanInformationFromPreviouslyExportedProject(exportProperties, outputDirectory); platform.ExportProject(result, buildData, exportProperties); exporter.ExportFiles(result); return(new ExportResponse()); }
public override void ExportProject( Dictionary <string, FileOutput> output, BuildData buildData, ExportProperties exportProperties) { throw new NotImplementedException(); }
public override Dictionary<string, string> GenerateReplacementDictionary( ExportProperties exportProperties, BuildData buildData) { Dictionary<string, string> replacements = this.ParentPlatform.GenerateReplacementDictionary(exportProperties, buildData); replacements["ORGANIZATION_NAME"] = "Organization Name"; replacements["DEVELOPMENT_TEAM_ALL_CAPS"] = ""; replacements["DEVELOPMENT_TEAM_NOT_CAPS"] = ""; string developmentTeam = exportProperties.IosDevTeamId; if (developmentTeam != null) { replacements["DEVELOPMENT_TEAM_NOT_CAPS"] = "DevelopmentTeam = " + developmentTeam + ";"; replacements["DEVELOPMENT_TEAM_ALL_CAPS"] = "DEVELOPMENT_TEAM = " + developmentTeam + ";"; } string bundleIdPrefix = exportProperties.IosBundlePrefix; replacements["IOS_BUNDLE_ID"] = bundleIdPrefix == null ? exportProperties.ProjectID : bundleIdPrefix + "." + exportProperties.ProjectID; Orientations orientations = exportProperties.Orientations; replacements["IOS_SUPPORTED_ORIENTATIONS_INFO_PLIST"] = string.Join("", "\t<array>\n", orientations.SupportsPortrait ? "\t\t<string>UIInterfaceOrientationPortrait</string>\n" : "", orientations.SupportsUpsideDown ? "\t\t<string>UIInterfaceOrientationPortraitUpsideDown</string>\n" : "", orientations.SupportsLandscapeLeft ? "\t\t<string>UIInterfaceOrientationLandscapeLeft</string>\n" : "", orientations.SupportsLandscapeRight ? "\t\t<string>UIInterfaceOrientationLandscapeRight</string>\n" : "", "\t</array>"); return replacements; }
public string GetExportProperty(string key) { if (ExportProperties.ContainsKey(key)) { return(ExportProperties[key]); } return(string.Empty); }
static void ShowNamePopup() { ExportWindow window = new ExportWindow(); string[] assets = AssetDatabase.FindAssets("ExportProperties t:ExportProperties", new[] { "Assets/UCO" }); if (assets.Length > 0) { Debug.Log(AssetDatabase.GUIDToAssetPath(assets[0])); exportProperties = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(assets[0]), typeof(ExportProperties)) as ExportProperties; studentName = exportProperties.studentName; } window.ShowUtility(); }
public override Dictionary <string, string> GenerateReplacementDictionary( ExportProperties exportProperties, BuildData buildData) { Dictionary <string, string> replacements = this.ParentPlatform.GenerateReplacementDictionary(exportProperties, buildData); replacements["ANDROID_ORIENTATION"] = this.ConvertOrientationString(exportProperties.Orientations); // This logic is duplicated in LangJava's PlatformImpl replacements["JAVA_PACKAGE"] = (exportProperties.JavaPackage ?? exportProperties.ProjectID).ToLowerInvariant(); if (replacements["JAVA_PACKAGE"].StartsWith("org.crayonlang.interpreter")) { throw new InvalidOperationException("Cannot use org.crayonlang.interpreter as the project's package."); } return(replacements); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ExportProperties obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public static void ExportSceneXFile(string file, IOSystem iosystem, AssimpSharp.Scene scene, ExportProperties propoerties) { throw (new NotImplementedException()); }
public override Dictionary <string, string> GenerateReplacementDictionary( ExportProperties exportProperties, BuildData buildData) { return(AbstractPlatform.GenerateGeneralReplacementsDictionary(exportProperties)); }
public aiExportDataBlob ExportToBlob(aiScene pScene, string pFormatId, aiPostProcessSteps pPreprocessing, ExportProperties pProperties) { global::System.IntPtr cPtr = assimp_swigPINVOKE.Exporter_ExportToBlob__SWIG_0(swigCPtr, aiScene.getCPtr(pScene), pFormatId, (uint)pPreprocessing, ExportProperties.getCPtr(pProperties)); aiExportDataBlob ret = (cPtr == global::System.IntPtr.Zero) ? null : new aiExportDataBlob(cPtr, false); return(ret); }
public aiReturn Export(aiScene pScene, string pFormatId, string pPath, aiPostProcessSteps pPreprocessing, ExportProperties pProperties) { aiReturn ret = (aiReturn)assimp_swigPINVOKE.Exporter_Export__SWIG_0(swigCPtr, aiScene.getCPtr(pScene), pFormatId, pPath, (uint)pPreprocessing, ExportProperties.getCPtr(pProperties)); return(ret); }
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 }
public virtual void GleanInformationFromPreviouslyExportedProject( ExportProperties exportProperties, string outputDirectory) { }
public void GenerateIconFile(Dictionary <string, FileOutput> files, string iconOutputPath, ExportProperties exportProperties) { string[] iconPaths = exportProperties.IconPaths; Wax.Util.Images.IconGenerator iconGen = new Wax.Util.Images.IconGenerator(); foreach (string path in iconPaths) { iconGen.AddImage(new Wax.Util.Images.Bitmap(path.Trim())); } files[iconOutputPath] = new FileOutput() { Type = FileOutputType.Binary, BinaryContent = iconGen.GenerateIconFile(), }; }
public abstract Dictionary <string, string> GenerateReplacementDictionary(ExportProperties exportProperties, BuildData buildData);
protected static Dictionary <string, string> GenerateGeneralReplacementsDictionary(ExportProperties exportProperties) { return(new Dictionary <string, string>() { { "PROJECT_ID", exportProperties.ProjectID }, { "PROJECT_ID_LOWERCASE", exportProperties.ProjectID.ToLowerInvariant() }, { "PROJECT_TITLE", exportProperties.ProjectTitle ?? "Untitled Project" }, { "PROJECT_DESCRIPTION", exportProperties.Description ?? "" }, { "PROJECT_VERSION", exportProperties.Version ?? "" }, { "DEFAULT_WINDOW_WIDTH", "800" }, { "DEFAULT_WINDOW_HEIGHT", "600" }, }); }
public abstract void ExportProject( Dictionary <string, FileOutput> output, BuildData buildData, ExportProperties exportProperties);
public void OutputAndroidBoilerplate(Dictionary <string, FileOutput> output, Dictionary <string, string> replacements, ExportProperties exportProperties) { string androidSdkLocation = exportProperties.AndroidSdkLocation; replacements["ANDROID_SDK_LOCATION"] = this.EscapeAndroidSdkPath(androidSdkLocation); string packagedDir = replacements["JAVA_PACKAGE"].Replace('.', '/'); output[".gitignore"] = this.LoadTextFile("JsAndroidResources/gitignore.txt", replacements); output["build.gradle"] = this.LoadTextFile("JsAndroidResources/buildGradle.txt", replacements); output[replacements["PROJECT_ID_LOWERCASE"] + ".iml"] = this.LoadTextFile("JsAndroidResources/androidIml.txt", replacements); output["gradle.properties"] = this.LoadTextFile("JsAndroidResources/gradleProperties.txt", replacements); output["gradlew"] = this.LoadTextFile("JsAndroidResources/gradlew.txt", replacements); output["gradlew.bat"] = this.LoadTextFile("JsAndroidResources/gradlewBat.txt", replacements); output["local.properties"] = this.LoadTextFile("JsAndroidResources/localProperties.txt", replacements); output["settings.gradle"] = this.LoadTextFile("JsAndroidResources/settingsGradle.txt", replacements); output["gradle/wrapper/gradle-wrapper.jar"] = this.LoadBinaryFile("JsAndroidResources/gradle/wrapper/GradleWrapper.jar"); output["gradle/wrapper/gradle-wrapper.properties"] = this.LoadTextFile("JsAndroidResources/gradle/wrapper/GradleWrapperProperties.txt", replacements); output[".idea/compiler.xml"] = this.LoadTextFile("JsAndroidResources/idea/compilerXml.txt", replacements); output[".idea/encodings.xml"] = this.LoadTextFile("JsAndroidResources/idea/encodingsXml.txt", replacements); output[".idea/gradle.xml"] = this.LoadTextFile("JsAndroidResources/idea/gradleXml.txt", replacements); output[".idea/misc.xml"] = this.LoadTextFile("JsAndroidResources/idea/miscXml.txt", replacements); output[".idea/modules.xml"] = this.LoadTextFile("JsAndroidResources/idea/modulesXml.txt", replacements); output[".idea/vcs.xml"] = this.LoadTextFile("JsAndroidResources/idea/vcsXml.txt", replacements); output[".idea/copyright/profiles_settings.xml"] = this.LoadTextFile("JsAndroidResources/idea/copyright/profileSettings.txt", replacements); output[".idea/scopes/scope_settings.xml"] = this.LoadTextFile("JsAndroidResources/idea/scopes/scopeSettings.txt", replacements); if (!exportProperties.SkipAndroidWorkspaceXml) { output[".idea/workspace.xml"] = this.LoadTextFile("JsAndroidResources/idea/workspaceXml.txt", replacements); } output["app/.gitignore"] = this.LoadTextFile("JsAndroidResources/app/gitignore.txt", replacements); output["app/app.iml"] = this.LoadTextFile("JsAndroidResources/app/appIml.txt", replacements); output["app/build.gradle"] = this.LoadTextFile("JsAndroidResources/app/buildGradle.txt", replacements); output["app/proguard-rules.txt"] = this.LoadTextFile("JsAndroidResources/app/proguardRules.txt", replacements); output["app/src/main/java/" + packagedDir + "/app/MainActivity.java"] = this.LoadTextFile("JsAndroidResources/app/src/main/java/org/crayonlang/sampleapp/app/MainActivityJava.txt", replacements); output["app/src/main/java/" + packagedDir + "/app/CrayonWebView.java"] = this.LoadTextFile("JsAndroidResources/app/src/main/java/org/crayonlang/sampleapp/app/CrayonWebViewJava.txt", replacements); output["app/src/main/res/layout/activity_main.xml"] = this.LoadTextFile("JsAndroidResources/app/src/main/res/layout/ActivityMainXml.txt", replacements); output["app/src/main/res/menu/main.xml"] = this.LoadTextFile("JsAndroidResources/app/src/main/res/menu/MainXml.txt", replacements); output["app/src/main/res/values/dimens.xml"] = this.LoadTextFile("JsAndroidResources/app/src/main/res/values/DimensXml.txt", replacements); output["app/src/main/res/values/strings.xml"] = this.LoadTextFile("JsAndroidResources/app/src/main/res/values/StringsXml.txt", replacements); output["app/src/main/res/values/styles.xml"] = this.LoadTextFile("JsAndroidResources/app/src/main/res/values/StylesXml.txt", replacements); output["app/src/main/res/values-w820dp/dimens.xml"] = this.LoadTextFile("JsAndroidResources/app/src/main/res/valuesW820dp/DimensXml.txt", replacements); FileOutput androidManifest = this.LoadTextFile("JsAndroidResources/app/src/main/AndroidManifestXml.txt", replacements); output["app/src/main/AndroidManifest.xml"] = androidManifest; IconSetGenerator icons = new IconSetGenerator(); if (exportProperties.HasIcon) { string[] iconPaths = exportProperties.IconPaths; foreach (string iconPath in iconPaths) { Bitmap icon = new Bitmap(iconPath); icons.AddInputImage(icon); } } Dictionary <int, Bitmap> iconImagesBySize = icons .AddOutputSize(48) .AddOutputSize(72) .AddOutputSize(96) .AddOutputSize(144) .AddOutputSize(512) .GenerateWithDefaultFallback(); output["app/src/main/res/drawable-mdpi/ic_launcher.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[48] }; output["app/src/main/res/drawable-hdpi/ic_launcher.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[72] }; output["app/src/main/res/drawable-xhdpi/ic_launcher.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[96] }; output["app/src/main/res/drawable-xxhdpi/ic_launcher.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[144] }; output["app/src/main/ic_launcher-web.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[512] }; output["app/src/main/assets/android.js"] = this.LoadTextFile("JsAndroidResources/app/src/main/assets/androidJs.txt", replacements); }
public override void ExportProject( Dictionary <string, FileOutput> output, BuildData buildData, ExportProperties exportProperties) { Dictionary <string, string> replacements = this.GenerateReplacementDictionary(exportProperties, buildData); this.OutputAndroidBoilerplate(output, replacements, exportProperties); exportProperties.JsFilePrefix = null; exportProperties.JsFullPage = false; exportProperties.JsHeadExtras = string.Join( "\n", "<script type=\"text/javascript\" src=\"android.js\"></script>", "<style type=\"text/css\">", " body { margin:0px; background-color:#000; }", " #crayon_host {", " background-color:#000;", " text-align:left;", " width:100%;", " height:100%;", " }", "</style>" ); Dictionary <string, FileOutput> files = new Dictionary <string, FileOutput>(); Dictionary <string, FileOutput> basicProject = new Dictionary <string, FileOutput>(); this.ParentPlatform.ExportProject( basicProject, buildData, exportProperties); foreach (string filePath in basicProject.Keys) { FileOutput file = basicProject[filePath]; if (filePath.EndsWith("index.html")) { file.TextContent = file.TextContent.Replace( "<script type=\"text/javascript\" src=\"", "<script type=\"text/javascript\" src=\"file:///android_asset/"); file.TextContent = file.TextContent.Replace( "<link rel=\"shortcut icon\" href=\"favicon.ico\">", ""); } else if (filePath == "test_server.py") { // TODO: add an option called INCLUDE_TEST_SERVER for the parent platform so that this doesn't appear in the first place. continue; } files["app/src/main/assets/" + filePath] = file; } // TODO: use orientations Orientations orientations = exportProperties.Orientations; foreach (string filename in files.Keys) { output[this.ApplyReplacements(filename, replacements)] = files[filename]; } }
public override void ExportProject( Dictionary<string, FileOutput> output, BuildData buildData, ExportProperties exportProperties) { exportProperties.JsFilePrefix = null; exportProperties.JsFullPage = false; // iOS export has its own enforced fullscreen logic exportProperties.JsHeadExtras = ""; Dictionary<string, string> replacements = this.GenerateReplacementDictionary(exportProperties, buildData); Dictionary<string, FileOutput> files = new Dictionary<string, FileOutput>(); Dictionary<string, FileOutput> basicProject = new Dictionary<string, FileOutput>(); this.ParentPlatform.ExportProject( basicProject, buildData, exportProperties); foreach (string filePath in basicProject.Keys) { files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/" + filePath] = basicProject[filePath]; } // TODO: use this in the pbxproj file. string uuidSeed = exportProperties.GuidSeed; Orientations orientations = exportProperties.Orientations; bool useLandscapeForLaunchscreen = orientations.SupportsLandscapeLeft || orientations.SupportsLandscapeRight; FileOutput launchScreen; if (exportProperties.HasLaunchScreen) { launchScreen = new FileOutput() { Type = FileOutputType.Image, Bitmap = new Bitmap(exportProperties.LaunchScreenPath), }; } else { string resourcePath = "SwiftResources/" + (useLandscapeForLaunchscreen ? "launchhorizontal.png" : "launchvertical.png"); byte[] bytes = new ResourceStore(typeof(JavaScriptAppIos.PlatformImpl)).ReadAssemblyFileBytes(resourcePath); launchScreen = new FileOutput() { Type = FileOutputType.Image, Bitmap = new Bitmap(bytes), }; } files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/Launchscreen.imageset/launchscreen.png"] = launchScreen; replacements["LAUNCH_SCREEN_WIDTH"] = launchScreen.Bitmap.Width.ToString(); replacements["LAUNCH_SCREEN_HEIGHT"] = launchScreen.Bitmap.Height.ToString(); IconSetGenerator icons = new IconSetGenerator(); if (exportProperties.HasIcon) { foreach (string iconPath in exportProperties.IconPaths) { Bitmap icon = new Bitmap(iconPath); icons.AddInputImage(icon); } } Dictionary<int, Bitmap> iconImagesBySize = icons .AddOutputSize(20 * 1) .AddOutputSize(20 * 2) .AddOutputSize(20 * 3) .AddOutputSize(29 * 1) .AddOutputSize(29 * 2) .AddOutputSize(29 * 3) .AddOutputSize(40 * 1) .AddOutputSize(40 * 2) .AddOutputSize(40 * 3) .AddOutputSize(60 * 2) .AddOutputSize(60 * 3) .AddOutputSize(76 * 1) .AddOutputSize(76 * 2) .AddOutputSize(167) // 83.5 * 2 .AddOutputSize(1024) .GenerateWithDefaultFallback(); foreach (int size in iconImagesBySize.Keys) { files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/AppIcon.appiconset/icon" + size + ".png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[size], }; } foreach (string pair in new string[] { "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%.xcodeproj/project.pbxproj|SwiftResources/PbxProj.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/AppDelegate.swift|SwiftResources/AppDelegateSwift.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/AppIcon.appiconset/Contents.json|SwiftResources/IconSetContentJson.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/Launchscreen.imageset/Contents.json|SwiftResources/ImageSetContentJson.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Base.lproj/LaunchScreen.storyboard|SwiftResources/LaunchScreenStoryboard.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Base.lproj/Main.storyboard|SwiftResources/MainStoryboard.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Info.plist|SwiftResources/InfoPlist.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/ViewController.swift|SwiftResources/ViewControllerSwift.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/ios.js|SwiftResources/iOSjs.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/index.html|SwiftResources/HostHtml.txt", }) { string[] parts = pair.Split('|'); files[parts[0]] = new FileOutput() { TrimBomIfPresent = true, Type = FileOutputType.Text, TextContent = this.LoadTextResource(parts[1], replacements), }; } foreach (string filename in files.Keys) { output[this.ApplyReplacements(filename, replacements)] = files[filename]; } }
/// <summary> /// Saves the current map as an image to the specified file. /// </summary> /// <param name="fileName">The file name.</param> /// <param name="properties">The export properties.</param> /// <param name="format">The image format.</param> public void SaveMap(string fileName, ExportProperties properties, ImageFormat format) { // Create a new bitmap. Bitmap bitmap = new Bitmap(properties.Size.Width, properties.Size.Height); // Compute the map scale. MapScale mapScale = new MapScale( properties.Size.Width / this.mapBounds.Width, properties.Size.Height / this.mapBounds.Height ); // Compute the grid. MapSize majorGridSize = new MapSize(1.0, 1.0); MapSize minorGridSize = new MapSize(1.0, 1.0); Point majorGridBegin; Point majorGridEnd; Point minorGridBegin; Point minorGridEnd; // Compute the grid size. majorGridSize = new MapSize( Math.Pow(10.0, Math.Floor(Math.Log10(this.mapSize.Width))), Math.Pow(10.0, Math.Floor(Math.Log10(this.mapSize.Height))) ); // Adjust the horizontal grid. if (majorGridSize.Width > 10.0) { // Select the first value than results in a displayed width greater than the minimum width. for (int index = 0; index < MapControl.majorGridValues.Length; index++) { if (majorGridValues[index] * mapScale.Width >= MapControl.majorGridMinimumSize.Width) { majorGridSize.Width = MapControl.majorGridValues[index]; minorGridSize.Width = MapControl.minorGridValues[index]; break; } } // Limit the grid size to the highest value. if (majorGridSize.Width > MapControl.majorGridValues[MapControl.majorGridValues.Length - 1]) { majorGridSize.Width = MapControl.majorGridValues[MapControl.majorGridValues.Length - 1]; minorGridSize.Width = MapControl.minorGridValues[MapControl.majorGridValues.Length - 1]; } } else { // Select the first factor that results in a displayed width greater than the minimum width. for (int index = 0; index < MapControl.majorGridFactor.Length; index++) { if (majorGridSize.Width * MapControl.majorGridFactor[index] >= MapControl.majorGridMinimumSize.Width) { majorGridSize.Width *= MapControl.majorGridFactor[index]; minorGridSize.Width = majorGridSize.Width * minorGridFactor[index]; break; } } } // Adjust the vertical grid. if (majorGridSize.Height > 10.0) { // Select the first value than results in a displayed height greater than the minimum height. for (int index = 0; index < MapControl.majorGridValues.Length; index++) { if (MapControl.majorGridValues[index] * mapScale.Height >= MapControl.majorGridMinimumSize.Height) { majorGridSize.Height = MapControl.majorGridValues[index]; minorGridSize.Height = MapControl.minorGridValues[index]; break; } } // Limit the grid size to the highest value. if (majorGridSize.Height > MapControl.majorGridValues[MapControl.majorGridValues.Length - 1]) { majorGridSize.Height = MapControl.majorGridValues[MapControl.majorGridValues.Length - 1]; minorGridSize.Height = MapControl.minorGridValues[MapControl.majorGridValues.Length - 1]; } } else { // Select the first factor that results in a displayed height greater than the minimum height. for (int index = 0; index < MapControl.majorGridFactor.Length; index++) { if (majorGridSize.Height * MapControl.majorGridFactor[index] >= MapControl.majorGridMinimumSize.Height) { majorGridSize.Height *= MapControl.majorGridFactor[index]; minorGridSize.Height = majorGridSize.Height * MapControl.minorGridFactor[index]; break; } } } // Compute the major grid begin and end. majorGridBegin = new Point( this.mapBounds.Left % majorGridSize.Width == 0 ? (int)Math.Ceiling(this.mapBounds.Left / majorGridSize.Width) + 1 : (int)Math.Ceiling(this.mapBounds.Left / majorGridSize.Width), this.mapBounds.Top % majorGridSize.Height == 0 ? (int)Math.Floor(this.mapBounds.Top / majorGridSize.Height) - 1 : (int)Math.Floor(this.mapBounds.Top / majorGridSize.Height) ); majorGridEnd = new Point( this.mapBounds.Right % majorGridSize.Width == 0 ? (int)Math.Floor(this.mapBounds.Right / majorGridSize.Width) - 1 : (int)Math.Floor(this.mapBounds.Right / majorGridSize.Width), this.mapBounds.Bottom % majorGridSize.Height == 0 ? (int)Math.Ceiling(this.mapBounds.Bottom / majorGridSize.Height) + 1 : (int)Math.Ceiling(this.mapBounds.Bottom / majorGridSize.Height) ); // Compute the minor grid begin and end. minorGridBegin = new Point( this.mapBounds.Left % minorGridSize.Width == 0 ? (int)Math.Ceiling(this.mapBounds.Left / minorGridSize.Width) + 1 : (int)Math.Ceiling(this.mapBounds.Left / minorGridSize.Width), this.mapBounds.Top % minorGridSize.Height == 0 ? (int)Math.Floor(this.mapBounds.Top / minorGridSize.Height) - 1 : (int)Math.Floor(this.mapBounds.Top / minorGridSize.Height) ); minorGridEnd = new Point( this.mapBounds.Right % minorGridSize.Width == 0 ? (int)Math.Floor(this.mapBounds.Right / minorGridSize.Width) - 1 : (int)Math.Floor(this.mapBounds.Right / minorGridSize.Width), this.mapBounds.Bottom % minorGridSize.Height == 0 ? (int)Math.Ceiling(this.mapBounds.Bottom / minorGridSize.Height) + 1 : (int)Math.Ceiling(this.mapBounds.Bottom / minorGridSize.Height) ); // Compute the horizontal major grid. double[] majorGridHorizontalCoordinate = new double[majorGridEnd.X - majorGridBegin.X + 1]; float[] majorGridHorizontalPoint = new float[majorGridHorizontalCoordinate.Length]; for (int index = 0; index < majorGridHorizontalPoint.Length; index++) { majorGridHorizontalCoordinate[index] = (majorGridBegin.X + index) * majorGridSize.Width; majorGridHorizontalPoint[index] = (float)((majorGridHorizontalCoordinate[index] - this.mapBounds.Left) * mapScale.Width); } // Compute the vertical major grid. double[] majorGridVerticalCoordinate = new double[majorGridBegin.Y - majorGridEnd.Y + 1]; float[] majorGridVerticalPoint = new float[majorGridVerticalCoordinate.Length]; for (int index = 0; index < majorGridVerticalPoint.Length; index++) { majorGridVerticalCoordinate[index] = (majorGridEnd.Y + index) * majorGridSize.Height; majorGridVerticalPoint[index] = (float)((this.mapBounds.Top - majorGridVerticalCoordinate[index]) * mapScale.Height); } // Draw the bitmap. using (Graphics graphics = Graphics.FromImage(bitmap)) { // Set the smooting mode. graphics.SmoothingMode = properties.Smoothing; using (SolidBrush brush = new SolidBrush(properties.BackgroundColor)) { using (Pen pen = new Pen(properties.RegionNormalBorderColor)) { // Fill the background. graphics.FillRectangle(brush, 0, 0, properties.Size.Width, properties.Size.Height); // Change the brush color. brush.Color = properties.RegionNormalBackgroundColor; // Get an exclusive reader lock to the regions list. this.regions.Lock(); try { // Draw the map regions. foreach (MapRegion region in this.regions) { // Draw the region. region.Draw(graphics, this.mapBounds, mapScale, brush, properties.Borders ? pen : null); } } finally { this.regions.Unlock(); } // Draw the major grid. if (properties.MajorGrid) { // Set the pen color. pen.Color = properties.MajorGridColor; // Set the brush color. brush.Color = Color.Black; // Draw the horizontal grid. if (null != majorGridHorizontalPoint) { for (int index = 0; index < majorGridHorizontalPoint.Length; index++) { // Draw the grid line. graphics.DrawLine(pen, majorGridHorizontalPoint[index], 0, majorGridHorizontalPoint[index], properties.Size.Height - 1); // Draw the coordinates. graphics.DrawString( majorGridHorizontalCoordinate[index].LongitudeToString(), this.fontGrid, brush, new Point((int)majorGridHorizontalPoint[index], 0)); } } // Draw the vertical grid. if (null != majorGridVerticalPoint) { for (int index = 0; index < majorGridVerticalPoint.Length; index++) { // Draw the grid line. graphics.DrawLine(pen, 0, majorGridVerticalPoint[index], properties.Size.Width - 1, majorGridVerticalPoint[index]); // Draw the coordinates. graphics.DrawString( majorGridVerticalCoordinate[index].LatitudeToString(), this.fontGrid, brush, new Point(0, (int)majorGridVerticalPoint[index])); } } } // If the show markers flag is set. if (properties.Markers) { // Change the pen and brush colors. pen.Color = properties.MarkerNormalBorderColor; brush.Color = properties.MarkerNormalBackgroundColor; // Try lockLock the markers collection. if (this.markers.TryLock()) { try { // Draw the normal markers. foreach (MapMarker marker in this.markers) { if (!marker.Emphasized) { marker.Draw(graphics, this.mapBounds, mapScale, brush, pen); } } // Change the pen and brush colors. pen.Color = properties.MarkerEmphasisBorderColor; brush.Color = properties.MarkerEmphasisBackgroundColor; // Draw the emphasized markers. foreach (MapMarker marker in this.markers) { if (marker.Emphasized) { marker.Draw(graphics, this.mapBounds, mapScale, brush, pen); } } } finally { this.markers.Unlock(); } } } } } } // Check the directory exists. if (Directory.EnsureFileDirectoryExists(fileName)) { // Save the bitmap to file. bitmap.Save(fileName, format); } }