Exemple #1
0
        private async Task InitialiseAsync()
        {
            try
            {
                _discord = new DiscordClient(new DiscordConfiguration()
                {
                    LogLevel              = LogLevel.Debug,
                    TokenType             = TokenType.User,
                    Token                 = _token,
                    MessageCacheSize      = 0,
                    UseInternalLogHandler = true
                });

                _badgeManager         = new BadgeManager(_discord);
                _tileManager          = new TileManager(_discord);
                _secondaryTileManager = new SecondaryTileManager(_discord);
                _toastManager         = new ToastManager();

                _discord.Ready               += OnReady;
                _discord.MessageCreated      += OnDiscordMessage;
                _discord.MessageAcknowledged += OnMessageAcknowledged;

                await _discord.ConnectAsync(status : UserStatus.Invisible, idlesince : DateTimeOffset.Now);
            }
            catch (Exception)
            {
                this.ExitThread();
            }
        }
        public FolderListupPageViewModel(
            BookmarkManager bookmarkManager,
            ImageCollectionManager imageCollectionManager,
            SourceStorageItemsRepository sourceStorageItemsRepository,
            PathReferenceCountManager PathReferenceCountManager,
            SecondaryTileManager secondaryTileManager,
            FolderLastIntractItemManager folderLastIntractItemManager,
            FolderListingSettings folderListingSettings,
            OpenPageCommand openPageCommand,
            OpenFolderItemCommand openFolderItemCommand,
            OpenImageViewerCommand openImageViewerCommand,
            OpenFolderListupCommand openFolderListupCommand,
            OpenWithExplorerCommand openWithExplorerCommand,
            SecondaryTileAddCommand secondaryTileAddCommand,
            SecondaryTileRemoveCommand secondaryTileRemoveCommand
            )
        {
            _bookmarkManager              = bookmarkManager;
            _imageCollectionManager       = imageCollectionManager;
            _sourceStorageItemsRepository = sourceStorageItemsRepository;
            _PathReferenceCountManager    = PathReferenceCountManager;
            SecondaryTileManager          = secondaryTileManager;
            _folderLastIntractItemManager = folderLastIntractItemManager;
            _folderListingSettings        = folderListingSettings;
            OpenPageCommand            = openPageCommand;
            OpenFolderItemCommand      = openFolderItemCommand;
            OpenImageViewerCommand     = openImageViewerCommand;
            OpenFolderListupCommand    = openFolderListupCommand;
            OpenWithExplorerCommand    = openWithExplorerCommand;
            SecondaryTileAddCommand    = secondaryTileAddCommand;
            SecondaryTileRemoveCommand = secondaryTileRemoveCommand;
            FolderItems      = new ObservableCollection <StorageItemViewModel>();
            ArchiveFileItems = new ObservableCollection <StorageItemViewModel>();
            EBookFileItems   = new ObservableCollection <StorageItemViewModel>();
            ImageFileItems   = new ObservableCollection <StorageItemViewModel>();

            FileItemsView        = new AdvancedCollectionView(ImageFileItems);
            SelectedFileSortType = new ReactivePropertySlim <FileSortType>(FileSortType.TitleAscending);



            FileDisplayMode       = _folderListingSettings.ToReactivePropertyAsSynchronized(x => x.FileDisplayMode);
            FolderLastIntractItem = new ReactivePropertySlim <StorageItemViewModel>();
            ImageLastIntractItem  = new ReactivePropertySlim <int>();

            /*
             * _currentQueryOptions = Observable.CombineLatest(
             *  SelectedFolderViewFirstSort,
             *  (queryType, sort) => (queryType, sort)
             *  )
             *  .Select(_ =>
             *  {
             *      var options = new QueryOptions();
             *      options.FolderDepth = FolderDepth.Shallow;
             *      options.SetPropertyPrefetch(Windows.Storage.FileProperties.PropertyPrefetchOptions.ImageProperties, Enumerable.Empty<string>());
             *      return options;
             *  })
             *  .ToReadOnlyReactivePropertySlim();
             */
        }
 public void OnLaunched(Windows.ApplicationModel.Activation.LaunchActivatedEventArgs e)
 {
     var a = Dispatcher.RunIdleAsync((o) =>
     {
         ToggleAppBarButton(!SecondaryTileManager.TileExists(appbarTileId));
     });
 }
        public SearchResultPageViewModel(
            StorageItemSearchManager storageItemSearchManager,
            SourceStorageItemsRepository sourceStorageItemsRepository,
            PathReferenceCountManager PathReferenceCountManager,
            FolderListingSettings folderListingSettings,
            BookmarkManager bookmarkManager,
            ThumbnailManager thumbnailManager,
            SecondaryTileManager secondaryTileManager,

            OpenFolderItemCommand openFolderItemCommand,
            OpenImageViewerCommand openImageViewerCommand,
            OpenFolderListupCommand openFolderListupCommand,
            OpenWithExplorerCommand openWithExplorerCommand,
            SecondaryTileAddCommand secondaryTileAddCommand,
            SecondaryTileRemoveCommand secondaryTileRemoveCommand
            )
        {
            _storageItemSearchManager     = storageItemSearchManager;
            _sourceStorageItemsRepository = sourceStorageItemsRepository;
            _PathReferenceCountManager    = PathReferenceCountManager;
            _folderListingSettings        = folderListingSettings;
            _bookmarkManager           = bookmarkManager;
            _thumbnailManager          = thumbnailManager;
            SecondaryTileManager       = secondaryTileManager;
            OpenFolderItemCommand      = openFolderItemCommand;
            OpenImageViewerCommand     = openImageViewerCommand;
            OpenFolderListupCommand    = openFolderListupCommand;
            OpenWithExplorerCommand    = openWithExplorerCommand;
            SecondaryTileAddCommand    = secondaryTileAddCommand;
            SecondaryTileRemoveCommand = secondaryTileRemoveCommand;
        }
