attribute.cs

来自「电子像册: 采用C#和SQL编写」· CS 代码 · 共 51 行

CS
51
字号
using System;
using System.Windows.Forms;

namespace EAlbum
{
	public enum TextType { name,time, desc };

	//显示照片名称、照相时间和描述信息,继承了 TextBox,Observer两个类
	public class Attribute : TextBox,Observer
	{
		private Model model;
		public TextType type;

		//构造函数
		public Attribute()
		{
		}

		//实现自己的dataUpdate
		public void dataUpdate(Model model,string str,int npara)
		{
			this.model = model;
			DrawText();
		}	
	
		//设置视图对应的模型
		public void SetModel(Model model)
		{
			this.model = model;
		}		

		//重画
		private void DrawText()
		{
			int index=model.ListIndex;
			if(index>=0 && model.nameList.Count>0)
			{
				if(this.type==TextType.name)
					this.Text=(string)model.nameList[index];
				else if(this.type==TextType.desc)
					this.Text=(string)model.descList[index];
				else if(this.type==TextType.time)
					this.Text=(string)model.timeList[index];
			}
			else
					this.Text="";
		}
		
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?