public void HtmlAttribute_SetsCssClassAttribute() { actual = string.Empty; returnHtml = string.Empty; TabOption target = new TabOption(); string expected = target.CssClass = "Sample"; returnHtml = Utility.ControlOptionHtmlBuilder <TabOption>(target, _startTag); actual = Utility.GetAttribute(returnHtml, "class", _startTag); Assert.AreEqual(expected, actual); }
public void HtmlAttribute_SetsDisabledAttribute() { actual = string.Empty; returnHtml = string.Empty; TabOption target = new TabOption(); target.Disabled = false; string expected = "{\"disabled\":false}"; returnHtml = Utility.ControlOptionHtmlBuilder <TabOption>(target, _startTag); actual = Utility.GetAttribute(returnHtml, "data-control-options", _startTag); Assert.AreEqual(expected, actual); }
public void HtmlAttribute_SetsCollapsibleAttribute() { actual = string.Empty; returnHtml = string.Empty; TabOption target = new TabOption(); target.Collapsible = true; string expected = "{\"collapsible\":true}"; returnHtml = Utility.ControlOptionHtmlBuilder <TabOption>(target, _startTag); actual = Utility.GetAttribute(returnHtml, "data-control-options", _startTag); Assert.AreEqual(expected, actual); }
public void HtmlAttribute_SetsCustomHtmlAttribute() { actual = string.Empty; returnHtml = string.Empty; TabOption target = new TabOption(); target.HtmlAttributeList = new RouteValueDictionary(new { CustomAttribute = "Sample" }); string expected = "Sample"; returnHtml = Utility.ControlOptionHtmlBuilder <TabOption>(target, _startTag); actual = Utility.GetAttribute(returnHtml, "CustomAttribute", _startTag); Assert.AreEqual(expected, actual); }
public void HtmlAttribute_SetsShowAttribute() { actual = string.Empty; returnHtml = string.Empty; TabOption target = new TabOption(); target.Show = new TabAnimate(enable: true, delay: 1000, easing: Easing.EaseInOutBack, effect: Effect.Blind, duration: 1000);; string expected = "{\"show\":{\"effect\":\"blind\",\"delay\":1000,\"easing\":\"easeInOutBack\",\"duration\":1000}}"; returnHtml = Utility.ControlOptionHtmlBuilder <TabOption>(target, _startTag); actual = Utility.GetAttribute(returnHtml, "data-control-options", _startTag); Assert.AreEqual(expected, actual); }
public void HtmlAttribute_SetsHeightStyleAttribute() { actual = string.Empty; returnHtml = string.Empty; TabOption target = new TabOption(); target.HeightStyle = HeightStyle.Auto; string expected = "{\"heightStyle\":\"auto\"}"; returnHtml = Utility.ControlOptionHtmlBuilder <TabOption>(target, _startTag); actual = Utility.GetAttribute(returnHtml, "data-control-options", _startTag); Assert.AreEqual(expected, actual); }
public void HtmlAttribute_SetsEventAttribute() { actual = string.Empty; returnHtml = string.Empty; TabOption target = new TabOption(); target.Event = EventType.Click; string expected = "{\"event\":\"click\"}"; returnHtml = Utility.ControlOptionHtmlBuilder <TabOption>(target, _startTag); actual = Utility.GetAttribute(returnHtml, "data-control-options", _startTag); Assert.AreEqual(expected, actual); }
/// <summary> /// Overview Window draw function. /// </summary> public void DrawOverviewDialog() { EditorGUI.DrawRect(new Rect(0, 0, maxSize.x, maxSize.y), backgroundColor); GUIStyle style = new GUIStyle(GUI.skin.label); style.richText = true; GUILayout.Label("<b><color=maroon>Attention: </color>\n 1) Fix as much folders as possible.\n 2) Fix remaining files.\n 3) Edit Configs to deal with remaining folder/files.</b>", style); string[] tabs = new string[(int)TabOption.NumberOfTabs]; for (int i = 0; i < (int)TabOption.NumberOfTabs; i++) { tabs[i] = ((TabOption)i).ToString(); } tab = (TabOption)GUILayout.Toolbar((int)tab, tabs); if (configText == null) { configText = ConventionKeeper.config.ToString(true); } switch (tab) { case TabOption.Folders: GUILayout.Label("Not Convention Valid Folders: " + ConventionKeeper.overviewFolderList.Count); if (ConventionKeeper.overviewFolderList.Count == 0) { scrollPos = GUILayout.BeginScrollView(scrollPos, false, true); { GUILayout.Label("<color=green><b>No folder convention problems, good!</b></color>", style); } GUILayout.EndScrollView(); break; } scrollPos = GUILayout.BeginScrollView(scrollPos, false, true); { bool breakLoop = false; foreach (var item in ConventionKeeper.overviewFolderList) { string errors = "<color=red>"; foreach (FolderConventionState error in item.folderError) { errors += " | " + error.ToString(); } errors += "</color>"; GUILayout.BeginHorizontal(); { DrawButton("FIX IT!", delegate() { breakLoop = true; //Fix NotValid state first because it means the convention system is not tracking it. if (item.folderError.Contains(FolderConventionState.NotValid)) { //Fix it ConventionKeeper.AddPathToConvention(item.assetsFullPath); } //Fix noFoldersAllowed second because with no folders allowance the code does not check child folders and just halt. if (item.folderError.Contains(FolderConventionState.NoFoldersAllowed)) { //Fix it ConventionKeeper.AddFolderTypeToPath(item.assetsFullPath); } //Reset Overview Data - Recheck convention RefreshOverviewData(); }, 10); DrawButton("Ignore", delegate() { ConventionKeeper.AddToIgnoredPaths(item.assetsFullPath); //Reset Overview Data - Recheck convention RefreshOverviewData(); }, 10); DrawButton("Delete", delegate() { ConventionKeeper.DeleteFolder(item.assetsFullPath); //Reset Overview Data - Recheck convention RefreshOverviewData(); }, 10); GUILayout.Label(item.assetsFullPath + errors, style); } GUILayout.EndHorizontal(); if (breakLoop) { break; } } } GUILayout.EndScrollView(); break; case TabOption.Files: GUILayout.Label("Not Convention Valid Files: " + ConventionKeeper.overviewFileList.Count); if (ConventionKeeper.overviewFolderList.Count > 0) { scrollPos = GUILayout.BeginScrollView(scrollPos, false, true); { GUILayout.Label("<color=maroon>You need to resolve all the <b>folder issues first!</b></color>", style); } GUILayout.EndScrollView(); break; } if (ConventionKeeper.overviewFileList.Count == 0) { scrollPos = GUILayout.BeginScrollView(scrollPos, false, true); { GUILayout.Label("<color=green><b>No file convention problems, good!</b></color>", style); } GUILayout.EndScrollView(); break; } scrollPos = GUILayout.BeginScrollView(scrollPos, false, true); { bool breakLoop = false; foreach (var item in ConventionKeeper.overviewFileList) { string errors = "<color=red>"; foreach (var error in item.fileError) { errors += " | " + error.ToString(); if (error == FileConventionState.NotValid) { errors += " - <b>Is the file in the right folder?</b>"; } } errors += "</color>"; GUILayout.BeginHorizontal(); { if (item.fileError.Count > 0 && !item.fileError.Contains(FileConventionState.NotValid)) { DrawButton("FIX IT!", delegate() { breakLoop = true; //First fix file name as it may affect the file type(?) if (item.fileError.Contains(FileConventionState.WrongFileName)) { ConventionKeeper.FileNameChangeDialog(item); } //Fix unknown file type - This just fix already stablished name conventions/file types in the config doc! if (item.fileError.Contains(FileConventionState.UnknownFileType)) { ConventionKeeper.AddFileTypeToPath(item); } //Reset Overview Data - Recheck convention RefreshOverviewData(); }, 10); } if (ConventionKeeper.IsValidFileType(item.type)) { DrawButton("Ignore File", delegate() { breakLoop = true; ConventionKeeper.AddToIgnoredFiles(item); //Reset Overview Data - Recheck convention RefreshOverviewData(); }, 10); } if (ConventionKeeper.IsValidFileType(item.type)) { DrawButton("Ignore Type", delegate() { breakLoop = true; ConventionKeeper.AddToIgnoredFileTypes(item); //Reset Overview Data - Recheck convention RefreshOverviewData(); }, 10); } if (item.type != "cs") { DrawButton("Delete File", delegate() { breakLoop = true; ConventionKeeper.DeleteDialog(item); //Reset Overview Data - Recheck convention RefreshOverviewData(); }, 10); } GUILayout.Label(item.assetsFullPath + errors, style); } GUILayout.EndHorizontal(); if (breakLoop) { break; } } } GUILayout.EndScrollView(); break; case TabOption.Configs: scrollPos = GUILayout.BeginScrollView(scrollPos, false, true); { configText = GUILayout.TextArea(configText); } GUILayout.EndScrollView(); if (configText != ConventionKeeper.config.ToString(true)) { GUI.enabled = true; } else { GUI.enabled = false; } if (GUILayout.Button("Save Configuration File")) { ConventionKeeper.config = new JSONObject(configText); ConventionKeeper.SaveConfigs(); } GUI.enabled = true; break; } GUILayout.BeginHorizontal(); { if (GUILayout.Button("Refresh")) { RefreshOverviewData(); } if (!EditorPrefs.HasKey(ConventionKeeper.setupDoneKey)) { if (GUILayout.Button("Cancel")) { ConventionKeeper.usingOverview = false; EditorPrefs.SetBool(ConventionKeeper.setupDoneKey, false); this.Close(); } } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { if (!EditorPrefs.HasKey(ConventionKeeper.setupDoneKey) || !EditorPrefs.GetBool(ConventionKeeper.setupDoneKey)) { if (ConventionKeeper.overviewFolderList.Count > 0 || ConventionKeeper.overviewFileList.Count > 0) { GUI.enabled = false; } else { GUI.enabled = true; } if (GUILayout.Button("Finish First Time Setup")) { EditorPrefs.SetBool(ConventionKeeper.setupDoneKey, true); this.Close(); } GUI.enabled = true; } } GUILayout.EndHorizontal(); }