public OnlineStatusControl() { InitializeComponent(); story = new Storyboard(); ColorAnimation animation1 = new ColorAnimation(); Storyboard.SetTarget(animation1, ((RadialGradientBrush)this.ellipse.Fill).GradientStops[0]); Storyboard.SetTargetProperty( animation1, new PropertyPath(GradientStop.ColorProperty)); animation1.Duration = new Duration(new TimeSpan(0, 0, 1)); ; animation1.To = Colors.White; story.Stop(); story.Children.Add(animation1); ColorAnimation animation2 = new ColorAnimation(); Storyboard.SetTarget(animation2, ((RadialGradientBrush)this.ellipse.Fill).GradientStops[1]); Storyboard.SetTargetProperty( animation2, new PropertyPath(GradientStop.ColorProperty)); animation2.Duration = new Duration(new TimeSpan(0, 0, 1)); ; animation2.To = Common.MyColor.ConvertColor("#ff2ADC16"); story.Stop(); story.Children.Add(animation2); story.AutoReverse = true; story.RepeatBehavior = RepeatBehavior.Forever; this.LayoutRoot.Resources.Add("sotry_", story); OnlineStatus = 1; }
/// <summary> /// Called when it's time to execute this storyboard action /// </summary> internal override void Invoke( FrameworkElement containingFE, FrameworkContentElement containingFCE, Storyboard storyboard ) { Debug.Assert( containingFE != null || containingFCE != null, "Caller of internal function failed to verify that we have a FE or FCE - we have neither." ); if( containingFE != null ) { storyboard.Stop(containingFE); } else { storyboard.Stop(containingFCE); } }
public CameraItem() { InitializeComponent(); panPicture = (Storyboard)TryFindResource("scaleandmove"); EventHandler handler2 = null; handler2 = delegate { panPicture.Completed -= handler2; panPicture.Stop(); camera_image.Opacity = 0; EventHandler handler3 = null; handler3 = delegate { panPicture2.Completed -= handler3; panPicture2.Stop(); TransformGroup trGrp = new TransformGroup(); TranslateTransform trTns = new TranslateTransform(-80.5, -3.389); ; ScaleTransform trScl = new ScaleTransform(1.293, 1.293); trGrp.Children.Add(trTns); trGrp.Children.Add(trScl); camera_image2.RenderTransform = trGrp; //CameraiTime.camera_image2.Opacity = 1; }; panPicture2.Completed += handler3; panPicture2.Begin(); }; panPicture.Completed += handler2; panPicture2 = (Storyboard)TryFindResource("scale2"); }
/// <summary> /// Animates the translate transform object, responsible for displacement of the target. /// </summary> /// <param name="target">The target object.</param> /// <param name="storyboard">The storyboard.</param> /// <param name="to">Animation's ending value.</param> /// <param name="seconds">Duration of the animation in seconds.</param> /// <param name="easingFunction">Easing function applied to the animation.</param> public static void AnimateTranslateTransform(this DependencyObject target, Storyboard storyboard, Point to, double seconds, IEasingFunction easingFunction = null) { Duration duration = new Duration(TimeSpan.FromSeconds(seconds)); DoubleAnimation doubleAnimationX = new DoubleAnimation() { To = to.X, Duration = duration, EasingFunction = easingFunction }; DoubleAnimation doubleAnimationY = new DoubleAnimation() { To = to.Y, Duration = duration, EasingFunction = easingFunction }; storyboard.Stop(); storyboard.Children.Clear(); storyboard.Duration = duration; storyboard.Children.Add(doubleAnimationX); storyboard.Children.Add(doubleAnimationY); Storyboard.SetTarget(doubleAnimationX, target); Storyboard.SetTarget(doubleAnimationY, target); Storyboard.SetTargetProperty(doubleAnimationX, (target as UIElement).GetPropertyPathForTranslateTransformX()); Storyboard.SetTargetProperty(doubleAnimationY, (target as UIElement).GetPropertyPathForTranslateTransformY()); storyboard.Begin(); }
public void ClosingWindow() { //キーフレームで時間を区切る var frame0 = new EasingDoubleKeyFrame(this.Width, KeyTime.FromTimeSpan(new TimeSpan(1))); var frame1 = new EasingDoubleKeyFrame(0, KeyTime.FromTimeSpan(new TimeSpan(2500000))); var frame2 = new EasingDoubleKeyFrame(this.Height, KeyTime.FromTimeSpan(new TimeSpan(2500001))); var frame3 = new EasingDoubleKeyFrame(0, KeyTime.FromTimeSpan(new TimeSpan(5000000))); //キーフレームをアニメーションとしてまとめる var animationWidth = new DoubleAnimationUsingKeyFrames(); animationWidth.KeyFrames.Add(frame0); animationWidth.KeyFrames.Add(frame1); //アニメーションをアニメーションさせたいオブジェクトクラスのプロパティにひもづける //...ということはオブジェクト毎にアニメーションさせるのはだめ? Storyboard.SetTargetName(animationWidth, this.Name); Storyboard.SetTargetProperty(animationWidth, new PropertyPath(MainWindow.WidthProperty)); var animationHeight = new DoubleAnimationUsingKeyFrames(); animationHeight.KeyFrames.Add(frame2); animationHeight.KeyFrames.Add(frame3); Storyboard.SetTargetName(animationHeight, this.Name); Storyboard.SetTargetProperty(animationHeight, new PropertyPath(MainWindow.HeightProperty)); //静的にひもづけられたストーリーボードへアニメーションを登録する myStoryboard = new Storyboard(); myStoryboard.Completed += new EventHandler(endAnimation); myStoryboard.Children.Add(animationWidth); myStoryboard.Children.Add(animationHeight); //アニメーションを実行する myStoryboard.Begin(this); myStoryboard.Stop(); }
void ButtonSave_Click(object sender, RoutedEventArgs e) { Storyboard sb = new Storyboard(); sb = Application.Current.Resources["ButtonPressAnimation"] as Storyboard; sb.Completed += new EventHandler(delegate(object obj, EventArgs es) { sb.Stop(); }); Storyboard.SetTarget(sb, ButtonSaveTransform); sb.Begin(); if (!string.IsNullOrEmpty(TextBoxDefaultWidth.Text)) IsolatedStorageManager.SaveIntoIsolatedStorage("DefaultWidth", Convert.ToInt32(TextBoxDefaultWidth.Text)); if (!string.IsNullOrEmpty(TextBoxDefaultHeight.Text)) IsolatedStorageManager.SaveIntoIsolatedStorage("DefaultHeight", Convert.ToInt32(TextBoxDefaultHeight.Text)); if (!string.IsNullOrEmpty(TextBoxMinimumWidth.Text)) IsolatedStorageManager.SaveIntoIsolatedStorage("MinimumWidth", Convert.ToInt32(TextBoxMinimumWidth.Text)); if (!string.IsNullOrEmpty(TextBoxMinimumHeight.Text)) IsolatedStorageManager.SaveIntoIsolatedStorage("MinimumHeight", Convert.ToInt32(TextBoxMinimumHeight.Text)); IsolatedStorageManager.SaveIntoIsolatedStorage("ResizeWithBrowser", CheckboxResizeWithBrowser.IsChecked); IsolatedStorageManager.SaveIntoIsolatedStorage("MaintainAspectRatio", CheckboxMaintainAspectRatio.IsChecked); IsolatedStorageManager.SaveIntoIsolatedStorage("ForceIPv4", CheckboxForceIPv4.IsChecked); if (!string.IsNullOrEmpty(TextBoxNumberOfMessagesOnMonitor.Text)) IsolatedStorageManager.SaveIntoIsolatedStorage("NumberOfMessagesOnMonitor", Convert.ToInt32(TextBoxNumberOfMessagesOnMonitor.Text)); LoadSettingsFromIsolatedStorage(); SystemMessages sm = new SystemMessages(new Message() { UserMessage = "Successfully Saved System Settings", SystemMessage = string.Empty, UserMessageType = MessageType.Success }, ButtonType.OkOnly); sm.ShowPopup(); }
public static Task SmoothSetAsync(this FrameworkElement @this, DependencyProperty dp, double targetvalue, TimeSpan iDuration, CancellationToken iCancellationToken) { TaskCompletionSource<object> tcs = new TaskCompletionSource<object>(); DoubleAnimation anim = new DoubleAnimation(targetvalue, new Duration(iDuration)); PropertyPath p = new PropertyPath("(0)", dp); Storyboard.SetTargetProperty(anim, p); Storyboard sb = new Storyboard(); sb.Children.Add(anim); EventHandler handler = null; handler = delegate { sb.Completed -= handler; sb.Remove(@this); @this.SetValue(dp, targetvalue); tcs.TrySetResult(null); }; sb.Completed += handler; sb.Begin(@this, true); iCancellationToken.Register(() => { double v = (double)@this.GetValue(dp); sb.Stop(); sb.Remove(@this); @this.SetValue(dp, v); tcs.TrySetCanceled(); }); return tcs.Task; }
/// <summary> /// 结束登录动画 /// </summary> private void StopLoginStd() { DoubleAnimation da = new DoubleAnimation(); da.Duration = new Duration(TimeSpan.FromSeconds(1)); da.To = 0d; this.axr.BeginAnimation(AxisAngleRotation3D.AngleProperty, da); storyboardCar.Stop(); }
private void Button_Click(object sender, RoutedEventArgs e) { //MainPanel.IsEnabled = false; _sb = new Storyboard(); _sb.FillBehavior = FillBehavior.Stop; _sb.RepeatBehavior = RepeatBehavior.Forever; DoubleAnimationUsingKeyFrames da2 = new DoubleAnimationUsingKeyFrames(); da2.KeyFrames.Add(new LinearDoubleKeyFrame(30, TimeSpan.FromSeconds(0.1))); da2.KeyFrames.Add(new LinearDoubleKeyFrame(60, TimeSpan.FromSeconds(0.2))); da2.KeyFrames.Add(new LinearDoubleKeyFrame(90, TimeSpan.FromSeconds(0.3))); da2.KeyFrames.Add(new LinearDoubleKeyFrame(120, TimeSpan.FromSeconds(0.4))); da2.KeyFrames.Add(new LinearDoubleKeyFrame(150, TimeSpan.FromSeconds(0.5))); da2.KeyFrames.Add(new LinearDoubleKeyFrame(180, TimeSpan.FromSeconds(0.6))); Storyboard.SetTarget(da2, Button); Storyboard.SetTargetProperty(da2, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)")); _sb.Children.Add(da2); _sb.Begin(); // 延时打开DockWindow Thread t = new Thread(() => { Thread.Sleep(3000); Dispatcher.Invoke(new Action(() => { if (userName.Text == "1") { _sb.Stop(); Close(); var dockView = new MainWindow(); dockView.ShowDialog(); } else { _sb.Stop(); var errorWindow = new ErrorWindow(); errorWindow.ShowDialog(); } })); }); t.Start(); }
/// <summary> /// 向Storyboard添加动画 /// </summary> /// <param name="sb">目标Storyboard</param> /// <param name="dobj">动画目标</param> /// <param name="property">被改变的值</param> /// <param name="to">动画完毕后的最终值</param> /// <param name="Duration">动画持续时间</param> /// <param name="eh">Storyboard完成事件处理程序</param> public void AddAnimationToStoryboard(Storyboard sb, DependencyObject dobj, string property, double to, TimeSpan Duration) { DoubleAnimation da = new DoubleAnimation(); Storyboard.SetTarget(da, dobj); Storyboard.SetTargetProperty(da, new PropertyPath(property)); da.To = to; da.Duration = new Duration(Duration); sb.Stop(); sb.Children.Add(da); }
/// <summary> /// 地震 /// </summary> /// <param name="depth">深度</param> public void Shake(int depth) { Storyboard shakeStoryboard = new Storyboard() { AutoReverse = true }; shakeStoryboard.Children.Add(GlobalMethod.CreateDoubleAnimation(thisTranslateTransform, "X", thisTranslateTransform.X + RandomSeed.Next(-depth, depth), TimeSpan.FromMilliseconds(40), new CubicEase() { EasingMode = EasingMode.EaseOut })); shakeStoryboard.Children.Add(GlobalMethod.CreateDoubleAnimation(thisTranslateTransform, "Y", thisTranslateTransform.Y + RandomSeed.Next(-depth, depth), TimeSpan.FromMilliseconds(40), new CubicEase() { EasingMode = EasingMode.EaseOut })); EventHandler handler = null; shakeStoryboard.Completed += handler = delegate { shakeStoryboard.Completed -= handler; shakeStoryboard.Stop(); }; shakeStoryboard.Begin(); }
public void Show() { //2s之内连续按2次,退出 if (clickCount > 0) { if (Completed != null) { Completed(true); } } else { clickCount++; if (Completed != null) { Completed(false); } var tips = new JMessboxControl(); tips.TBMessage.Text = this.messageText; popup.Height = 65; popup.Width = 200; popup.Margin = new Thickness(140, 380, 0, 0); popup.IsOpen = false; popup.Child = tips; //渐变效果:透明度200毫秒内从0->1 Storyboard story = new Storyboard(); DoubleAnimation topAnimation = new DoubleAnimation(); topAnimation.From = 0; topAnimation.To = 1; topAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(200)); Storyboard.SetTarget(topAnimation, tips); Storyboard.SetTargetProperty(topAnimation, new PropertyPath("(UIElement.Opacity)")); story.Children.Add(topAnimation); popup.IsOpen = true; story.Begin(); //动画延迟2秒 story.Duration = new Duration(new TimeSpan(0, 0, 2)); //story.BeginTime = new TimeSpan(0, 0, 0, 0, 1); story.Completed += (s1, e1) => { //2s后执行此方法 clickCount = 0; popup.IsOpen = false; story.Stop(); }; } }
void ButtonSearch_Click(object sender, RoutedEventArgs e) { #if SILVERLIGHT Storyboard sb = new Storyboard(); sb = Application.Current.Resources["ButtonPressAnimation"] as Storyboard; sb.Completed += new EventHandler(delegate(object obj, EventArgs es) { sb.Stop(); }); Storyboard.SetTarget(sb, ButtonSearchTransform); sb.Begin(); #endif string searchText = TextBoxSearch.Text.ToUpper(); ListBoxOtherDeviceList.ItemsSource = (from item in m_otherDeviceList where item.Acronym.ToUpper().Contains(searchText) || item.Name.ToUpper().Contains(searchText) || item.InterconnectionName.ToUpper().Contains(searchText) || item.CompanyName.ToUpper().Contains(searchText) || item.VendorDeviceName.ToUpper().Contains(searchText) select item).ToList(); }
public override void Run(RoleBase caster, Space space, MagicArgs args) { double distance = GlobalMethod.GetDistance(args.Position, args.Destination); double speed = 2; caster.LinearShuttle(args.Destination, distance * speed); int count = 0; EventHandler timerHandler = null; DispatcherTimer timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(100) }; timer.Tick += timerHandler = delegate { caster.Target = null; if (count == args.Number || caster.Action != Actions.Attack) { timer.Tick -= timerHandler; timer.Stop(); } else { WriteableBitmap writeableBitmap = new WriteableBitmap((int)caster.OverallSize.X, (int)caster.OverallSize.Y); writeableBitmap.Render(caster.EquipEntity(EquipTypes.Overall), null); writeableBitmap.Invalidate(); EntityObject chasingShadow = new EntityObject() { RenderTransform = caster.RenderTransform, ImageSource = writeableBitmap, Center = caster.Center, Position = caster.Position, Z = caster.Z - 20 }; space.Children.Add(chasingShadow); Storyboard storyboard = new Storyboard(); storyboard.Children.Add(GlobalMethod.CreateDoubleAnimation(chasingShadow,"Opacity",0.9,0,TimeSpan.FromMilliseconds(caster.HeartInterval * 3),null)); EventHandler handler = null; storyboard.Completed += handler = delegate { storyboard.Completed -= handler; storyboard.Stop(); space.Children.Remove(chasingShadow); }; storyboard.Begin(); //每200毫秒伤害一次 if (count % 2 == 0) { for (int i = space.AllRoles().Count - 1; i >= 0; i--) { RoleBase target = space.AllRoles()[i]; if (caster.IsHostileTo(target) && target.InCircle(caster.Position, args.Radius * args.Scale)) { caster.CastingToEffect(target, args); } } } count++; } }; timer.Start(); }
void ButtonClear_Click(object sender, RoutedEventArgs e) { Storyboard sb = new Storyboard(); sb = Application.Current.Resources["ButtonPressAnimation"] as Storyboard; sb.Completed += new EventHandler(delegate(object obj, EventArgs es) { sb.Stop(); }); Storyboard.SetTarget(sb, ButtonClearTransform); sb.Begin(); //Load Default Settings. ProxyClient.SetDefaultSystemSettings(true); LoadSettingsFromIsolatedStorage(); SystemMessages sm = new SystemMessages(new Message() { UserMessage = "Successfully Restored Default System Settings", SystemMessage = string.Empty, UserMessageType = MessageType.Success }, ButtonType.OkOnly); sm.ShowPopup(); }
public void BeginTransition(TransitionPresenter transitionElement, UIElement oldContent, UIElement newContent) { var sb = new Storyboard(); var animation = CreateFadeOutAnimation(oldContent); sb.Children.Add(animation); sb.Duration = FadeLength; sb.Completed += (s, e) =>{ sb.Stop(); transitionElement.TransitionEnded(this, oldContent, newContent); }; sb.Begin(); }
void ButtonSendServiceRequest_Click(object sender, RoutedEventArgs e) { #if SILVERLIGHT Storyboard sb = new Storyboard(); sb = Application.Current.Resources["ButtonPressAnimation"] as Storyboard; sb.Completed += new EventHandler(delegate(object obj, EventArgs es) { sb.Stop(); }); Storyboard.SetTarget(sb, ButtonSendServiceRequestTransform); sb.Begin(); #endif if (!string.IsNullOrEmpty(TextBoxServiceRequest.Text)) { SendRequest(); TextBoxServiceRequest.Focus(); TextBoxServiceRequest.SelectAll(); } }
private void DPLoaded(object sender, RoutedEventArgs e) { WIPAnimation = (this.FindResource("WorkInProgress") as Storyboard); WIPAnimation.Begin(); ESDDL = new WebClient(); ESDDL.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ESDDL_DownloadProgressChanged); ESDDL.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(ESDDL_DownloadFileCompleted); this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate() { ESDUrl = MainWindowHandle.ESDParams[0]; ESDSavePath = MainWindowHandle.ESDParams[1]; ESDSavePath = TempFolder + "\\" + ESDSavePath; MainWindowHandle.ESDPath = ESDSavePath; } )); if (File.Exists(ESDSavePath)) { this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate() { MainWindowHandle.SendGXNReport("ESD already exists"); } )); this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate() { Storyboard DieAnimation = (this.FindResource("DieProgress") as Storyboard); DieAnimation.Begin(); WIPAnimation.Stop(); ProgressLabel.Visibility = System.Windows.Visibility.Hidden; DownloadProgress.Visibility = System.Windows.Visibility.Hidden; PageHeading.Content = "Ready to upgrade"; SummaryBlock.Text = "Press the \"Next\" button to start the upgrade process."; NextBtn.IsEnabled = true; NextBtn.Opacity = 1; } )); } else { this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate() { MainWindowHandle.SendGXNReport("ESD download started"); } )); ESDDL.DownloadFileAsync(new Uri(ESDUrl), ESDSavePath); } }
public void StopTest () { bool complete = false; Rectangle target = new Rectangle { Width = 0 }; Storyboard sb = new Storyboard (); DoubleAnimation anim = new DoubleAnimation { From = 10, To = 100, Duration = TimeSpan.FromMilliseconds (10) }; sb.Children.Add (anim); Storyboard.SetTarget (anim, target); Storyboard.SetTargetProperty (anim, new PropertyPath (Rectangle.WidthProperty)); sb.Completed += delegate { complete = true; }; Enqueue (() => sb.Begin ()); EnqueueConditional (() => complete, "#1"); Enqueue (() => Assert.AreEqual (100, target.Width, "#2")); Enqueue (() => sb.Stop ()); Enqueue (() => Assert.AreEqual (0, target.Width, "#3")); EnqueueTestComplete (); }
void ButtonAdd_Click(object sender, RoutedEventArgs e) { if ((bool)CheckAll.IsChecked) CheckAll.IsChecked = false; #if SILVERLIGHT Storyboard sb = new Storyboard(); sb = Application.Current.Resources["ButtonPressAnimation"] as Storyboard; sb.Completed += new EventHandler(delegate(object obj, EventArgs es) { sb.Stop(); }); Storyboard.SetTarget(sb, ButtonAddTransform); sb.Begin(); #endif AddDevices addDevices = new AddDevices(m_sourceOutputStreamID, m_sourceOutputStreamAcronym); addDevices.Closed += new EventHandler(addDevices_Closed); #if SILVERLIGHT addDevices.Show(); #else addDevices.Owner = Window.GetWindow(this); addDevices.WindowStartupLocation = WindowStartupLocation.CenterOwner; addDevices.ShowDialog(); #endif }
/// <summary> /// Begins the transition. /// </summary> /// <param name="transitionElement">The transition element.</param> /// <param name="oldContent">The old content.</param> /// <param name="newContent">The new content.</param> public void BeginTransition(TransitionPresenter transitionElement, UIElement oldContent, UIElement newContent) { var sb = new Storyboard { Duration = _swipLength }; Canvas.SetLeft(newContent, Configuration.InternalResolution.Width); var animation = CreateSwipAnimation(newContent); sb.Children.Add(animation); sb.Completed += (s, e) => { sb.Stop(); transitionElement.TransitionEnded(oldContent); Canvas.SetLeft(newContent, 0); }; sb.Begin(); }
/// <summary> /// Begins the transition. /// </summary> /// <param name="transitionElement">The transition element.</param> /// <param name="oldContent">The old content.</param> /// <param name="newContent">The new content.</param> public void BeginTransition(TransitionPresenter transitionElement, UIElement oldContent, UIElement newContent) { transitionElement.Children.Clear(); transitionElement.Children.Add(newContent); var sb = new Storyboard(); var animation = CreateFadeInAnimation(newContent); sb.Children.Add(animation); sb.Duration = _fadeLength; newContent.Opacity = 0; sb.Completed += (s, e) => { sb.Stop(); newContent.Opacity = 1; }; sb.Begin(); }
void ButtonShowAll_Click(object sender, RoutedEventArgs e) { Storyboard sb = new Storyboard(); sb = Application.Current.Resources["ButtonPressAnimation"] as Storyboard; sb.Completed += new EventHandler(delegate(object obj, EventArgs es) { sb.Stop(); }); Storyboard.SetTarget(sb, ButtonShowAllTransform); sb.Begin(); BindData(m_measurementList); }
void ButtonSearch_Click(object sender, RoutedEventArgs e) { Storyboard sb = new Storyboard(); sb = Application.Current.Resources["ButtonPressAnimation"] as Storyboard; sb.Completed += new EventHandler(delegate(object obj, EventArgs es) { sb.Stop(); }); Storyboard.SetTarget(sb, ButtonSearchTransform); sb.Begin(); string searchText = TextBoxSearch.Text.ToUpper(); //ListBoxMeasurementList.ItemsSource List<Measurement> searchResult = new List<Measurement>(); searchResult = (from item in m_measurementList where item.PointTag.Contains(searchText) || item.SignalReference.Contains(searchText) || item.SignalSuffix.Contains(searchText) || item.Description.ToUpper().Contains(searchText) || item.DeviceAcronym.Contains(searchText) || item.SignalName.ToUpper().Contains(searchText) || item.SignalAcronym.Contains(searchText) select item).ToList(); BindData(searchResult); }
void ButtonSave_Click(object sender, RoutedEventArgs e) { Storyboard sb = new Storyboard(); sb = Application.Current.Resources["ButtonPressAnimation"] as Storyboard; sb.Completed += new EventHandler(delegate(object obj, EventArgs es) { sb.Stop(); }); Storyboard.SetTarget(sb, ButtonSaveTransform); sb.Begin(); if (IsValid()) { Measurement measurement = new Measurement(); measurement.HistorianID = ((KeyValuePair<int, string>)ComboBoxHistorian.SelectedItem).Key == 0 ? (int?)null : ((KeyValuePair<int, string>)ComboBoxHistorian.SelectedItem).Key; measurement.DeviceID = ((KeyValuePair<int, string>)ComboBoxDevice.SelectedItem).Key == 0 ? (int?)null : ((KeyValuePair<int, string>)ComboBoxDevice.SelectedItem).Key; measurement.PointTag = TextBoxPointTag.Text.CleanText(); measurement.AlternateTag = TextBoxAlternateTag.Text.CleanText(); measurement.SignalTypeID = ((KeyValuePair<int, string>)ComboBoxSignalType.SelectedItem).Key; measurement.PhasorSourceIndex = ((KeyValuePair<int, string>)ComboBoxPhasorSource.SelectedItem).Key == 0 ? (int?)null : ((KeyValuePair<int, string>)ComboBoxPhasorSource.SelectedItem).Key; measurement.SignalReference = TextBoxSignalReference.Text.CleanText(); measurement.Adder = TextBoxAdder.Text.ToDouble(); measurement.Multiplier = TextBoxMultiplier.Text.ToDouble(); measurement.Description = TextBoxDescription.Text.CleanText(); measurement.Enabled = (bool)CheckboxEnabled.IsChecked; if (m_inEditMode == true && !string.IsNullOrEmpty(m_signalID)) { measurement.SignalID = m_signalID; m_client.SaveMeasurementAsync(measurement, false); } else m_client.SaveMeasurementAsync(measurement, true); } }
void ButtonClear_Click(object sender, RoutedEventArgs e) { Storyboard sb = new Storyboard(); sb = Application.Current.Resources["ButtonPressAnimation"] as Storyboard; sb.Completed += new EventHandler(delegate(object obj, EventArgs es) { sb.Stop(); }); Storyboard.SetTarget(sb, ButtonClearTransform); sb.Begin(); ClearForm(); }
private void Transition(Storyboard aStoryboard, Storyboard bStoryboard) { if (m_AnimationElement == null || bStoryboard == null) return; bStoryboard.Stop(); // Give the target a unique name so we can find it later string name = Guid.NewGuid().ToString(); bStoryboard.SetTargetName(name); m_AnimationElement.Tag = name; bStoryboard.SetTarget(m_AnimationElement); foreach (Timeline animation in bStoryboard.Children) animation.SetTarget(m_AnimationElement); //m_AnimationElement.Visibility = Visibility.Visible; m_AnimationElement.UpdateLayout(); if (aStoryboard != null) { aStoryboard.Pause(); Duration duration = bStoryboard.Duration; TimeSpan timeSpan = aStoryboard.GetCurrentTime(); bStoryboard.Begin(); if (timeSpan.TotalMilliseconds != 0 && duration.HasTimeSpan) bStoryboard.Seek(duration.TimeSpan - timeSpan); } else bStoryboard.Begin(); }
private static bool Run(Storyboard storyboard, ChartSeries series, Action completed = null) { if (storyboard.Children.Count == 0) { return false; } storyboard.Completed += (s, e) => { storyboard.Stop(); lock (locker) { int count = (int)series.GetValue(ChartAnimationUtilities.RunningAnimationsCountProperty); count--; series.SetValue(ChartAnimationUtilities.RunningAnimationsCountProperty, count); } if (completed != null) { completed(); } }; storyboard.Begin(); lock (locker) { int count = (int)series.GetValue(ChartAnimationUtilities.RunningAnimationsCountProperty); count++; series.SetValue(ChartAnimationUtilities.RunningAnimationsCountProperty, count); } return true; }
void ButtonSave_Click(object sender, RoutedEventArgs e) { #if SILVERLIGHT Storyboard sb = new Storyboard(); sb = Application.Current.Resources["ButtonPressAnimation"] as Storyboard; sb.Completed += new EventHandler(delegate(object obj, EventArgs es) { sb.Stop(); }); Storyboard.SetTarget(sb, ButtonSaveTransform); sb.Begin(); #endif if (IsValid()) { Vendor vendor = new Vendor(); vendor.Acronym = TextBoxAcronym.Text.CleanText(); vendor.Name = TextBoxName.Text.CleanText(); vendor.PhoneNumber = TextBoxPhoneNumber.Text.CleanText(); vendor.ContactEmail = TextBoxContactEmail.Text.CleanText(); vendor.URL = TextBoxUrl.Text.CleanText(); if (m_vendorID != 0 && m_inEditMode == true) //i.e. It is an update to existing item. { vendor.ID = m_vendorID; SaveVendor(vendor, false); } else //i.e. It is a new item SaveVendor(vendor, true); } }
/// <summary> /// 闪烁 /// </summary> /// <param name="timeSpan"></param> public void Flash(double timeSpan) { Storyboard storyboard = new Storyboard() { AutoReverse = true }; storyboard.Children.Add(GlobalMethod.CreateDoubleAnimation(this, "Opacity", 0, 1, TimeSpan.FromMilliseconds(timeSpan), null)); EventHandler handler = null; storyboard.Completed += handler = (s, e) => { storyboard.Completed -= handler; storyboard.Stop(); storyboard = null; Dispose(this, e); }; storyboard.Begin(); }
/// <summary> /// Create exploding in animation for 3D Pie/Doughnut /// </summary> /// <param name="dataPoint">DataPoint</param> /// <param name="storyboard">Stroyboard used for animation</param> /// <param name="pathElements">Path elements reference</param> /// <param name="label">Label reference</param> /// <param name="labelLine">Label line reference</param> /// <param name="unExplodedPoints">Unexploded points</param> /// <param name="explodedPoints">Exploded points</param> /// <param name="xOffset">X offset</param> /// <param name="yOffset">Y offset</param> /// <returns>Storyboard</returns> private static Storyboard CreateExplodingIn3DAnimation(DataSeries currentDataSeries, DataPoint dataPoint, Storyboard storyboard, List<Shape> pathElements, Panel label, Path labelLine, PieDoughnut3DPoints unExplodedPoints, PieDoughnut3DPoints explodedPoints, Double xOffset, Double yOffset) { DoubleCollection values; DoubleCollection frames; List<KeySpline> splines; #if WPF if (storyboard != null && storyboard.GetValue(System.Windows.Media.Animation.Storyboard.TargetProperty) != null) storyboard.Stop(); #else if (storyboard != null) storyboard.Stop(); #endif #region Animating Slice foreach (Shape path in pathElements) { if (path == null) continue; TranslateTransform translateTransform = path.RenderTransform as TranslateTransform; values = Graphics.GenerateDoubleCollection(xOffset, 0); frames = Graphics.GenerateDoubleCollection(0, 0.4); splines = AnimationHelper.GenerateKeySplineList ( new Point(0, 0), new Point(1, 1), new Point(0, 0), new Point(0, 1) ); DoubleAnimationUsingKeyFrames sliceXAnimation = CreateDoubleAnimation(currentDataSeries, dataPoint, translateTransform, "(TranslateTransform.X)", 0, frames, values, splines); values = Graphics.GenerateDoubleCollection(yOffset, 0); frames = Graphics.GenerateDoubleCollection(0, 0.4); splines = AnimationHelper.GenerateKeySplineList ( new Point(0, 0), new Point(1, 1), new Point(0, 0), new Point(0, 1) ); DoubleAnimationUsingKeyFrames sliceYAnimation = CreateDoubleAnimation(currentDataSeries, dataPoint, translateTransform, "(TranslateTransform.Y)", 0, frames, values, splines); storyboard.Children.Add(sliceXAnimation); storyboard.Children.Add(sliceYAnimation); } #endregion Animating Slice #region Animating Label if (dataPoint.LabelStyle == LabelStyles.Inside) { if (label != null) { TranslateTransform translateTransform = label.RenderTransform as TranslateTransform; values = Graphics.GenerateDoubleCollection(xOffset, 0); frames = Graphics.GenerateDoubleCollection(0, 0.4); splines = AnimationHelper.GenerateKeySplineList ( new Point(0, 0), new Point(1, 1), new Point(0, 0), new Point(0, 1) ); DoubleAnimationUsingKeyFrames labelXAnimation1 = CreateDoubleAnimation(currentDataSeries, dataPoint, translateTransform, "(TranslateTransform.X)", 0, frames, values, splines); values = Graphics.GenerateDoubleCollection(yOffset, 0); frames = Graphics.GenerateDoubleCollection(0, 0.4); splines = AnimationHelper.GenerateKeySplineList ( new Point(0, 0), new Point(1, 1), new Point(0, 0), new Point(0, 1) ); DoubleAnimationUsingKeyFrames labelYAnimation2 = CreateDoubleAnimation(currentDataSeries, dataPoint, translateTransform, "(TranslateTransform.Y)", 0, frames, values, splines); storyboard.Children.Add(labelXAnimation1); storyboard.Children.Add(labelYAnimation2); } } else { values = Graphics.GenerateDoubleCollection(explodedPoints.LabelPosition.X, unExplodedPoints.LabelPosition.X); frames = Graphics.GenerateDoubleCollection(0, 0.4); splines = AnimationHelper.GenerateKeySplineList ( new Point(0, 0), new Point(1, 1), new Point(0, 0), new Point(0, 1) ); DoubleAnimationUsingKeyFrames labelXAnimation = CreateDoubleAnimation(currentDataSeries, dataPoint, label, "(Canvas.Left)", 0, frames, values, splines); storyboard.Children.Add(labelXAnimation); } #endregion Animating Label #region Animating Label Line if (labelLine != null) { TranslateTransform translateTransform = labelLine.RenderTransform as TranslateTransform; values = Graphics.GenerateDoubleCollection(xOffset, 0); frames = Graphics.GenerateDoubleCollection(0, 0.4); splines = AnimationHelper.GenerateKeySplineList ( new Point(0, 0), new Point(1, 1), new Point(0, 0), new Point(0, 1) ); DoubleAnimationUsingKeyFrames sliceXAnimation = CreateDoubleAnimation(currentDataSeries, dataPoint, translateTransform, "(TranslateTransform.X)", 0, frames, values, splines); values = Graphics.GenerateDoubleCollection(yOffset, 0); frames = Graphics.GenerateDoubleCollection(0, 0.4); splines = AnimationHelper.GenerateKeySplineList ( new Point(0, 0), new Point(1, 1), new Point(0, 0), new Point(0, 1) ); DoubleAnimationUsingKeyFrames sliceYAnimation = CreateDoubleAnimation(currentDataSeries, dataPoint, translateTransform, "(TranslateTransform.Y)", 0, frames, values, splines); storyboard.Children.Add(sliceXAnimation); storyboard.Children.Add(sliceYAnimation); PathFigure figure = (labelLine.Data as PathGeometry).Figures[0]; PathSegmentCollection segments = figure.Segments; storyboard = CreateLabelLineInteractivityAnimation(currentDataSeries, dataPoint, storyboard, segments[0], explodedPoints.LabelLineMidPoint, unExplodedPoints.LabelLineMidPoint); storyboard = CreateLabelLineInteractivityAnimation(currentDataSeries, dataPoint, storyboard, segments[1], explodedPoints.LabelLineEndPoint, unExplodedPoints.LabelLineEndPoint); } #endregion Animating Label Line return storyboard; }
private void Button_Click_4(object sender, RoutedEventArgs e) { storyboard.Stop(); }