Exemplo n.º 1
0
        public static void UpdateFont(this UITextView textView, ITextStyle textStyle, IFontManager fontManager)
        {
            var font   = textStyle.Font;
            var uiFont = fontManager.GetFont(font, UIFont.LabelFontSize);

            textView.Font = uiFont;
        }
Exemplo n.º 2
0
        public static void UpdateTextColor(this UILabel nativeLabel, ITextStyle textStyle, UIColor?defaultColor = null)
        {
            // Default value of color documented to be black in iOS docs
            var textColor = textStyle.TextColor;

            nativeLabel.TextColor = textColor.ToNative(defaultColor ?? ColorExtensions.LabelColor);
        }
        public static void Run()
        {
            //ExStart:AddNotesSlideWithNotesStyle
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD();

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            // Instantiate Presentation class that represents the presentation file
            using (Presentation presentation = new Presentation(dataDir + "AccessSlides.pptx"))
            {
                IMasterNotesSlide notesMaster = presentation.MasterNotesSlideManager.MasterNotesSlide;

                if (notesMaster != null)
                {
                    // Get MasterNotesSlide text style
                    ITextStyle notesStyle = notesMaster.NotesStyle;

                    //Set symbol bullet for the first level paragraphs
                    IParagraphFormat paragraphFormat = notesStyle.GetLevel(0);
                    paragraphFormat.Bullet.Type = BulletType.Symbol;
                }

                // Save the PPTX file to the Disk
                presentation.Save(dataDir + "AddNotesSlideWithNotesStyle_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
            }
            //ExEnd:AddNotesSlideWithNotesStyle
        }
Exemplo n.º 4
0
        public static void UpdateTextColor(this ButtonBase platformButton, ITextStyle button)
        {
            var brush = button.TextColor?.ToPlatform();

            if (brush is null)
            {
                // Windows.Foundation.UniversalApiContract < 5
                platformButton.Resources.Remove("ButtonForeground");
                platformButton.Resources.Remove("ButtonForegroundPointerOver");
                platformButton.Resources.Remove("ButtonForegroundPressed");
                platformButton.Resources.Remove("ButtonForegroundDisabled");

                // Windows.Foundation.UniversalApiContract >= 5
                platformButton.ClearValue(Button.ForegroundProperty);
            }
            else
            {
                // Windows.Foundation.UniversalApiContract < 5
                platformButton.Resources["ButtonForeground"]            = brush;
                platformButton.Resources["ButtonForegroundPointerOver"] = brush;
                platformButton.Resources["ButtonForegroundPressed"]     = brush;
                platformButton.Resources["ButtonForegroundDisabled"]    = brush;

                // Windows.Foundation.UniversalApiContract >= 5
                platformButton.Foreground = brush;
            }
        }
Exemplo n.º 5
0
 public static void UpdateFont(this Entry platformEntry, ITextStyle textStyle, IFontManager fontManager)
 {
     platformEntry.BatchBegin();
     platformEntry.FontSize       = textStyle.Font.Size > 0 ? textStyle.Font.Size : 25.ToDPFont();
     platformEntry.FontAttributes = textStyle.Font.GetFontAttributes();
     platformEntry.FontFamily     = fontManager.GetFontFamily(textStyle.Font.Family) ?? "";
     platformEntry.BatchCommit();
 }
Exemplo n.º 6
0
        public static void UpdateTextColor(this UITextField textField, ITextStyle textStyle, UIColor?defaultTextColor = null)
        {
            // Default value of color documented to be black in iOS docs

            var textColor = textStyle.TextColor;

            textField.TextColor = textColor.ToPlatform(defaultTextColor ?? ColorExtensions.LabelColor);
        }
Exemplo n.º 7
0
 public static void ApplyTextStyle(this Inline inline, ITextStyle style)
 {
     inline.FontFamily = style.FontFamily;
     inline.FontSize   = style.FontSize * 96d / 72d;
     inline.FontStyle  = style.FontStyle;
     inline.FontWeight = style.FontWeight;
     inline.Foreground = new SolidColorBrush(style.FontColor);
 }
Exemplo n.º 8
0
        public static void UpdateCharacterSpacing(this UITextField textField, ITextStyle textStyle)
        {
            var textAttr = textField.AttributedText?.WithCharacterSpacing(textStyle.CharacterSpacing);

            if (textAttr != null)
            {
                textField.AttributedText = textAttr;
            }
        }
Exemplo n.º 9
0
        public ManagedTextViewStyle(ITextStyle instance, UITextView target, string styleID, string text, bool updateConstraints)
        {
            styleInstance      = instance as TextStyle;
            _updateConstraints = updateConstraints;
            Target             = target;

            StyleID = styleID;
            Text    = !string.IsNullOrEmpty(text) ? text : Target.Text;
        }
Exemplo n.º 10
0
        public static void UpdateTextColor(this UITextField textField, ITextStyle textStyle)
        {
            var textColor = textStyle.TextColor;

            if (textColor != null)
            {
                textField.TextColor = textColor.ToPlatform(ColorExtensions.LabelColor);
            }
        }
Exemplo n.º 11
0
        public static void UpdateTextColor(this TextView textView, ITextStyle textStyle)
        {
            var textColor = textStyle.TextColor;

            if (textColor != null)
            {
                textView.SetTextColor(textColor.ToPlatform());
            }
        }
Exemplo n.º 12
0
        public static void UpdateTextColor(this TextView textView, ITextStyle textStyle, Graphics.Color defaultColor)
        {
            var textColor = textStyle.TextColor?.ToNative() ?? defaultColor?.ToNative();

            if (textColor != null)
            {
                textView.SetTextColor(textColor.Value);
            }
        }
Exemplo n.º 13
0
        public static void UpdateCharacterSpacing(this UILabel nativeLabel, ITextStyle textStyle)
        {
            var textAttr = nativeLabel.AttributedText?.WithCharacterSpacing(textStyle.CharacterSpacing);

            if (textAttr != null)
            {
                nativeLabel.AttributedText = textAttr;
            }
        }
Exemplo n.º 14
0
 public StyleSerializationProxy(ITextStyle style)
 {
     Name = style.Name;
     IsOneParagraph = style.IsOneParagraph;
     FontWeight = style.FontWeight.ToString();
     FontFamily = style.FontFamily.ToString();
     FontStyle = style.FontStyle.ToString();
     FontSize = style.FontSize;
     FontColor = style.FontColor.ToString();
 }
Exemplo n.º 15
0
        public static void UpdateFont(this UISearchBar uiSearchBar, ITextStyle textStyle, IFontManager fontManager, UITextField?textField)
        {
            textField ??= uiSearchBar.FindDescendantView <UITextField>();
            if (textField == null)
            {
                return;
            }

            textField.UpdateFont(textStyle, fontManager);
        }
Exemplo n.º 16
0
        public ViewStyle(ITextStyle instance, TextView target, string styleID, string text, bool updateConstraints)
        {
            _instance          = instance as TextStyle;
            _updateConstraints = updateConstraints;
            _rawText           = text;

            Target  = target;
            StyleID = styleID;
            UpdateText(text);
        }
Exemplo n.º 17
0
        public ViewStyle(ITextStyle instance, UIView target, string styleID, string text, bool updateConstraints)
        {
            _instance          = instance as TextStyle;
            _updateConstraints = updateConstraints;
            _textField         = target as UITextField;

            StyleID = styleID;
            Target  = target;
            UpdateText(text);
        }
Exemplo n.º 18
0
 public StyleSerializationProxy(ITextStyle style)
 {
     Name           = style.Name;
     IsOneParagraph = style.IsOneParagraph;
     FontWeight     = style.FontWeight.ToString();
     FontFamily     = style.FontFamily.ToString();
     FontStyle      = style.FontStyle.ToString();
     FontSize       = style.FontSize;
     FontColor      = style.FontColor.ToString();
 }
Exemplo n.º 19
0
 public static void ApplyTextStyle(this TextSelection selection, ITextStyle style)
 {
     if (selection == null || selection.Start == selection.End)
         return;
     selection.ApplyPropertyValue(TextElement.FontFamilyProperty, style.FontFamily);
     selection.ApplyPropertyValue(TextElement.FontSizeProperty, style.FontSize * 96d / 72d);
     selection.ApplyPropertyValue(TextElement.FontStyleProperty, style.FontStyle);
     selection.ApplyPropertyValue(TextElement.FontWeightProperty, style.FontWeight);
     selection.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(style.FontColor));
     FlowDocumentHelper.SetStyleName(selection.Start.Parent, style.Name);
 }
