/// <summary>
 /// 在移除项时将添加时的部分属性还原,成功返回true。如果成功则移除该项
 /// </summary>
 /// <param name="value"></param>
 protected virtual bool RestoreItemAttribute(int value)
 {
     if (value >= 0 && value < this.m_Owner.List.Count)
     {
         ISetViewItemHelper pSetViewItemHelper = this.m_Owner.List[value] as ISetViewItemHelper;
         if (pSetViewItemHelper != null &&
             pSetViewItemHelper.SetViewParameterStyle(ViewParameterStyle.eNone) &&
             value >= this.m_Owner.TopViewItemIndex && value <= this.m_Owner.BottomViewItemIndex)
         {
             IOwner pOwner = this.m_Owner as IOwner;
             if (pOwner != null)
             {
                 ViewItem viewItem = this.m_Owner.List[value] as ViewItem;
                 if (viewItem != null)
                 {
                     Rectangle rectangle = viewItem.DisplayRectangle;
                     rectangle.Inflate(1, 1);
                     pOwner.Invalidate(rectangle);
                 }
             }
         }
     }
     return(true);
 }
Beispiel #2
0
        protected virtual void DrawItem(System.Windows.Forms.PaintEventArgs e)
        {
            //Rectangle rectangle = this.DisplayRectangle;
            IViewItemOwner pViewItemOwner     = this.pOwner as IViewItemOwner;
            Rectangle      viewItemsRectangle = e.ClipRectangle;// pViewItemOwner == null ? rectangle : pViewItemOwner.ViewItemsRectangle;

            GISShare.Controls.WinForm.WFNew.LayoutEngine.LayoutStackH_Row(e.Graphics, this, viewItemsRectangle, this.DisplayRectangle, ref this._TopViewItemIndex, ref this._BottomViewItemIndex);
            ViewItem      viewItem = null;
            IMessageChain pMessageChain;

            for (int i = this.TopViewItemIndex; i <= this.BottomViewItemIndex; i++)
            {
                viewItem = this.ViewItems[i];
                if (viewItem == null)
                {
                    continue;
                }
                Rectangle clipRectangle = Rectangle.Intersect(viewItemsRectangle, viewItem.DisplayRectangle);
                if (clipRectangle.Width > 0 && clipRectangle.Height > 0)
                {
                    pMessageChain = viewItem as IMessageChain;
                    if (pMessageChain != null)
                    {
                        e.Graphics.SetClip(clipRectangle);
                        MessageInfo messageInfo = new MessageInfo(this, MessageStyle.eMSPaint, new PaintEventArgs(e.Graphics, clipRectangle));
                        pMessageChain.SendMessage(messageInfo);
                    }
                }
            }
            #region 已抛弃(布局移植到LayoutEngine)
            //Rectangle rectangle = this.DisplayRectangle;
            //int iW = 0;
            //int iOffsetX = 0;
            ////
            //IViewItemOwner pViewItemOwner = this.pOwner as IViewItemOwner;
            //Rectangle viewItemsRectangle = pViewItemOwner == null ? rectangle : pViewItemOwner.ViewItemsRectangle;
            ////
            //ViewItem viewItem = null;
            //int iCount = this.ViewItems.Count;
            //int iLeftX = 0;
            //int iRightX = 0;
            //int iLeftIndex = 0;
            //int iRightIndex = iCount;
            //for (int i = 0; i < iCount; i++)
            //{
            //    viewItem = this.ViewItems[i];
            //    //
            //    iW = viewItem.MeasureSize(e.Graphics).Width;
            //    iLeftX = rectangle.Left + iOffsetX;
            //    iRightX = iLeftX + iW;
            //    if (iRightX <= viewItemsRectangle.Left)
            //    {
            //        iLeftIndex++;
            //    }
            //    else if (iLeftX >= viewItemsRectangle.Right)
            //    {
            //        iRightIndex--;
            //    }
            //    else
            //    {
            //        ISetViewItemHelper pSetViewItemHelper = viewItem as ISetViewItemHelper;
            //        if (pSetViewItemHelper != null)
            //        {
            //            pSetViewItemHelper.SetViewItemDisplayRectangle(new Rectangle(iLeftX, rectangle.Top, iW, rectangle.Height));
            //            //
            //            Rectangle clipRectangle = Rectangle.Intersect(viewItemsRectangle, viewItem.DisplayRectangle);
            //            if (clipRectangle.Width > 0 && clipRectangle.Height > 0)
            //            {
            //                IMessageChain pMessageChain = viewItem as IMessageChain;
            //                if (pMessageChain != null)
            //                {
            //                    e.Graphics.SetClip(clipRectangle);
            //                    MessageInfo messageInfo = new MessageInfo(this, MessageStyle.eMSPaint, new PaintEventArgs(e.Graphics, clipRectangle));
            //                    pMessageChain.SendMessage(messageInfo);
            //                }
            //            }
            //        }
            //    }
            //    //
            //    iOffsetX += iW;
            //}
            ////
            //this.m_TopViewItemIndex = iLeftIndex;
            //this.m_BottomViewItemIndex = iRightIndex - 1;
            #endregion
        }
