Exemple #1
0
        private static void subscript(RichTextEditor editor)
        {
            if (editor == null)
            {
                return;
            }

            RichTextBox richTextBox = editor.RichTextBox;

            if (richTextBox == null || richTextBox.Selection == null)
            {
                return;
            }

            var currentAlignment = richTextBox.Selection.GetPropertyValue(Inline.BaselineAlignmentProperty);

            if (currentAlignment == DependencyProperty.UnsetValue)
            {
                return;
            }

            BaselineAlignment newAlignment = ((BaselineAlignment)currentAlignment == BaselineAlignment.Subscript) ? BaselineAlignment.Baseline : BaselineAlignment.Subscript;

            richTextBox.Selection.ApplyPropertyValue(Inline.BaselineAlignmentProperty, newAlignment);
        }
        internal override NativeElement ToNative(NativeElement element)
        {
            var native = EnsureDerived <NativeTextBlock>(element);

            if (native == null)
            {
#if __ANDROID__
                native = new NativeTextBlock(Rect.ToNative(), Font.ToNative(), Baseline);
#elif __IOS__
                native          = new NativeTextBlock(Rect.ToNative(), Font.ToNative());
                native.Baseline = (ushort)Baseline;
#elif WINDOWS_PHONE_APP
                native          = new NativeTextBlock();
                native.Font     = Font.ToNative();
                native.Baseline = Baseline;
#endif
            }
            native.AutoWidth         = AutoWidth;
            native.BaselineAlignment = BaselineAlignment.ToNative();
            if (Color != BandColor.Empty)
            {
                native.Color = Color.ToNative();
            }
            native.ColorSource = ColorSource.ToNative();
            return(base.ToNative(native));
        }
        public GenericTextRunProperties(
            Typeface typeface,
            double size,
            double hintingSize,
            TextDecorationCollection textDecorations,
            Brush forgroundBrush,
            Brush backgroundBrush,
            BaselineAlignment baselineAlignment,
            TextEffectCollection textEffects,
            CultureInfo culture)
        {
            if (typeface == null)
                throw new ArgumentNullException("typeface");

            ValidateCulture(culture);

            _typeface = typeface;
            _emSize = size;
            _emHintingSize = hintingSize;
            _textDecorations = textDecorations;
            _foregroundBrush = forgroundBrush;
            _backgroundBrush = backgroundBrush;
            _baselineAlignment = baselineAlignment;
            _textEffects = textEffects;
            _culture = culture;
        }
        private void supperScriptButton_Click(object sender, RoutedEventArgs e)
        {
            var currentAlignment           = richTextBox.Selection.GetPropertyValue(Inline.BaselineAlignmentProperty);
            BaselineAlignment newAlignment = ((BaselineAlignment)currentAlignment == BaselineAlignment.Superscript) ? BaselineAlignment.Baseline : BaselineAlignment.Superscript;

            richTextBox.Selection.ApplyPropertyValue(Inline.BaselineAlignmentProperty, newAlignment);
        }
Exemple #5
0
 /// <summary>
 /// Creates a new VisualLineElementTextRunProperties instance that copies its values
 /// from the specified <paramref name="textRunProperties"/>.
 /// For the <see cref="TextDecorations"/> and <see cref="TextEffects"/> collections, deep copies
 /// are created if those collections are not frozen.
 /// </summary>
 public VisualLineElementTextRunProperties(TextRunProperties textRunProperties)
 {
     if (textRunProperties == null)
     {
         throw new ArgumentNullException("textRunProperties");
     }
     backgroundBrush     = textRunProperties.BackgroundBrush;
     baselineAlignment   = textRunProperties.BaselineAlignment;
     cultureInfo         = textRunProperties.CultureInfo;
     fontHintingEmSize   = textRunProperties.FontHintingEmSize;
     fontRenderingEmSize = textRunProperties.FontRenderingEmSize;
     foregroundBrush     = textRunProperties.ForegroundBrush;
     typeface            = textRunProperties.Typeface;
     textDecorations     = textRunProperties.TextDecorations;
     if (textDecorations != null && !textDecorations.IsFrozen)
     {
         textDecorations = textDecorations.Clone();
     }
     textEffects = textRunProperties.TextEffects;
     if (textEffects != null && !textEffects.IsFrozen)
     {
         textEffects = textEffects.Clone();
     }
     typographyProperties = textRunProperties.TypographyProperties;
     numberSubstitution   = textRunProperties.NumberSubstitution;
 }
Exemple #6
0
        public void ToggleSuperscript()
        {
            var currentAlignment           = this.Selection.GetPropertyValue(Inline.BaselineAlignmentProperty);
            BaselineAlignment newAlignment = ((BaselineAlignment)currentAlignment == BaselineAlignment.Superscript) ? BaselineAlignment.Baseline : BaselineAlignment.Superscript;

            this.Selection.ApplyPropertyValue(Inline.BaselineAlignmentProperty, newAlignment);
        }
Exemple #7
0
        public GenericTextRunProperties(
            Typeface typeface,
            double pixelsPerDip,
            double size,
            double hintingSize,
            TextDecorationCollection textDecorations,
            Brush foregroundBrush,
            Brush backgroundBrush,
            BaselineAlignment baselineAlignment,
            CultureInfo culture)
        {
            if (typeface == null)
            {
                throw new ArgumentNullException("typeface");
            }

            ValidateCulture(culture);

            PixelsPerDip       = pixelsPerDip;
            _typeface          = typeface;
            _emSize            = size;
            _emHintingSize     = hintingSize;
            _textDecorations   = textDecorations;
            _foregroundBrush   = foregroundBrush;
            _backgroundBrush   = backgroundBrush;
            _baselineAlignment = BaselineAlignment;
            _culture           = culture;
        }
Exemple #8
0
        //
        // ToolStripButton Superscript wurde gedrückt
        // (läßt sich auch durch Command in XAML machen.
        // Damit dann aber ein wirkliches Superscript angezeigt wird, muß die benutzte Font OpenType sein:
        // http://msdn.microsoft.com/en-us/library/ms745109.aspx#variants
        // Um auch für alle anderen Schriftarten Superscript zu realisieren, läßt sich stattdessen die Baseline Eigenschaft verändern)
        //
        private void ToolStripButtonSuperscript_Click(object sender, RoutedEventArgs e)
        {
            var currentAlignment = RichTextControl.Selection.GetPropertyValue(Inline.BaselineAlignmentProperty);

            BaselineAlignment newAlignment = ((BaselineAlignment)currentAlignment == BaselineAlignment.Superscript) ? BaselineAlignment.Baseline : BaselineAlignment.Superscript;

            RichTextControl.Selection.ApplyPropertyValue(Inline.BaselineAlignmentProperty, newAlignment);
        }
        private void btnSuperscript_Click(object sender, RoutedEventArgs e)
        {
            var currentAlignment = rtbDocument.Selection.GetPropertyValue(Inline.BaselineAlignmentProperty);

            BaselineAlignment newAlignment = ((BaselineAlignment)currentAlignment == BaselineAlignment.Superscript)
                                                 ? BaselineAlignment.Baseline
                                                 : BaselineAlignment.Superscript;

            rtbDocument.Selection.ApplyPropertyValue(Inline.BaselineAlignmentProperty, newAlignment);
        }
 public JapaneseTextRunProperties(Typeface typeface, double size, double hintingSize, TextDecorationCollection textDecorations, Brush forgroundBrush, Brush backgroundBrush, BaselineAlignment baselineAlignment, CultureInfo culture)
 {
     this._typeface          = typeface;
     this._emSize            = size;
     this._emHintingSize     = hintingSize;
     this._textDecorations   = textDecorations;
     this._foregroundBrush   = forgroundBrush;
     this._backgroundBrush   = backgroundBrush;
     this._baselineAlignment = baselineAlignment;
     this._culture           = culture;
 }
