{
public partial class TweetDetailsView : UserControl
{
- public TweenMain Owner { get; set; } = null!;
+ private TweenMain Owner
+ => this.owner ?? throw this.NotInitializedException();
/// <summary>プロフィール画像のキャッシュ</summary>
- public ImageCache IconCache { get; set; } = null!;
+ private ImageCache IconCache
+ => this.iconCache ?? throw this.NotInitializedException();
/// <summary><see cref="PostClass"/> のダンプを表示するか</summary>
public bool DumpPostClass { get; set; }
/// <summary>現在表示中の発言</summary>
public PostClass? CurrentPost { get; private set; }
+ public ThemeManager Theme
+ {
+ get => this.themeManager ?? throw this.NotInitializedException();
+ set => this.themeManager = value;
+ }
+
[DefaultValue(false)]
public new bool TabStop
{
/// <summary><see cref="ContextMenuPostBrowser"/> 展開時の <see cref="PostBrowser"/>.StatusText を保持するフィールド</summary>
private string postBrowserStatusText = "";
+ private TweenMain? owner;
+ private ImageCache? iconCache;
+ private ThemeManager? themeManager;
+
public TweetDetailsView()
{
this.InitializeComponent();
this.PostBrowser.AllowWebBrowserDrop = false; // COMException を回避するため、ActiveX の初期化が終わってから設定する
}
+ public void Initialize(TweenMain owner, ImageCache iconCache, ThemeManager themeManager)
+ {
+ this.owner = owner;
+ this.iconCache = iconCache;
+ this.themeManager = themeManager;
+ }
+
+ private Exception NotInitializedException()
+ => new InvalidOperationException("Cannot call before initialization");
+
public void ClearPostBrowser()
=> this.PostBrowser.DocumentText = this.Owner.CreateDetailHtml("");
}
var nameForeColor = SystemColors.ControlText;
- if (post.IsOwl && (SettingManager.Common.OneWayLove || post.IsDm))
- nameForeColor = SettingManager.Local.ColorOWL;
+ if (post.IsOwl && (SettingManager.Instance.Common.OneWayLove || post.IsDm))
+ nameForeColor = this.Theme.ColorOWL;
if (post.RetweetedId != null)
- nameForeColor = SettingManager.Local.ColorRetweet;
+ nameForeColor = this.Theme.ColorRetweet;
if (post.IsFav)
- nameForeColor = SettingManager.Local.ColorFav;
+ nameForeColor = this.Theme.ColorFav;
this.AuthorNameLinkLabel.LinkColor = nameForeColor;
this.AuthorNameLinkLabel.ActiveLinkColor = nameForeColor;
if (tags.Count > 0)
{
if (forward)
- tags[0].ScrollTop += SettingManager.Local.FontDetail.Height;
+ tags[0].ScrollTop += this.Theme.FontDetail.Height;
else
- tags[0].ScrollTop -= SettingManager.Local.FontDetail.Height;
+ tags[0].ScrollTop -= this.Theme.FontDetail.Height;
}
}
if (tags.Count > 0)
{
if (forward)
- tags[0].ScrollTop += this.PostBrowser.ClientRectangle.Height - SettingManager.Local.FontDetail.Height;
+ tags[0].ScrollTop += this.PostBrowser.ClientRectangle.Height - this.Theme.FontDetail.Height;
else
- tags[0].ScrollTop -= this.PostBrowser.ClientRectangle.Height - SettingManager.Local.FontDetail.Height;
+ tags[0].ScrollTop -= this.PostBrowser.ClientRectangle.Height - this.Theme.FontDetail.Height;
}
}
.ToArray();
}
- private async Task SetUserPictureAsync(string imageUrl, bool force = false)
+ private async Task SetUserPictureAsync(string normalImageUrl, bool force = false)
{
- if (MyCommon.IsNullOrEmpty(imageUrl))
+ if (MyCommon.IsNullOrEmpty(normalImageUrl))
return;
if (this.IconCache == null)
this.ClearUserPicture();
- await this.UserPicture.SetImageFromTask(async () =>
+ var imageSize = Twitter.DecideProfileImageSize(this.UserPicture.Width);
+ var cachedImage = this.IconCache.TryGetLargerOrSameSizeFromCache(normalImageUrl, imageSize);
+ if (cachedImage != null)
{
- var image = await this.IconCache.DownloadImageAsync(imageUrl, force)
- .ConfigureAwait(false);
+ // 既にキャッシュされていればそれを表示して終了
+ this.UserPicture.Image = cachedImage.Clone();
+ return;
+ }
+
+ // 小さいサイズの画像がキャッシュにある場合は高解像度の画像が取得できるまでの間表示する
+ var fallbackImage = this.IconCache.TryGetLargerOrSameSizeFromCache(normalImageUrl, "mini");
+ if (fallbackImage != null)
+ this.UserPicture.Image = fallbackImage.Clone();
+
+ await this.UserPicture.SetImageFromTask(
+ async () =>
+ {
+ var imageUrl = Twitter.CreateProfileImageUrl(normalImageUrl, imageSize);
+ var image = await this.IconCache.DownloadImageAsync(imageUrl, force)
+ .ConfigureAwait(false);
- return await image.CloneAsync()
- .ConfigureAwait(false);
- });
+ return image.Clone();
+ },
+ useStatusImage: false
+ );
}
/// <summary>
{
var translatedText = await bing.TranslateAsync(str,
langFrom: null,
- langTo: SettingManager.Common.TranslateLanguage);
+ langTo: SettingManager.Instance.Common.TranslateLanguage);
this.PostBrowser.DocumentText = this.Owner.CreateDetailHtml(translatedText);
}
var searchOptions = new SearchWordDialog.SearchOptions(
SearchWordDialog.SearchType.Timeline,
selText,
- newTab: false,
- caseSensitive: false,
- useRegex: false);
+ NewTab: false,
+ CaseSensitive: false,
+ UseRegex: false
+ );
this.Owner.SearchDialog.ResultOptions = searchOptions;