Esempio n. 1
0
        private HCDataAnnotate GetDrawItemFirstDataAnnotateAt(int aDrawItemNo, int x, int y)
        {
            HCDataAnnotate Result = null;

            int vStyleNo = GetDrawItemStyle(aDrawItemNo);

            if (vStyleNo > HCStyle.Null)
            {
                Style.ApplyTempStyle(vStyleNo);
            }

            if (DrawItemOfAnnotate(aDrawItemNo, Style.TempCanvas, DrawItems[aDrawItemNo].Rect))
            {
                POINT vPt = new POINT(x, y);
                for (int i = 0; i <= FDrawItemAnnotates.Count - 1; i++)
                {
                    if (HC.PtInRect(FDrawItemAnnotates[i].DrawRect, vPt))
                    {
                        Result = FDrawItemAnnotates[i].DataAnnotate;
                        break;
                    }
                }
            }

            return(Result);
        }
Esempio n. 2
0
        /// <summary> 指定DrawItem范围内的批注获取各自的DrawItem范围 </summary>
        /// <param name="AFirstDrawItemNo">起始DrawItem</param>
        /// <param name="ALastDrawItemNo">结束DrawItem</param>
        private void CheckAnnotateRange(int aFirstDrawItemNo, int aLastDrawItemNo)
        {
            if (aFirstDrawItemNo < 0)
            {
                return;
            }

            int vFirstNo = this.DrawItems[aFirstDrawItemNo].ItemNo;
            int vLastNo  = this.DrawItems[aLastDrawItemNo].ItemNo;

            for (int i = 0; i <= FDataAnnotates.Count - 1; i++)
            {
                HCDataAnnotate vDataAnnotate = FDataAnnotates[i];

                if (vDataAnnotate.EndItemNo < vFirstNo)  // 未进入本次查找范围
                {
                    continue;
                }

                if (vDataAnnotate.StartItemNo > vLastNo)  // 超出本次查找的范围
                {
                    break;
                }

                vDataAnnotate.StartDrawItemNo =
                    this.GetDrawItemNoByOffset(vDataAnnotate.StartItemNo, vDataAnnotate.StartItemOffset);
                vDataAnnotate.EndDrawItemNo =
                    this.GetDrawItemNoByOffset(vDataAnnotate.EndItemNo, vDataAnnotate.EndItemOffset);
                if (vDataAnnotate.EndItemOffset == this.DrawItems[vDataAnnotate.EndDrawItemNo].CharOffs)  // 如果在结束的最前面,按上一个
                {
                    vDataAnnotate.EndDrawItemNo = vDataAnnotate.EndDrawItemNo - 1;
                }
            }
        }
Esempio n. 3
0
        protected override void DoLoadFromStream(Stream aStream, HCStyle aStyle, ushort aFileVersion)
        {
            base.DoLoadFromStream(aStream, aStyle, aFileVersion);

            if (aFileVersion > 22 && aFileVersion < 55)
            {
                ushort vAnnCount = 0;
                byte[] vBuffer   = BitConverter.GetBytes(vAnnCount);
                aStream.Read(vBuffer, 0, vBuffer.Length);
                vAnnCount = BitConverter.ToUInt16(vBuffer, 0);
                if (vAnnCount > 0)
                {
                    for (int i = 0; i < vAnnCount; i++)
                    {
                        HCDataAnnotate vAnn = new HCDataAnnotate();
                        vAnn.LoadFromStream(aStream, aFileVersion);
                        //FDataAnnotates.Add(vAnn);
                    }
                }
            }

            if (aFileVersion > 54)
            {
                byte[] vBuffer = BitConverter.GetBytes(FNextID);
                aStream.Read(vBuffer, 0, vBuffer.Length);
                FNextID = BitConverter.ToUInt32(vBuffer, 0);
            }
            else
            {
                FNextID = 0;
            }
        }
Esempio n. 4
0
 public HCAnnotateData(HCStyle aStyle) : base(aStyle)
 {
     FDataAnnotates = new HCDataAnnotates();
     FDataAnnotates.OnInsertAnnotate = DoInsertAnnotate;
     FDataAnnotates.OnRemoveAnnotate = DoRemoveAnnotate;
     FDrawItemAnnotates = new HCDrawItemAnnotates();
     FHotAnnotate       = null;
     FActiveAnnotate    = null;
 }
