我创建了一个动画图像以在我的画布上移动,然后我创建了另一个动画图像;
我想隐藏我的第一张图片,然后移动另一幅图像;
我尝试将绘图视觉或图像画笔等的不透明度设置为零;但是我的所有图像都是
隐藏;
List<EllipseGeometry> eg = new List<EllipseGeometry>();
Path ballPath;
int c = 0;
foreach (Polyline p in pl)
{
if (p.Points.Count > 1)
{
ballPath = new Path();
FormattedText formattedText = new FormattedText(" " + (anl[c].DOffset).ToString() + "\n " + anl[c].playername + " ", CultureInfo.GetCultureInfo("en-us"),
FlowDirection.LeftToRight,
new Typeface("arial"),
20,
Brushes.Black);
formattedText.MaxTextWidth = 500;
formattedText.MaxTextHeight = 500;
DrawingVisual drawingVisual = new DrawingVisual();
DrawingContext drawingContext = drawingVisual.RenderOpen();
drawingContext.DrawImage(il[c].Source, new Rect(4, 0, 26, 26));//30
drawingContext.DrawText(formattedText, new Point(1, 2));
drawingContext.Close();
RenderTargetBitmap bmp = new RenderTargetBitmap((int)formattedText.WidthIncludingTrailingWhitespace, (int)formattedText.Height, 96, 96, PixelFormats.Pbgra32);
bmp.Render(drawingVisual);
ImageBrush b = new ImageBrush(bmp);
b.Stretch = Stretch.Uniform;
ballPath.Fill = b;
mainwindow.animecan.Children.Add(ballPath);
////
int jy = 0;
for (int i = 0; i < anl.Count; i++)
{
try
{
if (anl[i].offset == m)
jy = anl[i].offset;
}
catch
{
}
}
if (multi && p.Uid == jy.ToString())//اگر آفست مالتی اسپید شده باشه
{
eg.Add(new EllipseGeometry(ms[ih].p1, 27, 27));
ballPath.Data = eg.First();// animatedEllipseGeometry;
PathFigure myPathFigure = new PathFigure();
PointCollection pe = new PointCollection();
pe.Add(ms[ih].p1);
pe.Add(ms[ih].p2);
myPathFigure.StartPoint = eg.First().Center;
myPathFigure.Segments.Add(
new PolyLineSegment(pe, true));
PathGeometry myPathGeometry = new PathGeometry();
myPathGeometry.Figures.Add(myPathFigure);
myPathGeometry = new PathGeometry();
myPathGeometry.Figures.Add(myPathFigure);//
PointAnimationUsingPath centerPointAnimation1 = new PointAnimationUsingPath();
centerPointAnimation1.PathGeometry = myPathGeometry;
centerPointAnimation1.Duration = TimeSpan.FromSeconds(ms[ih].sspeed);
centerPointAnimation1.BeginTime = TimeSpan.FromSeconds(ms[ih].delay);
centerPointAnimation1.FillBehavior = FillBehavior.HoldEnd;
eg.First().BeginAnimation(EllipseGeometry.CenterProperty, centerPointAnimation1);
eg.Remove(eg.First());
}
c++;
答案 0 :(得分:0)
我认为您的问题是由于您的整个代码块被立即执行而造成的。 (在更新用户界面之前),而不是逐行排除&#39;。为了在执行到达代码块结束之前调用Visibility
属性更新,您需要在Dispatcher
对象上对其进行排队。试试这个:
Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate
{
yourControl.Visibility = Visibility.Collapsed;
});