Esempio n. 1
0
        protected ColumnViewModelBase(IContextEntry context, ColumnDefinition definition, IConfig config,
                                      IStreamParser parser)
        {
            Configuration = config;
            Definition    = definition;
            Context       = context;
            Width         = definition.Width;
            IsLoading     = true;
            Statuses      = StatusCollection = new SmartCollection <StatusViewModel>();
            Parser        = parser;

            ColumnConfiguration        = new ColumnConfigurationViewModel(definition);
            ColumnConfiguration.Saved += ColumnConfiguration_Saved;

            if (config.General.RealtimeStreaming)
            {
                Parser.FriendsReceived += Parser_FriendsReceived;
                Parser.StatusReceived  += Parser_StatusReceived;
                Parser.StatusDeleted   += Parser_StatusDeleted;
            }

            ActionDispatcher = new ColumnActionDispatcher();
            ActionDispatcher.HeaderClicked += ActionDispatcher_HeaderClicked;
            ActionDispatcher.BottomReached += ActionDispatcher_BottomReached;

            MaxIdFilterExpression   = s => s.MaxID == MaxId - 1;
            SinceIdFilterExpression = s => s.SinceID == SinceId;
            CountExpression         = s => s.Count == config.General.TweetFetchCount;
            SubTitle = "@" + context.AccountName;
        }
Esempio n. 2
0
        protected ColumnViewModelBase(IContextEntry context, ColumnDefinition definition, IConfig config,
                                      IStreamParser parser, IMessenger messenger = null, IColumnActionDispatcher actionDispatcher = null)
            : base(messenger)
        {
            Configuration = config;
            Definition    = definition;
            Context       = context;
            Width         = definition.Width;
            IsLoading     = true;
            Items         = ItemCollection = new SmartCollection <ColumnItem>();
            Parser        = parser;
            MessengerInstance.Register <FilterUpdateMessage>(this, OnFiltersUpdated);

            ColumnConfiguration        = new ColumnConfigurationViewModel(definition);
            ColumnConfiguration.Saved += ColumnConfiguration_Saved;

            if (config.General.RealtimeStreaming)
            {
                Parser.StatusReceived        += Parser_StatusReceived;
                Parser.StatusDeleted         += Parser_ItemDeleted;
                Parser.DirectMessageDeleted  += Parser_ItemDeleted;
                Parser.DirectMessageReceived += Parser_DirectMessageReceived;
                Parser.FavoriteEventReceived += Parser_FavoriteEventReceived;
            }

            ActionDispatcher = actionDispatcher ?? new ColumnActionDispatcher();
            ActionDispatcher.HeaderClicked += ActionDispatcher_HeaderClicked;
            ActionDispatcher.BottomReached += ActionDispatcher_BottomReached;

            MaxIdFilterExpression   = s => s.MaxID == MaxId - 1;
            SinceIdFilterExpression = s => s.SinceID == SinceId;
            CountExpression         = s => s.Count == config.General.TweetFetchCount;
            SubTitle = "@" + Context.AccountName;
        }
Esempio n. 3
0
 public MessageColumn(IContextEntry context, ColumnDefinition definition, IConfig config, IStreamParser parser,
                      IMessenger messenger = null, IColumnActionDispatcher actionDispatcher = null)
     : base(context, definition, config, parser, messenger, actionDispatcher)
 {
     Title = Strings.Messages;
     MessengerInstance.Register <DmMessage>(this, OnDirectMessage);
 }
Esempio n. 4
0
 public TestColumnMock(IContextEntry context, ColumnDefinition definition, IConfig config = null,
                       IStreamParser parser = null)
     : base(context, definition, config ?? DefaultConfig(), parser ?? DefaultParser())
 {
     StatusFilterExpression = s => true;
     Icon = Icon.User;
 }
Esempio n. 5
0
 public AccountEntry(IContextEntry context)
 {
     Context               = context;
     AccountName           = Context.AccountName;
     ProfileImage          = Context.ProfileImageUrl;
     _RequiresConfirmation = Context.RequiresConfirmation;
 }
Esempio n. 6
0
 public FavoritesColumn(IContextEntry context, ColumnDefinition definition, IConfig config, IStreamParser parser,
                        IMessenger messenger = null)
     : base(context, definition, config, parser, messenger)
 {
     MaxIdFilterExpressionFavorites   = s => s.MaxID == MaxId - 1;
     SinceIdFilterExpressionFavorites = s => s.SinceID == SinceId;
     Title = Strings.Favourites;
 }
