public static CaptchaViewModel GetInstance(IBaconProvider baconProvider)
        {
            if (_instance == null)
                _instance = new CaptchaViewModel(baconProvider);

            return _instance;
        }
        public ReplyViewModel(IBaconProvider baconProvider, Thing replyTargetThing, RelayCommand cancel, Action<Thing> convertIntoUIReply, bool isEdit = false)
        {
            _convertIntoUIReply = convertIntoUIReply;
            _cancel = cancel;
            _baconProvider = baconProvider;
            _redditService = _baconProvider.GetService<IRedditService>();
            _userService = _baconProvider.GetService<IUserService>();
            _markdownProcessor = _baconProvider.GetService<IMarkdownProcessor>();
            _replyTargetThing = replyTargetThing;

            if (isEdit)
            {
                Editing = true;
                EditingId = ((Comment)_replyTargetThing.Data).Name;
                ReplyBody = ((Comment)_replyTargetThing.Data).Body.Replace("&gt;", ">").Replace("&lt;", "<");
            }

			RefreshUserImpl();

            _addBold = new RelayCommand(AddBoldImpl);
            _addItalic = new RelayCommand(AddItalicImpl);
            _addStrike = new RelayCommand(AddStrikeImpl);
            _addSuper = new RelayCommand(AddSuperImpl);
            _addLink = new RelayCommand(AddLinkImpl);
            _addQuote = new RelayCommand(AddQuoteImpl);
            _addCode = new RelayCommand(AddCodeImpl);
            _addBullets = new RelayCommand(AddBulletsImpl);
            _addNumbers = new RelayCommand(AddNumbersImpl);
            _submit = new RelayCommand(SubmitImpl);
			_refreshUser = new RelayCommand(RefreshUserImpl);
        }
        public MessageViewModel(IBaconProvider baconProvider, Thing message)
        {
            _baconProvider = baconProvider;
            _message = new TypedThing<Message>(message);
            _userService = baconProvider.GetService<IUserService>();
            _redditService = baconProvider.GetService<IRedditService>();
            _navigationService = baconProvider.GetService<INavigationService>();
            _dynamicViewLocator = baconProvider.GetService<IDynamicViewLocator>();

            if (message.Data is CommentMessage)
            {
                var commentMessage = new TypedThing<CommentMessage>(message);
                if (!String.IsNullOrEmpty(commentMessage.Data.Subject))
                {
                    if (commentMessage.Data.LinkTitle.Contains("post"))
                    {
                        isPostReply = true;
                    }
                    else
                    {
                        isPostReply = false;
                    }
                    _message.Data.Subject = commentMessage.Data.LinkTitle;
                }
            }

            _isNew = _message.Data.New;
        }
        public CommentViewModel(IBaconProvider baconProvider, Thing comment, string linkId, bool oddNesting, int depth = 0)
        {
            _isMinimized = false;
            _comment = new TypedThing<Comment>(comment);
            _baconProvider = baconProvider;
            _redditService = _baconProvider.GetService<IRedditService>();
            _navigationService = _baconProvider.GetService<INavigationService>();
            _userService = _baconProvider.GetService<IUserService>();
            _dynamicViewLocator = _baconProvider.GetService<IDynamicViewLocator>();
            _markdownProcessor = _baconProvider.GetService<IMarkdownProcessor>();
            _linkId = linkId;
            OddNesting = oddNesting;
			Depth = depth;
            AuthorFlair = _redditService.GetUsernameModifiers(_comment.Data.Author, _linkId, _comment.Data.Subreddit);
            AuthorFlairText = _comment.Data.AuthorFlairText;
            _showExtendedView = new RelayCommand(ShowExtendedViewImpl);
            _gotoReply = new RelayCommand(GotoReplyImpl);
            _save = new RelayCommand(SaveImpl);
            _report = new RelayCommand(ReportImpl);
            _gotoFullLink = new RelayCommand(GotoFullLinkImpl);
            _gotoContext = new RelayCommand(GotoContextImpl);
            _gotoUserDetails = new RelayCommand(GotoUserDetailsImpl);
            _gotoEdit = new RelayCommand(GotoEditImpl);
            _minimizeCommand = new RelayCommand(() => IsMinimized = !IsMinimized);
            Body = _comment.Data.Body;
        }