Exemplo n.º 20
0
        public static void UpdateCharacterSpacing(this UITextView textView, ITextStyle textStyle)
        {
            var textAttr = textView.AttributedText?.WithCharacterSpacing(textStyle.CharacterSpacing);

            if (textAttr != null)
            {
                textView.AttributedText = textAttr;
            }

            // TODO: Include AttributedText to Label Placeholder
        }
Exemplo n.º 21
0
        // ###############################################################################
        // ### M E T H O D S
        // ###############################################################################

        #region Methods

        /// <summary>Add an item to the end of the list.</summary>
        /// <param name="item">The style to add to the list.<see cref="ITextStyle"/></param>
        /// <remarks>The list is limited to a maximum of 32 styles.</remarks>
        public void Add(ITextStyle item)
        {
            if (_styles.Count >= 32)
            {
                SimpleLog.LogLine(TraceEventType.Error, CLASS_NAME + "::Add () Can't handle more than 32 styles!");
            }
            else
            {
                _styles.Add(item);
            }
        }
Exemplo n.º 22
0
        public static void UpdateFont(this UISearchBar uiSearchBar, ITextStyle textStyle, IFontManager fontManager, UITextField?textField)
        {
            textField ??= uiSearchBar.GetSearchTextField();

            if (textField == null)
            {
                return;
            }

            textField.UpdateFont(textStyle, fontManager);
        }
