📄 coursetablecontrol.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace 课程安排
{
[Serializable]
public partial class CourseTableControl : UserControl
{
#region 构造函数
public CourseTableControl()
{
InitializeComponent();
}
#endregion
#region 接口部分
private string gradeName = "";
public string GradeName
{
get { return gradeName; }
set { gradeName = value; }
}
private string clsName = "";
public string ClsName
{
get { return clsName; }
set { clsName = value; }
}
private Title title = null;
public Title Title
{
get { return title; }
set { title = value; }
}
private Foot foot = null;
public Foot Foot
{
get { return foot; }
set { foot = value; }
}
private bool titleVisible = true;
public bool TitleVisible
{
get { return titleVisible; }
set { titleVisible = value; }
}
private bool footVisible = true;
public bool FootVisible
{
get { return footVisible; }
set { footVisible = value; }
}
public void SetCourseTableBodyControl(List<CourseTableBodyControl.BodyCourseItem> courses, List<CourseTableBodyControl.BodySubjectItem> subjects, List<CourseTableBodyControl.BodyTimeItem> times)
{
if (courses != null)
this.courseTableBodyControl1.Courses = courses;
else
this.courseTableBodyControl1.ClearAllText();
this.courseTableBodyControl1.Subjects = subjects;
this.courseTableBodyControl1.Times = times;
}
public void GetCourseTableBodyControl(out List<CourseTableBodyControl.BodyCourseItem> courses, out List<CourseTableBodyControl.BodySubjectItem> subjects, out List<CourseTableBodyControl.BodyTimeItem> times)
{
courses = this.courseTableBodyControl1.Courses;
subjects = this.courseTableBodyControl1.Subjects;
times = this.courseTableBodyControl1.Times;
}
public void SetCourseTable(List<CourseTableBodyControl.BodyCourseItem> courses)
{
if (courses != null)
this.courseTableBodyControl1.Courses = courses;
else
this.courseTableBodyControl1.ClearAllText();
}
public List<CourseTableBodyControl.BodyCourseItem> GetCourseTable()
{
return this.courseTableBodyControl1.Courses;
}
public void ClearAllContent()
{
this.courseTableBodyControl1.ClearAllItems();
this.courseTableBodyControl1.ClearAllText();
}
public CourseTableBodyControl GetCourseTableBodyControl()
{
return this.courseTableBodyControl1;
}
#endregion
// 显示表头
private List<Label> titleLabels = new List<Label>();
private void showTitle()
{
if (titleLabels.Count != 5)
{
int lw = this.Width / 5;
for (int i = 0; i < 5; i++)
{
Label label = new Label();
label.Left = i * lw;
this.panelTop.Controls.Add(label);
titleLabels.Add(label);
}
}
foreach (Label label in titleLabels)
{
label.Text = "";
}
for (int i = 0; i < title.Items.Count; i++)
{
Label label = null;
if (title.Items[i].Position == Position.left)
{
label = titleLabels[0];
}
else if (title.Items[i].Position == Position.leftCenter)
{
label = titleLabels[1];
}
else if (title.Items[i].Position == Position.Center)
{
label = titleLabels[2];
}
else if (title.Items[i].Position == Position.RightCenter)
{
label = titleLabels[3];
}
else if (title.Items[i].Position == Position.Right)
{
label = titleLabels[4];
}
label.Text = label.Text + title.Items[i].Text;
label.Font = title.Items[i].Font;
label.BackColor = title.Items[i].BackColor;
label.Visible = this.titleVisible;
}
}
// 显示表脚
private List<Label> footLabels = new List<Label>();
private void showFoot()
{
if (footLabels.Count != 5)
{
int lw = this.Width / 5;
for (int i = 0; i < 5; i++)
{
Label label = new Label();
label.Left = i * lw;
this.panelBottom.Controls.Add(label);
footLabels.Add(label);
}
}
foreach (Label label in footLabels)
{
label.Text = "";
}
for (int i = 0; i < foot.Items.Count; i++)
{
Label label = null;
if (foot.Items[i].Position == Position.left)
label = footLabels[0];
else if (foot.Items[i].Position == Position.leftCenter)
label = footLabels[1];
else if (foot.Items[i].Position == Position.Center)
label = footLabels[2];
else if (foot.Items[i].Position == Position.RightCenter)
label = footLabels[3];
else if (foot.Items[i].Position == Position.Right)
label = footLabels[4];
label.Text = label.Text + foot.Items[i].Text;
label.Font = foot.Items[i].Font;
label.BackColor = foot.Items[i].BackColor;
label.Visible = this.footVisible;
}
}
private void CourseTableControl_Resize(object sender, EventArgs e)
{
//if (this.titleVisible == false && this.footVisible == false)
//{
// if (this.Width != 850)
// this.Width = 850;
// if (this.Height != 380 - 60)
// this.Height = 380 - 60;
//}
//else if (this.titleVisible == false || this.footVisible == false)
//{
// if (this.Width != 850)
// this.Width = 850;
// if (this.Height != 380 - 30)
// this.Height = 380 - 30;
//}
//else
//{
// if (this.Width != 850)
// this.Width = 850;
// if (this.Height != 380)
// this.Height = 380;
//}
if (this.Width != 850)
this.Width = 850;
if (this.Height != 380)
this.Height = 380;
}
}
// 表头
[Serializable]
public class Title
{
private List<Content> titleTextCollection;
public List<Content> Items
{
get { return titleTextCollection; }
set { titleTextCollection = value; }
}
#region 构造函数
public Title()
{
}
public Title(string Text)
{
}
public Title(Content TitleContent)
{
}
#endregion
#region 接口部分
public void Clear()
{
}
public void AddTitle(string Text)
{
}
public void AddTitle(Content TitleContent)
{
}
public void RemoveTitle(string Text)
{
}
public void RemoveTitle(Content TitleContent)
{
}
#endregion
}
// 表脚
[Serializable]
public class Foot
{
private List<Content> footTextCollection;
public List<Content> Items
{
get { return footTextCollection; }
set { footTextCollection = value; }
}
#region 构造函数
public Foot()
{
}
public Foot(string Text)
{
}
public Foot(Content FootContent)
{
}
#endregion
#region 接口部分
public void Clear()
{
}
public void AddFoot(string Text)
{
}
public void AddFoot(Content FootContent)
{
}
public void RemoveFoot(string Text)
{
}
public void RemoveFoot(Content FootContent)
{
}
#endregion
}
[Serializable]
public class Content
{
#region 构造函数
public Content()
{
}
public Content(string Text)
{
}
#endregion
#region 接口部分
private string text = "";
public string Text
{
set { text = value; }
get { return text; }
}
private Font font = null;
public Font Font
{
set { font = value; }
get { return font; }
}
private Color backColor = Color.White;
public Color BackColor
{
get { return backColor; }
set { backColor = value; }
}
private Position position = Position.Center;
public Position Position
{
get { return position; }
set { position = value; }
}
#endregion
}
public enum Position { left, leftCenter, Center, RightCenter, Right };
public enum CellType { text, combo };
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -