private void InitializeCurrentFontStyles(StyleDefinition styleDefinition) { UnderlineType underlineType = (UnderlineType)styleDefinition.GetPropertyValue(Span.UnderlineTypeProperty); this.radBtnUnderlineStyle.ToggleState = underlineType != UnderlineType.None ? ToggleState.On : ToggleState.Off; string fontFamiliy = (string)styleDefinition.GetPropertyValue(Span.FontFamilyProperty); this.radDropDownListFont.SuspendSelectionEvents = true; this.radDropDownListFont.Text = fontFamiliy; this.radDropDownListFont.SelectedValue = fontFamiliy; this.radDropDownListFont.SuspendSelectionEvents = false; float fontSize = (float)styleDefinition.GetPropertyValue(Span.FontSizeProperty); fontSize = (float)Math.Round(Unit.DipToPoint(fontSize), 1); this.EnsureFontSize(fontSize.ToString()); TextStyle fontStyle = (TextStyle)styleDefinition.GetPropertyValue(Span.FontStyleProperty); this.radBtnBoldStyle.ToggleState = fontStyle.HasFlag(TextStyle.Bold) ? ToggleState.On : ToggleState.Off; this.radBtnItalicStyle.ToggleState = fontStyle.HasFlag(TextStyle.Italic) ? ToggleState.On : ToggleState.Off; bool strikeThrough = (bool)styleDefinition.GetPropertyValue(Span.StrikethroughProperty); this.radBtnStrikethrough.ToggleState = strikeThrough ? ToggleState.On : ToggleState.Off; }
private void InitializeCurrentFontStyles(StyleDefinition styleDefinition) { UnderlineType underlineType = (UnderlineType)styleDefinition.GetPropertyValue(Span.UnderlineTypeProperty); string fontFamiliy = (string)styleDefinition.GetPropertyValue(Span.FontFamilyProperty); float fontSize = (float)styleDefinition.GetPropertyValue(Span.FontSizeProperty); fontSize = (float)Math.Round(Unit.DipToPoint(fontSize), 1); TextStyle fontStyle = (TextStyle)styleDefinition.GetPropertyValue(Span.FontStyleProperty); bool strikeThrough = (bool)styleDefinition.GetPropertyValue(Span.StrikethroughProperty); }
private void InitializeUI() { this.stylesInitializing = true; StyleDefinition styleDefinition = this.radRichTextBox1.CurrentEditingStyle; this.InitializeCurrentFontStyles(styleDefinition); this.InitializeCurrentParagraphStyles(styleDefinition); BaselineAlignment baselineAlignment = (BaselineAlignment)styleDefinition.GetPropertyValue(Span.BaselineAlignmentProperty); this.stylesInitializing = false; }
private void InitializeUI() { this.stylesInitializing = true; StyleDefinition styleDefinition = this.radRichTextBox1.CurrentEditingStyle; this.InitializeCurrentFontStyles(styleDefinition); this.InitializeCurrentParagraphStyles(styleDefinition); BaselineAlignment baselineAlignment = (BaselineAlignment)styleDefinition.GetPropertyValue(Span.BaselineAlignmentProperty); this.subscriptButtonElement.ToggleState = baselineAlignment == BaselineAlignment.Subscript ? ToggleState.On : ToggleState.Off; this.superscriptButtonElement.ToggleState = baselineAlignment == BaselineAlignment.Superscript ? ToggleState.On : ToggleState.Off; this.stylesInitializing = false; }
private void UpdateUI(StyleDefinition paragraphStyle) { this.comboAligment.SelectedValue = (RadTextAlignment)paragraphStyle.GetPropertyValue(Paragraph.TextAlignmentProperty); this.radNumSpacingBefore.Value = Unit.DipToPoint(((double?)paragraphStyle.GetPropertyValue(Paragraph.SpacingBeforeProperty)).Value); this.radNumSpacingAfter.Value = Unit.DipToPoint(((double?)paragraphStyle.GetPropertyValue(Paragraph.SpacingAfterProperty)).Value); this.checkBoxAutomaticSpacingBefore.IsChecked = ((bool?)paragraphStyle.GetPropertyValue(Paragraph.AutomaticSpacingBeforeProperty)).Value; this.checkBoxAutomaticSpacingAfter.IsChecked = ((bool?)paragraphStyle.GetPropertyValue(Paragraph.AutomaticSpacingAfterProperty)).Value; double leftIndent = Unit.DipToPoint(((double?)paragraphStyle.GetPropertyValue(Paragraph.LeftIndentProperty)).Value); this.radNumRightIndent.Value = Unit.DipToPoint(((double?)paragraphStyle.GetPropertyValue(Paragraph.RightIndentProperty)).Value); LineSpacingType lineSpacingType = ((LineSpacingType?)paragraphStyle.GetPropertyValue(Paragraph.LineSpacingTypeProperty)).Value; double lineSpacingValue = ((double?)paragraphStyle.GetPropertyValue(Paragraph.LineSpacingProperty)).Value; this.UpdateLineSpacingUI(lineSpacingType, lineSpacingValue); this.paragraphBackgroundColorSelector.SelectedColor = (Color)paragraphStyle.GetPropertyValue(Paragraph.BackgroundProperty); this.SetFlowDirection((FlowDirection)paragraphStyle.GetPropertyValue(Paragraph.FlowDirectionProperty)); double firstIndentValue = Unit.DipToPoint(((double?)paragraphStyle.GetPropertyValue(Paragraph.FirstLineIndentProperty)).Value); // < 0 is hanging; // > 0 is first line; // 0 is none; if (firstIndentValue > 0) { this.radNumFirstIndent.Value = firstIndentValue; this.comboFirstIndentType.SelectedItem = this.firstLineIndentTypes[FirstLineIndentDialogTypes.FirstLine]; } else if (firstIndentValue < 0) { this.comboFirstIndentType.SelectedItem = this.firstLineIndentTypes[FirstLineIndentDialogTypes.Hanging]; leftIndent += firstIndentValue; this.radNumFirstIndent.Value = -firstIndentValue; } else { this.comboFirstIndentType.SelectedItem = this.firstLineIndentTypes[FirstLineIndentDialogTypes.None]; } this.radNumLeftIndent.Value = leftIndent; }
private void UpdateUI(StyleDefinition paragraphStyle) { this.comboAligment.SelectedValue = (RadTextAlignment)paragraphStyle.GetPropertyValue(Paragraph.TextAlignmentProperty); this.radNumSpacingBefore.Value = Unit.DipToPoint(((double?)paragraphStyle.GetPropertyValue(Paragraph.SpacingBeforeProperty)).Value); this.radNumSpacingAfter.Value = Unit.DipToPoint(((double?)paragraphStyle.GetPropertyValue(Paragraph.SpacingAfterProperty)).Value); this.checkBoxAutomaticSpacingBefore.IsChecked = ((bool?)paragraphStyle.GetPropertyValue(Paragraph.AutomaticSpacingBeforeProperty)).Value; this.checkBoxAutomaticSpacingAfter.IsChecked = ((bool?)paragraphStyle.GetPropertyValue(Paragraph.AutomaticSpacingAfterProperty)).Value; double leftIndent = Unit.DipToPoint(((double?)paragraphStyle.GetPropertyValue(Paragraph.LeftIndentProperty)).Value); this.radNumRightIndent.Value = Unit.DipToPoint(((double?)paragraphStyle.GetPropertyValue(Paragraph.RightIndentProperty)).Value); LineSpacingType lineSpacingType = ((LineSpacingType?)paragraphStyle.GetPropertyValue(Paragraph.LineSpacingTypeProperty)).Value; double lineSpacingValue = ((double?)paragraphStyle.GetPropertyValue(Paragraph.LineSpacingProperty)).Value; this.UpdateLineSpacingUI(lineSpacingType, lineSpacingValue); this.paragraphBackgroundColorSelector.SelectedColor = (Color)paragraphStyle.GetPropertyValue(Paragraph.BackgroundProperty); this.SetFlowDirection((FlowDirection)paragraphStyle.GetPropertyValue(Paragraph.FlowDirectionProperty)); double firstIndentValue = Unit.DipToPoint(((double?)paragraphStyle.GetPropertyValue(Paragraph.FirstLineIndentProperty)).Value); // < 0 is hanging; // > 0 is first line; // 0 is none; if (firstIndentValue > 0) { this.radNumFirstIndent.Value = firstIndentValue; this.comboFirstIndentType.SelectedItem = this.firstLineIndentTypes[FirstLineIndentDialogTypes.FirstLine]; } else if (firstIndentValue < 0) { this.comboFirstIndentType.SelectedItem = this.firstLineIndentTypes[FirstLineIndentDialogTypes.Hanging]; leftIndent += firstIndentValue; this.radNumFirstIndent.Value = -firstIndentValue; } else { this.comboFirstIndentType.SelectedItem = this.firstLineIndentTypes[FirstLineIndentDialogTypes.None]; } this.radNumLeftIndent.Value = leftIndent; }