Beispiel #5
0
        public LinkViewModel(Thing linkThing, IBaconProvider baconProvider, bool? wasStreamed = null)
        {
            _linkThing = new TypedThing<Link>(linkThing);
            _baconProvider = baconProvider;
            _redditService = _baconProvider.GetService<IRedditService>();
            _navigationService = _baconProvider.GetService<INavigationService>();
            _imagesService = _baconProvider.GetService<IImagesService>();
            _dynamicViewLocator = _baconProvider.GetService<IDynamicViewLocator>();
            _settingsService = _baconProvider.GetService<ISettingsService>();
            _isPreviewShown = false;
			_isExtendedOptionsShown = false;
            _loading = false;
            _registeredLongNav = false;
            ShowPreview = new RelayCommand(() => IsPreviewShown = !IsPreviewShown);
			ShowExtendedOptions = new RelayCommand(() => IsExtendedOptionsShown = !IsExtendedOptionsShown);
            WasStreamed = wasStreamed ?? false;

            ContentIsFocused = !WasStreamed;

            if (Url != null)
            {
                if (_imagesService.MightHaveImagesFromUrl(Url) && !Url.EndsWith(".jpg") && !Url.EndsWith(".gif") && !Url.EndsWith(".png"))
                {
                    MessengerInstance.Register<LongNavigationMessage>(this, OnLongNav);
                    _registeredLongNav = true;
                }
            }
        }
 public SubredditLinks(IBaconProvider baconProvider, string subreddit, string subredditId = null)
 {
     _redditService = baconProvider.GetService<IRedditService>();
     _offlineService = baconProvider.GetService<IOfflineService>();
     _subreddit = subreddit;
     _subredditId = subredditId;
 }
Beispiel #7
0
 public SearchResults(IBaconProvider baconProvider, string query, bool reddits, string restrictedToSubreddit)
 {
     _query = query;
     _reddits = reddits;
     _restrictedToSubreddit = restrictedToSubreddit;
     _redditService = baconProvider.GetService<IRedditService>();
 }
 public VotableViewModel(Thing votableThing, IBaconProvider baconProvider, Action propertyChanged)
 {
     _votableThing = new TypedThing<IVotable>(votableThing);
     _redditService = baconProvider.GetService<IRedditService>();
     _propertyChanged = propertyChanged;
     originalVoteModifier = (Like ? 1 : 0) + (Dislike ? -1 : 0);
 }
Beispiel #9
0
 public PostComments(IBaconProvider baconProvider, string subreddit, string permaLink, string targetName)
 {
     _redditService = baconProvider.GetService<IRedditService>();
     _subreddit = subreddit;
     _permaLink = permaLink;
     _targetName = targetName;
 }
Beispiel #10
0
 public Task Initialize(IBaconProvider baconProvider)
 {
     if (_initTask == null)
     {
         _initTask = InitImpl(baconProvider.GetService<IRedditService>());
     }
     return _initTask;
 }
 public LinkViewModelCollection(IBaconProvider baconProvider, string subreddit, string subredditId = null)
     : base(baconProvider,
         new BaconographyPortable.Model.Reddit.ListingHelpers.SubredditLinks(baconProvider, subreddit, subredditId),
         new BaconographyPortable.Model.KitaroDB.ListingHelpers.SubredditLinks(baconProvider, subreddit, subredditId)) 
 {
     if (subreddit.Contains("+") || subreddit.Contains("/r/all") || !subreddit.Contains("/r/"))
         _state.Add("MultiRedditSource", string.Empty);
 }
 public CombinedSearchViewModel(IBaconProvider baconProvider)
 {
     _baconProvider = baconProvider;
     _viewModelContext = baconProvider.GetService<IViewModelContextService>();
     _systemServices = baconProvider.GetService<ISystemServices>();
     SearchResults = new BindingShellViewModelCollection(new SearchResultsViewModelCollection(_baconProvider, "", false));
     
 }
