Esempio n. 1
0
        public static void GetProps(ObjectWrapper wrapper, XmlElement parent_elem)
        {
            ClassDescriptor klass = wrapper.ClassDescriptor;

            foreach (ItemGroup group in klass.ItemGroups)
            {
                foreach (ItemDescriptor item in group)
                {
                    PropertyDescriptor prop = item as PropertyDescriptor;
                    if (prop == null)
                    {
                        continue;
                    }
                    if (!prop.VisibleFor(wrapper.Wrapped) || !prop.CanWrite || prop.Name == "Name")                             // Name is written in the id attribute
                    {
                        continue;
                    }

                    object value = prop.GetValue(wrapper.Wrapped);

                    // If the property has its default value, we don't need to write it
                    if (value == null || (prop.HasDefault && prop.IsDefaultValue(value)))
                    {
                        continue;
                    }

                    string val = prop.ValueToString(value);
                    if (val == null)
                    {
                        continue;
                    }

                    XmlElement prop_elem = parent_elem.OwnerDocument.CreateElement("property");
                    prop_elem.SetAttribute("name", prop.Name);
                    if (val.Length > 0)
                    {
                        prop_elem.InnerText = val;
                    }

                    if (prop.Translatable && prop.IsTranslated(wrapper.Wrapped))
                    {
                        prop_elem.SetAttribute("translatable", "yes");
                        string tcx = prop.TranslationContext(wrapper.Wrapped);
                        if (tcx != null && tcx.Length > 0)
                        {
                            prop_elem.SetAttribute("context", "yes");
                            prop_elem.InnerText = tcx + "|" + prop_elem.InnerText;
                        }
                        string tcm = prop.TranslationComment(wrapper.Wrapped);
                        if (tcm != null && tcm.Length > 0)
                        {
                            prop_elem.SetAttribute("comments", prop.TranslationComment(wrapper.Wrapped));
                        }
                    }

                    parent_elem.AppendChild(prop_elem);
                }
            }
        }
Esempio n. 2
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;
        }
Esempio n. 3
0
        void GroupData(Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
        {
            CellRendererPropertyGroup rc = (CellRendererPropertyGroup)cell;

            rc.IsGroup = (bool)model.GetValue(iter, 2);
            rc.Text    = (string)model.GetValue(iter, 0);

            PropertyDescriptor prop = (PropertyDescriptor)model.GetValue(iter, 1);

            if (prop != null)
            {
                InstanceData idata = (InstanceData)model.GetValue(iter, 3);
                rc.SensitiveProperty = prop.EnabledFor(idata.Instance) && prop.VisibleFor(idata.Instance);
            }
            else
            {
                rc.SensitiveProperty = true;
            }
        }
Esempio n. 4
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;
        }