예제 #1
0
        /// <summary>
        /// 清除当前所有选择的
        /// </summary>
        public void RemoveAllSelected()
        {
            foreach (DragThumb thumb in SelectDragThumbs)
            {
                this.Children.Remove(thumb);
                DragThumbs.Remove(thumb);
            }

            bSaved = false;
            _CurSelectedDragThumb = null;
            SelectDragThumbs.Clear();
            ReOrderAllDragImage();  //重新排序
        }
예제 #2
0
        /// <summary>
        /// 移除控件
        /// </summary>
        /// <param name="dragThumb"></param>
        public void RemoveDragThumb(DragThumb dragThumb)
        {
            if (dragThumb == null)
            {
                return;
            }
            this.Children.Remove(dragThumb);

            bSaved = false;
            SelectDragThumbs.Remove(dragThumb);
            DragThumbs.Remove(dragThumb);
            ReOrderAllDragImage();  //重新排序
        }
예제 #3
0
        /// <summary>
        /// 重新绘制对齐线
        /// </summary>
        /// <param name="curThumb">当前的控件</param>
        /// <param name="bDrawTop">是否绘制Top</param>
        /// <param name="bDrawBottom">是否绘制Bottom</param>
        /// <param name="bDrawHCenter">是否绘制水平中线</param>
        /// <param name="bDrawLeft">是否绘制Left</param>
        /// <param name="bDrawRight">是否绘制Right</param>
        /// <param name="bDrawVCenter">是否绘制垂直中线</param>
        public void ReDrawAlignLines(DragThumb curThumb, bool bDrawTop, bool bDrawBottom, bool bDrawHCenter, bool bDrawLeft, bool bDrawRight, bool bDrawVCenter)
        {
            ClearAlignLies();

            #region 绘制对齐线

            foreach (DragThumb dt in DragThumbs)
            {
                if (dt.Equals(curThumb))
                {
                    continue;
                }
                if (SelectDragThumbs.Contains(dt))
                {
                    continue;                                 //内部的线不绘制
                }
                double theLeft    = dt.Position.X;
                double theRight   = theLeft + dt.Width;
                double theVCenter = theLeft + (dt.Width / 2);  //垂直中心

                double theTop     = dt.Position.Y;
                double theBottom  = theTop + dt.Height;
                double theHCenter = theTop + (dt.Height / 2); //水平中心

                //Top Buttom HCenter Left Rigth VCenter
                double TOLERANCE = 0.00001;

                #region Draw Top

                if (bDrawTop)
                {
                    if (Math.Abs(theTop - curThumb.Position.Y) < TOLERANCE)
                    {
                        Line line = NewAlignLine();

                        if (theLeft + dt.Width < curThumb.Position.X) //基准在左边
                        {
                            line.X1 = theLeft + dt.Width;
                        }
                        else
                        {
                            line.X1 = theLeft;
                        }
                        if (curThumb.Position.X + curThumb.Width < theLeft) //基准在右边
                        {
                            line.X2 = curThumb.Position.X + curThumb.Width;
                        }
                        else
                        {
                            line.X2 = curThumb.Position.X;
                        }

                        line.Y1 = curThumb.Position.Y;
                        line.Y2 = curThumb.Position.Y;

                        AlignLines.Add(line);
                        this.Children.Add(line);
                    }
                }

                #endregion

                #region Draw Bottom

                if (bDrawBottom)
                {
                    if (Math.Abs(curThumb.Position.Y + curThumb.Height - theBottom) < TOLERANCE)
                    {
                        Line line = NewAlignLine();
                        if (theLeft + dt.Width < curThumb.Position.X) //基准在左边
                        {
                            line.X1 = theLeft + dt.Width;
                        }
                        else
                        {
                            line.X1 = theLeft;
                        }
                        if (curThumb.Position.X + curThumb.Width < theLeft) //基准在右边
                        {
                            line.X2 = curThumb.Position.X + curThumb.Width;
                        }
                        else
                        {
                            line.X2 = curThumb.Position.X;
                        }

                        line.Y1 = theBottom;
                        line.Y2 = theBottom;

                        AlignLines.Add(line);
                        this.Children.Add(line);
                    }
                }

                #endregion

                #region Draw theHCenter

                if (bDrawHCenter)
                {
                    if (Math.Abs(curThumb.Position.Y + (curThumb.Height / 2) - theHCenter) < TOLERANCE)
                    {
                        Line line = NewAlignLine();

                        if (theLeft + dt.Width < curThumb.Position.X) //基准在左边
                        {
                            line.X1 = theLeft + dt.Width;
                        }
                        else
                        {
                            line.X1 = theLeft;
                        }
                        if (curThumb.Position.X + curThumb.Width < theLeft) //基准在右边
                        {
                            line.X2 = curThumb.Position.X + curThumb.Width;
                        }
                        else
                        {
                            line.X2 = curThumb.Position.X;
                        }

                        line.Y1 = theHCenter;
                        line.Y2 = theHCenter;

                        AlignLines.Add(line);
                        this.Children.Add(line);
                    }
                }

                #endregion

                #region Draw Left

                if (bDrawLeft)
                {
                    if (Math.Abs(theLeft - curThumb.Position.X) < TOLERANCE)
                    {
                        Line line = NewAlignLine();

                        if (theTop + dt.Height < curThumb.Position.Y) //基准在上边
                        {
                            line.Y1 = theTop + dt.Height;
                        }
                        else
                        {
                            line.Y1 = theTop;
                        }
                        if (curThumb.Position.Y + curThumb.Height < theTop) //基准在下边
                        {
                            line.Y2 = curThumb.Position.Y + curThumb.Height;
                        }
                        else
                        {
                            line.Y2 = curThumb.Position.Y;
                        }

                        line.X1 = curThumb.Position.X;
                        line.X2 = curThumb.Position.X;

                        AlignLines.Add(line);
                        this.Children.Add(line);
                    }
                }

                #endregion

                #region Draw Right

                if (bDrawRight)
                {
                    if (Math.Abs(curThumb.Position.X + curThumb.Width - theRight) < TOLERANCE)
                    {
                        Line line = NewAlignLine();

                        if (theTop + dt.Height < curThumb.Position.Y) //基准在上边
                        {
                            line.Y1 = theTop + dt.Height;
                        }
                        else
                        {
                            line.Y1 = theTop;
                        }
                        if (curThumb.Position.Y + curThumb.Height < theTop) //基准在下边
                        {
                            line.Y2 = curThumb.Position.Y + curThumb.Height;
                        }
                        else
                        {
                            line.Y2 = curThumb.Position.Y;
                        }

                        line.X1 = theRight;
                        line.X2 = theRight;

                        AlignLines.Add(line);
                        this.Children.Add(line);
                    }
                }

                #endregion

                #region Draw theVCenter

                if (bDrawVCenter)
                {
                    if (Math.Abs(curThumb.Position.X + (curThumb.Width / 2) - theVCenter) < TOLERANCE)
                    {
                        Line line = NewAlignLine();

                        if (theTop + dt.Height < curThumb.Position.Y) //基准在上边
                        {
                            line.Y1 = theTop + dt.Height;
                        }
                        else
                        {
                            line.Y1 = theTop;
                        }
                        if (curThumb.Position.Y + curThumb.Height < theTop) //基准在下边
                        {
                            line.Y2 = curThumb.Position.Y + curThumb.Height;
                        }
                        else
                        {
                            line.Y2 = curThumb.Position.Y;
                        }

                        line.X1 = theVCenter;
                        line.X2 = theVCenter;

                        AlignLines.Add(line);
                        this.Children.Add(line);
                    }
                }

                #endregion
            }

            #endregion
        }