728x90
반응형
728x170
▶ MainWindow.xaml
<Window x:Class="TestProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxre="http://schemas.devexpress.com/winfx/2008/xaml/richedit"
Width="800"
Height="600"
Title="선택 텍스트 포맷 변경하기"
FontFamily="나눔고딕코딩"
FontSize="16">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<Button x:Name="formatCharactersButton"
Margin="10"
Height="25"
Content="Format Characters"
Click="formatCharactersButton_Click" />
<Button x:Name="formatParagraphButton"
Margin="10"
Height="25"
Content="Format Paragraph"
Click="formatParagraphButton_Click" />
</StackPanel>
<dxre:RichEditControl x:Name="richEditControl" Grid.Column="1" />
</Grid>
</Window>
728x90
▶ MainWindow.xaml.cs
using System.Drawing;
using System.Windows;
using DevExpress.Office.Utils;
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
namespace TestProject
{
/// <summary>
/// 메인 윈도우
/// </summary>
public partial class MainWindow : Window
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainWindow()
/// <summary>
/// 생성자
/// </summary>
public MainWindow()
{
InitializeComponent();
this.richEditControl.Document.LoadDocument("SampleText.rtf", DocumentFormat.Rtf);
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Format Characters 버튼 클릭시 처리하기 - formatCharactersButton_Click(sender, e)
/// <summary>
/// Format Characters 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void formatCharactersButton_Click(object sender, RoutedEventArgs e)
{
Document document = this.richEditControl.Document;
DocumentRange documentRange = document.Selection;
CharacterProperties characterProperties = document.BeginUpdateCharacters(documentRange);
characterProperties.FontName = "Comic Sans MS";
characterProperties.FontSize = 18;
characterProperties.ForeColor = Color.Yellow;
characterProperties.BackColor = Color.Blue;
characterProperties.Underline = UnderlineType.DoubleWave;
characterProperties.UnderlineColor = Color.White;
document.EndUpdateCharacters(characterProperties);
}
#endregion
#region Format Paragraph 버튼 클릭시 처리하기 - formatParagraphButton_Click(sender, e)
/// <summary>
/// Format Paragraph 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void formatParagraphButton_Click(object sender, RoutedEventArgs e)
{
Document document = this.richEditControl.Document;
DocumentRange documentRange = document.Selection;
ParagraphProperties paragraphProperties = document.BeginUpdateParagraphs(documentRange);
paragraphProperties.Alignment = ParagraphAlignment.Center;
paragraphProperties.LineSpacingType = ParagraphLineSpacing.Multiple;
paragraphProperties.LineSpacingMultiplier = 3;
paragraphProperties.LeftIndent = Units.InchesToDocumentsF(0.5f);
TabInfoCollection tabInfoCollection = paragraphProperties.BeginUpdateTabs(true);
TabInfo tabInfo = new TabInfo();
tabInfo.Alignment = TabAlignmentType.Center;
tabInfo.Position = Units.InchesToDocumentsF(1.5f);
tabInfoCollection.Add(tabInfo);
paragraphProperties.EndUpdateTabs(tabInfoCollection);
document.EndUpdateParagraphs(paragraphProperties);
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'DevExpress > WPF' 카테고리의 다른 글
[DEVEXPRESS/WPF] RichEditControl 클래스 : AutoCorrect 이벤트 처리하기 (0) | 2017.12.31 |
---|---|
[DEVEXPRESS/WPF] RichEditControl : 리본 스타일 사용자 컨트롤 만들기 (0) | 2017.12.30 |
[DEVEXPRESS/WPF] RichEditControl 클래스 : 시간이 걸리는 작업을 위한 진행 지시자 구현하기 (0) | 2017.12.30 |
[DEVEXPRESS/WPF] RichEditControl 클래스 : 코드로 프린터 지정하고 문서 인쇄하기 (0) | 2017.12.30 |
[DEVEXPRESS/WPF] RichEditControl 클래스 : 이미지 문서 인쇄하기 (0) | 2017.12.30 |
[DEVEXPRESS/WPF] PivotGridControl 클래스 : MDB 데이터베이스에 피벗 그리드 바인딩 하기 (0) | 2017.12.30 |
[DEVEXPRESS/WPF] PivotGridControl 클래스 : 피벗 그리드 인쇄하고 내보내기 (0) | 2017.12.30 |
[DEVEXPRESS/WPF] TreeListControl 클래스 : TOTAL SUMMARY 표시하기 (0) | 2017.12.26 |
[DEVEXPRESS/WPF] GridControl 클래스 : 마스터 행 확장하기/축소하기 (0) | 2017.12.25 |
[DEVEXPRESS/WPF] GridControl 클래스 : 상세 확장 버튼 표시 조정하기 (0) | 2017.12.25 |
댓글을 달아 주세요