Exemple #5
0
        public void PinToStart()
        {
            string activationArguments = "Playlist:" + ID.ToString();
            string appbarTileId        = "ModernMusic." + activationArguments.Replace(':', '.');

            Uri square150x150Logo = new Uri("ms-appx:///Assets/Transparent.png");

            SecondaryTileManager.PinSecondaryTile(appbarTileId, Name, square150x150Logo, activationArguments, true);
        }
Exemple #6
0
        public async Task PinToStart()
        {
            string activationArguments = "Album:" + ID.ToString();
            string appbarTileId        = "ModernMusic." + activationArguments.Replace(':', '.');

            Uri square150x150Logo = await Utilities.ResizeImageFileToFile(new Uri(CachedImagePath), 150);

            SecondaryTileManager.PinSecondaryTile(appbarTileId, AlbumName, square150x150Logo, activationArguments, true);
        }
        private async Task StartInProcTaskAsync()
        {
            _badgeManager         = new BadgeManager(App.Discord);
            _tileManager          = new TileManager(App.Discord);
            _secondaryTileManager = new SecondaryTileManager(App.Discord);

            await _tileManager.InitialiseAsync();

            await _secondaryTileManager.InitialiseAsync();

            App.Discord.MessageAcknowledged += OnMessageAcknowledged;
            App.Discord.MessageCreated      += OnMessageCreated;
        }
        private async void pinToStart_Click(object sender, RoutedEventArgs e)
        {
            if (SecondaryTileManager.TileExists(appbarTileId))
            {
                ToggleAppBarButton(await SecondaryTileManager.UnpinSecondaryTile(appbarTileId));
            }
            else
            {
                // Prepare package images for all four tile sizes in our tile to be pinned as well as for the square30x30 logo used in the Apps view.
                Uri square150x150Logo = new Uri("ms-appx:///Assets/Square150x150Logo.scale-240.png");

                SecondaryTileManager.PinSecondaryTile(appbarTileId, "Modern Music", square150x150Logo, showName: true);
            }
        }
