示例#1
0
            // Note that it return false if any of the referenced styles are already in a loop
            // ie. it returns true if and only if current style is in a loop now.
            private bool InCircularLoop()
            {
                StyleSheet styleSheet = (StyleSheet)RuntimeStyle.Control;

                Debug.Assert(styleSheet != null);

                String reference = RuntimeStyle.StyleReference;
                int    count     = styleSheet.Styles.Count + 1;

                while ((reference != null && reference.Length > 0) && count > 0)
                {
                    if (0 == String.Compare(RuntimeStyle.Name, reference, true, CultureInfo.InvariantCulture))
                    {
                        return(true);
                    }
                    else
                    {
                        Style style = styleSheet[reference];
                        if (null != style)
                        {
                            reference = style.StyleReference;
                            count--;
                        }
                        else
                        {
                            reference = null;
                        }
                    }
                }

                return(false);
            }
示例#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
        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);
            }
        }
示例#4
0
 internal StylesEditorDialog(StyleSheet stylesheet, StyleSheetDesigner styleSheetDesigner, string initialStyleName)
 {
     if (Utils.GetDuplicateStyles(stylesheet).Count > 0)
     {
         MessageBox.Show(MobileResource.GetString("StylesEditorDialog_DuplicateStyleNames"), MobileResource.GetString("StylesEditorDialog_Title"));
         throw new ArgumentException(MobileResource.GetString("StylesEditorDialog_DuplicateStyleException"));
     }
     this._tempStyleSheet = new StyleSheet();
     this._previewStyle = new Style();
     this._styleSheet = stylesheet;
     this._styleSheetDesigner = styleSheetDesigner;
     this._tempStyleSheet.Site = this._styleSheet.Site;
     this.InitializeComponent();
     this.InitAvailableStyles();
     this.LoadStyleItems();
     if (this._tvDefinedStyles.Nodes.Count > 0)
     {
         int num = 0;
         if (initialStyleName != null)
         {
             num = this.StyleIndex(initialStyleName);
         }
         this.SelectedStyle = (StyleNode) this._tvDefinedStyles.Nodes[num];
         this._tvDefinedStyles.Enabled = true;
         this.UpdateTypeText();
         this.UpdatePropertyGrid();
     }
     this.UpdateButtonsEnabling();
     this.UpdateFieldsEnabling();
 }
        protected virtual Object [] GetStyles(Object instance)
        {
            // We do not support anything other than a single styleSheet
            if (!(instance is System.Web.UI.MobileControls.StyleSheet))
            {
                return(null);
            }

            StyleSheet  _styleSheet = (StyleSheet)instance;
            ICollection styles      = _styleSheet.Styles;

            ArrayList _styleArray = new ArrayList();

            foreach (String key in styles)
            {
                System.Web.UI.MobileControls.Style style = (System.Web.UI.MobileControls.Style)_styleSheet[key];
                if (style.Name != null && style.Name.Length > 0)
                {
                    _styleArray.Add(style.Name);
                }
            }

            if (0 == _styleArray.Count)
            {
                // add (None) entry for CurrentStyle == null
                _styleArray.Add(SR.GetString(SR.StyleSheet_PropNotSet));
            }

            _styleArray.Sort();
            return(_styleArray.ToArray());
        }
示例#6
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);
            }
