예제 #1
0
        /// <inheritdoc />
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            if (string.IsNullOrEmpty(Action))
            {
                throw new MissingRequiredAttribute("Action", Action);
            }

            writer.AddAttribute("action", Action);

            if (Width > 0)
            {
                writer.AddAttribute("width", Width.ToString());
            }
            if (LabelWidth > 0)
            {
                writer.AddAttribute("labelwidth", LabelWidth.ToString());
            }

            base.AddAttributesToRender(writer);
        }
예제 #2
0
        private void OnGUI()
        {
            using (Horizontal.Do(EditorStyles.toolbar))
            {
                if (EditorHelper.DropDownButton("Drop Down Button", EditorStyles.toolbarDropDown))
                {
                    dropDownMenu.DropDown(EditorHelper.DropDownRect);
                }
                GUILayout.FlexibleSpace();
            }

            EditorGUILayout.LabelField("Selection Style", EditorHelper.Styles.Selection);
            EditorGUILayout.LabelField("PreDrop Style", EditorHelper.Styles.PreDrop);
            EditorGUILayout.LabelField("Plus Style", EditorHelper.Styles.Plus);
            EditorGUILayout.LabelField("Minus Style", EditorHelper.Styles.Minus);
            EditorGUILayout.LabelField("Warning Style", EditorHelper.Styles.Warning, GUILayout.Height(24.0f));

            using (LabelWidth.Do(256.0f))
            {
                EditorGUILayout.IntField("This is a 256 width label", 0);
            }

            EditorHelper.BeginBoxHeader();
            EditorGUILayout.LabelField("Awesome Box");
            EditorHelper.EndBoxHeaderBeginContent();

            EditorGUILayout.LabelField("Box contents...");

            Rect position = EditorHelper.Rect(4.0f);

            EditorGUI.DrawRect(position, Color.gray);

            GUI.tooltip = "This is a tooltip";
            EditorGUILayout.LabelField(EditorHelper.Label("This label has a tooltip"));

            EditorHelper.EndBox();

            searchText = EditorHelper.SearchField(searchText);
        }
예제 #3
0
        /// <Summary>BuildDiv creates the Control as a Div</Summary>
        /// <Param name="editInfo">The EditorInfo object for this control</Param>
        private void BuildDiv(EditorInfo editInfo)
        {
            HtmlGenericControl divLabel = null;

            if (editInfo.LabelMode != LabelMode.None)
            {
                divLabel = new HtmlGenericControl("div");
                string style = "float: " + editInfo.LabelMode.ToString().ToLower();
                if (editInfo.LabelMode == LabelMode.Left || editInfo.LabelMode == LabelMode.Right)
                {
                    style += "; width: " + LabelWidth.ToString();
                }
                divLabel.Attributes.Add("style", style);
                divLabel.Controls.Add(BuildLabel(editInfo));
            }

            HtmlGenericControl divEdit = new HtmlGenericControl("div");
            string             side    = GetOppositeSide(editInfo.LabelMode);

            // HACK : Modified to not error if object is null.
            //if (side.Length > 0)
            if (!String.IsNullOrEmpty(side))
            {
                string style = "float: " + side;
                style += "; width: " + EditControlWidth.ToString();
                divEdit.Attributes.Add("style", style);
            }

            EditControl       propEditor = BuildEditor(editInfo);
            VisibilityControl visibility = BuildVisibility(editInfo);

            if (visibility != null)
            {
                visibility.Attributes.Add("style", "float: right;");
                divEdit.Controls.Add(visibility);
            }
            divEdit.Controls.Add(propEditor);
            Image requiredIcon = BuildRequiredIcon(editInfo);

            divEdit.Controls.Add(propEditor);
            if (requiredIcon != null)
            {
                divEdit.Controls.Add(requiredIcon);
            }

            if (editInfo.LabelMode == LabelMode.Left || editInfo.LabelMode == LabelMode.Top)
            {
                Controls.Add(divLabel);
                Controls.Add(divEdit);
            }
            else
            {
                Controls.Add(divEdit);
                if (divLabel != null)
                {
                    Controls.Add(divLabel);
                }
            }

            //Build the Validators
            BuildValidators(editInfo, propEditor.ID);

            if (Validators.Count > 0)
            {
                //Add the Validators to the editor cell
                foreach (BaseValidator validator in Validators)
                {
                    validator.Width = this.Width;
                    Controls.Add(validator);
                }
            }
        }