コード例 #1
0
ファイル: JumpListService.cs プロジェクト: balaji119/MoneyFox
        public static async Task InitializeAsync()
        {
            if (!ApiInformation.IsTypePresent("Windows.UI.StartScreen.JumpList"))
            {
                return;
            }

            try
            {
                JumpList jumpList = await JumpList.LoadCurrentAsync();

                jumpList.Items.Clear();
                jumpList.SystemGroupKind = JumpListSystemGroupKind.None;

                var listItemAddPayment = JumpListItem.CreateWithArguments(AppConstants.AddPaymentId, Strings.AddPaymentLabel);
                listItemAddPayment.Logo = new Uri(INCOME_ICON);
                jumpList.Items.Add(listItemAddPayment);

                await jumpList.SaveAsync();
            }
            catch (Exception ex)
            {
                logger.Warn(ex);
            }
        }
コード例 #2
0
        public static async Task CreateDefaultList(bool clear = false)
        {
            if (JumpList.IsSupported())
            {
                var jumplist = await JumpList.LoadCurrentAsync();

                if (!jumplist.Items.Any() || clear)
                {
                    jumplist.Items.Clear();
                    var args = new ToastNotificationArgs()
                    {
                        type          = "jumplist",
                        openBookmarks = true
                    };
                    var item = JumpListItem.CreateWithArguments(JsonConvert.SerializeObject(args), "Open Bookmarks");
                    item.Logo                = new Uri("ms-appx:///Assets/BadgeLogo.scale-100.png");
                    args.openBookmarks       = false;
                    args.openPrivateMessages = true;

                    var item2 = JumpListItem.CreateWithArguments(JsonConvert.SerializeObject(args), "Open Private Messages");
                    item2.Logo = new Uri("ms-appx:///Assets/BadgeLogo.scale-100.png");
                    jumplist.Items.Add(item);
                    jumplist.Items.Add(item2);
                    var seperate = JumpListItem.CreateSeparator();
                    jumplist.Items.Add(seperate);
                    await jumplist.SaveAsync();
                }
            }
        }
コード例 #3
0
        private async Task UpdateJumpList()
        {
            if (!JumpList.IsSupported())
            {
                return;
            }

            try
            {
                JumpList jumpList = await JumpList.LoadCurrentAsync();

                jumpList.SystemGroupKind = JumpListSystemGroupKind.None;
                jumpList.Items.Clear();

                foreach (DirectionViewModel directionViewModel in AvailableDirections)
                {
                    string itemName  = string.Format("{0} → {1}", directionViewModel.OriginLanguage, directionViewModel.DestinationLanguage);
                    string arguments = "dict:" + directionViewModel.OriginLanguageCode + directionViewModel.DestinationLanguageCode;

                    JumpListItem jumpListItem = JumpListItem.CreateWithArguments(arguments, itemName);

                    jumpListItem.Logo = LanguageCodes.GetCountryFlagUri(directionViewModel.OriginLanguageCode);

                    jumpList.Items.Add(jumpListItem);
                }

                await jumpList.SaveAsync();
            }
            catch
            {
                // in rare cases, SaveAsync may fail with HRESULT 0x80070497: "Unable to remove the file to be replaced."
                // this appears to be a common problem without a solution, so we simply ignore any errors here
            }
        }
コード例 #4
0
        public static async Task UpdateAsync(ISettingsService settingsService)
        {
            if (!JumpList.IsSupported())
            {
                return;
            }

            try
            {
                var jumpList = await JumpList.LoadCurrentAsync();

                jumpList.Items.Clear();
                foreach (var profile in settingsService.GetAllProfiles())
                {
                    var item = JumpListItem.CreateWithArguments(ShellProfileFlag + profile.Id, profile.Name);
                    item.Description = profile.Location;
                    jumpList.Items.Add(item);
                }
                await jumpList.SaveAsync();
            }
            catch (Exception e)
            {
                Logger.Instance.Error(e, "JumpList Update Exception");
            }
        }
コード例 #5
0
        public void When_Logo_Uri_Is_ms_appdata()
        {
            var item = JumpListItem.CreateWithArguments("Hello", "Test");

            Assert.ThrowsException <ArgumentException>(
                () => item.Logo = new Uri("ms-appdata:///Test.png"));
        }
