コード例 #1
0
        private void SendBadge_Click(object sender, RoutedEventArgs e)
        {
            BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(6);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification());
            rootPage.NotifyUser("Badge notification sent", NotifyType.StatusMessage);
        }
コード例 #2
0
ファイル: ScenarioElement.xaml.cs プロジェクト: ice0/test
        private async void ButtonPinSecondaryTile_Click(object sender, RoutedEventArgs e)
        {
            _tileId = "ScenarioBadgeControl";

            SecondaryTile tile = new SecondaryTile(_tileId, "Name 1", "args", new Uri("ms-appx:///Assets/DefaultSecondaryTileAssests/Medium.png"), TileSize.Default);

            tile.VisualElements.Square71x71Logo             = new Uri("ms-appx:///Assets/DefaultSecondaryTileAssests/Small.png");
            tile.VisualElements.Wide310x150Logo             = new Uri("ms-appx:///Assets/DefaultSecondaryTileAssests/Wide.png");
            tile.VisualElements.Square310x310Logo           = new Uri("ms-appx:///Assets/DefaultSecondaryTileAssests/Large.png");
            tile.VisualElements.ShowNameOnSquare150x150Logo = true;
            tile.VisualElements.ShowNameOnSquare310x310Logo = true;
            tile.VisualElements.ShowNameOnWide310x150Logo   = true;
            await tile.RequestCreateAsync();

            //Prepare for next Step:

            // Pop all the notifications
            ToastHelper.PopToast("Toast 1", "Content of Toast 1");
            ToastHelper.PopToast("Toast 2", "Content of Toast 2");
            ToastHelper.PopToast("Toast 3", "Content of Toast 3");

            //Update badge
            IReadOnlyList <ToastNotification> TNList = ToastNotificationManager.History.GetHistory();

            BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent((uint)TNList.Count);

            // Send the notification to the application’s tile.
            BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(_tileId).Update(badgeContent.CreateNotification());

            // Move the UI to the next step
            stepsControl.Step++;
            stepsControl.NextButtonVisibility = Visibility.Collapsed;
        }
コード例 #3
0
        private async void CreateBadgeTile_Click(object sender, RoutedEventArgs e)
        {
            if (!SecondaryTile.Exists(BADGE_TILE_ID))
            {
                SecondaryTile secondTile = new SecondaryTile(
                    BADGE_TILE_ID,
                    "LockScreen CS - Badge only",
                    "BADGE_ARGS",
                    new Uri("ms-appx:///Assets/squareTile-sdk.png"),
                    TileSize.Square150x150
                    );
                secondTile.LockScreenBadgeLogo = new Uri("ms-appx:///Assets/badgelogo-sdk.png");

                bool isPinned = await secondTile.RequestCreateForSelectionAsync(GetElementRect((FrameworkElement)sender), Placement.Above);

                if (isPinned)
                {
                    BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(2);
                    BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(BADGE_TILE_ID).Update(new BadgeNotification(badgeContent.GetXml()));
                    rootPage.NotifyUser("Secondary tile created and badge updated. Go to PC settings to add it to the lock screen.", NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser("Tile not created.", NotifyType.ErrorMessage);
                }
            }
            else
            {
                rootPage.NotifyUser("Badge secondary tile already exists.", NotifyType.ErrorMessage);
            }
        }
コード例 #4
0
ファイル: TileHelper.cs プロジェクト: jevonsflash/Weather
        /// <summary>
        /// 更新磁贴数字
        /// </summary>
        /// <param name="number"></param>
        public static void UpdateBadgeWithNumber(int number)
        {
            BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent((uint)number);

            // Send the notification to the application’s tile.
            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification());
        }
コード例 #5
0
        /// <summary>
        /// 更新磁贴数字
        /// </summary>
        /// <param name="number"></param>
        public static void UpdateSecondaryBadgeWithNumber(string tileId, int number)
        {
            BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent((uint)number);

            // Send the notification to the application’s tile.
            BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(tileId).Update(badgeContent.CreateNotification());
        }
コード例 #6
0
        public static void SendBadge(uint count)
        {
            BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(count);
            BadgeNotification notif = new BadgeNotification(badgeContent.GetXml());

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(notif);
        }