Beispiel #13
0
 public virtual void Initialize(ISettingsService settingsService, ISimpleHttpService simpleHttpService, IUserService userService, INotificationService notificationService, IBaconProvider baconProvider)
 {
     _settingsService = settingsService;
     _simpleHttpService = simpleHttpService;
     _userService = userService;
     _notificationService = notificationService;
     _baconProvider = baconProvider;
 }
 public AboutSubredditViewModel(IBaconProvider baconProvider, Thing thing, bool subscribed)
 {
     _baconProvider = baconProvider;
     Thing = new TypedThing<Subreddit>(thing);
     _redditService = _baconProvider.GetService<IRedditService>();
     _userService = _baconProvider.GetService<IUserService>();
     _subscribed = subscribed;
 }
        public RedditPickerViewModel(IBaconProvider baconProvider)
        {
            _navigationService = baconProvider.GetService<INavigationService>();
            _dynamicViewLocator = baconProvider.GetService<IDynamicViewLocator>();
            _redditService = baconProvider.GetService<IRedditService>();

            _subreddits = new SubscribedSubredditViewModelCollection(baconProvider);
            _gotoSubreddit = new RelayCommand(GotoSubredditImpl);
        }
 public CaptchaViewModel(IBaconProvider baconProvider)
 {
     _baconProvider = baconProvider;
     _navigationService = baconProvider.GetService<INavigationService>();
     _settingsService = baconProvider.GetService<ISettingsService>();
     _redditService = baconProvider.GetService<IRedditService>();
     _locatorService = baconProvider.GetService<IDynamicViewLocator>();
     _send = new RelayCommand(SendImpl);
 }
        public AboutUserViewModel(IBaconProvider baconProvider)
        {
            _baconProvider = baconProvider;
            _userService = baconProvider.GetService<IUserService>();
            _redditService = baconProvider.GetService<IRedditService>();;
            _navigationService = baconProvider.GetService<INavigationService>();
            _dynamicViewLocator = baconProvider.GetService<IDynamicViewLocator>();

            MessengerInstance.Register<SelectUserAccountMessage>(this, (msg) => LoadAccount(msg.Account));
        }
		public SubredditSelectorViewModel(IBaconProvider baconProvider)
        {
            _baconProvider = baconProvider;
            _redditService = _baconProvider.GetService<IRedditService>();
            _navigationService = _baconProvider.GetService<INavigationService>();
            _userService = _baconProvider.GetService<IUserService>();
            _dynamicViewLocator = _baconProvider.GetService<IDynamicViewLocator>();
            _systemServices = _baconProvider.GetService<ISystemServices>();
            Subreddits = new BindingShellViewModelCollection(new SubredditViewModelCollection(_baconProvider));
        }
