private void AddClick(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "Image Files | *" + String.Join(";*", Extension); dialog.Multiselect = true; dialog.CheckFileExists = true; dialog.Title = "Choose Image"; if (dialog.ShowDialog() == true) { string [] fileNames = dialog.FileNames; ProjectTools.AddFiles(fileNames); /* Add files to _data so that the ListBox is updated. Note that as Images are added to the project directory, * images will be added in the _data with ImageData having header Path.DirectorySeparatorChar. */ List <string> temp = new List <string>(); foreach (var file in fileNames) { temp.Add(Path.GetFileName(file)); } if (fileNames.Length != 0) { txURL.Text = fileNames.Last(); } _data.OrderBy(image => image.Header).ElementAt(0).Images.AddRange(fileNames); } }
void AddGuest() { var randomSpawnPoint = ProjectTools.GetRandomWithinBounds(new Bounds(guestContainer.transform.position, ProjectTools.GetSymmetricalVector(danceFlorSize))); guestSpawner.SpawnGuests(1, guestContainer.transform, randomSpawnPoint); plannedNewGuests--; }
void NewProfile(GenericGamepadProfile profile) { if (!InputManager.instance._gamepads.Contains(profile)) { InputManager.instance._gamepads.Add(profile); EditorUtility.SetDirty(InputManager.instance); ProjectTools.RefreshAndSave(); } }
public void InitializeModuleImporting(string excludeModuleName) { excludeIndex = -1; modulesInProject = AssetTools.FindAssetsByType <Module>(false, null); unityPackagePaths = ProjectTools.GetFilesInDirectory(ModuleWorkFlow.defaultTargetExportDirectory, ProjectTools.packageExtension, out unityPackageNames); int l = unityPackagePaths.Length; importWarnings = ""; for (int i = 0; i < l; i++) { string unVersionedName; int unimportedVersion = ModuleWorkFlow.VersionFromFilePath(unityPackageNames[i], out unVersionedName); if (unVersionedName != null) { unityPackageNames[i] = unVersionedName; } if (unityPackageNames[i] == excludeModuleName) { excludeIndex = i; } // check for modules alraedy imported... for (int j = 0; j < modulesInProject.Count; j++) { Module importedModule = modulesInProject[j]; // if package in project already if (unityPackageNames[i] == importedModule.moduleName) { // check if our package version is higher than our already imported version if (unimportedVersion > importedModule.currentVersion) { importWarnings += "\n" + unityPackageNames[i] + " Upgrade available! Version: " + unimportedVersion + ", Current: " + importedModule.currentVersion; // mark as already imported but updateable unityPackageNames[i] = "[...] " + unityPackageNames[i]; } else { // mark as already imported unityPackageNames[i] = "[ X ] " + unityPackageNames[i]; } break; } } // add version to name as readable unityPackageNames[i] = unityPackageNames[i] + " [v" + unimportedVersion + "]"; } }
public void DeleteProfile(GenericGamepadProfile toDelete) { if (EditorUtility.DisplayDialog("Delete Gamepad Profile", "Are you sure you want to delete profile: " + toDelete.name + "?", "Yes", "No")) { InputManager.instance._gamepads.Remove(toDelete); EditorUtility.SetDirty(InputManager.instance); AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(toDelete)); ProjectTools.RefreshAndSave(); } }
void InitializeGUI() { if (icons == null) { icons = new GUIContent[BuiltInIcons.iconsCount]; for (int i = 0; i < BuiltInIcons.iconsCount; i++) { icons[i] = BuiltInIcons.GetIcon(BuiltInIcons.allIcons[i], BuiltInIcons.allIcons[i]); } } if (layoutOptions == null) { layoutOptions = new GUILayoutOption[] { GUILayout.Width(64) } } ; if (blackButtonStyle == null) { blackButtonStyle = new GUIStyle(GUITools.toolbarButton); blackButtonStyle.normal.background = null; } } void DrawButtonRow(GUIStyle style, Color32 color, int i) { GUI.color = color; EditorGUILayout.BeginHorizontal(GUITools.toolbar); GUI.color = GUITools.white; for (int x = 0; x < columns; x++) { if (i + x < icons.Length && GUILayout.Button(icons[i + x], style, layoutOptions)) { ProjectTools.CopyStringToClipBoard(icons[i + x].tooltip); Debug.Log("Copied to clipboard: " + icons[i + x].tooltip); } } EditorGUILayout.EndHorizontal(); } int columns = 7; void OnGUI() { InitializeGUI(); scroll_pos = EditorGUILayout.BeginScrollView(scroll_pos); for (int i = 0; i < icons.Length; i += columns) { DrawButtonRow(GUITools.toolbarButton, GUITools.white, i); DrawButtonRow(blackButtonStyle, GUITools.black, i); GUITools.Space(2); } EditorGUILayout.EndScrollView(); } }
public ActionResult UploadPhoto(HttpPostedFileBase file) { if (ModelState.IsValid) { var userid = User.UserID; var user = repository.GetUserById(userid); byte[] resizedImage = new byte[0]; var jpeg = new byte[] { 255, 216, 255, 224 }; // jpeg if (file.ContentLength > 0) { var filename = Path.GetFileName(file.FileName); //using (var reader = new System.IO.BinaryReader(file.InputStream)) //{ // if (!jpeg.SequenceEqual(reader.ReadBytes(file.ContentLength).Take(jpeg.Length))) // { // //file is not jpeg // return RedirectToAction("Index", "User"); // } //} try { System.Drawing.Image sourceimage = System.Drawing.Image.FromStream(file.InputStream); var BitmapResizedImage = ProjectTools.ResizeImage(sourceimage, 50, 50); resizedImage = ProjectTools.imageToByteArray(BitmapResizedImage); } catch (Exception ex) { ViewBag.ErrorMessage = ex.Message; return(this.View()); } } repository.DeleteAllAvatarsFromUser(userid); if (file != null && file.ContentLength > 0) { var avatar = new Picture { User = user, PictureName = System.IO.Path.GetFileName(file.FileName), Type = FileType.Avatar, ContentType = file.ContentType }; avatar.Content = resizedImage; repository.SavePicture(avatar, userid); } return(RedirectToAction("Index", "User")); } return(RedirectToAction("Index", "User")); }
public ChooseImageDialog() { InitializeComponent(); // Get image file with allowed extensions AddImages(ProjectTools.RetrieveFiles(ChooseImageDialog.Extension)); CollectionViewSource cvs = new CollectionViewSource(); cvs.Source = _data; cvs.GroupDescriptions.Add(new PropertyGroupDescription("Directory")); cvs.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending)); imgDisplay.ItemsSource = cvs.View; }
private void AddClick(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "Image Files|*" + String.Join(";*", Extension) + "|All Files|*.*"; dialog.Multiselect = true; dialog.CheckFileExists = true; dialog.Title = "Choose Image"; if (dialog.ShowDialog() == true) { string[] fileNames = dialog.FileNames; var files = ProjectTools.AddFiles(fileNames, ItemType.Resource); imgDisplay.SelectedItem = files.FirstOrDefault(); } }
public static List <GameObject> GetRecordPrefabs(List <Track> tracks, Transform parent) { var recordPrefabs = new List <GameObject> (); foreach (var track in tracks) { var prefab = SpawnPrefab.Instance.Spawn(Prefabs.DynamicRecord); var record = prefab.GetComponent <Record> (); record.Track = track; prefab.name = track.TrackName.ToString() + " (Record)"; prefab.transform.parent = parent; prefab.transform.position = ProjectTools.GetRandomPlaceWithinScreen(); recordPrefabs.Add(prefab); } return(recordPrefabs); }
void OnGUI() { for (int i = 0; i < colors.Length; i++) { colors[i] = EditorGUILayout.ColorField(contents[i], colors[i]); } if (GUILayout.Button("Copy Values")) { ProjectTools.CopyStringToClipBoard( string.Format(@" public static readonly Color32 blue = new Color32({0}, {1}, {2}, 255); public static readonly Color32 red = new Color32({3}, {4}, {5}, 255); public static readonly Color32 green = new Color32({6}, {7}, {8}, 255); public static readonly Color32 darkGray = new Color32({9}, {10}, {11}, 255); public static readonly Color32 gray = new Color32 ({12}, {13}, {14}, 255); public static readonly Color32 liteGray = new Color32 ({15}, {16}, {17}, 255); ", colors[0].r, colors[0].g, colors[0].b, colors[1].r, colors[1].g, colors[1].b, colors[2].r, colors[2].g, colors[2].b, colors[3].r, colors[3].g, colors[3].b, colors[4].r, colors[4].g, colors[4].b, colors[5].r, colors[5].g, colors[5].b ) ); } InitializeIcons(false); DrawButtonsPreview(GUITools.black); GUITools.Space(4); DrawButtonsPreview(colors[5]); if (GUILayout.Button("Refresh Icons")) { InitializeIcons(true); } }
static void BuildForAndroid() { Debug.Log("BuildForAndroid"); // prepare for build PrepareBuild(); Debug.Log("PrepareBuild "); // Function.DeleteFolder(Application.dataPath+"/Plugins/Android"); // if(Function.projectName == "91") // { // Function.CopyDirectory(Application.dataPath+"/91",Application.dataPath+"/Plugins/Android"); // PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android, "USE_SHARE"); // } // string version = ProjectTools.GetBGitVersion(); string version = "1.0"; ProjectTools.UpdateVersionFile(version); Debug.Log("set version"); string path = Application.dataPath + "/../Export/"; if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } Debug.Log("create file"); path = path + GetProjectSuffix() + version + ".apk"; Debug.Log("create apk"); //EditorPrefs.SetString("AndroidSdkRoot", "C:/Users/dsw/AppData/Local/Android/sdk"); Debug.Log("create AndroidSdkRoot"); BuildPipeline.BuildPlayer(GetBuildScenes(), path, BuildTarget.Android, BuildOptions.None); Debug.Log("create finish"); // MovieToolMenuItems.RestMovieClips(); }
protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); List <KeyValuePair <string, string> > images = new List <KeyValuePair <string, string> >(); /* Get image file with allowed extensions and group them with their directory */ images = ProjectTools.RetrieveFiles(ChooseImageDialog.Extension); IEnumerable <IGrouping <string, string> > grouping = images.GroupBy(image => image.Key, image => image.Value); /* Set values for _data and bind to the ListBox */ foreach (IGrouping <string, string> group in grouping) { List <string> temp = new List <string>(); foreach (var name in group) { temp.Add(name); } _data.Add(new ImageData(group.Key + Path.DirectorySeparatorChar, temp)); } Display.ItemsSource = _data; Display.SelectionChanged += delegate { Display.SelectedItem = null; }; }
public void GetVersionNew() { var version = ProjectTools.GetVersion(FourSixTwoProjNew); version.Should().Be("net462"); }
public async Task <ActionResult> EditUser(UserEditUserViewModel model, HttpPostedFileBase file) { // ModelState.AddModelError(string.Empty, "An image file must be chosen."); if (ModelState.IsValid) { if (file != null) { string fileName = Path.GetFileName(file.FileName); // Upload the file to Azure Blob Storage bool savedComplete = await Task.Run( () => { var userid = User.UserID; var user = repository.GetUserById(userid); byte[] resizedImage = new byte[0]; var jpeg = new byte[] { 255, 216, 255, 224 }; // jpeg if (file.ContentLength > 0) { var filename = Path.GetFileName(file.FileName); try { System.Drawing.Image sourceimage = System.Drawing.Image.FromStream(file.InputStream); var BitmapResizedImage = ProjectTools.ResizeImage(sourceimage, 256, 256); resizedImage = ProjectTools.imageToByteArray(BitmapResizedImage); } catch (Exception ex) { ViewBag.ErrorMessage = ex.Message; ModelState.AddModelError(string.Empty, "An image file must be chosen."); return(false); } } repository.DeleteAllAvatarsFromUser(userid); if (file != null && file.ContentLength > 0) { var avatar = new Picture { User = user, PictureName = System.IO.Path.GetFileName(file.FileName), Type = FileType.Avatar, ContentType = file.ContentType }; avatar.Content = resizedImage; repository.SavePicture(avatar, userid); } return(true); }); } if (User == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } repository.UserEditUser(model); User.FirstName = model.FirstName; User.LastName = model.LastName; return(RedirectToAction("Index")); } ViewBag.AcademyID = new SelectList(repository.GetAllAcademies(), "AcademyID", "AcademyName", model.AcademyID); return(View(model)); }
public void GetVersionOld() { var version = ProjectTools.GetVersion(FourSixTwoProjOld); version.Should().Be("v4.6.2"); }
public void ReturnIsCoreStyleProject() { var r = ProjectTools.IsCoreStyleProject(FourSixTwoProjNew); r.Should().BeTrue(); }
public void ReturnIsNoCoreStyleProject() { var r = ProjectTools.IsCoreStyleProject(FourSixTwoProjOld); r.Should().BeFalse(); }
public static void ExportModulePackage(Module module, string targetDirectory, bool isUpgrade) { // export base directory is the directory the module is in string exportDir = Path.GetDirectoryName(AssetDatabase.GetAssetPath(module)); // if the directory name for the module isnt a match with the module name // raise a warning, it might mean we're exporting the wrong module by accident string [] sp = exportDir.Split('/'); string dirName = sp[sp.Length - 1]; if (dirName != module.moduleName) { string msg = "Trying to export module: " + module.moduleName + ", but root directory for module is named: " + dirName + "\n\nAre you sure everything is set up right?"; if (!EditorUtility.DisplayDialog("Module Export:\n" + module.moduleName, msg, "Continue", "Abort")) { return; } } // when upgrading, we increment the version number, so other projects that use this module // know they need an update if (isUpgrade) { if (!EditorUtility.DisplayDialog("Module Upgrade:\n" + module.moduleName, "Are you sure you want to upgrade from v" + module.currentVersion + " to v" + (module.currentVersion + 1), "Upgrade", "Abort")) { return; } module.currentVersion++; // make sure this change gets saved before export // TODO: check if this is actually needed EditorUtility.SetDirty(module); AssetDatabase.Refresh(); AssetDatabase.SaveAssets(); string oldPath = targetDirectory + module.moduleName + versionPrefix + (module.currentVersion - 1) + ProjectTools.packageExtension; // Check if file exists with its full path if (File.Exists(oldPath)) { File.Delete(oldPath); Debug.Log("Deleted: " + oldPath); } } // dont let the ModuleProjectSpecifier in the project be exported with the module Func <string, bool> whereNotProjectSpecifierAsset = (filePath) => { // if its not an asset if (!filePath.EndsWith(".asset")) { return(true); } bool isProjectSpecifier = AssetDatabase.LoadAssetAtPath <ModuleProjectSpecifier>(filePath) != null; if (isProjectSpecifier) { Debug.LogWarning("Found ModuleProjectSpecifier in export files, removing: " + filePath); } return(!isProjectSpecifier); }; string [] files = ProjectTools.GetFilesInDirectory(exportDir).Where(whereNotProjectSpecifierAsset).ToArray(); if (files.Length == 0) { Debug.LogWarning("No files to export at directory: " + exportDir); return; } // only one file... chances are it's just the module object. // in which case, dont export if (files.Length == 1) { bool isModule = AssetDatabase.LoadAssetAtPath <ModuleProjectSpecifier>(files[0]) != null; if (isModule) { Debug.LogWarning("No files except module to export at directory: " + exportDir); return; } } // print out files as debug // for (int i = 0; i < files.Length; i++) Debug.Log("Export File: " + files[i]); string exportPath = targetDirectory + module.moduleName + versionPrefix + module.currentVersion + ProjectTools.packageExtension; AssetDatabase.ExportPackage(files, exportPath); EditorUtility.DisplayDialog("Export Complete", "Module Exported To:\n" + exportPath, "Ok", "Ok"); }
public void RenameProfile(GenericGamepadProfile profile, string newName) { AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(profile), newName); ProjectTools.RefreshAndSave(); }