Exemple #11
0
        //
        // ToolStripButton Superscript wurde gedrückt
        // (läßt sich auch durch Command in XAML machen.
        // Damit dann aber ein wirkliches Superscript angezeigt wird, muß die benutzte Font OpenType sein:
        // http://msdn.microsoft.com/en-us/library/ms745109.aspx#variants
        // Um auch für alle anderen Schriftarten Superscript zu realisieren, läßt sich stattdessen die Baseline Eigenschaft verändern)
        //
        private void ToolStripButtonSuperscript_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var currentAlignment = RichTextControl.Selection.GetPropertyValue(Inline.BaselineAlignmentProperty);

                BaselineAlignment newAlignment = ((BaselineAlignment)currentAlignment == BaselineAlignment.Superscript) ? BaselineAlignment.Baseline : BaselineAlignment.Superscript;
                RichTextControl.Selection.ApplyPropertyValue(Inline.BaselineAlignmentProperty, newAlignment);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n\r\n" + ex.StackTrace, ex.GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error); }
        }
    private void SuperScriptTextCommandHandler(FrameworkElement obj)
    {
        var rtb = obj as RichTextBox;

        if (rtb != null)
        {
            var currentAlignment           = rtb.Selection.GetPropertyValue(Inline.BaselineAlignmentProperty);
            BaselineAlignment newAlignment = ((BaselineAlignment)currentAlignment == BaselineAlignment.Superscript) ? BaselineAlignment.Baseline : BaselineAlignment.Superscript;
            rtb.Selection.ApplyPropertyValue(Inline.BaselineAlignmentProperty, newAlignment);
        }
    }
Exemple #13
0
        private void InitializeUI()
        {
            this.stylesInitializing = true;
            StyleDefinition styleDefinition = this.radRichTextBox1.CurrentEditingStyle;

            this.InitializeCurrentFontStyles(styleDefinition);
            this.InitializeCurrentParagraphStyles(styleDefinition);

            BaselineAlignment baselineAlignment = (BaselineAlignment)styleDefinition.GetPropertyValue(Span.BaselineAlignmentProperty);

            this.stylesInitializing = false;
        }
 public GenericTextRunProperties(FontRendering newRender)
 {
     _typeface = newRender.Typeface;
     _emSize = newRender.FontSize;
     _emHintingSize = newRender.FontSize;
     _textDecorations = newRender.TextDecorations;
     _foregroundBrush = newRender.ForegroundBrush;
     _backgroundBrush = newRender.BackgroundBrush;
     _baselineAlignment = BaselineAlignment.Baseline;
     _textEffects = newRender.TextEffects;
     _culture = CultureInfo.CurrentUICulture;
 }
 /// <inheritdoc />
 public TextRunProperties1(Brush backgroundBrush, BaselineAlignment baselineAlignment, CultureInfo cultureInfo, double fontHintingEmSize, double fontRenderingEmSize, Brush foregroundBrush, TextDecorationCollection textDecorations, TextEffectCollection textEffects, Typeface typeface)
 {
     _backgroundBrush     = backgroundBrush;
     _baselineAlignment   = baselineAlignment;
     _cultureInfo         = cultureInfo;
     _fontHintingEmSize   = fontHintingEmSize;
     _fontRenderingEmSize = fontRenderingEmSize;
     _foregroundBrush     = foregroundBrush;
     _textDecorations     = textDecorations;
     _textEffects         = textEffects;
     _typeface            = typeface;
 }
 public perFormattedTextItem(string text, bool isBold, bool isUnderline, bool isItalic, double fontSize, FontFamily fontFamily, Brush foreground, Brush background, BaselineAlignment baselineAlignment)
 {
     Content           = text;
     IsBold            = isBold;
     IsUnderline       = isUnderline;
     IsItalic          = isItalic;
     FontSize          = fontSize;
     FontFamily        = fontFamily;
     Foreground        = foreground;
     Background        = background;
     BaselineAlignment = baselineAlignment;
 }
Exemple #17
0
 public GenericTextRunProperties(Typeface typeface, double fontRenderingEmSize = DefaultFontRenderingEmSize,
                                 TextDecorationCollection?textDecorations      = null, IBrush?foregroundBrush = null,
                                 IBrush?backgroundBrush  = null, BaselineAlignment baselineAlignment          = BaselineAlignment.Baseline,
                                 CultureInfo?cultureInfo = null)
 {
     Typeface            = typeface;
     FontRenderingEmSize = fontRenderingEmSize;
     TextDecorations     = textDecorations;
     ForegroundBrush     = foregroundBrush;
     BackgroundBrush     = backgroundBrush;
     BaselineAlignment   = baselineAlignment;
     CultureInfo         = cultureInfo;
 }
        /// <summary>
        /// 根据当前选中文本的上标或下标状态设置或取消上下标,同时同步按钮状态
        /// </summary>
        /// <param name="value"></param>
        private void SetSuperscriptOrSubscript(BaselineAlignment value)
        {
            BaselineAlignment curValue = rtfManager.GetSelectionBaselineAlignment();

            if (curValue != value)
            {
                rtfManager.SetSelectionBaselineAlignment(value);
            }
            else
            {
                rtfManager.SetSelectionBaselineAlignment(BaselineAlignment.Baseline);
            }
        }
Exemple #19
0
        //-------------------------------------------------------------------
        //
        // Private Methods
        //
        //-------------------------------------------------------------------

        #region Private Methods
        private static bool IsValidBaselineAlignment(object o)
        {
            BaselineAlignment value = (BaselineAlignment)o;

            return(value == BaselineAlignment.Baseline ||
                   value == BaselineAlignment.Bottom ||
                   value == BaselineAlignment.Center ||
                   value == BaselineAlignment.Subscript ||
                   value == BaselineAlignment.Superscript ||
                   value == BaselineAlignment.TextBottom ||
                   value == BaselineAlignment.TextTop ||
                   value == BaselineAlignment.Top);
        }
Exemple #20
0
        // Token: 0x06006619 RID: 26137 RVA: 0x001CB564 File Offset: 0x001C9764
        internal static BaselineAlignment GetBaselineAlignment(DependencyObject element)
        {
            Inline            inline = element as Inline;
            BaselineAlignment result = (inline != null) ? inline.BaselineAlignment : BaselineAlignment.Baseline;

            while (inline != null && DynamicPropertyReader.BaselineAlignmentIsDefault(inline))
            {
                inline = (inline.Parent as Inline);
            }
            if (inline != null)
            {
                result = inline.BaselineAlignment;
            }
            return(result);
        }
        /// <summary>
        /// 根据当前选中文本的上标或下标状态设置或取消上下标,同时同步按钮状态
        /// </summary>
        /// <param name="value"></param>
        private void SetSuperscriptOrSubscript(BaselineAlignment value, ToggleButton btn)
        {
            BaselineAlignment curValue = rtfManager.GetSelectionBaselineAlignment();

            if (curValue != value)
            {
                rtfManager.SetSelectionBaselineAlignment(value);
                btn.IsChecked = true;
            }
            else
            {
                rtfManager.SetSelectionBaselineAlignment(BaselineAlignment.Baseline);
                btn.IsChecked = false;
            }
        }
