⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 document.cs

📁 CSharp的MDI窗口事例
💻 CS
字号:
using System;
using System.Text;
using System.Collections;
using System.Windows.Forms;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

namespace MDICSharp
{
	/// <summary>
	/// Summary description for Document.
	/// </summary>
	/// 
	// document class is serializable
	public class Document : IMDIDocument
	{
		public bool dirtyFlag;
		public ArrayList ViewList;

		public Document()
		{
			//
			// TODO: Add constructor logic here
			//
			// sdata = new StringBuilder();
			ViewList = new ArrayList();
			dirtyFlag = false;
		}
		public void AttachView(IMDIView view) 
		{
			if (this.ViewList.Count > 0) 
			{
				if (!this.ViewList.Contains(view))
					this.ViewList.Add(view);
			}
			else
				this.ViewList.Add(view);
		}

		public void CloseView(IMDIView view) 
		{
			this.ViewList.Remove(view);
			if ((ViewList.Count == 0) && (dirtyFlag == true)) 
			{
				MessageBox.Show("Save before quitting?");
			}
		}

		public void CloseAllViews() 
		{
			foreach (frmChild view in this.ViewList) 
			{
				view.Close();
				view.Dispose();
			}
		}

		public void UpdateAllViews(IMDIView view)
		{
			foreach (frmChild cview in this.ViewList)
			{
				if (cview != (frmChild)view) // no need to update current view
					cview.OnUpdate();
			}
		}

		public void OnNewDocument()
		{
			//sdata.Remove(0,sdata.Length); // clear all
			//sdata.Append( "hello from new Document");
			//sdata = "hello from new document" ;
		}

		public void Serialize(FileStream fs) 
		{
			BinaryFormatter bf = new BinaryFormatter();
			//bf.Serialize(fs,sdata);
			fs.Close();
		}
		
		public void DeSerialize(FileStream fs) 
		{
			BinaryFormatter bf = new BinaryFormatter();
			//sdata = (string) bf.Deserialize(fs);
			fs.Close();
		}

	}
}

⌨️ 快捷键说明

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