private void SetParagraphSpacings(StyleDefinition result) { if (this.radNumSpacingBefore.Value.HasValue) { double spacingBefore = Unit.PointToDip(this.radNumSpacingBefore.Value.Value); if (spacingBefore != this.initialProperties.SpacingBefore) { result.SetPropertyValue(Paragraph.SpacingBeforeProperty, spacingBefore); } } if (this.radNumSpacingAfter.Value.HasValue) { double spacingAfter = Unit.PointToDip(this.radNumSpacingAfter.Value.Value); if (spacingAfter != this.initialProperties.SpacingAfter) { result.SetPropertyValue(Paragraph.SpacingAfterProperty, spacingAfter); } } bool?automaticSpacingBefore = this.checkBoxAutomaticSpacingBefore.IsChecked; if (automaticSpacingBefore.HasValue && this.checkBoxAutomaticSpacingBefore.IsChecked != this.initialProperties.AutomaticSpacingBefore) { result.SetPropertyValue(Paragraph.AutomaticSpacingBeforeProperty, automaticSpacingBefore.Value); } bool?automaticSpacingAfter = this.checkBoxAutomaticSpacingAfter.IsChecked; if (automaticSpacingAfter.HasValue && automaticSpacingAfter != this.initialProperties.AutomaticSpacingAfter) { result.SetPropertyValue(Paragraph.AutomaticSpacingAfterProperty, automaticSpacingAfter); } }
private void SetFontWeightAndStyleToStyleDefinitionToApply(StyleDefinition result) { if (this.fontStyleListBox.SelectedValue != null && (DialogFontStyle)this.fontStyleListBox.SelectedValue != this.initialDialogFontStyle) { DialogFontStyle dialogFontStyle = (DialogFontStyle)this.fontStyleListBox.SelectedValue; switch (dialogFontStyle) { case DialogFontStyle.Regular: result.SetPropertyValue(Span.FontStyleProperty, FontStyles.Normal); result.SetPropertyValue(Span.FontWeightProperty, FontWeights.Normal); break; case DialogFontStyle.Italic: result.SetPropertyValue(Span.FontStyleProperty, FontStyles.Italic); result.SetPropertyValue(Span.FontWeightProperty, FontWeights.Normal); break; case DialogFontStyle.Bold: result.SetPropertyValue(Span.FontStyleProperty, FontStyles.Normal); result.SetPropertyValue(Span.FontWeightProperty, FontWeights.Bold); break; case DialogFontStyle.BoldItalic: result.SetPropertyValue(Span.FontStyleProperty, FontStyles.Italic); result.SetPropertyValue(Span.FontWeightProperty, FontWeights.Bold); break; default: break; } } }
private void SetTextAlignment(StyleDefinition result) { if (comboAligment.SelectedValue != null && (RadTextAlignment)comboAligment.SelectedValue != this.initialProperties.TextAlignment) { result.SetPropertyValue(Paragraph.TextAlignmentProperty, (RadTextAlignment)comboAligment.SelectedValue); } }
private void SetPropertyToStyleDefinitionIfDifferent <T, V>(StyleDefinition result, StylePropertyDefinition <T, V> stylePropertyDefinition, T valueToSet, T valueToCompare) where V : DocumentElementPropertiesBase { if (valueToSet != null && !valueToSet.Equals(valueToCompare)) { result.SetPropertyValue(stylePropertyDefinition, valueToSet); } }
private void SetFlowDirection(StyleDefinition result) { FlowDirection?flowDirection = this.GetFlowDirection(); if (flowDirection.HasValue && flowDirection != this.initialProperties.FlowDirection) { result.SetPropertyValue(Paragraph.FlowDirectionProperty, flowDirection); } }
private void SetBackground(StyleDefinition result) { Color backgroundColor = paragraphBackgroundColorSelector.SelectedColor; if (backgroundColor != this.initialProperties.Background && this.isBackgroundChanged) { result.SetPropertyValue(Paragraph.BackgroundProperty, backgroundColor); } }
private void SetIndents(StyleDefinition result) { if (this.radNumRightIndent.Value.HasValue) { double rightIndent = Unit.PointToDip(this.radNumRightIndent.Value.Value); if (rightIndent != this.initialProperties.RightIndent) { result.SetPropertyValue(Paragraph.RightIndentProperty, rightIndent); } } if (this.isIndentationChanged) { double leftIndent = Unit.PointToDip(this.radNumLeftIndent.Value ?? 0); if (this.comboFirstIndentType.SelectedValue != null) { string firstIndentValue = (string)this.comboFirstIndentType.SelectedValue; double firstIndent = Unit.PointToDip(this.radNumFirstIndent.Value ?? this.radNumFirstIndent.Minimum); if (firstIndentValue == this.firstLineIndentTypes[FirstLineIndentDialogTypes.FirstLine] && this.initialProperties.FirstLineIndent != firstIndent) { result.SetPropertyValue(Paragraph.FirstLineIndentProperty, firstIndent); } else if (firstIndentValue == this.firstLineIndentTypes[FirstLineIndentDialogTypes.Hanging]) { // hanging indent is negative first indent result.SetPropertyValue(Paragraph.FirstLineIndentProperty, -firstIndent); leftIndent += firstIndent; } else { result.SetPropertyValue(Paragraph.FirstLineIndentProperty, 0); } } if (leftIndent != this.initialProperties.LeftIndent) { result.SetPropertyValue(Paragraph.LeftIndentProperty, leftIndent); } } }
private void SetFontSizeToStyleDefinitionToApply(StyleDefinition result) { if (fontSizeListBox.SelectedItem as double? != this.initialFontSize) { double fontsize; if (double.TryParse(this.fontSizeTextBox.Text, out fontsize)) { result.SetPropertyValue(Span.FontSizeProperty, Unit.PointToDip(fontsize)); } } }
private void SetLineSpacingInStyle(StyleDefinition result) { string value = comboLineSpacing.SelectedValue.ToString(); if (value == this.lineSpacingTypes[LineSpacingDialogTypes.Single]) { result.SetPropertyValue(Paragraph.LineSpacingTypeProperty, LineSpacingType.Auto); result.SetPropertyValue(Paragraph.LineSpacingProperty, 1.0); } else if (value == this.lineSpacingTypes[LineSpacingDialogTypes.LineAndAHalf]) { result.SetPropertyValue(Paragraph.LineSpacingTypeProperty, LineSpacingType.Auto); result.SetPropertyValue(Paragraph.LineSpacingProperty, 1.5); } else if (value == this.lineSpacingTypes[LineSpacingDialogTypes.Double]) { result.SetPropertyValue(Paragraph.LineSpacingTypeProperty, LineSpacingType.Auto); result.SetPropertyValue(Paragraph.LineSpacingProperty, 2.0); } else if (value == this.lineSpacingTypes[LineSpacingDialogTypes.Exactly]) { result.SetPropertyValue(Paragraph.LineSpacingTypeProperty, LineSpacingType.Exact); result.SetPropertyValue(Paragraph.LineSpacingProperty, Unit.PointToDip(this.radNumLineSpacing.Value ?? this.radNumLineSpacing.Minimum)); } else if (value == this.lineSpacingTypes[LineSpacingDialogTypes.AtLeast]) { result.SetPropertyValue(Paragraph.LineSpacingTypeProperty, LineSpacingType.AtLeast); result.SetPropertyValue(Paragraph.LineSpacingProperty, Unit.PointToDip(this.radNumLineSpacing.Value ?? this.radNumLineSpacing.Minimum)); } else if (value == this.lineSpacingTypes[LineSpacingDialogTypes.Multiple]) { result.SetPropertyValue(Paragraph.LineSpacingTypeProperty, LineSpacingType.Auto); result.SetPropertyValue(Paragraph.LineSpacingProperty, this.radNumLineSpacing.Value); } else { Debug.Assert(false, "Unknown lines spacing type selected"); } }
private void SetParagraphSpacings(StyleDefinition result) { if (this.radNumSpacingBefore.Value.HasValue) { double spacingBefore = Unit.PointToDip(this.radNumSpacingBefore.Value.Value); if (spacingBefore != this.initialProperties.SpacingBefore) { result.SetPropertyValue(Paragraph.SpacingBeforeProperty, spacingBefore); } } if (this.radNumSpacingAfter.Value.HasValue) { double spacingAfter = Unit.PointToDip(this.radNumSpacingAfter.Value.Value); if (spacingAfter != this.initialProperties.SpacingAfter) { result.SetPropertyValue(Paragraph.SpacingAfterProperty, spacingAfter); } } bool? automaticSpacingBefore = this.checkBoxAutomaticSpacingBefore.IsChecked; if (automaticSpacingBefore.HasValue && this.checkBoxAutomaticSpacingBefore.IsChecked != this.initialProperties.AutomaticSpacingBefore) { result.SetPropertyValue(Paragraph.AutomaticSpacingBeforeProperty, automaticSpacingBefore.Value); } bool? automaticSpacingAfter = this.checkBoxAutomaticSpacingAfter.IsChecked; if (automaticSpacingAfter.HasValue && automaticSpacingAfter != this.initialProperties.AutomaticSpacingAfter) { result.SetPropertyValue(Paragraph.AutomaticSpacingAfterProperty, automaticSpacingAfter); } }
private void SetLineSpacingInStyle(StyleDefinition result) { if (this.comboLineSpacing.SelectedValue == null) { return; } string value = this.comboLineSpacing.SelectedValue.ToString(); bool isLineSpacingChanged = this.radNumLineSpacing.Value != this.initialProperties.LineSpacing || value != this.initialLineSpacingDialogType; if (isLineSpacingChanged) { double lineSpacing = Unit.PointToDip(this.radNumLineSpacing.Value ?? this.radNumLineSpacing.Minimum); if (value == this.lineSpacingTypes[LineSpacingDialogTypes.Single] && isLineSpacingChanged) { result.SetPropertyValue(Paragraph.LineSpacingTypeProperty, LineSpacingType.Auto); result.SetPropertyValue(Paragraph.LineSpacingProperty, 1.0); } else if (value == this.lineSpacingTypes[LineSpacingDialogTypes.LineAndAHalf] && isLineSpacingChanged) { result.SetPropertyValue(Paragraph.LineSpacingTypeProperty, LineSpacingType.Auto); result.SetPropertyValue(Paragraph.LineSpacingProperty, 1.5); } else if (value == this.lineSpacingTypes[LineSpacingDialogTypes.Double] && isLineSpacingChanged) { result.SetPropertyValue(Paragraph.LineSpacingTypeProperty, LineSpacingType.Auto); result.SetPropertyValue(Paragraph.LineSpacingProperty, 2.0); } else if (value == this.lineSpacingTypes[LineSpacingDialogTypes.Exactly] && isLineSpacingChanged) { result.SetPropertyValue(Paragraph.LineSpacingTypeProperty, LineSpacingType.Exact); result.SetPropertyValue(Paragraph.LineSpacingProperty, lineSpacing); } else if (value == this.lineSpacingTypes[LineSpacingDialogTypes.AtLeast] && isLineSpacingChanged) { result.SetPropertyValue(Paragraph.LineSpacingTypeProperty, LineSpacingType.AtLeast); result.SetPropertyValue(Paragraph.LineSpacingProperty, lineSpacing); } else if (value == this.lineSpacingTypes[LineSpacingDialogTypes.Multiple] && isLineSpacingChanged) { result.SetPropertyValue(Paragraph.LineSpacingTypeProperty, LineSpacingType.Auto); result.SetPropertyValue(Paragraph.LineSpacingProperty, this.radNumLineSpacing.Value); } } }
private void SetFlowDirection(StyleDefinition result) { FlowDirection? flowDirection = this.GetFlowDirection(); if (flowDirection.HasValue && flowDirection != this.initialProperties.FlowDirection) { result.SetPropertyValue(Paragraph.FlowDirectionProperty, flowDirection); } }
private void SetIndents(StyleDefinition result) { if (this.radNumRightIndent.Value.HasValue) { double rightIndent = Unit.PointToDip(this.radNumRightIndent.Value.Value); if (rightIndent != this.initialProperties.RightIndent) { result.SetPropertyValue(Paragraph.RightIndentProperty, rightIndent); } } if (this.isIndentationChanged) { double leftIndent = Unit.PointToDip(this.radNumLeftIndent.Value ?? 0); string firstIndentValue = this.comboFirstIndentType.SelectedValue.ToString(); if (this.comboFirstIndentType.SelectedValue != null) { double firstIndent = Unit.PointToDip(this.radNumFirstIndent.Value ?? this.radNumFirstIndent.Minimum); if (firstIndentValue == this.firstLineIndentTypes[FirstLineIndentDialogTypes.FirstLine] && this.initialProperties.FirstLineIndent != firstIndent) { result.SetPropertyValue(Paragraph.FirstLineIndentProperty, firstIndent); } else if (firstIndentValue == this.firstLineIndentTypes[FirstLineIndentDialogTypes.Hanging]) { // hanging indent is negative first indent result.SetPropertyValue(Paragraph.FirstLineIndentProperty, -firstIndent); leftIndent += firstIndent; } else { result.SetPropertyValue(Paragraph.FirstLineIndentProperty, 0); } } if (leftIndent != this.initialProperties.LeftIndent) { result.SetPropertyValue(Paragraph.LeftIndentProperty, leftIndent); } } }
public StyleDefinition GetParagraphStyleInfo() { StyleDefinition result = new StyleDefinition(StyleType.Paragraph); if (comboAligment.SelectedValue != null) { result.SetPropertyValue(Paragraph.TextAlignmentProperty, (RadTextAlignment)comboAligment.SelectedValue); } result.SetPropertyValue(Paragraph.FlowDirectionProperty, this.GetFlowDirection()); result.SetPropertyValue(Paragraph.SpacingBeforeProperty, Unit.PointToDip(this.radNumSpacingBefore.Value ?? this.radNumSpacingBefore.Minimum)); result.SetPropertyValue(Paragraph.SpacingAfterProperty, Unit.PointToDip(this.radNumSpacingAfter.Value ?? this.radNumSpacingAfter.Minimum)); result.SetPropertyValue(Paragraph.AutomaticSpacingBeforeProperty, this.checkBoxAutomaticSpacingBefore.IsChecked ?? false); result.SetPropertyValue(Paragraph.AutomaticSpacingAfterProperty, this.checkBoxAutomaticSpacingAfter.IsChecked ?? false); result.SetPropertyValue(Paragraph.RightIndentProperty, Unit.PointToDip(this.radNumRightIndent.Value ?? 0)); this.SetLineSpacingInStyle(result); result.SetPropertyValue(Paragraph.BackgroundProperty, paragraphBackgroundColorSelector.SelectedColor); double leftIndent = Unit.PointToDip(this.radNumLeftIndent.Value ?? 0); string firstIndentValue = this.comboFirstIndentType.SelectedValue.ToString(); if (this.comboFirstIndentType.SelectedValue != null) { if (firstIndentValue == this.firstLineIndentTypes[FirstLineIndentDialogTypes.FirstLine]) { result.SetPropertyValue(Paragraph.FirstLineIndentProperty, Unit.PointToDip(this.radNumFirstIndent.Value ?? this.radNumFirstIndent.Minimum)); } else if (firstIndentValue == this.firstLineIndentTypes[FirstLineIndentDialogTypes.Hanging]) { // hanging indent is negative first indent result.SetPropertyValue(Paragraph.FirstLineIndentProperty, -Unit.PointToDip(this.radNumFirstIndent.Value ?? this.radNumFirstIndent.Minimum)); leftIndent += Unit.PointToDip(this.radNumFirstIndent.Value ?? this.radNumFirstIndent.Minimum); } else { result.SetPropertyValue(Paragraph.FirstLineIndentProperty, 0); } } result.SetPropertyValue(Paragraph.LeftIndentProperty, leftIndent); return(result); }
public StyleDefinition GetParagraphStyleInfo() { StyleDefinition result = new StyleDefinition(StyleType.Paragraph); if (comboAligment.SelectedValue != null) { result.SetPropertyValue(Paragraph.TextAlignmentProperty, (RadTextAlignment)comboAligment.SelectedValue); } result.SetPropertyValue(Paragraph.FlowDirectionProperty, this.GetFlowDirection()); result.SetPropertyValue(Paragraph.SpacingBeforeProperty, Unit.PointToDip(this.radNumSpacingBefore.Value ?? this.radNumSpacingBefore.Minimum)); result.SetPropertyValue(Paragraph.SpacingAfterProperty, Unit.PointToDip(this.radNumSpacingAfter.Value ?? this.radNumSpacingAfter.Minimum)); result.SetPropertyValue(Paragraph.AutomaticSpacingBeforeProperty, this.checkBoxAutomaticSpacingBefore.IsChecked ?? false); result.SetPropertyValue(Paragraph.AutomaticSpacingAfterProperty, this.checkBoxAutomaticSpacingAfter.IsChecked ?? false); result.SetPropertyValue(Paragraph.RightIndentProperty, Unit.PointToDip(this.radNumRightIndent.Value ?? 0)); this.SetLineSpacingInStyle(result); result.SetPropertyValue(Paragraph.BackgroundProperty, paragraphBackgroundColorSelector.SelectedColor); double leftIndent = Unit.PointToDip(this.radNumLeftIndent.Value ?? 0); string firstIndentValue = this.comboFirstIndentType.SelectedValue.ToString(); if (this.comboFirstIndentType.SelectedValue != null) { if (firstIndentValue == this.firstLineIndentTypes[FirstLineIndentDialogTypes.FirstLine]) { result.SetPropertyValue(Paragraph.FirstLineIndentProperty, Unit.PointToDip(this.radNumFirstIndent.Value ?? this.radNumFirstIndent.Minimum)); } else if (firstIndentValue == this.firstLineIndentTypes[FirstLineIndentDialogTypes.Hanging]) { // hanging indent is negative first indent result.SetPropertyValue(Paragraph.FirstLineIndentProperty, -Unit.PointToDip(this.radNumFirstIndent.Value ?? this.radNumFirstIndent.Minimum)); leftIndent += Unit.PointToDip(this.radNumFirstIndent.Value ?? this.radNumFirstIndent.Minimum); } else { result.SetPropertyValue(Paragraph.FirstLineIndentProperty, 0); } } result.SetPropertyValue(Paragraph.LeftIndentProperty, leftIndent); return result; }