/// <summary> /// 展开推文显示区域 /// </summary> /// /// <param name="mainWindow">主窗体this指针</param> /// <param name="expandHeight">需要展开的高度</param> public static void ExpandTweetPanel(MainWindow w,int expandHeight) { DoubleAnimation a = new DoubleAnimation(); a.From = w.TweetPanel.Height; a.To = w.TweetPanel.Height + expandHeight; a.Duration = new Duration(TimeSpan.Parse("0:0:1")); a.AccelerationRatio = 0.5; a.DecelerationRatio = 0.5; Storyboard aHeightsb = new Storyboard(); Storyboard.SetTargetProperty(a, new PropertyPath(StackPanel.HeightProperty)); aHeightsb.Children.Add(a); aHeightsb.Begin(w.TweetPanel); DoubleAnimation b = new DoubleAnimation(); b.From = w.Top; b.To = b.From - expandHeight; b.Duration = new Duration(TimeSpan.Parse("0:0:1")); b.AccelerationRatio = 0.5; b.DecelerationRatio = 0.5; w.BeginAnimation(Window.TopProperty, b); DoubleAnimation c = new DoubleAnimation(); c.From = w.Height; c.To = w.Height + expandHeight; c.Duration = new Duration(TimeSpan.Parse("0:0:1")); c.AccelerationRatio = 0.5; c.DecelerationRatio = 0.5; w.BeginAnimation(MainWindow.HeightProperty, c); }
public static void CreateTweetGrid(MainWindow w, int TweetsAmount) { for (int i = 0; i < TweetsAmount;i++ ) { Grid g = new Grid(); g.Name = "Tweet" + i; g.Height = 50; g.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(50) }); g.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1,GridUnitType.Star) }); g.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); g.RowDefinitions.Add(new RowDefinition { Height = new GridLength(4, GridUnitType.Star) }); Image gImage=new Image{Margin=new Thickness(1)}; g.Children.Add(gImage); Grid.SetColumn(gImage, 0); Grid.SetRow(gImage, 0); Grid.SetRowSpan(gImage, 2); TextBlock tID = new TextBlock { Name = "ID", TextAlignment = TextAlignment.Right, FontSize = 8 }; g.Children.Add(tID); Grid.SetColumn(tID, 1); Grid.SetRow(tID, 0); TextBlock tStatus = new TextBlock { Name = "Status", FontSize = 10 }; g.Children.Add(tStatus); Grid.SetColumn(tStatus, 1); Grid.SetRow(tStatus, 1); w.TweetPanel.Children.Add(g); } }
public static void ExpandLoginPanel(MainWindow w,int expandHeight) { DoubleAnimation a = new DoubleAnimation(); a.From = w.LoginPanel.Height; a.To = w.LoginPanel.Height + expandHeight; a.Duration = new Duration(TimeSpan.Parse("0:0:1")); a.AccelerationRatio = 0.5; a.DecelerationRatio = 0.5; Storyboard aHeightsb = new Storyboard(); Storyboard.SetTargetProperty(a, new PropertyPath(StackPanel.HeightProperty)); aHeightsb.Children.Add(a); aHeightsb.Begin(w.LoginPanel); }