本文整理汇总了C#中System.Windows.Controls.StackPanel.BeginAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# StackPanel.BeginAnimation方法的具体用法?C# StackPanel.BeginAnimation怎么用?C# StackPanel.BeginAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.StackPanel
的用法示例。
在下文中一共展示了StackPanel.BeginAnimation方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowToast
public static void ShowToast(Grid baseGrid, string message)
{
gridCount ++;
StackPanel grid = new StackPanel();
grid.Width = 200;
grid.Height = 40;
grid.Background = new System.Windows.Media.SolidColorBrush(Colors.Gray);
grid.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
grid.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
grid.Margin = new Thickness(0, 0, 0, 30);
TextBlock text = new TextBlock();
text.Text = message;
text.VerticalAlignment = VerticalAlignment.Center;
text.HorizontalAlignment = HorizontalAlignment.Center;
text.FontSize = 22;
grid.Children.Add(text);
baseGrid.Children.Add(grid);
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 3);
timer.Tick += (sender, args) =>
{
var anim = new DoubleAnimation(0, (Duration) TimeSpan.FromSeconds(1));
grid.BeginAnimation(UIElement.OpacityProperty, anim);
anim.Completed += (s, _) => baseGrid.Children.Remove(grid);
timer.Stop();
};
timer.Start();
}
示例2: Draw
public void Draw()
{
if (SelectedItem == null) return;
if (gArcs == null) return;
gArcs.Children.Clear();
var a = 360.0/Segments;
if (SelectedItem.Element != null)
{
ccCenter.Content = SelectedItem.Element;
pBack.Visibility = Visibility.Collapsed;
//ccCenter.Visibility = Visibility.Visible;
}
else if (SelectedItem.Icon != null && SelectedItem == RootItem)
{
iCenterIcon.Source = new BitmapImage(new Uri(SelectedItem.Icon, UriKind.RelativeOrAbsolute));
iCenterIcon.Visibility = Visibility.Visible;
pBack.Visibility = Visibility.Collapsed;
}
else
{
iCenterIcon.Visibility = Visibility.Collapsed;
pBack.Visibility = Visibility.Visible;
//ccCenter.Visibility = Visibility.Collapsed;
}
if (!Open)
{
BackgroundBrush = null;
return;
}
BackgroundBrush = Brushes.White;
for (var i = 0; i < Segments; i++)
{
var mi = SelectedItem.Items.FirstOrDefault(k => k.Position == i);
var s = new Arc
{
Width = Size,
Height = Size,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Stretch = Stretch.None,
StartAngle = i*a,
StrokeThickness = 0,
Stroke = null,
EndAngle = (i + 1)*a - 1
};
if (mi != null && mi.Items != null && mi.Items.Count > 0)
{
s.Fill = AccentBrush;
s.MouseDown += (e, si) => SelectItem(mi);
s.TouchDown += (e, si) => SelectItem(mi);
}
else
{
s.Fill = SecondAccentBrush;
}
s.ArcThickness = 0;
s.ArcThicknessUnit = UnitType.Pixel;
gArcs.Children.Add(s);
s.BeginAnimation(Arc.ArcThicknessProperty,
new DoubleAnimation(ArrowArcSize, new Duration(new TimeSpan(0, 0, 0, 0, 200))));
const double dDegToRad = Math.PI/180.0;
if (mi == null) continue;
var f = new Arc
{
Width = Size - (ArrowArcSize*2) - 3,
Height = Size - (ArrowArcSize*2) - 3,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Stretch = Stretch.None,
StartAngle = i*a,
StrokeThickness = 0,
Stroke = null,
EndAngle = (i + 1)*a - 1,
Tag = i
};
if (mi.Fill == null) mi.Fill = Brushes.Transparent;
f.Fill = mi.Fill;
f.ArcThickness = ItemSize;
f.ArcThicknessUnit = UnitType.Pixel;
f.MouseDown += (sender, e) => SelectItem(mi);
//var eventAsObservable = Observable.FromEventPattern<TouchEventArgs>(f, "TouchDown");
//eventAsObservable.Throttle(TimeSpan.FromMilliseconds(200)).Subscribe(k => Execute.OnUIThread(() => SelectItem(mi)));
// Only subscribe to TouchDown on Windows 7: On Windows 8, it causes
var win8Version = new Version(6, 2, 9200, 0);
if (Environment.OSVersion.Platform == PlatformID.Win32NT &&
Environment.OSVersion.Version < win8Version)
{
f.TouchDown += (e, si) => SelectItem(mi);
}
//f.TouchDown += (sender, e) => SelectItem(mi);
gArcs.Children.Add(f);
//.........这里部分代码省略.........
示例3: option1_click
private void option1_click(object sender, RoutedEventArgs e)
{
StackPanel sp = sender as StackPanel;
StackPanel usedToBe = currentlyExpanded;
if (currentlyExpanded != null)
{
double initialHeight = usedToBe.DesiredSize.Height;
StackPanel sub = new StackPanel();
shrink();
this.UpdateLayout();
double finalHeight = views[usedToBe].stub.DesiredSize.Height;
sub.Height = initialHeight - finalHeight;
usedToBe.Children.Add(sub);
//views[sp].stub.Height = initialHeight;
this.UpdateLayout();
Duration duration = new Duration(TimeSpan.FromSeconds(0.50));
DoubleAnimationPlus doubleanimation = new DoubleAnimationPlus();
doubleanimation.Duration = duration;
doubleanimation.To = 0;
doubleanimation.TargetElement = usedToBe;
doubleanimation.Completed += new EventHandler(ShrinkAnimationCompleted);
//views[sp].stub.BeginAnimation(HeightProperty, doubleanimation);
sub.BeginAnimation(HeightProperty, doubleanimation);
}
if (usedToBe != sp)
{
double initialHeight = sp.DesiredSize.Height;
expand(sp);
this.UpdateLayout();
double finalHeight = views[sp].DesiredSize.Height;
//shrink();
views[sp].Height = initialHeight;
this.UpdateLayout();
//StackPanel sub = new StackPanel();
//sp.Children.Add(sub);
//sub.Height = 0;
Duration duration = new Duration(TimeSpan.FromSeconds(0.50));
DoubleAnimationPlus doubleanimation = new DoubleAnimationPlus();
doubleanimation.Duration = duration;
//doubleanimation.To = finalHeight - initialHeight;
doubleanimation.To = finalHeight;
doubleanimation.From = initialHeight;
doubleanimation.TargetElement = sp;
doubleanimation.Completed += new EventHandler(AnimationCompleted);
//sub.BeginAnimation(HeightProperty, doubleanimation);
views[sp].BeginAnimation(HeightProperty, doubleanimation);
}
}
示例4: CloseStackPanel
private void CloseStackPanel(StackPanel stackPanel)
{
if (stackPanel.Height > 0)
{
DoubleAnimation animation = new DoubleAnimation() { From = stackPanel.Height, To = 0, Duration = TimeSpan.Parse("0:0:0.35") };
stackPanel.BeginAnimation(StackPanel.HeightProperty, animation);
}
}
示例5: FoldAfterAnotherSingleMode
private void FoldAfterAnotherSingleMode(StackPanel openedStackPanel, StackPanel closedStackPanel)
{
double openedStackPanelHeight = GetStackPanelHeight(openedStackPanel);
double closedStackPanelHeight = GetStackPanelHeight(closedStackPanel);
DoubleAnimation closingAnimation = new DoubleAnimation() { From = openedStackPanelHeight, To = 0, Duration = TimeSpan.Parse("0:0:0.35") };
DoubleAnimation openingAnimation = new DoubleAnimation() { From = 0, To = closedStackPanelHeight, Duration = TimeSpan.Parse("0:0:0.35") };
closingAnimation.Completed += (s, e) => closedStackPanel.BeginAnimation(StackPanel.HeightProperty, openingAnimation);
openedStackPanel.BeginAnimation(StackPanel.HeightProperty, closingAnimation);
}
示例6: FoldStackPanelUpwardButton
private void FoldStackPanelUpwardButton(StackPanel stackPanel)
{
double stackPanelHeight = GetStackPanelHeightButton(stackPanel);
if (stackPanel.Height > 0)
{
DoubleAnimation animation = new DoubleAnimation() { From = stackPanelHeight, To = 0, Duration = TimeSpan.Parse("0:0:0.35") };
stackPanel.BeginAnimation(StackPanel.HeightProperty, animation);
}
else
{
DoubleAnimation animation = new DoubleAnimation() { From = 0, To = stackPanelHeight, Duration = TimeSpan.Parse("0:0:0.35") };
stackPanel.BeginAnimation(StackPanel.HeightProperty, animation);
}
}
示例7: FoldStackPanelSideward
private void FoldStackPanelSideward(StackPanel stackPanel)
{
double stackPanelWidth = GetStackPanelWidth(stackPanel);
if (stackPanel.Width > 0)
{
DoubleAnimation animation = new DoubleAnimation() { From = stackPanelWidth, To = 0, Duration = TimeSpan.Parse("0:0:0.35") };
stackPanel.BeginAnimation(StackPanel.WidthProperty, animation);
}
else
{
DoubleAnimation animation = new DoubleAnimation() { From = 0, To = stackPanelWidth, Duration = TimeSpan.Parse("0:0:0.35") };
stackPanel.BeginAnimation(StackPanel.WidthProperty, animation);
}
}