Beispiel #1
0
        private async void onMouseDown(bool wait)
        {
            _mStart       = Mouse.GetPosition(this.FindParent <TabBar>());
            _mStartOffset = new Vector(Canvas.GetLeft(this), Canvas.GetTop(this));
            if (_tabBar.ActualSelect != this)
            {
                _tabBar.SelectTab(this, true);
            }
            var targetWidth = Math.Max(ActualWidth, ActualHeight) * 2;

            Ripple.Width = 0;
            var mousePosition = Mouse.GetPosition(this);
            var startMargin   = new Thickness(mousePosition.X, mousePosition.Y, 0, 0);

            Ripple.Margin = startMargin;

            Animations.AnimateFade(0, 0.2, Ripple, 0, 0, null);

            Animations.AnimateRipple(0, targetWidth, Ripple, 0.3, startMargin, new Thickness(mousePosition.X - targetWidth / 2, mousePosition.Y - targetWidth / 2, 0, 0), true, 0.2);
            if (wait)
            {
                while (_secondsHeld != 1)
                {
                    await WaitForSeconds(100);

                    _secondsHeld += 1;
                    _locked       = false;
                    _mStart       = Mouse.GetPosition(this.FindParent <TabBar>());
                    _mStartOffset = new Vector(Canvas.GetLeft(this), Canvas.GetTop(this));
                }
            }
            else
            {
                _locked = false;
            }
        }
Beispiel #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;
            }
        }