Exemple #1
0
        public override void onMouseMove(object sender, MouseMoveEventArgs e)
        {
            base.onMouseMove(sender, e);

            if (!(HasFocus && holdCursor))
            {
                return;
            }
            TabView tv = Parent as TabView;
            TabItem previous = null, next = null;
            int     tmp = TabOffset + e.XDelta;

            if (tmp < tv.Spacing)
            {
                TabOffset = tv.Spacing;
            }
            else if (tmp > Parent.getSlot().Width - TabTitle.Slot.Width - tv.Spacing)
            {
                TabOffset = Parent.getSlot().Width - TabTitle.Slot.Width - tv.Spacing;
            }
            else
            {
                int idx = tv.Children.IndexOf(this);
                if (idx > 0 && e.XDelta < 0)
                {
                    previous = tv.Children [idx - 1] as TabItem;

                    if (tmp < previous.TabOffset + previous.TabTitle.Slot.Width / 2)
                    {
                        tv.Children.RemoveAt(idx);
                        tv.Children.Insert(idx - 1, this);
                        tv.SelectedTab = idx - 1;
                        tv.UpdateLayout(LayoutingType.ArrangeChildren);
                    }
                }
                else if (idx < tv.Children.Count - 1 && e.XDelta > 0)
                {
                    next = tv.Children [idx + 1] as TabItem;
                    if (tmp > next.TabOffset - next.TabTitle.Slot.Width / 2)
                    {
                        tv.Children.RemoveAt(idx);
                        tv.Children.Insert(idx + 1, this);
                        tv.SelectedTab = idx + 1;
                        tv.UpdateLayout(LayoutingType.ArrangeChildren);
                    }
                }
                TabOffset = tmp;
            }
        }
Exemple #2
0
        public override void onMouseMove(object sender, MouseMoveEventArgs e)
        {
            base.onMouseMove(sender, e);

            if (Parent == null)
            {
                return;
            }

            if (!IsDragged)
            {
                return;
            }

            TabView tv = Parent as TabView;

            if (Math.Abs(e.Position.Y - dragStartPoint.Y) > dragThreshold ||
                Math.Abs(e.Position.X - dragStartPoint.X) > dragThreshold)
            {
                makeFloating(tv);
                return;
            }

            Rectangle cb = ClientRectangle;

            int tmp = TabOffset + e.XDelta;

            if (tmp < tview.LeftSlope)
            {
                TabOffset = tview.LeftSlope;
            }
            else if (tmp > cb.Width - tv.RightSlope - tv.TabWidth)
            {
                TabOffset = cb.Width - tv.RightSlope - tv.TabWidth;
            }
            else
            {
                dragStartPoint.X = e.Position.X;
                TabItem[] tabItms = tv.Children.Cast <TabItem>().OrderBy(t => t.ViewIndex).ToArray();
                if (ViewIndex > 0 && e.XDelta < 0)
                {
                    TabItem previous = tabItms [ViewIndex - 1];
                    if (tmp < previous.TabOffset + tview.TabWidth / 2)
                    {
                        previous.ViewIndex = ViewIndex;
                        ViewIndex--;
                        tv.UpdateLayout(LayoutingType.ArrangeChildren);
                    }
                }
                else if (ViewIndex < tabItms.Length - 1 && e.XDelta > 0)
                {
                    TabItem next = tabItms [ViewIndex + 1];
                    if (tmp > next.TabOffset - tview.TabWidth / 2)
                    {
                        next.ViewIndex = ViewIndex;
                        ViewIndex++;
                        tv.UpdateLayout(LayoutingType.ArrangeChildren);
                    }
                }
                TabOffset = tmp;
            }
        }
Exemple #3
0
 public override void onMouseUp(object sender, MouseButtonEventArgs e)
 {
     base.onMouseUp(sender, e);
     tview.UpdateLayout(LayoutingType.ArrangeChildren);
 }