public IPropertyEditor CreateEditor(PropertyDescriptor prop)
        {
            PropertyEditorCell cell = PropertyEditorCell.GetPropertyCell(prop);

            cell.Initialize(this, prop, null);

            session = cell.StartEditing(new Gdk.Rectangle(), StateType.Normal);
            if (session == null)
            {
                return(new DummyEditor());
            }

            Gtk.Widget w = (Gtk.Widget)session.Editor as Gtk.Widget;
            w.ShowAll();
            return(session.Editor);
        }
Exemplo n.º 2
0
        void PropertyData(Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
        {
            CellRendererProperty rc = (CellRendererProperty)cell;
            bool group = (bool)model.GetValue(iter, 2);

            if (group)
            {
                rc.SetData(null, null, null);
            }
            else
            {
                PropertyDescriptor prop     = (PropertyDescriptor)model.GetValue(iter, 1);
                PropertyEditorCell propCell = PropertyEditorCell.GetPropertyCell(prop);
                InstanceData       idata    = (InstanceData)model.GetValue(iter, 3);
                propCell.Initialize(tree, prop, idata.Instance);
                rc.SetData(idata.Instance, prop, propCell);
            }
        }
Exemplo n.º 3
0
        public void SetData(object instance, PropertyDescriptor property, PropertyEditorCell editor)
        {
            this.instance = instance;
            this.property = property;
            if (property == null)
            {
                this.CellBackgroundGdk = tree.Style.MidColors [(int)Gtk.StateType.Normal];
            }
            else
            {
                this.CellBackground = null;
            }

            visible = property != null?property.VisibleFor(instance) : true;

            sensitive = property != null?property.EnabledFor(instance) && property.VisibleFor(instance) : true;

            editorCell = editor;
        }
Exemplo n.º 4
0
        public static PropertyEditorCell GetPropertyCell(PropertyDescriptor property)
        {
            Type editorType = property.EditorType;

            if (editorType == null)
            {
                editorType = GetEditorForType(property.PropertyType);
            }

            if (editorType == null)
            {
                return(Default);
            }

            if (typeof(IPropertyEditor).IsAssignableFrom(editorType))
            {
                if (!typeof(Gtk.Widget).IsAssignableFrom(editorType))
                {
                    throw new Exception("The property editor '" + editorType + "' must be a Gtk Widget");
                }
                return(Default);
            }

            PropertyEditorCell cell = (PropertyEditorCell)cellCache [editorType];

            if (cell != null)
            {
                return(cell);
            }

            if (!typeof(PropertyEditorCell).IsAssignableFrom(editorType))
            {
                throw new Exception("The property editor '" + editorType + "' must be a subclass of Stetic.PropertyEditorCell or implement Stetic.IPropertyEditor");
            }

            cell = (PropertyEditorCell)Activator.CreateInstance(editorType);
            cellCache [editorType] = cell;
            return(cell);
        }
Exemplo n.º 5
0
        public void SetData(object instance, PropertyDescriptor property, PropertyEditorCell editor)
        {
            this.instance = instance;
            this.property = property;
            if (property == null)
                this.CellBackgroundGdk = tree.Style.MidColors [(int)Gtk.StateType.Normal];
            else
                this.CellBackground = null;

            visible = property != null ? property.VisibleFor (instance): true;
            sensitive = property != null ? property.EnabledFor (instance) && property.VisibleFor (instance): true;
            editorCell = editor;
        }