Exemple #22
0
        private void InitializeUI()
        {
            this.stylesInitializing = true;
            StyleDefinition styleDefinition = this.radRichTextBox1.CurrentEditingStyle;

            this.InitializeCurrentFontStyles(styleDefinition);
            this.InitializeCurrentParagraphStyles(styleDefinition);

            BaselineAlignment baselineAlignment = (BaselineAlignment)styleDefinition.GetPropertyValue(Span.BaselineAlignmentProperty);

            this.subscriptButtonElement.ToggleState   = baselineAlignment == BaselineAlignment.Subscript ? ToggleState.On : ToggleState.Off;
            this.superscriptButtonElement.ToggleState = baselineAlignment == BaselineAlignment.Superscript ? ToggleState.On : ToggleState.Off;

            this.stylesInitializing = false;
        }
Exemple #23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="newRender"></param>
 /// <exception cref="ArgumentNullException"></exception>
 public GenericTextRunProperties([NotNull] FontRendering newRender)
 {
     if (newRender == null)
     {
         throw new ArgumentNullException(nameof(newRender));
     }
     _typeface          = newRender.Typeface;
     _emSize            = newRender.FontSize;
     _emHintingSize     = newRender.FontSize;
     _textDecorations   = newRender.TextDecorations;
     _foregroundBrush   = newRender.TextColor;
     _backgroundBrush   = null;
     _baselineAlignment = BaselineAlignment.Baseline;
     _culture           = CultureInfo.CurrentUICulture;
 }
Exemple #24
0
        // ------------------------------------------------------------------
        // GetBaselineAlignment
        // ------------------------------------------------------------------
        internal static BaselineAlignment GetBaselineAlignment(DependencyObject element)
        {
            Inline            i = element as Inline;
            BaselineAlignment baselineAlignment = (i != null) ? i.BaselineAlignment : BaselineAlignment.Baseline;

            // Walk up the tree to check if it inherits BaselineAlignment from a parent
            while (i != null && BaselineAlignmentIsDefault(i))
            {
                i = i.Parent as Inline;
            }

            if (i != null)
            {
                // Found an Inline with non-default baseline alignment
                baselineAlignment = i.BaselineAlignment;
            }
            return(baselineAlignment);
        }
		/// <summary>
		/// Creates a new VisualLineElementTextRunProperties instance that copies its values
		/// from the specified <paramref name="textRunProperties"/>.
		/// For the <see cref="TextDecorations"/> and <see cref="TextEffects"/> collections, deep copies
		/// are created if those collections are not frozen.
		/// </summary>
		public VisualLineElementTextRunProperties(TextRunProperties textRunProperties)
		{
			if (textRunProperties == null)
				throw new ArgumentNullException("textRunProperties");
			backgroundBrush = textRunProperties.BackgroundBrush;
			baselineAlignment = textRunProperties.BaselineAlignment;
			cultureInfo = textRunProperties.CultureInfo;
			fontHintingEmSize = textRunProperties.FontHintingEmSize;
			fontRenderingEmSize = textRunProperties.FontRenderingEmSize;
			foregroundBrush = textRunProperties.ForegroundBrush;
			typeface = textRunProperties.Typeface;
			textDecorations = textRunProperties.TextDecorations;
			if (textDecorations != null && !textDecorations.IsFrozen) {
				textDecorations = textDecorations.Clone();
			}
			textEffects = textRunProperties.TextEffects;
			if (textEffects != null && !textEffects.IsFrozen) {
				textEffects = textEffects.Clone();
			}
		}
Exemple #26
0
        private void ToggleBaselineAlignment(BaselineAlignment alignment)
        {
            object currentValue    = richTextBox_Main.Selection.GetPropertyValue(Inline.BaselineAlignmentProperty);
            object currentTextSize = richTextBox_Main.Selection.GetPropertyValue(TextElement.FontSizeProperty);

            BaselineAlignment newAlignment       = alignment;
            double            fontSizeMultiplier = 0.75d;

            if ((BaselineAlignment)currentValue == alignment)
            {
                newAlignment       = BaselineAlignment.Baseline;
                fontSizeMultiplier = 1 / 0.75d;
            }

            richTextBox_Main?.Selection.ApplyPropertyValue(Inline.BaselineAlignmentProperty, newAlignment);
            if (currentTextSize != DependencyProperty.UnsetValue)
            {
                richTextBox_Main?.Selection.ApplyPropertyValue(TextElement.FontSizeProperty, (double)currentTextSize * fontSizeMultiplier);
            }
        }
Exemple #27
0
 /// <summary>
 /// Constructing TextRunProperties
 /// </summary>
 /// <param name="typeface">typeface</param>
 /// <param name="size">text size</param>
 /// <param name="hintingSize">text size for Truetype hinting program</param>
 /// <param name="culture">text culture info</param>
 /// <param name="textDecorations">TextDecorations </param>
 /// <param name="foregroundBrush">text foreground brush</param>
 /// <param name="backgroundBrush">highlight background brush</param>
 /// <param name="baselineAlignment">text vertical alignment to its container</param>
 /// <param name="substitution">number substitution behavior to apply to the text; can be null,
 /// in which case the default number substitution method for the text culture is used</param>
 public GenericTextRunProperties(
     Typeface typeface,
     double size,
     double hintingSize,
     TextDecorationCollection textDecorations,
     Brush foregroundBrush,
     Brush backgroundBrush,
     BaselineAlignment baselineAlignment,
     CultureInfo culture,
     NumberSubstitution substitution
     )
 {
     _typeface           = typeface;
     _emSize             = size;
     _emHintingSize      = hintingSize;
     _textDecorations    = textDecorations;
     _foregroundBrush    = foregroundBrush;
     _backgroundBrush    = backgroundBrush;
     _baselineAlignment  = baselineAlignment;
     _culture            = culture;
     _numberSubstitution = substitution;
 }
 /// <summary>
 /// Constructing TextRunProperties
 /// </summary>
 /// <param name="typeface">typeface</param> 
 /// <param name="size">text size</param>
 /// <param name="hintingSize">text size for Truetype hinting program</param> 
 /// <param name="culture">text culture info</param> 
 /// <param name="textDecorations">TextDecorations </param>
 /// <param name="foregroundBrush">text foreground brush</param> 
 /// <param name="backgroundBrush">highlight background brush</param>
 /// <param name="baselineAlignment">text vertical alignment to its container</param>
 /// <param name="substitution">number substitution behavior to apply to the text; can be null,
 /// in which case the default number substitution method for the text culture is used</param> 
 public GenericTextRunProperties(
     Typeface                 typeface, 
     double                   size, 
     double                   hintingSize,
     TextDecorationCollection textDecorations, 
     Brush                    foregroundBrush,
     Brush                    backgroundBrush,
     BaselineAlignment        baselineAlignment,
     CultureInfo              culture, 
     NumberSubstitution       substitution
 ) 
 { 
      _typeface = typeface;
     _emSize = size; 
     _emHintingSize = hintingSize;
     _textDecorations = textDecorations;
     _foregroundBrush = foregroundBrush;
     _backgroundBrush = backgroundBrush; 
     _baselineAlignment = baselineAlignment;
     _culture = culture; 
     _numberSubstitution = substitution; 
 }
