Beispiel #1
0
        /// <summary>
        ///     Handles the Closed event of the fancyBalloon control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void fancyBalloon_Closed(object sender, EventArgs e)
        {
            var fancyBalloon = sender as FancyBalloon;

            if (fancyBalloon != null)
            {
                fancyBalloon.Closed -= fancyBalloon_Closed;
            }

            if (NextViewModel != null)
            {
                var balloon = new FancyBalloon
                {
                    DataContext = NextViewModel,
                    EventLog    = Settings.EventLog
                };

                long id;

                if (long.TryParse(NextViewModel.EntityId, out id))
                {
                    FancyBalloon.CurrentEntityId = id;
                }

                NextViewModel = null;

                _notifyIcon.ShowCustomBalloon(balloon, PopupAnimation.Scroll, _balloonTimeout);
            }
        }
Beispiel #2
0
        /// <summary>
        ///     Shows the balloon.
        /// </summary>
        /// <param name="entityMessage">The entity message.</param>
        /// <returns></returns>
        private bool ShowBalloon(EntityBrowserMessage entityMessage)
        {
            lock ( _syncRoot )
            {
                var entityBrowserViewModel = _userInterface.DataContext as EntityBrowserViewModel;

                if (entityBrowserViewModel != null)
                {
                    long   id;
                    long   tenantId;
                    Guid   upgradeId;
                    string name;
                    string description;
                    string tenant;
                    string solution;
                    string type;

                    if (entityBrowserViewModel.GetEntityDetails(entityMessage.Entity, out id, out tenantId, out upgradeId, out name, out description, out tenant, out solution, out type))
                    {
                        if (FancyBalloon.CurrentEntityId == id)
                        {
                            return(true);
                        }

                        FancyBalloon fancyBalloon = null;

                        if (_notifyIcon.CustomBalloon != null && _notifyIcon.CustomBalloon.Child != null)
                        {
                            fancyBalloon = _notifyIcon.CustomBalloon.Child as FancyBalloon;
                        }

                        FancyBalloon.CurrentEntityId = id;

                        var viewModel = new FancyBalloonViewModel
                        {
                            BalloonTitle = "ReadiMon Entity detected...",
                            EntityId     = id.ToString(CultureInfo.InvariantCulture),
                            TenantId     = entityBrowserViewModel.GetTenantName(tenantId),
                            UpgradeId    = upgradeId.ToString("B"),
                            Name         = name,
                            Description  = description,
                            Tenant       = tenant,
                            Solution     = solution,
                            Type         = type
                        };

                        viewModel.ShowEntity += viewModel_ShowEntity;

                        if (fancyBalloon != null)
                        {
                            NextViewModel = viewModel;

                            fancyBalloon.Closed += fancyBalloon_Closed;

                            _notifyIcon.CloseBalloon( );

                            return(true);
                        }

                        var balloon = new FancyBalloon
                        {
                            DataContext = viewModel,
                            EventLog    = Settings.EventLog
                        };

                        _notifyIcon.ShowCustomBalloon(balloon, PopupAnimation.Scroll, _balloonTimeout);

                        return(true);
                    }
                }
            }

            return(false);
        }