コード例 #7
0
        /// <summary>
        /// 更新未读头条文章的徽章badge
        /// </summary>
        /// <param name="t"></param>
        private static void UpdateBadge(LatestStories t)
        {
            //将当天未读TOP文章更新到 badge
            int un_readed = 0;

            t.Top_Stories.ToList().ForEach(s => { if (!DataShareManager.Current.ReadedList.Contains(s.ID))
                                                  {
                                                      un_readed++;
                                                  }
                                           });

            var updater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            if (un_readed != 0)
            {
                var badgexml = new BadgeNumericNotificationContent((uint)un_readed);

                var n = badgexml.CreateNotification();
                n.ExpirationTime = DateTime.Now.AddDays(7);

                updater.Update(n);
            }
            else
            {
                updater.Clear();
            }
        }
コード例 #8
0
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            if (CurrentShoppingCart == null)
            {
                return;
            }

            var badgeContent =
                new BadgeNumericNotificationContent((uint)CurrentShoppingCart.ItemsQuantity);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication()
            .Update(badgeContent.CreateNotification());

            if (CurrentShoppingCart.Items.Count > 0)
            {
                _tileSquareContent.TextBodyWrap.Text =
                    string.Format(SHOPPING_CART_MESSAGE, CurrentShoppingCart.ItemsQuantity);

                _tileWideContent.TextHeadingWrap.Text =
                    string.Format(SHOPPING_CART_MESSAGE, CurrentShoppingCart.ItemsQuantity);
            }
            else
            {
                _tileSquareContent.TextBodyWrap.Text  = EMPTY_SHOPPING_CART_MESSAGE;
                _tileWideContent.TextHeadingWrap.Text = EMPTY_SHOPPING_CART_MESSAGE;
            }

            _tileWideContent.Square150x150Content = _tileSquareContent;

            TileUpdateManager.CreateTileUpdaterForApplication()
            .Update(_tileWideContent.CreateNotification());
        }
コード例 #9
0
 private async void Button_Click_1(object sender, RoutedEventArgs e)
 {
     if (await ValidateUri())
     {
         var badge = new BadgeNumericNotificationContent((uint)BadgeValue.Value);
         await PostToCloud(badge.CreateNotification().Content, "wns/badge");
     }
 }
コード例 #10
0
        private void SendBadgeNotification_Click(object sender, RoutedEventArgs e)
        {
            if (VerifyTileIsPinned())
            {
                BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(6);

                // Send the notification to the secondary tile
                BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(MainPage.dynamicTileId).Update(new BadgeNotification(badgeContent.GetXml()));

                rootPage.NotifyUser("Badge notification sent to " + MainPage.dynamicTileId, NotifyType.StatusMessage);
            }
        }
コード例 #11
0
        void UpdateBadgeWithNumber(int number)
        {
            // Note: This sample contains an additional project, NotificationsExtensions.
            // NotificationsExtensions exposes an object model for creating notifications, but you can also modify the xml
            // of the notification directly. See the additional function UpdateBadgeWithNumberWithStringManipulation to see how to do it
            // by modifying strings directly

            BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent((uint)number);

            // send the notification to the app's application tile
            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification());

            OutputTextBlock.Text = badgeContent.GetContent();
        }
コード例 #12
0
ファイル: NotificationTask.cs プロジェクト: dw5/Viddi
        public void UpdateTileCount(int count, bool showToast)
        {
            if (showToast)
            {
                LoadPreviousToasts();
                ShowToasts();
                SavePreviousToasts();
            }

            if (count == 0)
            {
                ClearPreviousToasts();
                ToastNotificationManager.History.Clear();
            }

            // Update tile
            var badgeContent = new BadgeNumericNotificationContent((uint)count);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification());
        }
        /// <summary>
        /// This is the click handler for the 'Other' button.  You would replace this with your own handler
        /// if you have a button or buttons on this page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SendBadgeNotification_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (button != null)
            {
                if (SecondaryTile.Exists(MainPage.dynamicTileId))
                {
                    BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(6);

                    // Send the notification to the secondary tile
                    BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(MainPage.dynamicTileId).Update(badgeContent.CreateNotification());

                    rootPage.NotifyUser("Badge notification sent to " + MainPage.dynamicTileId, NotifyType.StatusMessage);
                }
                else
                {
                    ToggleButtons(false);
                    rootPage.NotifyUser(MainPage.dynamicTileId + " not pinned.", NotifyType.ErrorMessage);
                }
            }
        }
コード例 #14
0
        public void UpdateBadgeWithNumber(int number)
        {
            BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent((uint)number);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification());
        }
コード例 #15
0
        void UpdateBadgeWithNumber(int number)
        {
            BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent((uint)number);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification());
        }