示例#7
0
        /// <summary>
        ///    Create a new StylesEditorDialog instance
        /// </summary>
        /// <internalonly/>
        internal StylesEditorDialog(StyleSheet stylesheet,
                                    StyleSheetDesigner styleSheetDesigner,
                                    String initialStyleName)
        {
            if (stylesheet.DuplicateStyles.Count > 0)
            {
                GenericUI.ShowErrorMessage(
                    SR.GetString(SR.StylesEditorDialog_Title),
                    SR.GetString(SR.StylesEditorDialog_DuplicateStyleNames)
                    );
                throw new ArgumentException(
                          SR.GetString(SR.StylesEditorDialog_DuplicateStyleException)
                          );
            }

            _tempStyleSheet = new StyleSheet();
            _previewStyle   = new Style();

            _styleSheet         = stylesheet;
            _styleSheetDesigner = styleSheetDesigner;

            _tempStyleSheet.Site = _styleSheet.Site;

            InitializeComponent();

            InitAvailableStyles();
            LoadStyleItems();

            if (_tvDefinedStyles.Nodes.Count > 0)
            {
                int initialIndex = 0;
                if (initialStyleName != null)
                {
                    initialIndex = StyleIndex(initialStyleName);
                }
                SelectedStyle            = (StyleNode)_tvDefinedStyles.Nodes[initialIndex];
                _tvDefinedStyles.Enabled = true;
                UpdateTypeText();
                UpdatePropertyGrid();
            }

            UpdateButtonsEnabling();
            UpdateFieldsEnabling();
        }
        static StyleSheet()
        {
            //  initialize default stylesheet
            {
                Style title = new Style();
                title.Bold = BooleanOption.True;
                title.Font.Size = FontSize.Large;
                title.Name = "title";
                _default.AddParsedSubObject(title);

                Style error = new Style();
                error.ForeColor = Color.Red;
                error.Name = Constants.ErrorStyle;
                _default.AddParsedSubObject(error);

                Style subCommand = new Style();
                subCommand.Font.Size = FontSize.Small;
                subCommand.Name = "subcommand";
                subCommand.Alignment = Alignment.Center;
                _default.AddParsedSubObject(subCommand);
            }
        }
        internal void WriteDesignerStyleAttributes(MobileControl control, 
            Style style)
        {
            Alignment alignment = (Alignment) style[Style.AlignmentKey, true];
            Wrapping wrapping = (Wrapping) style[Style.WrappingKey, true];
            Color backColor = (Color) style[Style.BackColorKey, true];

            bool align  = (alignment != Alignment.NotSet);
            bool wrap = (wrapping == Wrapping.Wrap || wrapping == Wrapping.NotSet);

            String width = DesignerAdapterUtil.GetWidth(control);

            byte templateStatus;
            int maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(control, out templateStatus);
            if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT)
            {
                width = maxWidth.ToString(CultureInfo.InvariantCulture) + "px";
            }

            if (!wrap)
            {
                Write(" style=\"overflow-x:hidden;width:" + width);
            }
            else
            {
                Write(" style=\"word-wrap:break-word;overflow-x:hidden;width:" + width);
            }

            if (backColor != Color.Empty)
            {
                Write(";background-color:" + ColorTranslator.ToHtml(backColor));
            }

            if (align)
            {
                Write(";text-align:" + Enum.GetName(typeof(Alignment), alignment));
            }
        }
示例#10
0
        private void OnCreateNewStyle()
        {
            String newStyleAutoID = AutoIDStyle();

            Style newStyle = (Style)Activator.CreateInstance(_currentNewStyleType);

            Debug.Assert(newStyle != null);
            newStyle.Name = newStyleAutoID;

            // Add this style to StyleSheet
            _tempStyleSheet[newStyle.Name] = newStyle;
            newStyle.SetControl(_tempStyleSheet);

            StyleNode newStyleItem = new StyleNode(newStyle);

            _tvDefinedStyles.Enabled = true;
            _propertyBrowser.Enabled = true;
            _tvDefinedStyles.Nodes.Add(newStyleItem);
            SelectedStyle = newStyleItem;

            UpdateSamplePreview();
            UpdateButtonsEnabling();
        }
 private void RenderRule (XhtmlMobileTextWriter writer, Color foreColor, int columnSpan) {
     if (CssLocation == StyleSheetLocation.PhysicalFile || Device["requiresXhtmlCssSuppression"] == "true") {
         // Review: Since, if there is a physical stylesheet, we cannot know the intended foreColor,
         // do not render a rule.
         return;
     }
     writer.Write("<tr>");
     Style hruleStyle = new Style();
     // Rendering <td...> with background color equal to the style's forecolor renders a thin
     // rule with color forecolor, as intended.
     hruleStyle[Style.BackColorKey] = foreColor == Color.Empty ? Color.Black : foreColor;
     NameValueCollection additionalAttributes = new NameValueCollection();
     additionalAttributes["colspan"] = columnSpan.ToString(CultureInfo.InvariantCulture);              
     writer.EnterStyleInternal(hruleStyle, "td", StyleFilter.BackgroundColor, additionalAttributes);
     writer.ExitStyle(Style);
     writer.WriteEndTag("tr");            
 }
 /// <include file='doc\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlMobileTextWriter.ExitFormat"]/*' />
 public override void ExitFormat(Style style)
 {
     if (AnalyzeMode)
     {
         return;
     }
     _formatStack.Pop();
 }
 /// <include file='doc\XhtmlMobileTextWriter.uex' path='docs/doc[@for="XhtmlMobileTextWriter.ExitStyle"]/*' />
 public new void ExitStyle (Style style) {
     StylePair pair = (StylePair) _styleStack.Pop ();
     if (pair.Tag != null && pair.Tag.Length > 0) WriteEndTag (pair.Tag);
     if (IsBlockElement(pair.Tag)) {
         ClearPendingBreak();
     }
     WriteLine ();
 }
 internal void EnterStyleInternal (Style style, String styleTag, StyleFilter filter, NameValueCollection additionalAttributes) {
     EnterStyleInternal(new XhtmlStyleClass(style, filter), styleTag, additionalAttributes, false /* force tag to be written */);
 }
 /// <include file='doc\XhtmlMobileTextWriter.uex' path='docs/doc[@for="XhtmlMobileTextWriter.ExitLayout"]/*' />
 public override void ExitLayout (Style style) {
     ExitStyle (style);
 }
