Example #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();
        }
Example #2
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;
            }
        }