public ProfileViewerWindow(string username, IDevRantClient api) { InitializeComponent(); vm = new ProfileViewerWindowViewModel(username, this, api); DataContext = vm; }
public NotificationsChecker(IDataStore ds, IDevRantClient api) { this.ds = ds; this.api = api; Notifications = new ObservableCollection <ViewModels.Notification>(); }
public ProfileViewerWindowViewModel(string username, ProfileViewerWindow profileViewerWindow, IDevRantClient api) { this.username = username; this.window = profileViewerWindow; this.api = api; LoadSection(0); }
public static void Initialize(IDevRantClient api, DataStore.IDataStore settings, DataStore.IPersistentDataStore db) { instance = new AppManager() { API = api, Settings = settings, DB = db }; }
public OptionsWindow(IDataStore ds, IDevRantClient api) { vm = new OptionsWindowViewModel(ds, api, this); DataContext = vm; InitializeComponent(); SetUsernamePassword(ds.GetLoginInfo()); }
public RantViewerViewModel(Window window, Rant rant, IDevRantClient api, Action <string> onScroll) { Rant = rant; this.api = api; this.window = window; this.onScroll = onScroll; Comments = new ObservableCollection <Comment>(); GetComments(); }
public OptionsWindowViewModel(IDataStore ds, IDevRantClient api, Window window) { this.ds = ds; this.api = api; this.window = window; Cancelled = true; InitializeValues(); }
public EditPostWindowViewModel(Window window, EditPostWindow.Type type, Draft existing = null, Commentable parent = null, FeedItem edit = null) { this.window = window; this.api = AppManager.Instance.API; this.db = AppManager.Instance.DB; this.type = type; this.existing = existing; this.parent = parent; this.editing = edit; Cancelled = true; if (parent != null) { mode = Mode.NewComment; ViewModels.Comment comment = parent as ViewModels.Comment; if (comment != null) { if (AppManager.Instance.API.User.LoggedInUser != comment.Username) { Text = "@" + comment.Username + " "; } } } else if (existing != null) { mode = Mode.EditDraft; Text = existing.Text; TagsString = existing.Tags; ImagePath = existing.ImagePath; } else if (edit != null) { mode = Mode.EditExisting; var r = edit.AsRant(); var comment = edit.AsComment(); if (r != null) { Text = r.Text; TagsString = r.TagsString; } else if (comment != null) { Text = comment.Text; } else { throw new NotSupportedException(); } } }
public RantViewerWindow(Rant rant, IDevRantClient api) { InitializeComponent(); vm = new RantViewerViewModel(this, rant, api, Scroll); DataContext = vm; scroller = new ScrollHandler(ScrollViewer); //TODO: Check if this works Top = 10; Left = Utilities.GetLeft(Width); //ScrollViewer.Focus(); }
internal static async Task <bool> OpenFeedItem(FeedItem item, IDevRantClient api, Window owner) { if (item is ViewModels.Notification) { var notif = item.AsNotification(); var raw = await api.GetRant(notif.RantId); item = new ViewModels.Rant(raw); } else if (item is ViewModels.Comment) { var raw = await api.GetRant(item.AsComment().RantId); item = new ViewModels.Rant(raw); } if (item is ViewModels.Rant) { var rant = item.AsRant(); if (rant.CanAnimate == Visibility.Visible) //TODO: should be bool { string url = GetRantUrl(rant.RantId); Process.Start(url); } else { Window dlg; dlg = new RantViewerWindow((ViewModels.Rant)item, api); dlg.Owner = owner; dlg.ShowDialog(); } } else if (item is ViewModels.Collab) { string url = GetRantUrl(item.AsCollab().RantId); Process.Start(url); } else { return(false); } return(true); }
public static EditPostWindow CreateForEdit(IDevRantClient api, FeedItem existing) { var window = new EditPostWindow(existing); return(window); }
public static EditPostWindow CreateForComment(IDevRantClient api, Commentable parent) { var window = new EditPostWindow(Type.Comment, parent: parent); return(window); }
public static EditPostWindow CreateForComment(IDevRantClient api, long rantId) { Commentable dummy = new ViewModels.DummyCommentable(rantId); return(CreateForComment(api, dummy)); }
public FollowedUserChecker(IDataStore ds, IDevRantClient api, IPersistentDataStore history) { this.ds = ds; this.api = api; this.history = history; }
/// <summary> /// Casts a vote /// </summary> /// <param name="args"></param> /// <param name="api">API to use to vote</param> /// <param name="db">Optional DB to mark as Read</param> /// <returns>Throws exception on errors</returns> public static async Task Vote(ButtonClickedEventArgs args, IDevRantClient api, IPersistentDataStore db = null) { Vote vote = null; Votable votable = args.SelectedItem as Votable; if (votable.Voted == VoteState.Disabled) { return; } if (votable != null) { switch (args.Type) { case ButtonType.Down: if (votable.Voted == VoteState.Down) { vote = Dtos.Vote.ClearVote(); } else { var dlg = new DownvoteReasonWindow(); dlg.Topmost = true; dlg.ShowDialog(); if (dlg.Reason != null) { vote = Dtos.Vote.DownVote(dlg.Reason.Value); } else { return; } } break; case ButtonType.Up: if (votable.Voted == VoteState.Up) { vote = Dtos.Vote.ClearVote(); } else { vote = Dtos.Vote.UpVote(); } break; } FeedItem item = args.SelectedItem as FeedItem; switch (args.SelectedItem.Type) { case FeedItem.FeedItemType.Post: var rant = item.AsRant(); var r1 = await api.User.VoteRant(rant.ID, vote); rant.Update(r1); rant.Read = true; if (db != null) { db.MarkRead(rant.ID); } break; case FeedItem.FeedItemType.Collab: var collab = item.AsCollab(); var r2 = await api.User.VoteCollab(collab.ID, vote); collab.Update(r2); break; case FeedItem.FeedItemType.Comment: var comment = item.AsComment(); var r3 = await api.User.VoteComment(comment.ID, vote); comment.Update(r3); break; } args.InvokeCallback(); } }