Exemple #1
0
        private async void UserControl_MouseUp(object sender, MouseButtonEventArgs e)
        {
            TabBar parent = this.FindParent <TabBar>();

            foreach (Tab tab in parent.TabCollection)
            {
                tab.Effect = null;
            }
            parent.CalcSizes(true);
            _secondsHeld = 0;
            _locked      = true;
            await WaitForSeconds(200);

            ReleaseMouseCapture();
        }
Exemple #2
0
        public Tab(string text, UserControl uc, TabBar tb, int index)
        {
            InitializeComponent();
            AssociatedInstance = uc;
            Title.Text         = text;
            _tabBar            = tb;
            Index = index;
            DispatcherTimer dt = new DispatcherTimer()
            {
                Interval = new TimeSpan(0, 0, 0, 0, 200)
            };

            dt.Tick += (sender, args) =>
            {
                var parent = this.FindParent <TabBar>();
                if (parent != null)
                {
                    Rect rect = new Rect
                    {
                        Size     = new Size(parent.ActualWidth, parent.ActualHeight),
                        Location = new Point(parent.Margin.Left, parent.Margin.Top)
                    };
                    if (!rect.Contains(Mouse.GetPosition(parent)))
                    {
                        parent.CalcSizes(true);
                        foreach (var tab in parent.TabCollection)
                        {
                            tab.Effect = null;
                            tab.Index  = parent.TabCollection.IndexOf(tab);
                            Panel.SetZIndex(tab, 2);
                        }
                    }
                }
            };
            dt.Start();
        }
Exemple #3
0
        private void Title_Loaded(object sender, RoutedEventArgs e)
        {
            if (!created)
            {
                if (AssociatedInstance.Parent == null)
                {
                    this.FindParent <TabLayout>().container.Children.Add(AssociatedInstance);
                }


                RippleColor = this.FindParent <TabLayout>().RippleColor;
                double width = Title.ActualWidth + 64;
                this.Width = width;
                Console.WriteLine("loaded");
                TabBar parent = this.FindParent <TabBar>();

                if (double.IsNaN(this.FindParent <TabLayout>().TabSize))
                {
                    parent.TabCollection.Add(this);
                    if (parent.TabCollection.Count <= 1)
                    {
                        Canvas.SetLeft(this, 0);
                        DoubleAnimation dab = new DoubleAnimation()
                        {
                            From     = 0,
                            To       = 0,
                            Duration = TimeSpan.FromMilliseconds(0)
                        };
                        this.BeginAnimation(Canvas.LeftProperty, dab);
                    }
                    else
                    {
                        Tab    previousTab = parent.TabCollection[parent.TabCollection.IndexOf(this) - 1];
                        double pwidth      = previousTab.Title.ActualWidth + 64;
                        Canvas.SetLeft(this, Canvas.GetLeft(previousTab) + pwidth);
                        DoubleAnimation dab = new DoubleAnimation()
                        {
                            From     = Canvas.GetLeft(previousTab) + pwidth,
                            To       = Canvas.GetLeft(previousTab) + pwidth,
                            Duration = TimeSpan.FromMilliseconds(0)
                        };
                        this.BeginAnimation(Canvas.LeftProperty, dab);
                    }
                }
                else
                {
                    Canvas.SetLeft(this, parent.TabsCount * this.FindParent <TabLayout>().TabSize);
                    DoubleAnimation dab = new DoubleAnimation()
                    {
                        From     = parent.TabsCount * this.FindParent <TabLayout>().TabSize,
                        To       = parent.TabsCount * this.FindParent <TabLayout>().TabSize,
                        Duration = TimeSpan.FromMilliseconds(0)
                    };
                    this.BeginAnimation(Canvas.LeftProperty, dab);
                    parent.TabsCount += 1;
                    parent.TabCollection.Add(this);
                }
                if (parent.TabCollection.Count > 0)
                {
                    parent.SelectTab(parent.TabCollection[0], true);
                }

                parent.CalcSizes(false);
                created = true;
            }
        }
 private void Window_Closed(object sender, EventArgs e)
 {
     dt?.Stop();
     tab    = null;
     tabBar = null;
 }