Esempio n. 5
0
        public void NewDrawAnnotate(RECT aRect, HCAnnotateMark aMark, HCDataAnnotate aDataAnnotate)
        {
            HCDrawItemAnnotate vDrawItemAnnotate = new HCDrawItemAnnotate();

            vDrawItemAnnotate.DrawRect     = aRect;
            vDrawItemAnnotate.Mark         = aMark;
            vDrawItemAnnotate.DataAnnotate = aDataAnnotate;
            this.Add(vDrawItemAnnotate);
        }
        public override void GetCaretInfo(int aItemNo, int aOffset, ref HCCaretInfo aCaretInfo)
        {
            base.GetCaretInfo(aItemNo, aOffset, ref aCaretInfo);

            if (!this.Style.UpdateInfo.DragingSelected && this.SelectExists())
            {
                if (this.SelectInSameDrawItem() && (this.Items[SelectInfo.StartItemNo].StyleNo < HCStyle.Null))
                {
                }
                else
                {
                    aCaretInfo.Visible = false;
                }
            }

            int vCaretDrawItemNo = -1;

            if (this.CaretDrawItemNo < 0)
            {
                if (Style.UpdateInfo.DragingSelected)
                {
                    vCaretDrawItemNo = GetDrawItemNoByOffset(this.MouseMoveItemNo, this.MouseMoveItemOffset);
                }
                else
                {
                    vCaretDrawItemNo = GetDrawItemNoByOffset(SelectInfo.StartItemNo, SelectInfo.StartItemOffset);
                }
            }
            else
            {
                vCaretDrawItemNo = CaretDrawItemNo;
            }

            HCDataAnnotate vDataAnnotate = null;

            if (Style.UpdateInfo.DragingSelected)
            {
                vDataAnnotate = GetDrawItemFirstDataAnnotateAt(vCaretDrawItemNo,
                                                               GetDrawItemOffsetWidth(vCaretDrawItemNo,
                                                                                      this.MouseMoveItemOffset - DrawItems[vCaretDrawItemNo].CharOffs + 1),
                                                               DrawItems[vCaretDrawItemNo].Rect.Top + 1);
            }
            else
            {
                vDataAnnotate = GetDrawItemFirstDataAnnotateAt(vCaretDrawItemNo,
                                                               GetDrawItemOffsetWidth(vCaretDrawItemNo,
                                                                                      SelectInfo.StartItemOffset - DrawItems[vCaretDrawItemNo].CharOffs + 1),
                                                               DrawItems[vCaretDrawItemNo].Rect.Top + 1);
            }

            if (FActiveAnnotate != vDataAnnotate)
            {
                FActiveAnnotate = vDataAnnotate;
                Style.UpdateInfoRePaint();
            }
        }
Esempio n. 7
0
        public override void MouseMove(MouseEventArgs e)
        {
            base.MouseMove(e);

            HCDataAnnotate vDataAnnotate = GetDrawItemFirstDataAnnotateAt(MouseMoveDrawItemNo, e.X, e.Y);

            if (FHotAnnotate != vDataAnnotate)
            {
                FHotAnnotate = vDataAnnotate;
                Style.UpdateInfoRePaint();
            }
        }
Esempio n. 8
0
        public override void GetCaretInfo(int aItemNo, int aOffset, ref HCCaretInfo aCaretInfo)
        {
            base.GetCaretInfo(aItemNo, aOffset, ref aCaretInfo);

            int vCaretDrawItemNo = -1;

            if (this.CaretDrawItemNo < 0)
            {
                if (Style.UpdateInfo.Draging)
                {
                    vCaretDrawItemNo = GetDrawItemNoByOffset(this.MouseMoveItemNo, this.MouseMoveItemOffset);
                }
                else
                {
                    vCaretDrawItemNo = GetDrawItemNoByOffset(SelectInfo.StartItemNo, SelectInfo.StartItemOffset);
                }
            }
            else
            {
                vCaretDrawItemNo = CaretDrawItemNo;
            }

            HCDataAnnotate vDataAnnotate = null;

            if (Style.UpdateInfo.Draging)
            {
                vDataAnnotate = GetDrawItemFirstDataAnnotateAt(vCaretDrawItemNo,
                                                               GetDrawItemOffsetWidth(vCaretDrawItemNo,
                                                                                      this.MouseMoveItemOffset - DrawItems[vCaretDrawItemNo].CharOffs + 1),
                                                               DrawItems[vCaretDrawItemNo].Rect.Top + 1);
            }
            else
            {
                vDataAnnotate = GetDrawItemFirstDataAnnotateAt(vCaretDrawItemNo,
                                                               GetDrawItemOffsetWidth(vCaretDrawItemNo,
                                                                                      SelectInfo.StartItemOffset - DrawItems[vCaretDrawItemNo].CharOffs + 1),
                                                               DrawItems[vCaretDrawItemNo].Rect.Top + 1);
            }

            if (FActiveAnnotate != vDataAnnotate)
            {
                FActiveAnnotate = vDataAnnotate;
                Style.UpdateInfoRePaint();
            }
        }
