■ Windows Forms 응용 프로그램에서 데이터 입력을 수행하기 위해 WPF 복합 컨트롤을 호스팅하는 응용 프로그램을 작성한다.
[TestLibrary 프로젝트]
▶ CustomControlEventArgs.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
using System; namespace TestLibrary { /// <summary> /// 커스텀 컨트롤 이벤트 인자 /// </summary> public class CustomControlEventArgs : EventArgs { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// OK 버튼 클릭 여부 /// </summary> private bool okButtonClicked; /// <summary> /// 명칭 /// </summary> private string name; /// <summary> /// 주소 /// </summary> private string address; /// <summary> /// 도시 /// </summary> private string city; /// <summary> /// 주 /// </summary> private string state; /// <summary> /// 우편 번호 /// </summary> private string zip; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Property ////////////////////////////////////////////////////////////////////////////////////////// Public #region OK 버튼 클릭 여부 - OKButtonClicked /// <summary> /// OK 버튼 클릭 여부 /// </summary> public bool OKButtonClicked { get { return this.okButtonClicked; } set { this.okButtonClicked = value; } } #endregion #region 명칭 - Name /// <summary> /// 명칭 /// </summary> public string Name { get { return this.name; } set { this.name = value; } } #endregion #region 주소 - Address /// <summary> /// 주소 /// </summary> public string Address { get { return this.address; } set { this.address = value; } } #endregion #region 도시 - City /// <summary> /// 도시 /// </summary> public string City { get { return this.city; } set { this.city = value; } } #endregion #region 주 - State /// <summary> /// 주 /// </summary> public string State { get { return this.state; } set { this.state = value; } } #endregion #region 우편 번호 - Zip /// <summary> /// 우편 번호 /// </summary> public string Zip { get { return this.zip; } set { this.zip = value; } } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Consturctor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - CustomControlEventArgs(okButtonClicked, name, address, city, state, zip) /// <summary> /// 생성자 /// </summary> /// <param name="okButtonClicked">OK 버튼 클릭 여부</param> /// <param name="name">명칭</param> /// <param name="address">주소</param> /// <param name="city">도시</param> /// <param name="state">주</param> /// <param name="zip">우편 번호</param> public CustomControlEventArgs(bool okButtonClicked, string name, string address, string city, string state, string zip) { this.okButtonClicked = okButtonClicked; this.name = name; this.address = address; this.city = city; this.state = state; this.zip = zip; } #endregion } } |
▶ CustomControl.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
<Grid Name="mainGrid" x:Class="TestLibrary.CustomControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Background="#dcdcdc"> <Grid.Resources> <Style TargetType="{x:Type TextBlock}"> <Setter Property="Margin" Value="10 10 0 0" /> <Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="FontFamily" Value="나눔고딕코딩" /> <Setter Property="FontSize" Value="16" /> </Style> <Style TargetType="{x:Type TextBox}"> <Setter Property="Margin" Value="10 10 10 0" /> <Setter Property="Height" Value="25" /> <Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="FontFamily" Value="나눔고딕코딩" /> <Setter Property="FontSize" Value="16" /> </Style> </Grid.Resources> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" HorizontalAlignment="Center" Margin="10" FontSize="20" FontWeight="Bold" Text="Simple WPF Control" /> <TextBlock Name="nameTextBlock" Grid.Row="1" Grid.Column="0" Text="Name" /> <TextBox Name="nameTextBox" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" /> <TextBlock Name="addressTextBlock" Grid.Row="2" Grid.Column="0" Text="Address" /> <TextBox Name="addressTextBox" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" /> <TextBlock Name="cityTextBlock" Grid.Row="3" Grid.Column="0" Text="City" /> <TextBox Name="cityTextBox" Grid.Row="3" Grid.Column="1" Width="100" Height="25" VerticalContentAlignment="Center" /> <TextBlock Name="stateTextBlock" Grid.Row="3" Grid.Column="2" Text="State" /> <TextBox Name="stateTextBox" Grid.Row="3" Grid.Column="3" Width="50" /> <TextBlock Name="zipTextBlock" Grid.Row="4" Grid.Column="0" Text="Zip" /> <TextBox Name="zipTextBox" Grid.Row="4" Grid.Column="1" Width="100" /> <Button Name="okButton" Grid.Row="5" Grid.Column="0" Margin="10" Width="100" Height="30" Content="OK" /> <Button Name="cancelButton" Grid.Row="5" Grid.Column="1" Margin="10" Width="100" Height="30" Content="Cancel" /> </Grid> |
▶ CustomControl.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
using System; using System.Windows; using System.Windows.Controls; using System.Windows.Media; namespace TestLibrary { /// <summary> /// 커스텀 컨트롤 /// </summary> public partial class CustomControl : Grid { //////////////////////////////////////////////////////////////////////////////////////////////////// Delegate ////////////////////////////////////////////////////////////////////////////////////////// Public #region 커스텀 컨트롤 이벤트 핸들러 - CustomControlEventHandler(sender, e) /// <summary> /// 커스텀 컨트롤 이벤트 핸들러 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> public delegate void CustomControlEventHandler(object sender, CustomControlEventArgs e); #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Event ////////////////////////////////////////////////////////////////////////////////////////// Public #region 버튼 클릭시 이벤트 - ButtonClick /// <summary> /// 버튼 클릭시 이벤트 /// </summary> public event CustomControlEventHandler ButtonClick; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// 배경 브러시 /// </summary> private SolidColorBrush backgroundBrush; /// <summary> /// 전경 브러시 /// </summary> private SolidColorBrush foregroundBrush; /// <summary> /// 폰트 패밀리 /// </summary> private FontFamily fontFamily; /// <summary> /// 폰트 크기 /// </summary> private double fontSize; /// <summary> /// 폰트 가중치 /// </summary> private FontWeight fontWeight; /// <summary> /// 폰트 스타일 /// </summary> private FontStyle fontStyle; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Property ////////////////////////////////////////////////////////////////////////////////////////// Public #region 배경 브러시 - BackgroundBrush /// <summary> /// 배경 브러시 /// </summary> public SolidColorBrush BackgroundBrush { get { return this.backgroundBrush; } set { this.backgroundBrush = value; this.mainGrid.Background = value; } } #endregion #region 전경 브러시 - ForegroundBrush /// <summary> /// 전경 브러시 /// </summary> public SolidColorBrush ForegroundBrush { get { return this.foregroundBrush; } set { this.foregroundBrush = value; this.nameTextBlock.Foreground = value; this.addressTextBlock.Foreground = value; this.cityTextBlock.Foreground = value; this.stateTextBlock.Foreground = value; this.zipTextBlock.Foreground = value; } } #endregion #region 폰트 패밀리 - FontFamily /// <summary> /// 폰트 패밀리 /// </summary> public FontFamily FontFamily { get { return this.fontFamily; } set { this.fontFamily = value; this.nameTextBlock.FontFamily = value; this.addressTextBlock.FontFamily = value; this.cityTextBlock.FontFamily = value; this.stateTextBlock.FontFamily = value; this.zipTextBlock.FontFamily = value; } } #endregion #region 폰트 크기 - FontSize /// <summary> /// 폰트 크기 /// </summary> public double FontSize { get { return this.fontSize; } set { this.fontSize = value; this.nameTextBlock.FontSize = value; this.addressTextBlock.FontSize = value; this.cityTextBlock.FontSize = value; this.stateTextBlock.FontSize = value; this.zipTextBlock.FontSize = value; } } #endregion #region 폰트 가중치 - FontWeight /// <summary> /// 폰트 가중치 /// </summary> public FontWeight FontWeight { get { return this.fontWeight; } set { this.fontWeight = value; this.nameTextBlock.FontWeight = value; this.addressTextBlock.FontWeight = value; this.cityTextBlock.FontWeight = value; this.stateTextBlock.FontWeight = value; this.zipTextBlock.FontWeight = value; } } #endregion #region 폰트 스타일 - FontStyle /// <summary> /// 폰트 스타일 /// </summary> public FontStyle FontStyle { get { return this.fontStyle; } set { this.fontStyle = value; this.nameTextBlock.FontStyle = value; this.addressTextBlock.FontStyle = value; this.cityTextBlock.FontStyle = value; this.stateTextBlock.FontStyle = value; this.zipTextBlock.FontStyle = value; } } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - CustomControl() /// <summary> /// 생성자 /// </summary> public CustomControl() { InitializeComponent(); Loaded += Grid_Loaded; this.okButton.Click += button_Click; this.cancelButton.Click += button_Click; } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 그리드 로드시 처리하기 - Grid_Loaded(sender, e) /// <summary> /// 그리드 로드시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void Grid_Loaded(object sender, EventArgs e) { this.backgroundBrush = (SolidColorBrush)this.mainGrid.Background; this.foregroundBrush = (SolidColorBrush)this.nameTextBlock.Foreground; this.fontFamily = this.nameTextBlock.FontFamily; this.fontSize = this.nameTextBlock.FontSize; this.fontWeight = this.nameTextBlock.FontWeight; this.fontStyle = this.nameTextBlock.FontStyle; } #endregion #region 버튼 클릭시 처리하기 - button_Click(sender, e) /// <summary> /// 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void button_Click(object sender, RoutedEventArgs e) { CustomControlEventArgs customControlEventArgs = new CustomControlEventArgs ( true, this.nameTextBox.Text, this.addressTextBox.Text, this.cityTextBox.Text, this.stateTextBox.Text, this.zipTextBox.Text ); if(sender == this.cancelButton) { customControlEventArgs.OKButtonClicked = false; } if(ButtonClick != null) { ButtonClick(this, customControlEventArgs); } } #endregion } } |
[TestProject 프로젝트]
▶ MainForm.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
using System; using System.Windows; using System.Windows.Forms; using System.Windows.Media; using TestLibrary; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : Form { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// 커스텀 컨트롤 /// </summary> private CustomControl customControl; private System.Windows.Media.SolidColorBrush initialBackgroundBrush; private System.Windows.Media.SolidColorBrush initialForegroundBrush; private System.Windows.Media.FontFamily initialFontFamily; private double initialFontSize; private System.Windows.FontWeight initialFontWeight; private System.Windows.FontStyle initialFontStyle; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); Load += Form_Load; } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region 폼 로드시 처리하기 - Form_Load(sender, e) /// <summary> /// 폼 로드시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void Form_Load(object sender, EventArgs e) { this.customControl = new CustomControl(); this.customControl.InitializeComponent(); this.elementHost.Child = this.customControl; this.customControl.ButtonClick += customControl_ButtonClick; this.customControl.Loaded += customControl_Loaded; this.originalBackgroundColorRadioButton.Click += originalBackgroundColorRadioButton_Click; this.lightGreenBackgroundColorRadioButton.Click += lightGreenBackgroundColorRadioButton_Click; this.lightSalmonBackgroundColorRadioButton.Click += lightSalmonBackgroundColorRadioButton_Click; this.originalForegroundColorRadioButton.Click += originalForegroundColorRadioButton_Click; this.redForegroundColorRadioButton.Click += redForegroundColorRadioButton_Click; this.yellowForegroundColorRadioButton.Click += yellowForegroundColorRadioButton_Click; this.originalFontFamilyRadioButton.Click += originalFontFamilyRadioButton_Click; this.timesNewRomanFontFamilyRadioButton.Click += timesNewRomanFontFamilyRadioButton_Click; this.windingsFontFamilyRadioButton.Click += windingsFontFamilyRadioButton_Click; this.originalFontSizeRadioButton.Click += originalFontSizeRadioButton_Click; this.twelveFontSizeRadioButton.Click += twelveFontSizeRadioButton_Click; this.twentyFontSizeRadioButton.Click += twentyFontSizeRadioButton_Click; this.originalFontStyleRadioButton.Click += originalFontStyleRadioButton_Click; this.italicFontStyleRadioButton.Click += italicFontStyleRadioButton_Click; this.originalFontWeightRadioButton.Click += originalFontWeightRadioButton_Click; this.boldFontWeightRadioButton.Click += boldFontWeightRadioButton_Click; } #endregion #region Original 배경색 라디오 버튼 클릭시 처리하기 - originalBackgroundColorRadioButton_Click(sender, e) /// <summary> /// Original 배경색 라디오 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void originalBackgroundColorRadioButton_Click(object sender, EventArgs e) { this.customControl.BackgroundBrush = this.initialBackgroundBrush; } #endregion #region LightGreen 배경색 라디오 버튼 클릭시 처리하기 - lightGreenBackgroundColorRadioButton_Click(sender, e) /// <summary> /// LightGreen 배경색 라디오 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void lightGreenBackgroundColorRadioButton_Click(object sender, EventArgs e) { this.customControl.BackgroundBrush = new SolidColorBrush(Colors.LightGreen); } #endregion #region LightSalmon 배경색 라디오 버튼 클릭시 처리하기 - lightSalmonBackgroundColorRadioButton_Click(sender, e) /// <summary> /// LightSalmon 배경색 라디오 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void lightSalmonBackgroundColorRadioButton_Click(object sender, EventArgs e) { this.customControl.BackgroundBrush = new SolidColorBrush(Colors.LightSalmon); } #endregion #region Original 전경색 라디오 버튼 클릭시 처리하기 - originalForegroundColorRadioButton_Click(sender, e) /// <summary> /// Original 전경색 라디오 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void originalForegroundColorRadioButton_Click(object sender, EventArgs e) { this.customControl.ForegroundBrush = this.initialForegroundBrush; } #endregion #region Red 전경색 라디오 버튼 클릭시 처리하기 - redForegroundColorRadioButton_Click(sender, e) /// <summary> /// Red 전경색 라디오 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void redForegroundColorRadioButton_Click(object sender, EventArgs e) { this.customControl.ForegroundBrush = new System.Windows.Media.SolidColorBrush(Colors.Red); } #endregion #region Yellow 전경색 라디오 버튼 클릭시 처리하기 - yellowForegroundColorRadioButton_Click(sender, e) /// <summary> /// Yellow 전경색 라디오 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void yellowForegroundColorRadioButton_Click(object sender, EventArgs e) { this.customControl.ForegroundBrush = new System.Windows.Media.SolidColorBrush(Colors.Yellow); } #endregion #region Original 폰트 패밀리 라디오 버튼 클릭시 처리하기 - originalFontFamilyRadioButton_Click(sender, e) /// <summary> /// Original 폰트 패밀리 라디오 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void originalFontFamilyRadioButton_Click(object sender, EventArgs e) { this.customControl.FontFamily = this.initialFontFamily; } #endregion #region Times New Roman 폰트 패밀리 라디오 버튼 클릭시 처리하기 - timesNewRomanFontFamilyRadioButton_Click(sender, e) /// <summary> /// Times New Roman 폰트 패밀리 라디오 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void timesNewRomanFontFamilyRadioButton_Click(object sender, EventArgs e) { this.customControl.FontFamily = new System.Windows.Media.FontFamily("Times New Roman"); } #endregion #region Windings 폰트 패밀리 라디오 버튼 클릭시 처리하기 - windingsFontFamilyRadioButton_Click(sender, e) /// <summary> /// Windings 폰트 패밀리 라디오 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void windingsFontFamilyRadioButton_Click(object sender, EventArgs e) { this.customControl.FontFamily = new System.Windows.Media.FontFamily("WingDings"); } #endregion #region Original 폰트 크기 라디오 버튼 클릭시 처리하기 - originalFontSizeRadioButton_Click(sender, e) /// <summary> /// Original 폰트 크기 라디오 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void originalFontSizeRadioButton_Click(object sender, EventArgs e) { this.customControl.FontSize = this.initialFontSize; } #endregion #region 12 폰트 크기 라디오 버튼 클릭시 처리하기 - twelveFontSizeRadioButton_Click(sender, e) /// <summary> /// 12 폰트 크기 라디오 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void twelveFontSizeRadioButton_Click(object sender, EventArgs e) { this.customControl.FontSize = 12; } #endregion #region 20 폰트 크기 라디오 버튼 클릭시 처리하기 - twentyFontSizeRadioButton_Click(sender, e) /// <summary> /// 20 폰트 크기 라디오 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void twentyFontSizeRadioButton_Click(object sender, EventArgs e) { this.customControl.FontSize = 20; } #endregion #region Original 폰트 스타일 라디오 버튼 클릭시 처리하기 - originalFontStyleRadioButton_Click(sender, e) /// <summary> /// Original 폰트 스타일 라디오 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void originalFontStyleRadioButton_Click(object sender, EventArgs e) { this.customControl.FontStyle = this.initialFontStyle; } #endregion #region Italic 폰트 스타일 라디오 버튼 클릭시 처리하기 - italicFontStyleRadioButton_Click(sender, e) /// <summary> /// Italic 폰트 스타일 라디오 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void italicFontStyleRadioButton_Click(object sender, EventArgs e) { this.customControl.FontStyle = System.Windows.FontStyles.Italic; } #endregion #region Original 폰트 가중치 라디오 버튼 클릭시 처리하기 - originalFontWeightRadioButton_Click(sender, e) /// <summary> /// Original 폰트 가중치 라디오 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void originalFontWeightRadioButton_Click(object sender, EventArgs e) { this.customControl.FontWeight = this.initialFontWeight; } #endregion #region Bold 폰트 가중치 라디오 버튼 클릭시 처리하기 - boldFontWeightRadioButton_Click(sender, e) /// <summary> /// Bold 폰트 가중치 라디오 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void boldFontWeightRadioButton_Click(object sender, EventArgs e) { this.customControl.FontWeight = FontWeights.Bold; } #endregion #region 커스텀 컨트롤 로드시 처리하기 - customControl_Loaded(sender, e) /// <summary> /// 커스텀 컨트롤 로드시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void customControl_Loaded(object sender, RoutedEventArgs e) { this.initialBackgroundBrush = (System.Windows.Media.SolidColorBrush)this.customControl.BackgroundBrush; this.initialForegroundBrush = this.customControl.ForegroundBrush; this.initialFontFamily = this.customControl.FontFamily; this.initialFontSize = this.customControl.FontSize; this.initialFontWeight = this.customControl.FontWeight; this.initialFontStyle = this.customControl.FontStyle; } #endregion #region 커스텀 컨트롤 버튼 클릭시 처리하기 - customControl_ButtonClick(sender, e) /// <summary> /// 커스텀 컨트롤 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void customControl_ButtonClick(object sender, CustomControlEventArgs e) { if(e.OKButtonClicked) { this.addressLabel.Text = "Address : " + e.Address; this.cityLabel.Text = "City : " + e.City; this.nameLabel.Text = "Name : " + e.Name; this.stateLabel.Text = "State : " + e.State; this.zipLabel.Text = "Zip : " + e.Zip; } else { this.addressLabel.Text = "Address :"; this.cityLabel.Text = "City :"; this.nameLabel.Text = "Name :"; this.stateLabel.Text = "State :"; this.zipLabel.Text = "Zip :"; } } #endregion } } |