コード例 #6
0
        /// <summary>
        /// Clears and re-creates all custom items in the app's jump list.
        /// </summary>
        public async Task RefreshJumpList()
        {
            if (!JumpList.IsSupported())
            {
                return;
            }

            try
            {
                JumpList jumpList = await JumpList.LoadCurrentAsync();

                jumpList.Items.Clear();
                jumpList.SystemGroupKind = JumpListSystemGroupKind.None;
                string packageId = Package.Current.Id.Name;

                foreach (string color in new[] { "Blue", "Green", "Red", "Yellow" })
                {
                    var item = JumpListItem.CreateWithArguments(color, $"ms-resource://{packageId}/Resources/{color}NavItem/Content");
                    item.GroupName = $"ms-resource://{packageId}/Resources/JumpListGroupColors";
                    item.Logo      = new Uri($"ms-appx:///Assets/JumpList/{color}.png");
                    jumpList.Items.Add(item);
                }

                await jumpList.SaveAsync();
            }
            catch (Exception ex)
            {
                // TODO: Proper error handling. SaveAsync may fail, for example with exception
                //   "Unable to remove the file to be replaced." (Exception from HRESULT 0x80070497)
                Debug.WriteLine(ex);
            }
        }
コード例 #7
0
ファイル: JumpListManager.cs プロジェクト: rohitjha/MALClient
        public static async void InitJumpList()
        {
            try
            {
                var jumpList = await JumpList.LoadCurrentAsync();

                jumpList.SystemGroupKind = JumpListSystemGroupKind.None;
                jumpList.Items.Clear();

                if (!Credentials.Authenticated)
                {
                    return;
                }

                var item = JumpListItem.CreateWithArguments("https://myanimelist.net/anime.php", "Search");
                item.Logo = new Uri("ms-appx:///Assets/EmptySquare.png");
                jumpList.Items.Add(item);
                item      = JumpListItem.CreateWithArguments("https://myanimelist.net/mymessages.php", "Messages");
                item.Logo = new Uri("ms-appx:///Assets/EmptySquare.png");
                jumpList.Items.Add(item);
                item      = JumpListItem.CreateWithArguments("https://myanimelist.net/forum", "Forum");
                item.Logo = new Uri("ms-appx:///Assets/EmptySquare.png");;
                jumpList.Items.Add(item);

                await jumpList.SaveAsync();
            }
            catch (Exception)
            {
                //jumplist unavailable
            }
        }
コード例 #8
0
        private async void UpdateJumplist()
        {
            var jumpList = await Windows.UI.StartScreen.JumpList.LoadCurrentAsync();

            jumpList.Items.Clear();

            var item = JumpListItem.CreateWithArguments("opensearch", resourceLoader.GetString("SearchText"));

            item.Logo = new Uri("ms-appx:///Assets/searchicon.png");
            jumpList.Items.Add(item);

            foreach (Line line in savedLines)
            {
                if (line.Name != null)
                {
                    string name = line.Name;
                    if (name.Trim() == "")
                    {
                        name = resourceLoader.GetString("Unnamed");
                    }
                    var item2 = JumpListItem.CreateWithArguments($"{line.FromsID}-{line.FromlsID}-{line.TosID}-{line.TolsID}", name);
                    item2.Logo        = new Uri("ms-appx:///Assets/BadgeLogo.scale-100.png");
                    item2.Description = $"{line.From} - {line.To}";
                    item2.GroupName   = resourceLoader.GetString("SavedLines");
                    jumpList.Items.Add(item2);
                }
            }

            try { await jumpList.SaveAsync(); }
            catch (Exception) { }
        }
コード例 #9
0
        public void When_Logo_Uri_Is_ms_appx()
        {
            var item = JumpListItem.CreateWithArguments("Hello", "Test");

            item.Logo = new Uri("ms-appx:///Test.png");
            Assert.AreEqual("ms-appx:///Test.png", item.Logo.AbsoluteUri);
        }
