private void Button_Align_OnCheckChanged(object sender, bool IsChecked) { if (sender == Button_LeftAlign) { txt.Selection.ApplyPropertyValue(Paragraph.TextAlignmentProperty, TextAlignment.Left); Button_LeftAlign.SetCheckedNoCall(true); Button_RightAlign.SetCheckedNoCall(false); Button_CenterAlign.SetCheckedNoCall(false); Button_JustifyAlign.SetCheckedNoCall(false); } else if (sender == Button_CenterAlign) { txt.Selection.ApplyPropertyValue(Paragraph.TextAlignmentProperty, TextAlignment.Center); Button_RightAlign.SetCheckedNoCall(false); Button_JustifyAlign.SetCheckedNoCall(false); Button_LeftAlign.SetCheckedNoCall(false); Button_CenterAlign.SetCheckedNoCall(true); } else if (sender == Button_RightAlign) { txt.Selection.ApplyPropertyValue(Paragraph.TextAlignmentProperty, TextAlignment.Right); Button_CenterAlign.SetCheckedNoCall(false); Button_JustifyAlign.SetCheckedNoCall(false); Button_LeftAlign.SetCheckedNoCall(false); Button_RightAlign.SetCheckedNoCall(true); } else if (sender == Button_JustifyAlign) { txt.Selection.ApplyPropertyValue(Paragraph.TextAlignmentProperty, TextAlignment.Justify); Button_RightAlign.SetCheckedNoCall(false); Button_CenterAlign.SetCheckedNoCall(false); Button_LeftAlign.SetCheckedNoCall(false); Button_JustifyAlign.SetCheckedNoCall(true); } }
public void SetData(HorizontalAlignment horAl, VerticalAlignment verAl) { if (horAl == HorizontalAlignment.Left) { Button_LeftAlign.SetCheckedNoCall(true); } else if (horAl == HorizontalAlignment.Center) { Button_CenterAlign.SetCheckedNoCall(true); } else if (horAl == HorizontalAlignment.Right) { Button_RightAlign.SetCheckedNoCall(true); } if (verAl == VerticalAlignment.Top) { Button_VTopAlign.SetCheckedNoCall(true); } else if (verAl == VerticalAlignment.Center) { Button_VCenterAlign.SetCheckedNoCall(true); } else if (verAl == VerticalAlignment.Bottom) { Button_VBottomAlign.SetCheckedNoCall(true); } val = verAl; hal = horAl; }
private void Button_Align_OnCheckChanged(object sender, bool IsChecked) { if (sender == Button_LeftAlign) { hal = HorizontalAlignment.Left; Button_LeftAlign.SetCheckedNoCall(true); Button_RightAlign.SetCheckedNoCall(false); Button_CenterAlign.SetCheckedNoCall(false); } else if (sender == Button_CenterAlign) { hal = HorizontalAlignment.Center; Button_RightAlign.SetCheckedNoCall(false); Button_LeftAlign.SetCheckedNoCall(false); Button_CenterAlign.SetCheckedNoCall(true); } else if (sender == Button_RightAlign) { hal = HorizontalAlignment.Right; Button_CenterAlign.SetCheckedNoCall(false); Button_LeftAlign.SetCheckedNoCall(false); Button_RightAlign.SetCheckedNoCall(true); } else if (sender == Button_VTopAlign) { val = VerticalAlignment.Top; Button_VCenterAlign.SetCheckedNoCall(false); Button_VBottomAlign.SetCheckedNoCall(false); Button_VTopAlign.SetCheckedNoCall(true); } else if (sender == Button_VCenterAlign) { val = VerticalAlignment.Center; Button_VTopAlign.SetCheckedNoCall(false); Button_VBottomAlign.SetCheckedNoCall(false); Button_VCenterAlign.SetCheckedNoCall(true); } else if (sender == Button_VBottomAlign) { val = VerticalAlignment.Bottom; Button_VTopAlign.SetCheckedNoCall(false); Button_VCenterAlign.SetCheckedNoCall(false); Button_VBottomAlign.SetCheckedNoCall(true); } if (ChangedAlign != null) { ChangedAlign(hal, val); } }
private void Txt_SelectionChanged(object sender, RoutedEventArgs e) { try { if (txt.Selection.GetPropertyValue(FontSizeProperty) == DependencyProperty.UnsetValue) { ComboBox_FontSize.Text = "---"; } else { ComboBox_FontSize.Text = "" + txt.Selection.GetPropertyValue(FontSizeProperty); } ComboBox_FontName.Text = txt.Selection.GetPropertyValue(FontFamilyProperty).ToString(); if (((FontWeight)txt.Selection.GetPropertyValue(TextElement.FontWeightProperty)) == FontWeights.Bold) { SButton_Bold.SetChecked(true); } else { SButton_Bold.SetChecked(false); } if (((System.Windows.FontStyle)txt.Selection.GetPropertyValue(TextElement.FontStyleProperty)) == FontStyles.Italic) { SButton_Italic.SetChecked(true); } else { SButton_Italic.SetChecked(false); } FontVariants fv = (FontVariants)txt.Selection.GetPropertyValue(Typography.VariantsProperty); if (fv == FontVariants.Subscript) { SButton_SubScript.SetCheckedNoCall(true); SButton_SuperScript.SetCheckedNoCall(false); } else if (fv == FontVariants.Superscript) { SButton_SuperScript.SetCheckedNoCall(true); SButton_SubScript.SetCheckedNoCall(false); } else { SButton_SubScript.SetCheckedNoCall(false); SButton_SuperScript.SetCheckedNoCall(false); } TextDecorationCollection td = (TextDecorationCollection)txt.Selection.GetPropertyValue(Inline.TextDecorationsProperty); if (td == TextDecorations.Underline) { SButton_Underline.SetCheckedNoCall(true); SButton_Strikeline.SetCheckedNoCall(false); } else if (td == TextDecorations.Strikethrough) { SButton_Underline.SetCheckedNoCall(false); SButton_Strikeline.SetCheckedNoCall(true); } else { SButton_Underline.SetCheckedNoCall(false); SButton_Strikeline.SetCheckedNoCall(false); } TextAlignment textalign = (TextAlignment)txt.Selection.GetPropertyValue(Paragraph.TextAlignmentProperty); Button_LeftAlign.SetCheckedNoCall(false); Button_RightAlign.SetCheckedNoCall(false); Button_CenterAlign.SetCheckedNoCall(false); Button_JustifyAlign.SetCheckedNoCall(false); if (textalign == TextAlignment.Left) { Button_LeftAlign.SetCheckedNoCall(true); } else if (textalign == TextAlignment.Center) { Button_CenterAlign.SetCheckedNoCall(true); } else if (textalign == TextAlignment.Right) { Button_RightAlign.SetCheckedNoCall(true); } else if (textalign == TextAlignment.Justify) { Button_JustifyAlign.SetCheckedNoCall(true); } BackColor.Fill = (SolidColorBrush)txt.Selection.GetPropertyValue(Inline.BackgroundProperty); ForColor.Fill = (SolidColorBrush)txt.Selection.GetPropertyValue(Inline.ForegroundProperty); } catch (Exception ex) { Debug.WriteLine("Selection Changed: " + ex); } }
public void Load(Control control, DataStore data) { cont = control; try { ComboBox_FontName.Text = cont.FontFamily.ToString(); try { if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\GoodTeacher\\Temp\\")) { foreach (System.Windows.Media.FontFamily fm in Fonts.GetFontFamilies(new Uri(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\GoodTeacher\\Temp\\"))) { Debug.WriteLine(fm.ToString().Substring(3)); Debug.WriteLine("EXIST: " + data.FontManager.Exists(item => item.FontFamilyName == fm.ToString().Substring(3))); if (data.FontManager.Exists(item => item.FontFamilyName == fm.ToString().Substring(3))) { Label labelf = new Label(); labelf.Content = fm.ToString().Substring(3); labelf.FontFamily = fm; labelf.FontSize = 14; labelf.ToolTip = fm.ToString(); labelf.Foreground = new SolidColorBrush(Color.FromRgb(19, 87, 48)); ComboBox_FontName.Items.Add(labelf); } } } }catch (Exception ex) { Debug.WriteLine("!NotFoundFontFile: " + ex); } foreach (System.Windows.Media.FontFamily fm in Fonts.SystemFontFamilies) { Label labelf = new Label(); labelf.Content = fm; labelf.FontFamily = fm; labelf.FontSize = 14; labelf.ToolTip = fm.ToString(); ComboBox_FontName.Items.Add(labelf); } } catch (Exception ex) { Debug.WriteLine("Font not found: " + ex); } ComboBox_FontSize.Text = "" + cont.FontSize; if (cont.FontWeight == FontWeights.Bold) { SButton_Bold.SetCheckedNoCall(true); } else { SButton_Bold.SetCheckedNoCall(false); } if (cont.FontStyle == FontStyles.Italic) { SButton_Italic.SetCheckedNoCall(true); } else { SButton_Italic.SetCheckedNoCall(false); } if (cont.HorizontalContentAlignment == HorizontalAlignment.Left) { Button_LeftAlign.SetCheckedNoCall(true); } else if (cont.HorizontalContentAlignment == HorizontalAlignment.Center) { Button_CenterAlign.SetCheckedNoCall(true); } else if (cont.HorizontalContentAlignment == HorizontalAlignment.Right) { Button_RightAlign.SetCheckedNoCall(true); } if (cont.VerticalContentAlignment == VerticalAlignment.Top) { Button_VTopAlign.SetCheckedNoCall(true); } else if (cont.VerticalContentAlignment == VerticalAlignment.Center) { Button_VCenterAlign.SetCheckedNoCall(true); } else if (cont.VerticalContentAlignment == VerticalAlignment.Bottom) { Button_VBottomAlign.SetCheckedNoCall(true); } }