Beispiel #3
0
 private void MSMouseUp(MessageInfo messageInfo)
 {
     if (this.m_OperationStyle == 0)
     {
         MouseEventArgs mouseEventArgs = messageInfo.MessageParameter as MouseEventArgs;
         if (mouseEventArgs != null)
         {
             ISizeViewItem pSizeViewItem = this.ViewItems[this.m_MouseDownSelectedIndex];
             if (pSizeViewItem != null)
             {
                 //pSizeViewItem.Width += mouseEventArgs.Location.X - this.m_MouseDownPoint.X;
                 //this.Invalidate(this.DisplayRectangle);
                 int iW     = mouseEventArgs.Location.X - this.m_MouseDownPoint.X;
                 int iW_pre = pSizeViewItem.Width;
                 pSizeViewItem.Width += iW;
                 iW = pSizeViewItem.Width - iW_pre;
                 if (iW != 0)
                 {
                     if (this.IsFilled)
                     {
                         pSizeViewItem = this.ViewItems[this.m_MouseDownSelectedIndex + 1];
                         if (pSizeViewItem != null)
                         {
                             pSizeViewItem.Width -= iW;
                         }
                     }
                     this.Invalidate(this.DisplayRectangle);
                 }
             }
         }
         //
         Control ctr = this.TryGetDependControl_DG(this.pOwner);
         if (ctr != null)
         {
             ctr.Cursor = this.m_CursorDefault;
         }
         //
         messageInfo.CancelPreEvent = true;//取消事件 1
     }
     else if (this.m_OperationStyle == 1)
     {
         MouseEventArgs mouseEventArgs = messageInfo.MessageParameter as MouseEventArgs;
         if (mouseEventArgs != null)
         {
             this.Height += mouseEventArgs.Location.Y - this.m_MouseDownPoint.Y;
             if (this.DisplayRectangle.Height >= this.Height)
             {
                 this.Invalidate(this.DisplayRectangle);
             }
             else
             {
                 this.Invalidate(new Rectangle(this.DisplayRectangle.X, this.DisplayRectangle.Y, this.DisplayRectangle.Width, this.Height));
             }
         }
         //
         Control ctr = this.TryGetDependControl_DG(this.pOwner);
         if (ctr != null)
         {
             ctr.Cursor = this.m_CursorDefault;
         }
         //
         messageInfo.CancelPreEvent = true;//取消事件 2
     }
     else if (this.m_OperationStyle == 2)
     {
         MouseEventArgs mouseEventArgs = messageInfo.MessageParameter as MouseEventArgs;
         if (mouseEventArgs != null)
         {
             ViewItem viewItem = null;
             for (int i = this.TopViewItemIndex; i <= this.BottomViewItemIndex; i++)
             {
                 viewItem = this.ViewItems[i];
                 if (viewItem.DisplayRectangle.Contains(mouseEventArgs.Location))
                 {
                     this.ViewItems.ExchangeItem(this.m_MouseDownSelectedIndex, i);
                 }
             }
         }
         //
         Control ctr = this.TryGetDependControl_DG(this.pOwner);
         if (ctr != null)
         {
             ctr.Cursor = this.m_CursorDefault;
         }
     }
     else
     {
         IMessageChain pMessageChain;
         for (int i = this.TopViewItemIndex; i <= this.BottomViewItemIndex; i++)
         {
             pMessageChain = this.ViewItems[i] as IMessageChain;
             if (pMessageChain != null)
             {
                 pMessageChain.SendMessage(messageInfo);//new MessageInfo(this, messageInfo.eMessageStyle, messageInfo.MessageParameter)
             }
         }
     }
     //
     this.m_OperationStyle         = -1;
     this.m_MouseDownPoint         = Point.Empty;
     this.m_MouseDownSelectedIndex = -1;
     this.m_CursorDefault          = Cursors.Default;
 }