Beispiel #19
0
 public LoginViewModel(IBaconProvider baconProvider)
 {
     _userService = baconProvider.GetService<IUserService>();
     _systemServices = baconProvider.GetService<ISystemServices>();
     _notificationService = baconProvider.GetService<INotificationService>();
     _settingsService = baconProvider.GetService<ISettingsService>();
     _baconProvider = baconProvider;
     _isLoggedIn = false;
     MessengerInstance.Register<UserLoggedInMessage>(this, OnUserLoggedIn);
 }
        public SearchResultsViewModel(IBaconProvider baconProvider)
        {
            _baconProvider = baconProvider;
            _redditService = _baconProvider.GetService<IRedditService>();
            _navigationService = _baconProvider.GetService<INavigationService>();
            _userService = _baconProvider.GetService<IUserService>();
            _dynamicViewLocator = _baconProvider.GetService<IDynamicViewLocator>();

            MessengerInstance.Register<SearchQueryMessage>(this, OnSearchQuery);

        }
 public MessagesViewModel(IBaconProvider baconProvider)
 {
     _baconProvider = baconProvider;
     _userService = baconProvider.GetService<IUserService>();
     _redditService = baconProvider.GetService<IRedditService>();
     _navigationService = baconProvider.GetService<INavigationService>();
     _dynamicViewLocator = baconProvider.GetService<IDynamicViewLocator>();
     _smartOfflineService = baconProvider.GetService<ISmartOfflineService>();
     _notificationService = baconProvider.GetService<INotificationService>();
     _liveTileService = baconProvider.GetService<ILiveTileService>();
     _smartOfflineService.OffliningOpportunity += _smartOfflineService_OffliningOpportunity;
     MessengerInstance.Register<UserLoggedInMessage>(this, UserLoggedIn);
 }
        public ComposePostViewModel(IBaconProvider baconProvider)
        {
            _baconProvider = baconProvider;
            _userService = baconProvider.GetService<IUserService>();
            _redditService = baconProvider.GetService<IRedditService>();
            _navigationService = baconProvider.GetService<INavigationService>();
            _dynamicViewLocator = baconProvider.GetService<IDynamicViewLocator>();
            _notificationService = baconProvider.GetService<INotificationService>();
            _refreshUser = new RelayCommand(RefreshUserImpl);
            _submit = new RelayCommand(SubmitImpl);

            RefreshUserImpl();
        }
        /// <summary>
        /// Initializes a new instance of the CommentsViewModel class.
        /// </summary>
        public CommentsViewModel(IBaconProvider baconProvider)
        {
            _baconProvider = baconProvider;
            _userService = baconProvider.GetService<IUserService>();
            _redditService = baconProvider.GetService<IRedditService>();
            _navigationService = baconProvider.GetService<INavigationService>();
            _dynamicViewLocator = baconProvider.GetService<IDynamicViewLocator>();

            MessengerInstance.Register<SelectCommentTreeMessage>(this, OnComentTreeSelection);
            MessengerInstance.Register<ConnectionStatusMessage>(this, OnConnectionStatusChanged);

            _gotoLink = new RelayCommand(GotoLinkImpl);
            _gotoSubreddit = new RelayCommand(GotoSubredditImpl);
            _gotoUserDetails = new RelayCommand(GotoUserImpl);
        }
		public LinkViewLayoutManager()
		{
			FirstColumnWidth = new GridLength(1, GridUnitType.Star);
			SecondColumnWidth = new GridLength(PictureColumnWidth, GridUnitType.Pixel);
			PictureColumn = 1;
			TextColumn = 0;	
			
			_baconProvider = ServiceLocator.Current.GetInstance<IBaconProvider>();
			if (_baconProvider != null)
			{
				_settingsService = _baconProvider.GetService<ISettingsService>();
			}

			Messenger.Default.Register<SettingsChangedMessage>(this, OnSettingsChanged);
		}
		public OrientationManager()
		{
			_baconProvider = ServiceLocator.Current.GetInstance<IBaconProvider>();
			if (_baconProvider != null)
			{
				_settingsService = _baconProvider.GetService<ISettingsService>();
			}

            //_settingsService.ScreenHeight = (int)App  RootFrame.ActualHeight;
            //_settingsService.ScreenHeight = (int)App.RootFrame.ActualWidth;

			Messenger.Default.Register<SettingsChangedMessage>(this, OnSettingsChanged);
			Messenger.Default.Register<OrientationChangedMessage>(this, OnOrientationChanged);
            Messenger.Default.Register<LoadingMessage>(this, OnLoading);
		}