コード例 #16
0
ファイル: TileManager.cs プロジェクト: zoemaestra/Reddunt
        /// <summary>
        /// Makes sure the main app tile is an icon tile type
        /// </summary>
        public void UpdateMainTile(int unreadCount)
        {
            // Setup the main tile as iconic for small and medium
            TileContent content = new TileContent()
            {
                Visual = new TileVisual()
                {
                    TileSmall = new TileBinding()
                    {
                        Content = new TileBindingContentIconic()
                        {
                            Icon = new TileImageSource("ms-appx:///Assets/AppAssets/IconicTiles/Iconic144.png"),
                        }
                    },
                    TileMedium = new TileBinding()
                    {
                        Content = new TileBindingContentIconic()
                        {
                            Icon = new TileImageSource("ms-appx:///Assets/AppAssets/IconicTiles/Iconic200.png"),
                        }
                    },
                }
            };

            // If the user is signed in we will do more for large and wide.
            if (m_baconMan.UserMan.IsUserSignedIn && m_baconMan.UserMan.CurrentUser != null && !String.IsNullOrWhiteSpace(m_baconMan.UserMan.CurrentUser.Name))
            {
                content.Visual.TileWide = new TileBinding()
                {
                    Content = new TileBindingContentAdaptive()
                    {
                        Children =
                        {
                            new TileText()
                            {
                                Text  = m_baconMan.UserMan.CurrentUser.Name,
                                Style = TileTextStyle.Caption
                            },
                            new TileText()
                            {
                                Text  = String.Format("{0:N0}", m_baconMan.UserMan.CurrentUser.CommentKarma) + " comment karma",
                                Style = TileTextStyle.CaptionSubtle
                            },
                            new TileText()
                            {
                                Text  = String.Format("{0:N0}", m_baconMan.UserMan.CurrentUser.LinkKarma) + " link karma",
                                Style = TileTextStyle.CaptionSubtle
                            },
                        }
                    },
                };

                // If we have messages replace the user name with the message string.
                if (unreadCount != 0)
                {
                    TileText unreadCountText = new TileText()
                    {
                        Text  = unreadCount + " Unread Inbox Message" + (unreadCount == 1 ? "" : "s"),
                        Style = TileTextStyle.Body
                    };
                    ((TileBindingContentAdaptive)content.Visual.TileWide.Content).Children[0] = unreadCountText;
                }

                // Also set the cake day if it is today
                DateTime origin           = new DateTime(1970, 1, 1, 0, 0, 0, 0);
                DateTime userCreationTime = origin.AddSeconds(m_baconMan.UserMan.CurrentUser.CreatedUtc).ToLocalTime();
                TimeSpan elapsed          = DateTime.Now - userCreationTime;
                double   fullYears        = Math.Floor((elapsed.TotalDays / 365));
                int      daysUntil        = (int)(elapsed.TotalDays - (fullYears * 365));

                if (daysUntil == 0)
                {
                    // Make the text
                    TileText cakeDayText = new TileText()
                    {
                        Text  = "Today is your cake day!",
                        Style = TileTextStyle.Body
                    };
                    ((TileBindingContentAdaptive)content.Visual.TileWide.Content).Children[0] = cakeDayText;
                }
            }

            // Set large to the be same as wide.
            content.Visual.TileLarge = content.Visual.TileWide;

            // Update the tile
            TileUpdateManager.CreateTileUpdaterForApplication().Update(new TileNotification(content.GetXml()));

            // Update the badge
            BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent();

            badgeContent.Number = (uint)unreadCount;
            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(new BadgeNotification(badgeContent.GetXml()));
        }
コード例 #17
0
ファイル: Sender.cs プロジェクト: gpdeepblue/Aurora-Weather
        public static void CreateBadge(BadgeNumericNotificationContent badge)
        {
            BadgeNotification b = new BadgeNotification(badge.GetXml());

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(b);
        }
コード例 #18
0
        /// <summary>
        /// Generates badge notification of goldCount change for receiver.
        /// </summary>
        /// <param name="goldCount">The goldCount of the user.</param>
        /// <returns>String representation of badge object.</returns>
        private string GenerateBadgeNotification(uint goldCount)
        {
            BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(goldCount);

            return(badgeContent.GetContent());
        }
