/// <summary> /// the main validation for the form /// </summary> /// <param name="valid">the state of the form</param> private async void FormValidate(Boolean valid) { if (valid) { //if the registerController has been validated //we register the controller to the database retrieving the newly created user using UserFunctions userFunctions = new UserFunctions(); User newUser = userFunctions.RegisterUser(RegisterController); //if the creation of the user has failed we call the database connection error if (newUser == null) { MessageDisplay.CallDatabaseError(InstanceController.MessageDisplaySettings); //we return so as not to continue code execution return; } { using SubscriptionFunctions subscriptionFunctions = new SubscriptionFunctions(); //seeing as we now have our user we need to initialize the new Subscription for it if (!subscriptionFunctions.GenerateInactiveSubscription(newUser)) { //if we fail we call error MessageDisplay.CallDatabaseError(InstanceController.MessageDisplaySettings); //we return so as not to continue code execution return; } } //if this point has been reached a new user has been created and we need to send an activation Link //as such we need to send them a link to activate the email; Miscellaneous.Emails.Email.SendValidationEmail(newUser); //not that the pesky things are done we must login //though before we do that we will leave the register page ComponentDisplay.CallMain(InstanceController.DisplaySettings); #region Menu Generation //we deactivate the initial menu settings InstanceController.UserMenu.DeactivateMenu(); //then insert the initial settings Database.DatabaseLink.UserSettings.UserSettings.GenerateInitialUserSettings(newUser); { using Database.EntityFramework.DatabaseLink.UserSettings.MenuFunctions menuFunctions = new Database.EntityFramework.DatabaseLink.UserSettings.MenuFunctions(); menuFunctions.GenerateMenuSettingsForUser(newUser, InstanceController.UserMenu.UserMenu); } #endregion //now we also Login the user Functions.Login(newUser, InstanceController); } else { //we can't access the base html objects from c# so we need JavaScripts(Damn the elders of the Internet) await JSRuntime.InvokeVoidAsync("focusElement", "tbSurname"); //the call the StateHasChanged to force a page refresh this.StateHasChanged(); } }
private void getActors() { var parent = this.Parent; if (parent == null) { return; } Viewport3DXext vp = parent as Viewport3DXext; if (vp == null) { return; } foreach (var item in vp.Items) { this.viewPort = vp; LineGenerator3D linGen = item as LineGenerator3D; ArchitectureDisplay arcDisp = item as ArchitectureDisplay; ZoneGroupDisplay zoneDisp = item as ZoneGroupDisplay; ComponentDisplay comprepDisp = item as ComponentDisplay; OcTreeManager otMan = item as OcTreeManager; ViewFrustumFunctions vfFunc = item as ViewFrustumFunctions; if (linGen != null) { this.LineGen = linGen; } if (arcDisp != null) { this.ArcDisp = arcDisp; } if (zoneDisp != null) { this.ZoneDisp = zoneDisp; if (zoneDisp != null) { this.ZoneDisp.PropertyChanged += ZoneDisp_PropertyChanged; } } if (comprepDisp != null) { this.CompDisp = comprepDisp; } if (otMan != null) { this.OTManager = otMan; } if (vfFunc != null) { this.ViewFF = vfFunc; } } }
public void OnGUI () { if (EditorApplication.isCompiling || EditorApplication.isUpdating) { EditorGUILayout.LabelField("Please wait...", EditorStyles.centeredGreyMiniLabel); _cachedComponents = null; _selectedDisplay = null; _componentDisplays = null; _initialized = false; return; } if (!_initialized) { Initialize(); } Transform transform = Selection.activeTransform; if (Selection.GetFiltered(typeof(Transform), SelectionMode.Unfiltered).Length > 0) { transform = (Transform)Selection.GetFiltered(typeof(Transform), SelectionMode.Unfiltered)[0]; } if (transform == null) { EditorGUILayout.LabelField("Select a GameObject.", EditorStyles.centeredGreyMiniLabel); _cachedComponents = null; _selectedDisplay = null; _componentDisplays = null; } else { bool dirty = false; Component[] components = transform.GetComponents<Component>(); if (_cachedComponents == null || _cachedComponents.Count != components.Length) { dirty = true; } else { for (int i = 0; i < components.Length; i++) { if (components[i] != _cachedComponents[i]) { dirty = true; break; } } } if (dirty) { Dictionary<Component, ComponentDisplay> displays = new Dictionary<Component, ComponentDisplay>(); _cachedComponents = new List<Component>(components); if (_componentDisplays == null) { _componentDisplays = new Dictionary<Component, ComponentDisplay>(); } for (int i = 0; i < _cachedComponents.Count; i++) { Component component = _cachedComponents[i]; if (component == null) { continue; } ComponentDisplay display = null; if (!_componentDisplays.TryGetValue(component, out display)) { display = new ComponentDisplay(); display.component = component; } displays[component] = display; } _componentDisplays = displays; } } if (_componentDisplays == null) { return; } _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition); Editor editor = Editor.CreateEditor(transform.gameObject); editor.DrawHeader(); if (transform != null) { for (int i = 0; i < _cachedComponents.Count; i++) { Component component = _cachedComponents[i]; _componentDisplays[component].Draw(_componentDisplays[component] == _selectedDisplay); } ComponentDisplay hovered_display = null; for (int i = 0; i < _cachedComponents.Count; i++) { Component component = _cachedComponents[i]; if (_componentDisplays[component].GetRect().Contains(Event.current.mousePosition)) { hovered_display = _componentDisplays[component]; break; } } if (hovered_display != null) { if (Event.current.type == EventType.ContextClick) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Move Up"), false, MoveUp, hovered_display.component); menu.AddItem(new GUIContent("Move Down"), false, MoveDown, hovered_display.component); menu.AddItem(new GUIContent("Move to Top"), false, MoveToTop, hovered_display.component); menu.AddItem(new GUIContent("Move to Bottom"), false, MoveToBottom, hovered_display.component); menu.ShowAsContext(); Event.current.Use(); } if (_selectedDisplay == null && Event.current.type == EventType.MouseDown && Event.current.button == 0) { _dragged = false; _selectedDisplay = hovered_display; Event.current.Use(); } } if (_selectedDisplay != null) // Something was selected. { // If we're hovering over an option that's not the one we started on, treat this as a drag. if (hovered_display != null && _selectedDisplay != hovered_display) { _dragged = true; } // Draw where the component will be dropped. if (hovered_display != null) { Rect rect = new Rect(hovered_display.GetRect()); rect.height = 1; GUI.Box(rect, "", destination); } else if (Event.current.mousePosition.y > _componentDisplays[_cachedComponents[_cachedComponents.Count - 1]].GetRect().y) { Rect rect = new Rect(_componentDisplays[_cachedComponents[_cachedComponents.Count - 1]].GetRect()); rect.y += rect.height; rect.height = 1; GUI.Box(rect, "", destination); } else { Rect rect = new Rect(_componentDisplays[_cachedComponents[0]].GetRect()); rect.height = 1; GUI.Box(rect, "", destination); } } if (Event.current.type == EventType.MouseUp && Event.current.button == 0) { if (_selectedDisplay != null && _selectedDisplay == hovered_display) { // If we didn't attempt to drag the component, and we're not over content, fold it out. if (!_dragged && !_selectedDisplay.GetContentRect().Contains(Event.current.mousePosition)) { _selectedDisplay.Toggle(); } _selectedDisplay = null; Event.current.Use(); } else if (_selectedDisplay != null) { if (hovered_display != null) { int source_index = _cachedComponents.IndexOf(_selectedDisplay.component); int destination_index = _cachedComponents.IndexOf(hovered_display.component); int offset = destination_index - source_index; if (destination_index > source_index) { offset -= 1; } while (offset > 0) { UnityEditorInternal.ComponentUtility.MoveComponentDown(_selectedDisplay.component); offset --; } while (offset < 0) { UnityEditorInternal.ComponentUtility.MoveComponentUp(_selectedDisplay.component); offset ++; } } else if (Event.current.mousePosition.y > _componentDisplays[_cachedComponents[_cachedComponents.Count - 1]].GetRect().y) { MoveToBottom(_selectedDisplay.component); } else { MoveToTop(_selectedDisplay.component); } _selectedDisplay = null; } Event.current.Use(); } } EditorGUILayout.EndScrollView(); }
public void CreateList() { if (componentDisplays.Count > 0) { foreach (ComponentDisplay display in componentDisplays) { Destroy(display.gameObject); } componentDisplays.Clear(); } List <AvailableComponent> availableComponents = GetAvailableComponents(); if (availableComponents.Count > 0) { componentScrollbar.value = 1; RectTransform rectTransform = contentPanel.GetComponent <RectTransform>(); float prefabHeight = displayPrefab.gameObject.GetComponent <RectTransform>().rect.height; float contentPanelHeight = availableComponents.Count * prefabHeight + (prefabHeight * .5f); rectTransform.sizeDelta = new Vector2(contentPanel.rectTransform.sizeDelta.x, contentPanelHeight); for (int i = 0; i < availableComponents.Count; i++) { /*if (i % columnCount == 0) // Only matters if columnCount > 1 * counter++; */ string component = availableComponents[i].component; ComponentDisplay newItem = Instantiate(displayPrefab); newItem.gameObject.SetActive(true); newItem.name = availableComponents[i].component; Text[] texts = newItem.GetComponentsInChildren <Text>(); texts[0].text = availableComponents[i].component; texts[1].text = availableComponents[i].price.ToString("C"); // c = currency format //texts [2].text = info.GetComponentDescription(component); Button[] buttons = newItem.GetComponentsInChildren <Button>(); SetPurchaseButtonCallback(buttons[0], component, availableComponents[i].price); try { foreach (string str in GetFeaturesList(availableComponents[i].component)) { if (i == 0) { newItem.featuresPanel.StartList(str); } else { newItem.featuresPanel.AddToList(str); } } } catch (System.NullReferenceException) { newItem.featuresPanel.NoContent(); } try { foreach (string str in GetJobsList(availableComponents[i].component)) { if (i == 0) { newItem.jobsPanel.StartList(str); } else { newItem.jobsPanel.AddToList(str); } } } catch (System.NullReferenceException) { newItem.jobsPanel.NoContent(); } // Positioning newItem.transform.SetParent(contentPanel.transform.parent, false); newItem.gameObject.SetActive(true); newItem.gameObject.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, -prefabHeight * i); componentDisplays.Add(newItem); } foreach (ComponentDisplay display in componentDisplays) { display.transform.SetParent(contentPanel.transform); } } }
public void OnGUI() { if (EditorApplication.isCompiling || EditorApplication.isUpdating) { EditorGUILayout.LabelField("Please wait...", EditorStyles.centeredGreyMiniLabel); _cachedComponents = null; _selectedDisplay = null; _componentDisplays = null; _initialized = false; return; } if (!_initialized) { Initialize(); } Transform transform = Selection.activeTransform; if (Selection.GetFiltered(typeof(Transform), SelectionMode.Unfiltered).Length > 0) { transform = (Transform)Selection.GetFiltered(typeof(Transform), SelectionMode.Unfiltered)[0]; } if (transform == null) { EditorGUILayout.LabelField("Select a GameObject.", EditorStyles.centeredGreyMiniLabel); _cachedComponents = null; _selectedDisplay = null; _componentDisplays = null; } else { bool dirty = false; Component[] components = transform.GetComponents <Component>(); if (_cachedComponents == null || _cachedComponents.Count != components.Length) { dirty = true; } else { for (int i = 0; i < components.Length; i++) { if (components[i] != _cachedComponents[i]) { dirty = true; break; } } } if (dirty) { Dictionary <Component, ComponentDisplay> displays = new Dictionary <Component, ComponentDisplay>(); _cachedComponents = new List <Component>(components); if (_componentDisplays == null) { _componentDisplays = new Dictionary <Component, ComponentDisplay>(); } for (int i = 0; i < _cachedComponents.Count; i++) { Component component = _cachedComponents[i]; if (component == null) { continue; } ComponentDisplay display = null; if (!_componentDisplays.TryGetValue(component, out display)) { display = new ComponentDisplay(); display.component = component; } displays[component] = display; } _componentDisplays = displays; } } if (_componentDisplays == null) { return; } _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition); Editor editor = Editor.CreateEditor(transform.gameObject); editor.DrawHeader(); if (transform != null) { for (int i = 0; i < _cachedComponents.Count; i++) { Component component = _cachedComponents[i]; _componentDisplays[component].Draw(_componentDisplays[component] == _selectedDisplay); } ComponentDisplay hovered_display = null; for (int i = 0; i < _cachedComponents.Count; i++) { Component component = _cachedComponents[i]; if (_componentDisplays[component].GetRect().Contains(Event.current.mousePosition)) { hovered_display = _componentDisplays[component]; break; } } if (hovered_display != null) { if (Event.current.type == EventType.ContextClick) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Move Up"), false, MoveUp, hovered_display.component); menu.AddItem(new GUIContent("Move Down"), false, MoveDown, hovered_display.component); menu.AddItem(new GUIContent("Move to Top"), false, MoveToTop, hovered_display.component); menu.AddItem(new GUIContent("Move to Bottom"), false, MoveToBottom, hovered_display.component); menu.ShowAsContext(); Event.current.Use(); } if (_selectedDisplay == null && Event.current.type == EventType.MouseDown && Event.current.button == 0) { _dragged = false; _selectedDisplay = hovered_display; Event.current.Use(); } } if (_selectedDisplay != null) // Something was selected. { // If we're hovering over an option that's not the one we started on, treat this as a drag. if (hovered_display != null && _selectedDisplay != hovered_display) { _dragged = true; } // Draw where the component will be dropped. if (hovered_display != null) { Rect rect = new Rect(hovered_display.GetRect()); rect.height = 1; GUI.Box(rect, "", destination); } else if (Event.current.mousePosition.y > _componentDisplays[_cachedComponents[_cachedComponents.Count - 1]].GetRect().y) { Rect rect = new Rect(_componentDisplays[_cachedComponents[_cachedComponents.Count - 1]].GetRect()); rect.y += rect.height; rect.height = 1; GUI.Box(rect, "", destination); } else { Rect rect = new Rect(_componentDisplays[_cachedComponents[0]].GetRect()); rect.height = 1; GUI.Box(rect, "", destination); } } if (Event.current.type == EventType.MouseUp && Event.current.button == 0) { if (_selectedDisplay != null && _selectedDisplay == hovered_display) { // If we didn't attempt to drag the component, and we're not over content, fold it out. if (!_dragged && !_selectedDisplay.GetContentRect().Contains(Event.current.mousePosition)) { _selectedDisplay.Toggle(); } _selectedDisplay = null; Event.current.Use(); } else if (_selectedDisplay != null) { if (hovered_display != null) { int source_index = _cachedComponents.IndexOf(_selectedDisplay.component); int destination_index = _cachedComponents.IndexOf(hovered_display.component); int offset = destination_index - source_index; if (destination_index > source_index) { offset -= 1; } while (offset > 0) { UnityEditorInternal.ComponentUtility.MoveComponentDown(_selectedDisplay.component); offset--; } while (offset < 0) { UnityEditorInternal.ComponentUtility.MoveComponentUp(_selectedDisplay.component); offset++; } } else if (Event.current.mousePosition.y > _componentDisplays[_cachedComponents[_cachedComponents.Count - 1]].GetRect().y) { MoveToBottom(_selectedDisplay.component); } else { MoveToTop(_selectedDisplay.component); } _selectedDisplay = null; } Event.current.Use(); } } EditorGUILayout.EndScrollView(); }