public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { string str = value as string; FontFamilyConverter converter = new FontFamilyConverter(); if (str != null && str.Length > 0) { return(converter.ConvertFromString(str)); } else { return(converter.ConvertFromString("宋体")); } }
private void button8_Click(object sender, RoutedEventArgs e) { if (selTB != null) { selTB.Foreground = ChooseColor(); using (System.Windows.Forms.FontDialog fd = new System.Windows.Forms.FontDialog()) { try { fd.AllowScriptChange = false; fd.AllowSimulations = false; if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { FontFamilyConverter ffc = new FontFamilyConverter(); selTB.FontSize = fd.Font.Size; selTB.FontFamily = (FontFamily)ffc.ConvertFromString(fd.Font.Name); } } catch { //Not a truetype font MessageBox.Show("Шрифт не изменен"); } } } }
private void FountSetting(Font font) { FontFamilyConverter ffc = new FontFamilyConverter(); _showMainWindow.FontSize = font.Size; _showMainWindow.FontFamily = (FontFamily)ffc.ConvertFromString(font.Name); if (font.Bold) { _showMainWindow.FontWeight = FontWeights.Bold; } else { _showMainWindow.FontWeight = FontWeights.Normal; } if (font.Italic) { _showMainWindow.FontStyle = FontStyles.Italic; } else { _showMainWindow.FontStyle = FontStyles.Normal; } }
public void addPhoto(string path) { StackPanel sp = new StackPanel(); Label label = new Label(); label.HorizontalContentAlignment = HorizontalAlignment.Center; label.FontStyle = FontStyles.Italic; FontFamilyConverter ffc = new FontFamilyConverter(); FontFamily f = ffc.ConvertFromString("Calibri") as FontFamily; label.FontFamily = f; Image img = new Image(); sp.Children.Add(img); sp.Children.Add(label); BitmapImage bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.UriSource = new Uri(path); bitmap.EndInit(); img.ToolTip = "Press space to preview photo"; img.Source = bitmap; label.Content = System.IO.Path.GetFileName(img.Source.ToString()); img.Height = 128; img.Width = 135; selectListBox.Items.Add(sp); }
private FontFamily GetFontFamily() { var fontFamilyConverter = new FontFamilyConverter(); var fontFamily = (FontFamily)fontFamilyConverter.ConvertFromString(FontFamily); return(fontFamily); }
private void MenuItemFontChange_Clicked(object sender, RoutedEventArgs e) { System.Windows.Forms.FontDialog fontDialog = new System.Windows.Forms.FontDialog(); fontDialog.Font = new System.Drawing.Font(EditText1.FontFamily.ToString(), (float)EditText1.FontSize); if (fontDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { FontFamilyConverter ffc = new FontFamilyConverter(); EditText1.FontSize = (double)fontDialog.Font.Size; EditText1.FontFamily = (FontFamily)ffc.ConvertFromString(fontDialog.Font.Name); /* * if (fontDialog.Font.Bold) * textAnnotation.FontWeight = FontWeights.Bold; * else * textAnnotation.FontWeight = FontWeights.Normal; * * if (fontDialog.Font.Italic) * textAnnotation.FontStyle = FontStyles.Italic; * else * textAnnotation.FontStyle = FontStyles.Normal; */ } }
public void ChangeFontStyle(string fontType, int size) { FontFamilyConverter converter = new FontFamilyConverter(); txtMainArea.FontFamily = converter.ConvertFromString(fontType) as FontFamily; txtMainArea.FontSize = size; }
private void SetFont(TextBox textBox, System.Drawing.Font font) { FontFamilyConverter ffc = new FontFamilyConverter(); textBox.FontSize = font.Size; textBox.FontFamily = (FontFamily)ffc.ConvertFromString(font.Name); if (font.Bold) { textBox.FontWeight = FontWeights.Bold; } else { textBox.FontWeight = FontWeights.Normal; } if (font.Italic) { textBox.FontStyle = FontStyles.Italic; } else { textBox.FontStyle = FontStyles.Normal; } }
private void UpdateEmpiricalFormula(string empiricalFormula) { var paragraph = new Paragraph(); var ffc = new FontFamilyConverter(); paragraph.FontFamily = (FontFamily)ffc.ConvertFromString("Palatino Linotype"); foreach (var empiricalCharacter in empiricalFormula) { var run = new Run(empiricalCharacter.ToString()); // Subscript any numbers if (Char.IsNumber(empiricalCharacter)) { run.Typography.Variants = FontVariants.Subscript; } paragraph.Inlines.Add(run); } var flowDocument = new FlowDocument(); flowDocument.Blocks.Add(paragraph); EmpiricalFormulaRichTextBlock.Document = flowDocument; }
/// <summary> /// Internal API for loading text. Sets a text block's font family. (INLINE OVERLOAD) /// </summary> /// <param name="FBlockToSet">The Block to set the fontfamily of.</param> /// <param name="FontFamily">The font family in string form to set the Block's font family to.</param> /// <returns>An Inline with the font family set.</returns> internal Inline FMXAML_TextAPI_SetFontFamily(Inline FBlockToSet, string FontFamily) // Sets the font family. { FontFamilyConverter _FontFamilyConverter = new FontFamilyConverter(); FontFamily _FinalFontFamily = (FontFamily)_FontFamilyConverter.ConvertFromString(FontFamily); FBlockToSet.FontFamily = _FinalFontFamily; return(FBlockToSet); }
private static FontFamily GetThemeFont(string element, string attribute, FontFamily fallback) { try { return((FontFamily)_fontConverter.ConvertFromString(GetThemeValue(element, attribute))); } catch { return(fallback); } }
private void ComboBoxFonts_SelectionChanged(object sender, SelectionChangedEventArgs e) { FontFamilyConverter converter = new FontFamilyConverter(); ComboBoxItem selectedItem = e.AddedItems[0] as ComboBoxItem; string fontSelected = selectedItem.Content.ToString(); fontStyle = fontSelected; TextBoxPresentText.FontFamily = converter.ConvertFromString(fontSelected) as FontFamily; }
private void initialStyleSettings() { XmlDocument doc = new XmlDocument(); doc.PreserveWhitespace = true; try { doc.Load("BasicConfiguration.xml"); } catch (System.IO.FileNotFoundException) { //If file will not exists create it! doc.LoadXml("<style> \n" + " <fontFamily>Linux Libertine Display G</fontFamily> \n" + " <fontSize>12</fontSize> \n" + " <background>#FFFFFFFF</background> \n" + " <foreground>#FF000000</foreground> \n" + "</style>"); } XmlNode root = doc.FirstChild; if (root.HasChildNodes) { for (int i = 0; i < root.ChildNodes.Count; i++) { XmlElement elementXml = root.ChildNodes[i] as XmlElement; //It means that given element is \r\n if (elementXml != null) { BrushConverter c = new BrushConverter(); FontFamilyConverter converter = new FontFamilyConverter(); SolidColorBrush b; switch (elementXml.LocalName) { case "fontFamily": txtMainArea.FontFamily = converter.ConvertFromString(elementXml.InnerText) as FontFamily; break; case "fontSize": txtMainArea.FontSize = Convert.ToInt32(elementXml.InnerText); break; case "background": b = c.ConvertFromString(elementXml.InnerText) as SolidColorBrush; txtMainArea.Background = b; break; case "foreground": b = c.ConvertFromString(elementXml.InnerText) as SolidColorBrush; txtMainArea.Foreground = b; break; } } } } }
private void SetFont(string fontName) { FontFamilyConverter fontConverter = new FontFamilyConverter(); FontFamily font = fontConverter.ConvertFromString(fontName).To <FontFamily>(); this.uxMainMenu.FontFamily = font; foreach (Window window in Application.Current.Windows) { window.FontFamily = font; } }
/// <summary> /// Returns the width of the given string, using Segoe UI font /// </summary> /// <param name="str">String whose width we would like to calculate</param> /// <param name="fontSize">Fontsize to use for the string</param> /// <returns>Width the string will take on the UI using the Segoe UI font</returns> private double GetStringWidth(string str, double fontSize) { FontFamilyConverter converter = new FontFamilyConverter(); FormattedText formattedText = new FormattedText( str, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, new Typeface((FontFamily)converter.ConvertFromString("Segoe UI"), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal), fontSize, Brushes.Black); return(formattedText.Width); }
private void prepareTextEditor(TextEditor textEditor) { FontFamilyConverter conv = new FontFamilyConverter(); BrushConverter brconv = new BrushConverter(); System.Windows.Markup.XmlLanguageConverter langconv = new System.Windows.Markup.XmlLanguageConverter(); textEditor.FontFamily = (FontFamily)conv.ConvertFromString("Consolas"); textEditor.FontSize = 12; textEditor.Background = (Brush)brconv.ConvertFromString("White"); textEditor.Language = (System.Windows.Markup.XmlLanguage)langconv.ConvertFromString("XML"); textEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("XML"); textEditor.ShowLineNumbers = true; textEditor.IsReadOnly = false; textEditor.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (AppConfig.GetAppConfig("Exists") == null || AppConfig.GetAppConfig("Exists") != "True") { return; } var cvt = new FontFamilyConverter(); NpsBlock.FontFamily = KeyBlock.FontFamily = (FontFamily)cvt.ConvertFromString(AppConfig.GetAppConfig("Font")); NpsBlock.FontStyle = KeyBlock.FontStyle = Convert.ToBoolean(AppConfig.GetAppConfig("Italic")) ? FontStyles.Italic : FontStyles.Normal; NpsBlock.TextDecorations = KeyBlock.TextDecorations = Convert.ToBoolean(AppConfig.GetAppConfig("Underline")) ? TextDecorations.Underline : null; isGradation = GradationMenu.IsChecked = Convert.ToBoolean(AppConfig.GetAppConfig("Gradation")); var fontclr = AppConfig.GetAppConfig("FontColor").Split(','); NpsBlock.Foreground = KeyBlock.Foreground = new SolidColorBrush(new Color { A = Convert.ToByte(fontclr[0]), R = Convert.ToByte(fontclr[1]), G = Convert.ToByte(fontclr[2]), B = Convert.ToByte(fontclr[3]) }); var back = AppConfig.GetAppConfig("Background"); if (back.StartsWith("I>")) { MainGrid.Background = new ImageBrush(new BitmapImage(new Uri(back.Substring(2)))); } else { var split = back.Split(','); MainGrid.Background = new SolidColorBrush(new Color { A = Convert.ToByte(split[0]), R = Convert.ToByte(split[1]), G = Convert.ToByte(split[2]), B = Convert.ToByte(split[3]) }); } isDecimal = DecimalMenu.IsChecked = Convert.ToBoolean(AppConfig.GetAppConfig("Decimal")); }
private void btnReset_Click(object sender, RoutedEventArgs e) { try { FontFamilyConverter converter = new FontFamilyConverter(); FontFamily consolas = (FontFamily)converter.ConvertFromString("Consolas"); Properties.Settings.Default.EditorFontFace = consolas; this.fontSizeSlider.Value = 13d; Properties.Settings.Default.EditorForeground = Colors.Black; Properties.Settings.Default.EditorBackground = Colors.White; Properties.Settings.Default.Save(); } catch { //Can't reset settings } //Show settings this.ShowSettings(); }
private void FontTypeClick(object sender, RoutedEventArgs e) { System.Windows.Forms.FontDialog fd = new System.Windows.Forms.FontDialog(); var fontstyle = video.FontWeight == FontWeights.Normal ? System.Drawing.FontStyle.Regular : System.Drawing.FontStyle.Bold; fontstyle |= video.FontStyle == FontStyles.Italic ? System.Drawing.FontStyle.Italic : System.Drawing.FontStyle.Regular; fd.Font = new System.Drawing.Font( video.FontFamily.Source, (float)(video.FontSize * 72d / 96d), fontstyle); if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { FontFamilyConverter ffc = new FontFamilyConverter(); var selectedFont = fd.Font; video.FontFamily = (FontFamily)ffc.ConvertFromString(selectedFont.Name); video.FontSize = selectedFont.Size * 96.0 / 72.0; video.FontWeight = selectedFont.Bold ? FontWeights.Bold : FontWeights.Regular; video.FontStyle = selectedFont.Italic ? FontStyles.Italic : FontStyles.Normal; } }
public static object GetDPValueFromStr(this DependencyProperty dp, string str) { if (str == null) { return(null); } Type type = dp.PropertyType; if (type.IsEnum) { return(Enum.Parse(type, str)); } if (type == typeof(double)) { return(double.Parse(str)); } if (type == typeof(float)) { return(float.Parse(str)); } if (type == typeof(decimal)) { return(decimal.Parse(str)); } if (type == typeof(string)) { return(str); } if (type == typeof(bool)) { return(bool.Parse(str)); } if (type == typeof(byte)) { return(byte.Parse(str)); } if (type == typeof(int)) { return(int.Parse(str)); } if (type == typeof(char)) { return(char.Parse(str)); } if (type == typeof(Brush)) { if (string.IsNullOrEmpty(str)) { return(null); } Color color = (Color)ColorConverter.ConvertFromString(str); return(new SolidColorBrush(color)); } if (type == typeof(Thickness)) { return(_thicknessConverter.ConvertFromString(str)); } if (type == typeof(FontFamily)) { return(_fontFamilyConverter.ConvertFromString(str)); } if (type == typeof(FontWeight)) { return(_fontWeightConverter.ConvertFromString(str)); } if (type == typeof(Point)) { return(_pointConverter.ConvertFromString(str)); } return(str); }
private void Display() { nickNameL.Content = ChatMessageP[MesKeyStr.NickName] + "(" + ChatMessageP[MesKeyStr.UserID] + ")"; ipAdressL.Content = ChatMessageP[MesKeyStr.IP]; timeL.Content = ChatMessageP[MesKeyStr.DateTime]; if ((DisplayMethodP == DisplayMethod.OnlyRemark || DisplayMethodP == DisplayMethod.Both) && ChatMessageP.ContainsKey(MesKeyStr.Remark)) { remarkL.Content = ChatMessageP[MesKeyStr.Remark]; } if (DisplayMethodP == DisplayMethod.OnlyRemark || DisplayMethodP == DisplayMethod.None) { contentB.Background = null; contentB.Margin = new Thickness(5, 0, 5, 5); contentTB.Margin = new Thickness(0); } if ((MessageType)Enum.Parse(typeof(MessageType), ChatMessageP[MesKeyStr.MessageType]) == MessageType.Text) { string content = StaticStuff.RepToSep(ChatMessageP[MesKeyStr.Content]); contentTB.ToolTip = content; contentTB.Text = content; if (DisplayMethodP == DisplayMethod.OnlyStyle || DisplayMethodP == DisplayMethod.Both) { FontFamilyConverter fontFamilyConverter = new FontFamilyConverter(); try { contentTB.FontFamily = (FontFamily)fontFamilyConverter.ConvertFromString(ChatMessageP[MesKeyStr.FontFamily]); } catch (Exception e) { MessageBox.Show(e.Message + e.StackTrace); } contentTB.FontSize = int.Parse(ChatMessageP[MesKeyStr.FontSize]); if (int.Parse(ChatMessageP[MesKeyStr.FontStyle]) % 10 == 1) { contentTB.FontWeight = FontWeights.Bold; } if (int.Parse(ChatMessageP[MesKeyStr.FontStyle]) / 10 % 10 == 1) { contentTB.FontStyle = FontStyles.Italic; } if (int.Parse(ChatMessageP[MesKeyStr.FontStyle]) / 100 % 10 == 1) { contentTB.TextDecorations = TextDecorations.Underline; } contentTB.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString(ChatMessageP[MesKeyStr.FontColor])); } } else { string base64String = ChatMessageP[MesKeyStr.Base64String]; if (Directory.Exists("Image") == false) { Directory.CreateDirectory("Image"); } imagePath = "Image\\" + DateTime.Now.ToString("yyyyMMddhhmmss") + DateTime.Now.Millisecond + ".jpg"; byte[] buffer = Convert.FromBase64String(base64String); File.WriteAllBytes(imagePath, buffer); BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = new MemoryStream(buffer); bitmapImage.EndInit(); Image image = new Image(); image.MaxHeight = 300; image.ToolTip = "双击查看原图"; image.Source = bitmapImage; imageCC.Content = image; } }
// // Tablet View Constructor // public WindowTabletView(Configuration config, TabletDriver driver) { if (config.TabletView.Borderless) { WindowStyle = WindowStyle.None; } InitializeComponent(); this.config = config; this.driver = driver; // Tablet renderer tabletRenderer = new TabletRenderer(config); canvasTabletView.Children.Add(tabletRenderer); // Offset texts Canvas.SetLeft(textTabletInfo, Canvas.GetLeft(textTabletInfo) + config.TabletView.OffsetText.X); Canvas.SetTop(textTabletInfo, Canvas.GetTop(textTabletInfo) + config.TabletView.OffsetText.Y); Canvas.SetLeft(textInput, Canvas.GetLeft(textInput) + config.TabletView.OffsetText.X); Canvas.SetTop(textInput, Canvas.GetTop(textInput) + config.TabletView.OffsetText.Y); Canvas.SetLeft(textOutput, Canvas.GetLeft(textOutput) + config.TabletView.OffsetText.X); Canvas.SetTop(textOutput, Canvas.GetTop(textOutput) + config.TabletView.OffsetText.Y); Canvas.SetLeft(textLatency, Canvas.GetLeft(textLatency) + config.TabletView.OffsetText.X); Canvas.SetTop(textLatency, Canvas.GetTop(textLatency) + config.TabletView.OffsetText.Y); // Background color Brush brush; try { brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(config.TabletView.BackgroundColor)); } catch (Exception) { brush = Brushes.White; } canvasTabletView.Background = brush; Background = brush; // Text colors try { brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(config.TabletView.InfoColor)); } catch (Exception) { brush = Brushes.Black; } textTabletInfo.Foreground = brush; try { brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(config.TabletView.LatencyColor)); } catch (Exception) { brush = Brushes.Black; } textLatency.Foreground = brush; textInput.Foreground = tabletRenderer.brushInput; textOutput.Foreground = tabletRenderer.brushOutput; // Text font try { FontFamilyConverter fontConverter = new FontFamilyConverter(); FontFamily fontFamily = (FontFamily)fontConverter.ConvertFromString(config.TabletView.Font); textTabletInfo.FontFamily = fontFamily; textInput.FontFamily = fontFamily; textOutput.FontFamily = fontFamily; textLatency.FontFamily = fontFamily; } catch (Exception) { } // Font size textTabletInfo.FontSize = config.TabletView.FontSize; textInput.FontSize = config.TabletView.FontSize; textOutput.FontSize = config.TabletView.FontSize; textLatency.FontSize = config.TabletView.FontSize; // Info text textTabletInfo.Text = config.TabletName + " - " + Utils.GetNumberString(config.TabletAreas[0].Width) + " x " + Utils.GetNumberString(config.TabletAreas[0].Height) + " mm → " + Utils.GetNumberString(config.ScreenAreas[0].Width, "0") + " x " + Utils.GetNumberString(config.ScreenAreas[0].Height, "0") + " px"; // // Update/draw timer // timer = new MultimediaTimer { Interval = 2 }; timer.Tick += UpdateTimer_Tick; // Last values lastPosition = new Vector(0, 0); lastUpdate = DateTime.Now; lastPressure = 0; // Average values velocity = 0; latency = 0; // Input loss hadInputLoss = true; lastInputStartTime = DateTime.Now; // Window events Loaded += WindowTabletView_Loaded; Closing += WindowTabletView_Closing; KeyDown += WindowTabletView_KeyDown; MouseDown += WindowTabletView_MouseDown; MouseUp += WindowTabletView_MouseUp; // Set GC mode to low latency GCSettings.LatencyMode = GCLatencyMode.SustainedLowLatency; }
private void SettingFont() { using (var fontDialog = new System.Windows.Forms.FontDialog()) { fontDialog.Font = new System.Drawing.Font(m_strFontName, m_fFontSize, m_fontStyle); fontDialog.ShowColor = true; fontDialog.Color = m_fontColor; if (fontDialog.ShowDialog() != System.Windows.Forms.DialogResult.Cancel) { FontFamilyConverter ffc = new FontFamilyConverter(); this.messageEditBox.FontSize = fontDialog.Font.Size / 72 * 96; this.messageEditBox.FontFamily = (System.Windows.Media.FontFamily)ffc.ConvertFromString(fontDialog.Font.Name); if (fontDialog.Font.Bold) { this.messageEditBox.FontWeight = FontWeights.Bold; } else { this.messageEditBox.FontWeight = FontWeights.Normal; } if (fontDialog.Font.Italic) { this.messageEditBox.FontStyle = FontStyles.Italic; } else { this.messageEditBox.FontStyle = FontStyles.Normal; } BrushConverter bc = new BrushConverter(); this.messageEditBox.Foreground = (System.Windows.Media.Brush)bc.ConvertFromString(fontDialog.Color.Name); m_strFontName = fontDialog.Font.Name; m_fFontSize = fontDialog.Font.Size; m_fontStyle = fontDialog.Font.Style; m_fontColor = fontDialog.Color; } } }
/// <summary> /// Deserializes the font family. /// </summary> /// <param name="fontFamily">The font family.</param> /// <returns>The deserialized font family.</returns> public static FontFamily DeserializeFontFamily(string fontFamily) { var converter = new FontFamilyConverter(); return((FontFamily)converter.ConvertFromString(fontFamily)); }
private void canvas_MouseDown(object sender, MouseButtonEventArgs e) { //khoi tao gia tri startPoint = e.GetPosition(canvas); tempStart = startPoint; color = cboColor.Text; stroke = int.Parse(cboStroke.Text); sizeEraser = int.Parse(cboSizeEraser.Text); //bien convert color var bc = new BrushConverter(); //if (arrayMN != null) //{ // arrayMN[0].sRect.IsHitTestVisible = true; // arrayMN[0].sContent.SetValue(Selector.IsSelectedProperty, true); // arrayMN[0].sContent = null; // arrayMN[0].sRect = null; //} //set gia tri tung truong hop switch (key) { case 1: { _line = new Line(); _line.Stroke = (Brush)bc.ConvertFrom(color); _line.StrokeThickness = stroke; canvas.Children.Add(_line); } break; case 2: { _rectange = new Rectangle(); _rectange.Stroke = (Brush)bc.ConvertFrom(color); _rectange.StrokeThickness = stroke; if (chekFill.IsChecked == true) { _rectange.Fill = (Brush)bc.ConvertFrom(color); } canvas.Children.Add(_rectange); } break; case 3: { _ellipes = new Ellipse(); _ellipes.Stroke = (Brush)bc.ConvertFrom(color); _ellipes.StrokeThickness = stroke; if (chekFill.IsChecked == true) { _ellipes.Fill = (Brush)bc.ConvertFrom(color); } canvas.Children.Add(_ellipes); } break; case 5: { flagSizeEraser = true; } break; case 6: { var mn = new FontFamilyConverter(); TextBox lb = new TextBox(); lb.Text = "Add text...."; lb.FontFamily = (FontFamily)mn.ConvertFromString(cboFontFamily.Text); lb.FontSize = int.Parse(cboFontSize.Text); lb.Foreground = (Brush)bc.ConvertFrom(color); lb.BorderBrush = Brushes.White; canvas.Children.Add(lb); Canvas.SetTop(lb, startPoint.Y); Canvas.SetLeft(lb, startPoint.X); } break; case 7: { _star = new System.Windows.Shapes.Path(); _star.Stroke = (Brush)bc.ConvertFrom(color); _star.StrokeThickness = stroke; if (chekFill.IsChecked == true) { _star.Fill = (Brush)bc.ConvertFrom(color); } canvas.Children.Add(_star); } break; case 8: { _heart = new System.Windows.Shapes.Path(); _heart.Stroke = (Brush)bc.ConvertFrom(color); _heart.StrokeThickness = stroke; if (chekFill.IsChecked == true) { _heart.Fill = (Brush)bc.ConvertFrom(color); } canvas.Children.Add(_heart); } break; case 9: { _arrow = new System.Windows.Shapes.Path(); _arrow.Stroke = (Brush)bc.ConvertFrom(color); _arrow.StrokeThickness = stroke; if (chekFill.IsChecked == true) { _arrow.Fill = (Brush)bc.ConvertFrom(color); } canvas.Children.Add(_arrow); } break; } }
/// <summary> /// Font colour document. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Font_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.FontDialog fontDialog = new System.Windows.Forms.FontDialog(); // If ok. if (fontDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { // Get the selected text. TextSelection text = mainRTB.Selection; if (!text.IsEmpty) { // Font family converter. FontFamilyConverter ffc = new FontFamilyConverter(); // Apply the properties to the text. text.ApplyPropertyValue(RichTextBox.FontSizeProperty, (double)fontDialog.Font.Size); text.ApplyPropertyValue(RichTextBox.FontFamilyProperty, (FontFamily)ffc.ConvertFromString(fontDialog.Font.Name)); // Apply the properties to the text. if (fontDialog.Font.Bold) { text.ApplyPropertyValue(RichTextBox.FontWeightProperty, FontWeights.Bold); } else { text.ApplyPropertyValue(RichTextBox.FontWeightProperty, FontWeights.Normal); } // Apply the properties to the text. if (fontDialog.Font.Italic) { text.ApplyPropertyValue(RichTextBox.FontStyleProperty, FontStyles.Italic); } else { text.ApplyPropertyValue(RichTextBox.FontStyleProperty, FontStyles.Normal); } } } }