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; }
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 }
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; } }
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(); }
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); }
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); }
public static void UpdateCharacterSpacing(this UITextField textField, ITextStyle textStyle) { var textAttr = textField.AttributedText?.WithCharacterSpacing(textStyle.CharacterSpacing); if (textAttr != null) { textField.AttributedText = textAttr; } }
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; }
public static void UpdateTextColor(this UITextField textField, ITextStyle textStyle) { var textColor = textStyle.TextColor; if (textColor != null) { textField.TextColor = textColor.ToPlatform(ColorExtensions.LabelColor); } }
public static void UpdateTextColor(this TextView textView, ITextStyle textStyle) { var textColor = textStyle.TextColor; if (textColor != null) { textView.SetTextColor(textColor.ToPlatform()); } }
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); } }
public static void UpdateCharacterSpacing(this UILabel nativeLabel, ITextStyle textStyle) { var textAttr = nativeLabel.AttributedText?.WithCharacterSpacing(textStyle.CharacterSpacing); if (textAttr != null) { nativeLabel.AttributedText = textAttr; } }
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(); }
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); }
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); }
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); }
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); }
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 }
// ############################################################################### // ### 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); } }
public static void UpdateFont(this UISearchBar uiSearchBar, ITextStyle textStyle, IFontManager fontManager, UITextField?textField) { textField ??= uiSearchBar.GetSearchTextField(); if (textField == null) { return; } textField.UpdateFont(textStyle, fontManager); }
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; } }
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; }
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); }
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); }
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()); } }
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); }
/// <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 }); }
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; } }
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); } }
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(); }
public StylePickerItemViewModel(ITextStyle textStyle) { TextStyle = textStyle; }
// ------------------------------------------------------------------ /// <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); }
public void AddTextStyle(ITextStyle textStyle) { _styles.Add(textStyle); }
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); } } }
private void ApplyStyle(ITextStyle style) { base._documentState.CurrentSelection.ApplyTextStyle(style); }
/// <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(); }
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); }