Exemplo n.º 23
0
        public static void UpdateCharacterSpacing(this ButtonBase platformButton, ITextStyle button)
        {
            var characterSpacing = button.CharacterSpacing.ToEm();

            platformButton.CharacterSpacing = characterSpacing;

            if (platformButton.GetContent <TextBlock>() is TextBlock textBlock)
            {
                textBlock.CharacterSpacing = characterSpacing;
            }
        }
Exemplo n.º 24
0
        public static void UpdateTextColor(this MauiTextBox textBox, ITextStyle textStyle)
        {
            if (textStyle.TextColor == null)
            {
                return;
            }

            var brush = textStyle.TextColor.ToNative();

            textBox.Foreground           = brush;
            textBox.ForegroundFocusBrush = brush;
        }
Exemplo n.º 25
0
        public static void UpdateFont(this TextView textView, ITextStyle textStyle, IFontManager fontManager)
        {
            var font = textStyle.Font;

            var tf = fontManager.GetTypeface(font);

            textView.Typeface = tf;

            var sp = fontManager.GetScaledPixel(font);

            textView.SetTextSize(ComplexUnitType.Sp, sp);
        }
Exemplo n.º 26
0
        public static void UpdateFont(this TextView textView, ITextStyle textStyle, IFontManager fontManager)
        {
            var font = textStyle.Font;

            var tf = fontManager.GetTypeface(font);

            textView.Typeface = tf;

            var fontSize = fontManager.GetFontSize(font);

            textView.SetTextSize(fontSize.Unit, fontSize.Value);
        }
Exemplo n.º 27
0
        public static void UpdateTextColor(this TextView textView, ITextStyle textStyle, ColorStateList?defaultColor)
        {
            var textColor = textStyle.TextColor;

            if (textColor == null)
            {
                textView.SetTextColor(defaultColor);
            }
            else
            {
                textView.SetTextColor(textColor.ToNative());
            }
        }
Exemplo n.º 28
0
 public static void ApplyTextStyle(this TextSelection selection, ITextStyle style)
 {
     if (selection == null || selection.Start == selection.End)
     {
         return;
     }
     selection.ApplyPropertyValue(TextElement.FontFamilyProperty, style.FontFamily);
     selection.ApplyPropertyValue(TextElement.FontSizeProperty, style.FontSize * 96d / 72d);
     selection.ApplyPropertyValue(TextElement.FontStyleProperty, style.FontStyle);
     selection.ApplyPropertyValue(TextElement.FontWeightProperty, style.FontWeight);
     selection.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(style.FontColor));
     FlowDocumentHelper.SetStyleName(selection.Start.Parent, style.Name);
 }