Beispiel #26
0
        public MoreViewModel(IBaconProvider baconProvider, IEnumerable<string> ids, string targetName, string subreddit, Action<IEnumerable<string>, List<ViewModelBase>, ViewModelBase, ViewModelBase> loadMore, CommentViewModel parent, int depth, bool oddNesting)
        {
            _loadMore = loadMore;
            _parent = parent;
            _ids = ids;
            _targetName = targetName;
            _subreddit = subreddit;
			Depth = depth;
            Count = _ids.Count();
			OddNesting = oddNesting;
            //TODO use the targetname to determine the kind for now its always going to be comments but
            //that might change in the future
            Kind = "comment";

            _triggerLoad = new RelayCommand(TriggerLoadImpl);
        }
        public RedditViewModel(IBaconProvider baconProvider)
        {
            _baconProvider = baconProvider;
            _redditService = baconProvider.GetService<IRedditService>();
            _dynamicViewLocator = baconProvider.GetService<IDynamicViewLocator>();
            _navigationService = baconProvider.GetService<INavigationService>();
            _userService = baconProvider.GetService<IUserService>();
            _liveTileService = baconProvider.GetService<ILiveTileService>();
            _offlineService = baconProvider.GetService<IOfflineService>();
            _settingsService = baconProvider.GetService<ISettingsService>();

            MessengerInstance.Register<UserLoggedInMessage>(this, OnUserLoggedIn);
            MessengerInstance.Register<ConnectionStatusMessage>(this, OnConnectionStatusChanged);
            MessengerInstance.Register<SelectSubredditMessage>(this, OnSubredditChanged);
			MessengerInstance.Register<RefreshSubredditMessage>(this, OnSubredditRefreshed);
            MessengerInstance.Register<SettingsChangedMessage>(this, OnSettingsChanged);
            IsTemporary = false;
        }
        public static void Initialize(IBaconProvider baconProvider)
        {
            if (_baconProvider == null)
            {
                _baconProvider = baconProvider;

                //ensure we exist
                ServiceLocator.Current.GetInstance<RedditViewModel>();
                ServiceLocator.Current.GetInstance<LinkedWebViewModel>();
                ServiceLocator.Current.GetInstance<LoginViewModel>();
                ServiceLocator.Current.GetInstance<AboutUserViewModel>();
                ServiceLocator.Current.GetInstance<FileOpenPickerViewModel>();
                ServiceLocator.Current.GetInstance<SearchResultsViewModel>();
                ServiceLocator.Current.GetInstance<ContentPreferencesViewModel>();
                ServiceLocator.Current.GetInstance<RedditPickerViewModel>();
                ServiceLocator.Current.GetInstance<SearchQueryViewModel>();
                SimpleIoc.Default.Register<IDynamicViewLocator>(() => _baconProvider.GetService<IDynamicViewLocator>());
            }
        }
        public ComposeViewModel(IBaconProvider baconProvider, MessageViewModel replyMessage = null)
        {
            _baconProvider = baconProvider;
            _userService = baconProvider.GetService<IUserService>();
            _redditService = baconProvider.GetService<IRedditService>();
            _navigationService = baconProvider.GetService<INavigationService>();
            _dynamicViewLocator = baconProvider.GetService<IDynamicViewLocator>();
            _notificationService = baconProvider.GetService<INotificationService>();
            _refreshUser = new RelayCommand(RefreshUserImpl);
            _send = new RelayCommand(SendImpl);

            RefreshUserImpl();

            if (replyMessage != null)
            {
                IsReply = true;
                _replyMessage = replyMessage;
                _subject = _replyMessage.Subject;
                _recipient = _replyMessage.Author;
            }
        }
		public MainPageViewModel(IBaconProvider baconProvider)
        {
            _baconProvider = baconProvider;
            _redditService = baconProvider.GetService<IRedditService>();
            _dynamicViewLocator = baconProvider.GetService<IDynamicViewLocator>();
            _navigationService = baconProvider.GetService<INavigationService>();
            _userService = baconProvider.GetService<IUserService>();
            _liveTileService = baconProvider.GetService<ILiveTileService>();
            _offlineService = baconProvider.GetService<IOfflineService>();
            _settingsService = baconProvider.GetService<ISettingsService>();
			_notificationService = baconProvider.GetService<INotificationService>();

			MessengerInstance.Register<UserLoggedInMessage>(this, OnUserLoggedIn);
            MessengerInstance.Register<SelectSubredditMessage>(this, OnSubredditChanged);
			MessengerInstance.Register<SelectTemporaryRedditMessage>(this, OnSelectTemporarySubreddit);
			MessengerInstance.Register<CloseSubredditMessage>(this, OnCloseSubreddit);
			MessengerInstance.Register<ReorderSubredditMessage>(this, OnReorderSubreddit);
			MessengerInstance.Register<SettingsChangedMessage>(this, OnSettingsChanged);

			_subreddits = new ObservableCollection<TypedThing<Subreddit>>();

            _pivotItems = new RedditViewModelCollection();
        }