示例#16
0
        // 


        internal FontInfo(Style style)
        {
            _style = style;
        }
示例#17
0
        /// <include file='doc\StyleSheet.uex' path='docs/doc[@for="StyleSheet.LoadViewState"]/*' />
        protected override void LoadViewState(Object savedState)
        {
            if (savedState != null)
            {
                Object[] o = (Object[])savedState;
                base.LoadViewState(o[0]);

                if (o[2] != null)
                {
                    bool savedAll = (bool)o[1];
                    Object[] stylesState = (Object[])o[2];

                    if (savedAll)
                    {
                        _saveAll = true;
                        _styles.Clear();
                    }

                    int stylesCount = _styles.Count;
                    for (int i = 0; i < stylesState.Length; i++)
                    {
                        if (i >= stylesCount)
                        {
                            Style style = new Style();
                            IStateManager styleStateMgr = (IStateManager)style;

                            styleStateMgr.LoadViewState(stylesState[i]);
                            styleStateMgr.TrackViewState();
                            style.SetControl(this);
                            _styles[style.Name.ToLower(CultureInfo.InvariantCulture)] = style;
                        }
                        else if (stylesState != null)
                        {
                            ((IStateManager)_styles.GetAt(i)).LoadViewState(stylesState[i]);
                        }
                    }
                }
            }
        }
 internal StylePair (String styleTag, Style style, StyleFilter filter) {
     Tag = styleTag;
     Class = new XhtmlStyleClass (style, filter);
 }
 /// <include file='doc\XhtmlMobileTextWriter.uex' path='docs/doc[@for="XhtmlMobileTextWriter.SetBodyStyle"]/*' />
 public virtual void SetBodyStyle (Style style) {
     // Filter is not strictly needed here, since default property values are not written anyway
     // but it is a good practice to provide a meaningful filter.
     StyleFilter filter = _defaultStyleClass.GetFilter(style);
     _bodyStyle = new XhtmlStyleClass (style, filter);
     _isStyleSheetEmpty = filter == 0;
 }
 // Please see ASURT 144034 for this device-specific issue.
 // Internal-only utility to return name of an XhtmlFormatStyleClass that represents the (format) diff of the 
 // parameter from the current style. This does not push the style stack -it is used only for tags with 
 // small content models such as <a>.  
 internal String GetCssFormatClassName(Style style) {
     if (!_cachingRendering) {
         Debug.Fail ("Only call when caching rendering");
         return null;
     }
     if (style ==  null) {
         return null; // caller should check for this return value.
     }
     // We need to write all non-default properties, so get the filter from the _defaultStyleClass.
     StyleFilter filter = _defaultStyleClass.GetFilter(style);
     filter &= XhtmlConstants.Format;
     if (filter == StyleFilter.None) {
         return null;
     }
     XhtmlFormatStyleClass styleClass = new XhtmlFormatStyleClass(style, filter);
     // Value returned is a valid styleClass which can be added to the attributes of, e.g., an <a> element
     // to cause character formatting.  Please see 144034 for the device specific issue.
     XhtmlStyleClass hashStyleClass = EnsureXhtmlStyleClassInHashtable(styleClass);
     if (hashStyleClass == null) {
         return null;
     }
     return hashStyleClass.StyleClassName;
 }