Exemple #9
0
 public static void CreateTileForConversation(long userOrChatId, bool isChat, string name, List <string> imagesUris, Action <bool> completionCallback)
 {
     //Action<string> action=null;
     Execute.ExecuteOnUIThread((Action)(() =>
     {
         string tileType = "Conversation";
         string objId = userOrChatId.ToString() + isChat.ToString() + AppGlobalStateManager.Current.LoggedInUserId.ToString();
         imagesUris = imagesUris.Take <string>(8).ToList <string>();
         List <WaitHandle> waitHandles = SecondaryTileManager.DownloadImages(imagesUris.Select <string, Tuple <int, string> >((Func <string, Tuple <int, string> >)(i => new Tuple <int, string>(imagesUris.IndexOf(i), i))).ToList <Tuple <int, string> >(), tileType, objId);
         new Thread((ThreadStart)(() =>
         {
             if (!WaitHandle.WaitAll(waitHandles.ToArray(), 10000))
             {
                 completionCallback(false);
             }
             else
             {
                 List <string> localUris = new List <string>();
                 for (int ind = 0; ind < imagesUris.Count; ++ind)
                 {
                     if (!string.IsNullOrWhiteSpace(imagesUris[ind]))
                     {
                         localUris.Add("/" + SecondaryTileManager.GetLocalNameFor(ind, tileType, objId));
                     }
                 }
                 ConversationTileImageFormatter.CreateTileImage(localUris, userOrChatId, isChat, /*action ?? (action = (*/ new Action <string> (uriStr =>
                 {
                     if (!string.IsNullOrEmpty(uriStr))
                     {
                         FlipTileData flipTileData = new FlipTileData();
                         Uri uri = new Uri("isostore:" + uriStr, UriKind.Absolute);
                         flipTileData.SmallBackgroundImage = uri;
                         flipTileData.BackgroundImage = uri;
                         flipTileData.Title = name;
                         ShellTile.Create(new Uri(string.Format("/VKMessenger;component/Views/ConversationPage.xaml?UserOrChatId={0}&IsChat={1}&FromLookup={2}&NewMessageContents={3}&TileLoggedInUserId={4}&ClearBackStack=True", (object)userOrChatId, (object)isChat, (object)false, (object)false, (object)AppGlobalStateManager.Current.LoggedInUserId), UriKind.Relative), (ShellTileData)flipTileData, false);
                         completionCallback(true);
                     }
                     else
                     {
                         completionCallback(false);
                     }
                 }));
             }
         })).Start();
     }));
 }
        public async Task PinToStart()
        {
            string activationArguments = "Artist:" + ID.ToString();
            string appbarTileId        = "ModernMusic." + activationArguments.Replace(':', '.');

            await MusicLibrary.Instance.DownloadAlbumArt(this);

            Uri square150x150Logo = new Uri("ms-appx:///Assets/Square150x150Logo.scale-240.png");

            if (ImagePath != null)
            {
                Uri source = new Uri(ImagePath);
                if (!source.IsFile)
                {
                    square150x150Logo = await Utilities.ResizeImage(new Uri(ImagePath), 150);
                }
            }

            SecondaryTileManager.PinSecondaryTile(appbarTileId, "Modern Music", square150x150Logo, activationArguments);
        }
Exemple #11
0
        public ApplicationDataUpdateWhenPathReferenceCountChanged(
            IEventAggregator eventAggregator,
            RecentlyAccessManager recentlyAccessManager,
            BookmarkManager bookmarkManager,
            StorageItemSearchManager storageItemSearchManager,
            FolderContainerTypeManager folderContainerTypeManager,
            ThumbnailManager thumbnailManager,
            SecondaryTileManager secondaryTileManager,
            FolderLastIntractItemManager folderLastIntractItemManager
            )
        {
            _eventAggregator              = eventAggregator;
            _recentlyAccessManager        = recentlyAccessManager;
            _bookmarkManager              = bookmarkManager;
            _storageItemSearchManager     = storageItemSearchManager;
            _folderContainerTypeManager   = folderContainerTypeManager;
            _thumbnailManager             = thumbnailManager;
            _folderLastIntractItemManager = folderLastIntractItemManager;
            _eventAggregator.GetEvent <PathReferenceCountManager.PathReferenceAddedEvent>()
            .Subscribe(args =>
            {
            }
                       , keepSubscriberReferenceAlive: true
                       )
            .AddTo(_disposables);

            _eventAggregator.GetEvent <PathReferenceCountManager.PathReferenceRemovedEvent>()
            .Subscribe(async args =>
            {
                _recentlyAccessManager.Delete(args.Path);
                _bookmarkManager.RemoveBookmark(args.Path);
                _storageItemSearchManager.Remove(args.Path);
                _folderContainerTypeManager.Delete(args.Path);
                _folderLastIntractItemManager.Remove(args.Path);
                await _thumbnailManager.DeleteFromPath(args.Path);
                await secondaryTileManager.RemoveSecondaryTile(args.Path);
            }
                       , keepSubscriberReferenceAlive: true
                       )
            .AddTo(_disposables);
        }
Exemple #12
0
        public async void Execute(object parameter)
        {
            if (parameter is DiscordChannel channel && !SecondaryTile.Exists($"Channel_{channel.Id}"))
            {
                Analytics.TrackEvent("PinChannelCommand_PinChannel");

                var tile = new SecondaryTile(
                    $"Channel_{channel.Id}",
                    NotificationUtils.GetChannelHeaderName(channel),
                    $"-channelId={channel.Id}",
                    new Uri("ms-appx:///Assets/Store/Square150x150Logo.png"),
                    TileSize.Square150x150);

                tile.VisualElements.ShowNameOnSquare150x150Logo = true;
                tile.VisualElements.ShowNameOnWide310x150Logo   = true;
                tile.VisualElements.ShowNameOnSquare310x310Logo = true;

                if (await tile.RequestCreateAsync())
                {
                    SecondaryTileManager.ClearTileNotifications(channel, tile);
                }
            }
        }
