Inheritance: System.Windows.Controls.UserControl
コード例 #1
0
        public void AddTab(OpenTabCommandParameters commandParams, MainWindow mw)
        {
            UserControl userControl;

            if(commandParams.Control == null)
            {
                 userControl = new TabView(mw, commandParams.Url);
            }
            else
            {
                userControl = commandParams.Control;
            }

            Dispatcher.BeginInvoke((Action) (() =>
            {
                tab = new Tab(commandParams.Title, mw, userControl, commandParams.Brush);

                tab.Width = tabWidth;
                tab.Height = tabHeight;
                canvas.Children.Add(tab);
                Canvas.SetLeft(tab, TabCount * tabWidth);
                Canvas.SetTop(tab, 0);
                Canvas.SetTop(AddButton, 0);
                if (AddButtonCount == 1)
                {
                    AddButton.BeginAnimation(Canvas.LeftProperty,
                        new DoubleAnimation(0, AddButtonCount * tabWidth, TimeSpan.FromMilliseconds(moveButtonDuration)));
                }
                else
                {
                    AddButton.BeginAnimation(Canvas.LeftProperty,
                        new DoubleAnimation(Canvas.GetLeft(AddButton), AddButtonCount * tabWidth, TimeSpan.FromMilliseconds(moveButtonDuration)));
                }
                TabCount += 1;
                AddButtonCount += 1;
                TabCollection.Add(tab);

                var fade = new DoubleAnimation()
                {
                    From = 0,
                    To = 1,
                    Duration = TimeSpan.FromSeconds(0.25),
                };
                Storyboard.SetTarget(fade, tab);
                Storyboard.SetTargetProperty(fade, new PropertyPath(Button.OpacityProperty));

                var sb = new Storyboard();
                sb.Children.Add(fade);
                sb.Begin();

                CalcSizes();
            }));
        }
コード例 #2
0
        public async void RemoveTab(Tab tabToRemove)
        {
            TabCount       = 0;
            AddButtonCount = 1;

            TabCollection.Remove(tabToRemove);
            canvas.Children.Remove(tabToRemove);

            foreach (var ctrl in TabCollection)
            {
                ctrl.Width = tabWidth;
                ctrl.BeginAnimation(Canvas.LeftProperty,
                                    new DoubleAnimation(Canvas.GetLeft(ctrl), TabCount * tabWidth,
                                                        TimeSpan.FromMilliseconds(moveButtonDuration)));
                AddButton.BeginAnimation(Canvas.LeftProperty,
                                         new DoubleAnimation(Canvas.GetLeft(AddButton), AddButtonCount * tabWidth,
                                                             TimeSpan.FromMilliseconds(moveButtonDuration)));
                TabCount       += 1;
                AddButtonCount += 1;
                await CalcSizes();

                tabToRemove.mainWindow.container.Children.Remove(tabToRemove.form);
                if (tabToRemove.form.GetType() == typeof(TabView))
                {
                    var tv = tabToRemove.form as TabView;
                    tv.Shutdown();
                }
                if (!tabToRemove.bgTab)
                {
                    SelectTab(TabCollection[TabCollection.Count - 1]);
                }
            }
            if (TabCount == 0)
            {
                Application.Current.Shutdown();
            }
        }
コード例 #3
0
        public async void RemoveTab(Tab tabToRemove)
        {
            TabCount = 0;
            AddButtonCount = 1;

            TabCollection.Remove(tabToRemove);
            canvas.Children.Remove(tabToRemove);

            foreach (var ctrl in TabCollection)
            {
                ctrl.Width = tabWidth;
                ctrl.BeginAnimation(Canvas.LeftProperty,
                    new DoubleAnimation(Canvas.GetLeft(ctrl), TabCount*tabWidth,
                        TimeSpan.FromMilliseconds(moveButtonDuration)));
                AddButton.BeginAnimation(Canvas.LeftProperty,
                    new DoubleAnimation(Canvas.GetLeft(AddButton), AddButtonCount*tabWidth,
                        TimeSpan.FromMilliseconds(moveButtonDuration)));
                TabCount += 1;
                AddButtonCount += 1;
                await CalcSizes();
                tabToRemove.mainWindow.container.Children.Remove(tabToRemove.form);
                if (tabToRemove.form.GetType() == typeof (TabView))
                {
                    var tv = tabToRemove.form as TabView;
                    tv.Shutdown();
                }
                if (!tabToRemove.bgTab)
                {
                    SelectTab(TabCollection[TabCollection.Count - 1]);
                }
            }
            if (TabCount == 0)
            {
                Application.Current.Shutdown();
            }
        }
コード例 #4
0
        public async void SelectTab(Tab tabSelect)
        {
            foreach (var tab in TabCollection)
            {
                if (tab == tabSelect)
                {
                    tab.bgTab = false;
                    tab.form.Visibility = Visibility.Visible;
                    
                    }
                    else
                    {
                        tab.bgTab = true;
                        tab.form.Visibility = Visibility.Hidden;

                    }
                }
                await CalcSizes();
            
        }
コード例 #5
0
        public async void AddTab(OpenTabCommandParameters commandParams, MainWindow mw)
        {
            if (GetSizes() < 50 && TabCollection.Count > 0)
            {
            }
            else
            {
                UserControl userControl;

                if (commandParams.Control == null)
                {
                    userControl = new TabView(mw, commandParams.Url);
                }
                else
                {
                    userControl = commandParams.Control;
                }

                await Dispatcher.BeginInvoke((Action)(() =>
                {
                    mainWindow = mw;
                    tab = new Tab(commandParams.Title, mw, userControl, commandParams.Brush);

                    tab.Width = tabWidth;
                    tab.Height = tabHeight;
                    canvas.Children.Add(tab);
                    Canvas.SetLeft(tab, TabCount *tabWidth);
                    Canvas.SetTop(tab, 0);
                    Canvas.SetTop(AddButton, 0);
                    if (AddButtonCount == 1)
                    {
                        AddButton.BeginAnimation(Canvas.LeftProperty,
                                                 new DoubleAnimation(0, AddButtonCount *tabWidth, TimeSpan.FromMilliseconds(moveButtonDuration)));
                    }
                    else
                    {
                        AddButton.BeginAnimation(Canvas.LeftProperty,
                                                 new DoubleAnimation(Canvas.GetLeft(AddButton), AddButtonCount *tabWidth,
                                                                     TimeSpan.FromMilliseconds(moveButtonDuration)));
                    }
                    TabCount += 1;
                    AddButtonCount += 1;
                    TabCollection.Add(tab);

                    var fade = new DoubleAnimation
                    {
                        From = 26,
                        To = 0,
                        Duration = TimeSpan.FromSeconds(0.25)
                    };
                    Storyboard.SetTarget(fade, tab);
                    Storyboard.SetTargetProperty(fade, new PropertyPath(Canvas.TopProperty));

                    var sb = new Storyboard();
                    sb.Children.Add(fade);
                    sb.Completed += async(o, e1) =>
                    {
                        await CalcSizes();
                    };
                    sb.Begin();
                }));
            }
        }