internal void ShowPopup(NPopupNotify popup) { PopupAnimation animation = PopupAnimation.None; if (m_FadeCheck.Checked) { animation |= PopupAnimation.Fade; } if (m_SlideCheck.Checked) { animation |= PopupAnimation.Slide; } popup.AutoHide = m_AutoHideCheck.Checked; popup.VisibleSpan = (int)m_VisibleSpanNumeric.Value; popup.Opacity = (int)m_OpacityNumeric.Value; popup.Animation = animation; popup.AnimationDirection = (PopupAnimationDirection)animationDirectionCombo.SelectedItem; popup.VisibleOnMouseOver = m_StayVisibleCheck.Checked; popup.FullOpacityOnMouseOver = m_FullOpacityCheck.Checked; popup.AnimationInterval = (int)m_IntervalNumeric.Value; popup.AnimationSteps = (int)m_StepsNumeric.Value; popup.Palette.Copy(NUIManager.Palette); popup.Show(); }
// Token: 0x06005F37 RID: 24375 RVA: 0x001AB2C0 File Offset: 0x001A94C0 internal void SetupTranslateAnimations(PopupAnimation animationType, Duration duration, bool animateFromRight, bool animateFromBottom) { UIElement child = this.Child; if (child == null) { return; } TranslateTransform translateTransform = this._adornerDecorator.RenderTransform as TranslateTransform; if (translateTransform == null) { translateTransform = new TranslateTransform(); this._adornerDecorator.RenderTransform = translateTransform; } if (animationType == PopupAnimation.Scroll) { FlowDirection flowDirection = (FlowDirection)child.GetValue(FrameworkElement.FlowDirectionProperty); FlowDirection flowDirection2 = base.FlowDirection; if (flowDirection != flowDirection2) { animateFromRight = !animateFromRight; } double width = this._adornerDecorator.RenderSize.Width; DoubleAnimation animation = new DoubleAnimation(animateFromRight ? width : (-width), 0.0, duration, FillBehavior.Stop); translateTransform.BeginAnimation(TranslateTransform.XProperty, animation); } double height = this._adornerDecorator.RenderSize.Height; DoubleAnimation animation2 = new DoubleAnimation(animateFromBottom ? height : (-height), 0.0, duration, FillBehavior.Stop); translateTransform.BeginAnimation(TranslateTransform.YProperty, animation2); }
public void ShowBalloonTip(UIElement rootModel, PopupAnimation animation, int timeout = 4000) { if (TaskbarTrayIcon != null) { TaskbarTrayIcon.ShowCustomBalloon(rootModel, animation, timeout); } }
public void ShowBalloonTip(object rootModel, PopupAnimation animation, TimeSpan?timeout = null) { var view = ViewLocator.LocateForModel(rootModel, null, null); ViewModelBinder.Bind(rootModel, view, null); icon.ShowCustomBalloon(view, animation, timeout.HasValue ? (int)timeout.Value.TotalMilliseconds : (int?)null); }
public static void SetPopupAnimation(DependencyObject d, PopupAnimation value) { if (d == null) { throw new ArgumentNullException(nameof(d)); } d.SetValue(PopupAnimationProperty, value); }
public PopupSettings(TimeSpan duration, double overlayToControlRatio, double overlayOpacity, PopupAnimation animation, bool overlayDismissal) { AnimationDuration = duration; OverlayOpacity = overlayOpacity; OverlayToControlAnimationRatio = overlayToControlRatio; Animation = animation; OverlayDismissal = overlayDismissal; }
/// <summary> /// Show a custom balloon (ViewModel first), using the specified animation. /// After the timeout, the balloon is removed. /// </summary> /// <typeparam name="TViewModel">Type for the ViewModel to show</typeparam> /// <param name="viewModel">instance of your ViewModel</param> /// <param name="animation">PopupAnimation</param> /// <param name="timeout">TimeSpan</param> public void ShowBalloonTip <TViewModel>(TViewModel viewModel, PopupAnimation animation = PopupAnimation.Scroll, TimeSpan?timeout = default) where TViewModel : class { var view = ViewLocator.LocateForModel(viewModel, null, null); ViewModelBinder.Bind(viewModel, view, null); ShowCustomBalloon(view, animation, timeout.HasValue ? (int)timeout.Value.TotalMilliseconds : (int)TimeSpan.FromSeconds(4).TotalMilliseconds); }
public void ShowBalloonTip <T>(PopupAnimation animation, TimeSpan?timeout = default(TimeSpan?)) { var rootModel = IoC.Get <T>(); var view = ViewLocator.LocateForModel(rootModel, null, null); ViewModelBinder.Bind(rootModel, view, null); ShowCustomBalloon(view, animation, timeout.HasValue ? (int)timeout.Value.TotalMilliseconds : (int?)null); }
/// <summary> /// This is used for windows transition animation when new current screen is getting removed. /// </summary> /// <param name="target">Target.</param> public static bool OnWindowRemove(this GameObject target) { PopupAnimation transition = target.GetComponent <PopupAnimation> (); if (transition != null) { transition.OnWindowRemove(); return(true); } return(false); }
/// <summary> /// Shows the notification. /// </summary> /// <param name="text">The text.</param> /// <param name="popupAnimation">The popup animation.</param> /// <param name="timeout">The timeout.</param> public void ShowNotification(string text, PopupAnimation popupAnimation, int timeout) { if (this.CheckAccess()) { this.notificationBoxProvider.ShowNotification(text, popupAnimation, timeout); } else { this.Dispatcher.BeginInvoke(new Action <string, PopupAnimation, int>(this.ShowNotification), new object[] { text, popupAnimation, timeout }); } }
private void CreateFencePiece(Vector3 startPos, Vector3 endPos) { float yRot = GetYRotation(startPos, endPos); GameObject g = (GameObject)Instantiate(wallObject, startPos, Quaternion.Euler(new Vector3(0, (yRot + 90) + 180, 0))); g.transform.localScale = new Vector3(Vector3.Distance(startPos, endPos), g.transform.localScale.y, g.transform.localScale.z); if (animate) { PopupAnimation pA = g.AddComponent <PopupAnimation>(); pA.SetInitialScales(g.transform.localScale, 0); } }
/// <summary> /// Main constructor /// </summary> /// <param name="headerNotify">The header of notification</param> /// <param name="mainNotify">Main text of notification</param> /// <param name="countTicket">Count tickets that have searched</param> /// <param name="animation"></param> /// <param name="timeout"></param> public Notify(string headerNotify, List<MessageArgs> ListArgs, PopupAnimation animation = PopupAnimation.Slide, int? timeout = 5000) { HeaderNotify = headerNotify; foreach (var args in ListArgs) { MainTextNotify = "You have new ticket!" + Environment.NewLine + "From: " + args.From + " To " + args.To + Environment.NewLine + "Date: " + args.Date + Environment.NewLine + "Number place: " + args.PlacesCount + " | " + "Train number: " + args.TrainNumber + Environment.NewLine; } AnimationNotify = animation; Timeout = timeout; }
protected virtual Popup GetToastPopup(FrameworkElement content) { return(new Popup { Visibility = Visibility.Visible, #if WPF AllowsTransparency = true, Placement = PlacementMode.Relative, Child = new Border { Background = Brushes.Transparent, Child = content }, PopupAnimation = PopupAnimation #else Child = content #endif });
internal void SetupTranslateAnimations(PopupAnimation animationType, Duration duration, bool animateFromRight, bool animateFromBottom) { var child = Child; if (child == null) { return; } var renderTransform = _adornerDecorator.RenderTransform as TranslateTransform; if (renderTransform == null) { renderTransform = new TranslateTransform(); _adornerDecorator.RenderTransform = renderTransform; } if (animationType == PopupAnimation.Scroll) { var direction = (FlowDirection)child.GetValue(FlowDirectionProperty); var flowDirection = FlowDirection; if (direction != flowDirection) { animateFromRight = !animateFromRight; } var width = _adornerDecorator.RenderSize.Width; var horizontalAnimation = new DoubleAnimation( animateFromRight ? width : -width, 0.0, duration, FillBehavior.Stop); renderTransform.BeginAnimation(TranslateTransform.XProperty, horizontalAnimation); } var height = _adornerDecorator.RenderSize.Height; var verticalAnimation = new DoubleAnimation( animateFromBottom ? height : -height, 0.0, duration, FillBehavior.Stop); renderTransform.BeginAnimation(TranslateTransform.YProperty, verticalAnimation); }
public void StartPopup(int value) { if (null != mPopupValueLab) { mPopupValueLab.text = value.ToString(); } if (null != PopupAnimation) { Duration = PopupAnimation.clip.length; PopupAnimation.Play(); } if (null != Owner.TopNode) { SetPopupPos(Owner.TopNode.position); } }
/// <summary> /// 初始化生成 /// </summary> /// <param name="popupAnimation">动画</param> /// <param name="tittle">标题</param> private void ParamesInit(PopupAnimation popupAnimation, string tittle) { try { //生成标题 this.txtTittle.Text = tittle; TaskbarIcon.AddBalloonClosingHandler(this, OnBalloonClosing); TaskbarIcon MyNotifyIcon = new TaskbarIcon(); MyNotifyIcon.ShowCustomBalloon(this, popupAnimation, 60000); } catch (Exception ex) { MethodLb.CreateLog(this.GetType().FullName, "ParamesInit", ex.ToString(), popupAnimation, tittle); } finally { } }
public void ShowSnapPane(bool animate = true) { if (m_ConnectTask == null) { return; } if (m_ConnectTask.Status == TaskStatus.Running || m_ConnectTask.Status == TaskStatus.WaitingForActivation) { // wait for it to complete... Task.Run(async() => { while (m_ConnectTask.Status == TaskStatus.Running || m_ConnectTask.Status == TaskStatus.WaitingForActivation) { await Task.Delay(10); } await Current.Dispatcher.BeginInvoke(new Action <bool>(ShowSnapPane), animate); }).ConfigureAwait(false); return; } if (m_SnapcastClient.ServerData == null) { ShowNotification("Connection error", string.Format("Unable to connect to snapserver at {0}:{1}", SnapSettings.Server, SnapSettings.ControlPort)); return; } if (TaskbarIcon.CustomBalloon == null || TaskbarIcon.CustomBalloon.IsOpen == false) { Hardcodet.Wpf.TaskbarNotification.Interop.Point origin = TaskbarIcon.GetPopupTrayPosition(); origin.Y += 9; // spawn it as close to the taskbar as we can TaskbarIcon.CustomPopupPosition = () => { return(origin); }; SnapControl.SnapControl sc = new SnapControl.SnapControl(origin, m_SnapcastClient); PopupAnimation animation = animate ? PopupAnimation.Slide : PopupAnimation.None; TaskbarIcon.ShowCustomBalloon(sc, animation, null); } else { TaskbarIcon.CloseBalloon(); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="popupAnimation">弹出的动画方式</param> /// <param name="tittle">标题</param> /// <param name="element">要盛放的元素</param> public TongZhi(string tittle, FrameworkElement element, PopupAnimation popupAnimation) { try { InitializeComponent(); //生成通知 ParamesInit(popupAnimation, tittle); //把资源清除 this.borMain.Resources.Clear(); this.borMain.Child = element; } catch (Exception ex) { MethodLb.CreateLog(this.GetType().FullName, "TongZhi", ex.ToString(), tittle, element, popupAnimation); } finally { } }
public void Initialize(UISlider _slExp, UILabel _lbLevel, UILabel _lbAto, UILabel _lbMade, PopupAnimation _popupAnimation) { m_slExp = _slExp; m_lbLevel = _lbLevel; m_lbAto = _lbAto; m_lbMade = _lbMade; m_PopupAnimation = _popupAnimation; m_iTotalExp = GameMain.dbKvs.ReadInt(Define.USER_TOTAL_EXP); foreach (CsvLevelData level_data in DataManager.csv_level) { if (m_iTotalExp < level_data.need_exp) { break; } m_iLevel = level_data.level; } GameMain.dbKvs.WriteInt(Define.USER_LEVEL, m_iLevel); //m_iLevel = GameMain.dbKvs.ReadInt (Define.USER_LEVEL); m_iTotalExpTarget = GameMain.dbKvs.ReadInt(Define.USER_TOTAL_EXP); SetExp(m_iLevel, out m_iLevelExpNow, out m_iLevelExpNext); m_lbLevel.text = "Lv." + m_iLevel.ToString(); m_fValue = Define.GetValue(m_iTotalExp, m_iLevelExpNow, m_iLevelExpNext); m_slExp.value = m_fValue; m_lbAto.text = (m_iLevelExpNext - m_iTotalExp).ToString(); if (m_iLevel == Define.USER_LEVEL_MAX) { m_lbAto.text = "[FF0000]MAX[-]"; m_lbAto.transform.localPosition = new Vector3(m_lbAto.transform.localPosition.x, 37.0f, m_lbAto.transform.localPosition.z); m_lbMade.text = ""; } m_eStep = STEP.IDLE; m_eStepPre = STEP.MAX; return; }
/// <summary> /// 构造函数 /// </summary> /// <param name="popupAnimation">弹出的动画方式</param> /// <param name="tittle">标题</param> /// <param name="content">显示内容</param> public TongZhi(string tittle, string content, PopupAnimation popupAnimation) { try { InitializeComponent(); //生成通知 ParamesInit(popupAnimation, tittle); //指定通知内容 this.borMain.Child = new TextBlock() { Text = content }; } catch (Exception ex) { MethodLb.CreateLog(this.GetType().FullName, "TongZhi", ex.ToString(), tittle, content, popupAnimation); } finally { } }
// Popup is transparent, we can leave popup size alone // and animate the translation of the popup internal void SetupTranslateAnimations(PopupAnimation animationType, Duration duration, bool animateFromRight, bool animateFromBottom) { UIElement child = Child; if (child == null) { return; } TranslateTransform transform = _adornerDecorator.RenderTransform as TranslateTransform; if (transform == null) { transform = new TranslateTransform(); _adornerDecorator.RenderTransform = transform; } if (animationType == PopupAnimation.Scroll) { // If the flow direction of the child is different than ours, animate in opposite direction FlowDirection childFlowDirection = (FlowDirection)child.GetValue(FlowDirectionProperty); FlowDirection thisFlowDirection = FlowDirection; if (childFlowDirection != thisFlowDirection) { animateFromRight = !animateFromRight; } double width = _adornerDecorator.RenderSize.Width; DoubleAnimation xAnim = new DoubleAnimation(animateFromRight ? width : -width, 0.0, duration, FillBehavior.Stop); transform.BeginAnimation(TranslateTransform.XProperty, xAnim); } double height = _adornerDecorator.RenderSize.Height; DoubleAnimation yAnim = new DoubleAnimation(animateFromBottom ? height : -height, 0.0, duration, FillBehavior.Stop); transform.BeginAnimation(TranslateTransform.YProperty, yAnim); }
// TODO: If node at pathpoint and to pathpoint are blocked ignore spawning private void PathDone() { if (pathPoints.Count < 2) { return; } for (int i = 0; i < pathPoints.Count - 1; i++) { float yRot = GetYRotation(pathPoints[i], pathPoints[i + 1]); GameObject g = (GameObject)Instantiate(wallObject, pathPoints[i], Quaternion.Euler(new Vector3(0, (yRot + 90) + 180, 0))); g.transform.localScale = new Vector3(Vector3.Distance(pathPoints[i], pathPoints[i + 1]), 1, 1); if (animate) { PopupAnimation pA = g.AddComponent <PopupAnimation>(); pA.SetInitialScales(g.transform.localScale, i); } } for (int i = 1; i < pathPoints.Count; i++) { Wall wall = new Wall(); foreach (TileNode n in worldController._grid) { n.SetWall(worldController.GetAnchorFromPos(pathPoints[i - 1]), worldController.GetAnchorFromPos(pathPoints[i]), wall); } } foreach (AnchorNode a in worldController._anchors) { a.SetAnchorState(AnchorState.None); } pathPoints.Clear(); startPos = Vector3.zero; nextPos = Vector3.zero; canBuild = true; }
/// <summary> /// Shows the notification. /// </summary> /// <param name="text">The text.</param> /// <param name="popupAnimation">The popup animation.</param> /// <param name="timeout">The timeout.</param> public void ShowNotification(string text, PopupAnimation popupAnimation, int timeout) { this.balloonTextList.Add(text); this.balloon = new Balloon(); foreach (var ballonText in this.balloonTextList) { // ReSharper disable LocalizableElement if (string.IsNullOrEmpty(this.balloon.BalloonText)) { this.balloon.BalloonText = " - " + ballonText; } else { this.balloon.BalloonText = this.balloon.BalloonText + "\n - " + ballonText; } // ReSharper restore LocalizableElement } this.t1.Enabled = false; this.tb.ShowCustomBalloon(this.balloon, popupAnimation, timeout); this.t1.Interval = timeout; this.t1.Enabled = true; }
/// <summary> /// Shows a custom control as a tooltip in the tray location. /// </summary> /// <param name="balloon"></param> /// <param name="animation">An optional animation for the popup.</param> /// <param name="timeout">The time after which the popup is being closed. /// Submit null in order to keep the balloon open inde /// </param> /// <exception cref="ArgumentNullException">If <paramref name="balloon"/> /// is a null reference.</exception> public void ShowCustomBalloon(UIElement balloon, PopupAnimation animation, int? timeout) { Dispatcher dispatcher = this.GetDispatcher(); if (!dispatcher.CheckAccess()) { var action = new Action(() => ShowCustomBalloon(balloon, animation, timeout)); dispatcher.Invoke(DispatcherPriority.Normal, action); return; } if (balloon == null) throw new ArgumentNullException("balloon"); if (timeout.HasValue && timeout < 500) { string msg = "Invalid timeout of {0} milliseconds. Timeout must be at least 500 ms"; msg = String.Format(msg, timeout); throw new ArgumentOutOfRangeException("timeout", msg); } EnsureNotDisposed(); //make sure we don't have an open balloon lock (this) { CloseBalloon(); } //create an invisible popup that hosts the UIElement Popup popup = new Popup(); popup.AllowsTransparency = true; //provide the popup with the taskbar icon's data context UpdateDataContext(popup, null, DataContext); //don't animate by default - devs can use attached //events or override popup.PopupAnimation = animation; popup.Child = balloon; //don't set the PlacementTarget as it causes the popup to become hidden if the //TaskbarIcon's parent is hidden, too... //popup.PlacementTarget = this; popup.Placement = PlacementMode.AbsolutePoint; popup.StaysOpen = true; Point position = TrayInfo.GetTrayLocation(); popup.HorizontalOffset = position.X -1; popup.VerticalOffset = position.Y -1; //store reference lock (this) { SetCustomBalloon(popup); } //assign this instance as an attached property SetParentTaskbarIcon(balloon, this); //fire attached event RaiseBalloonShowingEvent(balloon, this); //display item popup.IsOpen = true; if (timeout.HasValue) { //register timer to close the popup balloonCloseTimer.Change(timeout.Value, Timeout.Infinite); } }
/// <summary> /// Shows a custom control as a tooltip in the tray location. /// </summary> /// <param name="balloon"></param> /// <param name="animation">An optional animation for the popup.</param> /// <param name="timeout">The time after which the popup is being closed. /// Submit null in order to keep the balloon open inde /// </param> /// <exception cref="ArgumentNullException">If <paramref name="balloon"/> /// is a null reference.</exception> public void ShowCustomBalloon(UIElement balloon, PopupAnimation animation, int?timeout) { Dispatcher dispatcher = this.GetDispatcher(); if (!dispatcher.CheckAccess()) { dispatcher.InvokeAsync( (() => ShowCustomBalloon(balloon, animation, timeout)), DispatcherPriority.Normal ); return; } if (balloon == null) { throw new ArgumentNullException("balloon"); } if (timeout.HasValue && timeout < 500) { throw new ArgumentOutOfRangeException("timeout", string.Format("Invalid timeout of {0} milliseconds. Timeout must be at least 500 ms", timeout)); } if (this.IsDisposed) { throw new ObjectDisposedException(this.Name ?? this.GetType().Name); } //make sure we don't have an open balloon lock (this.SyncLock) { CloseBalloon(); } // create an invisible popup that hosts the UIElement Popup popup = new Popup { AllowsTransparency = true }; //provide the popup with the taskbar icon's data context UpdateDataContext(popup, null, DataContext); //don't animate by default - devs can use attached events or override popup.PopupAnimation = animation; //in case the balloon is cleaned up through routed events, the //control didn't remove the balloon from its parent popup when //if was closed the last time - just make sure it doesn't have //a parent that is a popup var parent = LogicalTreeHelper.GetParent(balloon) as Popup; if (parent != null) { parent.Child = null; } if (parent != null) { string msg = "Cannot display control [{0}] in a new balloon popup - that control already has a parent. You may consider creating new balloons every time you want to show one."; msg = String.Format(msg, balloon); throw new InvalidOperationException(msg); } popup.Child = balloon; //don't set the PlacementTarget as it causes the popup to become hidden if the //TaskbarIcon's parent is hidden, too... //popup.PlacementTarget = this; popup.Placement = PlacementMode.AbsolutePoint; popup.StaysOpen = true; Point position = TrayInfo.GetTrayLocation(); position = GetDeviceCoordinates(position); popup.HorizontalOffset = position.X - 1; popup.VerticalOffset = position.Y - 1; //store reference lock (this.SyncLock) { SetCustomBalloon(popup); } //assign this instance as an attached property SetParentTaskbarIcon(balloon, this); //fire attached event RaiseBalloonShowingEvent(balloon, this); //display item popup.IsOpen = true; if (timeout.HasValue) { //register timer to close the popup balloonCloseTimer.Change(timeout.Value, Timeout.Infinite); } }
public static bool IsFlagOn(this PopupAnimation value, PopupAnimation flag) { return (value & flag) == flag; }
public NotificationArgs( CKNotification content, PopupAnimation animation, int? duration ) { Content = content; Animation = animation; Duration = duration; }
/// <summary> /// Shows a custom control as a tooltip in the tray location. /// </summary> /// <param name="balloon"></param> /// <param name="animation">An optional animation for the popup.</param> /// <param name="timeout">The time after which the popup is being closed. /// Submit null in order to keep the balloon open inde /// </param> /// <exception cref="ArgumentNullException">If <paramref name="balloon"/> /// is a null reference.</exception> public void ShowCustomBalloon(UIElement balloon, PopupAnimation animation, int?timeout) { if (!Application.Current.Dispatcher.CheckAccess()) { var action = new Action(() => ShowCustomBalloon(balloon, animation, timeout)); Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, action); return; } if (balloon == null) { throw new ArgumentNullException("balloon"); } if (timeout.HasValue && timeout < 500) { string msg = "Invalid timeout of {0} milliseconds. Timeout must be at least 500 ms"; msg = String.Format(msg, timeout); throw new ArgumentOutOfRangeException("timeout", msg); } EnsureNotDisposed(); //make sure we don't have an open balloon lock (this) { CloseBalloon(); } //create an invisible popup that hosts the UIElement Popup popup = new Popup(); popup.AllowsTransparency = true; //provide the popup with the taskbar icon's data context UpdateDataContext(popup, null, DataContext); //don't animate by default - devs can use attached //events or override popup.PopupAnimation = animation; popup.Child = balloon; //don't set the PlacementTarget as it causes the popup to become hidden if the //TaskbarIcon's parent is hidden, too... //popup.PlacementTarget = this; popup.Placement = PlacementMode.AbsolutePoint; popup.StaysOpen = true; Point position = TrayInfo.GetTrayLocation(); popup.HorizontalOffset = position.X - 1; popup.VerticalOffset = position.Y - 1; //store reference lock (this) { SetCustomBalloon(popup); } //assign this instance as an attached property SetParentTaskbarIcon(balloon, this); //fire attached event RaiseBalloonShowingEvent(balloon, this); //display item popup.IsOpen = true; if (timeout.HasValue) { //register timer to close the popup balloonCloseTimer.Change(timeout.Value, Timeout.Infinite); } return; }
/// <summary> /// Constructor /// </summary> /// <param name="balloon">Balloon control</param> /// <param name="timeout">Timeout in ms</param> /// <param name="animation">Animation <see cref="PopupAnimation"/></param> public ShowNotificationPopUpMessage(UIElement balloon, int timeout = 5000, PopupAnimation animation = PopupAnimation.Fade) { Balloon = balloon; Timeout = timeout; Animation = animation; }
/// <summary> /// Shows a custom control as a tooltip in the tray location. /// </summary> /// <param name="key">a unique key to identify this balloon.</param> /// <param name="balloon"></param> /// <param name="animation">An optional animation for the popup.</param> /// <param name="timeout">The time after which the popup is being closed. /// Submit null in order to keep the balloon open inde /// </param> /// <exception cref="ArgumentNullException">If <paramref name="balloon"/> /// is a null reference.</exception> public void ShowCustomBalloon(object key, FrameworkElement balloon, PopupAnimation animation, int? timeout) { if (key == null) { throw new ArgumentNullException("key"); } Dispatcher dispatcher = this.GetDispatcher(); if (!dispatcher.CheckAccess()) { var action = new Action(() => ShowCustomBalloon(key, balloon, animation, timeout)); dispatcher.Invoke(DispatcherPriority.Normal, action); return; } if (balloon == null) throw new ArgumentNullException("balloon"); if (timeout.HasValue && timeout < 500) { string msg = "Invalid timeout of {0} milliseconds. Timeout must be at least 500 ms"; msg = String.Format(msg, timeout); throw new ArgumentOutOfRangeException("timeout", msg); } EnsureNotDisposed(); //create an invisible popup that hosts the UIElement var popup = new Popup(); popup.Tag = key; popup.AllowsTransparency = true; //provide the popup with the taskbar icon's data context UpdateDataContext(popup, null, DataContext); //don't animate by default - devs can use attached //events or override popup.PopupAnimation = animation; popup.Child = balloon; //don't set the PlacementTarget as it causes the popup to become hidden if the //TaskbarIcon's parent is hidden, too... //popup.PlacementTarget = this; popup.Placement = PlacementMode.AbsolutePoint; popup.StaysOpen = true; //store reference lock (this) { PositionPopup(popup); var info = new CustomBalloonInfo { Key = key, Popup = popup }; if (timeout.HasValue) { info.CloseTimer = new Timer(CloseBalloonCallback, key, timeout.Value, Timeout.Infinite); } CustomBalloons.Add(info); } //assign this instance as an attached property SetParentTaskbarIcon(balloon, this); //fire attached event RaiseBalloonShowingEvent(balloon, this); //display item popup.IsOpen = true; }
// Popup is transparent, we can leave popup size alone // and animate the translation of the popup internal void SetupTranslateAnimations(PopupAnimation animationType, Duration duration, bool animateFromRight, bool animateFromBottom) { UIElement child = Child; if (child == null) return; TranslateTransform transform = _adornerDecorator.RenderTransform as TranslateTransform; if (transform == null) { transform = new TranslateTransform(); _adornerDecorator.RenderTransform = transform; } if (animationType == PopupAnimation.Scroll) { // If the flow direction of the child is different than ours, animate in opposite direction FlowDirection childFlowDirection = (FlowDirection)child.GetValue(FlowDirectionProperty); FlowDirection thisFlowDirection = FlowDirection; if (childFlowDirection != thisFlowDirection) { animateFromRight = !animateFromRight; } double width = _adornerDecorator.RenderSize.Width; DoubleAnimation xAnim = new DoubleAnimation(animateFromRight ? width : -width, 0.0, duration, FillBehavior.Stop); transform.BeginAnimation(TranslateTransform.XProperty, xAnim); } double height = _adornerDecorator.RenderSize.Height; DoubleAnimation yAnim = new DoubleAnimation(animateFromBottom ? height : -height, 0.0, duration, FillBehavior.Stop); transform.BeginAnimation(TranslateTransform.YProperty, yAnim); }
public PopupAnimationBuilder(PopupAnimation animation) { Animation = animation; }
public WindowSettingsBuilder WithPopupAnimation(PopupAnimation popupAnimation) { settings.PopupAnimation = popupAnimation; return(this); }
public void ShowCustomBalloon(string title, string message, BalloonIcon symbol = BalloonIcon.Info, PopupAnimation animation = PopupAnimation.Fade, int?timeout = 3000) { var baloon = new Balloon() { Title = title, Description = message, Icon = symbol }; _taskbarIcon.ShowCustomBalloon(baloon, animation, timeout); }
public void ShowCustomBalloon(PopupAnimation animation, int?timeout, UIElement balloon) { _taskbarIcon.ShowCustomBalloon(balloon, animation, timeout); }
/// <summary> /// Show a custom balloon (ViewModel first), using the specified animation. /// After the timeout, the balloon is removed. /// </summary> /// <typeparam name="TViewModel">Type for the ViewModel to show</typeparam> /// <param name="animation">PopupAnimation</param> /// <param name="timeout">TimeSpan</param> public void ShowBalloonTip <TViewModel>(PopupAnimation animation = PopupAnimation.Scroll, TimeSpan?timeout = default) where TViewModel : class { var viewModel = IoC.Get <TViewModel>(); ShowBalloonTip(viewModel, animation, timeout); }
/// <summary> /// Shows a custom control as a tooltip in the tray location. /// </summary> /// <param name="balloon"></param> /// <param name="animation">An optional animation for the popup.</param> /// <param name="timeout">The time after which the popup is being closed. /// Submit null in order to keep the balloon open inde /// </param> /// <exception cref="ArgumentNullException">If <paramref name="balloon"/> /// is a null reference.</exception> public void ShowCustomBalloon(UIElement balloon, PopupAnimation animation, int? timeout) { Dispatcher dispatcher = this.GetDispatcher(); if (!dispatcher.CheckAccess()) { var action = new Action(() => ShowCustomBalloon(balloon, animation, timeout)); dispatcher.Invoke(DispatcherPriority.Normal, action); return; } if (balloon == null) throw new ArgumentNullException("balloon"); if (timeout.HasValue && timeout < 500) { string msg = "Invalid timeout of {0} milliseconds. Timeout must be at least 500 ms"; msg = String.Format(msg, timeout); throw new ArgumentOutOfRangeException("timeout", msg); } EnsureNotDisposed(); //make sure we don't have an open balloon lock (this) { CloseBalloon(); } //create an invisible popup that hosts the UIElement Popup popup = new Popup(); popup.AllowsTransparency = true; //provide the popup with the taskbar icon's data context UpdateDataContext(popup, null, DataContext); //don't animate by default - devs can use attached //events or override popup.PopupAnimation = animation; //in case the balloon is cleaned up through routed events, the //control didn't remove the balloon from its parent popup when //if was closed the last time - just make sure it doesn't have //a parent that is a popup var parent = LogicalTreeHelper.GetParent(balloon) as Popup; if (parent != null) parent.Child = null; if (parent != null) { string msg = "Cannot display control [{0}] in a new balloon popup - that control already has a parent. You may consider creating new balloons every time you want to show one."; msg = String.Format(msg, balloon); throw new InvalidOperationException(msg); } popup.Child = balloon; //don't set the PlacementTarget as it causes the popup to become hidden if the //TaskbarIcon's parent is hidden, too... //popup.PlacementTarget = this; popup.Placement = PlacementMode.AbsolutePoint; popup.StaysOpen = true; Point position = TrayInfo.GetTrayLocation(); position = GetDeviceCoordinates(position); popup.HorizontalOffset = position.X - 1; popup.VerticalOffset = position.Y - 1; //store reference lock (this) { SetCustomBalloon(popup); } //assign this instance as an attached property SetParentTaskbarIcon(balloon, this); //fire attached event RaiseBalloonShowingEvent(balloon, this); //display item popup.IsOpen = true; if (timeout.HasValue) { //register timer to close the popup balloonCloseTimer.Change(timeout.Value, Timeout.Infinite); } }
/// <summary> /// Shows a custom balloon popup/notification on the taskbar icon. /// Used to alert the user e.g. "your check status just changed." /// </summary> public void ShowBalloonNotification(UIElement popup, PopupAnimation animation = PopupAnimation.Slide, int?timeoutMilliseconds = 4000) { tb.ShowCustomBalloon(popup, animation, timeoutMilliseconds); }