Esempio n. 7
0
        public ScheduleColumn(IContextEntry context, ColumnDefinition definition, IConfig config, IStreamParser parser,
                              IScheduler scheduler, IMessenger messenger = null)
            : base(context, definition, config, parser, messenger)
        {
            Scheduler = scheduler;
            Title     = Strings.Schedule;

            Scheduler.JobListUpdated += Scheduler_JobListUpdated;
        }
Esempio n. 8
0
        public async Task ViewStatus(StatusViewModel status, IContextEntry context)
        {
            Action <ITweetDetailsViewModel> vmSetup = vm =>
            {
                vm.Context      = context;
                vm.DisplayTweet = status;
            };

            await ShowWindow <TweetDetailsDialog, ITweetDetailsViewModel>(vmSetup);
        }
Esempio n. 9
0
        public MessageViewModel(DirectMessage model, IContextEntry context, IConfig config, IViewServiceRepository viewServices)
            : base(config, viewServices)
        {
            Model   = model;
            Context = context;

            User    = new UserViewModel(model.Sender);
            Partner = new UserViewModel(model.SenderID == context.UserId
                                ? model.Recipient
                                : model.Sender);

            IsIncoming = Model.SenderID != context.UserId;
        }
Esempio n. 10
0
        public MessageViewModel(DirectMessage model, IContextEntry context, IConfig config, IViewServiceRepository viewServices)
            : base(config, viewServices)
        {
            Model   = model;
            Context = context;

            User    = new UserViewModel(model.Sender);
            Partner = new UserViewModel(model.SenderID == context.UserId
                                ? model.Recipient
                                : model.Sender);

            IsIncoming = Model.SenderID != context.UserId;

            BlockUserCommand  = new LogMessageCommand("Tried to block user from MessageViewModel", LogLevel.Warn);
            ReportSpamCommand = new LogMessageCommand("Tried to report user from MessageViewModel", LogLevel.Warn);
        }
Esempio n. 11
0
        public StatusViewModel(Status model, IContextEntry context, IConfig config, IViewServiceRepository viewServiceRepo)
            : base(config, viewServiceRepo)
        {
            Context = context;

            Model          = model;
            OriginalStatus = Model;
            if (OriginalStatus.RetweetedStatus != null && OriginalStatus.RetweetedStatus.StatusID != 0)
            {
                Model      = OriginalStatus.RetweetedStatus;
                SourceUser = new UserViewModel(OriginalStatus.User);
            }
            else
            {
                Model      = OriginalStatus;
                SourceUser = null;
            }

            HasSensibleContent = config?.General?.FilterSensitiveTweets == true && Model.PossiblySensitive;
            User        = new UserViewModel(Model.User);
            Dispatcher  = new DispatcherHelperWrapper();
            RetweetedBy = new SmartCollection <UserViewModel>();
        }
Esempio n. 12
0
        public StatusViewModel(Status model, IContextEntry context, IConfig config, IViewServiceRepository viewServiceRepo)
        {
            Config  = config;
            Context = context;
            ViewServiceRepository = viewServiceRepo;

            Model          = model;
            OriginalStatus = Model;
            if (OriginalStatus.RetweetedStatus != null && OriginalStatus.RetweetedStatus.StatusID != 0)
            {
                Model      = OriginalStatus.RetweetedStatus;
                SourceUser = new UserViewModel(OriginalStatus.User);
            }
            else
            {
                Model      = OriginalStatus;
                SourceUser = null;
            }

            User        = new UserViewModel(Model.User);
            Dispatcher  = new DispatcherHelperWrapper();
            RetweetedBy = new SmartCollection <UserViewModel>();
        }
Esempio n. 13
0
 internal void OverwriteContext(IContextEntry context)
 {
     Context = context;
 }
Esempio n. 14
0
 public StaticColumn(IContextEntry context, ColumnDefinition definition, IConfig config, IStreamParser parser,
                     IMessenger messenger = null)
     : base(context, definition, config, parser, messenger)
 {
 }
Esempio n. 15
0
 public MentionsColumn(IContextEntry context, ColumnDefinition definition, IConfig config, IStreamParser parser)
     : base(context, definition, config, parser)
 {
     Icon  = Icon.Mentions;
     Title = Strings.Mentions;
 }
