Ejemplo n.º 1
0
 public DComboBox()
 {
     MType = MemberType.ComboBox;
     _tempMember = MDocument.CreateTextChar(EditorSetting.DefaultGraphics, "下拉框");
     Add(_tempMember);
     SetText = delegate(string text)
         {
             Reset();
             Add(MDocument.CreateTextChar(EditorSetting.DefaultGraphics, text));
             Invalidate();
         };
 }
Ejemplo n.º 2
0
 public void Add(DRowMember member)
 {
     if (CurrentMember == null)
     {
         _firstMember.NextMember = member;
         _lastMember.PreMember = member;
         member.NextMember = _lastMember;
         member.PreMember = _firstMember;
     }
     else
     {
         member.PreMember = CurrentMember;
         member.NextMember = CurrentMember.NextMember;
         CurrentMember.NextMember.PreMember = member;
         CurrentMember.NextMember = member;
     }
     CurrentMember = member;
     _firstMember.Height = _firstMember.NextMember.Height;
     _lastMember.Height = _lastMember.PreMember.Height;
     this.Width += member.Width;
     if (member.Height > this.Height) this.Height = member.Height;
     ResetPosition(GetHighestMember());
 }
Ejemplo n.º 3
0
 private void ProcessCurrentMember(DRowMember member, int x)
 {
     switch (member.MType)
     {
         case MemberType.TextInput:
             CurrentMember = member;
             break;
         case MemberType.CheckBox:
             break;
         case MemberType.ComboBox:
             break;
         case MemberType.Table:
             OwnerDocument.ClickMembers.Add(member);
             break;
         case MemberType.Image:
             OwnerDocument.ClickMembers.Add(member);
             break;
         case MemberType.HorizonLine:
             OwnerDocument.ClickMembers.Add(member);
             break;
     }
     member.MouseClick();
 }
Ejemplo n.º 4
0
 private void JoinMember(DRowMember fMember, DRowMember sMember)
 {
     if (fMember == null || sMember == null) return;
     fMember.NextMember = sMember;
     sMember.PreMember = fMember;
 }
Ejemplo n.º 5
0
 private bool IsOutRange(DRowMember fmember, DRowMember sMember)
 {
     return fmember.X + fmember.Width + sMember.Width > this.X + this.Width;
 }
Ejemplo n.º 6
0
 private bool IsInMemeberRange(DRowMember member, int x, int y)
 {
     if (member.NextMember == null)
     {
         return ((x > member.X + member.Width / 2 && x <= member.X + member.Width)
                 || (x > member.X + member.Width)) &&
                 y >= member.Y && y < member.Y + member.Height;
     }
     else
     {
         return (x > member.X + member.Width / 2 && x <= member.X + member.Width &&
                 y >= member.Y && y < member.Y + member.Height)
                 || (x > member.NextMember.X && x <= member.NextMember.X + member.NextMember.Width / 2 &&
                     y >= member.NextMember.Y && y < member.NextMember.Y + member.NextMember.Height);
     }
 }
Ejemplo n.º 7
0
 public void AddSelecteMember(DRowMember member)
 {
     if (SelectedMembers.Contains(member)) return;
     SelectedMembers.Add(member);
 }