Exemple #29
0
        private static void AddImage(TextBlock textBlock, string imageUrl, double lineHeight = 1.2, BaselineAlignment alignment = BaselineAlignment.Center)
        {
            if (File.Exists(imageUrl))
            {
                Image imgMessage = new Image();
                imgMessage.Height = textBlock.FontSize * lineHeight;
                BitmapImage bi = new BitmapImage();

                bi.BeginInit();
                bi.UriSource = new Uri(imageUrl, UriKind.RelativeOrAbsolute);
                bi.EndInit();

                imgMessage.Source = bi;
                InlineUIContainer iuc = new InlineUIContainer(imgMessage);
                iuc.BaselineAlignment = alignment;
                textBlock.Inlines.Add(iuc);
            }
        }
		public void SetBaselineAlignment(BaselineAlignment baseLineAlignment) 
		{ 
			//TODO: VisualLineElementTextRunProperties.SetBaselineAlignment()
			throw new NotImplementedException();
		}
Exemple #31
0
 /// <summary>
 /// Sets the <see cref="BaselineAlignment"/>.
 /// </summary>
 public void SetBaselineAlignment(BaselineAlignment value)
 {
     baselineAlignment = value;
 }
 public void SetSelectionBaselineAlignment(BaselineAlignment value)
 {
     _rtf.Selection.ApplyPropertyValue(Inline.BaselineAlignmentProperty, value);
 }
Exemple #33
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="text"></param>
 /// <param name="style"></param>
 public TextComponent(string text, BaselineAlignment style = BaselineAlignment.Baseline)
 {
     Text  = text;
     Style = style;
 }
 /// <summary>
 /// Sets the <see cref="BaselineAlignment"/>.
 /// </summary>
 public void SetBaselineAlignment(BaselineAlignment value)
 {
     baselineAlignment = value;
 }
 public void SetSelectionBaselineAlignment(BaselineAlignment value)
 {
     _rtf.Selection.ApplyPropertyValue(Inline.BaselineAlignmentProperty, value);
 }