コード例 #10
0
        public async static void UpdateJumpList(ObservableCollection <goal> listOfGoals)
        {
            var jumpList = await JumpList.LoadCurrentAsync();

            if (jumpList.Items != null && jumpList.Items.Count > 0)
            {
                clearJumpList(jumpList);
            }

            foreach (var goal in listOfGoals)
            {
                var item = JumpListItem.CreateWithArguments(goal.tileID, goal.name);
                item.Description = $"Quickly update your progress on for {goal.name}";
                item.GroupName   = "Shortcuts To Goals In Progress";

                if (isItemInJumpList(item, jumpList) == false)
                {
                    jumpList.Items.Add(item);
                }
            }


            jumpList.SystemGroupKind = JumpListSystemGroupKind.Recent;

            await jumpList.SaveAsync();
        }
コード例 #11
0
        public void When_Logo_Uri_Is_Set_To_Null()
        {
            var item = JumpListItem.CreateWithArguments("Hello", "Test");

            item.Logo = null;
            Assert.AreEqual(null, item.Logo);
        }
コード例 #12
0
        public void When_Logo_Uri_Is_Web()
        {
            var item = JumpListItem.CreateWithArguments("Hello", "Test");

            Assert.ThrowsException <ArgumentException>(
                () => item.Logo = new Uri("https://www.example.com/image.png"));
        }
コード例 #13
0
        public void When_Logo_Uri_Is_File_Path()
        {
            var item = JumpListItem.CreateWithArguments("Hello", "Test");

            Assert.ThrowsException <ArgumentException>(
                () => item.Logo = new Uri("C:\\Dev\\Hello.png"));
        }
コード例 #14
0
        public void When_Description_Is_Set_To_Null()
        {
            var item = JumpListItem.CreateWithArguments("Hello", "test");

            Assert.ThrowsException <ArgumentNullException>(
                () => item.Description = null);
        }
コード例 #15
0
ファイル: App.xaml.cs プロジェクト: tian-lt/calculator
        private async Task SetupJumpList()
        {
            try
            {
                var calculatorOptions = NavCategoryStates.CreateCalculatorCategoryGroup();

                var jumpList = await JumpList.LoadCurrentAsync();

                jumpList.SystemGroupKind = JumpListSystemGroupKind.None;
                jumpList.Items.Clear();

                foreach (NavCategory option in calculatorOptions.Categories)
                {
                    if (!NavCategoryStates.IsViewModeEnabled(option.ViewMode))
                    {
                        continue;
                    }
                    ViewMode mode = option.ViewMode;
                    var      item = JumpListItem.CreateWithArguments(((int)mode).ToString(), "ms-resource:///Resources/" + NavCategoryStates.GetNameResourceKey(mode));
                    item.Description = "ms-resource:///Resources/" + NavCategoryStates.GetNameResourceKey(mode);
                    item.Logo        = new Uri("ms-appx:///Assets/" + mode.ToString() + ".png");

                    jumpList.Items.Add(item);
                }

                await jumpList.SaveAsync();
            }
            catch
            {
            }
        }
コード例 #16
0
        private async Task SetJumplist()
        {
            var jumpList = await JumpList.LoadCurrentAsync();

            jumpList.Items.Clear();
            jumpList.SystemGroupKind = JumpListSystemGroupKind.None;

            var listItemAddIncome = JumpListItem.CreateWithArguments(Constants.ADD_INCOME_TILE_ID,
                                                                     Strings.AddIncomeLabel);

            listItemAddIncome.Logo = new Uri("ms-appx:///Assets/IncomeTileIcon.png");
            jumpList.Items.Add(listItemAddIncome);

            var listItemAddSpending = JumpListItem.CreateWithArguments(Constants.ADD_EXPENSE_TILE_ID,
                                                                       Strings.AddExpenseLabel);

            listItemAddSpending.Logo = new Uri("ms-appx:///Assets/SpendingTileIcon.png");
            jumpList.Items.Add(listItemAddSpending);

            var listItemAddTransfer = JumpListItem.CreateWithArguments(Constants.ADD_TRANSFER_TILE_ID,
                                                                       Strings.AddTransferLabel);

            listItemAddTransfer.Logo = new Uri("ms-appx:///Assets/TransferTileIcon.png");
            jumpList.Items.Add(listItemAddTransfer);

            await jumpList.SaveAsync();
        }