Exemplo n.º 29
0
 /// <summary>
 /// Clones text style.
 /// </summary>
 /// <param name="textStyle">The text style to clone.</param>
 /// <returns>The new instance of the <see cref="TextStyle"/> class.</returns>
 public static ITextStyle Clone(this ITextStyle textStyle)
 {
     return(new TextStyle()
     {
         Name = textStyle.Name,
         FontName = textStyle.FontName,
         FontFile = textStyle.FontFile,
         FontSize = textStyle.FontSize,
         FontStyle = textStyle.FontStyle.Clone(),
         TextHAlignment = textStyle.TextHAlignment,
         TextVAlignment = textStyle.TextVAlignment
     });
 }
Exemplo n.º 30
0
        public static void UpdateTextColor(this UIButton platformButton, ITextStyle button)
        {
            if (button.TextColor != null)
            {
                var color = button.TextColor.ToPlatform();

                platformButton.SetTitleColor(color, UIControlState.Normal);
                platformButton.SetTitleColor(color, UIControlState.Highlighted);
                platformButton.SetTitleColor(color, UIControlState.Disabled);

                platformButton.TintColor = color;
            }
        }
Exemplo n.º 31
0
        public static void UpdateTextColor(this TextView textView, ITextStyle textStyle, ColorStateList?defaultColor)
        {
            var textColor = textStyle.TextColor;

            if (textColor != null)
            {
                textView.SetTextColor(textColor.ToPlatform());
                return;
            }

            if (defaultColor != null)
            {
                textView.SetTextColor(defaultColor);
            }
        }
Exemplo n.º 32
0
        public static void UpdateTextColor(this TextBox textBox, ITextStyle textStyle)
        {
            var brush = textStyle.TextColor?.ToPlatform();

            if (brush is null)
            {
                textBox.Resources.RemoveKeys(TextColorResourceKeys);
            }
            else
            {
                textBox.Resources.SetValueForAllKey(TextColorResourceKeys, brush);
            }

            textBox.RefreshThemeResources();
        }
Exemplo n.º 33
0
 public StylePickerItemViewModel(ITextStyle textStyle)
 {
     TextStyle = textStyle;
 }
Exemplo n.º 34
0
    // ------------------------------------------------------------------
    /// <summary>
    /// Initializes this instance.
    /// </summary>
    // ------------------------------------------------------------------
    protected override void Initialize() {
      base.Initialize();
      mTextArea = Rectangle;

      mTextArea.Inflate(
          -TextRectangleInflation,
          -TextRectangleInflation);

      this.mTextStyle = new TextStyle(
          Color.Black,
          new Font("Arial", 12),
          StringAlignment.Center,
          StringAlignment.Center);

      this.mTextStyle.TextStyleChanged +=
          new TextStyleChangedEventHandler(HandleTextStyleChanged);
    }
Exemplo n.º 35
0
 public void AddTextStyle(ITextStyle textStyle)
 {
     _styles.Add(textStyle);
 }
Exemplo n.º 36
0
 private void ChangeStyle(ITextStyle style)
 {
     foreach (var block in _flowDocument.Blocks)
     {
         var paragraph = block as Paragraph;
         if (paragraph == null)
             continue;
         foreach (var inline in paragraph.Inlines)
         {
             if (FlowDocumentHelper.GetStyleName(inline) == style.Name)
                 inline.ApplyTextStyle(style);
         }
     }
 }
Exemplo n.º 37
0
 private void ApplyStyle(ITextStyle style)
 {
     base._documentState.CurrentSelection.ApplyTextStyle(style);
 }
Exemplo n.º 38
0
        /// <summary>
        /// Generates an object from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="T:System.Xml.XmlReader"></see> stream from which the object is deserialized.</param>
        /// <remarks>Documented by Dev05, 2007-10-29</remarks>
        public void ReadXml(System.Xml.XmlReader reader)
        {
            bool wasEmpty = reader.IsEmptyElement;

            if (wasEmpty)
                return;

            reader.Read();

            while (reader.NodeType != XmlNodeType.EndElement)
            {
                switch (reader.Name)
                {
                    case "question":
                        questionStyle = (XmlTextStyle)questionSerializer.Deserialize(reader);
                        break;
                    case "questionExample":
                        questionExampleStyle = (XmlTextStyle)questionExampleSerializer.Deserialize(reader);
                        break;
                    case "answer":
                        answerStyle = (XmlTextStyle)answerSerializer.Deserialize(reader);
                        break;
                    case "answerExample":
                        answerExampleStyle = (XmlTextStyle)answerExampleSerializer.Deserialize(reader);
                        break;
                    case "answerCorrect":
                        answerCorrect = (XmlTextStyle)answerCorrectSerializer.Deserialize(reader);
                        break;
                    case "answerWrong":
                        answerWrong = (XmlTextStyle)answerWrongSerializer.Deserialize(reader);
                        break;
                }
            }

            reader.Read();
        }