Exemple #36
0
        /// <summary>
        /// Sets the page content based on existing material.
        /// </summary>
        public void ConstructPage()
        {
            gui = new PgEntryGuiView();

            #region Entry name
            //Sets the entry name.
            if (string.IsNullOrWhiteSpace((string)Entry.GetData("name")))
            {
                gui.TxtblkEntryName.Text = GlobalStrings.NameUntitled;
            }
            else
            {
                gui.TxtblkEntryName.Text = (string)Entry.GetData("name");
            }
            #endregion

            //Gets template details.
            var    template      = project.GetCollectionTemplate(project.GetEntryCollection(entry));
            bool   tCenterImages = (bool)template.GetData("centerImages");
            var    tTwoColumns   = (bool)template.GetData("twoColumns");
            string tFontFamilies = (string)template.GetData("fontFamilies");

            gui.TxtblkEntryName.FontFamily = new FontFamily(tFontFamilies);

            var tContentColor = new SolidColorBrush(Color.FromRgb(
                                                        (byte)template.GetData("contentColorR"),
                                                        (byte)template.GetData("contentColorG"),
                                                        (byte)template.GetData("contentColorB")));

            var tTitleColor = new SolidColorBrush(Color.FromRgb(
                                                      (byte)template.GetData("headerColorR"),
                                                      (byte)template.GetData("headerColorG"),
                                                      (byte)template.GetData("headerColorB")));

            gui.TxtblkEntryName.Foreground = tTitleColor;

            //Adjusts the column widths if two columns are used.
            if (!tTwoColumns)
            {
                gui.RightCol.MaxWidth = 0;
            }

            //Gets entry fields, then sorts them by column order.
            var entryFields = project.GetEntryFields(entry);
            entryFields.OrderBy(new Func <DataItem, int>((a) =>
            {
                return((int)project.GetFieldTemplateField(a).GetData("columnOrder"));
            }));

            //Displays each field for viewing.
            for (int i = 0; i < entryFields.Count; i++)
            {
                //Gets the field and its data.
                var    field           = entryFields[i];
                object fieldData       = field.GetData("data");
                var    templateField   = project.GetFieldTemplateField(entryFields[i]);
                byte   tNumExtraImages = (byte)templateField.GetData("numExtraImages");
                var    tExtraImagePos  = (TemplateImagePos)(int)templateField.GetData("extraImagePos");

                //Gets various data regarding the field.
                var  currField           = entryFields[i];
                var  currTemplateField   = project.GetFieldTemplateField(currField);
                var  templateType        = (TemplateFieldType)(int)currTemplateField.GetData("dataType");
                var  fieldName           = (string)currTemplateField.GetData("name");
                var  tfIsVisible         = (bool)currTemplateField.GetData("isVisible");
                var  tfTitleIsVisible    = (bool)currTemplateField.GetData("isTitleVisible");
                bool displaySingleColumn = (bool)currTemplateField.GetData("displaySingleColumn");

                //Gets the type of data and associated grid position.
                var isFirstColumn = (bool)project.GetItemByGuid(
                    (ulong)currTemplateField.GetData("refGuid")).GetData("isFirstColumn");

                //Skips all 2nd-column fields in a single-column layout.
                if (!tTwoColumns && !isFirstColumn && !displaySingleColumn)
                {
                    continue;
                }

                //Skips fields not to be rendered.
                if (!tfIsVisible)
                {
                    continue;
                }

                //Sets the name of the field.
                TextBlock fieldNameGui = new TextBlock(new Run(fieldName));
                fieldNameGui.FontFamily = new FontFamily(tFontFamilies);
                fieldNameGui.FontWeight = FontWeights.Bold;
                fieldNameGui.Foreground = tContentColor;

                //Centers the field name to match centered image fields.
                if (templateType == TemplateFieldType.EntryImages && tCenterImages)
                {
                    fieldNameGui.HorizontalAlignment = HorizontalAlignment.Center;
                }

                //Creates a container for the whole field.
                StackPanel elementsContainer = new StackPanel();

                //Displays text fields.
                //Text is stored in the binary XamlPackage format.
                if (templateType == TemplateFieldType.Text)
                {
                    RichTextBoxNoMargins fieldDataGui = new RichTextBoxNoMargins();
                    fieldDataGui.Textbox.FontFamily = new FontFamily(tFontFamilies);
                    fieldDataGui.Textbox.Foreground = tContentColor;
                    fieldDataGui.Textbox.Margin     = new Thickness(0, 4, 0, 12);
                    fieldDataGui.Textbox.IsReadOnly = true;

                    //Set thickness since border color changes dynamically.
                    fieldDataGui.Textbox.BorderThickness = new Thickness(0);

                    //Loads the XamlPackage if possible.
                    if (fieldData is byte[])
                    {
                        TextRange txt = new TextRange(
                            fieldDataGui.Textbox.Document.ContentStart,
                            fieldDataGui.Textbox.Document.ContentEnd);

                        using (MemoryStream ms = new MemoryStream((byte[])fieldData))
                        {
                            try
                            {
                                txt.Load(ms, DataFormats.XamlPackage);
                            }
                            catch (ArgumentException) { }
                        }

                        //Does not display empty fields.
                        if (String.IsNullOrWhiteSpace(txt.Text))
                        {
                            continue;
                        }
                    }

                    //Skips rendering for empty strings (given if 0 bytes).
                    else
                    {
                        continue;
                    }

                    //Gets whether the title is visible or not.
                    if (tfTitleIsVisible)
                    {
                        elementsContainer.Children.Add(fieldNameGui);
                        elementsContainer.Children.Add(fieldDataGui);
                    }

                    //Adds the field.
                    else
                    {
                        elementsContainer.Children.Add(fieldDataGui);
                    }
                }

                //Displays text fields.
                //Data is stored as a string.
                if (templateType == TemplateFieldType.Min_Formula ||
                    templateType == TemplateFieldType.Min_Name ||
                    templateType == TemplateFieldType.Min_Group ||
                    templateType == TemplateFieldType.Min_Locality)
                {
                    //Does not display empty text fields.
                    if (String.IsNullOrWhiteSpace((string)fieldData))
                    {
                        continue;
                    }

                    TextBlock fieldDataGui = new TextBlock();
                    fieldDataGui.FontFamily   = new FontFamily(tFontFamilies);
                    fieldDataGui.Foreground   = tContentColor;
                    fieldDataGui.Margin       = new Thickness(2, 4, 2, 12);
                    fieldDataGui.Text         = (string)fieldData;
                    fieldDataGui.TextWrapping = TextWrapping.Wrap;

                    //Parses the appearance of mineral formulas.
                    if (templateType == TemplateFieldType.Min_Formula)
                    {
                        //Gets text, tracks alignment, and makes a run.
                        string            text  = fieldDataGui.Text;
                        BaselineAlignment align = BaselineAlignment.Baseline;
                        Run run = new Run();

                        //Clears text from field.
                        fieldDataGui.Inlines.Clear();

                        //Toggles align to subscript on _ and superscript on ^.
                        for (int j = 0; j < text.Length; j++)
                        {
                            if (text[j] == '_' ||
                                text[j] == '^')
                            {
                                fieldDataGui.Inlines.Add(run);
                                run = new Run();

                                if (text[j] == '_')
                                {
                                    if (align != BaselineAlignment.Subscript)
                                    {
                                        align = BaselineAlignment.Subscript;
                                    }
                                    else
                                    {
                                        align = BaselineAlignment.Baseline;
                                    }
                                }
                                else if (text[j] == '^')
                                {
                                    if (align != BaselineAlignment.Superscript)
                                    {
                                        align = BaselineAlignment.Superscript;
                                    }
                                    else
                                    {
                                        align = BaselineAlignment.Baseline;
                                    }
                                }

                                run.BaselineAlignment = align;
                            }
                            else
                            {
                                run.Text += text[j];
                            }
                        }
                        fieldDataGui.Inlines.Add(run);
                    }

                    //Gets whether the title is visible or not.
                    if (tfTitleIsVisible)
                    {
                        elementsContainer.Children.Add(fieldNameGui);
                    }
                    elementsContainer.Children.Add(fieldDataGui);
                }

                //Displays webpages.
                //Data is stored as a string.
                else if (templateType == TemplateFieldType.Hyperlink)
                {
                    string url = (string)fieldData;

                    //Prepends the scheme to the beginning if necessary.
                    if (!url.StartsWith("http"))
                    {
                        url = "http://" + url;
                    }

                    //Creates the hyperlink only if it's a valid internet url.
                    Uri uriResult;
                    if (Uri.TryCreate(url, UriKind.Absolute, out uriResult) &&
                        (uriResult.Scheme == Uri.UriSchemeHttp ||
                         uriResult.Scheme == Uri.UriSchemeHttps))
                    {
                        //Sets the hyperlink.
                        Hyperlink webpage = new Hyperlink();
                        webpage.Inlines.Add(url);

                        try
                        {
                            webpage.NavigateUri = new Uri((string)fieldData);
                            webpage.Click      += (a, b) =>
                            {
                                System.Diagnostics.Process.Start(webpage.NavigateUri.ToString());
                            };
                        }
                        catch (UriFormatException)
                        {
                            //Don't log navigation errors.
                        }
                        catch (Exception e)
                        {
                            Utils.Log("Hyperlink error: " + e.Message);
                        }

                        //Sets a containing textblock.
                        TextBlock fieldDataGui = new TextBlock(webpage);
                        fieldDataGui.FontFamily   = new FontFamily(tFontFamilies);
                        fieldDataGui.Foreground   = tContentColor;
                        fieldDataGui.Margin       = new Thickness(2, 4, 2, 12);
                        fieldDataGui.MinWidth     = 32;
                        fieldDataGui.TextWrapping = TextWrapping.Wrap;

                        if (tfTitleIsVisible)
                        {
                            elementsContainer.Children.Add(fieldNameGui);
                        }
                        elementsContainer.Children.Add(fieldDataGui);
                    }

                    //Does not display empty or malformed hyperlinks.
                    else
                    {
                        continue;
                    }
                }

                //Displays as a single text field.
                //Data is stored as a 2-element string array.
                else if (templateType == TemplateFieldType.MoneyUSD)
                {
                    //Gets the values of the currency.
                    string[] moneyData    = (string[])fieldData;
                    string   dollarAmount = moneyData[0];
                    string   centsAmount  = moneyData[1];

                    //If no dollars are given, displays a zero.
                    if (String.IsNullOrWhiteSpace(dollarAmount))
                    {
                        dollarAmount = "0";
                    }

                    //If no cents are given, displays a zero.
                    else if (String.IsNullOrWhiteSpace(centsAmount))
                    {
                        centsAmount = "00";
                    }

                    //Sets the textblock to display the money.
                    TextBlock fieldDataGui = new TextBlock();
                    fieldDataGui.FontFamily   = new FontFamily(tFontFamilies);
                    fieldDataGui.Foreground   = tContentColor;
                    fieldDataGui.Margin       = new Thickness(2, 4, 2, 12);
                    fieldDataGui.MinWidth     = 32;
                    fieldDataGui.Text         = "$" + dollarAmount + "." + centsAmount;
                    fieldDataGui.TextWrapping = TextWrapping.Wrap;

                    //Does not display empty currency fields.
                    if (String.IsNullOrWhiteSpace(moneyData[0]) &&
                        String.IsNullOrWhiteSpace(moneyData[1]))
                    {
                        continue;
                    }

                    //Displays the title if intended.
                    if (tfTitleIsVisible)
                    {
                        elementsContainer.Children.Add(fieldNameGui);
                    }

                    //Hides the field if no information was originally given.
                    elementsContainer.Children.Add(fieldDataGui);
                }

                //Displays image-type fields.
                //Data is stored as a string of urls delimited by |.
                else if (templateType == TemplateFieldType.EntryImages ||
                         templateType == TemplateFieldType.Images)
                {
                    List <string> allData           = new List <string>();
                    List <string> loadedUrls        = new List <string>();
                    bool          isAnimated        = false;
                    bool          isMuted           = false;
                    var           extraImagePos     = (TemplateImagePos)(int)currTemplateField.GetData("extraImagePos");
                    var           displayAsCarousel = (bool)currTemplateField.GetData("displayAsCarousel");

                    //Loads the data if it exists, or sets it if empty.
                    if (((string)fieldData) == String.Empty)
                    {
                        allData = new List <string>()
                        {
                            "False", "False", String.Empty
                        };
                    }
                    else
                    {
                        allData = ((string)fieldData).Split('|').ToList();
                    }

                    //Gets non-url data.
                    isAnimated = (allData[0] == "True");
                    isMuted    = (allData[1] == "True");

                    //Gets url data.
                    loadedUrls = allData.GetRange(2, allData.Count - 2);

                    //If no urls are valid, skips the field.
                    if (!loadedUrls.Any((a) => { return(File.Exists(a)); }))
                    {
                        continue;
                    }

                    //Sets up a container for all elements.
                    if (tfTitleIsVisible)
                    {
                        elementsContainer.Children.Add(fieldNameGui);
                    }

                    //Still images that do not rotate and are not movies.
                    if (!isAnimated && !displayAsCarousel)
                    {
                        Grid imagesContainer = new Grid();

                        //Creates an image for each url.
                        for (int j = 0; j < loadedUrls.Count; j++)
                        {
                            ImgThumbnail thumbnail = new ImgThumbnail(loadedUrls[j]);

                            //Sets margins based on orientation.
                            if (tExtraImagePos == TemplateImagePos.Left ||
                                tExtraImagePos == TemplateImagePos.Right)
                            {
                                thumbnail.Margin = new Thickness(4, 2, 12, 2);
                            }
                            else
                            {
                                thumbnail.Margin = new Thickness(2, 4, 2, 12);
                            }

                            //Resizes the image.
                            thumbnail.Loaded += (a, b) =>
                            {
                                if (thumbnail.ActualWidth > 0)
                                {
                                    thumbnail.MaxWidth  = thumbnail.GetSourceWidth();
                                    thumbnail.MaxHeight = thumbnail.GetSourceHeight();

                                    //Limits to 500px. Sets only one dimension
                                    //so the other can adapt automatically.
                                    if (thumbnail.MaxHeight > 500)
                                    {
                                        thumbnail.MaxHeight = 500;
                                    }
                                    else if (thumbnail.MaxWidth > 500)
                                    {
                                        thumbnail.MaxWidth = 500;
                                    }
                                }
                                else
                                {
                                    thumbnail.SetSize(0);
                                }
                            };

                            imagesContainer.Children.Add(thumbnail);

                            //Exits when 1 + number of extra images are displayed.
                            if (j == tNumExtraImages && tNumExtraImages > 0)
                            {
                                break;
                            }
                        }

                        //Reverses element order.
                        if (extraImagePos == TemplateImagePos.Above ||
                            extraImagePos == TemplateImagePos.Left)
                        {
                            List <UIElement> elements = new List <UIElement>();
                            for (int k = 0; k < imagesContainer.Children.Count; k++)
                            {
                                elements.Add(imagesContainer.Children[k]);
                            }
                            elements.Reverse();
                            imagesContainer.Children.Clear();
                            for (int k = 0; k < elements.Count; k++)
                            {
                                imagesContainer.Children.Add(elements[k]);
                            }
                        }

                        //Sets position of elements.
                        for (int k = 0; k < imagesContainer.Children.Count; k++)
                        {
                            var item = imagesContainer.Children[k];

                            if (extraImagePos == TemplateImagePos.Left ||
                                extraImagePos == TemplateImagePos.Right)
                            {
                                Grid.SetColumn(item, imagesContainer.ColumnDefinitions.Count);
                                imagesContainer.ColumnDefinitions.Add(new ColumnDefinition());
                            }
                            else
                            {
                                Grid.SetRow(item, imagesContainer.RowDefinitions.Count);
                                imagesContainer.RowDefinitions.Add(new RowDefinition());
                            }
                        }

                        ScrollViewer horzScroller = new ScrollViewer();
                        horzScroller.VerticalScrollBarVisibility   = ScrollBarVisibility.Disabled;
                        horzScroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
                        horzScroller.Content = imagesContainer;

                        //Centers the scrollbar for new items.
                        horzScroller.Loaded += (a, b) =>
                        {
                            horzScroller.ScrollToHorizontalOffset(horzScroller.ScrollableWidth / 2);
                        };

                        //Sets the width and columns of the images container.
                        if ((templateType == TemplateFieldType.EntryImages) &&
                            tCenterImages)
                        {
                            AdjustWidths(horzScroller, false);
                            Grid.SetRow(horzScroller, 1);
                            gui.GuiItems.Children.Add(horzScroller);
                        }
                        else if (isFirstColumn)
                        {
                            AdjustWidths(horzScroller, tTwoColumns);
                            gui.LeftColItems.Children.Add(horzScroller);
                        }
                        else
                        {
                            AdjustWidths(horzScroller, tTwoColumns);
                            gui.RightColItems.Children.Add(horzScroller);
                        }

                        continue;
                    }

                    else if (!isAnimated && displayAsCarousel)
                    {
                        ImgCarouselGui carousel = new ImgCarouselGui();
                        carousel.Margin = new Thickness(2, 4, 2, 12);

                        //Adds an image from each url to the carousel.
                        bool isCarouselImageSet = false;
                        for (int j = 0; j < loadedUrls.Count; j++)
                        {
                            ImgThumbnail thumbnail = new ImgThumbnail(loadedUrls[j]);
                            thumbnail.Opacity = 0.75;
                            carousel.GuiImageThumbnails.Children.Add(thumbnail);

                            //Opacity visually changes when the mouse is hovered.
                            thumbnail.MouseEnter += (a, b) =>
                            {
                                thumbnail.Opacity = 1;
                            };

                            thumbnail.MouseLeave += (a, b) =>
                            {
                                thumbnail.Opacity = 0.75;
                            };

                            //Removes invalid images and sets the first image.
                            thumbnail.Loaded += (a, b) =>
                            {
                                if (thumbnail.ActualWidth <= 0)
                                {
                                    carousel.GuiImageThumbnails.Children.Remove(thumbnail);
                                }
                                else if (!isCarouselImageSet)
                                {
                                    isCarouselImageSet = true;
                                    carousel.GuiDisplayedImage.Source = thumbnail.Source;
                                    carousel.GuiDisplayedImage.ImgUrl = thumbnail.ImgUrl;
                                    thumbnail.Visibility = Visibility.Collapsed;
                                }
                            };

                            //Clicking a thumbnail sets it as the main image.
                            thumbnail.PreviewMouseUp += (a, b) =>
                            {
                                carousel.GuiDisplayedImage.Source = thumbnail.Source;
                                carousel.GuiDisplayedImage.ImgUrl = thumbnail.ImgUrl;

                                //Hides the current thumbnail and reveals the rest.
                                for (int k = 0; k < carousel.GuiImageThumbnails.Children.Count; k++)
                                {
                                    carousel.GuiImageThumbnails.Children[k].Visibility =
                                        Visibility.Visible;
                                }
                                thumbnail.Visibility = Visibility.Collapsed;

                                //Thumbnails shouldn't show in full in a popup.
                                b.Handled = true;
                            };

                            //Exits when 1 + number of extra images are displayed.
                            if (j == tNumExtraImages && tNumExtraImages > 0)
                            {
                                break;
                            }
                        }

                        elementsContainer.Children.Add(carousel);
                    }

                    //Images that rotate or are movies.
                    else
                    {
                        MediaElement media     = null;
                        ImgAnimated  thumbnail = null;

                        //Loads movies.
                        if (loadedUrls.Count >= 1 &&
                            (loadedUrls[0].ToLower().EndsWith(".wmv") ||
                             loadedUrls[0].ToLower().EndsWith(".mp4")))
                        {
                            media         = new MediaElement();
                            media.IsMuted = isMuted;
                            media.Margin  = new Thickness(2, 4, 2, 12);

                            try
                            {
                                media.Source       = new Uri(loadedUrls[0]);
                                media.MediaOpened += (a, b) =>
                                {
                                    media.MaxWidth  = media.NaturalVideoWidth;
                                    media.MaxHeight = media.NaturalVideoHeight;
                                };
                                media.MediaEnded += (a, b) =>
                                {
                                    media.Position = new TimeSpan(0, 0, 1);
                                };
                            }
                            catch (InvalidOperationException) { } //Ignores loading errors.
                            catch (ArgumentNullException) { }     //Ignores loading errors.
                            catch (UriFormatException) { }        //Ignores loading errors.
                            catch (Exception e) //Logs unknown errors.
                            {
                                Utils.Log("While loading media: " + e.Message);
                            }
                        }

                        //Loads rotating images.
                        else
                        {
                            thumbnail = new ImgAnimated(loadedUrls, true);
                            thumbnail.SetPlaybackDelay(1000);
                            thumbnail.Margin    = new Thickness(2, 4, 2, 12);
                            thumbnail.MaxWidth  = thumbnail.GetSourceWidth();
                            thumbnail.MaxHeight = thumbnail.GetSourceHeight();
                        }

                        if (media != null)
                        {
                            elementsContainer.Children.Add(media);
                        }
                        else
                        {
                            elementsContainer.Children.Add(thumbnail);
                        }
                    }
                }

                //Sets the width and columns of the element container.
                AdjustWidths(elementsContainer, tTwoColumns);
                if ((templateType == TemplateFieldType.EntryImages &&
                     tCenterImages) || displaySingleColumn)
                {
                    if (displaySingleColumn)
                    {
                        gui.FooterItems.Children.Add(elementsContainer);
                    }
                    else
                    {
                        Grid.SetRow(elementsContainer, 1);
                        gui.GuiItems.Children.Add(elementsContainer);
                    }
                }
                else if (isFirstColumn)
                {
                    gui.LeftColItems.Children.Add(elementsContainer);
                }
                else
                {
                    gui.RightColItems.Children.Add(elementsContainer);
                }
            }

            //If there is nothing to display, shows a message saying so.
            if (gui.GuiItems.Children.Count == 2 &&
                gui.LeftColItems.Children.Count == 0 &&
                gui.RightColItems.Children.Count == 0)
            {
                //Creates the message as a textblock.
                TextBlock emptyMessage = new TextBlock();
                emptyMessage.Text = GlobalStrings.HintNoContent;
                emptyMessage.HorizontalAlignment = HorizontalAlignment.Center;
                emptyMessage.VerticalAlignment   = VerticalAlignment.Center;
                emptyMessage.Foreground          = Brushes.LightGray;

                //Adds the message to the center of the grid.
                Grid.SetRow(emptyMessage, 1);
                gui.GuiItems.Children.Add(emptyMessage);
            }
        }
