本文整理汇总了C#中Image.BeginAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# Image.BeginAnimation方法的具体用法?C# Image.BeginAnimation怎么用?C# Image.BeginAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image.BeginAnimation方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderClouds
internal static async void RenderClouds(Canvas canvas, int density = 10, int boundry = 10)
{
List<string> getClouds = Resource.GetFiles("images/scene/clouds", "cloud_*.png");
var random = new Random();
for (int x = 0; x < density; x++)
{
string cloudImage = getClouds[random.Next(0, getClouds.Count)];
int[] cloudSize = await Core.ImageSize(cloudImage);
double cloudOpacity = random.Next(10, 100);
int cloudWidth = random.Next(Core.GetPercentage(cloudSize[0], 100), cloudSize[0]);
int cloudHeight = (cloudSize[1] > cloudWidth) ? cloudSize[1] - cloudWidth : cloudSize[1] + cloudWidth;
int cloudX = random.Next(0 - (cloudWidth/2), (int) canvas.ActualWidth);
int cloudY = random.Next(0 - (cloudHeight/2), Core.GetPercentage((int) canvas.ActualHeight, boundry));
var cloud = new Image
{
Name = (x < 10) ? "Cloud_0" + x : "Cloud_" + x,
Source = await Core.StreamImage(cloudImage),
Height = cloudHeight,
Width = cloudWidth,
Opacity = cloudOpacity/100
};
canvas.Children.Add(cloud);
Canvas.SetLeft(cloud, cloudX);
Canvas.SetTop(cloud, 0 - cloud.Height);
Panel.SetZIndex(cloud, 0);
var slideDownClouds = new DoubleAnimation
{
From = Canvas.GetTop(cloud),
To = cloudY,
Duration = new Duration(TimeSpan.FromSeconds(1))
};
cloud.BeginAnimation(Canvas.TopProperty, slideDownClouds);
}
}
示例2: RenderStars
internal static async void RenderStars(Canvas canvas, int density = 200)
{
List<string> getStars = Resource.GetFiles("images/scene/stars", "star_*.png");
var random = new Random();
for (int x = 0; x < density; x++)
{
string starImage = getStars[random.Next(0, getStars.Count)];
int starSize = random.Next(1, 10);
int starOpacity = random.Next(10, 50);
int starX = random.Next(0, (int) canvas.ActualWidth);
int starY = random.Next(0, (int) canvas.ActualHeight);
var star = new Image
{
Name = (x < 10) ? "Star_0" + x : "Star_" + x,
Source = await Core.StreamImage(starImage),
Height = starSize,
Width = starSize,
Opacity = 0
};
canvas.Children.Add(star);
Canvas.SetLeft(star, starX);
Canvas.SetTop(star, starY);
Panel.SetZIndex(star, 0);
var fadeInStars = new DoubleAnimation
{
From = 0,
To = (double) starOpacity/100
};
star.BeginAnimation(UIElement.OpacityProperty, fadeInStars);
}
}
示例3: WebMatrixManIDE
/// <summary>
/// Creates a square image and attaches an event handler to the layout changed event that
/// adds the the square in the upper right-hand corner of the TextView via the adornment layer
/// </summary>
/// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
public WebMatrixManIDE(IWpfTextView view)
{
_view = view;
try
{
_view = view;
_image = new Image();
_image.Opacity = 0.45;
var assemblylocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
_imagePathCollection =
System.IO.Directory.GetFiles(Path.Combine(string.IsNullOrEmpty(assemblylocation) ? "" : assemblylocation, "assets"),
"*.png");
_image.Stretch = Stretch.Uniform;
_image.Height = 500;
_image.Width = 500;
Task.Run(delegate
{
var r = new Random();
while (true)
{
_image.Dispatcher.InvokeAsync(() =>
{
_bitmap = new BitmapImage(new Uri(_imagePathCollection[r.Next(0, _imagePathCollection.Length - 1)], UriKind.Absolute));
_image.BeginAnimation(Image.OpacityProperty, _fadeOutAnimation);
_image.Source = _bitmap;
_image.BeginAnimation(Image.OpacityProperty, _fadeInAnimation);
});
Thread.Sleep(TimeSpan.FromSeconds(10));
}
});
}
catch (Exception)
{
}
//Grab a reference to the adornment layer that this adornment should be added to
_adornmentLayer = view.GetAdornmentLayer("WebMatrixManIDE");
_view.ViewportHeightChanged += delegate { this.onSizeChange(); };
_view.ViewportWidthChanged += delegate { this.onSizeChange(); };
}
示例4: ImagePopup_MouseEnter
private void ImagePopup_MouseEnter(object sender, MouseEventArgs e)
{
MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
Point point = e.GetPosition(mainWindow.MainCanvas);
_image = new Image { Source = Source, Height = 200, Width = 200 };
double y = point.Y;
if (y + _image.Height > mainWindow.ActualHeight - 60)
{
y = mainWindow.ActualHeight - _image.Height - 60;
}
_image.Margin = new Thickness(point.X, y, 0, 0);
_image.Opacity = 0;
_image.IsHitTestVisible = false;
mainWindow.MainCanvas.Children.Add(_image);
DoubleAnimation doubleAnimation = new DoubleAnimation(1, new Duration(TimeSpan.FromMilliseconds(200)));
_image.BeginAnimation(OpacityProperty, doubleAnimation);
}
示例5: HideImage
private void HideImage(Image i)
{
foreach (var c in this.MainGrid.Children)
{
var tb = c as TextBlock;
if (tb != null)
{
if (tb.Name == i.Name.Replace("img", "text"))
{
DoubleAnimation animation = new DoubleAnimation(0.25, TimeSpan.FromSeconds(0.5));
i.BeginAnimation(OpacityProperty, animation);
DoubleAnimation show = new DoubleAnimation(1, TimeSpan.FromSeconds(0.5));
textAbout.BeginAnimation(OpacityProperty, show);
DoubleAnimation hide = new DoubleAnimation(0, TimeSpan.FromSeconds(0.5));
tb.BeginAnimation(OpacityProperty, hide);
return;
}
}
}
}
示例6: RenderGrass
internal static async void RenderGrass(Canvas canvas, int height = 100)
{
List<string> getGrass = Resource.GetFiles("images/scene/grass", "grass_*.png");
for (int x = 0; x < getGrass.Count; x++)
{
string[] grassName = Regex.Split(Path.GetFileNameWithoutExtension(getGrass[x]), "_");
int grassIndex = (grassName[1] == "01") ? 3 : 1;
var grass = new Image
{
Name = (x < 10) ? "Grass_0" + x : "Grass_" + x,
Source = await Core.StreamImage(getGrass[x]),
Height = (grassName[1] == "01") ? height : height + 50,
Width = canvas.ActualWidth + 100,
Stretch = Stretch.Fill,
StretchDirection = StretchDirection.Both
};
canvas.Children.Add(grass);
Canvas.SetLeft(grass, -50);
Canvas.SetBottom(grass, 0 - grass.Height);
Panel.SetZIndex(grass, grassIndex);
var slideupGrass = new DoubleAnimation
{
From = Canvas.GetBottom(grass),
To = 0,
Duration = new Duration(TimeSpan.FromSeconds(1))
};
slideupGrass.Completed += (sender, e) => Animation.Grass(canvas);
grass.BeginAnimation(Canvas.BottomProperty, slideupGrass);
}
}
示例7: RenderLogo
internal static async void RenderLogo(Canvas canvas)
{
string getLogo = "images/various/blueniverse_logo.png";
int[] logoSize = await Core.ImageSize(getLogo);
var logoImage = new Image
{
Source = await Core.StreamImage(getLogo),
Width = logoSize[0]/2,
Height = logoSize[1]/2,
Opacity = 0
};
canvas.Children.Add(logoImage);
Canvas.SetLeft(logoImage, (canvas.ActualWidth/2 - logoImage.Width/2));
Canvas.SetTop(logoImage, (canvas.ActualHeight/2 - logoImage.Height));
Panel.SetZIndex(logoImage, 2);
var logoFadeIn = new DoubleAnimation
{
From = 0,
To = 1,
Duration = new Duration(TimeSpan.FromSeconds(1))
};
logoImage.BeginAnimation(UIElement.OpacityProperty, logoFadeIn);
}
示例8: OpacityAnimate
private void OpacityAnimate(Image image, double from, double to)
{
var da = new DoubleAnimation()
{
From = from,
To = to,
Duration = new Duration(TimeSpan.FromSeconds(1))
};
da.Completed += (sender, e) =>
{
image.BeginAnimation(OpacityProperty, null);
if (Cover1CanVisible)
{
//Bring cover1 to front
var tmpZIndex = Panel.GetZIndex(Cover1);
Panel.SetZIndex(Cover1, Panel.GetZIndex(Cover2));
Panel.SetZIndex(Cover2, tmpZIndex);
//Change to next image
Cover2.Source = thumnailList[nextImageIndex].Source;
Cover1CanVisible = false;
}
else
{
//Bring cover 2 to front
var tmpZIndex = Panel.GetZIndex(Cover2);
Panel.SetZIndex(Cover2, Panel.GetZIndex(Cover1));
Panel.SetZIndex(Cover1, tmpZIndex);
//Change to next image
Cover1.Source = thumnailList[nextImageIndex].Source;
Cover1CanVisible = true;
}
//Console.WriteLine(Panel.GetZIndex(Cover1));
//Console.WriteLine(Panel.GetZIndex(Cover2));
nextImageIndex--;
if (nextImageIndex < 0) nextImageIndex = thumnailList.Count - 1;
Console.WriteLine(nextImageIndex);
};
image.BeginAnimation(OpacityProperty, da);
}
示例9: Add
public void Add(Gesture_Event_Linking link)
{
Dispatcher.BeginInvoke(new Action(() =>
{
Gesture_Event_Linking temp = null;
foreach (Gesture_Event_Linking gesture in cardLinks.Keys) {
if (gesture.Equals(link)) {
temp = gesture;
}
}
if (temp != null)
{
Remove(temp);
return;
}
Line follower = new Line();
follower.X1 = link.Card1.CurrentPosition.X;
follower.Y1 = link.Card1.CurrentPosition.Y;
follower.X2 = link.Points[0].CurrentPoint.Position.X;
follower.Y2 = link.Points[0].CurrentPoint.Position.Y;
follower.Stroke = new SolidColorBrush(link.Card1.HightlightColor);
follower.StrokeThickness = 3;
follower.Opacity = 1;
cardLinks[link] = follower;
Link_List.AddLink(link);
Image image = new Image();
image.Source = arrowImage[link.Card1.Owner];
image.Width = 50;
image.Height = 50;
image.Stretch = Stretch.Fill;
arrows[follower] = new Image[] { image };
moveArrow(follower);
this.Children.Add(follower);
this.Children.Add(image);
Canvas.SetZIndex(image, cardLinks.Count);
DoubleAnimation animation = new DoubleAnimation(0, 1, TimeSpan.FromSeconds(STATICS.ANIMATION_DURATION));
follower.BeginAnimation(Canvas.OpacityProperty, animation);
image.BeginAnimation(Canvas.OpacityProperty, animation);
}));
}
示例10: FadeOut
public static void FadeOut(Image image, double nFadeTime, EventHandler OnCompleted)
{
DoubleAnimation animFader = new DoubleAnimation(1.0, 0.0, new Duration(TimeSpan.FromMilliseconds(nFadeTime)), FillBehavior.HoldEnd);
if (OnCompleted != null) {
animFader.Completed += new EventHandler(OnCompleted);
}
image.BeginAnimation(Rectangle.OpacityProperty, animFader);
}
示例11: animationFade
private void animationFade(Image btn, double from, double to, int duration)
{
DoubleAnimation animationFade = new DoubleAnimation();
animationFade.From = from;
animationFade.To = to;
animationFade.Duration = new Duration(TimeSpan.FromMilliseconds(duration));
btn.BeginAnimation(Button.OpacityProperty, animationFade);
}
示例12: CreateVisuals
private void CreateVisuals(ITextViewLine line, IList<VariableDeclaratorSyntax> fields, IList<VariableDeclaratorSyntax> fieldsThatShouldBeReadOnly)
{
IWpfTextViewLineCollection textViewLines = this.view.TextViewLines;
var fieldsOnThisLine = fields.Where(f => f.FullSpan.IntersectsWith(new TextSpan(line.Start.Position, line.Length)));
foreach (var field in fieldsOnThisLine)
{
if (fieldsThatShouldBeReadOnly.Contains(field) && !this.layer.Elements.Any(e => AdornmentTagFor(field).Equals(e.Tag)))
{
var startIndex = field.FullSpan.Start;
SnapshotSpan span = new SnapshotSpan(this.view.TextSnapshot, Span.FromBounds(startIndex, startIndex + field.FullSpan.Length));
var geometry = textViewLines.GetMarkerGeometry(span);
if (geometry != null)
{
var drawing = new GeometryDrawing(this.brush, this.pen, geometry);
drawing.Freeze();
var drawingImage = new DrawingImage(drawing);
drawingImage.Freeze();
var image = new Image
{
Source = drawingImage,
};
// If you're going to torment your colleagues, torment them good and hard
image.BeginAnimation(Image.VisibilityProperty, new ObjectAnimationUsingKeyFrames
{
Duration = new Duration(TimeSpan.FromSeconds(1)),
RepeatBehavior = RepeatBehavior.Forever,
KeyFrames = new ObjectKeyFrameCollection
{
new DiscreteObjectKeyFrame(Visibility.Visible, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.0))),
new DiscreteObjectKeyFrame(Visibility.Hidden, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.5))),
},
});
// Align the image with the top of the bounds of the text geometry
Canvas.SetLeft(image, geometry.Bounds.Left);
Canvas.SetTop(image, geometry.Bounds.Top);
this.layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, AdornmentTagFor(field), image, null);
}
}
else
{
this.layer.RemoveAdornmentsByTag(AdornmentTagFor(field));
}
}
}