コード例 #17
0
        /// <summary>
        /// Add history items.
        /// </summary>
        /// <param name="historyItems">History items.</param>
        public async Task ChangeHistoryItems(IDictionary <long, string> historyItems)
        {
            if (!JumpList.IsSupported())
            {
                return;
            }

            var jumpList = await JumpList.LoadCurrentAsync();

            var oldItems = jumpList.Items
                           .ToList()
                           .Where(a => a.GroupName == HistoryGroupName)
                           .ToList();

            foreach (var oldItem in oldItems)
            {
                jumpList.Items.Remove(oldItem);
            }

            foreach (var historyItem in historyItems)
            {
                var item = JumpListItem.CreateWithArguments($"releasecardhistory:{historyItem.Key}", historyItem.Value);
                item.GroupName = HistoryGroupName;
                jumpList.Items.Add(item);
            }

            OrderItems(jumpList);

            try {
                await jumpList.SaveAsync();
            }
            catch {
                // Sometimes it was cause application failure
            }
        }
コード例 #18
0
        internal static UIApplicationShortcutItem ToShortcutItem(this JumpListItem jumpListItem)
        {
            var dictionary = new Dictionary <string, string>()
            {
                { JumpListItem.UnoShortcutKey, "true" }
            };

            if (jumpListItem.Logo != null)
            {
                dictionary[JumpListItem.ImagePathKey] = jumpListItem.Logo.ToString();
            }

            var displayName = jumpListItem.DisplayName;

            if (string.IsNullOrEmpty(displayName))
            {
                displayName = " ";                 //use single space to make sure item is displayed
            }

            var shortcut =
                new UIApplicationShortcutItem(
                    jumpListItem.Arguments,
                    displayName,
                    jumpListItem.Description,
                    jumpListItem.Logo != null ? UIApplicationShortcutIcon.FromTemplateImageName(jumpListItem.Logo.LocalPath) : null,
                    NSDictionary <NSString, NSObject> .FromObjectsAndKeys(
                        dictionary.Values.Cast <object>().ToArray(),
                        dictionary.Keys.Cast <object>().ToArray()));

            return(shortcut);
        }
コード例 #19
0
ファイル: UpdateTask.cs プロジェクト: zhuxb711/Files
        private async Task RefreshJumpList()
        {
            if (JumpList.IsSupported())
            {
                var instance = await JumpList.LoadCurrentAsync();

                // Disable automatic jumplist. It doesn't work with Files UWP.
                instance.SystemGroupKind = JumpListSystemGroupKind.None;

                var jumpListItems = instance.Items.ToList();

                // Clear all items to avoid localization issues
                instance.Items.Clear();

                foreach (var temp in jumpListItems)
                {
                    var jumplistItem = JumpListItem.CreateWithArguments(temp.Arguments, temp.DisplayName);
                    jumplistItem.Description = jumplistItem.Arguments;
                    jumplistItem.GroupName   = "ms-resource:///Resources/JumpListRecentGroupHeader";
                    jumplistItem.Logo        = new Uri("ms-appx:///Assets/FolderIcon.png");
                    instance.Items.Add(jumplistItem);
                }

                await instance.SaveAsync();
            }
        }
コード例 #20
0
        /// <summary>
        /// Init jump list
        /// </summary>
        private async void InitJumpList()
        {
            try
            {
                JumpList jumpList = await JumpList.LoadCurrentAsync();

                jumpList.SystemGroupKind = JumpListSystemGroupKind.None;
                jumpList.Items.Clear();

                var loginItem = JumpListItem.CreateWithArguments("/Login", "登录网关");
                loginItem.Description = "登录北京师范大学上网认证网关";
                var logoutItem = JumpListItem.CreateWithArguments("/Logout", "注销网关");
                logoutItem.Description = "注销北京师范大学上网认证网关";
                var forceItem = JumpListItem.CreateWithArguments("/ForceLogout", "强制离线网关");
                forceItem.Description = "强制离线北京师范大学上网认证网关";

                jumpList.Items.Add(loginItem);
                jumpList.Items.Add(logoutItem);
                jumpList.Items.Add(forceItem);

                await jumpList.SaveAsync();
            }
            catch
            { }
        }