Exemple #37
0
    private static void smethod_1(Class857 A_0, Class97 A_1, ParagraphFormat A_2)
    {
        int      num    = 0x10;
        Class396 class2 = A_0.method_11();
        bool     flag   = false;
        int      num2   = 0;
        int      num3   = 0;
        string   str    = null;
        string   str2   = null;
        bool     flag2  = false;

        while (class2.method_19())
        {
            string str3;
            if (((!Class857.smethod_0(class2, A_1, A_2) && !Class857.smethod_9(class2, A_1.method_35())) && (!Class857.smethod_1(class2, A_1.method_37()) && !Class857.smethod_2(class2, A_1.method_39()))) && ((str3 = class2.method_1()) != null))
            {
                int num4;
                if (Class1160.dictionary_27 == null)
                {
                    Dictionary <string, int> dictionary1 = new Dictionary <string, int>(0x16);
                    dictionary1.Add(BookmarkStart.b("䘵夷崹夻ጽ⸿㝁⥃⑅ⵇ㡉", num), 0);
                    dictionary1.Add(BookmarkStart.b("䈵崷䈹䠻ጽℿ⹁ⵃⅅ♇杉⁋⽍⍏♑", num), 1);
                    dictionary1.Add(BookmarkStart.b("娵儷吹夻ጽ⸿㝁⥃⑅ⵇ㡉", num), 2);
                    dictionary1.Add(BookmarkStart.b("堵䴷圹帻嬽㈿潁⡃⽅♇⽉㽋", num), 3);
                    dictionary1.Add(BookmarkStart.b("嬵夷䤹䠻嬽㈿潁㑃❅⽇⽉態⁍ㅏ㽑ㅓ", num), 4);
                    dictionary1.Add(BookmarkStart.b("䈵崷䈹䠻ጽℿ⹁ⵃⅅ♇", num), 5);
                    dictionary1.Add(BookmarkStart.b("䄵䨷匹䠻圽⸿╁楃⭅❇⹉⥋", num), 6);
                    dictionary1.Add(BookmarkStart.b("䈵崷䈹䠻ጽ⤿ⱁ⁃⍅♇㹉", num), 7);
                    dictionary1.Add(BookmarkStart.b("娵儷吹夻ጽ⠿❁ⵃⅅ⁇㹉", num), 8);
                    dictionary1.Add(BookmarkStart.b("娵儷吹夻ጽ⠿❁ⵃⅅ⁇㹉態⽍⑏网㡓㍕㥗⥙⡛", num), 9);
                    dictionary1.Add(BookmarkStart.b("崵崷弹䰻ጽ㐿ⵁ⍃⍅㱇≉⥋㱍", num), 10);
                    dictionary1.Add(BookmarkStart.b("崵崷弹䰻ጽ㜿⭁ぃ⹅敇⑉⥋㙍⑏", num), 11);
                    dictionary1.Add(BookmarkStart.b("吵夷夹圻夽㈿ⵁㅃ⡅ⱇ杉⽋⅍㱏㵑♓", num), 12);
                    dictionary1.Add(BookmarkStart.b("䈵崷䈹䠻ጽℿ㝁ぃ⥅㭇㩉ⵋⵍ㕏", num), 13);
                    dictionary1.Add(BookmarkStart.b("䘵䴷吹弻䨽㔿⍁ぃ⽅❇⑉態㥍≏㍑⑓", num), 14);
                    dictionary1.Add(BookmarkStart.b("䀵崷䠹䠻圽⌿⍁⡃歅⥇♉╋⥍㹏", num), 15);
                    dictionary1.Add(BookmarkStart.b("䔵嘷嬹䰻ጽ㐿ⵁ楃⩅⥇㍉⍋㭍⑏网㍓⑕ㅗ㹙", num), 0x10);
                    dictionary1.Add(BookmarkStart.b("帵䄷䨹吻嬽⸿⍁ぃ⽅❇⑉態≍ㅏ㙑こ㍕⩗睙㽛ㅝᕟౡၣ", num), 0x11);
                    dictionary1.Add(BookmarkStart.b("䈵夷堹ᄻ䴽㐿ⵁ㑃歅ⱇ⍉㽋㩍ㅏ㱑㝓㍕", num), 0x12);
                    dictionary1.Add(BookmarkStart.b("䔵倷嬹堻儽㜿", num), 0x13);
                    dictionary1.Add(BookmarkStart.b("䄵儷帹医䤽㌿", num), 20);
                    dictionary1.Add(BookmarkStart.b("夵䨷䨹吻弽⸿ㅁ", num), 0x15);
                    Class1160.dictionary_27 = dictionary1;
                }
                if (Class1160.dictionary_27.TryGetValue(str3, out num4))
                {
                    switch (num4)
                    {
                    case 0:
                        if (class2.method_3() != BookmarkStart.b("圵䴷丹医", num))
                        {
                            A_1.method_44(class2.method_3());
                        }
                        break;

                    case 1:
                        str = class2.method_3();
                        break;

                    case 2:
                        A_1.method_42(class2.method_4());
                        break;

                    case 3:
                        if (class2.method_3() == BookmarkStart.b("䈵䨷伹夻", num))
                        {
                            A_2.SuppressLineNumbers = false;
                        }
                        break;

                    case 4:
                        if (!Class567.smethod_16(A_1.method_6()))
                        {
                            A_1.method_7(Class576.smethod_87(class2.method_3()));
                        }
                        break;

                    case 5:
                        str2 = class2.method_3();
                        break;

                    case 6:
                        goto Label_0340;

                    case 7:
                        A_2.FirstLineIndent = ((float)Class576.smethod_36(class2.method_3())) / 20f;
                        break;

                    case 8:
                        if (class2.method_3() != BookmarkStart.b("堵圷䠹儻弽ⰿ", num))
                        {
                            A_2.LineSpacing     = ((float)Class576.smethod_52(class2.method_3())) / 20f;
                            A_2.LineSpacingRule = class2.method_3().EndsWith(BookmarkStart.b("ጵ", num)) ? LineSpacingRule.Multiple : LineSpacingRule.Exactly;
                        }
                        break;

                    case 9:
                        A_2.LineSpacingRule = LineSpacingRule.AtLeast;
                        A_2.LineSpacing     = ((float)Class576.smethod_36(class2.method_3())) / 20f;
                        break;

                    case 10:
                        if (class2.method_3() == BookmarkStart.b("圵吷䴹崻䜽㌿", num))
                        {
                            A_2.SetAttr(0x410, true);
                        }
                        break;

                    case 11:
                        if (class2.method_3() == BookmarkStart.b("圵吷䴹崻䜽㌿", num))
                        {
                            A_2.SetAttr(0x41a, true);
                        }
                        break;

                    case 12:
                        if (class2.method_3() != BookmarkStart.b("䈵䨷嬹刻䴽〿⍁㙃⍅♇㹉", num))
                        {
                            A_2.SetAttr(0x5b4, Class576.smethod_62(class2.method_3(), (Class16)A_2.method_31(0x5b4)));
                            A_1.method_15().SetAttr(0x5b4, Class576.smethod_62(class2.method_3(), (Class16)A_2.method_31(0x5b4)));
                        }
                        break;

                    case 13:
                        A_2.SetAttr(0x4d8, class2.method_3() == BookmarkStart.b("張尷弹医夽㈿⍁㑃⹅敇⭉⁋㹍㡏㍑", num));
                        break;

                    case 14:
                        if (class2.method_3() == BookmarkStart.b("䔵儷圹䰻刽┿", num))
                        {
                            A_2.SetAttr(0x442, false);
                        }
                        break;

                    case 15:
                    {
                        BaselineAlignment alignment = Class922.smethod_43(class2.method_3());
                        if (alignment != BaselineAlignment.Baseline)
                        {
                            A_2.SetAttr(0x5e6, alignment);
                        }
                        break;
                    }

                    case 0x10:
                        if (class2.method_3() == BookmarkStart.b("䈵䨷伹夻", num))
                        {
                            A_2.SetAttr(0x4ec, true);
                        }
                        break;

                    case 0x11:
                        if (class2.method_3() == BookmarkStart.b("堵圷᜹倻圽ⴿ⭁ぃ", num))
                        {
                            A_2.SetAttr(0x582, true);
                        }
                        break;

                    case 0x12:
                        if (A_1.method_0() == null)
                        {
                            A_0.method_9().Settings.float_0 = Class576.smethod_36(class2.method_3());
                        }
                        break;

                    case 0x13:
                        flag = Class576.smethod_90(class2.method_3());
                        break;

                    case 20:
                        num2 = class2.method_4();
                        break;

                    case 0x15:
                        num3 = class2.method_4();
                        break;
                    }
                }
            }
            continue;
Label_0340:
            flag2 = class2.method_3() == BookmarkStart.b("䐵吷᜹䠻尽", num);
            if ((class2.method_3() == BookmarkStart.b("䐵吷᜹䠻尽", num)) || (class2.method_3() == BookmarkStart.b("䐵吷", num)))
            {
                A_2.SetAttr(0x618, true);
            }
            if ((class2.method_3() == BookmarkStart.b("娵䨷᜹䠻尽", num)) || (class2.method_3() == BookmarkStart.b("娵䨷", num)))
            {
                A_2.SetAttr(0x618, false);
            }
        }
        if (str2 != null)
        {
            A_2.HorizontalAlignment = Class922.smethod_65(str2, flag2);
        }
        bool flag3 = (num2 == 2) && (num3 == 2);

        if ((A_1.method_0() != null) && (A_1.method_0() != BookmarkStart.b("攵䰷嬹刻娽ℿぁ⁃", num)))
        {
            if (flag3)
            {
                A_2.SetAttr(0x5be, true);
            }
            else if (!flag3)
            {
                A_2.SetAttr(0x5be, false);
            }
        }
        else if ((num2 >= 2) && (num3 >= 2))
        {
            if (flag3)
            {
                A_0.method_9().Settings.bool_67 = true;
            }
        }
        else
        {
            A_0.method_9().Settings.bool_67 = false;
        }
        if (str == BookmarkStart.b("尵䴷䤹䠻圽☿㭁", num))
        {
            A_2.SetAttr(0x3fc, HorizontalAlignment.Distribute);
        }
        smethod_2(A_2, A_1, flag);
    }
        /// <summary>
        /// 根据当前选中文本的上标或下标状态设置或取消上下标,同时同步按钮状态
        /// </summary>
        /// <param name="value"></param>
        private void SetSuperscriptOrSubscript(BaselineAlignment value, ToggleButton btn)
        {
            BaselineAlignment curValue = rtfManager.GetSelectionBaselineAlignment();

            if (curValue != value)
            {
                rtfManager.SetSelectionBaselineAlignment(value);
                btn.IsChecked = true;
            }
            else
            {
                rtfManager.SetSelectionBaselineAlignment(BaselineAlignment.Baseline);
                btn.IsChecked = false;
            }
        }
 public JapaneseTextRunProperties(Typeface typeface, double size, double hintingSize, TextDecorationCollection textDecorations, Brush forgroundBrush, Brush backgroundBrush, BaselineAlignment baselineAlignment, CultureInfo culture)
 {
     this._typeface = typeface;
     this._emSize = size;
     this._emHintingSize = hintingSize;
     this._textDecorations = textDecorations;
     this._foregroundBrush = forgroundBrush;
     this._backgroundBrush = backgroundBrush;
     this._baselineAlignment = baselineAlignment;
     this._culture = culture;
 }
Exemple #40
0
        private void ToggleBaselineAlignment(BaselineAlignment alignment)
        {
            object currentValue = richTextBox_Main.Selection.GetPropertyValue(Inline.BaselineAlignmentProperty);
            object currentTextSize = richTextBox_Main.Selection.GetPropertyValue(TextElement.FontSizeProperty);

            BaselineAlignment newAlignment = alignment;
            double fontSizeMultiplier = 0.75d;
            if ((BaselineAlignment)currentValue == alignment)
            {
                newAlignment = BaselineAlignment.Baseline;
                fontSizeMultiplier = 1 / 0.75d;
            }

            richTextBox_Main?.Selection.ApplyPropertyValue(Inline.BaselineAlignmentProperty, newAlignment);
            if (currentTextSize != DependencyProperty.UnsetValue)
                richTextBox_Main?.Selection.ApplyPropertyValue(TextElement.FontSizeProperty, (double)currentTextSize * fontSizeMultiplier);
        }