Example #1
0
        public override void Draw()
        {
            object newValue = null;

            if (IsPrimitive(PropertyType))
            {
                newValue = DrawPrimitive();
            }
            else if (IsArray(PropertyType))
            {
                newValue = DrawArray();
            }
            else if (IsEnum(PropertyType))
            {
                newValue = DrawEnum();
            }
            else if (IsUnityObject(PropertyType))
            {
                newValue = DrawUnityObject();
            }

            if (newValue == Value)
            {
                return;
            }

            EventChange?.Invoke(newValue);
            Value = newValue;
        }
Example #2
0
 private void SendMessage(EventChange message)
 {
     foreach (var observer in _observers)
     {
         observer.OnNext(message);
     }
 }
Example #3
0
        public HtmlRadioGroup(string name, bool verbose, bool isPostBack)
            : base(verbose ? name : "")
        {
            attrName = new AttrName(name);

            attributes.Add(attrDisabled = new AttrDisabled());

            if (isPostBack)
            {
                events.Add(eventChange = new EventChange(string.Format("__doPostBack('{0}', '');", name)));
            }
        }
Example #4
0
        public HtmlSelect(string name, bool multiple, bool isPostBack)
            : base(name)
        {
            attributes.Add(attrName = new AttrName(name));

            attributes.Add(attrDisabled = new AttrDisabled());

            attributes.Add(attrMultiple = new AttrMultiple(multiple));

            attributes.Add(attrSize = new AttrSize());

            if (isPostBack)
            {
                events.Add(eventChange = new EventChange(string.Format("__doPostBack('{0}', '');", name)));
            }
        }
Example #5
0
        public HtmlTextBox(string name)
            : base(name, "text")
        {
            attributes.Add(attrPlaceholder = new AttrPlaceholder());

            attributes.Add(attrDataNumber = new AttrDataNumber());

            attributes.Add(attrDataMin = new AttrDataMin());

            attributes.Add(attrDataMax = new AttrDataMax());

            attributes.Add(attrDataStep = new AttrDataStep());

            attributes.Add(attrDataPrecision = new AttrDataPrecision());

            events.Add(eventChange = new EventChange());

            events.Add(eventFocus = new EventFocus());

            events.Add(eventBlur = new EventBlur());
        }
Example #6
0
        public override void Draw()
        {
            var options = Variants.Select(t => t.Name).ToList();

            if (CanNullable)
            {
                options.Insert(0, "null");
            }

            if (!options.Any())
            {
                throw new InvalidDataException("options for select in dropdown not contains any element");
            }

            var index            = Variants.FindIndex(t => t.Value.Equals(Selected));
            var current_selected = Selected == null ? 0 : index == -1 ? 0 : index + (CanNullable ? 1 : 0);

            int new_selection;

            if (Label == null)
            {
                new_selection = EditorGUILayout.Popup(current_selected, options.ToArray(), LayoutOptions);
            }
            else
            {
                new_selection = EditorGUILayout.Popup(new GUIContent(Label), current_selected,
                                                      options.Select(t => new GUIContent(t)).ToArray(), LayoutOptions);
            }

            if (current_selected == new_selection)
            {
                return;
            }

            var variantValue = Variants.FirstOrDefault(t => t.Name == options[new_selection]);
            var newSelected  = variantValue == null ? default(T) : variantValue.Value;

            EventChange?.Invoke(newSelected);
            Selected = newSelected;
        }
Example #7
0
        public HtmlSelect(string name, int size, bool isPostBack)
            : base(name)
        {
            attributes.Add(attrName = new AttrName(name));

            attributes.Add(attrDisabled = new AttrDisabled());

            attributes.Add(attrMultiple = new AttrMultiple(true));

            if (size < 1)
            {
                throw new ArgumentException();
            }
            else
            {
                attributes.Add(attrSize = new AttrSize(size));
            }

            if (isPostBack)
            {
                events.Add(eventChange = new EventChange(string.Format("__doPostBack('{0}', '');", name)));
            }
        }
Example #8
0
 private void cmbImplementation_SelectedIndexChanged(object sender, EventArgs e)
 {
     EventChange?.Invoke((ETypeImpl)cmbImpl.SelectedIndex);
     NextEventChange?.Invoke((ETypeImpl)cmbImpl.SelectedIndex);
 }
Example #9
0
 private void SendMessage(EventChange message)
 {
     foreach (var observer in _observers)
     {
         observer.OnNext(message);
     }
 }