using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Infragistics.Win.Printing;
using Infragistics.Win.UltraWinGrid;
private UltraGrid ultraGrid;
private UltraGridPrintDocument ultraGridPrintDocument;
private UltraPrintPreviewDialog ultraPrintPreviewDialog;
...
#region 폼 로드시 처리하기 - Form_Load(sender, e)
/// <summary>
/// 폼 로드시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void Form_Load(object sender, EventArgs e)
{
this.ultraGrid.DataSource = new MovieDataProvider().MovieCategoryList;
this.ultraGrid.DisplayLayout.ViewStyleBand = ViewStyleBand.Horizontal;
this.ultraGridPrintDocument.Grid = this.ultraGrid;
this.ultraPrintPreviewDialog.Document = ultraGridPrintDocument;
this.ultraGrid.Rows.ExpandAll(true);
}
#endregion
#region UltraGrid 행 초기화 하기 - ultraGrid_InitializeRow(sender, e)
/// <summary>
/// UltraGrid 행 초기화 하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void ultraGrid_InitializeRow(object sender, InitializeRowEventArgs e)
{
UltraGridColumn ultraGridColumn = this.ultraGrid.DisplayLayout.Bands[1].Columns[2];
string cellText = e.Row.GetCellText(ultraGridColumn);
if(e.Row.Band.Layout.IsPrintLayout)
{
if(cellText == "PG")
{
e.Row.StartsNewPrintedPage = true;
}
}
}
#endregion
#region UltraButton 클릭시 처리하기 - ultraButton_Click(sender, e)
/// <summary>
/// UltraButton 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void ultraButton_Click(object sender, EventArgs e)
{
this.ultraPrintPreviewDialog.ShowDialog(this);
}
#endregion
...
/// <summary>
/// 영화 데이터 제공자
/// </summary>
public class MovieDataProvider
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// 영화 카테고리 리스트
/// </summary>
private List<MovieCategory> movieCategoryList;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Property
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 영화 카테고리 리스트 - MovieCategoryList
/// <summary>
/// 영화 카테고리 리스트
/// </summary>
public List<MovieCategory> MovieCategoryList
{
get
{
return this.movieCategoryList;
}
set
{
if(this.movieCategoryList != null && this.movieCategoryList == value)
{
return;
}
this.movieCategoryList = value;
}
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MovieDataProvider()
/// <summary>
/// 생성자
/// </summary>
public MovieDataProvider()
{
this.movieCategoryList = new List<MovieCategory>();
// Drama
MovieCategory dramaCategory = new MovieCategory("Drama");
dramaCategory.AddMovie("Movie Title...", "Description", "PG" );
dramaCategory.AddMovie("Movie Title...", "Description", "R" );
dramaCategory.AddMovie("Movie Title...", "Description", "PG-13");
dramaCategory.AddMovie("Movie Title...", "Description", "PG" );
dramaCategory.AddMovie("Movie Title...", "Description", "R" );
dramaCategory.AddMovie("Movie Title...", "Description", "R" );
dramaCategory.AddMovie("Movie Title...", "Description", "PG-13");
dramaCategory.AddMovie("Movie Title...", "Description", "PG-13");
dramaCategory.AddMovie("Movie Title...", "Description", "NR" );
dramaCategory.AddMovie("Movie Title...", "Description", "NR" );
this.movieCategoryList.Add(dramaCategory);
MovieCategory actionCategory = new MovieCategory("Action");
actionCategory.AddMovie("Movie Title...", "Description", "R" );
actionCategory.AddMovie("Movie Title...", "Description", "PG-13");
actionCategory.AddMovie("Movie Title...", "Description", "PG-13");
actionCategory.AddMovie("Movie Title...", "Description", "R" );
actionCategory.AddMovie("Movie Title...", "Description", "PG" );
actionCategory.AddMovie("Movie Title...", "Description", "PG-13");
actionCategory.AddMovie("Movie Title...", "Description", "PG-13");
actionCategory.AddMovie("Movie Title...", "Description", "NR" );
actionCategory.AddMovie("Movie Title...", "Description", "R" );
actionCategory.AddMovie("Movie Title...", "Description", "NR" );
this.movieCategoryList.Add(actionCategory);
MovieCategory commedyCategory = new MovieCategory("Commedy");
commedyCategory.AddMovie("Movie Title...", "Description", "PG-13");
commedyCategory.AddMovie("Movie Title...", "Description", "R" );
commedyCategory.AddMovie("Movie Title...", "Description", "R" );
commedyCategory.AddMovie("Movie Title...", "Description", "R" );
commedyCategory.AddMovie("Movie Title...", "Description", "PG-13");
commedyCategory.AddMovie("Movie Title...", "Description", "PG-13");
commedyCategory.AddMovie("Movie Title...", "Description", "PG-13");
commedyCategory.AddMovie("Movie Title...", "Description", "PG" );
commedyCategory.AddMovie("Movie Title...", "Description", "R" );
commedyCategory.AddMovie("Movie Title...", "Description", "NR" );
this.movieCategoryList.Add(commedyCategory);
MovieCategory documentaryCategory = new MovieCategory("Documentary");
documentaryCategory.AddMovie("Movie Title...", "Description", "PG" );
documentaryCategory.AddMovie("Movie Title...", "Description", "R" );
documentaryCategory.AddMovie("Movie Title...", "Description", "PG" );
documentaryCategory.AddMovie("Movie Title...", "Description", "PG" );
documentaryCategory.AddMovie("Movie Title...", "Description", "PG-13");
documentaryCategory.AddMovie("Movie Title...", "Description", "PG-13");
documentaryCategory.AddMovie("Movie Title...", "Description", "PG-13");
documentaryCategory.AddMovie("Movie Title...", "Description", "PG" );
documentaryCategory.AddMovie("Movie Title...", "Description", "R" );
documentaryCategory.AddMovie("Movie Title...", "Description", "NR" );
this.movieCategoryList.Add(documentaryCategory);
}
#endregion
}
/// <summary>
/// 영화 카테고리
/// </summary>
public class MovieCategory
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// 분류
/// </summary>
private string category;
/// <summary>
/// 영화 리스트
/// </summary>
private List<Movie> movieList = new List<Movie>();
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Property
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 카테고리 - Category
/// <summary>
/// 카테고리
/// </summary>
public string Category
{
get
{
return this.category;
}
set
{
if(this.category != null && this.category == value)
{
return;
}
this.category = value;
}
}
#endregion
#region 영화 리스트 - MovieList
/// <summary>
/// 영화 리스트
/// </summary>
public List<Movie> MovieList
{
get
{
return this.movieList;
}
set
{
if(this.movieList != null && this.movieList == value)
{
return;
}
this.movieList = value;
}
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MovieCategory(category)
/// <summary>
/// 생성자
/// </summary>
/// <param name="category">분류</param>
public MovieCategory(string category)
{
this.category = category;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Methid
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 영화 추가하기 - AddMovie(title, description, rating)
/// <summary>
/// 영화 추가하기
/// </summary>
/// <param name="title">제목</param>
/// <param name="description">설명</param>
/// <param name="rating">등급</param>
public void AddMovie(string title, string description, string rating)
{
this.movieList.Add(new Movie(title, description, rating));
}
#endregion
}
/// <summary>
/// 영화
/// </summary>
public class Movie
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// 제목
/// </summary>
private string title;
/// <summary>
/// 설명
/// </summary>
private string description;
/// <summary>
/// 등급
/// </summary>
private string rating;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Property
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 제목 - Title
/// <summary>
/// 제목
/// </summary>
public string Title
{
get
{
return this.title;
}
set
{
if(this.title != null && this.title == value)
{
return;
}
this.title = value;
}
}
#endregion
#region 설명 - Description
/// <summary>
/// 설명
/// </summary>
public string Description
{
get
{
return this.description;
}
set
{
if(this.description != null && this.description == value)
{
return;
}
this.description = value;
}
}
#endregion
#region 등급 - Rating
/// <summary>
/// 등급
/// </summary>
public string MovieRating
{
get
{
return this.rating;
}
set
{
if(this.rating != null && this.rating == value)
{
return;
}
rating = value;
}
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - Movie(title, description, rating)
/// <summary>
/// 생성자
/// </summary>
/// <param name="title">제목</param>
/// <param name="description">설명</param>
/// <param name="rating">등급</param>
public Movie(string title, string description, string rating)
{
this.title = title;
this.description = description;
this.rating = rating;
}
#endregion
}