Пример #1
0
        private void LoadStyleItems()
        {
            ICollection styles = _styleSheet.Styles;

            foreach (String key in styles)
            {
                Style style    = (Style)_styleSheet[key];
                Style newStyle = (Style)Activator.CreateInstance(style.GetType());

                PropertyDescriptorCollection propDescs = TypeDescriptor.GetProperties(style);

                for (int i = 0; i < propDescs.Count; i++)
                {
                    if (propDescs[i].Name.Equals("Font"))
                    {
                        foreach (PropertyDescriptor desc in TypeDescriptor.GetProperties(style.Font))
                        {
                            desc.SetValue(newStyle.Font, desc.GetValue(style.Font));
                        }
                    }
                    else if (!propDescs[i].IsReadOnly)
                    {
                        propDescs[i].SetValue(newStyle, propDescs[i].GetValue(style));
                    }
                }

                _tempStyleSheet[newStyle.Name] = newStyle;
                newStyle.SetControl(_tempStyleSheet);

                StyleNode newStyleItem = new StyleNode(newStyle);
                _tvDefinedStyles.Nodes.Add(newStyleItem);
            }
        }
Пример #2
0
        private void InitAvailableStyles()
        {
            //int[] colMaxWidth = { _lvAvailableStyles.Columns[0].Width, _lvAvailableStyles.Columns[1].Width };
            int[] colMaxWidth = { 68, 202 };
            int[] colReqWidth = { 0, 0 };

            // NOTE: Currently no way for third party extenders to add their
            // own styles.  They'll need to specify complete name with tagprefix included.
            StringCollection mobileStyles = new StringCollection();

            mobileStyles.AddRange(
                new String[2] {
                "System.Web.UI.MobileControls.PagerStyle",
                "System.Web.UI.MobileControls.Style"
            });

            foreach (String mobileStyle in mobileStyles)
            {
                Type         type     = Type.GetType(mobileStyle, true);
                String[]     subItems = { type.Name, type.Namespace };
                ListViewItem item     = new ListViewItem(subItems);
                _lvAvailableStyles.Items.Add(item);
            }

            ICollection styles = _styleSheet.Styles;

            foreach (String key in styles)
            {
                Style style = (Style)_styleSheet[key];
                Type  type  = style.GetType();
                if (!mobileStyles.Contains(type.FullName))
                {
                    String[]     subItems = { type.Name, type.Namespace };
                    ListViewItem item     = new ListViewItem(subItems);
                    _lvAvailableStyles.Items.Add(item);

                    // Rectangle rcLvi = lvi.GetBounds((int) ItemBoundsPortion.Label);
                    // use a method like GetExtendPoint32
                    colReqWidth[0] = 68;
                    if (colReqWidth[0] > colMaxWidth[0])
                    {
                        colMaxWidth[0] = colReqWidth[0];
                    }
                    // use a method like GetExtendPoint32
                    colReqWidth[1] = 202;
                    if (colReqWidth[1] > colMaxWidth[1])
                    {
                        colMaxWidth[1] = colReqWidth[1];
                    }
                }
            }
            _lvAvailableStyles.Columns[0].Width = colMaxWidth[0] + 4;
            _lvAvailableStyles.Columns[1].Width = colMaxWidth[1] + 4;

            Debug.Assert(_lvAvailableStyles.Items.Count > 0);
            _lvAvailableStyles.Sort();
            _lvAvailableStyles.Items[0].Selected = true;
            _currentNewStyleType = Type.GetType((String)_lvAvailableStyles.Items[0].SubItems[1].Text + "." +
                                                _lvAvailableStyles.Items[0].Text, true);
        }
Пример #3
0
            internal StyleNode(Style style)
            {
                _runtimeStyle          = style;
                _fullName              = style.GetType().FullName;
                _styleReference        = RuntimeStyle.StyleReference;
                _styleReferenceChanged = new EventHandler(this.OnStyleReferenceChanged);
                base.Text              = RuntimeStyle.Name;


                PropertyDescriptor property;

                property = TypeDescriptor.GetProperties(typeof(Style))["StyleReference"];
                Debug.Assert(property != null);
                property.AddValueChanged(RuntimeStyle, _styleReferenceChanged);
            }
 private bool PropertyExistsInStyle(
     PropertyDescriptor property, Style style)
 {
     return style.GetType().GetProperty(property.Name) != null;
 }
            internal StyleNode(Style style)
            {
                _runtimeStyle = style;
                _fullName = style.GetType().FullName;
                _styleReference = RuntimeStyle.StyleReference;
                _styleReferenceChanged = new EventHandler(this.OnStyleReferenceChanged);
                base.Text = RuntimeStyle.Name;


                PropertyDescriptor property;
                property = TypeDescriptor.GetProperties(typeof(Style))["StyleReference"];
                Debug.Assert(property != null);
                property.AddValueChanged(RuntimeStyle, _styleReferenceChanged);
            }
Пример #6
0
 internal StyleNode(Style style)
 {
     this._runtimeStyle = style;
     this._fullName = style.GetType().FullName;
     this._styleReference = this.RuntimeStyle.get_StyleReference();
     this._styleReferenceChanged = new EventHandler(this.OnStyleReferenceChanged);
     base.Text = this.RuntimeStyle.get_Name();
     TypeDescriptor.GetProperties(typeof(Style))["StyleReference"].AddValueChanged(this.RuntimeStyle, this._styleReferenceChanged);
 }