Esempio n. 16
0
        public async Task OnLoad(object data)
        {
            if (ProfileId == 0 && string.IsNullOrWhiteSpace(ScreenName))
            {
                Close(false);
                return;
            }

            IsBusy = true;
            var contextId = await(Cache?.FindFriend(ProfileId) ?? Task.FromResult(0ul));

            IContextEntry friendContext = ContextList.Contexts.FirstOrDefault(ctx => ctx.UserId == contextId);

            Context = friendContext ?? ContextList.Contexts.FirstOrDefault(ctx => ctx.IsDefault) ?? ContextList.Contexts.First();

            UserEx user = null;

            try
            {
                if (ProfileId == 0)
                {
                    user = await Context.Twitter.Users.ShowUser(ScreenName, true);
                }
                else
                {
                    user = await Context.Twitter.Users.ShowUser(ProfileId, true);
                }
            }
            catch (Exception ex)
            {
                LogTo.WarnException("Failed to load user profile", ex);
                Notifier.DisplayMessage(ex.GetReason(), NotificationType.Error);
            }
            if (user == null)
            {
                Notifier.DisplayMessage(Strings.UserNotFound, NotificationType.Error);
                Close(false);
                return;
            }

            User       = new UserViewModel(user);
            Friendship = await Context.Twitter.Friendships.GetFriendshipWith(Context.UserId, User.UserId);

            UserPages = new List <UserSubPage>
            {
                new UserSubPage(Strings.Tweets, LoadStatuses, LoadMoreStatuses, User.Model.StatusesCount)
                {
                    Dispatcher = Dispatcher
                },
                new UserSubPage(Strings.Following, LoadFollowings, User.Model.FriendsCount)
                {
                    Dispatcher = Dispatcher
                },
                new UserSubPage(Strings.Followers, LoadFollowers, User.Model.FollowersCount)
                {
                    Dispatcher = Dispatcher
                }
            };
            RaisePropertyChanged(nameof(UserPages));

            await Dispatcher.RunAsync(Center);

            IsBusy = false;
        }
Esempio n. 17
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="StreamParser" /> class.
 /// </summary>
 /// <param name="stream"> The user stream. </param>
 /// <param name="context"> The context this stream is associated with </param>
 private StreamParser(IStreamingConnection stream, IContextEntry context)
 {
     AssociatedContext = context;
     Connections       = new List <IStreaming>();
     Stream            = stream;
 }
Esempio n. 18
0
 /// <summary>
 ///     Creates a new parser for the specified stream.
 /// </summary>
 /// <param name="userStream"> The stream. </param>
 /// <param name="context"> The context this stream is associated with </param>
 /// <returns> The created parser. </returns>
 public static StreamParser Create(IStreamingConnection userStream, IContextEntry context)
 {
     return(new StreamParser(userStream, context));
 }
Esempio n. 19
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="context"></param>
 /// <param name="loadImage">Disable this during tests so wpf won't try to load the image</param>
 public AccountEntry(IContextEntry context, bool loadImage = true)
 {
     Context = context;
     Image   = loadImage ? new BitmapImage(context.ProfileImageUrl) : new BitmapImage();
 }
Esempio n. 20
0
 public TestColumn(IContextEntry context = null, IConfig config = null, IStreamParser parser = null)
     : base(
         context ?? DefaultContext(), new ColumnDefinition(ColumnType.Mentions), config ?? DefaultConfig(),
         parser ?? DefaultParser())
 {
 }
Esempio n. 21
0
 public UserColumn(IContextEntry context, ColumnDefinition definition, IConfig config, IStreamParser parser)
     : base(context, definition, config, parser)
 {
     UserId   = definition.TargetAccounts.First();
     SubTitle = "";
 }
Esempio n. 22
0
 public TestColumn(IContextEntry context, ColumnDefinition definition, IConfig config, IStreamParser parser)
     : base(context, definition, config, parser)
 {
     StatusFilterExpression = s => true;
     Icon = Icon.User;
 }
Esempio n. 23
0
 public AccountEntry(IContextEntry context)
 {
     Context = context;
     Image   = new BitmapImage(context.ProfileImageUrl);
 }
Esempio n. 24
0
 public MessageColumn(IContextEntry context, ColumnDefinition definition, IConfig config, IStreamParser parser,
                      IMessenger messenger = null)
     : base(context, definition, config, parser, messenger)
 {
     MessengerInstance.Register <DmMessage>(this, OnDirectMessage);
 }
 public InferenceState Push(IContextEntry entry) => new InferenceState(this.Fresh, this.Context.Add(entry));
Esempio n. 26
0
 public TestUserColumn(IContextEntry context = null, ColumnDefinition definition = null, IConfig config = null, IStreamParser parser = null)
     : base(context ?? DefaultContext(), definition ?? DefaultDefinition(), config ?? DefaultConfig(), parser ?? DefaultParser())
 {
 }
Esempio n. 27
0
 // TODO: Implement joined timelines for multiple contexts
 public TimelineColumn(IContextEntry context, ColumnDefinition definition, IConfig config, IStreamParser parser)
     : base(context, definition, config, parser)
 {
     Title = Strings.Timeline;
 }