示例#21
0
        /*
         *  END EVENT HANDLING
         */

        private bool ReferencesContainCycle(StyleNode startingStyleItem)
        {
            StyleNode currentStyleItem = startingStyleItem;
            Style     currentStyle     = currentStyleItem.RuntimeStyle;
            String    reference        = currentStyle.StyleReference;
            bool      found            = true;
            bool      cycle            = false;

            // Clear referenced boolean
            foreach (StyleNode styleNode in _tvDefinedStyles.Nodes)
            {
                styleNode.Referenced = false;
            }

            // Set current style as referenced.
            currentStyleItem.Referenced = true;

            while ((reference != null && reference.Length > 0) && found && !cycle)
            {
                found = false;
                foreach (StyleNode styleNode in _tvDefinedStyles.Nodes)
                {
                    Style style = styleNode.RuntimeStyle;
                    if (0 == String.Compare(style.Name, reference, true, CultureInfo.InvariantCulture))
                    {
                        reference = style.StyleReference;
                        found     = true;
                        if (styleNode.Referenced)
                        {
                            cycle = true;
                        }
                        else
                        {
                            styleNode.Referenced = true;
                        }
                        break;
                    }
                }

                // keep on looking.
                // It depends on whether a style defined in web.config can have a reference or not.

/*              if we do need to keep on looking we need to store the Referenced flag
 *              // for those styles as well.
 *              // If not found, check default styles
 *              if (!found)
 *              {
 *                  if (null != StyleSheet.Default[reference])
 *                  {
 *                      Style style = StyleSheet.Default[reference];
 *                      reference = style.Reference;
 *                      found = true;
 *                      // get styleNode from other list
 *                      if (styleNode.Referenced)
 *                      {
 *                          cycle = true;
 *                      }
 *                      else
 *                      {
 *                          styleNode.Referenced = true;
 *                      }
 *                      break;
 *                  }
 *              }
 */
            }

            return(cycle);
        }
            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);
            }
示例#23
0
        /// <summary>
        ///   Apply the currently selected style to the preview label.
        ///   This function should only be called after making sure that there is no
        ///   cycle that starts with _tvDefinedStyles.SelectedItem
        /// </summary>
        private void ApplyStyle()
        {
            StyleNode currentStyleItem = (StyleNode)SelectedStyle;
            Style     currentStyle     = currentStyleItem.RuntimeStyle;

            Color         foreColor  = currentStyle.ForeColor;
            Color         backColor  = currentStyle.BackColor;
            BooleanOption fontBold   = currentStyle.Font.Bold;
            BooleanOption fontItalic = currentStyle.Font.Italic;
            FontSize      fontSize   = currentStyle.Font.Size;
            String        fontName   = currentStyle.Font.Name;
            String        reference  = currentStyle.StyleReference;

            bool found = true;

            while ((reference != null && reference.Length > 0) && found)
            {
                found = false;
                foreach (StyleNode styleNode in _tvDefinedStyles.Nodes)
                {
                    Style style = styleNode.RuntimeStyle;
                    if (0 == String.Compare(style.Name, reference, true, CultureInfo.InvariantCulture))
                    {
                        if (foreColor == Color.Empty)
                        {
                            foreColor = style.ForeColor;
                        }
                        if (backColor == Color.Empty)
                        {
                            backColor = style.BackColor;
                        }
                        if (fontBold == BooleanOption.NotSet)
                        {
                            fontBold = style.Font.Bold;
                        }
                        if (fontItalic == BooleanOption.NotSet)
                        {
                            fontItalic = style.Font.Italic;
                        }
                        if (fontSize == FontSize.NotSet)
                        {
                            fontSize = style.Font.Size;
                        }
                        if (fontName == String.Empty)
                        {
                            fontName = style.Font.Name;
                        }
                        reference = style.StyleReference;
                        found     = true;
                        break;
                    }
                }

                // If not found, check default styles
                if (!found)
                {
                    if (null != StyleSheet.Default[reference])
                    {
                        Style style = StyleSheet.Default[reference];
                        if (foreColor == Color.Empty)
                        {
                            foreColor = style.ForeColor;
                        }
                        if (backColor == Color.Empty)
                        {
                            backColor = style.BackColor;
                        }
                        if (fontBold == BooleanOption.NotSet)
                        {
                            fontBold = style.Font.Bold;
                        }
                        if (fontItalic == BooleanOption.NotSet)
                        {
                            fontItalic = style.Font.Italic;
                        }
                        if (fontSize == FontSize.NotSet)
                        {
                            fontSize = style.Font.Size;
                        }
                        if (fontName == String.Empty)
                        {
                            fontName = style.Font.Name;
                        }
                        reference = null;
                        found     = true;
                        break;
                    }
                }
            }

            _previewStyle.ForeColor   = foreColor;
            _previewStyle.BackColor   = backColor;
            _previewStyle.Font.Name   = fontName;
            _previewStyle.Font.Size   = fontSize;
            _previewStyle.Font.Bold   = fontBold;
            _previewStyle.Font.Italic = fontItalic;
        }
 private void CopyStyleProperties(Style source, Style dest)
 {
     // We copy the StateBag to duplicate the style properties without
     // walking the inheritance.
     dest.State.Clear();
     foreach(String key in source.State.Keys)
     {
         dest.State[key] = source.State[key];
     }
 }
 /// <include file='doc\XhtmlMobileTextWriter.uex' path='docs/doc[@for="XhtmlMobileTextWriter.ExitFormat"]/*' />
 public override void ExitFormat (Style style) {
     ExitStyle (style);
 }
        /// <include file='doc\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlMobileTextWriter.EnterLayout"]/*' />
        public override void EnterLayout(Style style)
        {
            if (AnalyzeMode)
            {
                return;
            }

            WmlLayout newLayout = new WmlLayout(style, CurrentLayout);
            _layoutStack.Push(newLayout);
        }
