示例#1
0
        public int GetStyleIndex(ContentStyle style)
        {
            if (style == null ||
                style == _Default ||
                _Default.EqualsStyleValue(style))
            {
                return(-1);
            }
            else
            {
                int index = this.Styles.IndexOfExt(style);
                if (index < 0)
                {
                    if (style.RemoveSameStyle(this.Default) > 0)
                    {
                        index = this.Styles.IndexOfExt(style);
                        if (index < 0)
                        {
                            index = this.Styles.Add(style);
                        }
                        ////style.Index = index;
                        //if ( this.Document != null && this.Document.CanLogUndo)
                        //{
                        //    this.Document.UndoList.Add(
                        //        new XTextUndoModifyArrayItem(
                        //            XTextUndoModifyListAction.Insert,
                        //            this.Styles,
                        //            index,
                        //            null,
                        //            style));
                        //}

                        ClearRuntimeStyleList();
                    }
                    else
                    {
                        return(-1);
                    }
                }
                return(index);
            }
        }