/************************************************************************************************************************/
            #endregion
            /************************************************************************************************************************/
            #region Models
            /************************************************************************************************************************/

            private static void DoModelsGUI()
            {
                var property = ModelsProperty;
                var count = property.arraySize = EditorGUILayout.DelayedIntField(nameof(Models), property.arraySize);

                // Drag and Drop to add model.
                var area = GUILayoutUtility.GetLastRect();
                AnimancerGUI.HandleDragAndDrop<GameObject>(area,
                    (gameObject) =>
                    {
                        return
                            EditorUtility.IsPersistent(gameObject) &&
                            !Models.Contains(gameObject) &&
                            gameObject.GetComponentInChildren<Animator>() != null;
                    },
                    (gameObject) =>
                    {
                        var modelsProperty = ModelsProperty;// Avoid Closure.
                        modelsProperty.serializedObject.Update();

                        var i = modelsProperty.arraySize;
                        modelsProperty.arraySize = i + 1;
                        modelsProperty.GetArrayElementAtIndex(i).objectReferenceValue = gameObject;
                        modelsProperty.serializedObject.ApplyModifiedProperties();
                    });

                if (count == 0)
                    return;

                property.isExpanded = EditorGUI.Foldout(area, property.isExpanded, GUIContent.none, true);
                if (!property.isExpanded)
                    return;

                EditorGUI.indentLevel++;

                var model = property.GetArrayElementAtIndex(0);
                for (int i = 0; i < count; i++)
                {
                    GUILayout.BeginHorizontal();

                    EditorGUILayout.ObjectField(model);

                    if (GUILayout.Button("x", AnimancerGUI.MiniButton))
                    {
                        Serialization.RemoveArrayElement(property, i);
                        property.serializedObject.ApplyModifiedProperties();

                        AnimancerGUI.Deselect();
                        GUIUtility.ExitGUI();
                        return;
                    }

                    GUILayout.Space(EditorStyles.objectField.margin.right);
                    GUILayout.EndHorizontal();
                    model.Next(false);
                }

                EditorGUI.indentLevel--;
            }
Beispiel #2
0
        // Singleton pattern
        private PrositIntensityModel(string model)
        {
            if (!Models.Contains(model))
            {
                throw new PrositNotConfiguredException(string.Format(
                                                           PrositResources.PrositIntensityModel_PrositIntensityModel_Intensity_model__0__does_not_exist,
                                                           model));
            }

            Model = model;
        }
        private void OnDelete(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            if (btn != null)
            {
                PricingModelObject pmo = btn.CommandParameter as PricingModelObject;
                if (pmo != null)
                {
                    if (Models.Contains(pmo))
                    {
                        Models.Remove(pmo);
                    }
                }
            }
        }
Beispiel #4
0
		/// <summary>
		/// Renders an LI element for the given sitemap node.
		/// </summary>
		/// <param name="curr">The current page</param>
		/// <param name="item">The sitemap element</param>
		/// <param name="str">The string builder</param>
		/// <param name="stop">The desired stop level</param>
		private void RenderLI(Guid? curr, Models.SiteMap.SiteMapItem item, StringBuilder sb, int stop) {
			//if (page.GroupId == Guid.Empty || HttpContext.Current.User.IsMember(page.GroupId)) {
			var active = curr.HasValue && curr.Value == item.Id;
			var childactive = curr.HasValue && item.Contains(curr.Value);

			// Render item start
			if (Hooks.UI.Menu.RenderItemStart != null) {
				Hooks.UI.Menu.RenderItemStart(sb, item, active, childactive);
			} else {
				var hasChild = item.Items.Count() > 0 ? " has-child" : "";
				sb.AppendLine("<li" + (active ? " class=\"active" + hasChild + "\"" :
					(childactive ? " class=\"active-child" + hasChild + "\"" :
					(item.Items.Count() > 0 ? " class=\"has-child\"" : ""))) + ">");
			}
			// Render item link
			//if (WebPages.Hooks.Menu.RenderItemLink != null) {
			//	WebPages.Hooks.Menu.RenderItemLink(this, str, page) ;
			//} else {
			sb.AppendLine(String.Format("<a href=\"{0}\">{1}</a>", App.Env.Url("~/" + item.Slug),
				!String.IsNullOrEmpty(item.NavigationTitle) ? item.NavigationTitle : item.Title));
			//}
			// Render subpages
			if (item.Items.Count() > 0)
				RenderUL(curr, item.Items, sb, stop);
			// Render item end
			if (Hooks.UI.Menu.RenderItemEnd != null) {
				Hooks.UI.Menu.RenderItemEnd(sb, item, active, childactive);
			} else {
				sb.AppendLine("</li>");
			}
			//}
		}
 public bool Contains(Model model)
 {
     return Models.Contains(model);
 }