コード例 #1
0
        /// <summary>
        /// Comment on a specific rant using the RantSelector
        /// </summary>
        private async void ViewSpecificRant()
        {
            var rantSelector = new IDInputWindow(IDInputWindowViewModel.Type.Rant);

            rantSelector.Owner = window;

            rantSelector.ShowDialog();

            if (!string.IsNullOrEmpty(rantSelector.InputValue))
            {
                try
                {
                    Dtos.Rant rant = await api.GetRant(Convert.ToInt64(rantSelector.InputValue));

                    var dlg = new RantViewerWindow(new ViewModels.Rant(rant), api);
                    dlg.Owner = window;

                    dlg.ShowDialog();
                }
                catch (Exception e)
                {
                    MessageBoxFactory.ShowError(e);
                }
            }
        }
コード例 #2
0
        private async void SurpriseMe()
        {
            window.SetIsEnabled(false);

            try
            {
                UpdateStatus("Finding random rant...");

                acceptorTries = 0; //Reset counter
                Dtos.Rant rant = await api.SurpriseMe(acceptRant);

                UpdateStatus("Done, after " + acceptorTries + " tries.");

                var dlg = new RantViewerWindow(new ViewModels.Rant(rant), api);
                dlg.Owner = window;

                dlg.ShowDialog();

                if (db != null)
                {
                    db.MarkRead(rant.Id);
                }
            }
            catch (Exception e)
            {
                //MessageBoxFactory.ShowError(e);
                UpdateStatus("Error: " + e.Message);
            }
            finally
            {
                window.SetIsEnabled(true);
            }
        }
コード例 #3
0
ファイル: Utilities.cs プロジェクト: gitpushdev/devrant
        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);
        }