public FontInfo(String Name, double Size, FontFamily Family) { this.Name = Name; this.Size = Size; this.Family = Family; this.Typeface = Family.GetTypefaces().First(); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) return null; string input = System.Convert.ToString(value); string name = GetFontNameFromFile(input); var uri = new System.Uri(input); var ret = new FontFamily(new Uri(uri.AbsoluteUri), name); return ret; }
public static bool IsFixedPitchFont(FontFamily font) { try { var family = new System.Drawing.FontFamily(font.Source); if (!family.IsStyleAvailable(FontStyle.Regular)) return false; var winHandle = new System.Windows.Interop.WindowInteropHelper(App.Current.MainWindow).Handle; using (Graphics gr = Graphics.FromHwnd(winHandle)) using (Font fnt = new Font(family, 10, FontStyle.Regular)) { return gr.MeasureString("iii", fnt).Width == gr.MeasureString("WWW", fnt).Width; } } catch(Exception exp) { Console.WriteLine(font.Source); Console.WriteLine(exp); return false; } }
/// <summary> /// Shows the general informaiton of a player in the general tab /// </summary> /// <param name="p">Player to display</param> private void ShowGeneralInformation(Player p) { wpGeneral.Children.Clear(); FontFamily ff = new System.Windows.Media.FontFamily(new Uri("pack://EHMProgressTracker:,,,Fonts/#Quantico-Regular", UriKind.Absolute), "Quantico"); wpGeneral.Children.Add(new Label() { Content = "Name: " + p.fullName, FontFamily = ff, FontSize = 16 }); wpGeneral.Children.Add(new Label() { Content = "Birth Date: " + p.birthDate, FontFamily = ff, FontSize = 16 }); wpGeneral.Children.Add(new Label() { Content = "Age (latest snapshot): " + p.GetAge(), FontFamily = ff, FontSize = 16 }); wpGeneral.Children.Add(new Label() { Content = "Type: " + p.playerType.ToString(), FontFamily = ff, FontSize = 16 }); wpGeneral.Children.Add(new Label() { Content = "Total attributes (latest snapshot): " + p.Snapshots.First().AttributesTotal(), FontFamily = ff, FontSize = 16 }); wpGeneral.Children.Add(new Label() { Content = "Total attribute growth per day: " + AttributePerDay(p), FontFamily = ff, FontSize = 16 }); }
public wMain(Host _AppObjects) { try { InitializeComponent(); lmf= MemoryField.LoadData("addresses.txt"); Tag = this.Title; coll = new ObservableCollection<MemoryField>(); // coll.Add(new MemoryField() { Address = Convert.ToString(0x450BBC, 16), Type = "BattleTime", Comment = "" }); foreach (MemoryField mf in lmf) coll.Add(mf); dgMemory.ItemsSource = coll; dgMemory.Items.Refresh(); dgMemory.CanUserReorderColumns = false; AppObjects = _AppObjects; this.Owner = AppObjects.wMain; _timer = new DispatcherTimer(); _timer.Tick += new EventHandler(_timer_Tick); lsFonts = new List<string>(); foreach (FontFamily s in Fonts.SystemFontFamilies) lsFonts.Add(s.Source); FontFamily fm = new System.Windows.Media.FontFamily(SystemFonts.CaptionFontFamily.Source); dgMemory.FontFamily = fm; dgMemory.UpdateLayout(); Start_Click(null, null); } catch (Exception) { _timer.Stop(); throw; } }
/// <summary> /// Print the array of strings to the default printer. /// </summary> /// <param name="InLines"></param> public static void PrintLines(IEnumerable <string> Lines, string Title = "", int TabSize = 2) { PrintDialog printDialog = new PrintDialog(); if ((bool)printDialog.ShowDialog().GetValueOrDefault()) { FlowDocument flowDoc = new FlowDocument(); flowDoc.ColumnWidth = printDialog.PrintableAreaWidth; flowDoc.PagePadding = new Thickness(25); var fontFamily = new System.Windows.Media.FontFamily("Lucida console"); double pointSize = 12; foreach (string line in Lines) { var para = new Paragraph(); para.Margin = new Thickness(0); para.FontFamily = fontFamily; para.FontSize = pointSize; para.Inlines.Add(new Run(line)); flowDoc.Blocks.Add(para); } DocumentPaginator paginator = (flowDoc as IDocumentPaginatorSource).DocumentPaginator; printDialog.PrintDocument(paginator, Title); } }
public static void RegisterFont(string name, FontFamily fontFamily) { Argument.IsNotNullOrWhitespace(() => name); Argument.IsNotNull(() => fontFamily); RegisteredFontFamilies[name] = fontFamily; }
// copied and adapted from presenter::GetLabelWidthAndHeight(...) private double TestHelper_GetLabelWidthAndHeight(string text) { var defaultFontFamily = new System.Windows.Media.FontFamily(); var defaultFontStyle = new System.Windows.FontStyle(); var defaultFontStretch = new System.Windows.FontStretch(); var defaultFontSizeEm = 12.0; var typeFace = new Typeface(defaultFontFamily, defaultFontStyle, System.Windows.FontWeights.Normal, defaultFontStretch); var formattedText = new FormattedText( text, System.Globalization.CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, typeFace, defaultFontSizeEm, Brushes.Black); var Padding = 15; // empirical var width = formattedText.Width + Padding; return(width); }
private void Button_Click_1(object sender, RoutedEventArgs e) { FontDialog fd = new FontDialog(); System.Windows.Forms.DialogResult dr = fd.ShowDialog(); if (dr != System.Windows.Forms.DialogResult.Cancel) { FontFamily fontFamily = new System.Windows.Media.FontFamily(fd.Font.Name); double fontSize = fd.Font.Size * 96.0 / 72.0; ; FontWeight fontWeight = fd.Font.Bold ? FontWeights.Bold : FontWeights.Regular; FontStyle fontStyle = fd.Font.Italic ? FontStyles.Italic : FontStyles.Normal; tbSourse.FontFamily = fontFamily; tbTranslated.FontFamily = fontFamily; tbSourse.FontSize = fontSize; tbTranslated.FontSize = fontSize; tbSourse.FontWeight = fontWeight; tbTranslated.FontWeight = fontWeight; tbSourse.FontStyle = fontStyle; tbTranslated.FontStyle = fontStyle; Properties.Settings.Default.FontFamily = fontFamily; Properties.Settings.Default.FontSize = fontSize; Properties.Settings.Default.FontWeight = fontWeight; Properties.Settings.Default.FontStyle = fontStyle; Properties.Settings.Default.Save(); } }
public IlisBiding() { InitializeComponent(); List <StudentX> stu = new List <StudentX>() { new StudentX() { Name = "ZZ", Sex = "男", Id = 1001 }, new StudentX() { Name = "YY", Sex = "女", Id = 1002 } //new StudentX("XX","男",1004) }; this.lb11.ItemsSource = stu; FontFamily f = new System.Windows.Media.FontFamily(new Uri(""), ""); Binding bd = new Binding("SelectedItem.Name") { Source = this.lb11 }; this.tb11.SetBinding(TextBox.TextProperty, bd); }
public static GlyphSlot GetOrSetGlyphMetrics(Text text, int i) { if (!FontGlyphs.TextFaces.TryGetValue(text.Font, out var face)) { var windowFontFamily = new System.Windows.Media.FontFamily(text.Font.FontFamily.Name); var typeface = new Typeface(windowFontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal); typeface.TryGetGlyphTypeface(out var glyphTypeface); face = new Face(FontGlyphs.TextLibrary, glyphTypeface.FontUri.AbsolutePath); face.SetCharSize(0, text.Font.SizeInPoints * 64, 1, 1); FontGlyphs.TextFaces[text.Font] = face; FontGlyphs.TextFaceHeights[text.Font] = face.Size.Metrics.Height; } if (face.GetCharIndex(text.Content[i]) == 0) { if (!FontGlyphs.FallbackTextFaces.TryGetValue(text.Font, out face)) { face = new Face(FontGlyphs.TextLibrary, FontGlyphs.FallbackFontBytes, 1); face.SetCharSize(0, text.Font.SizeInPoints * 64, 1, 1); FontGlyphs.FallbackTextFaces[text.Font] = face; } } face.LoadChar(text.Content[i], LoadFlags.Default, LoadTarget.Mono); var glyphSlot = face.Glyph; glyphSlot.RenderGlyph(RenderMode.Mono); FontGlyphs.TextMetrics[text.GetCharKey(i)] = glyphSlot.Metrics; return(glyphSlot); }
internal static FontFamilyInternal GetOrCreateFromWpf(WpfFontFamily wpfFontFamily) { FontFamilyInternal fontFamily = new FontFamilyInternal(wpfFontFamily); fontFamily = FontFamilyCache.CacheOrGetFontFamily(fontFamily); return(fontFamily); }
public bool DrawString( System.Windows.Media.DrawingContext graphics, System.Windows.Media.FontFamily fontFamily, System.Windows.FontStyle fontStyle, System.Windows.FontWeight fontWeight, double fontSize, string strText, System.Windows.Point ptDraw, System.Globalization.CultureInfo ci) { Geometry path = GDIPath.CreateTextGeometry(strText, fontFamily, fontStyle, fontWeight, fontSize, ptDraw, ci); if (m_bClrText) { SolidColorBrush brush = new SolidColorBrush(m_clrText); Pen pen = new Pen(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), 1.0); graphics.DrawGeometry(brush, pen, path); } else { Pen pen = new Pen(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), 1.0); graphics.DrawGeometry(m_brushText, pen, path); } return(true); }
public static string[] Find(int charCode) { var r = new List<string>(); GlyphTypeface glyph; foreach (string familyName in Fonts) { var font = new FontFamily(familyName); foreach (Typeface tf in font.GetTypefaces()) { if (tf.TryGetGlyphTypeface(out glyph)) { if (glyph.CharacterToGlyphMap.ContainsKey(charCode)) { //Debug.Print("Found in {0} font.", familyName); r.Add(familyName); break; } } } } return r.ToArray(); }
public FontFamilyWrapper(FontFamily fontFamily) { this.fontFamily = fontFamily; FamilyNames = fontFamily.FamilyNames.ToArray(); Typefaces = fontFamily.GetTypefaces().ToArray(); }
// Implementation Notes // FontFamilyInternal implements an XFontFamily. // // * Each XFontFamily object is just a handle to its FontFamilyInternal singleton. // // * A FontFamilyInternal is uniquely identified by its name. It // is not possible to use two different fonts that have the same // family name. FontFamilyInternal(string familyName #if !WITHOUT_DRAWING , bool createPlatformObjects #endif ) { _sourceName = _name = familyName; #if CORE && !WITHOUT_DRAWING || GDI if (createPlatformObjects) { _gdiFontFamily = new GdiFontFamily(familyName); _name = _gdiFontFamily.Name; } #endif #if WPF && !SILVERLIGHT if (createPlatformObjects) { _wpfFontFamily = new WpfFontFamily(familyName); _name = _wpfFontFamily.FamilyNames[FontHelper.XmlLanguageEnUs]; } #endif #if SILVERLIGHT _wpfFontFamily = new WpfFontFamily(_name); _name = _wpfFontFamily.Source; // Not expected to change _name. #endif }
public Typeface(FontFamily fontFamily, FontStyle style = FontStyle.Normal, FontWeight weight = FontWeight.Normal, FontStretch stretch = FontStretch.Normal) { this.FontFamily = fontFamily; this.Style = style; this.Weight = weight; this.Stretch = stretch; }
private void RenderCommonLayout(Rect rect, DrawingContext drawingContext) { drawingContext.DrawLine(new Pen(Brushes.Silver, 1.5), new Point(rect.Left, rect.Top), new Point(rect.Left, rect.Top + rect.Height)); drawingContext.DrawLine(new Pen(Brushes.Silver, 1.5), new Point(rect.Left, rect.Top + rect.Height), new Point(rect.Left + rect.Width, rect.Top + rect.Height)); var courier = new FontFamily("Segoe"); var courierTypeface = new Typeface(courier, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal); var formattedText = new FormattedText("Frequency", System.Globalization.CultureInfo.CurrentCulture, FlowDirection.LeftToRight, courierTypeface, 10.0, Brushes.White); drawingContext.DrawText(formattedText, new Point(rect.Right - formattedText.Width, rect.Bottom + 4)); formattedText = new FormattedText("Level", System.Globalization.CultureInfo.CurrentCulture, FlowDirection.LeftToRight, courierTypeface, 10.0, Brushes.White); drawingContext.PushTransform(new RotateTransform(-90)); drawingContext.DrawText(formattedText, new Point(-rect.Top - formattedText.Width, rect.Left - 14)); drawingContext.Pop(); }
/// <summary> /// Gets the Windows or Windows Phone font family from the user /// settings Font /// </summary> /// <param name="settings">the custom caption settings</param> /// <returns>the font family</returns> private Media.FontFamily GetFontFamily(CustomCaptionSettings settings) { if (this.fontMap == null) { this.fontMap = new Dictionary <Microsoft.PlayerFramework.CaptionSettings.Model.FontFamily, Media.FontFamily>(); } Media.FontFamily fontFamily; if (this.fontMap.TryGetValue(settings.FontFamily, out fontFamily)) { return(fontFamily); } string fontName = CC608CaptionSettingsPlugin.GetFontFamilyName(settings.FontFamily); if (fontName == null) { return(null); } fontFamily = new Media.FontFamily(fontName); this.fontMap[settings.FontFamily] = fontFamily; return(fontFamily); }
public FontHandler(swm.FontFamily family, double size, sw.FontStyle style, sw.FontWeight weight) { Family = new FontFamily(new FontFamilyHandler(family)); Size = size; WpfFontStyle = style; WpfFontWeight = weight; }
public static void Register (string fontName, SpriteFont font) { if (String.IsNullOrEmpty(fontName) || font == null ) throw new ArgumentException(); var fontFamily = new FontFamily (fontName, font.Spacing, font.LineSpacing); registeredFonts[fontFamily] = font; }
/// <summary> /// Updates the font family. /// </summary> /// <param name="fontFamily"></param> protected void UpdateFontFamily(FontFamily fontFamily) { var font = fontFamily.ToString(); if (font.Contains("Arial")) { UpdateArialFontFamily(); } else if (font.Contains("Courier")) { UpdateCourierFontFamily(); } else if (font.Contains("Verdana")) { UpdateVerdanaFontFamily(); } else if (font.Contains("Webdings")) { UpdateOtherFontFamily(); } else { throw new Exception("Font type not supported."); } }
public bool DrawString( System.Windows.Media.DrawingContext graphics, System.Windows.Media.FontFamily fontFamily, System.Windows.FontStyle fontStyle, System.Windows.FontWeight fontWeight, double fontSize, string strText, System.Windows.Point ptDraw, System.Globalization.CultureInfo ci) { Geometry path = GDIPath.CreateTextGeometry(strText, fontFamily, fontStyle, fontWeight, fontSize, ptDraw, ci); for (int i = 1; i <= m_nThickness; ++i) { SolidColorBrush solidbrush = new SolidColorBrush(m_clrOutline); Pen pen = new Pen(solidbrush, i); pen.LineJoin = PenLineJoin.Round; if (m_bClrText) { SolidColorBrush brush = new SolidColorBrush(m_clrText); graphics.DrawGeometry(brush, pen, path); } else { graphics.DrawGeometry(m_brushText, pen, path); } } return(true); }
public static void Register(FontFamily fontFamily, SpriteFont font) { if (fontFamily == null || font == null) throw new ArgumentException(); registeredFonts[fontFamily] = font; }
public static SpriteFont Resolve(FontFamily fontFamily) { if (fontFamily == null) throw new ArgumentNullException(); return registeredFonts[fontFamily]; }
public override IEnumerable <KeyValuePair <string, object> > GetAvailableFamilyFaces(string family) { FontFamily wpfFamily; if (!registeredFonts.TryGetValue(family, out wpfFamily)) // check for custom fonts { wpfFamily = new FontFamily(family); } foreach (var face in wpfFamily.GetTypefaces()) { var langCurrent = SW.Markup.XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag); var langInvariant = SW.Markup.XmlLanguage.GetLanguage("en-us");; string name; if (face.FaceNames.TryGetValue(langCurrent, out name) || face.FaceNames.TryGetValue(langInvariant, out name)) { var fontData = new FontData(wpfFamily, 0) { Style = face.Style, Weight = face.Weight, Stretch = face.Stretch }; yield return(new KeyValuePair <string, object> (name, fontData)); } } yield break; }
public FontHandler(Eto.Generator generator, swm.FontFamily family, double size, sw.FontStyle style, sw.FontWeight weight) { this.Family = new FontFamily(generator, new FontFamilyHandler(family)); this.Size = size; this.WpfFontStyle = style; this.WpfFontWeight = weight; }
public override FontFamily Get(string key) { if (Contains(key)) { return(base.Get(key)); } FontFamily f; bool exists = (from ff in Fonts.SystemFontFamilies where ff.Source.Equals(key) select ff).Any(); if (exists) { f = new FontFamily(key); } else { logger.Info("Loading font '{0}' from {1} ", key, new Uri(path)); f = new System.Windows.Media.FontFamily(new Uri(path + "./#" + key + ".ttf"), key); } if (f == null) { logger.Warn("Could not load font family '{0}'. falling back to Arial", key); return(base.Get("Arial")); } logger.Info("Added '{0}' to FontCache", key); Add(key, f); return(f); }
/// <summary> /// Gets the mapped font /// </summary> /// <returns>a native font family</returns> private Media.FontFamily GetFont() { if (this.fontMap == null) { this.fontMap = new Dictionary <PlayerFramework.CaptionSettings.Model.FontFamily, Media.FontFamily>(); } Media.FontFamily fontFamily; if (this.fontMap.TryGetValue(this.Settings.FontFamily, out fontFamily)) { return(fontFamily); } var name = GetFontFamilyName(this.Settings.FontFamily); if (name == null) { return(null); } fontFamily = new Media.FontFamily(name); this.fontMap[this.Settings.FontFamily] = fontFamily; return(fontFamily); }
/// <summary> /// Gets the font family from the user settings Font /// </summary> /// <param name="userSettings">the user settings</param> /// <returns>the font family</returns> private static FF.FontFamily GetFontFamily(CustomCaptionSettings userSettings) { if (fontMap == null) { fontMap = new Dictionary <Microsoft.PlayerFramework.CaptionSettings.Model.FontFamily, FF.FontFamily>(); // _Smallcaps is a unique keyword that will trigger the usage of Typography.SetCapitals(textblock, FontCapitals.SmallCaps) // and the default font. fontMap[Microsoft.PlayerFramework.CaptionSettings.Model.FontFamily.Smallcaps] = new FF.FontFamily("_Smallcaps"); } FF.FontFamily fontFamily; if (fontMap.TryGetValue(userSettings.FontFamily, out fontFamily)) { return(fontFamily); } var name = GetFontFamilyName(userSettings.FontFamily); if (name == null) { return(null); } fontFamily = new FF.FontFamily(name); fontMap[userSettings.FontFamily] = fontFamily; return(fontFamily); }
// 更改主题 private void ApplyTheme(TomatoClockTheme theme) { ThemeTag = theme.Tag; GlobalBackground = new SolidColorBrush( (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(theme.GlobalBackground)); ButtonStaticForeground = new SolidColorBrush(ColorStrToColor(theme.Button.StaticForeground)); ButtonMouseOverForeground = new SolidColorBrush(ColorStrToColor(theme.Button.MouseOverForeground)); ButtonPressedForeground = new SolidColorBrush(ColorStrToColor(theme.Button.PressedForeground)); ButtonStaticOpacity = ColorStrToColor(theme.Button.StaticForeground).A / 255.0; ButtonMouseOverOpacity = ColorStrToColor(theme.Button.MouseOverForeground).A / 255.0; ButtonPressedOpacity = ColorStrToColor(theme.Button.PressedForeground).A / 255.0; CloseIcon = GetBitmapBaseOnTheme(AppResource.CloseIcon); MinimizeIcon = GetBitmapBaseOnTheme(AppResource.MinimizeIcon); TopMostIcon = GetBitmapBaseOnTheme(AppResource.UnpinIcon); StartIcon = GetBitmapBaseOnTheme(AppResource.StartIcon); PauseIcon = GetBitmapBaseOnTheme(AppResource.PauseIcon); ResetIcon = GetBitmapBaseOnTheme(AppResource.ResetIcon); NextIcon = GetBitmapBaseOnTheme(AppResource.NextIcon); PreIcon = GetBitmapBaseOnTheme(AppResource.PreIcon); FCListIcon = GetBitmapBaseOnTheme(AppResource.FCListIcon); TaskListIcon = GetBitmapBaseOnTheme(AppResource.TaskListIcon); LabelFontFamily = new System.Windows.Media.FontFamily(theme.Label.FontFamily); LabelFontSize = theme.Label.FontSize; LabelForeground = new SolidColorBrush(ColorStrToColor(theme.Label.Foreground)); }
private void Window_Loaded(object sender, RoutedEventArgs e) { // Haal een array op van alle geinstalleerde lettertypes. System.Windows.Media.FontFamily[] fonts; using (InstalledFontCollection installedFonts = new InstalledFontCollection()) { fonts = new System.Windows.Media.FontFamily[installedFonts.Families.Length]; for (int i = 0; i < fonts.Length; i++) { // Om een of andere reden zijn alle fonts uit InstalledFontCollection een // System.Drawing.FontFamily en TextBlock heeft een // System.Windows.Media.FontFamily nodig. // Dit moet anders kunnen maar hoe? :S fonts[i] = new System.Windows.Media.FontFamily( installedFonts.Families[i].Name); Console.WriteLine(fonts[i]); } } Console.WriteLine(fonts.Length + " fonts available"); Random random = new Random(); foreach (char c in text) { Run run = new Run(Char.ToString(c)); run.FontFamily = fonts[random.Next(0, fonts.Length)]; run.FontSize = 18; textBlock.Inlines.Add(run); } }
private static ImageSource CreateGlyph(string text, FontFamily fontFamily, FontStyle fontStyle, FontWeight fontWeight, FontStretch fontStretch, Brush foreBrush) { if (fontFamily != null && !string.IsNullOrEmpty(text)) { var typeface = new Typeface(fontFamily, fontStyle, fontWeight, fontStretch); GlyphTypeface glyphTypeface; if (!typeface.TryGetGlyphTypeface(out glyphTypeface)) { throw Log.ErrorAndCreateException <InvalidOperationException>("No glyph type face found"); } var glyphIndexes = new ushort[text.Length]; var advanceWidths = new double[text.Length]; for (var i = 0; i < text.Length; i++) { ushort glyphIndex; try { var key = text[i]; if (!glyphTypeface.CharacterToGlyphMap.TryGetValue(key, out glyphIndex)) { glyphIndex = 42; } } catch (Exception) { glyphIndex = 42; } glyphIndexes[i] = glyphIndex; var width = glyphTypeface.AdvanceWidths[glyphIndex] * 1.0; advanceWidths[i] = width; } try { var glyphRun = new GlyphRun(glyphTypeface, 0, false, RenderingEmSize, glyphIndexes, new Point(0, 0), advanceWidths, null, null, null, null, null, null); var glyphRunDrawing = new GlyphRunDrawing(foreBrush, glyphRun); //TextOptions.SetTextRenderingMode(glyphRunDrawing, TextRenderingMode.Aliased); var drawingImage = new DrawingImage(glyphRunDrawing); //TextOptions.SetTextRenderingMode(drawingImage, TextRenderingMode.Aliased); return(drawingImage); } catch (Exception ex) { Log.Error(ex, "Error in generating Glyphrun"); } } return(null); }
public void ControlEntitySetDefaults() { ControlType = ControlType.Label; ID = ""; Text = ""; ListOfKeyValuePairs = new List <ComboBoxPair>(); SelectedKey = "--Select Item ---"; SelectedValue = "--Select Item ---"; Checked = false; ButtonPressed = false; ImageFile = ""; RowNumber = 0; ColumnNumber = 0; Width = 0; Height = 0; TextWrap = true; Multiline = false; ShowTextBox = true; ShowFormattedAmount = true; BackgroundColor = null; ForegroundColor = null; Amount = 0; ParentLkDDLNamesItemsInc = -1; ComboBoxIsSorted = false; ComboBoxIsEditable = false; DDLName = ""; ToolTipx = ""; ColumnSpan = 1; FontFamilyx = new System.Windows.Media.FontFamily("Segoe UI"); FontSize = 12; FontStretchx = FontStretches.Normal; FontStyle = System.Windows.FontStyles.Normal; FontWeight = FontWeights.Normal; SourceDataTable = new DataTable(); }
void BtnDraw_Click(object sender, RoutedEventArgs e) { string iupacname = txtIupacName.Text.Trim(); try { DrawingCanvas.Children.Clear(); Color backgroundColor = (Color)cmbBackGroundColor.SelectedValue; Color fontColor = (Color)cmbFontColor.SelectedValue; Color nodeColor = (Color)cmbNodeColor.SelectedValue; Color verticeColor = (Color)cmbVerticeColor.SelectedValue; int width = (int)DrawingCanvas.ActualWidth; int height = (int)DrawingCanvas.ActualHeight; System.Windows.Media.FontFamily fontFamily = (FontFamily)cmbFontType.SelectedItem; int fontSize = Convert.ToInt16(txtFontsize.Text); int verticeLength = Convert.ToInt16(txtVerticeLength.Text); int verticeThickness = Convert.ToInt16(txtVerticeThickness.Text); Painter painter = new Painter(DrawingCanvas, backgroundColor, fontColor, fontSize, fontFamily, nodeColor, verticeColor, verticeThickness); IUPAC2ImageConverter converter = new IUPAC2ImageConverter(iupacname, width, height, verticeLength, painter); converter.DrawOnCanvas(); } catch (Exception exception) { string errorMessage = string.Format("Cannot process {0}", iupacname); MessageBox.Show(errorMessage); } }
public MainWindow() { WinConsole.ShowConsole(); InitializeComponent(); var wc = new WindowChrome { CaptionHeight = 30, GlassFrameThickness = new Thickness(0), CornerRadius = new CornerRadius(0), UseAeroCaptionButtons = false, ResizeBorderThickness = new Thickness(5) }; WindowChrome.SetWindowChrome(this, wc); Activated += MainWindow_Activated; Deactivated += MainWindow_Deactivated; SizeChanged += MainWindow_OnSizeChanged; Client.CloseDialogPanelEvent += Client_CloseDialogPanelEvent; Client.ShowDialogPanelEvent += Client_ShowDialogPanelEvent; Client.ShowToastEvent += Client_ShowToastEvent; //基于dip决定高分屏字体 try { using (var graphics = Graphics.FromHwnd(IntPtr.Zero)) { if (Math.Abs(graphics.DpiX - 96) > 0) { TextOptions.SetTextFormattingMode(this, TextFormattingMode.Ideal); FontFamily = new FontFamily("Microsoft Yahei"); } else { TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display); FontFamily = new FontFamily("SimSun"); } } } catch (Exception) { // ignored } //默认风格 _buttonStatus.Baseurl = "Resources/Icon/ControlBox/drak/"; DataContext = _buttonStatus; //初始化页面加载、方便调用UI线程委托 Common.MainWindow = this; Client.MainWindow = this; //加载login页面 LoginTabItem.ClickDown(null, null); //启动状态定时器 new Timer { Interval = 1000, Enabled = true }.Elapsed += MainWindow_Elapsed; }
/// <summary> /// Gets the font family from the user settings Font /// </summary> /// <param name="fontFamily">the font family</param> /// <returns>the Windows font family</returns> private Media.FontFamily GetFontFamily(Microsoft.PlayerFramework.CaptionSettings.Model.FontFamily fontFamily) { if (this.fontMap == null) { this.fontMap = new Dictionary <Microsoft.PlayerFramework.CaptionSettings.Model.FontFamily, Media.FontFamily>(); } Media.FontFamily mediaFontFamily; if (this.fontMap.TryGetValue(fontFamily, out mediaFontFamily)) { return(mediaFontFamily); } var fontName = CaptionSettingsPluginBase.GetFontFamilyName(fontFamily); if (fontName == null) { return(null); } mediaFontFamily = new Media.FontFamily(fontName); this.fontMap[fontFamily] = mediaFontFamily; return(mediaFontFamily); }
private void hed_main_btn_load_click(object sender, RoutedEventArgs e) { Reset(); information = mwh.LoadFile(); BitmapImage image = mwh.GetImage(information.ImageUri); currentBitmap = BitmapImage2Bitmap(image); ft_tb_currentpath.Text = image.UriSource.ToString(); cnt_image.Height = image.Height; cnt_image.Width = image.Width; cnt_image.Source = image; information.ImageUri = image.UriSource.ToString(); currentSave = image.UriSource.LocalPath.ToString(); foreach (Text item in information.Texts) { LabelHelper lbl = new LabelHelper(); lbl.label.Name = item.Name; lbl.label.Content = item.Content; lbl.label.Margin = new Thickness(item.Margin.Left, item.Margin.Top, item.Margin.Left, item.Margin.Top); lbl.label.Foreground = Brushes.Black; lbl.label.FontSize = item.FontSize; System.Windows.Media.FontFamily font = new System.Windows.Media.FontFamily(item.Font); lbl.label.FontFamily = font; lbl.label.PreviewMouseDown += Label_OnPreviewMouseDown; lbl.label.PreviewMouseMove += Label_OnPreviewMouseMove; lbl.label.PreviewMouseUp += Label_OnPreviewMouseUp; lbl.label.MouseEnter += Label_OnMouseHoverEnter; lbl.label.MouseLeave += Label_OnMouseHoverLeave; lbl.label.KeyUp += Label_OnKeyUp; cnt_labels.Children.Add(lbl.label); text_on_image.Add(lbl); } ShowHiddenStartContent(); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var fontName = value as string; if (fontName == null) return value; var fontFamily = new FontFamily(fontName); return fontFamily; }
public PlatformFontResolverInfo(string faceName, bool mustSimulateBold, bool mustSimulateItalic, WpfFontFamily wpfFontFamily, WpfTypeface wpfTypeface, WpfGlyphTypeface wpfGlyphTypeface) : base(faceName, mustSimulateBold, mustSimulateItalic) { _wpfFontFamily = wpfFontFamily; _wpfTypeface = wpfTypeface; _wpfGlyphTypeface = wpfGlyphTypeface; }
public TextContext() { fontFamily = new System.Windows.Media.FontFamily("Arial"); fontStyle = new System.Windows.FontStyle(); nfontSize = 20; pszText = null; ptDraw = new System.Windows.Point(0, 0); ci = new System.Globalization.CultureInfo("en-US"); }
FontFamilyInternal(GdiFontFamily gdiFontFamily) { _sourceName = _name = gdiFontFamily.Name; _gdiFontFamily = gdiFontFamily; #if WPF // Hybrid build only. _wpfFontFamily = new WpfFontFamily(gdiFontFamily.Name); #endif }
void avAddressCtrl_Loaded(object sender, EventArgs e) { initBackBrush = (SolidColorBrush)wpfAddressCtrl.MyControl_Background; initForeBrush = wpfAddressCtrl.MyControl_Foreground; initFontFamily = wpfAddressCtrl.MyControl_FontFamily; initFontSize = wpfAddressCtrl.MyControl_FontSize; initFontWeight = wpfAddressCtrl.MyControl_FontWeight; initFontStyle = wpfAddressCtrl.MyControl_FontStyle; }
public CodeEditor() { FontFamily = new FontFamily("Consolas"); FontSize = 12; ShowLineNumbers = true; Options = new TextEditorOptions { ConvertTabsToSpaces = true }; }
private void ButtonOK_OnClick(object sender, RoutedEventArgs e) { var si = ListBoxFonts.SelectedItem as ListBoxItem; if (si != null) { fontFamily = si.DataContext as FontFamily; } this.Close(); }
public FontSettingsImpl(ThemeFontSettings owner, Guid themeGuid, FontFamily fontFamily, double fontSize) { if (owner == null) throw new ArgumentNullException(nameof(owner)); if (fontFamily == null) throw new ArgumentNullException(nameof(fontFamily)); ThemeFontSettings = owner; ThemeGuid = themeGuid; this.fontFamily = fontFamily; FontSize = fontSize; }
/// <summary> /// 获取根据当地文化(比如汉语)显示的字体名称 /// </summary> /// <param name="?"></param> /// <returns></returns> public static string GetLocaliteFontName(FontFamily font) { if (font == null) return ""; LanguageSpecificStringDictionary dic = font.FamilyNames; CultureInfo cultureInfo = CultureInfo.CurrentCulture; if (dic.ContainsKey(XmlLanguage.GetLanguage(cultureInfo.Name))) return font.FamilyNames[XmlLanguage.GetLanguage(cultureInfo.Name)]; else return font.FamilyNames[XmlLanguage.GetLanguage("en-us")]; }
/// <param name="fontSize">Font size in points.</param> public SpriteFontTTF(FontSource source, FontFamily family, int fontSize) { this.FontFamily = family; this.FontSource = source; this.FontSize = fontSize * pointsToPixels; measuringTextBlock = new TextBlock() { FontSize = FontSize, FontFamily = FontFamily, FontSource = FontSource }; }
/// <summary> /// Initializes a new instance of the FontViewModel class. /// </summary> public FontViewModel() { GalaSoft.MvvmLight.Messaging.Messenger.Default.Register<Messaging.FontSelected>(this, onFontSelected); _familyMaps = new System.Collections.ObjectModel.ObservableCollection<FontFamilyMap>(); _familyNames = new System.Collections.ObjectModel.ObservableCollection<KeyValuePair<string, string>>(); _familyTypeFaces = new System.Collections.ObjectModel.ObservableCollection<FamilyTypeface>(); if (this.IsInDesignMode) { var ff = new System.Windows.Media.FontFamily("Arial"); loadFont(ff); } }
internal SystemFont(FontFamily rpFontFamily) { FontFamily = rpFontFamily; var rNames = rpFontFamily.FamilyNames; string rName; if (rNames.TryGetValue(XmlLanguage.GetLanguage("ja-jp"), out rName) || rNames.TryGetValue(XmlLanguage.GetLanguage("zh-cn"), out rName) || rNames.TryGetValue(XmlLanguage.GetLanguage("zh-tw"), out rName) || rNames.TryGetValue(XmlLanguage.GetLanguage("zh-hk"), out rName) || rNames.TryGetValue(XmlLanguage.GetLanguage("en-us"), out rName)) Name = rName; else Name = rpFontFamily.ToString(); }
/// <summary> /// Create a object represents danmaku style. /// </summary> /// <param name="Duration">Danmaku duration for disapper (ms)</param> /// <param name="Content">Danmaku content</param> /// <param name="ColorR">Danmaku Color - Red</param> /// <param name="ColorG">Danmaku Color - Green</param> /// <param name="ColorB">Danmaku Color - Blue</param> /// <param name="FontSize">Danmaku font size</param> /// <param name="Outline">Enable danmaku outline stroke</param> /// <param name="Shadow">Enable danmaku shadow (low performance)</param> /// <param name="Font">Danmaku font style (Default: Microsoft YaHei)</param> /// <param name="PositionX">Danmaku start position - X</param> /// <param name="PositionY">Danmaku start position - Y</param> public BaseDanmaku(int Duration = 9000, byte ColorR = 255, byte ColorG = 255, byte ColorB = 255, int FontSize = 30, bool Outline = true, bool Shadow = false, FontFamily Font = null, double PositionX = 0, double PositionY = 0) { this.ColorR = ColorR; this.ColorG = ColorG; this.ColorB = ColorB; this.FontSize = FontSize; this.Outline = Outline; this.Shadow = Shadow; this.FontFamily = Font; this.PositionX = PositionX; this.PositionY = PositionY; this.Duration = Duration; }
public CodeCanvas() { InitializeComponent(); AcceptsReturn = false; FontFamily = new System.Windows.Media.FontFamily("Lucida console"); FontSize = 12; DependencyPropertyDescriptor .FromProperty(Control.FontSizeProperty, typeof(CodeCanvas)) .AddValueChanged(this, FontSizeChanged); DependencyPropertyDescriptor .FromProperty(Control.FontFamilyProperty, typeof(CodeCanvas)) .AddValueChanged(this, FontFamilyChanged); FontSizeChanged(this, new EventArgs()); FontFamilyChanged(this, new EventArgs()); }
public static FontFamily GetFontFamily(this DataNew.Entities.Font font, FontFamily defaultFont) { if (!System.IO.File.Exists(font.Src)) return defaultFont; using(var pf = new System.Drawing.Text.PrivateFontCollection()) { pf.AddFontFile(font.Src); if(pf.Families.Length == 0) { Log.WarnFormat("Could not load font {0}", font.Src); return defaultFont; } string font1 = "file:///" + Path.GetDirectoryName(font.Src) + "/#" + pf.Families[0].Name; Log.Info(string.Format("Loading font with path: {0}", font1).Replace("\\", "/")); var ret = new FontFamily(font1.Replace("\\", "/") + ", " + defaultFont.Source); return ret; } }
internal static string GetFamilyName(FontFamily fontFamily) { if (fontFamily == null) { return "Arial"; } try { //TODO Potentiell gefährlich wenn auf dem Server andere Sprache ist. var currentLanguage = CultureInfo.CurrentUICulture.IetfLanguageTag; var currentXmlLanguage = XmlLanguage.GetLanguage(currentLanguage); if (fontFamily.FamilyNames.ContainsKey(currentXmlLanguage)) { return fontFamily.FamilyNames[currentXmlLanguage]; } var defaultLanguage = CultureInfo.InvariantCulture.IetfLanguageTag; var defaultXmlLanguage = XmlLanguage.GetLanguage(defaultLanguage); if (fontFamily.FamilyNames.ContainsKey(defaultXmlLanguage)) { return fontFamily.FamilyNames[defaultXmlLanguage]; } // ReSharper disable once AssignNullToNotNullAttribute var fontName = fontFamily.FamilyNames.Values.FirstOrDefault(); if (string.IsNullOrEmpty(fontName)) { return fontFamily.Source; // throw new InvalidOperationException("No FontName for Font available"); } return fontName; } catch (Exception) { return fontFamily.Source; } }
public override IEnumerable<KeyValuePair<string, object>> GetAvailableFamilyFaces (string family) { FontFamily wpfFamily; if (!registeredFonts.TryGetValue (family, out wpfFamily)) // check for custom fonts wpfFamily = new FontFamily (family); foreach (var face in wpfFamily.GetTypefaces ()) { var langCurrent = SW.Markup.XmlLanguage.GetLanguage (CultureInfo.CurrentCulture.IetfLanguageTag); var langInvariant = SW.Markup.XmlLanguage.GetLanguage ("en-us");; string name; if (face.FaceNames.TryGetValue (langCurrent, out name) || face.FaceNames.TryGetValue (langInvariant, out name)) { var fontData = new FontData (wpfFamily, 0) { Style = face.Style, Weight = face.Weight, Stretch = face.Stretch }; yield return new KeyValuePair<string, object> (name, fontData); } } yield break; }
// Implementation Notes // FontFamilyInternal implements an XFontFamily. // // * Each XFontFamily object is just a handle to its FontFamilyInternal singleton. // // * A FontFamilyInternal is is uniquely identified by its name. It // is not possible to use two different fonts that have the same // family name. FontFamilyInternal(string familyName, bool createPlatformObjects) { _sourceName = _name = familyName; #if CORE || GDI if (createPlatformObjects) { _gdiFontFamily = new GdiFontFamily(familyName); _name = _gdiFontFamily.Name; } #endif #if WPF && !SILVERLIGHT if (createPlatformObjects) { _wpfFontFamily = new WpfFontFamily(familyName); _name = _wpfFontFamily.FamilyNames[FontHelper.XmlLanguageEnUs]; } #endif #if SILVERLIGHT _wpfFontFamily = new WpfFontFamily(_name); _name = _wpfFontFamily.Source; // Not expected to change _name. #endif }
public static void ApplyLegacyFont(System.Windows.FrameworkElement element, Font font) { var style = System.Windows.FontStyles.Normal; if (font.Italic) { style = System.Windows.FontStyles.Italic; } var weight = System.Windows.FontWeights.Normal; if (font.Bold) { weight = System.Windows.FontWeights.Bold; } float size = (float) ((font.Size * 96.0) / 72.0); var family = new System.Windows.Media.FontFamily(font.FontFamily.Name); if (element is Control) { var control = element as Control; control.FontFamily = family; control.FontSize = size; control.FontStyle = style; control.FontWeight = weight; } if (element is TextBlock) { var textBlock = element as TextBlock; textBlock.FontFamily = family; textBlock.FontSize = size; textBlock.FontStyle = style; textBlock.FontWeight = weight; if (font.Underline) { textBlock.TextDecorations.Add(System.Windows.TextDecorations.Underline); } if (font.Strikeout) { textBlock.TextDecorations.Add(System.Windows.TextDecorations.Strikethrough); } } }
/// <summary> /// 読み込み /// </summary> /// <param name="tailerElement"></param> public void Load( XmlElement tailerElement ) { // 属性 foreach( XmlAttribute attribute in tailerElement.Attributes ) { var attributeName = attribute.Name.ToLower(); switch( attributeName ) { case "fontfamily": FontFamily = new FontFamily( attribute.Value ); break; case "fontsize": FontSize = double.Parse( attribute.Value ); break; default: Debug.Assert( false, "未知の属性 attributeName={0}", attributeName ); break; } } // 要素 foreach( XmlNode childNode in tailerElement.ChildNodes ) { var elementName = childNode.Name.ToLower(); switch( elementName ) { case "tailer": var tailer = new Tailer(); tailer.Load( childNode as XmlElement ); Tailers.Add( tailer ); break; default: Debug.Assert( false, "未知の要素 elementName={0}", elementName ); break; } } }
/// <summary> /// Loads the content of a source file in the editor /// </summary> public TypeCobolEditor(CobolFile sourceFile) { TextView textView = TextArea.TextView; // Default text style FontFamily = new FontFamily("Consolas"); FontSize = 13; // Show line numbers ShowLineNumbers = true; // Activate search box SearchPanel.Install(this); // Plug in TypeCobol syntax highlighting syntaxHighlighter = new SyntaxHighlighter(); textView.LineTransformers.Add(syntaxHighlighter); // Plug in TypeCobol error marker errorMarker = new ErrorMarker(this); textView.BackgroundRenderers.Add(errorMarker); textView.LineTransformers.Add(errorMarker); // Tooltip management tooltipManager = new TooltipManager(this, errorMarker); textView.MouseHover += tooltipManager.MouseHover; textView.MouseHoverStopped += tooltipManager.MouseHoverStopped; textView.VisualLinesChanged += tooltipManager.VisualLinesChanged; // Initial load of the cobol file if necessary if (sourceFile != null) { Document = new ICSharpCode.AvalonEdit.Document.TextDocument(sourceFile.ReadChars()); } // Wrap the AvalonEdit.Document in a ITextDocument interface textDocument = new AvalonEditTextDocument(Document, IBMCodePages.GetDotNetEncodingFromIBMCCSID(1147), ColumnsLayout.CobolReferenceFormat); }