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