Esempio n. 1
0
        private static void WriteListMarker(StringBuilder textBuffer, TextMarkerStyle listMarkerStyle, int listItemNumber)
        {
            string str = null;

            char[] chArray = null;

            switch (listMarkerStyle)
            {
            case TextMarkerStyle.None:
                str = "";
                break;

            case TextMarkerStyle.Disc:
                str = "•";
                break;

            case TextMarkerStyle.Circle:
                str = "○";
                break;

            case TextMarkerStyle.Square:
                str = "□";
                break;

            case TextMarkerStyle.Box:
                str = "■";
                break;

            case TextMarkerStyle.LowerRoman:
                str = ConvertNumberToRomanString(listItemNumber, false);
                break;

            case TextMarkerStyle.UpperRoman:
                str = ConvertNumberToRomanString(listItemNumber, true);
                break;

            case TextMarkerStyle.LowerLatin:
                chArray = ConvertNumberToString(listItemNumber, true, "abcdefghijklmnopqrstuvwxyz");
                break;

            case TextMarkerStyle.UpperLatin:
                chArray = ConvertNumberToString(listItemNumber, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
                break;

            case TextMarkerStyle.Decimal:
                chArray = ConvertNumberToString(listItemNumber, false, "0123456789");
                break;
            }

            if (str != null)
            {
                textBuffer.Append(str);
            }
            else if (chArray != null)
            {
                textBuffer.Append(chArray, 0, chArray.Length);
            }

            textBuffer.Append('\t');
        }
        internal static void UpdateSelectionListType(ToggleButton button, TextSelection selection, TextMarkerStyle expectedValue)
        {
            Paragraph startParagraph, endParagraph;

            if (selection != null)
            {
                startParagraph = selection.Start.Paragraph;
                endParagraph   = selection.End.Paragraph;
            }
            else
            {
                startParagraph = endParagraph = null;
            }

            if (startParagraph != null && endParagraph != null &&
                (startParagraph.Parent is ListItem) &&
                (endParagraph.Parent is ListItem) &&
                Object.ReferenceEquals(((ListItem)startParagraph.Parent).List, ((ListItem)endParagraph.Parent).List))
            {
                TextMarkerStyle markerStyle = ((ListItem)startParagraph.Parent).List.MarkerStyle;

                button.IsChecked = markerStyle == expectedValue;

                return;
            }

            button.IsChecked = false;
        }
        /// <summary>
        /// Updates the visual state of the List styles, such as Numbers and Bullets.
        /// </summary>
        private void UpdateSelectionListType()
        {
            //uncheck both
            _btnBullets.IsChecked = false;
            _btnNumbers.IsChecked = false;

            Paragraph startParagraph = ((Target != null) && (Target.Selection != null))
                                  ? Target.Selection.Start.Paragraph
                                  : null;
            Paragraph endParagraph = ((Target != null) && (Target.Selection != null))
                                ? Target.Selection.End.Paragraph
                                : null;

            if (startParagraph != null && endParagraph != null && (startParagraph.Parent is ListItem) && (endParagraph.Parent is ListItem) && object.ReferenceEquals((( ListItem )startParagraph.Parent).List, (( ListItem )endParagraph.Parent).List))
            {
                TextMarkerStyle markerStyle = (( ListItem )startParagraph.Parent).List.MarkerStyle;
                if (markerStyle == TextMarkerStyle.Disc) //bullets
                {
                    _btnBullets.IsChecked = true;
                }
                else if (markerStyle == TextMarkerStyle.Decimal) //numbers
                {
                    _btnNumbers.IsChecked = true;
                }
            }
        }
        public static string CreateMakerText(this TextMarkerStyle textMarker, int index)
        {
            switch (textMarker)
            {
            default:
                throw new InvalidOperationException("sorry library manager forget to modify about listmerker.");

            case TextMarkerStyle.Disc:
                return("•");

            case TextMarkerStyle.Box:
                return("▪");

            case TextMarkerStyle.Circle:
                return("○");

            case TextMarkerStyle.Square:
                return("❏");

            case TextMarkerStyle.Decimal:
                return((index + 1).ToString() + ".");

            case TextMarkerStyle.LowerLatin:
                return(NumberToOrder.ToLatin(index + 1).ToLower() + ".");

            case TextMarkerStyle.UpperLatin:
                return(NumberToOrder.ToLatin(index + 1) + ".");

            case TextMarkerStyle.LowerRoman:
                return(NumberToOrder.ToRoman(index + 1).ToLower() + ".");

            case TextMarkerStyle.UpperRoman:
                return(NumberToOrder.ToRoman(index + 1) + ".");
            }
        }
Esempio n. 5
0
        private void rTextBox_SelectionChanged(object sender, RoutedEventArgs e)
        {
            TextSelection selection = rTextBox.Selection;

            ToggleBoldTB.IsChecked      = (FontWeight)selection.GetPropertyValue(TextElement.FontWeightProperty) == FontWeights.Bold;
            ToggleItalicTB.IsChecked    = (FontStyle)selection.GetPropertyValue(TextElement.FontStyleProperty) == FontStyles.Italic;
            ToggleUnderlineTB.IsChecked = (TextDecorationCollection)selection.GetPropertyValue(Inline.TextDecorationsProperty) == TextDecorations.Underline;

            FontFamilyCB.SelectedItem     = selection.GetPropertyValue(TextElement.FontFamilyProperty);
            FontSizeCB.SelectedItem       = selection.GetPropertyValue(TextElement.FontSizeProperty);
            FontColorPicker.SelectedColor = (selection.GetPropertyValue(TextElement.ForegroundProperty) as SolidColorBrush).Color;

            Paragraph start = selection.Start.Paragraph;

            if (start != null && start.Parent is ListItem)
            {
                TextMarkerStyle markerStyle = ((ListItem)start.Parent).List.MarkerStyle;
                ToggleBulletsTB.IsChecked   = markerStyle is >= TextMarkerStyle.Disc and <= TextMarkerStyle.Box;
                ToggleNumberingTB.IsChecked = markerStyle is >= TextMarkerStyle.LowerRoman and <= TextMarkerStyle.Decimal;
            }
            else
            {
                ToggleBulletsTB.IsChecked   = false;
                ToggleNumberingTB.IsChecked = false;
            }

            var    lineSpacingVal = selection.GetPropertyValue(Block.LineHeightProperty);
            double lineSpacing    = lineSpacingVal is Double ? (double)lineSpacingVal : Double.NaN;

            LineSpacingCB.Text = Double.IsNaN(lineSpacing) ? "-" : lineSpacing.ToString();
        }
Esempio n. 6
0
        public bool GetBulletBoolValue()
        {
            var ListWidget = GetEligibleWidgets_Toolbar(PropertyOption.Option_Bullet);

            if (ListWidget.Count < 1)
            {
                return(false);
            }

            bool bReturnValue = true;

            foreach (WidgetViewModBase data in ListWidget)
            {
                Type         iType        = data.GetType();
                PropertyInfo propertyInfo = iType.GetProperty("vTextBulletStyle");

                if (propertyInfo == null)
                {
                    bReturnValue = false;
                    break;
                }

                TextMarkerStyle style = (TextMarkerStyle)(propertyInfo.GetValue(data, null));

                bReturnValue &= (style == TextMarkerStyle.Disc);
            }

            return(bReturnValue);
        }
Esempio n. 7
0
        public static bool CheckForStyle(this TextSelection selectedText, TextMarkerStyle expectedStyle)
        {
            if (selectedText == null)
            {
                return(false);
            }

            var startParagraph = selectedText.Start.Paragraph;
            var endParagraph   = selectedText.End.Paragraph;

            if (startParagraph != null && endParagraph != null && (startParagraph.Parent is ListItem) && (endParagraph.Parent is ListItem) && object.ReferenceEquals(((ListItem)startParagraph.Parent).List, ((ListItem)endParagraph.Parent).List))
            {
                TextMarkerStyle markerStyle = ((ListItem)startParagraph.Parent).List.MarkerStyle;

                if (markerStyle == expectedStyle)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        private void UpdateSelectionListType()
        {
            Paragraph startParagraph = rtbDocument.Selection.Start.Paragraph;
            Paragraph endParagraph   = rtbDocument.Selection.End.Paragraph;

            if (startParagraph != null && endParagraph != null &&
                (startParagraph.Parent is ListItem) &&
                (endParagraph.Parent is ListItem) &&
                object.ReferenceEquals(((ListItem)startParagraph.Parent).List, ((ListItem)endParagraph.Parent).List))
            {
                TextMarkerStyle markerStyle = ((ListItem)startParagraph.Parent).List.MarkerStyle;
                if (markerStyle == TextMarkerStyle.Disc)
                {
                    btnBullets.IsChecked = true;
                }
                else if (markerStyle == TextMarkerStyle.Decimal)
                {
                    btnNumbering.IsChecked = true;
                }
            }
            else
            {
                btnBullets.IsChecked   = false;
                btnNumbering.IsChecked = false;
            }
        }
Esempio n. 9
0
 internal static bool IsKnownSymbolMarkerStyle(TextMarkerStyle markerStyle)
 {
     return(
         markerStyle == TextMarkerStyle.Disc ||
         markerStyle == TextMarkerStyle.Circle ||
         markerStyle == TextMarkerStyle.Square ||
         markerStyle == TextMarkerStyle.Box
         );
 }
        // Token: 0x0600387A RID: 14458 RVA: 0x000FD100 File Offset: 0x000FB300
        private static bool HasBulletMarker(List list)
        {
            if (list == null)
            {
                return(false);
            }
            TextMarkerStyle markerStyle = list.MarkerStyle;

            return(TextMarkerStyle.Disc <= markerStyle && markerStyle <= TextMarkerStyle.Box);
        }
Esempio n. 11
0
 internal static bool IsKnownIndexMarkerStyle(TextMarkerStyle markerStyle)
 {
     return(
         markerStyle == TextMarkerStyle.Decimal ||
         markerStyle == TextMarkerStyle.LowerLatin ||
         markerStyle == TextMarkerStyle.UpperLatin ||
         markerStyle == TextMarkerStyle.LowerRoman ||
         markerStyle == TextMarkerStyle.UpperRoman
         );
 }
        // Token: 0x0600387B RID: 14459 RVA: 0x000FD128 File Offset: 0x000FB328
        private static bool HasNumericMarker(List list)
        {
            if (list == null)
            {
                return(false);
            }
            TextMarkerStyle markerStyle = list.MarkerStyle;

            return(TextMarkerStyle.LowerRoman <= markerStyle && markerStyle <= TextMarkerStyle.Decimal);
        }
        // Worker that updates editor UI when selection properties change.
        private object UpdateSelectionProperties(object arg)
        {
            object value;

            value = this.RichTextBox.Selection.GetPropertyValue(TextElement.FontFamilyProperty);
            this.SelectionFontFamily = (value == DependencyProperty.UnsetValue) ? null : value.ToString();

            value = this.RichTextBox.Selection.GetPropertyValue(TextElement.FontSizeProperty);
            this.SelectionFontSize = (value == DependencyProperty.UnsetValue) ? null : value.ToString();

            value = this.RichTextBox.Selection.GetPropertyValue(TextElement.FontWeightProperty);
            this.SelectionIsBold = (value == DependencyProperty.UnsetValue) ? false : ((FontWeight)value == FontWeights.Bold);

            value = this.RichTextBox.Selection.GetPropertyValue(TextElement.FontStyleProperty);
            this.SelectionIsItalic = (value == DependencyProperty.UnsetValue) ? false : ((FontStyle)value == FontStyles.Italic);

            value = this.RichTextBox.Selection.GetPropertyValue(Inline.TextDecorationsProperty);
            this.SelectionIsUnderline = (value == DependencyProperty.UnsetValue) ? false : value != null && System.Windows.TextDecorations.Underline.Equals(value);

            value = this.RichTextBox.Selection.GetPropertyValue(Paragraph.TextAlignmentProperty);
            this.SelectionIsAlignLeft    = (value == DependencyProperty.UnsetValue) ? true : (TextAlignment)value == TextAlignment.Left;
            this.SelectionIsAlignCenter  = (value == DependencyProperty.UnsetValue) ? false : (TextAlignment)value == TextAlignment.Center;
            this.SelectionIsAlignRight   = (value == DependencyProperty.UnsetValue) ? false : (TextAlignment)value == TextAlignment.Right;
            this.SelectionIsAlignJustify = (value == DependencyProperty.UnsetValue) ? false : (TextAlignment)value == TextAlignment.Justify;

            FlowDirection flowDirection = this.RichTextBox.Selection.Start.Paragraph.FlowDirection;

            this.SelectionParagraphIsLeftToRight = flowDirection == FlowDirection.LeftToRight;
            this.SelectionParagraphIsRightToLeft = flowDirection == FlowDirection.RightToLeft;

            // Bullets and Numbering
            Paragraph startParagraph = this.RichTextBox.Selection.Start.Paragraph;
            Paragraph endParagraph   = this.RichTextBox.Selection.End.Paragraph;

            if (startParagraph != null && endParagraph != null &&
                (startParagraph.Parent is ListItem) && (endParagraph.Parent is ListItem) &&
                ((ListItem)startParagraph.Parent).List == ((ListItem)endParagraph.Parent).List)
            {
                TextMarkerStyle markerStyle = ((ListItem)startParagraph.Parent).List.MarkerStyle;
                this.SelectionIsBullets = (
                    markerStyle == TextMarkerStyle.Disc ||
                    markerStyle == TextMarkerStyle.Circle ||
                    markerStyle == TextMarkerStyle.Square ||
                    markerStyle == TextMarkerStyle.Box);
                this.SelectionIsNumbering = (
                    markerStyle == TextMarkerStyle.LowerRoman ||
                    markerStyle == TextMarkerStyle.UpperRoman ||
                    markerStyle == TextMarkerStyle.LowerLatin ||
                    markerStyle == TextMarkerStyle.UpperLatin ||
                    markerStyle == TextMarkerStyle.Decimal);
            }

            _updateSelectionPropertiesPending = false;
            return(null);
        }
Esempio n. 14
0
 private void ProcessParagraph(TextMarkerStyle style, Paragraph para)
 {
     if (style == TextMarkerStyle.None)
     {
         DeleteBullet(para);
     }
     else
     {
         AddBullet(para);
     }
 }
Esempio n. 15
0
        //-------------------------------------------------------------------
        //
        // Private Methods
        //
        //-------------------------------------------------------------------

        #region Private Methods

        private static bool IsValidMarkerStyle(object o)
        {
            TextMarkerStyle value = (TextMarkerStyle)o;

            return(value == TextMarkerStyle.None ||
                   value == TextMarkerStyle.Disc ||
                   value == TextMarkerStyle.Circle ||
                   value == TextMarkerStyle.Square ||
                   value == TextMarkerStyle.Box ||
                   value == TextMarkerStyle.LowerRoman ||
                   value == TextMarkerStyle.UpperRoman ||
                   value == TextMarkerStyle.LowerLatin ||
                   value == TextMarkerStyle.UpperLatin ||
                   value == TextMarkerStyle.Decimal);
        }
Esempio n. 16
0
        public OpenXmlWriter()
        {
            listLevel     = 0;
            listContext   = 0;
            lastListLevel = 0;


            //30 is more than enough
            listMarkerStyle = new TextMarkerStyle[30];
            int i;

            for (i = 0; i < 30; i++)
            {
                listMarkerStyle[i] = TextMarkerStyle.Disc;
            }
        }
Esempio n. 17
0
 private bool IsSelected(TextMarkerStyle textMarkerStyle)
 {
     if (this.editor != null && this.editor.Selection != null)
     {
         Paragraph start = this.editor.Selection.Start.Paragraph;
         Paragraph end   = this.editor.Selection.End.Paragraph;
         if (start != null && end != null)
         {
             if (start.Parent is ListItem sli && end.Parent is ListItem eli && sli.List == eli.List && sli.List != null)
             {
                 return(sli.List.MarkerStyle == textMarkerStyle);
             }
         }
     }
     return(false);
 }
        // Token: 0x06003B82 RID: 15234 RVA: 0x0010EF28 File Offset: 0x0010D128
        internal static bool ConvertParagraphsToListItems(TextRange range, TextMarkerStyle markerStyle)
        {
            if (range.IsEmpty && TextPointerBase.IsAtPotentialParagraphPosition(range.Start))
            {
                TextPointer textPointer = TextRangeEditTables.EnsureInsertionPosition(range.Start);
                ((ITextRange)range).Select(textPointer, textPointer);
            }
            Block       paragraphOrBlockUIContainer = range.Start.ParagraphOrBlockUIContainer;
            TextPointer textPointer2 = (TextPointer)TextRangeEdit.GetAdjustedRangeEnd(range.Start, range.End);
            Block       paragraphOrBlockUIContainer2 = textPointer2.ParagraphOrBlockUIContainer;

            if (paragraphOrBlockUIContainer == null || paragraphOrBlockUIContainer2 == null || paragraphOrBlockUIContainer.Parent != paragraphOrBlockUIContainer2.Parent || (paragraphOrBlockUIContainer.Parent is ListItem && paragraphOrBlockUIContainer.PreviousBlock == null))
            {
                return(false);
            }
            Block block = paragraphOrBlockUIContainer;

            while (block != paragraphOrBlockUIContainer2 && block != null)
            {
                if (block is Table || block is Section)
                {
                    return(false);
                }
                block = block.NextBlock;
            }
            ListItem listItem = paragraphOrBlockUIContainer.Parent as ListItem;

            if (listItem != null)
            {
                Block block3;
                for (Block block2 = paragraphOrBlockUIContainer; block2 != null; block2 = block3)
                {
                    block3 = ((block2 == paragraphOrBlockUIContainer2) ? null : (block2.ElementEnd.GetAdjacentElement(LogicalDirection.Forward) as Block));
                    Invariant.Assert(block2.Parent is ListItem);
                    TextRangeEdit.SplitElement(block2.ElementStart);
                }
            }
            else
            {
                new List
                {
                    MarkerStyle = markerStyle
                }.Apply(paragraphOrBlockUIContainer, paragraphOrBlockUIContainer2);
            }
            return(true);
        }
Esempio n. 19
0
        /*private void Align_left(object sender, RoutedEventArgs e)
         * {
         *  if (leftt.IsChecked == true) // выключаем, но не можем
         *  {
         *      rightt.IsChecked = false;
         *      centerr.IsChecked = false;
         *      leftt.IsChecked = true;
         *      p1.TextAlignment = TextAlignment.Left;
         *  }
         *  else // включаем
         *  {
         *      leftt.IsChecked = true;
         *      rightt.IsChecked = false;
         *      centerr.IsChecked = false;
         *      p1.TextAlignment = TextAlignment.Left;
         *  }
         * }
         * private void Align_Center(object sender, RoutedEventArgs e)
         * {
         *  if (centerr.IsChecked == false) // выключаем
         *  {
         *      centerr.IsChecked = false;
         *      leftt.IsChecked = true;
         *
         *      p1.TextAlignment = TextAlignment.Left;
         *  }
         *  else if (centerr.IsChecked == true) // включаем
         *  {
         *      leftt.IsChecked = false;
         *      rightt.IsChecked = false;
         *      p1.TextAlignment = TextAlignment.Center;
         *      centerr.IsChecked = true;
         *  }
         * }
         * private void Align_Right(object sender, RoutedEventArgs e)
         * {
         *  if (rightt.IsChecked == false) // выключаем
         *  {
         *      rightt.IsChecked = false;
         *      leftt.IsChecked = true;
         *      p1.TextAlignment = TextAlignment.Left;
         *  }
         *  else // включаем
         *  {
         *      leftt.IsChecked = false;
         *      centerr.IsChecked = false;
         *      p1.TextAlignment = TextAlignment.Right;
         *      rightt.IsChecked = true;
         *  }
         * }*/
        //............................



        //Маркеры.....................
        private void Markers_Click(object sender, RoutedEventArgs e)
        {
            TextMarkerStyle style = TextMarkerStyle.Square;

            switch ((sender as FrameworkElement).Name)
            {
            case "markerDigit": style = TextMarkerStyle.Decimal; break;

            case "markerDisk": style = TextMarkerStyle.Disc; break;

            case "markerRoman": style = TextMarkerStyle.UpperRoman; break;
            }

            List <Block> blocks = doc.Blocks.Where(b => b.ContentStart.CompareTo(TextBlock.Selection.End) < 0 && b.ContentEnd.CompareTo(TextBlock.Selection.Start) > 0).ToList();

            try
            {
                if (blocks != null && (blocks[0] is Paragraph par))
                {
                    Block upper = par.PreviousBlock;
                    Block next  = par.NextBlock;

                    List list = new List(new ListItem(par));
                    list.MarkerStyle = style;
                    if (upper != null)
                    {
                        doc.Blocks.InsertAfter(upper, list);
                    }
                    else if (next != null)
                    {
                        doc.Blocks.InsertBefore(next, list);
                    }
                    else
                    {
                        doc.Blocks.Add(list);
                    }
                    TextBlock.CaretPosition = list.ContentEnd;
                }
            }
            catch
            {
            }
            mb_save = false;
        }
Esempio n. 20
0
        private void OnBulletStyleChange(object obj)
        {
            BeginChange();
            try
            {
                TextMarkerStyle style = (TextMarkerStyle)obj;

                if (Selection != null)
                {
                    if (Selection.Text.Length == 0)
                    {
                        if (CaretPosition != null && CaretPosition.Paragraph != null)
                        {
                            Paragraph para = CaretPosition.Paragraph;

                            ProcessParagraph(style, para);

                            CaretPosition = para.ContentEnd;
                        }
                    }
                    else if (Selection.Text.Length > 0)
                    {
                        TextPointer pStart = Selection.Start;
                        TextPointer pEnd   = Selection.End;

                        Paragraph para = pStart.Paragraph;

                        while (para != null && para.ContentStart.CompareTo(pEnd) < 0)
                        {
                            ProcessParagraph(style, para);

                            para = para.NextBlock as Paragraph;
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                NLogger.Warn("RichEditControl OnBulletStyleChange error," + ex.Message.ToString());
            }

            EndChange();
        }
Esempio n. 21
0
        public void SwitchMarkerStyle(TextMarkerStyle tms)
        {
            switch(tms)
            {

                case TextMarkerStyle.Disc:
                    bn_Numeric.isChecked = false;
                    bn_Bullet.isChecked = true;
                    break;
                case TextMarkerStyle.Decimal:
                    bn_Numeric.isChecked = true;
                    bn_Bullet.isChecked = false;
                    break;
                default:
                    bn_Numeric.isChecked = false;
                    bn_Bullet.isChecked = false;
                    break;
            }
        }
        private void Initialize()
        {
            ClipartImages = new string[] {
                "/RibbonDemo;component/Images/Clipart/caCompClient.png",
                "/RibbonDemo;component/Images/Clipart/caCompClientEnabled.png",
                "/RibbonDemo;component/Images/Clipart/caDatabaseBlue.png",
                "/RibbonDemo;component/Images/Clipart/caDataBaseDisabled.png",
                "/RibbonDemo;component/Images/Clipart/caDataBaseGreen.png",
                "/RibbonDemo;component/Images/Clipart/caDataBaseViolet.png",
                "/RibbonDemo;component/Images/Clipart/caInet.png",
                "/RibbonDemo;component/Images/Clipart/caInetSearch.png",
                "/RibbonDemo;component/Images/Clipart/caModem.png",
                "/RibbonDemo;component/Images/Clipart/caModemEnabled.png",
                "/RibbonDemo;component/Images/Clipart/caNetCard.png",
                "/RibbonDemo;component/Images/Clipart/caNetwork.png",
                "/RibbonDemo;component/Images/Clipart/caNetworkEnabled.png",
                "/RibbonDemo;component/Images/Clipart/caServer.png",
                "/RibbonDemo;component/Images/Clipart/caServerEnabled.png",
                "/RibbonDemo;component/Images/Clipart/caWebCam.png"
            };
            RecentDocuments = new RecentItemViewModel[] {
                new RecentItemViewModel("Recent Document 1", @"c:\My Documents\Recent Document 1.rtf", "../../../Images/Icons/new-32x32.png"),
                new RecentItemViewModel("Recent Document 2", @"c:\My Documents\Recent Document 2.rtf", "../../../Images/Icons/new-32x32.png"),
                new RecentItemViewModel("Recent Document 3", @"c:\My Documents\Recent Document 3.rtf", "../../../Images/Icons/new-32x32.png"),
                new RecentItemViewModel("Recent Document 4", @"c:\My Documents\Recent Document 4.rtf", "../../../Images/Icons/new-32x32.png")
            };

            RecentPlaces = new RecentItemViewModel[] {
                new RecentItemViewModel("Recent place 1", @"c:\My Documents\Recent place 1", "../../../Images/Icons/open-32x32.png"),
                new RecentItemViewModel("Recent place 2", @"c:\My Documents\Recent place 2", "../../../Images/Icons/open-32x32.png"),
                new RecentItemViewModel("Recent place 3", @"c:\My Documents\Recent place 3", "../../../Images/Icons/open-32x32.png")
            };
            CurrentOptions   = RibbonSimplePadOptionsViewModel.Create();
            NewOptions       = RibbonSimplePadOptionsViewModel.Create();
            ListMarkerStyles = new TextMarkerStyle[] { TextMarkerStyle.None, TextMarkerStyle.Disc, TextMarkerStyle.Circle, TextMarkerStyle.Square, TextMarkerStyle.Box, TextMarkerStyle.LowerRoman, TextMarkerStyle.UpperRoman, TextMarkerStyle.LowerLatin, TextMarkerStyle.UpperLatin, TextMarkerStyle.Decimal };
            FontSizes        = new Nullable <double>[] { null, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 24, 26, 28, 30,
                                                         32, 34, 36, 38, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 88, 96, 104, 112, 120, 128, 136, 144 };
            ShapeTypes           = new InlineImageBorderType[] { InlineImageBorderType.None, InlineImageBorderType.Rectangle, InlineImageBorderType.Circle, InlineImageBorderType.Triangle, InlineImageBorderType.Star, InlineImageBorderType.LeftArrow, InlineImageBorderType.RightArrow, InlineImageBorderType.DownArrow, InlineImageBorderType.UpArrow };
            FontFamilies         = GetFontFamilies();
            BorderWeightArray    = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            ImageScaleValueArray = new string[] { "25%", "50%", "75%", "100%", "125%", "150%", "175%", "200%", "250%", "300%", "400%", "500%" };
            PageCategoryColors   = new Color[] { Colors.Red, Colors.Orange, Colors.Yellow, Colors.Green, Colors.Blue, Color.FromArgb(255, 75, 0, 130), Color.FromArgb(255, 238, 130, 238) };
        }
Esempio n. 23
0
        protected void UpdateFormat()
        {
            object      value;
            RichTextBox edit = GetEdit();

            value = edit.Selection.GetPropertyValue(TextElement.FontFamilyProperty);
            eFontFamily.EditValue = (value == DependencyProperty.UnsetValue) ? null : value;

            value = edit.Selection.GetPropertyValue(TextElement.FontSizeProperty);
            eFontSize.EditValue = (value == DependencyProperty.UnsetValue) ? null : value;

            value = edit.Selection.GetPropertyValue(TextElement.ForegroundProperty);
            fontColorChooser.Color = (value == DependencyProperty.UnsetValue) ? Colors.Black : ((SolidColorBrush)value).Color;

            value           = edit.Selection.GetPropertyValue(TextElement.FontWeightProperty);
            bBold.IsChecked = (value == DependencyProperty.UnsetValue) ? false : ((FontWeight)value == FontWeights.Bold);

            value             = edit.Selection.GetPropertyValue(TextElement.FontStyleProperty);
            bItalic.IsChecked = (value == DependencyProperty.UnsetValue) ? false : ((FontStyle)value == FontStyles.Italic);

            value = edit.Selection.GetPropertyValue(Inline.TextDecorationsProperty);
            bUnderline.IsChecked = (value == DependencyProperty.UnsetValue) ? false : value != null && System.Windows.TextDecorations.Underline.Equals(value);

            value             = edit.Selection.GetPropertyValue(Paragraph.TextAlignmentProperty);
            bLeft.IsChecked   = (value == DependencyProperty.UnsetValue) ? true : (TextAlignment)value == TextAlignment.Left;
            bCenter.IsChecked = (value == DependencyProperty.UnsetValue) ? false : (TextAlignment)value == TextAlignment.Center;
            bRight.IsChecked  = (value == DependencyProperty.UnsetValue) ? false : (TextAlignment)value == TextAlignment.Right;

            Paragraph startParagraph = edit.Selection.Start.Paragraph;
            Paragraph endParagraph   = edit.Selection.End.Paragraph;

            if (startParagraph != null && endParagraph != null && (startParagraph.Parent is ListItem) && (endParagraph.Parent is ListItem) && object.ReferenceEquals(((ListItem)startParagraph.Parent).List, ((ListItem)endParagraph.Parent).List))
            {
                TextMarkerStyle markerStyle = ((ListItem)startParagraph.Parent).List.MarkerStyle;
                bBullets.IsChecked = (markerStyle == TextMarkerStyle.Disc || markerStyle == TextMarkerStyle.Circle || markerStyle == TextMarkerStyle.Square || markerStyle == TextMarkerStyle.Box);
            }
            else
            {
                bBullets.IsChecked = false;
            }
            isInvokePending = false;
        }
        /// <summary>
        /// Construct a text marker object
        /// </summary>
        /// <param name="style">marker style</param>
        /// <param name="offset">distance from line start to the end of the marker symbol</param>
        /// <param name="autoNumberingIndex">autonumbering counter of counter-style marker</param>
        /// <param name="textParagraphProperties">text paragraph properties</param>
        public TextSimpleMarkerProperties(
            TextMarkerStyle style,
            double offset,
            int autoNumberingIndex,
            TextParagraphProperties textParagraphProperties
            )
        {
            if (textParagraphProperties == null)
            {
                throw new ArgumentNullException("textParagraphProperties");
            }

            _offset = offset;

            if (style != TextMarkerStyle.None)
            {
                if (TextMarkerSource.IsKnownSymbolMarkerStyle(style))
                {
                    // autoNumberingIndex is ignored
                }
                else if (TextMarkerSource.IsKnownIndexMarkerStyle(style))
                {
                    // validate autoNumberingIndex
                    if (autoNumberingIndex < 1)
                    {
                        throw new ArgumentOutOfRangeException("autoNumberingIndex", SR.Get(SRID.ParameterCannotBeLessThan, 1));
                    }
                }
                else
                {
                    // invalid style
                    throw new ArgumentException(SR.Get(SRID.Enum_Invalid, typeof(TextMarkerStyle)), "style");
                }

                _textSource = new TextMarkerSource(
                    textParagraphProperties,
                    style,
                    autoNumberingIndex
                    );
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Construct a text marker object
        /// </summary>
        /// <param name="style">marker style</param>
        /// <param name="offset">distance from line start to the end of the marker symbol</param>
        /// <param name="autoNumberingIndex">autonumbering counter of counter-style marker</param>
        /// <param name="textParagraphProperties">text paragraph properties</param>
        public TextSimpleMarkerProperties(
            TextMarkerStyle             style,
            double                      offset,
            int                         autoNumberingIndex,
            TextParagraphProperties     textParagraphProperties
            ) 
        {

            if (textParagraphProperties == null)
                throw new ArgumentNullException("textParagraphProperties");

            _offset = offset;

            if (style != TextMarkerStyle.None)
            {
                if (TextMarkerSource.IsKnownSymbolMarkerStyle(style))
                {
                    // autoNumberingIndex is ignored
                }
                else if (TextMarkerSource.IsKnownIndexMarkerStyle(style))
                {
                    // validate autoNumberingIndex
                    if (autoNumberingIndex < 1)
                    {
                        throw new ArgumentOutOfRangeException("autoNumberingIndex", SR.Get(SRID.ParameterCannotBeLessThan, 1));
                    }
                }
                else
                {
                    // invalid style
                    throw new ArgumentException(SR.Get(SRID.Enum_Invalid, typeof(TextMarkerStyle)), "style");
                }

                _textSource = new TextMarkerSource(
                    textParagraphProperties, 
                    style, 
                    autoNumberingIndex
                    );
            }
        }
Esempio n. 26
0
        private void OnBulletChange(object newValue)
        {
            TextMarkerStyle style = (TextMarkerStyle)newValue;

            try
            {
                if (style == TextMarkerStyle.None)
                {
                    BulletToNone();
                }
                else if (style == TextMarkerStyle.Disc)
                {
                    NoneToBullet();
                }
            }
            catch (System.Exception ex)
            {
                NLogger.Warn("RichBlocks OnBulletChange error," + ex.Message.ToString());
            }

            TranslateControlToText();
        }
Esempio n. 27
0
        private void UpdateSelectionListType() //обновления формата списка
        {
            Paragraph startParagraph = _richTextBox.Selection.Start.Paragraph;
            Paragraph endParagraph   = _richTextBox.Selection.End.Paragraph;

            if (startParagraph != null && endParagraph != null && (startParagraph.Parent is ListItem) && (endParagraph.Parent is ListItem) && object.ReferenceEquals(((ListItem)startParagraph.Parent).List, ((ListItem)endParagraph.Parent).List))
            {
                TextMarkerStyle markerStyle = ((ListItem)startParagraph.Parent).List.MarkerStyle;
                if (markerStyle == TextMarkerStyle.Disc) //bullets
                {
                    _buttonBullets.IsChecked = true;
                }
                else if (markerStyle == TextMarkerStyle.Decimal) //numbers
                {
                    _buttonNumbering.IsChecked = true;
                }
            }
            else
            {
                _buttonBullets.IsChecked   = false;
                _buttonNumbering.IsChecked = false;
            }
        }
Esempio n. 28
0
        private void UpdateSelectionListType()
        {
            Paragraph startParagraph = SpellChecking.FocusedRTB.Selection.Start.Paragraph;
            Paragraph endParagraph   = SpellChecking.FocusedRTB.Selection.End.Paragraph;

            if (startParagraph != null && endParagraph != null && (startParagraph.Parent is ListItem) && (endParagraph.Parent is ListItem) && object.ReferenceEquals(((ListItem)startParagraph.Parent).List, ((ListItem)endParagraph.Parent).List))
            {
                TextMarkerStyle markerStyle = ((ListItem)startParagraph.Parent).List.MarkerStyle;
                if (markerStyle == TextMarkerStyle.Disc)                 //bullets
                {
                    toggleBullets.IsChecked = true;
                }
                else if (markerStyle == TextMarkerStyle.Decimal)                 //numbers
                {
                    toggleNumbers.IsChecked = true;
                }
            }
            else
            {
                toggleBullets.IsChecked = false;
                toggleNumbers.IsChecked = false;
            }
        }
Esempio n. 29
0
        private void UpdateSelectionListType()
        {
            Paragraph startParagraph = NotesTextBox.Selection.Start.Paragraph;
            Paragraph endParagraph   = NotesTextBox.Selection.End.Paragraph;

            if (startParagraph != null && endParagraph != null && (startParagraph.Parent is ListItem) && (endParagraph.Parent is ListItem) && object.ReferenceEquals(((ListItem)startParagraph.Parent).List, ((ListItem)endParagraph.Parent).List))
            {
                TextMarkerStyle markerStyle = ((ListItem)startParagraph.Parent).List.MarkerStyle;
                if (markerStyle == TextMarkerStyle.Disc) //bullets
                {
                    BulletsBtn.IsChecked = true;
                }
                else if (markerStyle == TextMarkerStyle.Decimal) //numbers
                {
                    NumberedBtn.IsChecked = true;
                }
            }
            else
            {
                BulletsBtn.IsChecked  = false;
                NumberedBtn.IsChecked = false;
            }
        }
Esempio n. 30
0
        private static void PlainConvertListItemStart(StringBuilder textBuffer, TextPointer navigator, ref Stack <int> listItemCounter)
        {
            if (navigator is TextPointer)
            {
                List     parent          = (List)((TextPointer)navigator).Parent;
                ListItem adjacentElement = (ListItem)navigator.GetAdjacentElement(LogicalDirection.Forward);

                if (listItemCounter == null)
                {
                    listItemCounter = new Stack <int>(1);
                }
                if (listItemCounter.Count == 0)
                {
                    listItemCounter.Push(Array.IndexOf(adjacentElement.SiblingListItems.ToArray <ListItem>(), adjacentElement));
                }

                int             item            = listItemCounter.Pop();
                int             num2            = (parent != null) ? parent.StartIndex : 0;
                TextMarkerStyle listMarkerStyle = (parent != null) ? parent.MarkerStyle : TextMarkerStyle.Disc;
                WriteListMarker(textBuffer, listMarkerStyle, item + num2);
                item++;
                listItemCounter.Push(item);
            }
        }
Esempio n. 31
0
 private static bool IsKnownSymbolMarkerStyle(TextMarkerStyle markerStyle)
 {
     return (
             markerStyle == TextMarkerStyle.Disc
         || markerStyle == TextMarkerStyle.Circle
         || markerStyle == TextMarkerStyle.Square
         || markerStyle == TextMarkerStyle.Box
         );
 }
        /// <summary>
        /// Fetch the floaw document of all the numbered list elements
        /// </summary>
        /// <param name="lexes">List of lexical elements to partly process</param>
        /// <param name="pos">Position in the lexes list where to start processing</param>
        /// <param name="tms">The list marker style derived from the first element of the enumerated list</param>
        /// <param name="offset">The offset for the porition to continue processing in the calling process</param>
        /// <returns>FLow document xaml of the list elements</returns>
        private string GetNumberedListElementsText(List<DocLexElement> lexes, int pos, TextMarkerStyle tms, out int offset)
        {
            string subtxt = "";
            string answ = "";
            offset = 0;
            DocLexElement lex;
            bool stop = false;
            InParamodeEnum ipm = InParamodeEnum.none;
            char listc;

            switch (tms)
            {
                case TextMarkerStyle.Decimal:
                    listc = '0';
                    break;
                case TextMarkerStyle.LowerLatin:
                    listc = 'a';
                    break;
                case TextMarkerStyle.UpperLatin:
                    listc = 'A';
                    break;
                case TextMarkerStyle.UpperRoman:
                    listc = 'I';
                    break;
                default:
                    throw new ApplicationException("Unknown list marker style");
            }

            for (int i = pos; !stop && (i < lexes.Count); i++)
            {
                lex = lexes[i];
                switch (lex.Type)
                {
                    case DocLexElement.LexTypeEnum.parabreak:
                        if (!IsListElementStart(lexes, i + 1, listc))
                            stop = true;
                        else
                        {
                            answ += string.Format("<ListItem><Paragraph TextAlignment=\"{1}\">{0}</Paragraph></ListItem>",
                                        subtxt,
                                        HeadingTextAlignment);
                            subtxt = "";
                        }
                        break;

                    case DocLexElement.LexTypeEnum.linebreak:
                        if (!IsListElementStart(lexes, i + 1, listc))
                            stop = true;
                        else
                        {
                            answ += string.Format("<ListItem><Paragraph TextAlignment=\"{1}\">{0}</Paragraph></ListItem>",
                                        subtxt,
                                        HeadingTextAlignment);
                            subtxt = "";
                        }
                        break;

                    case DocLexElement.LexTypeEnum.word:
                        subtxt += GetTextAndSpaces(lex.Text, lex.SpaceCountAtEnd);
                        break;

                    case DocLexElement.LexTypeEnum.cellstart:
                        subtxt += GetTextAndSpaces("|", lex.SpaceCountAtEnd);
                        break;

                    case DocLexElement.LexTypeEnum.greaterthan:
                        subtxt += GetTextAndSpaces("&gt;", lex.SpaceCountAtEnd);
                        break;

                    case DocLexElement.LexTypeEnum.emphasize:
                        subtxt += GetInlineFormat(lex, ref ipm, lexes, i + 1);
                        break;

                    case DocLexElement.LexTypeEnum.bold:
                        subtxt += GetInlineFormat(lex, ref ipm, lexes, i + 1);
                        break;

                    case DocLexElement.LexTypeEnum.underline:
                        subtxt += GetInlineFormat(lex, ref ipm, lexes, i + 1);
                        break;

                    case DocLexElement.LexTypeEnum.enumeration:
                        if (!AtBeginningOfLine(lexes, i))
                            subtxt += GetTextAndSpaces(lex.Text, lex.SpaceCountAtEnd);
                        break;

                    case DocLexElement.LexTypeEnum.minus:
                        subtxt += GetTextAndSpaces("-", lex.SpaceCountAtEnd);
                        break;

                    case DocLexElement.LexTypeEnum.plus:
                        subtxt += GetTextAndSpaces("+", lex.SpaceCountAtEnd);
                        break;

                    case DocLexElement.LexTypeEnum.codeinline:
                        if (!ipm.HasFlag(InParamodeEnum.inlinecode))
                        {
                            ipm |= InParamodeEnum.inlinecode;
                            subtxt += string.Format("<Span  xml:space=\"preserve\" FontFamily=\"{0}\">",
                                CodingFontFamily);
                        }
                        else
                        {
                            subtxt += "</Span>" + GetStringOf(" ", lex.SpaceCountAtEnd);
                            ipm &= ~InParamodeEnum.inlinecode;
                        }
                        break;

                }

                offset++;

            }

            //handle the end of doc with this
            if (!string.IsNullOrEmpty(subtxt))
                answ += string.Format("<ListItem><Paragraph TextAlignment=\"{1}\">{0}</Paragraph></ListItem>",
                                        subtxt,
                                        HeadingTextAlignment);

            return answ;
        }
Esempio n. 33
0
        internal TextMarkerSource(
            TextParagraphProperties     textParagraphProperties,
            TextMarkerStyle             markerStyle,
            int                         autoNumberingIndex
            )
        {
            Debug.Assert(markerStyle != TextMarkerStyle.None);

            _textParagraphProperties = textParagraphProperties;
            TextRunProperties defaultRunProperties = _textParagraphProperties.DefaultTextRunProperties;

            string symbolString = null;

            if(IsKnownSymbolMarkerStyle(markerStyle))
            {
                switch(markerStyle)
                {
                    case TextMarkerStyle.Disc:
                        symbolString = "\x9f"; break;

                    case TextMarkerStyle.Circle:
                        symbolString = "\xa1"; break;

                    case TextMarkerStyle.Square:
                        symbolString = "\x71"; break;

                    case TextMarkerStyle.Box:
                        symbolString = "\xa7"; break;
                }

                Typeface defaultTypeface = defaultRunProperties.Typeface;

                // recreate a new marker run properties based on symbol typeface e.g. Wingding
                _textRunProperties = new GenericTextRunProperties(
                    new Typeface(
                        new FontFamily("Wingdings"), 
                        defaultTypeface.Style, 
                        defaultTypeface.Weight, 
                        defaultTypeface.Stretch
                        ),
                    defaultRunProperties.FontRenderingEmSize, 
                    defaultRunProperties.FontHintingEmSize, 
                    defaultRunProperties.TextDecorations, 
                    defaultRunProperties.ForegroundBrush,
                    defaultRunProperties.BackgroundBrush,
                    defaultRunProperties.BaselineAlignment,
                    CultureMapper.GetSpecificCulture(defaultRunProperties.CultureInfo),
                    null // default number substitution for culture
                    );
            }
            else if(IsKnownIndexMarkerStyle(markerStyle))
            {
                // Internal client code should have already validated this.
                Debug.Assert(autoNumberingIndex > 0);

                _textRunProperties = defaultRunProperties;

                int counter = autoNumberingIndex;

                switch(markerStyle)
                {
                    case TextMarkerStyle.Decimal:
                        _characterArray = ConvertNumberToString(counter, false, DecimalNumerics);
                        break;

                    case TextMarkerStyle.LowerLatin:
                        _characterArray = ConvertNumberToString(counter, true, LowerLatinNumerics);
                        break;

                    case TextMarkerStyle.UpperLatin:
                        _characterArray = ConvertNumberToString(counter, true, UpperLatinNumerics);
                        break;

                    case TextMarkerStyle.LowerRoman:
                        symbolString = ConvertNumberToRomanString(counter, false);
                        break;
                            
                    case TextMarkerStyle.UpperRoman:
                        symbolString = ConvertNumberToRomanString(counter, true);
                        break;
                }
            }
            else
            {
                Debug.Assert(false, "Invalid marker style");
            }

            if(symbolString != null)
            {
                _characterArray = symbolString.ToCharArray();
            }

            Debug.Assert(_characterArray != null);
        }
Esempio n. 34
0
        internal static bool ConvertParagraphsToListItems(TextRange range, TextMarkerStyle markerStyle)
        {
            if (range.IsEmpty && TextPointerBase.IsAtPotentialParagraphPosition(range.Start))
            {
                TextPointer insertionPosition = TextRangeEditTables.EnsureInsertionPosition(range.Start);
                ((ITextRange)range).Select(insertionPosition, insertionPosition);
            }

            Block firstBlock = range.Start.ParagraphOrBlockUIContainer;

            TextPointer end = (TextPointer)TextRangeEdit.GetAdjustedRangeEnd(range.Start, range.End);
            Block lastBlock = end.ParagraphOrBlockUIContainer;

            // We assume that a range contains a sequence of one-level paragraphs.
            // Otherwise the operation is disabled.
            if (firstBlock == null || lastBlock == null || firstBlock.Parent != lastBlock.Parent ||
                firstBlock.Parent is ListItem && firstBlock.PreviousBlock == null)
            {
                // Either the paragraphs belong to different scopes or first of them has a bullet already.
                // We cannot convert them into bulleted lists.
                return false;
            }

            // Check that all top-level elements of selection are Paragraphs.
            // We do not apply the command to Tables or Sections.
            for (Block block = firstBlock; block != lastBlock && block != null; block = block.NextBlock)
            {
                if (block is Table || block is Section)
                {
                    return false;
                }
            }

            ListItem parentListItem = firstBlock.Parent as ListItem;
            if (parentListItem != null)
            {
                // Paragraphs are inside of ListItem already.

                // Split a current ListItem before each of selected blocks
                Block block = firstBlock;
                while (block != null)
                {
                    Block nextBlock = block == lastBlock ? null : block.ElementEnd.GetAdjacentElement(LogicalDirection.Forward) as Block;

                    Invariant.Assert(block.Parent is ListItem);
                    TextRangeEdit.SplitElement(block.ElementStart);

                    block = nextBlock;
                }
            }
            else
            {
                // Create a list around all paragraphs
                List list = new List();
                list.MarkerStyle = markerStyle;
                list.Apply(firstBlock, lastBlock);

                // Merge with neighboring lists
                //MergeLists(list.ElementEnd);  // start with End to not loose an instance of "list" during merging with the following list
                //MergeLists(list.ElementStart);
            }

            return true;
        }
Esempio n. 35
0
        internal TextMarkerSource(
            TextParagraphProperties textParagraphProperties,
            TextMarkerStyle markerStyle,
            int autoNumberingIndex
            )
        {
            Debug.Assert(markerStyle != TextMarkerStyle.None);

            _textParagraphProperties = textParagraphProperties;
            TextRunProperties defaultRunProperties = _textParagraphProperties.DefaultTextRunProperties;

            PixelsPerDip = defaultRunProperties.PixelsPerDip;
            string symbolString = null;

            if (IsKnownSymbolMarkerStyle(markerStyle))
            {
                switch (markerStyle)
                {
                case TextMarkerStyle.Disc:
                    symbolString = "\x9f"; break;

                case TextMarkerStyle.Circle:
                    symbolString = "\xa1"; break;

                case TextMarkerStyle.Square:
                    symbolString = "\x71"; break;

                case TextMarkerStyle.Box:
                    symbolString = "\xa7"; break;
                }

                Typeface defaultTypeface = defaultRunProperties.Typeface;

                // recreate a new marker run properties based on symbol typeface e.g. Wingding
                _textRunProperties = new GenericTextRunProperties(
                    new Typeface(
                        new FontFamily("Wingdings"),
                        defaultTypeface.Style,
                        defaultTypeface.Weight,
                        defaultTypeface.Stretch
                        ),
                    defaultRunProperties.FontRenderingEmSize,
                    defaultRunProperties.FontHintingEmSize,
                    PixelsPerDip,
                    defaultRunProperties.TextDecorations,
                    defaultRunProperties.ForegroundBrush,
                    defaultRunProperties.BackgroundBrush,
                    defaultRunProperties.BaselineAlignment,
                    CultureMapper.GetSpecificCulture(defaultRunProperties.CultureInfo),
                    null // default number substitution for culture
                    );
            }
            else if (IsKnownIndexMarkerStyle(markerStyle))
            {
                // Internal client code should have already validated this.
                Debug.Assert(autoNumberingIndex > 0);

                _textRunProperties = defaultRunProperties;

                int counter = autoNumberingIndex;

                switch (markerStyle)
                {
                case TextMarkerStyle.Decimal:
                    _characterArray = ConvertNumberToString(counter, false, DecimalNumerics);
                    break;

                case TextMarkerStyle.LowerLatin:
                    _characterArray = ConvertNumberToString(counter, true, LowerLatinNumerics);
                    break;

                case TextMarkerStyle.UpperLatin:
                    _characterArray = ConvertNumberToString(counter, true, UpperLatinNumerics);
                    break;

                case TextMarkerStyle.LowerRoman:
                    symbolString = ConvertNumberToRomanString(counter, false);
                    break;

                case TextMarkerStyle.UpperRoman:
                    symbolString = ConvertNumberToRomanString(counter, true);
                    break;
                }
            }
            else
            {
                Debug.Assert(false, "Invalid marker style");
            }

            if (symbolString != null)
            {
                _characterArray = symbolString.ToCharArray();
            }

            Debug.Assert(_characterArray != null);
        }
Esempio n. 36
0
        // Writes a text representation of a list marker 
        private static void WriteListMarker(StringBuilder textBuffer, TextMarkerStyle listMarkerStyle, int listItemNumber) 
        {
            string markerText = null; 
            Char[] charArray = null;

            switch (listMarkerStyle)
            { 
                case TextMarkerStyle.None :
                    markerText = ""; 
                    break; 
                case TextMarkerStyle.Disc :
                    markerText = "\x2022"; // Bullet // not a "\x9f"; 
                    break;
                case TextMarkerStyle.Circle :
                    markerText = "\x25CB"; // White Circle // not a "\xa1";
                    break; 
                case TextMarkerStyle.Square :
                    markerText = "\x25A1"; // White Box // not a "\x71"; 
                    break; 
                case TextMarkerStyle.Box :
                    markerText = "\x25A0"; // Black Box // not a "\xa7"; 
                    break;

                case TextMarkerStyle.Decimal:
                    charArray = ConvertNumberToString(listItemNumber, false, DecimalNumerics); 
                    break;
 
                case TextMarkerStyle.LowerLatin: 
                    charArray = ConvertNumberToString(listItemNumber, true, LowerLatinNumerics);
                    break; 

                case TextMarkerStyle.UpperLatin:
                    charArray = ConvertNumberToString(listItemNumber, true, UpperLatinNumerics);
                    break; 

                case TextMarkerStyle.LowerRoman: 
                    markerText = ConvertNumberToRomanString(listItemNumber, false); 
                    break;
 
                case TextMarkerStyle.UpperRoman:
                    markerText = ConvertNumberToRomanString(listItemNumber, true);
                    break;
            } 

            if (markerText != null) 
            { 
                textBuffer.Append(markerText);
            } 
            else if (charArray != null)
            {
                textBuffer.Append(charArray, 0, charArray.Length);
            } 
            textBuffer.Append('\t');
        } 
 public ListDeserializeStrategy(TextMarkerStyle markerStyle)
 {
     _markerStyle = markerStyle;
 }
        public void OpenDocxFile(string fileName)
        {
            XElement wordDoc = null;

            try
            {
                Package package = Package.Open(fileName);
                Uri documentUri = new Uri("/word/document.xml", UriKind.Relative);
                PackagePart documentPart = package.GetPart(documentUri);
                wordDoc = XElement.Load(new StreamReader(documentPart.GetStream()));
            }
            catch (Exception)
            {
                this.rtbDocument.Document.Blocks.Add(new Paragraph(new Run("Cannot open file!")));
                return;
            }

            XNamespace w = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";

            var paragraphs = from p in wordDoc.Descendants(w + "p")
                             select p;
            foreach (var p in paragraphs)
            {
                var style = from s in p.Descendants(w + "rPr")
                            select s;

                var parStyle = from s in p.Descendants(w + "pPr")
                               select s;

                var font = (from f in style.Descendants(w + "rFonts")
                            select f.FirstAttribute).FirstOrDefault();

                var size = (from s in style.Descendants(w + "sz")
                            select s.FirstAttribute).FirstOrDefault();

                var rgbColor = (from c in style.Descendants(w + "color")
                             select c.FirstAttribute).FirstOrDefault();

                var bold = (from b in style.Descendants(w + "b")
                           select b).FirstOrDefault();

                var italic = (from i in style.Descendants(w + "i")
                             select i).FirstOrDefault();

                var underline = (from u in style.Descendants(w + "u")
                                select u).FirstOrDefault();

                var alignment = (from a in parStyle.Descendants(w + "jc")
                                 select a).FirstOrDefault();

                var textElements = from t in p.Descendants(w + "t")
                                   select t;

                var list = (from l in parStyle.Descendants(w + "numPr")
                           select l).FirstOrDefault();

                StringBuilder text = new StringBuilder();
                foreach (var element in textElements)
                {
                    text.Append(element.Value);
                }

                Paragraph par = new Paragraph();
                Run run = new Run(text.ToString());

                List items = new List();
                if (list != null)
                {
                    //List items = new List();
                    items.ListItems.Add(new ListItem(par));
                    var markerStyleElement = (from l in list.Descendants(w + "numId")
                                       select l).FirstOrDefault();

                    TextMarkerStyle markerStyle = new TextMarkerStyle();
                    if(markerStyleElement != null)
                    {
                        int value = int.Parse(markerStyleElement.Attribute(w + "val").Value);
                        switch (value)
                        {
                            case 1:
                                markerStyle = TextMarkerStyle.Disc;
                                break;
                            case 2:
                                markerStyle = TextMarkerStyle.Decimal;
                                break;
                        }
                    }

                    items.MarkerStyle = markerStyle;
                }

                if(font != null)
                {
                    FontFamilyConverter converter = new FontFamilyConverter();
                    run.FontFamily = (FontFamily) converter.ConvertFrom(font.Value);
                }

                if(size != null)
                {
                    run.FontSize = double.Parse(size.Value);
                }

                if(rgbColor != null)
                {
                    Color color = ConvertRgbToColor(rgbColor.Value);
                    run.Foreground = new SolidColorBrush(color);
                }

                if(bold != null)
                {
                    if (bold.Attribute(w + "val") != null)
                    {
                        if (bold.Attribute(w + "val").Value == "off")
                        {
                            run.FontWeight = FontWeights.Normal;
                        }
                        else
                        {
                            run.FontWeight = FontWeights.Bold;
                        }
                    }
                    else
                    {
                        run.FontWeight = FontWeights.Bold;
                    }
                }

                if(italic != null)
                {
                    if (italic.Attribute(w + "val") != null)
                    {
                        if (italic.Attribute(w + "val").Value == "off")
                        {
                            run.FontStyle = FontStyles.Normal;
                        }
                        else
                        {
                            run.FontStyle = FontStyles.Italic;
                        }
                    }
                    else
                    {
                        run.FontStyle = FontStyles.Italic;
                    }
                }

                if(underline != null)
                {
                    run.TextDecorations.Add(TextDecorations.Underline);
                }

                if(alignment != null)
                {
                    TextAlignment textAlignment = new TextAlignment();
                    string value = alignment.Attribute(w + "val").Value;
                    switch (value)
                    {
                        case "left":
                            textAlignment = TextAlignment.Left;
                            break;

                        case "center":
                            textAlignment = TextAlignment.Center;
                            break;

                        case "right":
                            textAlignment = TextAlignment.Right;
                            break;

                        case "justify":
                            textAlignment = TextAlignment.Justify;
                            break;
                    }

                    par.TextAlignment = textAlignment;
                }
                else
                {
                    par.TextAlignment = TextAlignment.Left;
                }

                par.Inlines.Add(run);
                if(list != null)
                {
                    this.rtbDocument.Document.Blocks.Add(items);
                }
                else
                {
                    this.rtbDocument.Document.Blocks.Add(par);
                }
            }
        }
Esempio n. 39
0
        private object UpdateToolbarSelection(object args)
        {
            try
            {
                TextSelection selText = this._TextBox.Selection;

                object value;
                //Get the style for the current selection.
                //  - Font size.
                value = selText.GetPropertyValue(TextElement.FontSizeProperty);
                this._toolSize.Text = (value == DependencyProperty.UnsetValue) ? "" : value.ToString();
                // - Font typeface.
                value = selText.GetPropertyValue(TextElement.FontFamilyProperty);
                if (value != DependencyProperty.UnsetValue)
                {
                    if (this._toolFont.Items.Contains((FontFamily)value))
                    {
                        this._toolFont.SelectedIndex = this._toolFont.Items.IndexOf(value);
                    }
                    else
                    {
                        this._toolFont.Text = ((FontFamily)value).Source;
                    }
                }
                else
                {
                    this._toolFont.Text = "";
                }
                // - Font weight. (Bold)
                value = selText.GetPropertyValue(TextElement.FontWeightProperty);
                this._toolBold.IsChecked = (value == DependencyProperty.UnsetValue) ? false : ((FontWeight)value != FontWeights.Normal);
                // - Font Style. (Italic)
                value = selText.GetPropertyValue(TextElement.FontStyleProperty);
                this._toolItalic.IsChecked = (value == DependencyProperty.UnsetValue) ? false : ((FontStyle)value != FontStyles.Normal);
                // - Font underline.
                value = selText.GetPropertyValue(Inline.TextDecorationsProperty);
                bool isUnder = false;
                if (value != DependencyProperty.UnsetValue)
                {
                    foreach (TextDecoration text in (TextDecorationCollection)value)
                    {
                        if (text.Location == TextDecorationLocation.Underline)
                        {
                            isUnder = true;
                        }
                    }
                }
                this._toolUnderline.IsChecked = isUnder;
                // - Font alignment
                value = selText.GetPropertyValue(Paragraph.TextAlignmentProperty);
                this._toolJusLeft.IsChecked   = (value == DependencyProperty.UnsetValue) ? true : (TextAlignment)value == TextAlignment.Left;
                this._toolJusCenter.IsChecked = (value == DependencyProperty.UnsetValue) ? false : (TextAlignment)value == TextAlignment.Center;
                this._toolJusRight.IsChecked  = (value == DependencyProperty.UnsetValue) ? false : (TextAlignment)value == TextAlignment.Right;
                // - Marker # Numbering
                Paragraph startParagraph = selText.Start.Paragraph;
                Paragraph endParagraph   = selText.End.Paragraph;
                if (startParagraph != null && endParagraph != null &&
                    (startParagraph.Parent is ListItem) && (endParagraph.Parent is ListItem) &&
                    ((ListItem)startParagraph.Parent).List == ((ListItem)endParagraph.Parent).List)
                {
                    TextMarkerStyle markerStyle = ((ListItem)startParagraph.Parent).List.MarkerStyle;
                    this._toolBullet.IsChecked = (markerStyle == TextMarkerStyle.Disc ||
                                                  markerStyle == TextMarkerStyle.Circle ||
                                                  markerStyle == TextMarkerStyle.Square ||
                                                  markerStyle == TextMarkerStyle.Box);
                    this._toolNumber.IsChecked = (markerStyle == TextMarkerStyle.LowerRoman ||
                                                  markerStyle == TextMarkerStyle.UpperRoman ||
                                                  markerStyle == TextMarkerStyle.LowerLatin ||
                                                  markerStyle == TextMarkerStyle.UpperLatin ||
                                                  markerStyle == TextMarkerStyle.Decimal);
                }
                else
                {
                    this._toolBullet.IsChecked = false;
                    this._toolNumber.IsChecked = false;
                }
            }
            finally
            {
                this.updSelectionProcessing = false;
            }
            return(null);
        }
Esempio n. 40
0
 private static bool IsKnownIndexMarkerStyle(TextMarkerStyle markerStyle)
 {
     return (
             markerStyle == TextMarkerStyle.Decimal
         || markerStyle == TextMarkerStyle.LowerLatin
         || markerStyle == TextMarkerStyle.UpperLatin
         || markerStyle == TextMarkerStyle.LowerRoman
         || markerStyle == TextMarkerStyle.UpperRoman
         );
 }