Beispiel #4
0
        private void MSMouseDown(MessageInfo messageInfo)
        {
            MouseEventArgs mouseEventArgs = messageInfo.MessageParameter as MouseEventArgs;

            if (mouseEventArgs != null)
            {
                if (this.CanResizeItemHeight && this.DisplayRectangle.Bottom - CONST_RESIZERECTANGLESIZE <= mouseEventArgs.Location.Y)
                {
                    this.m_OperationStyle         = 1;
                    this.m_MouseDownPoint         = mouseEventArgs.Location;
                    this.m_MouseDownSelectedIndex = -1;
                    Control ctr = this.TryGetDependControl_DG(this.pOwner);
                    if (ctr != null)
                    {
                        this.m_CursorDefault = ctr.Cursor;
                        ctr.Cursor           = Cursors.SizeNS;
                    }
                    messageInfo.CancelPreEvent = true;//取消事件 1
                    //Console.WriteLine(this.ToString() + " - " + this.m_OperationStyle);
                }
                else
                {
                    ViewItem viewItem = null;
                    for (int i = this.TopViewItemIndex; i <= this.BottomViewItemIndex; i++)
                    {
                        viewItem = this.ViewItems[i];
                        if (viewItem == null)
                        {
                            continue;
                        }
                        //
                        if (viewItem.DisplayRectangle.Contains(mouseEventArgs.Location))
                        {
                            if (this.CanResizeItemWidth && viewItem.DisplayRectangle.Right - CONST_RESIZERECTANGLESIZE <= mouseEventArgs.Location.X)
                            {
                                this.m_OperationStyle         = 0;
                                this.m_MouseDownPoint         = mouseEventArgs.Location;
                                this.m_MouseDownSelectedIndex = i;
                                Control ctr = this.TryGetDependControl_DG(this.pOwner);
                                if (ctr != null)
                                {
                                    this.m_CursorDefault = ctr.Cursor;
                                    ctr.Cursor           = Cursors.SizeWE;
                                }
                                messageInfo.CancelPreEvent = true;//取消事件 2
                                break;
                            }
                            else
                            {
                                //if (this.CanExchangeItem)
                                //{
                                //    this.m_OperationStyle = 2;
                                //    this.m_MouseDownSelectedIndex = i;
                                //    Control ctr = this.TryGetDependControl_DG(this.pOwner);
                                //    if (ctr != null)
                                //    {
                                //        this.m_CursorDefault = ctr.Cursor;
                                //        ctr.Cursor = Cursors.Hand;
                                //    }
                                //}
                                //else
                                //{
                                //    IMessageChain pMessageChain = viewItem as IMessageChain;
                                //    if (pMessageChain != null)
                                //    {
                                //        pMessageChain.SendMessage(messageInfo);//new MessageInfo(this, messageInfo.eMessageStyle, messageInfo.MessageParameter)
                                //    }
                                //}
                                IMessageChain pMessageChain = viewItem as IMessageChain;
                                if (pMessageChain != null)
                                {
                                    pMessageChain.SendMessage(messageInfo);//new MessageInfo(this, messageInfo.eMessageStyle, messageInfo.MessageParameter)
                                }
                                //
                                this.SelectedIndex = i;
                            }
                            //
                            break;
                        }
                    }
                }
            }
        }