Beispiel #1
0
        private void FolderContentChanged(object sender, FolderContentChangedEventArgs args)
        {
            logger.Info("Folder content changed. Files have been added: {0}", string.Join(", ", args.CreatedFiles.Select(x => x.FileName)));
            foreach (var file in args.CreatedFiles)
            {
                App.Current.Dispatcher.Invoke((Action) delegate
                {
                    var notification = new NewFileNotification
                    {
                        ChangeDate = file.ChangeDate,
                        Folder     = settings.Folders.Single(x => x.FolderId == file.FolderId).FolderName,
                        File       = file.FileName.Substring(file.FileName.LastIndexOf('\\') + 1)
                    };

                    var vm        = new NotificationViewModel(notification, this.iocContainer);
                    vm.OnDismiss += this.NotificationDismissed;
                    this.notificationHistoryService.Create(notification);
                    this.Notifications.Add(vm);
                });
            }

            if (args.CreatedFiles != null && args.CreatedFiles.Any())
            {
                this.windowManager.ShowBalloon(Resources.NewFilesDetected_Title, string.Join(Environment.NewLine, args.CreatedFiles.Select(x => x.FileName)));
            }

            // remove notifications for removed files if this is desired
            if (!this.settings.KeepNotificationsForDeletedFiles)
            {
                foreach (var deletedFile in args.DeletedFiles)
                {
                    logger.Info("Removing notification for deleted file: {0}", deletedFile.FileName);

                    var notification = this.Notifications.SingleOrDefault(x => (x.Notification.Folder + "\\" + x.Notification.File).ToLower() == deletedFile.FileName.ToLower());

                    if (notification != null)
                    {
                        App.Current.Dispatcher.Invoke((Action) delegate
                        {
                            notification.DismissNotification();
                        });
                    }
                }
            }

            this.NotifyOfPropertyChanges("ToolTip");
            this.NotifyOfPropertyChanges("Icon");
            this.NotifyOfPropertyChanges("IsIconVisible");
        }
Beispiel #2
0
 void m_vcServer_FolderContentChanged(object sender, FolderContentChangedEventArgs e)
 {
 }