public void DrawBefore(CyberAttrribute cyberAttribute) { SeparatorAttribute attribute = cyberAttribute as SeparatorAttribute; EditorGUILayout.BeginHorizontal(); var content = new GUIContent(attribute.Label); float width = EditorStyles.label.CalcSize(content).x; if (string.IsNullOrEmpty(attribute.Label) == false) { DrawMinBox(); EditorGUILayout.LabelField(attribute.Label, attribute.GUIStyle, GUILayout.Width(width)); DrawMinBox(); } else { DrawMinBox(); } EditorGUILayout.EndHorizontal(); void DrawMinBox() { EditorGUILayout.BeginVertical(); GUILayout.Box(GUIContent.none, "GroupBox", GUILayout.Height(1), GUILayout.MaxWidth(int.MaxValue)); EditorGUILayout.EndVertical(); } }
/// <summary> /// Find all properties from the model and fill this.properties. /// </summary> /// <param name="model">The mode object</param> public void FindAllProperties(Model model) { this.model = model; this.properties.Clear(); if (this.model != null) { var members = from member in this.model.GetType().GetMembers(BindingFlags.Instance | BindingFlags.Public) where Attribute.IsDefined(member, typeof(DescriptionAttribute)) && (member is PropertyInfo || member is FieldInfo) orderby((DescriptionAttribute)member .GetCustomAttributes(typeof(DescriptionAttribute), false) .Single()).LineNumber select member; foreach (MemberInfo member in members) { IVariable property = null; if (member is PropertyInfo) { property = new VariableProperty(this.model, member as PropertyInfo); } else if (member is FieldInfo) { property = new VariableField(this.model, member as FieldInfo); } if (property != null && property.Description != null && property.Writable) { // Only allow lists that are double[], int[] or string[] bool includeProperty = true; if (property.DataType.GetInterface("IList") != null) { includeProperty = property.DataType == typeof(double[]) || property.DataType == typeof(int[]) || property.DataType == typeof(string[]); } if (Attribute.IsDefined(member, typeof(SeparatorAttribute))) { SeparatorAttribute separator = Attribute.GetCustomAttribute(member, typeof(SeparatorAttribute)) as SeparatorAttribute; properties.Add(new VariableObject(separator.ToString())); // use a VariableObject for separators } if (includeProperty) { this.properties.Add(property); } if (property.DataType == typeof(DataTable)) { this.grid.DataSource = property.Value as DataTable; } } } } }
/// <summary> /// Find all properties from the model and fill this.properties. /// </summary> /// <param name="model">The mode object</param> public void FindAllProperties(Model model) { this.model = model; properties.Clear(); if (this.model != null) { var orderedMembers = GetMembers(model); foreach (MemberInfo member in orderedMembers) { IVariable property = null; if (member is PropertyInfo) { property = new VariableProperty(this.model, member as PropertyInfo); } else if (member is FieldInfo) { property = new VariableField(this.model, member as FieldInfo); } if (property != null && property.Description != null && property.Writable) { // Only allow lists that are double[], int[] or string[] bool includeProperty = true; if (property.DataType.GetInterface("IList") != null) { includeProperty = property.DataType == typeof(double[]) || property.DataType == typeof(int[]) || property.DataType == typeof(string[]); } if (Attribute.IsDefined(member, typeof(SeparatorAttribute))) { SeparatorAttribute separator = Attribute.GetCustomAttribute(member, typeof(SeparatorAttribute)) as SeparatorAttribute; properties.Add(new VariableObject(separator.ToString())); // use a VariableObject for separators } if (includeProperty) { properties.Add(property); } if (property.DataType == typeof(DataTable)) { grid.DataSource = property.Value as DataTable; } } } } }
public void Start() { foreach (ItemDefinition definition in definitions.GetDefinitions()) { if (IsPage(definition)) { SeparatorAttribute separator = new SeparatorAttribute("seo", SortIndex); separator.ContainerName = Tabs.Details; definition.Add(separator); var titleEditor = AddEditableText(definition, TitleTitle, SeoConcern.HeadTitle, SortIndex + 3, 200); titleEditor.HelpTitle = "This text is displayed in the browser's title bar and in search engine result lists, when this value is empty the page title is used."; var keywordsEditor = AddEditableText(definition, MetaKeywordsTitle, SeoConcern.MetaKeywords, SortIndex + 6, 400); keywordsEditor.HelpTitle = "Keywords that may be used by search engines to pinpoint whe subject of this page. Text content and incoming links also affect this."; var descriptionEditor = AddEditableText(definition, MetaDescriptionTitle, SeoConcern.MetaDescription, SortIndex + 9, 1000); descriptionEditor.HelpTitle = "A text that can be used by search engines to describe this page when displaying it in search results."; } } }
/// <summary> /// Find all properties from the model and fill this.properties. /// </summary> /// <param name="model">The mode object</param> public void FindAllProperties(Model model) { this.model = model; properties.Clear(); bool filterByCategory = !((this.CategoryFilter == "") || (this.CategoryFilter == null)); bool filterBySubcategory = !((this.SubcategoryFilter == "") || (this.SubcategoryFilter == null)); if (this.model != null) { var orderedMembers = GetMembers(model); foreach (MemberInfo member in orderedMembers) { IVariable property = null; if (member is PropertyInfo) { property = new VariableProperty(this.model, member as PropertyInfo); } else if (member is FieldInfo) { property = new VariableField(this.model, member as FieldInfo); } if (property != null && property.Description != null && property.Writable) { // Only allow lists that are double[], int[] or string[] bool includeProperty = true; if (property.DataType.GetInterface("IList") != null) { includeProperty = property.DataType == typeof(double[]) || property.DataType == typeof(int[]) || property.DataType == typeof(string[]) || property.DataType == typeof(DateTime[]); } if (Attribute.IsDefined(member, typeof(SeparatorAttribute))) { SeparatorAttribute separator = Attribute.GetCustomAttribute(member, typeof(SeparatorAttribute)) as SeparatorAttribute; properties.Add(new VariableObject(separator.ToString())); // use a VariableObject for separators } //If the above conditions have been met and, //If a CategoryFilter has been specified. //filter only those properties with a [Catagory] attribute that matches the filter. if (includeProperty && filterByCategory) { bool hasCategory = Attribute.IsDefined(member, typeof(CategoryAttribute), false); if (hasCategory) { CategoryAttribute catAtt = (CategoryAttribute)Attribute.GetCustomAttribute(member, typeof(CategoryAttribute)); if (catAtt.Category == this.CategoryFilter) { if (filterBySubcategory) { //the catAtt.Subcategory is by default given a value of //"Unspecified" if the Subcategory is not assigned in the Category Attribute. //so this line below will also handle "Unspecified" subcategories. includeProperty = (catAtt.Subcategory == this.SubcategoryFilter); } else { includeProperty = true; } } else { includeProperty = false; } } else { //if we are filtering on "Unspecified" category then there is no Category Attribute // just a Description Attribute on the property in the model. //So we still may need to include it in this case. if (this.CategoryFilter == "Unspecified") { includeProperty = true; } else { includeProperty = false; } } } if (includeProperty) { properties.Add(property); } if (property.DataType == typeof(DataTable)) { grid.DataSource = property.Value as DataTable; } } } } }