コード例 #21
0
        public async Task When_Description_Is_Empty_No_Exception()
        {
            try
            {
                var item = JumpListItem.CreateWithArguments("Hello", "Test");
                item.Description = string.Empty;
                var jumpList = await JumpList.LoadCurrentAsync();

                jumpList.Items.Clear();
                jumpList.Items.Add(item);
                await jumpList.SaveAsync();

                // reload from native
                var newJumpList = await JumpList.LoadCurrentAsync();

                Assert.AreEqual(string.Empty, newJumpList.Items.First().Description);
            }
            finally
            {
                var jumpList = await JumpList.LoadCurrentAsync();

                jumpList.Items.Clear();
                await jumpList.SaveAsync();
            }
        }
コード例 #22
0
        public async Task AddItem(JumpListGroup Group, params StorageFolder[] FolderList)
        {
            if (await Initialize().ConfigureAwait(false))
            {
                bool ItemModified = false;

                string GroupString = ConvertGroupEnumToResourceString(Group);

                foreach (StorageFolder Folder in FolderList)
                {
                    if (InnerList.Items.Where((Item) => Item.GroupName == GroupString).All((Item) => Item.Description != Folder.Path))
                    {
                        string RecentGroupString  = ConvertGroupEnumToResourceString(JumpListGroup.Recent);
                        string LibraryGroupString = ConvertGroupEnumToResourceString(JumpListGroup.Library);

                        JumpListItem[] RecentGroupItems = InnerList.Items.Where((Item) => Item.GroupName == RecentGroupString).ToArray();

                        JumpListItem[] LibraryGroupItems = InnerList.Items.Where((Item) => Item.GroupName == LibraryGroupString).ToArray();

                        if (Group == JumpListGroup.Library)
                        {
                            if (LibraryGroupItems.Length >= GroupItemMaxNum && RecentGroupItems.Length + LibraryGroupItems.Length >= 2 * GroupItemMaxNum)
                            {
                                if (RecentGroupItems.Length > 4)
                                {
                                    InnerList.Items.Remove(RecentGroupItems.FirstOrDefault());
                                }
                                else
                                {
                                    InnerList.Items.Remove(LibraryGroupItems.FirstOrDefault());
                                }
                            }
                        }
                        else
                        {
                            if (RecentGroupItems.Length >= GroupItemMaxNum || RecentGroupItems.Length + LibraryGroupItems.Length >= 2 * GroupItemMaxNum)
                            {
                                InnerList.Items.Remove(RecentGroupItems.FirstOrDefault());
                            }
                        }

                        JumpListItem NewItem = JumpListItem.CreateWithArguments(Folder.Path, Folder.DisplayName);

                        NewItem.Logo        = new Uri("ms-appx:///Assets/FolderIcon.png");
                        NewItem.Description = Folder.Path;
                        NewItem.GroupName   = GroupString;

                        InnerList.Items.Add(NewItem);

                        ItemModified = true;
                    }
                }

                if (ItemModified)
                {
                    await InnerList.SaveAsync();
                }
            }
        }
コード例 #23
0
        private static JumpListItem CreateJumpListItem(string arguments, string displayName, string groupName, Uri uri)
        {
            JumpListItem item = JumpListItem.CreateWithArguments(arguments, displayName);

            item.GroupName = groupName;
            item.Logo      = uri;
            return(item);
        }
コード例 #24
0
        public void When_Instance_Is_Created_Default_Values()
        {
            var item = JumpListItem.CreateWithArguments("Hello", "test");

            Assert.AreEqual(string.Empty, item.Description);
            Assert.AreEqual(null, item.Logo);
            Assert.AreEqual(false, item.RemovedByUser);
            Assert.AreEqual(JumpListItemKind.Arguments, item.Kind);
        }
