void ta_Completed(object sender, EventArgs e) { Dispatcher.Invoke(delegate() { ThicknessAnimation ta = new ThicknessAnimation(); ta.From = new Thickness(0); ta.To = new Thickness(0, 0, 0, 0); ta.Duration = new Duration(TimeSpan.FromSeconds(0)); ta.Completed += ta_FixCompleted; CapturedImage.BeginAnimation(MarginProperty, ta); }); }
private void captureButton_MouseDown(object sender, MouseButtonEventArgs e) { if (currentMode == 0) { if ((DateTime.Now - lastImageTaken).TotalMilliseconds > 200) { lastImageTaken = DateTime.Now; BitmapSource captureImage = (BitmapSource)webcamImage.Source; /*CapturedImage.Source = BitmapImage.Create( * 2, * 2, * 96, * 96, * PixelFormats.Indexed1, * new BitmapPalette(new List<Color> { Colors.Transparent }), * new byte[] { 0, 0, 0, 0 }, * 1);*/ CapturedImage.Source = captureImage; CapturedImage.Width = captureImage.Width; CapturedImage.Height = captureImage.Height; CapturedImage.Opacity = 1; /*DoubleAnimation da = new DoubleAnimation(); * da.From = videoSource.VideoResolution.FrameSize.Height; * da.To = new Thickness(100); * da.Duration = new Duration(TimeSpan.FromSeconds(0.15F)); * */ //da.RepeatBehavior=new RepeatBehavior(3); DoubleAnimation ta = new DoubleAnimation(); ta.From = captureImage.Height; ta.To = 0; ta.Duration = new Duration(TimeSpan.FromSeconds(0.3F)); ta.Completed += ta_Completed; CapturedImage.BeginAnimation(HeightProperty, ta); DoubleAnimation da = new DoubleAnimation(); da.From = 1; da.To = 0; da.Duration = new Duration(TimeSpan.FromSeconds(0.2F)); CapturedImage.BeginAnimation(OpacityProperty, da); WriteJpeg(GetFileName("Picture", ".jpeg"), 100, (BitmapSource)captureImage, Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)); } } else if (currentMode == 1) { if (isRecording) { StopRecording(); } else { StartRecording(); } } }