Ejemplo n.º 8
0
 private bool IsInMemberRange(DRowMember member, int x)
 {
     return x >= member.X + member.Width / 2 && member.NextMember != null &&
            x <= member.NextMember.X + member.NextMember.Width / 2;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 将传入的成员链末尾与该行首成员进行连接,超出的
        /// 尾部链自动向下一行遍历连接
        /// </summary>
        public void WriteHead(DRowMember linkedListHead)
        {
            if (linkedListHead == null) return;

            linkedListHead.RecursiveChangeDocRow(this);
            linkedListHead.PreMember = null;
            var lastMember = linkedListHead.GetTailMember();
            lastMember.NextMember = this.FirstMember;

            if (this.FirstMember != null)
            {
                this.FirstMember.PreMember = lastMember;
            }

            //定义两个活动指针
            var leftPointer = lastMember;
            var rightPointer = this.FirstMember;
            DRowMember oLinkedListHeader = null;
            this.FirstMember = linkedListHead;
            var isOutRange = false;

            while (true)
            {
                leftPointer.AfterChangeRow();
                if (rightPointer == null) break;
                //此处断链子
                if (GetRangeResult(rightPointer) == 1)
                {
                    if (Paragraph == RowParagraph.Right || Paragraph == RowParagraph.Middle)
                    {
                        rightPointer = GetOutRangeMember();
                        leftPointer = rightPointer.PreMember;
                    }
                    leftPointer.NextMember = null;
                    rightPointer.PreMember = null;
                    oLinkedListHeader = rightPointer;
                    IsContinue = true;
                    isOutRange = true;
                    break;
                }
                else if (GetRangeResult(rightPointer) == 0)
                {
                    IsContinue = true;
                }
                else
                {
                    IsContinue = false;
                }
                leftPointer.IsBreakTail = false;
                leftPointer = rightPointer;
                rightPointer = rightPointer.NextMember;
            }

            this.LastMember = leftPointer.Equals(linkedListHead) ? null : leftPointer;

            //如果该行未越界则返回
            if (!isOutRange) return;

            if (NextDocRow == null)
            {
                NextDocRow = OwnerDocument.CreateRow();
                NextDocRow.WriteHead(oLinkedListHeader);
            }
            else if (oLinkedListHeader.GetTailMember().IsBreakTail)
            {
                NextDocRow = OwnerDocument.InsertRowBefore(NextDocRow);
                NextDocRow.WriteHead(oLinkedListHeader);
            }
            else
            {
                NextDocRow.WriteHead(oLinkedListHeader);
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 将该行某个成员去除
 /// </summary>
 /// <param name="member"></param>
 public void RemoveMember(DRowMember member)
 {
     if (member == null) return;
     if (member.Equals(FirstMember))
     {
         if (member.NextMember == null)
         {
             FirstMember = null;
             return;
         }
         else if (member.NextMember.Equals(LastMember))
         {
             FirstMember = member.NextMember;
             LastMember = null;
             member.NextMember.PreMember = null;
             member.NextMember = null;
             return;
         }
         FirstMember = member.NextMember;
         member.NextMember.PreMember = null;
         member.NextMember = null;
     }
     else if (member.Equals(LastMember))
     {
         if (member.PreMember.Equals(FirstMember))
         {
             member.PreMember.NextMember = null;
             member.PreMember = null;
             LastMember = null;
             return;
         }
         LastMember = member.PreMember;
         member.PreMember.NextMember = null;
         member.PreMember = null;
     }
     else
     {
         if(member.PreMember != null)
             member.PreMember.NextMember = member.NextMember;
         if(member.NextMember != null)
             member.NextMember.PreMember = member.PreMember;
         member.PreMember = null;
         member.NextMember = null;
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// 从指定成员开始重新排版
        /// </summary>
        public void ReComposing(DRowMember member)
        {
            if (member == null) return;
            var leftPointer = member;
            var rightPointer = member.NextMember;
            DRowMember linkedListHead = null;
            while (true)
            {
                if (rightPointer == null) break;
                //超出界限
                if (rightPointer.X + rightPointer.Width > this.X + this.Width)
                {
                    leftPointer.NextMember = null;
                    rightPointer.PreMember = null;
                    linkedListHead = rightPointer;
                    LastMember = leftPointer;
                    IsContinue = true;
                }
                leftPointer = rightPointer;
                rightPointer = rightPointer.NextMember;
            }

            if (linkedListHead == null) return;

            if (NextDocRow == null)
            {
                NextDocRow = OwnerDocument.CreateRow();
                NextDocRow.WriteHead(linkedListHead);
            }
            else if (linkedListHead.GetTailMember().IsBreakTail)
            {
                NextDocRow = OwnerDocument.InsertRowBefore(NextDocRow);
                NextDocRow.WriteHead(linkedListHead);
            }
            else
            {
                NextDocRow.WriteHead(linkedListHead);
            }
        }
Ejemplo n.º 12
0
 public void LocateCurrentMember(int x, int y)
 {
     CurrentMember = null;
     var tempMember = FirstMember;
     while (tempMember != null)
     {
         if (IsInMemeberRange(tempMember, x, y))
         {
             CurrentMember = tempMember;
             break;
         }
         tempMember = tempMember.NextMember;
     }
 }
Ejemplo n.º 13
0
        public void Locate(int x)
        {
            if (FirstMember == null)
            {
                CurrentMember = null;
                return;
            }

            var tempMember = FirstMember;
            while (tempMember != null)
            {
                if (tempMember.NextMember != null)
                {
                    if (tempMember.X + tempMember.Width/2 <= x &&
                        tempMember.NextMember.X + tempMember.NextMember.Width/2 > x)
                    {
                        CurrentMember = tempMember;
                        break;
                    }
                }
                else
                {
                    if (tempMember.X + tempMember.Width / 2 <= x)
                    {
                        CurrentMember = tempMember;
                        break;
                    }
                }
                tempMember = tempMember.NextMember;
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 为删除动作连接成员
        /// </summary>
        /// <param name="member">连接的成员</param>
        /// <param name="isDel"></param>
        /// <returns>连接成功TRUE,失败FALSE</returns>
        public bool ConcatMemberForDelete(DRowMember member, bool isDel)
        {
            if (member == null) return false;

            if (FirstMember == null)
            {
                FirstMember = member;
                member.OwnerDocRow = this;
                return true;
            }
            else if (LastMember == null)
            {
                if (IsContinue && isDel)
                {
                    FirstMember = member;
                    member.OwnerDocRow = this;
                    return true;
                }
                else if (IsOutRange(FirstMember, member))
                {
                    IsContinue = true;
                    return false;
                }
                JoinMember(FirstMember, member);
                LastMember = member;
                member.OwnerDocRow = this;
                return true;
            }

            if (isDel && !LastMember.IsBreakTail)
            {
                var tempMember = LastMember.PreMember;
                CutMember(LastMember.PreMember, LastMember);
                LastMember = tempMember;
            }

            if (IsOutRange(LastMember, member))
            {
                IsContinue = true;
                return false;
            }

            JoinMember(LastMember, member);
            if (member.IsBreakTail) IsContinue = false;
            LastMember = member;
            member.OwnerDocRow = this;
            return true;
        }
Ejemplo n.º 15
0
        public virtual void Click(int x, int y)
        {
            var touchMember = OwnerDocument.TouchMember;
            if (touchMember != null &&
                touchMember.MType != MemberType.TextChar &&
                touchMember.TouchMe(x, y))
            {
                ProcessCurrentMember((DRowMember)touchMember, x);
                return;
            }

            CurrentMember = null;

            var member = FirstMember;
            if (member == null) return;

            while (member != null)
            {
                if (IsInMemeberRange(member, x, y))
                {
                    CurrentMember = member;
                    return;
                }
                member = member.NextMember;
            }
        }
Ejemplo n.º 16
0
 public override void MouseClick()
 {
     DRowMember member = _firstMember;
     var page = OwnerDocRow.OwnerDocument.Context;
     while (member != null)
     {
         if (IsInMemberRange(member, page.MouseCurrentPosition.X))
         {
             CurrentMember = member;
             return;
         }
         member = member.NextMember;
     }
     CurrentMember = null;
 }
Ejemplo n.º 17
0
 public void Remove(DRowMember member = null)
 {
     if (member == null) member = CurrentMember;
     if (member == null || member.Equals(_firstMember) || member.Equals(_lastMember)) return;
     if (member.PreMember == null || member.NextMember == null) return;
     member.PreMember.NextMember = member.NextMember;
     member.NextMember.PreMember = member.PreMember;
     CurrentMember = member.PreMember;
     member.PreMember = null;
     member.NextMember = null;
     _firstMember.Height = _firstMember.NextMember.Height;
     _lastMember.Height = _lastMember.PreMember.Height;
     this.Width -= member.Width;
     var hmember = GetHighestMember();
     this.Height = hmember.Height;
     ResetPosition(hmember);
 }
Ejemplo n.º 18
0
        /// <summary>
        /// 将传入的成员链头与该行末成员进行连接,超出的
        /// 尾部链自动向下一行遍历连接
        /// </summary>
        public void WriteTail(DRowMember linkedListHead)
        {
            if (linkedListHead == null) return;

            linkedListHead.RecursiveChangeDocRow(this);
            linkedListHead.PreMember = this.LastMember;
            this.LastMember.NextMember = linkedListHead;

            //定义两个活动指针
            var leftPointer = this.LastMember;
            var rightPointer = linkedListHead;
            DRowMember oLinkedListHeader = null;
            var isOutRange = false;

            while (true)
            {
                //此处断链子
                if (GetRangeResult(rightPointer) == 1)
                {
                    rightPointer.GetTailMember().IsBreakTail = leftPointer.IsBreakTail;
                    leftPointer.IsBreakTail = false;
                    leftPointer.NextMember = null;
                    rightPointer.PreMember = null;
                    oLinkedListHeader = rightPointer;
                    IsContinue = true;
                    isOutRange = true;
                    break;
                }
                else if (GetRangeResult(rightPointer) == 0)
                {
                    IsContinue = true;
                }
                else
                {
                    IsContinue = false;
                }
                rightPointer.AfterChangeRow();
                //断点属性传递
                rightPointer.IsBreakTail = leftPointer.IsBreakTail;
                leftPointer.IsBreakTail = false;
                leftPointer = rightPointer;
                rightPointer = rightPointer.NextMember;
                if (rightPointer == null) break;
            }

            this.LastMember = leftPointer;

            //如果该行未越界则返回
            if (!isOutRange) return;

            if (NextDocRow == null)
            {
                NextDocRow = OwnerDocument.CreateRow();
                NextDocRow.WriteHead(oLinkedListHeader);
            }
            else if (oLinkedListHeader.GetTailMember().IsBreakTail)
            {
                NextDocRow = OwnerDocument.InsertRowBefore(NextDocRow);
                NextDocRow.WriteHead(oLinkedListHeader);
            }
            else
            {
                NextDocRow.WriteHead(oLinkedListHeader);
            }
        }
Ejemplo n.º 19
0
 private void JoinMember(DRowMember member1, DRowMember member2)
 {
     if (member1 != null) member1.NextMember = member2;
     if (member2 != null) member2.PreMember = member1;
 }
Ejemplo n.º 20
0
 private void CutMember(DRowMember fMember, DRowMember sMember)
 {
     if(fMember != null) fMember.NextMember = null;
     if(sMember != null) sMember.PreMember = null;
 }
Ejemplo n.º 21
0
 private int GetRangeResult(DRowMember rightMember)
 {
     var flag = -1;
     if (Paragraph == RowParagraph.Left)
     {
         if (rightMember.X + rightMember.Width > this.X + this.Width)
         {
             flag = 1;
         }
         else if (rightMember.X + rightMember.Width == this.X + this.Width)
         {
             flag = 0;
         }
     }
     else if(Paragraph == RowParagraph.Middle)
     {
         if (rightMember.X + rightMember.Width > this.X + this.Width/2)
         {
             flag = 1;
         }
         else if (rightMember.X + rightMember.Width == this.X + this.Width/2)
         {
             flag = 0;
         }
     }
     else
     {
         if (FirstMember.X < this.X - this.Width)
         {
             flag = 1;
         }
         else if (FirstMember.X == this.X - this.Width)
         {
             flag = 0;
         }
     }
     return flag;
 }
Ejemplo n.º 22
0
 public void AddRowMember(DRowMember member)
 {
     member.OwnerDocRow = this;
     if (FirstMember == null)
     {
         member.X = this.X;
         member.Y = this.Y;
         FirstMember = member;
     }
     else if (LastMember == null)
     {
         FirstMember.NextMember = member;
         member.PreMember = FirstMember;
         LastMember = member;
     }
     else
     {
         LastMember.NextMember = member;
         member.PreMember = LastMember;
         LastMember = member;
     }
 }