Exemplo n.º 39
0
        public void IChapterStyle()
        {
            //Todo: OtherElements, ITextStyle.ToString()
            TestInfrastructure.DebugLineStart(TestContext);
            if (TestInfrastructure.IsActive(TestContext))
            {
                using (IDictionary writeLM = TestInfrastructure.GetLMConnection(TestContext, TestInfrastructure.GetAdminUser))
                {
                    IChapter chapter = writeLM.Chapters.AddNew();
                    chapter.Title = "Chapter xyz";
                    ICardStyle style = chapter.CreateCardStyle();

                    ITextStyle defaultTextStyle = style.Answer;     //just for init

                    defaultTextStyle.BackgroundColor = Color.Red;
                    defaultTextStyle.FontFamily = new FontFamily("Arial");
                    defaultTextStyle.FontSize = 8;
                    defaultTextStyle.FontSizeUnit = FontSizeUnit.Pixel;
                    defaultTextStyle.FontStyle = CSSFontStyle.Bold;
                    defaultTextStyle.ForeColor = Color.Red;
                    defaultTextStyle.HorizontalAlign = HorizontalAlignment.Center;
                    defaultTextStyle.VerticalAlign = VerticalAlignment.Bottom;
                    defaultTextStyle.OtherElements.Add("key1", "value1");

                    style.Answer = defaultTextStyle;
                    style.AnswerCorrect = defaultTextStyle;
                    style.AnswerExample = defaultTextStyle;
                    style.AnswerWrong = defaultTextStyle;
                    style.Question = defaultTextStyle;
                    style.QuestionExample = defaultTextStyle;

                    if (chapter.Settings == null)
                        chapter.Settings = writeLM.CreateSettings();        //only occurs in DB mode
                    chapter.Settings.Style = style;      //assign Style to chapter

                    //Check
                    IChapter chap = writeLM.Chapters.Find("Chapter xyz");

                    ITextStyle[] checkStyle = new ITextStyle[6];
                    checkStyle[0] = chapter.Settings.Style.Answer;
                    checkStyle[1] = chapter.Settings.Style.AnswerCorrect;
                    checkStyle[2] = chapter.Settings.Style.AnswerExample;
                    checkStyle[3] = chapter.Settings.Style.AnswerWrong;
                    checkStyle[4] = chapter.Settings.Style.Question;
                    checkStyle[5] = chapter.Settings.Style.QuestionExample;

                    foreach (ITextStyle sty in checkStyle)
                    {
                        Assert.AreEqual(Color.Red, sty.BackgroundColor, "Style BackgroundColor was not saved to ICardStyle()");
                        Assert.AreEqual(new FontFamily("Arial").Name, sty.FontFamily.Name, "Style FontFamily was not saved to ICardStyle()");
                        Assert.AreEqual(8, sty.FontSize, "Style FontSize was not saved to ICardStyle()");
                        Assert.AreEqual(FontSizeUnit.Pixel, sty.FontSizeUnit, "Style FontSizeUnit was not saved to ICardStyle()");
                        Assert.AreEqual(CSSFontStyle.Bold, sty.FontStyle, "Style FontStyle was not saved to ICardStyle()");
                        Assert.AreEqual(Color.Red, sty.ForeColor, "Style ForeColor was not saved to ICardStyle()");
                        Assert.AreEqual(HorizontalAlignment.Center, sty.HorizontalAlign, "Style HorizontalAlign was not saved to ICardStyle()");
                        Assert.AreEqual(VerticalAlignment.Bottom, sty.VerticalAlign, "Style VerticalAlign was not saved to ICardStyle()");
                        Assert.AreEqual("value1", sty.OtherElements["key1"], "Style OtherElements(key, value) was not saved to ICardStyle()");
                    }
                }
            }
            TestInfrastructure.DebugLineEnd(TestContext);
        }