コード例 #25
0
ファイル: App.xaml.cs プロジェクト: rafaelps95/AudictiveMusic
        private JumpListItem CreateJumpListItem(string arguments, string displayName, Uri imageUri)
        {
            var taskItem = JumpListItem.CreateWithArguments(
                arguments, displayName);

            taskItem.Logo = imageUri;

            return(taskItem);
        }
コード例 #26
0
        public static void JumpListBuilder(ref JumpList jumpList, string arg, string name, string icon, string groupname = "Functions", string description = "")
        {
            var Item = JumpListItem.CreateWithArguments(arg, name);

            Item.Description = (description == "") ? name : description;
            Item.GroupName   = groupname;
            Item.Logo        = new Uri(icon);
            jumpList.Items.Add(Item);
        }
コード例 #27
0
        public static JumpListItem CreateItem(string argument, string displayName, string group, string desc, Uri pic)
        {
            var adding = JumpListItem.CreateWithArguments(argument, displayName);

            adding.GroupName   = group;
            adding.Description = desc;
            adding.Logo        = pic;
            return(adding);
        }
コード例 #28
0
        private Windows.UI.StartScreen.JumpListItem CreateJumpListItemTask(string u, string description, string uri)
        {
            var taskItem = JumpListItem.CreateWithArguments(
                u, description);

            taskItem.Description = description;
            taskItem.Logo        = new Uri(uri);
            return(taskItem);
        }
コード例 #29
0
ファイル: JumplistHelper.cs プロジェクト: Losses/DarkPlayer
        public async Task ProvisionJumplistAsync()
        {
            if (!IsJumplistPresent)
            {
                throw new NotSupportedException("Jumplist requires contract Windows.Foundation.UniversalApiContract, version 2.0.");
            }

            try
            {
                var jumpList = await JumpList.LoadCurrentAsync();

                jumpList.Items.Clear();

                var albumMenuEntry = JumpListItem.CreateWithArguments("light-jumplist:viewallalbums",
                                                                      CommonSharedStrings.JumplistAlbumText);

                albumMenuEntry.GroupName   = CommonSharedStrings.CategoryGroupName;
                albumMenuEntry.Description = CommonSharedStrings.JumplistAlbumText;

                albumMenuEntry.Logo = new Uri(CommonSharedStrings.JumplistAlbumIconPath);

                var artistMenuEntry = JumpListItem.CreateWithArguments("light-jumplist:viewallartists",
                                                                       CommonSharedStrings.JumplistArtistText);

                artistMenuEntry.GroupName   = CommonSharedStrings.CategoryGroupName;
                artistMenuEntry.Description = CommonSharedStrings.JumplistArtistText;

                artistMenuEntry.Logo = new Uri(CommonSharedStrings.JumplistArtistIconPath);

                var songMenuEntry = JumpListItem.CreateWithArguments("light-jumplist:viewallsongs",
                                                                     CommonSharedStrings.JumplistSongText);

                songMenuEntry.GroupName   = CommonSharedStrings.CategoryGroupName;
                songMenuEntry.Description = CommonSharedStrings.JumplistSongText;

                songMenuEntry.Logo = new Uri(CommonSharedStrings.JumplistSongIconPath);

                var playlistMenuEntry = JumpListItem.CreateWithArguments("light-jumplist:viewallplaylist",
                                                                         CommonSharedStrings.JumplistPlaylistText);

                playlistMenuEntry.GroupName   = CommonSharedStrings.CategoryGroupName;
                playlistMenuEntry.Description = CommonSharedStrings.JumplistPlaylistText;

                playlistMenuEntry.Logo = new Uri(CommonSharedStrings.JumplistPlaylistIconPath);

                jumpList.Items.Add(albumMenuEntry);
                jumpList.Items.Add(artistMenuEntry);
                jumpList.Items.Add(songMenuEntry);
                jumpList.Items.Add(playlistMenuEntry);

                await jumpList.SaveAsync();
            }
            catch
            {
                // Ignore
            }
        }
コード例 #30
0
        private static bool isItemInJumpList(JumpListItem item, JumpList jumpList)
        {
            bool itemIsInJumplist = false;

            if (jumpList.Items.Contains(item))
            {
                itemIsInJumplist = true;
            }
            return(itemIsInJumplist);
        }