Exemple #13
0
 public SecondaryTileRemoveCommand(SecondaryTileManager secondaryTileManager)
 {
     _secondaryTileManager = secondaryTileManager;
 }
Exemple #14
0
 public SecondaryTileAddCommand(SecondaryTileManager secondaryTileManager)
 {
     _secondaryTileManager = secondaryTileManager;
 }
Exemple #15
0
        public SourceStorageItemsPageViewModel(
            IEventAggregator eventAggregator,
            FolderListingSettings folderListingSettings,
            BookmarkManager bookmarkManager,
            ThumbnailManager thumbnailManager,
            PathReferenceCountManager PathReferenceCountManager,
            SourceStorageItemsRepository sourceStorageItemsRepository,
            RecentlyAccessManager recentlyAccessManager,
            SecondaryTileManager secondaryTileManager,
            SourceChoiceCommand sourceChoiceCommand,
            OpenFolderItemCommand openFolderItemCommand,
            OpenImageViewerCommand openImageViewerCommand,
            OpenFolderListupCommand openFolderListupCommand,
            OpenWithExplorerCommand openWithExplorerCommand,
            SecondaryTileAddCommand secondaryTileAddCommand,
            SecondaryTileRemoveCommand secondaryTileRemoveCommand
            )
        {
            Folders                       = new ObservableCollection <StorageItemViewModel>();
            RecentlyItems                 = new ObservableCollection <StorageItemViewModel>();
            OpenFolderItemCommand         = openFolderItemCommand;
            SourceChoiceCommand           = sourceChoiceCommand;
            _sourceStorageItemsRepository = sourceStorageItemsRepository;
            _recentlyAccessManager        = recentlyAccessManager;
            SecondaryTileManager          = secondaryTileManager;
            _eventAggregator              = eventAggregator;
            OpenImageViewerCommand        = openImageViewerCommand;
            OpenFolderListupCommand       = openFolderListupCommand;
            OpenWithExplorerCommand       = openWithExplorerCommand;
            SecondaryTileAddCommand       = secondaryTileAddCommand;
            SecondaryTileRemoveCommand    = secondaryTileRemoveCommand;
            _bookmarkManager              = bookmarkManager;
            _thumbnailManager             = thumbnailManager;
            _PathReferenceCountManager    = PathReferenceCountManager;
            _folderListingSettings        = folderListingSettings;

            Groups = new[]
            {
                new SourceItemsGroup
                {
                    GroupId = "Folders",
                    Items   = Folders,
                },
                new SourceItemsGroup
                {
                    GroupId = "RecentlyUsedFiles",
                    Items   = RecentlyItems,
                },
            };

            _eventAggregator.GetEvent <SourceStorageItemsRepository.AddedEvent>()
            .Subscribe(args =>
            {
                var existInFolders = Folders.FirstOrDefault(x => x.Token == args.Token);
                if (existInFolders != null)
                {
                    Folders.Remove(existInFolders);
                }

                var existInFiles = RecentlyItems.FirstOrDefault(x => x.Token == args.Token);
                if (existInFiles != null)
                {
                    RecentlyItems.Remove(existInFiles);
                }

                var storageItemImageSource = new StorageItemImageSource(args.StorageItem, _thumbnailManager);
                if (storageItemImageSource.ItemTypes == Models.Domain.StorageItemTypes.Folder)
                {
                    // 追加用ボタンの次に配置するための 1
                    Folders.Insert(1, new StorageItemViewModel(storageItemImageSource, args.Token, _sourceStorageItemsRepository, _folderListingSettings, _bookmarkManager));
                }
                else if (storageItemImageSource.ItemTypes == Models.Domain.StorageItemTypes.Image ||
                         storageItemImageSource.ItemTypes == Models.Domain.StorageItemTypes.Archive ||
                         storageItemImageSource.ItemTypes == Models.Domain.StorageItemTypes.EBook
                         )
                {
                    RecentlyItems.Insert(0, new StorageItemViewModel(storageItemImageSource, args.Token, _sourceStorageItemsRepository, _folderListingSettings, _bookmarkManager));
                }
            })
            .AddTo(_disposables);

            _eventAggregator.GetEvent <SourceStorageItemsRepository.RemovedEvent>()
            .Subscribe(args =>
            {
                var existInFolders = Folders.FirstOrDefault(x => x.Token == args.Token);
                if (existInFolders != null)
                {
                    Folders.Remove(existInFolders);
                }

                var existInFiles = RecentlyItems.Where(x => x.Token == args.Token).ToList();
                foreach (var item in existInFiles)
                {
                    RecentlyItems.Remove(item);
                }
            })
            .AddTo(_disposables);
        }