示例#27
0
        protected virtual Object [] GetStyles(Object instance)
        {
            StyleSheet styleSheet    = null;
            Style      instanceStyle = null;

            // Remember, ChoicePropertyFilter is a MobileControl, so we must
            // check for ChoicePropertyFilter first...
            if (instance is IDeviceSpecificChoiceDesigner)
            {
                instance = ((IDeviceSpecificChoiceDesigner)instance).UnderlyingObject;
            }

            if (instance is System.Web.UI.MobileControls.Style)
            {
                instanceStyle = (Style)instance;
                if (instanceStyle.Control is StyleSheet)
                {
                    styleSheet = (StyleSheet)instanceStyle.Control;
                }
                else if ((instanceStyle.Control is Form && instanceStyle is PagerStyle) ||
                         (instanceStyle.Control is ObjectList))
                {
                    if (instanceStyle.Control.MobilePage != null)
                    {
                        styleSheet = instanceStyle.Control.MobilePage.StyleSheet;
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    Debug.Fail("Unsupported objects passed in");
                }
            }
            else if (instance is System.Web.UI.MobileControls.MobileControl)
            {
                MobileControl control = (MobileControl)instance;
                if (control.MobilePage == null)
                {
                    return(null);
                }
                styleSheet = control.MobilePage.StyleSheet;
            }
            else if (instance is Array)
            {
                Array array = (Array)instance;
                Debug.Assert(array.Length > 0);

                return(GetStyles(array.GetValue(0)));
            }
            else
            {
                Debug.Fail("Unsupported type passed in");
                return(null);
            }
            Debug.Assert(null != styleSheet);

            ICollection styles     = styleSheet.Styles;
            ArrayList   styleArray = new ArrayList();

            foreach (String key in styles)
            {
                System.Web.UI.MobileControls.Style style = styleSheet[key];
                if (style.Name != null && style.Name.Length > 0)
                {
                    if (null == instanceStyle || 0 != String.Compare(instanceStyle.Name, style.Name, false, CultureInfo.InvariantCulture))
                    {
                        styleArray.Add(style.Name);
                    }
                }
            }

            if (styleSheet == StyleSheet.Default)
            {
                styleArray.Sort();
                return(styleArray.ToArray());
            }

            styles = StyleSheet.Default.Styles;
            foreach (String key in styles)
            {
                System.Web.UI.MobileControls.Style style = StyleSheet.Default[key];
                if (style.Name != null && style.Name.Length > 0)
                {
                    if (null == instanceStyle || 0 != String.Compare(instanceStyle.Name, style.Name, false, CultureInfo.InvariantCulture))
                    {
                        styleArray.Add(style.Name);
                    }
                }
            }

            if (styleArray.Count <= 1)
            {
                return(styleArray.ToArray());
            }

            styleArray.Sort();
            String preID = ((String)styleArray[0]).ToLower(CultureInfo.InvariantCulture);

            int i = 1;

            while (i < styleArray.Count)
            {
                if (((String)styleArray[i]).ToLower(CultureInfo.InvariantCulture).Equals(preID))
                {
                    styleArray.RemoveAt(i);
                }
                else
                {
                    preID = ((String)styleArray[i]).ToLower(CultureInfo.InvariantCulture);
                    i++;
                }
            }

            return(styleArray.ToArray());
        }
        /// <include file='doc\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlMobileTextWriter.EnterFormat"]/*' />
        public override void EnterFormat(Style style)
        {
            if (AnalyzeMode)
            {
                return;
            }

            WmlFormat newFormat = new WmlFormat(style, CurrentFormat);
            _formatStack.Push(newFormat);
        }
 // Overloads for complex controls like list that compose list items.  For these controls, the accessKey attribute
 // for each link may be different from the accessKey attribute for the control.
 /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderBeginLink"]/*' />
 protected virtual void RenderBeginLink(XhtmlMobileTextWriter writer, String target, String accessKey, Style style, String cssClass) {
     RenderBeginLink(writer, target, accessKey, style, cssClass, null /* title */);
 }
 /// <include file='doc\XhtmlMobileTextWriter.uex' path='docs/doc[@for="XhtmlMobileTextWriter.ExitLayout1"]/*' />
 public override void ExitLayout (Style style, bool breakafter) {
     ExitStyle (style);
     if (breakafter) {
         SetPendingBreak();
     }
 }
        /// <summary>
        ///    Create a new StylesEditorDialog instance
        /// </summary>
        /// <internalonly/>
        internal StylesEditorDialog(StyleSheet stylesheet, 
            StyleSheetDesigner styleSheetDesigner,
            String initialStyleName) : base (stylesheet.Site)
        {
            if(stylesheet.DuplicateStyles.Count > 0)
            {
                GenericUI.ShowErrorMessage(
                    SR.GetString(SR.StylesEditorDialog_Title),
                    SR.GetString(SR.StylesEditorDialog_DuplicateStyleNames)
                );
                throw new ArgumentException(
                    SR.GetString(SR.StylesEditorDialog_DuplicateStyleException)
                );
            }
        
            _tempStyleSheet = new StyleSheet();
            _previewStyle   = new Style();

            _styleSheet         = stylesheet;
            _styleSheetDesigner = styleSheetDesigner;

            _tempStyleSheet.Site = _styleSheet.Site;

            InitializeComponent();

            InitAvailableStyles();
            LoadStyleItems();

            if (_tvDefinedStyles.Nodes.Count > 0)
            {
                int initialIndex = 0;
                if (initialStyleName != null)
                {
                    initialIndex = StyleIndex(initialStyleName);
                }
                SelectedStyle = (StyleNode)_tvDefinedStyles.Nodes[initialIndex];
                _tvDefinedStyles.Enabled = true;
                UpdateTypeText();
                UpdatePropertyGrid();
            }

            UpdateButtonsEnabling();
            UpdateFieldsEnabling();
        }
 /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderBeginLink"]/*' />
 protected virtual void RenderBeginLink(XhtmlMobileTextWriter writer, String target, String accessKey, Style style, String cssClass, String title) {
     writer.WriteBeginTag("a");
     writer.Write(" href=\"");
     RenderHrefValue (writer, target);
     writer.Write("\"");
     if (accessKey != null && accessKey.Length > 0) {
         writer.WriteAttribute("accesskey", accessKey, true);
     }
     if (CssLocation != StyleSheetLocation.PhysicalFile) {
         String className = writer.GetCssFormatClassName(style);
         if (className != null) {
             writer.WriteAttribute ("class", className);
         }
     }
     else if (cssClass != null && cssClass.Length > 0) {
         writer.WriteAttribute ("class", cssClass, true /* encode */);
     }
     if (title != null && title.Length > 0) {
         writer.WriteAttribute("title", title, true /* encode */);
     }
     writer.WriteLine(">");            
 }
 private bool PropertyExistsInStyle(
     PropertyDescriptor property, Style style)
 {
     return style.GetType().GetProperty(property.Name) != null;
 }
        /////////////////////////////////////////////////////////////////////////
        //  ENTER STYLE SUPPORT:  These methods should, in general, be used in place
        //  of writer.EnterStyle, ExitStyle, etc.  They check whether there is
        //  a cssLocation attribute on the active form, and enter style only if
        //  not.
        /////////////////////////////////////////////////////////////////////////

        /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalEnterStyle"]/*' />
        protected virtual void ConditionalEnterStyle(XhtmlMobileTextWriter writer, Style style) {
            ConditionalEnterStyle(writer, style, String.Empty);
        }
 /// <include file='doc\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlMobileTextWriter.ExitLayout"]/*' />
 public override void ExitLayout(Style style, bool breakAfter)
 {
     if (!AnalyzeMode)
     {
         if (breakAfter)
         {
             PendingBreak = true;
         }
         _layoutStack.Pop();
     }
 }
        /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalEnterStyle1"]/*' />
        protected virtual void ConditionalEnterStyle(XhtmlMobileTextWriter writer, Style style, String tag) {
            if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] == "true") {
                return;
            }
            if (CssLocation == StyleSheetLocation.PhysicalFile) {
                // Do nothing.  Styles should be handled by CssClass custom attribute.
                return;
            }
            if (tag == null || tag.Length == 0) {
                writer.EnterStyle(style);
            }
            else {
                writer.EnterStyle(style, tag);
            }

        }
 /// <include file='doc\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlLayout.WmlLayout"]/*' />
 public WmlLayout(Style style, WmlLayout currentLayout)
 {
     Alignment align = (Alignment)style[Style.AlignmentKey, true];
     Align = (align != Alignment.NotSet) ? align : currentLayout.Align;
     Wrapping wrap = (Wrapping)style[Style.WrappingKey , true];
     Wrap = (wrap != Wrapping.NotSet) ? wrap : currentLayout.Wrap;
 }
 /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalExitLayout"]/*' />
 protected virtual void ConditionalExitLayout(XhtmlMobileTextWriter writer, Style style) {
     if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] == "true") {
         return;
     }
     if (CssLocation == StyleSheetLocation.PhysicalFile) {
         // Do nothing.  Styles should be handled by CssClass custom attribute.
         return;
     }
     writer.ExitLayout(style);        
 }
 /// <include file='doc\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlFormat.WmlFormat"]/*' />
 public WmlFormat(Style style, WmlFormat currentFormat)
 {
     BooleanOption bold = (BooleanOption)style[Style.BoldKey, true];
     Bold = (bold != BooleanOption.NotSet) ? bold == BooleanOption.True : currentFormat.Bold;
     BooleanOption italic = (BooleanOption)style[Style.ItalicKey, true];
     Italic = (italic != BooleanOption.NotSet) ? italic == BooleanOption.True : currentFormat.Italic;
     FontSize fontSize  = (FontSize)style[Style.FontSizeKey, true];
     Size = (fontSize != FontSize.NotSet) ? fontSize : currentFormat.Size;
 }
 // For Style/CssClass args, see ASURT 144034
 /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderPostBackEventAsAnchor2"]/*' />
 protected virtual void RenderPostBackEventAsAnchor (
     XhtmlMobileTextWriter writer,
     String argument,
     String linkText, 
     String accessKey,
     Style style,
     String cssClass) {            
     writer.WriteBeginTag("a");
     writer.Write(" href=\"");
     PageAdapter.RenderUrlPostBackEvent(writer, Control.UniqueID /* target */, argument);
     writer.Write("\" ");
     if (accessKey != null && accessKey.Length > 0) {
         writer.WriteAttribute("accesskey", accessKey);
     }
     if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true") {
         if (CssLocation != StyleSheetLocation.PhysicalFile) {
             String className = writer.GetCssFormatClassName(style);
             if (className != null) {
                 writer.WriteAttribute ("class", className);
             }
         }
         else if (cssClass != null && cssClass.Length > 0) {
             writer.WriteAttribute ("class", cssClass, true /* encode */);
         }
     }
     writer.Write(">");
     writer.WriteEncodedText(linkText);
     writer.WriteEndTag("a");
 }