コード例 #19
0
        /// <summary>
        /// Updates all of the notifications based on the message list.
        /// </summary>
        /// <param name="newMessages"></param>
        public async void UpdateNotifications(List <Message> newMessages)
        {
            bool updateSliently = !m_baconMan.IsBackgroundTask;

            // Check if we are disabled.
            if (!IsEnabled || !m_baconMan.UserMan.IsUserSignedIn)
            {
                // Clear things out
                ToastNotificationManager.History.Clear();
                // Clear the tile
                BadgeNumericNotificationContent content = new BadgeNumericNotificationContent();
                content.Number = 0;
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(new BadgeNotification(content.GetXml()));
                return;
            }

            try
            {
                // Get the current state of the messages.
                IReadOnlyList <ToastNotification> history = ToastNotificationManager.History.GetHistory();

                // We need to keep track of anything new to send to the band.
                List <Tuple <string, string, string> > newNotifications = new List <Tuple <string, string, string> >();

                // We also need to keep track of how many are unread so we can updates our badge.
                int unreadCount = 0;

                if (NotificationType == 0)
                {
                    // For help look here.
                    // http://blogs.msdn.com/b/tiles_and_toasts/archive/2015/07/09/quickstart-sending-a-local-toast-notification-and-handling-activations-from-it-windows-10.aspx

                    // We need to keep track of what notifications we should have so we can remove ones we don't need.
                    Dictionary <string, bool> unReadMessages = new Dictionary <string, bool>();

                    foreach (Message message in newMessages.Reverse <Message>())
                    {
                        // If it is new
                        if (message.IsNew)
                        {
                            unreadCount++;

                            // Add the message to our list
                            unReadMessages.Add(message.Id, true);

                            // Check if it is already been reported but dismissed from the UI
                            if (ShownMessageNotifications.ContainsKey(message.Id))
                            {
                                continue;
                            }

                            // If not add that we are showing it.
                            ShownMessageNotifications[message.Id] = true;

                            // Check if it is already in the UI
                            foreach (ToastNotification oldToast in history)
                            {
                                if (oldToast.Tag.Equals(message.Id))
                                {
                                    continue;
                                }
                            }

                            // Get the post title.
                            string title = "";
                            if (message.WasComment)
                            {
                                string subject = message.Subject;
                                if (subject.Length > 0)
                                {
                                    subject = subject.Substring(0, 1).ToUpper() + subject.Substring(1);
                                }
                                title = subject + " from " + message.Author;
                            }
                            else
                            {
                                title = message.Subject;
                            }

                            // Get the body
                            string body = message.Body;

                            // Add the notification to our list
                            newNotifications.Add(new Tuple <string, string, string>(title, body, message.Id));
                        }
                    }

                    // Make sure that all of the messages in our history are still unread
                    // if not remove them.
                    for (int i = 0; i < history.Count; i++)
                    {
                        if (!unReadMessages.ContainsKey(history[i].Tag))
                        {
                            // This message isn't unread any longer.
                            ToastNotificationManager.History.Remove(history[i].Tag);
                        }
                    }

                    // Save any settings we changed
                    SaveSettings();
                }
                else
                {
                    // Count how many are unread
                    foreach (Message message in newMessages)
                    {
                        if (message.IsNew)
                        {
                            unreadCount++;
                        }
                    }

                    // If we have a different unread count now show the notification.
                    if (LastKnownUnreadCount != unreadCount)
                    {
                        // Update the notification.
                        LastKnownUnreadCount = unreadCount;

                        // Clear anything we have in the notification center already.
                        ToastNotificationManager.History.Clear();

                        if (unreadCount != 0)
                        {
                            newNotifications.Add(new Tuple <string, string, string>($"You have {unreadCount} new inbox message" + (unreadCount == 1 ? "." : "s."), "", "totalCount"));
                        }
                    }
                }

                // For every notification, show it.
                bool hasShownNote = false;
                foreach (Tuple <string, string, string> newNote in newNotifications)
                {
                    // Make the visual
                    ToastVisual visual = new ToastVisual();
                    visual.TitleText = new ToastText()
                    {
                        Text = newNote.Item1
                    };
                    if (!String.IsNullOrWhiteSpace(newNote.Item2))
                    {
                        visual.BodyTextLine1 = new ToastText()
                        {
                            Text = newNote.Item2
                        };
                    }

                    // Make the toast content
                    ToastContent toastContent = new ToastContent();
                    toastContent.Visual         = visual;
                    toastContent.Launch         = c_messageInboxOpenArgument;
                    toastContent.ActivationType = ToastActivationType.Foreground;
                    toastContent.Duration       = ToastDuration.Short;

                    var toast = new ToastNotification(toastContent.GetXml());
                    toast.Tag = newNote.Item3;

                    // Only show if we should and this is the first message to show.
                    toast.SuppressPopup = hasShownNote || updateSliently || AddToNotificationCenterSilently;
                    ToastNotificationManager.CreateToastNotifier().Show(toast);

                    // Mark that we have shown one.
                    hasShownNote = true;
                }

                // Make sure the main tile is an iconic tile.
                m_baconMan.TileMan.EnsureMainTileIsIconic();

                // Update the badge
                BadgeNumericNotificationContent content = new BadgeNumericNotificationContent();
                content.Number = (uint)unreadCount;
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(new BadgeNotification(content.GetXml()));

                // Update the band if we have one.
                if (!updateSliently)
                {
                    await m_baconMan.BackgroundMan.BandMan.UpdateInboxMessages(newNotifications, newMessages);
                }

                // If all was successful update the last time we updated
                LastUpdateTime = DateTime.Now;
            }
            catch (Exception ex)
            {
                m_baconMan.TelemetryMan.ReportUnExpectedEvent(this, "messageUpdaterFailed", ex);
                m_baconMan.MessageMan.DebugDia("failed to update message notifications", ex);
            }

            // When we are done release the deferral
            ReleaseDeferal();
        }