Esempio n. 9
0
        public override void LoadFromStream(Stream aStream, HCStyle aStyle, ushort aFileVersion)
        {
            base.LoadFromStream(aStream, aStyle, aFileVersion);

            if (aFileVersion > 22)
            {
                ushort vAnnCount = 0;
                byte[] vBuffer   = BitConverter.GetBytes(vAnnCount);
                aStream.Read(vBuffer, 0, vBuffer.Length);
                if (vAnnCount > 0)
                {
                    for (int i = 0; i <= vAnnCount - 1; i++)
                    {
                        HCDataAnnotate vAnn = new HCDataAnnotate();
                        vAnn.LoadFromStream(aStream, aFileVersion);
                        FDataAnnotates.Add(vAnn);
                    }
                }
            }
        }
Esempio n. 10
0
 public override void InitializeField()
 {
     base.InitializeField();
     FHotAnnotate    = null;
     FActiveAnnotate = null;
 }
Esempio n. 11
0
        /// <summary> 获取指定的DrawItem所属的批注以及在各批注中的区域 </summary>
        /// <param name="ADrawItemNo"></param>
        /// <param name="ACanvas">应用了DrawItem样式的Canvas</param>
        /// <returns></returns>
        private bool DrawItemOfAnnotate(int aDrawItemNo, HCCanvas aCanvas, RECT aDrawRect)
        {
            if (FDataAnnotates.Count == 0)
            {
                return(false);
            }

            int vItemNo = this.DrawItems[aDrawItemNo].ItemNo;

            if (vItemNo < FDataAnnotates.First.StartItemNo)
            {
                return(false);
            }
            if (vItemNo > FDataAnnotates.Last.EndItemNo)
            {
                return(false);
            }

            bool Result = false;

            FDrawItemAnnotates.Clear();
            for (int i = 0; i <= FDataAnnotates.Count - 1; i++)
            {
                HCDataAnnotate vDataAnnotate = FDataAnnotates[i];
                if (vDataAnnotate.EndItemNo < vItemNo)
                {
                    continue;
                }

                if (vDataAnnotate.StartItemNo > vItemNo)
                {
                    break;
                }

                if (aDrawItemNo == vDataAnnotate.StartDrawItemNo)
                {
                    if (aDrawItemNo == vDataAnnotate.EndDrawItemNo)
                    {
                        FDrawItemAnnotates.NewDrawAnnotate(
                            new RECT(aDrawRect.Left + GetDrawItemOffsetWidth(aDrawItemNo, vDataAnnotate.StartItemOffset - this.DrawItems[aDrawItemNo].CharOffs + 1, aCanvas),
                                     aDrawRect.Top,
                                     aDrawRect.Left + GetDrawItemOffsetWidth(aDrawItemNo, vDataAnnotate.EndItemOffset - this.DrawItems[aDrawItemNo].CharOffs + 1, aCanvas),
                                     aDrawRect.Bottom),
                            HCAnnotateMark.amBoth, vDataAnnotate);
                    }
                    else  // 仅是批注头
                    {
                        FDrawItemAnnotates.NewDrawAnnotate(
                            new RECT(aDrawRect.Left + GetDrawItemOffsetWidth(aDrawItemNo, vDataAnnotate.StartItemOffset - this.DrawItems[aDrawItemNo].CharOffs + 1, aCanvas),
                                     aDrawRect.Top, aDrawRect.Right, aDrawRect.Bottom),
                            HCAnnotateMark.amFirst, vDataAnnotate);
                    }

                    Result = true;
                }
                else
                if (aDrawItemNo == vDataAnnotate.EndDrawItemNo)      // 当前DrawItem是批注结束
                {
                    FDrawItemAnnotates.NewDrawAnnotate(
                        new RECT(aDrawRect.Left, aDrawRect.Top,
                                 aDrawRect.Left + GetDrawItemOffsetWidth(aDrawItemNo, vDataAnnotate.EndItemOffset - this.DrawItems[aDrawItemNo].CharOffs + 1, aCanvas),
                                 aDrawRect.Bottom),
                        HCAnnotateMark.amLast, vDataAnnotate);

                    Result = true;
                }
                else
                {
                    FDrawItemAnnotates.NewDrawAnnotate(aDrawRect, HCAnnotateMark.amNormal, vDataAnnotate);
                    Result = true;
                }
            }

            return(Result);
        }