/// <summary> /// 绘制Item的事件 /// </summary> /// <param name="ACanvas"></param> /// <param name="aDrawRect">当前DrawItem的区域</param> /// <param name="ADataDrawBottom">Item所在的Data本次绘制底部位置</param> /// <param name="ADataScreenTop"></param> /// <param name="ADataScreenBottom"></param> public void PaintTo(HCStyle aStyle, RECT aDrawRect, int APageDataDrawTop, int APageDataDrawBottom, int APageDataScreenTop, int APageDataScreenBottom, HCCanvas ACanvas, PaintInfo APaintInfo) // 不可继承 { if (APaintInfo.Print && FPrintInvisible) { return; } int vDCState = ACanvas.Save(); try { DoPaint(aStyle, aDrawRect, APageDataDrawTop, APageDataDrawBottom, APageDataScreenTop, APageDataScreenBottom, ACanvas, APaintInfo); } finally { ACanvas.Restore(vDCState); ACanvas.Refresh(); // 处理下一个使用Pen时修改Pen的属性值和当前属性值一样时,不会触发Canvas重新SelectPen导致Pen的绘制失效的问题 } }
public override void LoadFromStream(Stream aStream, HCStyle aStyle, ushort aFileVersion) { // StyleNo加载时先读取并根据值创建 byte[] vBuffer = BitConverter.GetBytes(FLeft); aStream.Read(vBuffer, 0, vBuffer.Length); FLeft = BitConverter.ToInt32(vBuffer, 0); vBuffer = BitConverter.GetBytes(FTop); aStream.Read(vBuffer, 0, vBuffer.Length); FTop = BitConverter.ToInt32(vBuffer, 0); vBuffer = BitConverter.GetBytes(Width); aStream.Read(vBuffer, 0, vBuffer.Length); Width = BitConverter.ToInt32(vBuffer, 0); vBuffer = BitConverter.GetBytes(Height); aStream.Read(vBuffer, 0, vBuffer.Length); Height = BitConverter.ToInt32(vBuffer, 0); if (aFileVersion > 28) { vBuffer = BitConverter.GetBytes(FPageIndex); aStream.Read(vBuffer, 0, vBuffer.Length); FPageIndex = BitConverter.ToInt32(vBuffer, 0); } if (aFileVersion > 37) { vBuffer = BitConverter.GetBytes(FLock); aStream.Read(vBuffer, 0, vBuffer.Length); FLock = BitConverter.ToBoolean(vBuffer, 0); } else { FLock = false; } }
public virtual void LoadFromStream(Stream aStream, HCStyle aStyle, ushort aFileVersion) { byte[] vBuffer = BitConverter.GetBytes(FParaNo); aStream.Read(vBuffer, 0, vBuffer.Length); FParaNo = System.BitConverter.ToInt32(vBuffer, 0); if (aFileVersion > 25) { FOptions.Value = (byte)aStream.ReadByte(); } else { vBuffer = BitConverter.GetBytes(ParaFirst); aStream.Read(vBuffer, 0, vBuffer.Length); ParaFirst = BitConverter.ToBoolean(vBuffer, 0); } if (aFileVersion > 33) { byte vByte = (byte)aStream.ReadByte(); FPrintInvisible = HC.IsOdd(vByte >> 7); } }
public override void LoadFromStream(Stream AStream, HCStyle AStyle, ushort AFileVersion) { // StyleNo加载时先读取并根据值创建 byte[] vBuffer = BitConverter.GetBytes(FLeft); AStream.Read(vBuffer, 0, vBuffer.Length); FLeft = BitConverter.ToInt32(vBuffer, 0); vBuffer = BitConverter.GetBytes(FTop); AStream.Read(vBuffer, 0, vBuffer.Length); FTop = BitConverter.ToInt32(vBuffer, 0); vBuffer = BitConverter.GetBytes(FLeft); AStream.Read(vBuffer, 0, vBuffer.Length); FLeft = BitConverter.ToInt32(vBuffer, 0); vBuffer = BitConverter.GetBytes(FLeft); AStream.Read(vBuffer, 0, vBuffer.Length); Width = BitConverter.ToInt32(vBuffer, 0); vBuffer = BitConverter.GetBytes(FLeft); AStream.Read(vBuffer, 0, vBuffer.Length); Height = BitConverter.ToInt32(vBuffer, 0); }
protected override void DoPaint(HCStyle AStyle, RECT ADrawRect, int ADataDrawTop, int ADataDrawBottom, int ADataScreenTop, int ADataScreenBottom, HCCanvas ACanvas, PaintInfo APaintInfo) { base.DoPaint(AStyle, ADrawRect, ADataDrawTop, ADataDrawBottom, ADataScreenTop, ADataScreenBottom, ACanvas, APaintInfo); FButtonDrawRect = FButtonRect; FButtonDrawRect.Offset(ADrawRect.Left, ADrawRect.Top); if (IsSelectComplate) { ACanvas.Brush.Color = AStyle.SelColor; } else if (FMouseInButton) { ACanvas.Brush.Color = HC.clMenu; } else { ACanvas.Brush.Color = HC.clWindow; } ACanvas.FillRect(FButtonDrawRect); ACanvas.Pen.Color = Color.Black; int vLeft = FButtonDrawRect.Left + (BTNWIDTH - 7) / 2; int vTop = FButtonDrawRect.Top + (FButtonDrawRect.Height - 4) / 2; for (int i = 0; i <= 3; i++) { ACanvas.MoveTo(vLeft, vTop); ACanvas.LineTo(vLeft + 7 - i - i, vTop); vLeft++; vTop++; } }
private void _FormatBreakTextDrawItem(int aItemNo, int aFmtLeft, int aFmtRight, ref int aDrawItemNo, ref POINT aPos, ref RECT vRect, ref int vRemainderWidth, ref bool vParaFirst) { HCCanvas vCanvas = HCStyle.CreateStyleCanvas(); try { HCCustomDrawItem vDrawItem = DrawItems[aDrawItemNo]; HCCustomItem vItemBK = Items[vDrawItem.ItemNo]; int vLen = vItemBK.Text.Length; CalcItemFormatHeigh(vItemBK); int vWidth = Style.TempCanvas.TextWidth(vItemBK.Text[vLen - 1]); // 分裂前 vDrawItem.CharLen = vDrawItem.CharLen - 1; vDrawItem.Rect.Right = vDrawItem.Rect.Right - vWidth; vRemainderWidth = aFmtRight - vDrawItem.Rect.Right; FinishLine(aItemNo, aDrawItemNo, vRemainderWidth); // 分裂后 aPos.X = aFmtLeft; aPos.Y = vDrawItem.Rect.Bottom; vRect.Left = aPos.X; vRect.Top = aPos.Y; vRect.Right = vRect.Left + vWidth; vRect.Bottom = vRect.Top + FItemFormatHeight; NewDrawItem(vDrawItem.ItemNo, vLen - 1, 1, vRect, false, true, ref aDrawItemNo); vParaFirst = false; aPos.X = vRect.Right; vRemainderWidth = aFmtRight - vRect.Right; // 放入最多后的剩余量 } finally { HCStyle.DestroyStyleCanvas(vCanvas); } }
public override void LoadFromStream(Stream aStream, HCStyle aStyle, ushort aFileVersion) { base.LoadFromStream(aStream, aStyle, aFileVersion); byte[] vBuffer = BitConverter.GetBytes(FTextStyleNo); aStream.Read(vBuffer, 0, vBuffer.Length); FTextStyleNo = BitConverter.ToInt32(vBuffer, 0); if (!OwnerData.Style.States.Contain(HCState.hosLoading)) { if (aStyle != null) { FTextStyleNo = OwnerData.Style.GetStyleNo(aStyle.TextStyles[FTextStyleNo], true); } else { FTextStyleNo = 0; } } else if ((aStyle != null) && (FTextStyleNo > aStyle.TextStyles.Count - 1)) // 兼容历史错误(删除多余样式时没有) { FTextStyleNo = 0; } }
public override void LoadFromStream(System.IO.Stream aStream, HCStyle aStyle, ushort aFileVersion) { base.LoadFromStream(aStream, aStyle, aFileVersion); uint vSize = 0; byte[] vBuffer = BitConverter.GetBytes(vSize); aStream.Read(vBuffer, 0, vBuffer.Length); vSize = BitConverter.ToUInt32(vBuffer, 0); vBuffer = new byte[vSize]; aStream.Read(vBuffer, 0, vBuffer.Length); using (MemoryStream vImgStream = new MemoryStream(vBuffer)) { FGifImage = Image.FromStream(vImgStream); } this.Width = FGifImage.Width; this.Height = FGifImage.Height; FAnimate = true; BeginAnimate(); // 调用开始动画方法 }
public override void LoadFromStream(Stream aStream, HCStyle aStyle, ushort aFileVersion) { base.LoadFromStream(aStream, aStyle, aFileVersion); // read bitmap data size uint vSize = 0; byte[] vBuffer = BitConverter.GetBytes(vSize); aStream.Read(vBuffer, 0, vBuffer.Length); vSize = BitConverter.ToUInt32(vBuffer, 0); if (vSize > 0) { vBuffer = new byte[vSize]; aStream.Read(vBuffer, 0, vBuffer.Length); using (MemoryStream vImgStream = new MemoryStream(vBuffer)) { FImage = new Bitmap(vImgStream); } FEmpty = false; } else { FImage = new Bitmap(this.Width, this.Height); FEmpty = true; } if (aFileVersion > 26) { FShapeManager.LoadFromStream(aStream); } DoImageChange(this); }
public override void LoadFromStream(Stream AStream, HCStyle AStyle, ushort AFileVersion) { base.LoadFromStream(AStream, AStyle, AFileVersion); if (AFileVersion > 12) { int vFloatCount = 0; byte[] vBuffer = BitConverter.GetBytes(vFloatCount); AStream.Read(vBuffer, 0, vBuffer.Length); vFloatCount = BitConverter.ToInt32(vBuffer, 0); HCFloatItem vFloatItem = null; while (vFloatCount > 0) { int vStyleNo = HCStyle.Null; vBuffer = BitConverter.GetBytes(vStyleNo); AStream.Read(vBuffer, 0, vBuffer.Length); vFloatItem = CreateFloatItemByStyle(vStyleNo); vFloatItem.LoadFromStream(AStream, AStyle, AFileVersion); FFloatItems.Add(vFloatItem); vFloatCount--; } } }
private void DoLoadFromStream(Stream stream, HCStyle style, LoadSectionProcHandler loadSectionProc) { stream.Position = 0; string vFileExt = ""; ushort vFileVersion = 0; byte vLang = 0; HC._LoadFileFormatAndVersion(stream, ref vFileExt, ref vFileVersion, ref vLang); if (vFileExt != HC.HC_EXT) { throw new Exception("加载失败,不是" + HC.HC_EXT + "文件!"); } if (vFileVersion > HC.HC_FileVersionInt) { throw new Exception("加载失败,当前编辑器最高支持版本为" + HC.HC_FileVersionInt.ToString() + "的文件,无法打开版本为" + vFileVersion.ToString() + "的文件!"); } DoLoadStreamBefor(stream, vFileVersion); // 触发加载前事件 style.LoadFromStream(stream, vFileVersion); // 加载样式表 loadSectionProc(vFileVersion); // 加载节数量、节数据 DoLoadStreamAfter(stream, vFileVersion); }
public override void LoadFromStream(Stream AStream, HCStyle AStyle, ushort AFileVersion) { base.LoadFromStream(AStream, AStyle, AFileVersion); HC.HCLoadTextFromStream(AStream, ref FTopText); HC.HCLoadTextFromStream(AStream, ref FBottomText); }
protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo) { base.DoPaint(aStyle, aDrawRect, aDataDrawTop, aDataDrawBottom, aDataScreenTop, aDataScreenBottom, aCanvas, aPaintInfo); if (!aPaintInfo.Print) { if (FReadOnly) { aCanvas.Brush.Color = HC.clBtnFace; aCanvas.FillRect(aDrawRect); } else if (this.IsSelectComplate) { aCanvas.Brush.Color = aStyle.SelColor; aCanvas.FillRect(aDrawRect); } if (SelectTextExists()) { aCanvas.Brush.Color = aStyle.SelColor; int vLeft = GetCharDrawLeft(FCaretOffset); int vRight = GetCharDrawLeft(FSelEnd); vLeft = Math.Max(0, Math.Min(vLeft, Width)); vRight = Math.Max(0, Math.Min(vRight, Width)); aCanvas.FillRect(new RECT(aDrawRect.Left + vLeft, aDrawRect.Top, aDrawRect.Left + vRight, aDrawRect.Bottom)); } } aStyle.TextStyles[TextStyleNo].ApplyStyle(aCanvas, aPaintInfo.ScaleY / aPaintInfo.Zoom); if (!this.AutoSize) { aCanvas.TextRect(aDrawRect, aDrawRect.Left + FPaddingLeft - FLeftOffset, aDrawRect.Top + FPaddingTop, FText); } else { aCanvas.TextOut(aDrawRect.Left + FPaddingLeft, aDrawRect.Top + FPaddingTop, FText); } if (aPaintInfo.Print && FPrintOnlyText) { return; } if (FBorderSides.Value > 0) { if (FMouseIn || Active) { aCanvas.Pen.Color = Color.Blue; } else // 鼠标不在其中或打印 { aCanvas.Pen.Color = Color.Black; } aCanvas.Pen.Width = FBorderWidth; aCanvas.Pen.Style = HCPenStyle.psSolid; if (FBorderSides.Contains((byte)BorderSide.cbsLeft)) { aCanvas.MoveTo(aDrawRect.Left, aDrawRect.Top); aCanvas.LineTo(aDrawRect.Left, aDrawRect.Bottom); } if (FBorderSides.Contains((byte)BorderSide.cbsTop)) { aCanvas.MoveTo(aDrawRect.Left, aDrawRect.Top); aCanvas.LineTo(aDrawRect.Right, aDrawRect.Top); } if (FBorderSides.Contains((byte)BorderSide.cbsRight)) { aCanvas.MoveTo(aDrawRect.Right - 1, aDrawRect.Top); aCanvas.LineTo(aDrawRect.Right - 1, aDrawRect.Bottom); } if (FBorderSides.Contains((byte)BorderSide.cbsBottom)) { aCanvas.MoveTo(aDrawRect.Left, aDrawRect.Bottom - 1); aCanvas.LineTo(aDrawRect.Right, aDrawRect.Bottom - 1); } } }
public HCRichData(HCStyle AStyle) : base(AStyle) { FDomainStartDeletes = new List <int>(); FHotDomain = new HCDomain(); FActiveDomain = new HCDomain(); }
public virtual bool InsertStream(Stream aStream, HCStyle aStyle, ushort aFileVersion) { return(false); }
public override void LoadFromStream(Stream aStream, HCStyle aStyle, ushort aFileVersion) { base.LoadFromStream(aStream, aStyle, aFileVersion); FLineHeight = (byte)aStream.ReadByte(); FLineStyle = (HCPenStyle)aStream.ReadByte(); }
public override void LoadFromStream(Stream aStream, HCStyle aStyle, ushort aFileVersion) { base.LoadFromStream(aStream, aStyle, aFileVersion); HC.HCLoadTextFromStream(aStream, ref FText, aFileVersion); }
protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo) { if (this.Active && (!aPaintInfo.Print)) { aCanvas.Brush.Color = HC.clBtnFace; aCanvas.FillRect(aDrawRect); } if (!FLineHide) // 分数线 { aCanvas.Pen.Color = Color.Black; aCanvas.MoveTo(aDrawRect.Left + FPadding, aDrawRect.Top + FTopRect.Bottom + FPadding); aCanvas.LineTo(aDrawRect.Left + Width - FPadding, aDrawRect.Top + FTopRect.Bottom + FPadding); } if (!aPaintInfo.Print) { RECT vFocusRect = new RECT(); if (FActiveArea != ExpressArea.ceaNone) { if (FActiveArea == ExpressArea.ceaTop) { vFocusRect = FTopRect; } else if (FActiveArea == ExpressArea.ceaBottom) { vFocusRect = FBottomRect; } vFocusRect.Offset(aDrawRect.Left, aDrawRect.Top); vFocusRect.Inflate(2, 2); aCanvas.Pen.Color = Color.Blue; aCanvas.Rectangle(vFocusRect); } if ((FMouseMoveArea != ExpressArea.ceaNone) && (FMouseMoveArea != FActiveArea)) { if (FMouseMoveArea == ExpressArea.ceaTop) { vFocusRect = FTopRect; } else if (FMouseMoveArea == ExpressArea.ceaBottom) { vFocusRect = FBottomRect; } vFocusRect.Offset(aDrawRect.Left, aDrawRect.Top); vFocusRect.Inflate(2, 2); aCanvas.Pen.Color = HC.clMedGray; aCanvas.Rectangle(vFocusRect); } } aStyle.TextStyles[TextStyleNo].ApplyStyle(aCanvas, aPaintInfo.ScaleY / aPaintInfo.Zoom); aCanvas.TextOut(aDrawRect.Left + FTopRect.Left, aDrawRect.Top + FTopRect.Top, FTopText); aCanvas.TextOut(aDrawRect.Left + FBottomRect.Left, aDrawRect.Top + FBottomRect.Top, FBottomText); }
public static void DeleteUnUsedStyle(HCStyle style, List <HCSection> sections, HashSet <SectionArea> parts) { style.TextStyles[0].CheckSaveUsed = true; style.TextStyles[0].TempNo = 0; for (int i = 1; i < style.TextStyles.Count; i++) { style.TextStyles[i].CheckSaveUsed = false; style.TextStyles[i].TempNo = HCStyle.Null; } for (int i = 0; i < style.ParaStyles.Count; i++) { style.ParaStyles[i].CheckSaveUsed = false; style.ParaStyles[i].TempNo = HCStyle.Null; } for (int i = 0; i < sections.Count; i++) { sections[i].MarkStyleUsed(true, parts); } int vUnCount = 0; for (int i = 1; i < style.TextStyles.Count; i++) { if (style.TextStyles[i].CheckSaveUsed) { style.TextStyles[i].TempNo = i - vUnCount; } else { vUnCount++; } } vUnCount = 0; for (int i = 0; i < style.ParaStyles.Count; i++) { if (style.ParaStyles[i].CheckSaveUsed) { style.ParaStyles[i].TempNo = i - vUnCount; } else { vUnCount++; } } HCCustomData vData = null; for (int i = 0; i < sections.Count; i++) { sections[i].MarkStyleUsed(false, parts); vData = sections[i].ActiveData.GetTopLevelData(); if (vData.CurStyleNo > HCStyle.Null) { vData.CurStyleNo = style.TextStyles[vData.CurStyleNo].TempNo; } vData.CurParaNo = style.ParaStyles[vData.CurParaNo].TempNo; } for (int i = style.TextStyles.Count - 1; i >= 1; i--) { if (!style.TextStyles[i].CheckSaveUsed) { style.TextStyles.RemoveAt(i); } } for (int i = style.ParaStyles.Count - 1; i >= 0; i--) { if (!style.ParaStyles[i].CheckSaveUsed) { style.ParaStyles.RemoveAt(i); } } }
public override void LoadFromStream(Stream aStream, HCStyle aStyle, ushort aFileVersion) { base.LoadFromStream(aStream, aStyle, aFileVersion); FMarkType = (MarkType)aStream.ReadByte(); }
protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo) { FCode128.PaintTo(aCanvas, aDrawRect); base.DoPaint(aStyle, aDrawRect, aDataDrawTop, aDataDrawBottom, aDataScreenTop, aDataScreenBottom, aCanvas, aPaintInfo); }
public override bool StyleHasMatch(HCStyle aStyle, int aCurStyleNo) { return(aStyle.TextStyles[aCurStyleNo].FontStyles.Contains((byte)FFontStyle)); }
public HCUndoData(HCStyle aStyle) : base(aStyle) { FUndoGroupCount = 0; FItemAddCount = 0; }
public override void LoadFromStream(Stream AStream, HCStyle AStyle, ushort AFileVersion) { base.LoadFromStream(AStream, AStyle, AFileVersion); FLineHeight = (byte)AStream.ReadByte(); FLineStyle = (HCPenStyle)AStream.ReadByte(); }
public override void ApplySelectTextStyle(HCStyle aStyle, HCStyleMatch aMatchStyle) { FTextStyleNo = aMatchStyle.GetMatchStyleNo(aStyle, FTextStyleNo); }
protected void Paste() { IDataObject vIData = Clipboard.GetDataObject(); if (vIData.GetDataPresent(HC.HC_EXT)) { MemoryStream vStream = (MemoryStream)vIData.GetData(HC.HC_EXT); try { string vFileFormat = ""; ushort vFileVersion = 0; byte vLan = 0; vStream.Position = 0; HC._LoadFileFormatAndVersion(vStream, ref vFileFormat, ref vFileVersion, ref vLan); // 文件格式和版本 HCStyle vStyle = new HCStyle(); try { vStyle.LoadFromStream(vStream, vFileVersion); this.BeginUpdate(); try { FData.InsertStream(vStream, vStyle, vFileVersion); } finally { this.EndUpdate(); } } finally { vStyle.Dispose(); } } finally { vStream.Close(); vStream.Dispose(); } } else if (vIData.GetDataPresent(DataFormats.Text)) { FData.InsertText(Clipboard.GetText()); } else if (vIData.GetDataPresent(DataFormats.Bitmap)) { Image vImage = (Image)vIData.GetData(typeof(Bitmap)); HCRichData vTopData = FData.GetTopLevelData() as HCRichData; HCImageItem vImageItem = new HCImageItem(vTopData); vImageItem.Image = new Bitmap(vImage); vImageItem.Width = vImageItem.Image.Width; vImageItem.Height = vImageItem.Image.Height; vImageItem.RestrainSize(vTopData.Width, vImageItem.Height); FData.InsertItem(vImageItem); } }
public HCTableCellData(HCStyle aStyle) : base(aStyle) { }
protected virtual void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo) { }
public virtual bool StyleHasMatch(HCStyle aStyle, int aCurStyleNo) { return(false); }
public HCViewData(HCStyle aStyle) : base(aStyle) { FDomainStartDeletes = new List <int>(); FHotDomain = new HCDomainInfo(); FActiveDomain = new HCDomainInfo(); }