示例#1
0
        public ComposeForm(ApiClient ac, Types.Status inReplyTo)
            : this(ac)
        {
            Text = "Compose Reply";

            var actual = inReplyTo.ReblogOrSelf();
            _inReplyTo = inReplyTo;
            Visibility = actual.Visibility;
            // TODO: remove ourselves as a mention
            var actualMentions = actual.Mentions
                                 .Where(x => x.AccountId != actual.Account.AccountId);
            contentBox.Text = string.Join(" ", actualMentions
                                          .Select(x => x.ToString()).ToArray());
            cwBox.Text = actual.ContentWarning;
        }
示例#2
0
        public void SetForUI(Types.Status status)
        {
            var toUse = status.ReblogOrSelf();

            metaListView.Items.Clear();
            if (status.Reblog != null)
            {
                AddMeta("Boost from", status.Account);
                AddMeta("Boost date", status.CreatedAt);
            }
            if (toUse.ReblogCount > 0)
            {
                AddMeta("Boosts", toUse.ReblogCount);
            }

            AddMeta("From", toUse.Account);
            AddMeta("Date", toUse.CreatedAt);

            AddMeta("Visibility", toUse.Visibility);

            if (toUse.FavouriteCount > 0)
            {
                AddMeta("Favourites", toUse.FavouriteCount);
            }
            if (!string.IsNullOrEmpty(toUse.ContentWarning))
            {
                AddMeta("Spoiler", toUse.ContentWarning);
            }
            if (toUse.Application != null)
            {
                AddMeta("Application", toUse.Application);
            }
            if (toUse.Pinned.HasValue && toUse.Pinned.Value)
            {
                AddMeta("Pinned", "Yes");
            }
            if (!string.IsNullOrEmpty(toUse.Language))
            {
                AddMeta("Language", toUse.Language);
            }

            favMenuItem.Checked   = toUse.HasFavourited.HasValue ? toUse.HasFavourited.Value : false;
            boostMenuItem.Checked = toUse.HasReblogged.HasValue ? toUse.HasReblogged.Value : false;

            foreach (var mention in toUse.Mentions)
            {
                AddMeta("Mentions", mention);
            }
            foreach (var tag in toUse.Tags)
            {
                AddMeta("Hashtag", tag);
            }

            // Attachments
            if (toUse.Attachments.Count > 0)
            {
                attachmentsBox.BeginUpdate();
                attachmentsBox.Items.Clear();
                foreach (var attachment in toUse.Attachments)
                {
                    attachmentsBox.Items.Add(attachment);
                }
                attachmentsBox.EndUpdate();
                attachmentsBox.ItemWidth = -1;
            }
            attachmentsPage.Text = string.Format("Attachments ({0})", toUse.Attachments.Count);

            // Thread
            try
            {
                threadBox.BeginUpdate();

                var contextJson = _ac.Get(FormatStatusRoute("context"));
                var context     = JsonUtility.MaybeDeserialize <Types.Context>(contextJson);

                threadBox.Items.Clear();
                foreach (var s in context.Ancestors.Concat(context.Descendants))
                {
                    threadBox.Items.Add(s);
                }
            }
            catch (Exception e)
            {
                ErrorDispatcher.ShowError(e, "Reconstructing Thread");
            }
            finally
            {
                threadBox.EndUpdate();
                threadBox.ItemWidth = -1;
                threadPage.Text     = string.Format("Thread ({0})", threadBox.Items.Count);
            }

            keyHeader.Width   = -1;
            valueHeader.Width = -1;

            // include emojis and cap their size (otherwise they render full
            // size and we definitely are NOT hidpi
            var content = HtmlUtility.StatusContentsRenderingEmoji(toUse, 16);

            webBrowser1.DocumentText = content;
        }
示例#3
0
        string FormatStatusRoute(string statusEndpoint, bool useReblogged)
        {
            var status = useReblogged ? _status.ReblogOrSelf() : _status;

            return(string.Format(STATUS_ROUTE_TEMPLATE, status.Id, statusEndpoint));
        }