Ejemplo n.º 1
0
 public MainViewModel()
 {
     GlobalMessenger.Register <GenericMessage <BackgroundType> >(this, m =>
     {
         BackgroundImageType = m.Content;
     });
 }
Ejemplo n.º 2
0
        public BookmarksViewModel(ItemBoxViewModel itemBox)
        {
            SelectedIndex = itemBox.ToNum();
            Messenger.Default.Register <GenericMessage <Tag> >(this, ReflectToTag);

            All      = new ObservableItems <BookmarkItemViewModel>(service.allItems);
            Unread   = new ObservableItems <BookmarkItemViewModel>(service.unreadItems);
            Private_ = new ObservableItems <BookmarkItemViewModel>(service.privateItems);
            Public_  = new ObservableItems <BookmarkItemViewModel>(service.publicItems);
            Untagged = new ObservableItems <BookmarkItemViewModel>(service.untaggedItems);
            Tagged   = new ObservableItems <BookmarkItemViewModel>(service.taggedItems);

            GlobalMessenger.Register <BookmarkChangeMessage>(this, m =>
            {
                if (m.Type == BookmarkChangeType.Add)
                {
                    All.Refresh();
                    Unread.Refresh();
                    Private_.Refresh();
                    Public_.Refresh();
                    Untagged.Refresh();
                    Tagged.Refresh();
                }
                else if (m.Type == BookmarkChangeType.Delete || m.Type == BookmarkChangeType.Modify)
                {
                    if (All.Items.Contains(m.Content))
                    {
                        All.Refresh();
                    }
                    if (Unread.Items.Contains(m.Content))
                    {
                        Unread.Refresh();
                    }
                    if (Private_.Items.Contains(m.Content))
                    {
                        Private_.Refresh();
                    }
                    if (Public_.Items.Contains(m.Content))
                    {
                        Public_.Refresh();
                    }
                    if (Untagged.Items.Contains(m.Content))
                    {
                        Untagged.Refresh();
                    }
                    if (Tagged.Items.Contains(m.Content))
                    {
                        Tagged.Refresh();
                    }
                }
            });
        }