throw new InvalidOperationException("Err:Can't attach multiple media to DM.");
var mediaItem = mediaItems[0];
-
- string mediaCategory;
- switch (mediaItem.Extension)
+ var mediaCategory = mediaItem.Extension switch
{
- case ".gif":
- mediaCategory = "dm_gif";
- break;
- default:
- mediaCategory = "dm_image";
- break;
- }
+ ".gif" => "dm_gif",
+ _ => "dm_image",
+ };
var mediaId = await this.UploadMediaItem(mediaItems[0], mediaCategory)
.ConfigureAwait(false);
buttonRuleToggleEnabled.Enabled = false;
}
- switch (tab.TabType)
- {
- case MyCommon.TabUsageType.Home:
- LabelTabType.Text = Properties.Resources.TabUsageTypeName_Home;
- break;
- case MyCommon.TabUsageType.Mentions:
- LabelTabType.Text = Properties.Resources.TabUsageTypeName_Mentions;
- break;
- case MyCommon.TabUsageType.DirectMessage:
- LabelTabType.Text = Properties.Resources.TabUsageTypeName_DirectMessage;
- break;
- case MyCommon.TabUsageType.Favorites:
- LabelTabType.Text = Properties.Resources.TabUsageTypeName_Favorites;
- break;
- case MyCommon.TabUsageType.UserDefined:
- LabelTabType.Text = Properties.Resources.TabUsageTypeName_UserDefined;
- break;
- case MyCommon.TabUsageType.PublicSearch:
- LabelTabType.Text = Properties.Resources.TabUsageTypeName_PublicSearch;
- break;
- case MyCommon.TabUsageType.Lists:
- LabelTabType.Text = Properties.Resources.TabUsageTypeName_Lists;
- break;
- case MyCommon.TabUsageType.Related:
- LabelTabType.Text = Properties.Resources.TabUsageTypeName_Related;
- break;
- case MyCommon.TabUsageType.UserTimeline:
- LabelTabType.Text = Properties.Resources.TabUsageTypeName_UserTimeline;
- break;
- case MyCommon.TabUsageType.Mute:
- LabelTabType.Text = "Mute";
- break;
- case MyCommon.TabUsageType.SearchResults:
- LabelTabType.Text = "SearchResults";
- break;
- default:
- LabelTabType.Text = "UNKNOWN";
- break;
- }
+ this.LabelTabType.Text = tab.TabType switch
+ {
+ MyCommon.TabUsageType.Home => Properties.Resources.TabUsageTypeName_Home,
+ MyCommon.TabUsageType.Mentions => Properties.Resources.TabUsageTypeName_Mentions,
+ MyCommon.TabUsageType.DirectMessage => Properties.Resources.TabUsageTypeName_DirectMessage,
+ MyCommon.TabUsageType.Favorites => Properties.Resources.TabUsageTypeName_Favorites,
+ MyCommon.TabUsageType.UserDefined => Properties.Resources.TabUsageTypeName_UserDefined,
+ MyCommon.TabUsageType.PublicSearch => Properties.Resources.TabUsageTypeName_PublicSearch,
+ MyCommon.TabUsageType.Lists => Properties.Resources.TabUsageTypeName_Lists,
+ MyCommon.TabUsageType.Related => Properties.Resources.TabUsageTypeName_Related,
+ MyCommon.TabUsageType.UserTimeline => Properties.Resources.TabUsageTypeName_UserTimeline,
+ MyCommon.TabUsageType.Mute => "Mute",
+ MyCommon.TabUsageType.SearchResults => "SearchResults",
+ _ => "UNKNOWN",
+ };
+
ButtonRenameTab.Enabled = true;
if (tab.IsDefaultTabType || tab.Protected)
{
public void Notify(NotifyType notificationType, string id, string title, string text, Image? icon = null, string url = "")
{
if (!_initialized) return;
- var notificationName = "";
- switch (notificationType)
+
+ var notificationName = notificationType switch
{
- case NotifyType.Reply:
- notificationName = "REPLY";
- break;
- case NotifyType.DirectMessage:
- notificationName = "DIRECT_MESSAGE";
- break;
- case NotifyType.Notify:
- notificationName = "NOTIFY";
- break;
- case NotifyType.UserStreamEvent:
- notificationName = "USERSTREAM_EVENT";
- break;
- }
+ NotifyType.Reply => "REPLY",
+ NotifyType.DirectMessage => "DIRECT_MESSAGE",
+ NotifyType.Notify => "NOTIFY",
+ NotifyType.UserStreamEvent => "USERSTREAM_EVENT",
+ _ => "",
+ };
+
object? n;
if (icon != null || !string.IsNullOrEmpty(url))
{
private void ComboUsage_SelectedIndexChanged(object sender, EventArgs e)
{
- switch (ComboUsage.SelectedIndex)
+ this.Usage = ComboUsage.SelectedIndex switch
{
- case 0:
- this.Usage = MyCommon.TabUsageType.UserDefined;
- break;
- case 1:
- this.Usage = MyCommon.TabUsageType.Lists;
- break;
- case 2:
- this.Usage = MyCommon.TabUsageType.PublicSearch;
- break;
- default:
- this.Usage = MyCommon.TabUsageType.Undefined;
- break;
- }
+ 0 => MyCommon.TabUsageType.UserDefined,
+ 1 => MyCommon.TabUsageType.Lists,
+ 2 => MyCommon.TabUsageType.PublicSearch,
+ _ => MyCommon.TabUsageType.Undefined,
+ };
}
}
}
public static void SetProxy(ProxyType pType, string host, int port)
{
- string? proxy = null;
- switch (pType)
+ var proxy = pType switch
{
- case ProxyType.IE:
- proxy = null;
- break;
- case ProxyType.None:
- proxy = "";
- break;
- case ProxyType.Specified:
- proxy = host + (port > 0 ? ":" + port : "");
- break;
- }
+ ProxyType.IE => null,
+ ProxyType.None => "",
+ ProxyType.Specified => host + (port > 0 ? ":" + port : ""),
+ _ => null,
+ };
RefreshProxySettings(proxy);
}
#endregion
public void LoadConfig(SettingCommon settingCommon)
{
- switch (settingCommon.NameBalloon)
+ this.cmbNameBalloon.SelectedIndex = settingCommon.NameBalloon switch
{
- case MyCommon.NameBalloonEnum.None:
- this.cmbNameBalloon.SelectedIndex = 0;
- break;
- case MyCommon.NameBalloonEnum.UserID:
- this.cmbNameBalloon.SelectedIndex = 1;
- break;
- case MyCommon.NameBalloonEnum.NickName:
- this.cmbNameBalloon.SelectedIndex = 2;
- break;
- }
-
+ MyCommon.NameBalloonEnum.None => 0,
+ MyCommon.NameBalloonEnum.UserID => 1,
+ MyCommon.NameBalloonEnum.NickName => 2,
+ _ => 2,
+ };
this.CheckDispUsername.Checked = settingCommon.DispUsername;
-
- switch (settingCommon.DispLatestPost)
+ this.ComboDispTitle.SelectedIndex = settingCommon.DispLatestPost switch
{
- case MyCommon.DispTitleEnum.None:
- this.ComboDispTitle.SelectedIndex = 0;
- break;
- case MyCommon.DispTitleEnum.Ver:
- this.ComboDispTitle.SelectedIndex = 1;
- break;
- case MyCommon.DispTitleEnum.Post:
- this.ComboDispTitle.SelectedIndex = 2;
- break;
- case MyCommon.DispTitleEnum.UnreadRepCount:
- this.ComboDispTitle.SelectedIndex = 3;
- break;
- case MyCommon.DispTitleEnum.UnreadAllCount:
- this.ComboDispTitle.SelectedIndex = 4;
- break;
- case MyCommon.DispTitleEnum.UnreadAllRepCount:
- this.ComboDispTitle.SelectedIndex = 5;
- break;
- case MyCommon.DispTitleEnum.UnreadCountAllCount:
- this.ComboDispTitle.SelectedIndex = 6;
- break;
- case MyCommon.DispTitleEnum.OwnStatus:
- this.ComboDispTitle.SelectedIndex = 7;
- break;
- }
-
+ MyCommon.DispTitleEnum.None => 0,
+ MyCommon.DispTitleEnum.Ver => 1,
+ MyCommon.DispTitleEnum.Post => 2,
+ MyCommon.DispTitleEnum.UnreadRepCount => 3,
+ MyCommon.DispTitleEnum.UnreadAllCount => 4,
+ MyCommon.DispTitleEnum.UnreadAllRepCount => 5,
+ MyCommon.DispTitleEnum.UnreadCountAllCount => 6,
+ MyCommon.DispTitleEnum.OwnStatus => 7,
+ _ => 2,
+ };
this.CheckAlwaysTop.Checked = settingCommon.AlwaysTop;
this.CheckBalloonLimit.Checked = settingCommon.LimitBalloon;
this.chkTabIconDisp.Checked = settingCommon.TabIconDisp;
this.CheckMonospace.Checked = settingCommon.IsMonospace;
this.CheckPreviewEnable.Checked = settingCommon.PreviewEnable;
this.CheckStatusAreaAtBottom.Checked = settingCommon.StatusAreaAtBottom;
-
- switch (settingCommon.ReplyIconState)
+ this.ReplyIconStateCombo.SelectedIndex = settingCommon.ReplyIconState switch
{
- case MyCommon.REPLY_ICONSTATE.None:
- this.ReplyIconStateCombo.SelectedIndex = 0;
- break;
- case MyCommon.REPLY_ICONSTATE.StaticIcon:
- this.ReplyIconStateCombo.SelectedIndex = 1;
- break;
- case MyCommon.REPLY_ICONSTATE.BlinkIcon:
- this.ReplyIconStateCombo.SelectedIndex = 2;
- break;
- }
-
- switch (settingCommon.Language)
+ MyCommon.REPLY_ICONSTATE.None => 0,
+ MyCommon.REPLY_ICONSTATE.StaticIcon => 1,
+ MyCommon.REPLY_ICONSTATE.BlinkIcon => 2,
+ _ => 1,
+ };
+ this.LanguageCombo.SelectedIndex = settingCommon.Language switch
{
- case "OS":
- this.LanguageCombo.SelectedIndex = 0;
- break;
- case "ja":
- this.LanguageCombo.SelectedIndex = 1;
- break;
- case "en":
- this.LanguageCombo.SelectedIndex = 2;
- break;
- default:
- this.LanguageCombo.SelectedIndex = 0;
- break;
- }
-
+ "OS" => 0,
+ "ja" => 1,
+ "en" => 2,
+ _ => 0,
+ };
this.ChkNewMentionsBlink.Checked = settingCommon.BlinkNewMentions;
this.IsNotifyUseGrowlCheckBox.Checked = settingCommon.IsUseNotifyGrowl;
this.IsNotifyUseGrowlCheckBox.Enabled = GrowlHelper.IsDllExists;
public void SaveConfig(SettingCommon settingCommon)
{
- switch (this.cmbNameBalloon.SelectedIndex)
+ settingCommon.NameBalloon = this.cmbNameBalloon.SelectedIndex switch
{
- case 0:
- settingCommon.NameBalloon = MyCommon.NameBalloonEnum.None;
- break;
- case 1:
- settingCommon.NameBalloon = MyCommon.NameBalloonEnum.UserID;
- break;
- case 2:
- settingCommon.NameBalloon = MyCommon.NameBalloonEnum.NickName;
- break;
- }
-
+ 0 => MyCommon.NameBalloonEnum.None,
+ 1 => MyCommon.NameBalloonEnum.UserID,
+ 2 => MyCommon.NameBalloonEnum.NickName,
+ _ => throw new IndexOutOfRangeException(),
+ };
settingCommon.DispUsername = this.CheckDispUsername.Checked;
-
- switch (this.ComboDispTitle.SelectedIndex)
+ settingCommon.DispLatestPost = this.ComboDispTitle.SelectedIndex switch
{
- case 0: // None
- settingCommon.DispLatestPost = MyCommon.DispTitleEnum.None;
- break;
- case 1: // Ver
- settingCommon.DispLatestPost = MyCommon.DispTitleEnum.Ver;
- break;
- case 2: // Post
- settingCommon.DispLatestPost = MyCommon.DispTitleEnum.Post;
- break;
- case 3: // RepCount
- settingCommon.DispLatestPost = MyCommon.DispTitleEnum.UnreadRepCount;
- break;
- case 4: // AllCount
- settingCommon.DispLatestPost = MyCommon.DispTitleEnum.UnreadAllCount;
- break;
- case 5: // Rep+All
- settingCommon.DispLatestPost = MyCommon.DispTitleEnum.UnreadAllRepCount;
- break;
- case 6: // Unread/All
- settingCommon.DispLatestPost = MyCommon.DispTitleEnum.UnreadCountAllCount;
- break;
- case 7: // Count of Status/Follow/Follower
- settingCommon.DispLatestPost = MyCommon.DispTitleEnum.OwnStatus;
- break;
- }
-
+ 0 => MyCommon.DispTitleEnum.None,
+ 1 => MyCommon.DispTitleEnum.Ver,
+ 2 => MyCommon.DispTitleEnum.Post,
+ 3 => MyCommon.DispTitleEnum.UnreadRepCount,
+ 4 => MyCommon.DispTitleEnum.UnreadAllCount,
+ 5 => MyCommon.DispTitleEnum.UnreadAllRepCount,
+ 6 => MyCommon.DispTitleEnum.UnreadCountAllCount,
+ 7 => MyCommon.DispTitleEnum.OwnStatus,
+ _ => throw new IndexOutOfRangeException(),
+ };
settingCommon.AlwaysTop = this.CheckAlwaysTop.Checked;
settingCommon.LimitBalloon = this.CheckBalloonLimit.Checked;
settingCommon.TabIconDisp = this.chkTabIconDisp.Checked;
settingCommon.IsMonospace = this.CheckMonospace.Checked;
settingCommon.PreviewEnable = this.CheckPreviewEnable.Checked;
settingCommon.StatusAreaAtBottom = this.CheckStatusAreaAtBottom.Checked;
-
- switch (this.ReplyIconStateCombo.SelectedIndex)
+ settingCommon.ReplyIconState = this.ReplyIconStateCombo.SelectedIndex switch
{
- case 0:
- settingCommon.ReplyIconState = MyCommon.REPLY_ICONSTATE.None;
- break;
- case 1:
- settingCommon.ReplyIconState = MyCommon.REPLY_ICONSTATE.StaticIcon;
- break;
- case 2:
- settingCommon.ReplyIconState = MyCommon.REPLY_ICONSTATE.BlinkIcon;
- break;
- }
-
- switch (this.LanguageCombo.SelectedIndex)
+ 0 => MyCommon.REPLY_ICONSTATE.None,
+ 1 => MyCommon.REPLY_ICONSTATE.StaticIcon,
+ 2 => MyCommon.REPLY_ICONSTATE.BlinkIcon,
+ _ => throw new IndexOutOfRangeException(),
+ };
+ settingCommon.Language = this.LanguageCombo.SelectedIndex switch
{
- case 0:
- settingCommon.Language = "OS";
- break;
- case 1:
- settingCommon.Language = "ja";
- break;
- case 2:
- settingCommon.Language = "en";
- break;
- default:
- settingCommon.Language = "en";
- break;
- }
-
+ 0 => "OS",
+ 1 => "ja",
+ 2 => "en",
+ _ => "en",
+ };
settingCommon.BlinkNewMentions = this.ChkNewMentionsBlink.Checked;
settingCommon.IsUseNotifyGrowl = this.IsNotifyUseGrowlCheckBox.Checked;
}
public void LoadConfig(SettingCommon settingCommon)
{
- switch (settingCommon.IconSize)
+ this.IconSize.SelectedIndex = settingCommon.IconSize switch
{
- case MyCommon.IconSizes.IconNone:
- this.IconSize.SelectedIndex = 0;
- break;
- case MyCommon.IconSizes.Icon16:
- this.IconSize.SelectedIndex = 1;
- break;
- case MyCommon.IconSizes.Icon24:
- this.IconSize.SelectedIndex = 2;
- break;
- case MyCommon.IconSizes.Icon48:
- this.IconSize.SelectedIndex = 3;
- break;
- case MyCommon.IconSizes.Icon48_2:
- this.IconSize.SelectedIndex = 4;
- break;
- }
-
+ MyCommon.IconSizes.IconNone => 0,
+ MyCommon.IconSizes.Icon16 => 1,
+ MyCommon.IconSizes.Icon24 => 2,
+ MyCommon.IconSizes.Icon48 => 3,
+ MyCommon.IconSizes.Icon48_2 => 4,
+ _ => 1,
+ };
this.OneWayLv.Checked = settingCommon.OneWayLove;
this.CheckSortOrderLock.Checked = settingCommon.SortOrderLock;
this.CheckViewTabBottom.Checked = settingCommon.ViewTabBottom;
public void SaveConfig(SettingCommon settingCommon)
{
- switch (this.IconSize.SelectedIndex)
+ settingCommon.IconSize = this.IconSize.SelectedIndex switch
{
- case 0:
- settingCommon.IconSize = MyCommon.IconSizes.IconNone;
- break;
- case 1:
- settingCommon.IconSize = MyCommon.IconSizes.Icon16;
- break;
- case 2:
- settingCommon.IconSize = MyCommon.IconSizes.Icon24;
- break;
- case 3:
- settingCommon.IconSize = MyCommon.IconSizes.Icon48;
- break;
- case 4:
- settingCommon.IconSize = MyCommon.IconSizes.Icon48_2;
- break;
- }
-
+ 0 => MyCommon.IconSizes.IconNone,
+ 1 => MyCommon.IconSizes.Icon16,
+ 2 => MyCommon.IconSizes.Icon24,
+ 3 => MyCommon.IconSizes.Icon48,
+ 4 => MyCommon.IconSizes.Icon48_2,
+ _ => throw new IndexOutOfRangeException($"Invalid {nameof(IconSize)} index: {this.IconSize.SelectedIndex}"),
+ };
settingCommon.OneWayLove = this.OneWayLv.Checked;
settingCommon.SortOrderLock = this.CheckSortOrderLock.Checked;
settingCommon.ViewTabBottom = this.CheckViewTabBottom.Checked;
try
{
- switch (shortenerType)
+ return shortenerType switch
{
- case MyCommon.UrlConverter.TinyUrl:
- return await this.ShortenByTinyUrlAsync(srcUri)
- .ConfigureAwait(false);
- case MyCommon.UrlConverter.Isgd:
- return await this.ShortenByIsgdAsync(srcUri)
- .ConfigureAwait(false);
- case MyCommon.UrlConverter.Bitly:
- return await this.ShortenByBitlyAsync(srcUri, "bit.ly")
- .ConfigureAwait(false);
- case MyCommon.UrlConverter.Jmp:
- return await this.ShortenByBitlyAsync(srcUri, "j.mp")
- .ConfigureAwait(false);
- case MyCommon.UrlConverter.Uxnu:
- return await this.ShortenByUxnuAsync(srcUri)
- .ConfigureAwait(false);
- default:
- throw new ArgumentException("Unknown shortener.", nameof(shortenerType));
- }
+ MyCommon.UrlConverter.TinyUrl => await this.ShortenByTinyUrlAsync(srcUri)
+ .ConfigureAwait(false),
+ MyCommon.UrlConverter.Isgd => await this.ShortenByIsgdAsync(srcUri)
+ .ConfigureAwait(false),
+ MyCommon.UrlConverter.Bitly => await this.ShortenByBitlyAsync(srcUri, "bit.ly")
+ .ConfigureAwait(false),
+ MyCommon.UrlConverter.Jmp => await this.ShortenByBitlyAsync(srcUri, "j.mp")
+ .ConfigureAwait(false),
+ MyCommon.UrlConverter.Uxnu => await this.ShortenByUxnuAsync(srcUri)
+ .ConfigureAwait(false),
+ _ => throw new ArgumentException("Unknown shortener.", nameof(shortenerType)),
+ };
}
catch (OperationCanceledException)
{
public static MapThumb GetDefaultInstance()
{
- Type classType;
-
var confValue = SettingManager.Common.MapThumbnailProvider;
- switch (confValue)
+ var classType = confValue switch
{
- case MapProvider.OpenStreetMap:
- classType = typeof(MapThumbOSM);
- break;
- case MapProvider.GoogleMaps:
- classType = typeof(MapThumbGoogle);
- break;
- default:
- throw new NotSupportedException("Map Provider '" + confValue + "' is not supported.");
- }
+ MapProvider.OpenStreetMap => typeof(MapThumbOSM),
+ MapProvider.GoogleMaps => typeof(MapThumbGoogle),
+ _ => throw new NotSupportedException($"Map Provider '{confValue}' is not supported."),
+ };
if (MapThumb.defaultInstance == null || MapThumb.defaultInstance.GetType() != classType)
{
ColumnOrgText[6] = "";
ColumnOrgText[7] = "Source";
- var c = 0;
- switch (_statuses.SortMode)
- {
- case ComparerMode.Nickname: //ニックネーム
- c = 1;
- break;
- case ComparerMode.Data: //本文
- c = 2;
- break;
- case ComparerMode.Id: //時刻=発言Id
- c = 3;
- break;
- case ComparerMode.Name: //名前
- c = 4;
- break;
- case ComparerMode.Source: //Source
- c = 7;
- break;
- }
+ var c = this._statuses.SortMode switch
+ {
+ ComparerMode.Nickname => 1, // ニックネーム
+ ComparerMode.Data => 2, // 本文
+ ComparerMode.Id => 3, // 時刻=発言Id
+ ComparerMode.Name => 4, // 名前
+ ComparerMode.Source => 7, // Source
+ _ => 0,
+ };
if (_iconCol)
{
catch (WebApiException ex)
{
this._myStatusError = true;
-
- string tabType;
- switch (tab)
- {
- case HomeTabModel _:
- tabType = "GetTimeline";
- break;
- case MentionsTabModel _:
- tabType = "GetTimeline";
- break;
- case DirectMessagesTabModel _:
- tabType = "GetDirectMessage";
- break;
- case FavoritesTabModel _:
- tabType = "GetFavorites";
- break;
- case PublicSearchTabModel _:
- tabType = "GetSearch";
- break;
- case UserTimelineTabModel _:
- tabType = "GetUserTimeline";
- break;
- case ListTimelineTabModel _:
- tabType = "GetListStatus";
- break;
- case RelatedPostsTabModel _:
- tabType = "GetRelatedTweets";
- break;
- default:
- tabType = tab.GetType().Name.Replace("Model", "");
- break;
- }
-
+ var tabType = tab switch
+ {
+ HomeTabModel _ => "GetTimeline",
+ MentionsTabModel _ => "GetTimeline",
+ DirectMessagesTabModel _ => "GetDirectMessage",
+ FavoritesTabModel _ => "GetFavorites",
+ PublicSearchTabModel _ => "GetSearch",
+ UserTimelineTabModel _ => "GetUserTimeline",
+ ListTimelineTabModel _ => "GetListStatus",
+ RelatedPostsTabModel _ => "GetRelatedTweets",
+ _ => tab.GetType().Name.Replace("Model", ""),
+ };
this.StatusLabel.Text = $"Err:{ex.Message}({tabType})";
}
finally
if (this._iconCol)
return ComparerMode.Id;
- switch (columnIndex)
- {
- case 1: // ニックネーム
- return ComparerMode.Nickname;
- case 2: // 本文
- return ComparerMode.Data;
- case 3: // 時刻=発言Id
- return ComparerMode.Id;
- case 4: // 名前
- return ComparerMode.Name;
- case 7: // Source
- return ComparerMode.Source;
- default:
- // 0:アイコン, 5:未読マーク, 6:プロテクト・フィルターマーク
- return null;
- }
+ return columnIndex switch
+ {
+ 1 => ComparerMode.Nickname, // ニックネーム
+ 2 => ComparerMode.Data, // 本文
+ 3 => ComparerMode.Id, // 時刻=発言Id
+ 4 => ComparerMode.Name, // 名前
+ 7 => ComparerMode.Source, // Source
+ _ => (ComparerMode?)null, // 0:アイコン, 5:未読マーク, 6:プロテクト・フィルターマーク
+ };
}
/// <summary>
private void ApplyListViewIconSize(MyCommon.IconSizes iconSz)
{
// アイコンサイズの再設定
- _iconCol = false;
- switch (iconSz)
- {
- case MyCommon.IconSizes.IconNone:
- _iconSz = 0;
- break;
- case MyCommon.IconSizes.Icon16:
- _iconSz = 16;
- break;
- case MyCommon.IconSizes.Icon24:
- _iconSz = 26;
- break;
- case MyCommon.IconSizes.Icon48:
- _iconSz = 48;
- break;
- case MyCommon.IconSizes.Icon48_2:
- _iconSz = 48;
- _iconCol = true;
- break;
- }
+ this._iconSz = iconSz switch
+ {
+ MyCommon.IconSizes.IconNone => 0,
+ MyCommon.IconSizes.Icon16 => 16,
+ MyCommon.IconSizes.Icon24 => 26,
+ MyCommon.IconSizes.Icon48 => 48,
+ MyCommon.IconSizes.Icon48_2 => 48,
+ _ => throw new InvalidEnumArgumentException(nameof(iconSz), (int)iconSz, typeof(MyCommon.IconSizes)),
+ };
+ this._iconCol = iconSz == MyCommon.IconSizes.Icon48_2;
if (_iconSz > 0)
{
SettingManager.Common.Token = tw.AccessToken;
SettingManager.Common.TokenSecret = tw.AccessTokenSecret;
SettingManager.Common.SortOrder = (int)_statuses.SortOrder;
- switch (_statuses.SortMode)
- {
- case ComparerMode.Nickname: //ニックネーム
- SettingManager.Common.SortColumn = 1;
- break;
- case ComparerMode.Data: //本文
- SettingManager.Common.SortColumn = 2;
- break;
- case ComparerMode.Id: //時刻=発言Id
- SettingManager.Common.SortColumn = 3;
- break;
- case ComparerMode.Name: //名前
- SettingManager.Common.SortColumn = 4;
- break;
- case ComparerMode.Source: //Source
- SettingManager.Common.SortColumn = 7;
- break;
- }
-
+ SettingManager.Common.SortColumn = this._statuses.SortMode switch
+ {
+ ComparerMode.Nickname => 1, // ニックネーム
+ ComparerMode.Data => 2, // 本文
+ ComparerMode.Id => 3, // 時刻=発言Id
+ ComparerMode.Name => 4, // 名前
+ ComparerMode.Source => 7, // Source
+ _ => throw new InvalidOperationException($"Invalid sort mode: {this._statuses.SortMode}"),
+ };
SettingManager.Common.HashTags = HashMgr.HashHistories;
if (HashMgr.IsPermanent)
{
if (endpointName == null)
{
// 表示中のタブに応じて更新
- switch (tabType)
- {
- case MyCommon.TabUsageType.Home:
- case MyCommon.TabUsageType.UserDefined:
- endpointName = "/statuses/home_timeline";
- break;
-
- case MyCommon.TabUsageType.Mentions:
- endpointName = "/statuses/mentions_timeline";
- break;
-
- case MyCommon.TabUsageType.Favorites:
- endpointName = "/favorites/list";
- break;
-
- case MyCommon.TabUsageType.DirectMessage:
- endpointName = "/direct_messages/events/list";
- break;
-
- case MyCommon.TabUsageType.UserTimeline:
- endpointName = "/statuses/user_timeline";
- break;
-
- case MyCommon.TabUsageType.Lists:
- endpointName = "/lists/statuses";
- break;
-
- case MyCommon.TabUsageType.PublicSearch:
- endpointName = "/search/tweets";
- break;
-
- case MyCommon.TabUsageType.Related:
- endpointName = "/statuses/show/:id";
- break;
-
- default:
- break;
- }
-
+ endpointName = tabType switch
+ {
+ MyCommon.TabUsageType.Home => "/statuses/home_timeline",
+ MyCommon.TabUsageType.UserDefined => "/statuses/home_timeline",
+ MyCommon.TabUsageType.Mentions => "/statuses/mentions_timeline",
+ MyCommon.TabUsageType.Favorites => "/favorites/list",
+ MyCommon.TabUsageType.DirectMessage => "/direct_messages/events/list",
+ MyCommon.TabUsageType.UserTimeline => "/statuses/user_timeline",
+ MyCommon.TabUsageType.Lists => "/lists/statuses",
+ MyCommon.TabUsageType.PublicSearch => "/search/tweets",
+ MyCommon.TabUsageType.Related => "/statuses/show/:id",
+ _ => null,
+ };
this.toolStripApiGauge.ApiEndpoint = endpointName;
}
else
{
// 表示中のタブに関連する endpoint であれば更新
- var update = false;
-
- switch (endpointName)
- {
- case "/statuses/home_timeline":
- update = tabType == MyCommon.TabUsageType.Home ||
- tabType == MyCommon.TabUsageType.UserDefined;
- break;
-
- case "/statuses/mentions_timeline":
- update = tabType == MyCommon.TabUsageType.Mentions;
- break;
-
- case "/favorites/list":
- update = tabType == MyCommon.TabUsageType.Favorites;
- break;
-
- case "/direct_messages/events/list":
- update = tabType == MyCommon.TabUsageType.DirectMessage;
- break;
-
- case "/statuses/user_timeline":
- update = tabType == MyCommon.TabUsageType.UserTimeline;
- break;
-
- case "/lists/statuses":
- update = tabType == MyCommon.TabUsageType.Lists;
- break;
-
- case "/search/tweets":
- update = tabType == MyCommon.TabUsageType.PublicSearch;
- break;
-
- case "/statuses/show/:id":
- update = tabType == MyCommon.TabUsageType.Related;
- break;
-
- default:
- break;
- }
-
+ var update = endpointName switch
+ {
+ "/statuses/home_timeline" => tabType == MyCommon.TabUsageType.Home || tabType == MyCommon.TabUsageType.UserDefined,
+ "/statuses/mentions_timeline" => tabType == MyCommon.TabUsageType.Mentions,
+ "/favorites/list" => tabType == MyCommon.TabUsageType.Favorites,
+ "/direct_messages/events/list" => tabType == MyCommon.TabUsageType.DirectMessage,
+ "/statuses/user_timeline" => tabType == MyCommon.TabUsageType.UserTimeline,
+ "/lists/statuses" => tabType == MyCommon.TabUsageType.Lists,
+ "/search/tweets" => tabType == MyCommon.TabUsageType.PublicSearch,
+ "/statuses/show/:id" => tabType == MyCommon.TabUsageType.Related,
+ _ => false,
+ };
if (update)
{
this.toolStripApiGauge.ApiEndpoint = endpointName;
{
this.CheckAccountState();
- string mediaType;
-
- switch (item.Extension)
+ var mediaType = item.Extension switch
{
- case ".png":
- mediaType = "image/png";
- break;
- case ".jpg":
- case ".jpeg":
- mediaType = "image/jpeg";
- break;
- case ".gif":
- mediaType = "image/gif";
- break;
- default:
- mediaType = "application/octet-stream";
- break;
- }
+ ".png" => "image/png",
+ ".jpg" => "image/jpeg",
+ ".jpeg" => "image/jpeg",
+ ".gif" => "image/gif",
+ _ => "application/octet-stream",
+ };
var initResponse = await this.Api.MediaUploadInit(item.Size, mediaType, mediaCategory)
.ConfigureAwait(false);
{
// 参照: REST APIs - 各endpointのcountパラメータ
// https://dev.twitter.com/rest/public
- switch (type)
- {
- case MyCommon.WORKERTYPE.Timeline:
- case MyCommon.WORKERTYPE.Reply:
- case MyCommon.WORKERTYPE.UserTimeline:
- case MyCommon.WORKERTYPE.Favorites:
- case MyCommon.WORKERTYPE.List: // 不明
- return 200;
-
- case MyCommon.WORKERTYPE.PublicSearch:
- return 100;
-
- default:
- throw new InvalidOperationException("Invalid type: " + type);
- }
+ return type switch
+ {
+ MyCommon.WORKERTYPE.Timeline => 200,
+ MyCommon.WORKERTYPE.Reply => 200,
+ MyCommon.WORKERTYPE.UserTimeline => 200,
+ MyCommon.WORKERTYPE.Favorites => 200,
+ MyCommon.WORKERTYPE.List => 200, // 不明
+ MyCommon.WORKERTYPE.PublicSearch => 100,
+ _ => throw new InvalidOperationException("Invalid type: " + type),
+ };
}
/// <summary>