예제 #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;
        }
예제 #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
        }
예제 #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;
            }
        }
예제 #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();
 }
예제 #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);
        }
예제 #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);
 }
예제 #8
0
        public static void UpdateCharacterSpacing(this UITextField textField, ITextStyle textStyle)
        {
            var textAttr = textField.AttributedText?.WithCharacterSpacing(textStyle.CharacterSpacing);

            if (textAttr != null)
            {
                textField.AttributedText = textAttr;
            }
        }
예제 #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;
        }
예제 #10
0
        public static void UpdateTextColor(this UITextField textField, ITextStyle textStyle)
        {
            var textColor = textStyle.TextColor;

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

            if (textColor != null)
            {
                textView.SetTextColor(textColor.ToPlatform());
            }
        }
예제 #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);
            }
        }
예제 #13
0
        public static void UpdateCharacterSpacing(this UILabel nativeLabel, ITextStyle textStyle)
        {
            var textAttr = nativeLabel.AttributedText?.WithCharacterSpacing(textStyle.CharacterSpacing);

            if (textAttr != null)
            {
                nativeLabel.AttributedText = textAttr;
            }
        }
예제 #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();
 }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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();
 }
예제 #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);
 }
예제 #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
        }
예제 #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);
            }
        }
예제 #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);
        }
예제 #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;
            }
        }
예제 #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;
        }
예제 #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);
        }
예제 #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);
        }
예제 #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());
            }
        }
예제 #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);
 }
예제 #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
     });
 }
예제 #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;
            }
        }
예제 #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);
            }
        }
예제 #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();
        }
예제 #33
0
 public StylePickerItemViewModel(ITextStyle textStyle)
 {
     TextStyle = textStyle;
 }
예제 #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);
    }
예제 #35
0
 public void AddTextStyle(ITextStyle textStyle)
 {
     _styles.Add(textStyle);
 }
예제 #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);
         }
     }
 }
예제 #37
0
 private void ApplyStyle(ITextStyle style)
 {
     base._documentState.CurrentSelection.ApplyTextStyle(style);
 }
예제 #38
0
파일: XmlCardStyle.cs 프로젝트: hmehr/OSS
        /// <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();
        }
예제 #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);
        }