1.首先整个文档要有一个文档对象负责管理,
然后控件初始化的时候先初始化一下文档对象CurrentEditorControl.InitializeDocument();
myEMRDoc.RefreshSize();
myEMRDoc.RefreshLine();
其中 RefreshLine对全部文档重新进行排布和分行,并进行分页处理
目前还不清楚 RefreshPages();
if (this.myOwnerControl != null)
{
this.myOwnerControl.UpdatePages();
}
为什么先RefreshPages,后UpdatePages
在UpdatePages中
float rate = (float)(1.0 / this.ClientToViewXRate); 0.32=1/3.12
System.Drawing.Size size = new System.Drawing.Size(
(int)(myPages.PaperWidth * rate),
(int)(myPages.PaperHeight * rate));
得到size是758,1122
System.Drawing.Size TotalSize = new System.Drawing.Size(
size.Width + this.intPageSpacing * 2,
(size.Height + this.intPageSpacing) * myPages.Count + this.intPageSpacing);
TotalSize 是编辑区域控件的大小
MultiPageTransform trans = (MultiPageTransform)this.myTransform;
base.intGraphicsUnit = myPages.GraphicsUnit;
trans.Pages = myPages;
trans.Refresh(rate, this.intPageSpacing);
int ClientWidth = this.ClientSize.Width;
int x = 0;
if (ClientWidth <= TotalSize.Width)
x = this.intPageSpacing;
else
{
x = (ClientWidth - TotalSize.Width) / 2 + intPageSpacing;
}
trans.OffsetSource(x, 0, false);
//使用trans做一些x y方向上的偏移
this.RefreshScaleTransform();
System.Drawing.Rectangle rect = System.Drawing.Rectangle.Empty;
for (int iCount = 0; iCount < myPages.Count; iCount++)
{
rect.X = x;
rect.Y = (size.Height + this.intPageSpacing) * iCount + this.intPageSpacing;
rect.Width = size.Width;
rect.Height = size.Height;
myPages[iCount].ClientBounds = rect;
}
//为每一个矩形设置实际显示大小
this.UpdateCurrentPage();//还不太确定这个的作用