コード例 #20
0
        /// <summary>
        /// バッジの追加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addBadgeButton_Click(object sender, RoutedEventArgs e)
        {
            BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(6);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification());
        }
コード例 #21
0
        private async void ExtendedSplashScreen_Loaded(object sender, RoutedEventArgs e)
        {
            ProgressText.Text = ApplicationData.Current.LocalSettings.Values.ContainsKey("Initialized") &&
                                (bool)ApplicationData.Current.LocalSettings.Values["Initialized"]
                                    ? "Loading blogs..."
                                    : "Initializing for first use: this may take several minutes...";

            await App.Instance.DataSource.LoadGroups();

            foreach (var group in App.Instance.DataSource.GroupList)
            {
                Progress.IsActive = true;
                ProgressText.Text = "Loading " + group.Title;
                await App.Instance.DataSource.LoadAllItems(group);
            }

            ApplicationData.Current.LocalSettings.Values["Initialized"] = true;

            // Create a Frame to act as the navigation context and associate it with
            // a SuspensionManager key
            var rootFrame = new Frame();

            SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

            var list = App.Instance.DataSource.GroupList;

            var totalNew = list.Sum(g => g.NewItemCount);

            if (totalNew > 99)
            {
                totalNew = 99;
            }

            if (totalNew > 0)
            {
                var badgeContent = new BadgeNumericNotificationContent((uint)totalNew);
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification());
            }
            else
            {
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
            }

            // load most recent 5 items then order from oldest to newest

            var query = from i in
                        (from g in list
                         from i in g.Items
                         orderby i.PostDate descending
                         select i).Take(5)
                        orderby i.PostDate
                        select i;

            var x = 0;

            TileUpdateManager.CreateTileUpdaterForApplication().Clear();
            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);

            foreach (var item in query)
            {
                var squareTile = new TileSquarePeekImageAndText04();
                squareTile.TextBodyWrap.Text = item.Title;
                squareTile.Image.Alt         = item.Title;
                squareTile.Image.Src         = item.DefaultImageUri.ToString();

                var wideTile = new TileWideSmallImageAndText03
                {
                    SquareContent = squareTile
                };
                wideTile.Image.Alt         = item.Title;
                wideTile.Image.Src         = item.DefaultImageUri.ToString();
                wideTile.TextBodyWrap.Text = item.Title;

                var notification = wideTile.CreateNotification();
                notification.Tag = string.Format("Item {0}", x++);
                TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
            }

            Windows.ApplicationModel.Search.SearchPane.GetForCurrentView().SuggestionsRequested += SplashPage_SuggestionsRequested;

            App.Instance.Extended = true;

            if (_searchArgs != null)
            {
                SearchResultsPage.Activate(_searchArgs);
                return;
            }

            if (_activationArgs != null)
            {
                if (_activationArgs.Arguments.StartsWith("Group"))
                {
                    var group = _activationArgs.Arguments.Split('=');
                    rootFrame.Navigate(typeof(GroupDetailPage), group[1]);
                }
                else if (_activationArgs.Arguments.StartsWith("Item"))
                {
                    var item = _activationArgs.Arguments.Split('=');
                    rootFrame.Navigate(typeof(ItemDetailPage), item[1]);
                }
                else if (_activationArgs.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate
                    await SuspensionManager.RestoreAsync();
                }
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(GroupedItemsPage), "AllGroups"))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            // Place the frame in the current Window and ensure that it is active
            Window.Current.Content = rootFrame;
            Window.Current.Activate();
        }
