protected static PDFName CreatePostScriptFontName(Typeface typeface) { string name = typeface.FontFamily.Source.Replace(" ", ""); FontStyle style = typeface.Style; FontWeight weight = typeface.Weight; if (style != FontStyles.Normal || weight != FontWeights.Normal) { string styleString = (style == FontStyles.Normal) ? "" : style.ToString(); string weightString = (weight == FontWeights.Normal) ? "" : weight.ToString(); name = $"{name}-{weightString}{styleString}"; } // Add a random prefix of uppercase letters, like "FRDVGH+", which indicates this font is a subset. char[] chars = new char[7]; Random random = new Random(); for (int i = 0; i < 6; i++) { chars[i] = (char)random.Next('A', 'Z'); } chars[6] = '+'; return(PDFName.GetEscapedName(new string(chars) + name)); }
public void ApplyChanges() { Settings.Default.Theme = Theme; Settings.Default.FontFamily = FontFamily; Settings.Default.FontStretch = FontStretch.ToString(); Settings.Default.FontWeight = FontWeight.ToString(); Settings.Default.ScratchpadNumberOfLines = ScratchpadNumberOfLines; Settings.Default.ToastNotificationVerticalFillPercentage = ToastNotificationVerticalFillPercentage; Settings.Default.ToastNotificationHorizontalFillPercentage = ToastNotificationHorizontalFillPercentage; Settings.Default.ToastNotificationSecondsPerCharacter = ToastNotificationSecondsPerCharacter; Settings.Default.CursorWidthInPixels = CursorWidthInPixels; Settings.Default.CursorHeightInPixels = CursorHeightInPixels; Settings.Default.MagnifierCenterOnScreen = MagnifierCenterOnScreen; Settings.Default.MagnifySourcePercentageOfScreen = MagnifySourcePercentageOfScreen; Settings.Default.MagnifyDestinationPercentageOfScreen = MagnifyDestinationPercentageOfScreen; Settings.Default.ConversationOnlyMode = ConversationOnlyMode; Settings.Default.ConversationConfirmEnable = ConversationConfirmEnable; Settings.Default.ConversationConfirmOnlyMode = ConversationConfirmOnlyMode; Settings.Default.StartupKeyboard = StartupKeyboard; Settings.Default.MainWindowMinimisedPosition = MinimisedPosition; Settings.Default.KeyCase = KeyCase; Settings.Default.MainWindowFullDockThicknessAsPercentageOfScreen = MainWindowFullDockThicknessAsPercentageOfScreen; Settings.Default.MainWindowCollapsedDockThicknessAsPercentageOfFullDockThickness = MainWindowCollapsedDockThicknessAsPercentageOfFullDockThickness; Settings.Default.ConversationBorderThickness = ConversationBorderThickness; Settings.Default.EnableQuitKeys = EnableQuitKeys; Settings.Default.EnableAttentionKey = EnableAttentionKey; Settings.Default.EnableCopyAllScratchpadKey = EnableCopyAllScratchpadKey; Settings.Default.DynamicKeyboardsLocation = DynamicKeyboardsLocation; Settings.Default.StartupKeyboardFile = StartupKeyboardFile; }
protected virtual Font CreateFont(string fam, double size, FontStyle style, FontWeight weigth, FontStretch stretch) { return(Font.FromName(fam + " " + style.ToString() + " " + weigth.ToString() + " " + stretch.ToString() + " " + size.ToString(CultureInfo.InvariantCulture))); }
public void ApplyChanges() { Settings.Default.Theme = Theme; Settings.Default.MainWindowOpacity = (double)Opacity / 100.0f; Settings.Default.FontFamily = FontFamily; Settings.Default.FontStretch = FontStretch.ToString(); Settings.Default.FontWeight = FontWeight.ToString(); Settings.Default.ScratchpadNumberOfLines = ScratchpadNumberOfLines; Settings.Default.ToastNotificationVerticalFillPercentage = ToastNotificationVerticalFillPercentage; Settings.Default.ToastNotificationHorizontalFillPercentage = ToastNotificationHorizontalFillPercentage; Settings.Default.ToastNotificationSecondsPerCharacter = ToastNotificationSecondsPerCharacter; Settings.Default.CursorWidthInPixels = CursorWidthInPixels; Settings.Default.CursorHeightInPixels = CursorHeightInPixels; Settings.Default.GazeIndicatorStyle = (GazeIndicatorStyles)Enum.Parse(typeof(GazeIndicatorStyles), GazeIndicatorStyle); Settings.Default.GazeIndicatorSize = GazeIndicatorSize; Settings.Default.MagnifierCenterOnScreen = MagnifierCenterOnScreen; Settings.Default.MagnifySourcePercentageOfScreen = MagnifySourcePercentageOfScreen; Settings.Default.MagnifyDestinationPercentageOfScreen = MagnifyDestinationPercentageOfScreen; Settings.Default.ConversationOnlyMode = ConversationOnlyMode; Settings.Default.ConversationConfirmEnable = ConversationConfirmEnable; Settings.Default.ConversationConfirmOnlyMode = ConversationConfirmOnlyMode; Settings.Default.StartupKeyboard = StartupKeyboard; Settings.Default.MainWindowMinimisedPosition = MinimisedPosition; Settings.Default.KeyCase = KeyCase; Settings.Default.MainWindowCollapsedDockThicknessAsPercentageOfFullDockThickness = MainWindowCollapsedDockThicknessAsPercentageOfFullDockThickness; Settings.Default.ConversationBorderThickness = ConversationBorderThickness; Settings.Default.DynamicKeyboardsLocation = DynamicKeyboardsLocation; Settings.Default.StartupKeyboardFile = StartupKeyboardFile; // We don't apply changes to window/size position if Optikey's state has changed to one in which re-positioning isn't supported bool allowReposition = windowManipulationService.GetPersistedState() && Settings.Default.MainWindowState != WindowStates.Maximised && Settings.Default.MainWindowState != WindowStates.Minimised && Settings.Default.MainWindowState != WindowStates.Hidden && Settings.Default.MainWindowDockSize != DockSizes.Collapsed; if (allowReposition) { // Changes to window state, these methods will save the new values also if (Settings.Default.MainWindowState != MainWindowState || Settings.Default.MainWindowDockPosition != DockPosition || !Settings.Default.MainWindowFullDockThicknessAsPercentageOfScreen.IsCloseTo( MainWindowFullDockThicknessAsPercentageOfScreen) || !Settings.Default.MainWindowFloatingSizeAndPosition.IsCloseTo(FloatingSizeAndPosition)) { Settings.Default.MainWindowFullDockThicknessAsPercentageOfScreen = MainWindowFullDockThicknessAsPercentageOfScreen; Settings.Default.MainWindowFloatingSizeAndPosition = FloatingSizeAndPosition; // this also saves the changes windowManipulationService.ChangeState(MainWindowState, DockPosition); } } windowManipulationService.SetOpacity(Settings.Default.MainWindowOpacity); Settings.Default.EnableResizeWithMouse = EnableResizeWithMouse; windowManipulationService.SetResizeState(); }
public ExpanderAttributes(SolidColorBrush background, SolidColorBrush foreground, FontWeight fontWeight) { Background = background; BackgroundColor = background.Color.ToString(); Foreground = foreground; ForegroundColor = foreground.Color.ToString(); TextFontWeight = fontWeight; TextFontWeightString = fontWeight.ToString(); TextFontStyle = FontStyles.Normal; }
/// <summary>Retrieves the string representation of a <see cref="FontWeight"/>.</summary> /// <param name="family">The family string.</param> /// <param name="weight">The <see cref="FontWeight"/>.</param> /// <returns>The string representation of <paramref name="weight"/> in the specified <paramref name="family"/>.</returns> public static string GetWeightString(string family, FontWeight weight) { string weightString = weight.ToString(); if (family != GetFamilyString(Typeface.Purista) && weight == FontWeight.Regular) { weightString = string.Empty; } return(weightString); }
/// <summary> /// Retrieves the string representation of a <see cref="FontWeight"/>. /// </summary> /// <param name="typeface">The <see cref="Typeface"/>.</param> /// <param name="weight">The <see cref="FontWeight"/>.</param> /// <returns>The string representation of <paramref name="weight"/> in the specified <paramref name="typeface"/>.</returns> public static string GetWeightString(string family, FontWeight weight) { string weightString = weight.ToString(); // Only exo has an explicit "regular" weight, other fonts do not if (family != GetFamilyString(Typeface.Exo) && weight == FontWeight.Regular) { weightString = string.Empty; } return(weightString); }
public void ApplyChanges() { Settings.Default.Theme = Theme; Settings.Default.FontFamily = FontFamily; Settings.Default.FontStretch = FontStretch.ToString(); Settings.Default.FontWeight = FontWeight.ToString(); Settings.Default.ToastNotificationVerticalFillPercentage = ToastNotificationVerticalFillPercentage; Settings.Default.ToastNotificationHorizontalFillPercentage = ToastNotificationHorizontalFillPercentage; Settings.Default.ToastNotificationSecondsPerCharacter = ToastNotificationSecondsPerCharacter; Settings.Default.MinImageDisplayTimeInSeconds = MinImageDisplayTimeInSeconds; Settings.Default.DelayBeforeProgressingInSeconds = DelayBeforeProgressingInSeconds; }
public static FontUsage GetFont(Typeface typeface = Typeface.OpenSans, float size = DEFAULT_FONT_SIZE, FontWeight weight = FontWeight.Regular, bool italics = false, bool fixedWidth = false) { var outputSize = size; // Light font is 2x resolution so the size needs to be halved if (weight == FontWeight.Light) { outputSize = size / 2; } return(new FontUsage(GetFamilyString(typeface), outputSize, weight.ToString(), italics, fixedWidth)); }
/// <summary> /// Generates code for value /// </summary> /// <param name="parentClass">The parent class.</param> /// <param name="method">The method.</param> /// <param name="value">The value.</param> /// <param name="baseName">Name of the base.</param> /// <param name="dictionary">The dictionary.</param> /// <returns></returns> public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) { CodeExpression valueExpression = null; if (value != null) { FontWeight fontWeight = (FontWeight)value; CodeTypeReferenceExpression typeReference = new CodeTypeReferenceExpression("FontStyle"); valueExpression = new CodeFieldReferenceExpression(typeReference, fontWeight.ToString()); } return(valueExpression); }
private void Serialize() { appData.GetTextWrappingInfo(Wrapping.IsChecked); appData.GetCheckMissPellingsInfo(editTextBox.SpellCheck.IsEnabled); appData.GetBackgroundColor(backColor.ToString()); appData.GetFontColor(fontColor.ToString()); appData.GetFontFamily(fontFamily.ToString()); appData.GetFontSize(fontSize); appData.GetFontWeight(fontWeight.ToString()); appData.GetFontStyle(fontStyle.ToString()); appData.GetWindowHeight(this.Height); appData.GetWindowWidth(this.Width); appData.Serialize(); }
public override string ToString() { var formattedRelativeFontSize = $"{RelativeFontSize}em "; var formattedFontWeight = FontWeight == FontWeights.Normal ? "" : $"{FontWeight.ToString().ToLower().First()}"; var formattedFontStyle = FontStyle == FontStyles.Normal ? "" : $"{FontWeight.ToString().ToLower().First()}"; //var formattedForegroundDescriptor = return($"{formattedRelativeFontSize}em " + $"{formattedFontWeight} " + $"{formattedFontStyle} "); }
public String GetFullName() { String name = family.ToString(); if (weight != FontWeights.Normal) { name += " " + weight.ToString(); } if (style != FontStyles.Normal) { name += " " + style.ToString(); } return(name); }
public static bool SaveSetting() { string settingFilePath = System.IO.Directory.GetCurrentDirectory() + "\\setting.ini"; FileIOPermission f = new FileIOPermission(FileIOPermissionAccess.Write, System.IO.Directory.GetCurrentDirectory()); try { f.Demand(); } catch (SecurityException e) { System.Windows.MessageBox.Show("文件夹权限错误,请检查UAC权限,无法保存设置。", "弹幕派", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK); return(false); } FileStream fs = new FileStream(settingFilePath, FileMode.Create); StreamWriter settingFileSW = new StreamWriter(fs); try { settingFileSW.WriteLine("[Basic]"); settingFileSW.WriteLine("Num = " + NUM.ToString()); settingFileSW.WriteLine("Duration = " + DURATION.ToString()); settingFileSW.WriteLine("Speed = " + SPEED.ToString()); settingFileSW.WriteLine("[Font]"); settingFileSW.WriteLine("Background = " + background.ToString()); settingFileSW.WriteLine("Foreground = " + foreground.ToString()); settingFileSW.WriteLine("FontFamily = " + fontFamily.ToString()); settingFileSW.WriteLine("FontStyle = " + fontStyle.ToString()); settingFileSW.WriteLine("FontWeight = " + fontWeight.ToString()); settingFileSW.WriteLine("FontSize = " + fontSize.ToString()); settingFileSW.WriteLine("Opactity = " + opactity.ToString()); settingFileSW.WriteLine("Random Color = " + randomColor.ToString()); settingFileSW.WriteLine("Random FontFamily = " + randomFontFamily.ToString()); settingFileSW.Close(); fs.Close(); return(true); } catch (IOException e) { System.Windows.MessageBox.Show("写入配置文件时错误。", "云弹幕", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK); } if (settingFileSW != null) { settingFileSW.Close(); } if (fs != null) { fs.Close(); } return(false); }
public override string ToString() { StringBuilder sb = new StringBuilder(Font.FamilyName); if (Style != FontStyle.Normal) { sb.Append(' ').Append(Style.ToString()); } if (Weight != FontWeight.Normal) { sb.Append(' ').Append(Weight.ToString()); } if (Stretch != FontStretch.Normal) { sb.Append(' ').Append(Stretch.ToString()); } sb.Append(' ').Append(Font.PointSize.ToString(CultureInfo.InvariantCulture)); return(sb.ToString()); }
public void ApplyChanges() { Settings.Default.Theme = Theme; Settings.Default.FontFamily = FontFamily; Settings.Default.FontStretch = FontStretch.ToString(); Settings.Default.FontWeight = FontWeight.ToString(); Settings.Default.ScratchpadNumberOfLines = ScratchpadNumberOfLines; Settings.Default.ToastNotificationVerticalFillPercentage = ToastNotificationVerticalFillPercentage; Settings.Default.ToastNotificationHorizontalFillPercentage = ToastNotificationHorizontalFillPercentage; Settings.Default.ToastNotificationSecondsPerCharacter = ToastNotificationSecondsPerCharacter; Settings.Default.CursorWidthInPixels = CursorWidthInPixels; Settings.Default.CursorHeightInPixels = CursorHeightInPixels; Settings.Default.MagnifySourcePercentageOfScreen = MagnifySourcePercentageOfScreen; Settings.Default.MagnifyDestinationPercentageOfScreen = MagnifyDestinationPercentageOfScreen; Settings.Default.ConversationOnlyMode = ConversationOnlyMode; Settings.Default.StartupKeyboard = StartupKeyboard; Settings.Default.MainWindowMinimisedPosition = MinimisedPosition; Settings.Default.MainWindowFullDockThicknessAsPercentageOfScreen = MainWindowFullDockThicknessAsPercentageOfScreen; Settings.Default.MainWindowCollapsedDockThicknessAsPercentageOfFullDockThickness = MainWindowCollapsedDockThicknessAsPercentageOfFullDockThickness; }
/// <summary> /// Creates a user defined font object. /// </summary> /// <param name="fontName">The font name</param> /// <param name="size">Font size.</param> /// <param name="weight">Bold/Demi bold, etc.</param> /// <param name="isItalic">True if the text is too be rendered in italic.</param> /// <returns>The font object.</returns> /// public static Font CreateFont(string fontName, int size, FontWeight weight, bool isItalic) { String fontKey = fontName + size + weight.ToString() + isItalic.ToString(); return(CreateFont(fontKey, fontName, size, weight, isItalic)); }
public virtual T WithFontWeight(FontWeight fontWeight) { return(SetAttr(new { fontWeight = fontWeight.ToString().ToLower() })); }
public static FontUsage With(this FontUsage usage, FontWeight?weight = null, float?size = null, bool?italics = null, bool?fixedWidth = null) => usage.With("SegoeUI", size, weight?.ToString(), italics, fixedWidth);
/// <summary> /// Formats the specified value. /// </summary> /// <param name="value">The value.</param> /// <returns></returns> public static string Format(this FontWeight value) { return(value.ToString()); }
public static FontUsage GetFont(FontWeight?weight = null, float size = 14.0f, bool italics = false, bool fixedWidth = false) => new FontUsage("SegoeUI", size, weight?.ToString(), italics, fixedWidth);
/// <summary> /// Retrieves the string representation of a <see cref="FontWeight"/>. /// </summary> /// <param name="family">The family string.</param> /// <param name="weight">The <see cref="FontWeight"/>.</param> /// <returns>The string representation of <paramref name="weight"/> in the specified <paramref name="family"/>.</returns> public static string GetWeightString(string family, FontWeight weight) => weight.ToString();
public HtmlString FontWeight(FontWeight fontWeight) { return(HtmlAttributes(new { style = $"font-weight:{fontWeight.ToString().ToLower()};" })); }
DW.FontWeight GetDWFontWeigth(FontWeight weigth) { return((DW.FontWeight)Enum.Parse(typeof(DW.FontWeight), weigth.ToString())); }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { FontWeight fontWt = (FontWeight)value; return(fontWt.ToString()); }
public static FontUsage GetFont(float size = DEFAULT_SIZE, FontWeight weight = FontWeight.Regular, bool italics = false, bool fixedWidth = false) => new FontUsage("Raleway", size, weight.ToString(), false, fixedWidth);
public FontWeightViewModel(FontWeight fontWeight) { Text = fontWeight.ToString(); FontWeight = fontWeight; }