コード例 #22
0
        public TestPageOld()
        {
            InitializeComponent();

            Logout                 = new RelayCommand(() => VKHelper.Reset());
            GetUniqueDeviceID      = new RelayCommand(async() => await(new MessageDialog(CoreHelper.GetUniqueDeviceID(), "UniqueDeviceID")).ShowAsync());
            GetDeviceName          = new RelayCommand(async() => await(new MessageDialog(CoreHelper.GetDeviceName(), "DeviceName")).ShowAsync());
            GetOperatingSystemName = new RelayCommand(async() => await(new MessageDialog(CoreHelper.GetOperatingSystemName(), "OperatingSystem")).ShowAsync());
            CaptchaForce           = new RelayCommand(async() => await(new CaptchaForceRequest()).ExecuteAsync());
            ShowLocalFolderPath    = new RelayCommand(async() => await(new MessageDialog(ApplicationData.Current.LocalFolder.Path, "LocalFolder Path")).ShowAsync());
            TurnOnNotification     = new RelayCommand(async() =>
            {
                bool result = await NotificationsHelper.Connect();
                await(new MessageDialog(result ? "Success" : "Fail", "Push notifications")).ShowAsync();
            });

            TestMessageFlags = new RelayCommand(async() =>
            {
                var flags = (VKMessageFlags)243;
                await(new MessageDialog(flags.ToString(), "243 as VKMessageFlags")).ShowAsync();
                flags = (VKMessageFlags)241;
                await(new MessageDialog(flags.ToString(), "241 as VKMessageFlags")).ShowAsync();
            });
            StartLongPolling = new RelayCommand(() =>
            {
                ServiceHelper.VKLongPollService.StartLongPolling();
                StopLongPolling.RaiseCanExecuteChanged();
                StartLongPolling.RaiseCanExecuteChanged();
            }, () => true);
            StopLongPolling = new RelayCommand(() =>
            {
                ServiceHelper.VKLongPollService.StopLongPolling();
                StartLongPolling.RaiseCanExecuteChanged();
                StopLongPolling.RaiseCanExecuteChanged();
            }, () => true);

            ShowToast = new RelayCommand(() =>
            {
                ((ChromeFrame)Frame).ShowPopup(new PopupMessage
                {
                    Title     = "Добро пожаловать в OneVK", Content = "Это уведомление вернет вас на тестовую страницу",
                    Parameter = new NavigateToPageMessage()
                    {
                        Page = AppViews.TestView
                    },
                    Type = PopupMessageType.Info
                });
            });

            GoToBotView = new RelayCommand(() =>
            {
                Messenger.Default.Send <NavigateToPageMessage>(new NavigateToPageMessage
                {
                    Page      = AppViews.BotView,
                    Operation = NavigationType.New
                });
            });
            GoToBlankPage = new RelayCommand(() => Frame.Navigate(typeof(BlankPage1)));

            ClearBadgeTile = new RelayCommand(() =>
            {
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
            });

            SendBadgeTile = new RelayCommand(() =>
            {
                var badge = new BadgeNumericNotificationContent(7).CreateNotification();
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);
            });

            SendMessageTile = new RelayCommand(() =>
            {
                var tile           = TileContentFactory.CreateTileSquare150x150IconWithBadge();
                tile.ImageIcon.Src = "ms-appx:///Assets/BadgeIcon.png";
                TileUpdateManager.CreateTileUpdaterForApplication().Update(tile.CreateNotification());

                var badge = new BadgeNumericNotificationContent(7).CreateNotification();
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);
            });

            SendToast = new RelayCommand(() =>
            {
                var toast               = ToastContentFactory.CreateToastText02();
                toast.Audio.Content     = ToastAudioContent.IM;
                toast.Duration          = ToastDuration.Long;
                toast.TextHeading.Text  = "OneVK";
                toast.TextBodyWrap.Text = "Это тестовое уведомление";

                ToastNotificationManager.CreateToastNotifier().Show(toast.CreateNotification());
            });

            StartVKSaver = new RelayCommand(async() =>
            {
                IVKSaverCommand command = new VKSaverStartAppCommand();
                await command.TryExecute();
            });
        }