using var twitterApi = new TwitterApi(ApiKey.Create("fake_consumer_key"), ApiKey.Create("fake_consumer_secret"));
twitterApi.apiConnection = mock.Object;
- await twitterApi.StatusesUpdate("hogehoge", replyToId: 100L, mediaIds: new[] { 10L, 20L },
- autoPopulateReplyMetadata: true, excludeReplyUserIds: new[] { 100L, 200L },
- attachmentUrl: "https://twitter.com/twitterapi/status/22634515958")
+ await twitterApi.StatusesUpdate(
+ "hogehoge",
+ replyToId: 100L,
+ mediaIds: new[] { 10L, 20L },
+ autoPopulateReplyMetadata: true,
+ excludeReplyUserIds: new[] { 100L, 200L },
+ attachmentUrl: "https://twitter.com/twitterapi/status/22634515958"
+ )
.IgnoreResponse()
.ConfigureAwait(false);
{
// GET http://example.com/hoge?aaa=foo に対する署名を生成
// 実際の param は oauth_consumer_key などのパラメーターが加わった状態で渡される
- var oauthSignature = OAuthUtility.CreateSignature(ApiKey.Create("ConsumerSecret"), "TokenSecret",
- "GET", new Uri("http://example.com/hoge"), new Dictionary<string, string> { ["aaa"] = "foo" });
+ var oauthSignature = OAuthUtility.CreateSignature(
+ ApiKey.Create("ConsumerSecret"),
+ "TokenSecret",
+ "GET",
+ new Uri("http://example.com/hoge"),
+ new Dictionary<string, string> { ["aaa"] = "foo" });
var expectSignatureBase = "GET&http%3A%2F%2Fexample.com%2Fhoge&aaa%3Dfoo";
var expectSignatureKey = "ConsumerSecret&TokenSecret";
{
// GET http://example.com/hoge?aaa=foo&bbb=bar に対する署名を生成
// 複数のパラメータが渡される場合は name 順でソートされる
- var oauthSignature = OAuthUtility.CreateSignature(ApiKey.Create("ConsumerSecret"), "TokenSecret",
- "GET", new Uri("http://example.com/hoge"), new Dictionary<string, string> {
+ var oauthSignature = OAuthUtility.CreateSignature(
+ ApiKey.Create("ConsumerSecret"),
+ "TokenSecret",
+ "GET",
+ new Uri("http://example.com/hoge"),
+ new Dictionary<string, string> {
["bbb"] = "bar",
["aaa"] = "foo",
});
{
// GET http://example.com/hoge?aaa=foo に対する署名を生成
// リクエストトークンの発行時は tokenSecret が空の状態で署名を生成することになる
- var oauthSignature = OAuthUtility.CreateSignature(ApiKey.Create("ConsumerSecret"), null,
- "GET", new Uri("http://example.com/hoge"), new Dictionary<string, string> { ["aaa"] = "foo" });
+ var oauthSignature = OAuthUtility.CreateSignature(
+ ApiKey.Create("ConsumerSecret"),
+ null,
+ "GET",
+ new Uri("http://example.com/hoge"),
+ new Dictionary<string, string> { ["aaa"] = "foo" });
var expectSignatureBase = "GET&http%3A%2F%2Fexample.com%2Fhoge&aaa%3Dfoo";
var expectSignatureKey = "ConsumerSecret&"; // 末尾の & は除去されない
public void CreateAuthorization_Test()
{
var authorization = OAuthUtility.CreateAuthorization(
- "GET", new Uri("http://example.com/hoge"), new Dictionary<string, string> { ["aaa"] = "hoge" },
- ApiKey.Create("ConsumerKey"), ApiKey.Create("ConsumerSecret"), "AccessToken", "AccessSecret", "Realm");
+ "GET",
+ new Uri("http://example.com/hoge"),
+ new Dictionary<string, string> { ["aaa"] = "hoge" },
+ ApiKey.Create("ConsumerKey"),
+ ApiKey.Create("ConsumerSecret"),
+ "AccessToken",
+ "AccessSecret",
+ "Realm");
Assert.StartsWith("OAuth ", authorization, StringComparison.Ordinal);
var filter = new PostFilterRule();
Assert.PropertyChanged(
- filter, "FilterName",
+ filter,
+ "FilterName",
() => filter.FilterName = "hogehoge"
);
// 値に変化がないので PropertyChanged イベントは発生しない
TestUtils.NotPropertyChanged(
- filter, "FilterName",
+ filter,
+ "FilterName",
() => filter.FilterName = "hogehoge"
);
await service.GetThumbnailInfoAsync(
"https://www.swarmapp.com/c/xxxxxxxx",
- post, CancellationToken.None);
+ post,
+ CancellationToken.None);
Assert.Equal(0, handler.QueueCount);
}
await service.GetThumbnailInfoAsync(
"https://foursquare.com/hogehoge/checkin/xxxxxxxx",
- post, CancellationToken.None);
+ post,
+ CancellationToken.None);
Assert.Equal(0, handler.QueueCount);
}
await service.GetThumbnailInfoAsync(
"https://foursquare.com/hogehoge/checkin/xxxxxxxx?s=aaaaaaa",
- post, CancellationToken.None);
+ post,
+ CancellationToken.None);
Assert.Equal(0, handler.QueueCount);
}
await service.GetThumbnailInfoAsync(
"https://www.swarmapp.com/c/xxxxxxxx",
- post, CancellationToken.None);
+ post,
+ CancellationToken.None);
Assert.Equal(1, handler.QueueCount);
}
return this.Connection.GetAsync<TwitterStatus>(endpoint, param, "/statuses/show/:id");
}
- public Task<LazyJson<TwitterStatus>> StatusesUpdate(string status, long? replyToId, IReadOnlyList<long>? mediaIds,
- bool? autoPopulateReplyMetadata = null, IReadOnlyList<long>? excludeReplyUserIds = null, string? attachmentUrl = null)
+ public Task<LazyJson<TwitterStatus>> StatusesUpdate(
+ string status,
+ long? replyToId,
+ IReadOnlyList<long>? mediaIds,
+ bool? autoPopulateReplyMetadata = null,
+ IReadOnlyList<long>? excludeReplyUserIds = null,
+ string? attachmentUrl = null)
{
var endpoint = new Uri("statuses/update.json", UriKind.Relative);
var param = new Dictionary<string, string>
authUserCombo.SelectedIndex = idx;
- MessageBox.Show(this, Properties.Resources.AuthorizeButton_Click1,
- "Authenticate", MessageBoxButtons.OK);
+ MessageBox.Show(
+ this,
+ Properties.Resources.AuthorizeButton_Click1,
+ "Authenticate",
+ MessageBoxButtons.OK);
}
catch (WebApiException ex)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
}
- public static void SetWebProxy(ProxyType proxyType, string proxyAddress, int proxyPort,
- string proxyUser, string proxyPassword)
+ public static void SetWebProxy(
+ ProxyType proxyType,
+ string proxyAddress,
+ int proxyPort,
+ string proxyUser,
+ string proxyPassword)
{
IWebProxy? proxy;
switch (proxyType)
return base.SendAsync(request, cancellationToken);
}
- public static OAuthEchoHandler CreateHandler(HttpMessageHandler innerHandler, Uri authServiceProvider,
- ApiKey consumerKey, ApiKey consumerSecret, string accessToken, string accessSecret, Uri? realm = null)
+ public static OAuthEchoHandler CreateHandler(
+ HttpMessageHandler innerHandler,
+ Uri authServiceProvider,
+ ApiKey consumerKey,
+ ApiKey consumerSecret,
+ string accessToken,
+ string accessSecret,
+ Uri? realm = null)
{
- var credential = OAuthUtility.CreateAuthorization("GET", authServiceProvider, null,
- consumerKey, consumerSecret, accessToken, accessSecret, realm?.AbsoluteUri);
+ var credential = OAuthUtility.CreateAuthorization(
+ "GET",
+ authServiceProvider,
+ null,
+ consumerKey,
+ consumerSecret,
+ accessToken,
+ accessSecret,
+ realm?.AbsoluteUri);
return new OAuthEchoHandler(innerHandler, authServiceProvider, credential);
}
var query = await GetParameters(request.RequestUri, request.Content)
.ConfigureAwait(false);
- var credential = OAuthUtility.CreateAuthorization(request.Method.ToString().ToUpperInvariant(), request.RequestUri, query,
- this.ConsumerKey, this.ConsumerSecret, this.AccessToken, this.AccessSecret);
+ var credential = OAuthUtility.CreateAuthorization(
+ request.Method.ToString().ToUpperInvariant(),
+ request.RequestUri,
+ query,
+ this.ConsumerKey,
+ this.ConsumerSecret,
+ this.AccessToken,
+ this.AccessSecret);
request.Headers.TryAddWithoutValidation("Authorization", credential);
if (request.Content is FormUrlEncodedContent postContent)
/// <param name="token">アクセストークン、もしくはリクエストトークン。未取得なら空文字列</param>
/// <param name="tokenSecret">アクセストークンシークレット。認証処理では空文字列</param>
/// <param name="realm">realm (必要な場合のみ)</param>
- public static string CreateAuthorization(string httpMethod, Uri requestUri, IEnumerable<KeyValuePair<string, string>>? query,
- ApiKey consumerKey, ApiKey consumerSecret, string token, string tokenSecret,
+ public static string CreateAuthorization(
+ string httpMethod,
+ Uri requestUri,
+ IEnumerable<KeyValuePair<string, string>>? query,
+ ApiKey consumerKey,
+ ApiKey consumerSecret,
+ string token,
+ string tokenSecret,
string? realm = null)
{
// OAuth共通情報取得
{
var uri = new Uri(RestApiBase, authServiceProvider);
- return OAuthEchoHandler.CreateHandler(Networking.CreateHttpClientHandler(), uri,
- this.consumerKey, this.consumerSecret, this.AccessToken, this.AccessSecret, realm);
+ return OAuthEchoHandler.CreateHandler(
+ Networking.CreateHttpClientHandler(),
+ uri,
+ this.consumerKey,
+ this.consumerSecret,
+ this.AccessToken,
+ this.AccessSecret,
+ realm);
}
public void Dispose()
return response;
}
- private static async Task<IDictionary<string, string>> GetOAuthTokenAsync(Uri uri, IDictionary<string, string> param,
- ApiKey consumerKey, ApiKey consumerSecret, (string Token, string TokenSecret)? oauthToken)
+ private static async Task<IDictionary<string, string>> GetOAuthTokenAsync(
+ Uri uri,
+ IDictionary<string, string> param,
+ ApiKey consumerKey,
+ ApiKey consumerSecret,
+ (string Token, string TokenSecret)? oauthToken)
{
HttpClient authorizeClient;
if (oauthToken != null)
this._targetConnector = this._connector.CreateInstance("Growl.Connector.GrowlConnector");
var _t = this._connector.GetType("Growl.Connector.NotificationType");
- this._growlNTreply = _t.InvokeMember(null,
- BindingFlags.CreateInstance, null, null, new object[] { "REPLY", "Reply" }, CultureInfo.InvariantCulture);
+ this._growlNTreply = _t.InvokeMember(
+ null,
+ BindingFlags.CreateInstance,
+ null,
+ null,
+ new object[] { "REPLY", "Reply" },
+ CultureInfo.InvariantCulture);
this._growlNTdm = _t.InvokeMember(null,
- BindingFlags.CreateInstance, null, null, new object[] { "DIRECT_MESSAGE", "DirectMessage" }, CultureInfo.InvariantCulture);
-
- this._growlNTnew = _t.InvokeMember(null,
- BindingFlags.CreateInstance, null, null, new object[] { "NOTIFY", "新着通知" }, CultureInfo.InvariantCulture);
+ BindingFlags.CreateInstance,
+ null,
+ null,
+ new object[] { "DIRECT_MESSAGE", "DirectMessage" },
+ CultureInfo.InvariantCulture);
+
+ this._growlNTnew = _t.InvokeMember(
+ null,
+ BindingFlags.CreateInstance,
+ null,
+ null,
+ new object[] { "NOTIFY", "新着通知" },
+ CultureInfo.InvariantCulture);
var encryptType =
this._connector.GetType("Growl.Connector.Cryptography+SymmetricAlgorithmType").InvokeMember(
if (File.Exists(Path.Combine(Application.StartupPath, "Icons\\Tween.png")))
{
// Icons\Tween.pngを使用
- var ci = this._core.GetType(
- "Growl.CoreLibrary.Resource").GetConstructor(
+ var ci = this._core.GetType("Growl.CoreLibrary.Resource").GetConstructor(
BindingFlags.NonPublic | BindingFlags.Instance,
- null, new Type[] { typeof(string) }, null);
+ null,
+ new Type[] { typeof(string) },
+ null);
var data = ci.Invoke(new object[] { Path.Combine(Application.StartupPath, "Icons\\Tween.png") });
var pi = this._growlApp.GetType().GetProperty("Icon");
else if (File.Exists(Path.Combine(Application.StartupPath, "Icons\\MIcon.ico")))
{
// アイコンセットにMIcon.icoが存在する場合それを使用
- var cibd = this._core.GetType(
- "Growl.CoreLibrary.BinaryData").GetConstructor(
+ var cibd = this._core.GetType("Growl.CoreLibrary.BinaryData").GetConstructor(
BindingFlags.Public | BindingFlags.Instance,
- null, new Type[] { typeof(byte[]) }, null);
+ null,
+ new Type[] { typeof(byte[]) },
+ null);
var bdata = cibd.Invoke(
new object[] { this.IconToByteArray(Path.Combine(Application.StartupPath, "Icons\\MIcon.ico")) });
- var ciRes = this._core.GetType(
- "Growl.CoreLibrary.Resource").GetConstructor(
+ var ciRes = this._core.GetType("Growl.CoreLibrary.Resource").GetConstructor(
BindingFlags.NonPublic | BindingFlags.Instance,
- null, new Type[] { bdata.GetType() }, null);
+ null,
+ new Type[] { bdata.GetType() },
+ null);
var data = ciRes.Invoke(new object[] { bdata });
var pi = this._growlApp.GetType().GetProperty("Icon");
else
{
// 内蔵アイコンリソースを使用
- var cibd = this._core.GetType(
- "Growl.CoreLibrary.BinaryData").GetConstructor(
+ var cibd = this._core.GetType("Growl.CoreLibrary.BinaryData").GetConstructor(
BindingFlags.Public | BindingFlags.Instance,
- null, new Type[] { typeof(byte[]) }, null);
+ null,
+ new Type[] { typeof(byte[]) },
+ null);
var bdata = cibd.Invoke(
new object[] { this.IconToByteArray(Properties.Resources.MIcon) });
- var ciRes = this._core.GetType(
- "Growl.CoreLibrary.Resource").GetConstructor(
+ var ciRes = this._core.GetType("Growl.CoreLibrary.Resource").GetConstructor(
BindingFlags.NonPublic | BindingFlags.Instance,
- null, new Type[] { bdata.GetType() }, null);
+ null,
+ new Type[] { bdata.GetType() },
+ null);
var data = ciRes.Invoke(new object[] { bdata });
var pi = this._growlApp.GetType().GetProperty("Icon");
CultureInfo.InvariantCulture);
}
var cc = this._connector.GetType("Growl.Connector.CallbackContext").InvokeMember(
- null, BindingFlags.CreateInstance, null, this._connector,
+ null,
+ BindingFlags.CreateInstance,
+ null,
+ this._connector,
new object[] { "some fake information", notificationName },
CultureInfo.InvariantCulture);
this._targetConnector!.GetType().InvokeMember("Notify", BindingFlags.InvokeMethod, null, this._targetConnector, new object[] { n, cc }, CultureInfo.InvariantCulture);
return imageTask;
}
- }, cancelToken);
+ },
+ cancelToken);
}
private async Task<MemoryImage> FetchImageAsync(string uri, CancellationToken cancelToken)
if (this.SourceUri == null)
return WebUtility.HtmlEncode(this.Source);
- return string.Format("<a href=\"{0}\" rel=\"nofollow\">{1}</a>",
- WebUtility.HtmlEncode(this.SourceUri.AbsoluteUri), WebUtility.HtmlEncode(this.Source));
+ return string.Format(
+ "<a href=\"{0}\" rel=\"nofollow\">{1}</a>",
+ WebUtility.HtmlEncode(this.SourceUri.AbsoluteUri),
+ WebUtility.HtmlEncode(this.Source));
}
}
var matchExpr = this.MakeFiltersExpr(
postParam,
- this.FilterName, this.FilterBody, this.FilterSource, this.FilterRt,
- this.UseRegex, this.CaseSensitive, this.UseNameField, this.UseLambda, this.FilterByUrl);
+ this.FilterName,
+ this.FilterBody,
+ this.FilterSource,
+ this.FilterRt,
+ this.UseRegex,
+ this.CaseSensitive,
+ this.UseNameField,
+ this.UseLambda,
+ this.FilterByUrl);
var excludeExpr = this.MakeFiltersExpr(
postParam,
- this.ExFilterName, this.ExFilterBody, this.ExFilterSource, this.ExFilterRt,
- this.ExUseRegex, this.ExCaseSensitive, this.ExUseNameField, this.ExUseLambda, this.ExFilterByUrl);
+ this.ExFilterName,
+ this.ExFilterBody,
+ this.ExFilterSource,
+ this.ExFilterRt,
+ this.ExUseRegex,
+ this.ExCaseSensitive,
+ this.ExUseNameField,
+ this.ExUseLambda,
+ this.ExFilterByUrl);
Expression<Func<PostClass, MyCommon.HITRESULT>> filterExpr;
protected virtual Expression? MakeFiltersExpr(
ParameterExpression postParam,
- string? filterName, string[] filterBody, string? filterSource, bool filterRt,
- bool useRegex, bool caseSensitive, bool useNameField, bool useLambda, bool filterByUrl)
+ string? filterName,
+ string[] filterBody,
+ string? filterSource,
+ bool filterRt,
+ bool useRegex,
+ bool caseSensitive,
+ bool useNameField,
+ bool useLambda,
+ bool filterByUrl)
{
var filterExprs = new List<Expression>();
}
protected Expression MakeGenericFilter(
- ParameterExpression postParam, string targetFieldName, string pattern,
- bool useRegex, bool caseSensitive, bool exactMatch = false)
+ ParameterExpression postParam,
+ string targetFieldName,
+ string pattern,
+ bool useRegex,
+ bool caseSensitive,
+ bool exactMatch = false)
{
// x.<targetFieldName>
var targetField = Expression.Property(
public int SubmitUpdate()
=> this.SubmitUpdate(out _, out _, out _, out _);
- public int SubmitUpdate(out string soundFile, out PostClass[] notifyPosts,
- out bool newMentionOrDm, out bool isDeletePost)
+ public int SubmitUpdate(
+ out string soundFile,
+ out PostClass[] notifyPosts,
+ out bool newMentionOrDm,
+ out bool isDeletePost)
{
// 注:メインスレッドから呼ぶこと
lock (this.LockObj)
if (idx_to < idx_fr)
{
- Array.Copy(values, idx_to, values,
- idx_to + 1, num_moved);
+ Array.Copy(values, idx_to, values, idx_to + 1, num_moved);
}
else
{
- Array.Copy(values, idx_fr + 1, values,
- idx_fr, num_moved);
+ Array.Copy(values, idx_fr + 1, values, idx_fr, num_moved);
}
values[idx_to] = moved_value;
#region "グローバルフック"
[DllImport("user32")]
- private static extern int RegisterHotKey(IntPtr hwnd, int id,
- int fsModifiers, int vk);
+ private static extern int RegisterHotKey(IntPtr hwnd, int id, int fsModifiers, int vk);
[DllImport("user32")]
private static extern int UnregisterHotKey(IntPtr hwnd, int id);
[DllImport("kernel32", CharSet = CharSet.Auto, BestFitMapping = false, ThrowOnUnmappableChar = true)]
{
var foundHwnd = IntPtr.Zero;
- EnumWindows((hWnd, lParam) =>
- {
- GetWindowThreadProcessId(hWnd, out var procId);
-
- if (procId == pid)
+ EnumWindows(
+ (hWnd, lParam) =>
{
- var windowTitleLen = GetWindowTextLength(hWnd);
+ GetWindowThreadProcessId(hWnd, out var procId);
- if (windowTitleLen > 0)
+ if (procId == pid)
{
- var windowTitle = new StringBuilder(windowTitleLen + 1);
- GetWindowText(hWnd, windowTitle, windowTitle.Capacity);
+ var windowTitleLen = GetWindowTextLength(hWnd);
- if (windowTitle.ToString().Contains(searchWindowTitle))
+ if (windowTitleLen > 0)
{
- foundHwnd = hWnd;
- return false;
+ var windowTitle = new StringBuilder(windowTitleLen + 1);
+ GetWindowText(hWnd, windowTitle, windowTitle.Capacity);
+
+ if (windowTitle.ToString().Contains(searchWindowTitle))
+ {
+ foundHwnd = hWnd;
+ return false;
+ }
}
}
- }
- return true;
- }, IntPtr.Zero);
+ return true;
+ },
+ IntPtr.Zero);
return foundHwnd;
}
{
tcs.SetException(ex);
}
- }, null);
+ },
+ null);
return tcs.Task;
}
}
return null;
- }, token);
+ },
+ token);
}
public virtual void Dispose()
TooltipText = null,
FullSizeImageUrl = this.ReplaceUrl(url, this.fullsize_replacement)
};
- }, token);
+ },
+ token);
}
protected string? ReplaceUrl(string url)
TooltipText = null,
FullSizeImageUrl = largeUrl,
};
- }, token);
+ },
+ token);
}
public class Thumbnail : ThumbnailInfo
{
public override Task<MemoryImage> LoadThumbnailImageAsync(HttpClient http, CancellationToken cancellationToken)
{
- return Task.Run(async () =>
- {
- var apiConnection = TonTwitterCom.GetApiConnection!();
+ return Task.Run(
+ async () =>
+ {
+ var apiConnection = TonTwitterCom.GetApiConnection!();
- using var imageStream = await apiConnection.GetStreamAsync(new Uri(this.ThumbnailImageUrl), null)
- .ConfigureAwait(false);
+ using var imageStream = await apiConnection.GetStreamAsync(new Uri(this.ThumbnailImageUrl), null)
+ .ConfigureAwait(false);
- cancellationToken.ThrowIfCancellationRequested();
+ cancellationToken.ThrowIfCancellationRequested();
- return await MemoryImage.CopyFromStreamAsync(imageStream)
- .ConfigureAwait(false);
- }, cancellationToken);
+ return await MemoryImage.CopyFromStreamAsync(imageStream)
+ .ConfigureAwait(false);
+ },
+ cancellationToken);
}
}
}
TooltipText = null,
IsPlayable = true,
};
- }, token);
+ },
+ token);
}
}
}
// Twitter用通信クラス初期化
Networking.DefaultTimeout = TimeSpan.FromSeconds(SettingManager.Common.DefaultTimeOut);
Networking.UploadImageTimeout = TimeSpan.FromSeconds(SettingManager.Common.UploadImageTimeout);
- Networking.SetWebProxy(SettingManager.Local.ProxyType,
- SettingManager.Local.ProxyAddress, SettingManager.Local.ProxyPort,
- SettingManager.Local.ProxyUser, SettingManager.Local.ProxyPassword);
+ Networking.SetWebProxy(
+ SettingManager.Local.ProxyType,
+ SettingManager.Local.ProxyAddress,
+ SettingManager.Local.ProxyPort,
+ SettingManager.Local.ProxyUser,
+ SettingManager.Local.ProxyPassword);
Networking.ForceIPv4 = SettingManager.Common.ForceIPv4;
TwitterApiConnection.RestApiHost = SettingManager.Common.TwitterApiHost;
}
catch (WebApiException ex)
{
- MessageBox.Show(this, string.Format(Properties.Resources.StartupAuthError_Text, ex.Message),
- ApplicationSettings.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ MessageBox.Show(
+ this,
+ string.Format(Properties.Resources.StartupAuthError_Text, ex.Message),
+ ApplicationSettings.ApplicationName,
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Warning);
}
// サムネイル関連の初期化
// 更新確定
int addCount;
- addCount = this._statuses.SubmitUpdate(out var soundFile, out var notifyPosts,
- out var newMentionOrDm, out var isDelete);
+ addCount = this._statuses.SubmitUpdate(
+ out var soundFile,
+ out var notifyPosts,
+ out var newMentionOrDm,
+ out var isDelete);
if (MyCommon._endingFlag) return;
}
}
- private async Task PostMessageAsyncInternal(IProgress<string> p, CancellationToken ct, PostStatusParams postParams,
- IMediaUploadService? uploadService, IMediaItem[]? uploadItems)
+ private async Task PostMessageAsyncInternal(
+ IProgress<string> p,
+ CancellationToken ct,
+ PostStatusParams postParams,
+ IMediaUploadService? uploadService,
+ IMediaItem[]? uploadItems)
{
if (ct.IsCancellationRequested)
return;
{
if (multiFavoriteChangeDialogEnable)
{
- var confirm = MessageBox.Show(Properties.Resources.FavRemoveToolStripMenuItem_ClickText1,
+ var confirm = MessageBox.Show(
+ Properties.Resources.FavRemoveToolStripMenuItem_ClickText1,
Properties.Resources.FavRemoveToolStripMenuItem_ClickText2,
- MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
+ MessageBoxButtons.OKCancel,
+ MessageBoxIcon.Question);
if (confirm == DialogResult.Cancel)
return;
if (!posts.Any(x => x.CanDeleteBy(this.tw.UserId)))
return;
- var ret = MessageBox.Show(this,
+ var ret = MessageBox.Show(
+ this,
string.Format(Properties.Resources.DeleteStripMenuItem_ClickText1, Environment.NewLine),
Properties.Resources.DeleteStripMenuItem_ClickText2,
- MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
+ MessageBoxButtons.OKCancel,
+ MessageBoxIcon.Question);
if (ret != DialogResult.OK)
return;
Networking.DefaultTimeout = TimeSpan.FromSeconds(SettingManager.Common.DefaultTimeOut);
Networking.UploadImageTimeout = TimeSpan.FromSeconds(SettingManager.Common.UploadImageTimeout);
- Networking.SetWebProxy(SettingManager.Local.ProxyType,
- SettingManager.Local.ProxyAddress, SettingManager.Local.ProxyPort,
- SettingManager.Local.ProxyUser, SettingManager.Local.ProxyPassword);
+ Networking.SetWebProxy(
+ SettingManager.Local.ProxyType,
+ SettingManager.Local.ProxyAddress,
+ SettingManager.Local.ProxyPort,
+ SettingManager.Local.ProxyUser,
+ SettingManager.Local.ProxyPassword);
Networking.ForceIPv4 = SettingManager.Common.ForceIPv4;
this.ImageSelector.Reset(this.tw, this.tw.Configuration);
if (confirm)
{
var tmp = string.Format(Properties.Resources.RemoveSpecifiedTabText1, Environment.NewLine);
- if (MessageBox.Show(tmp, TabName + " " + Properties.Resources.RemoveSpecifiedTabText2,
- MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Cancel)
+ var result = MessageBox.Show(
+ tmp,
+ TabName + " " + Properties.Resources.RemoveSpecifiedTabText2,
+ MessageBoxButtons.OKCancel,
+ MessageBoxIcon.Question,
+ MessageBoxDefaultButton.Button2);
+ if (result == DialogResult.Cancel)
{
return false;
}
using var fnt = new Font(e.Item.Font, FontStyle.Bold);
- TextRenderer.DrawText(e.Graphics,
+ TextRenderer.DrawText(
+ e.Graphics,
post.IsDeleted ? "(DELETED)" : post.TextSingleLine,
e.Item.Font,
Rectangle.Round(rct),
TextFormatFlags.EndEllipsis |
TextFormatFlags.GlyphOverhangPadding |
TextFormatFlags.NoPrefix);
- TextRenderer.DrawText(e.Graphics,
+ TextRenderer.DrawText(
+ e.Graphics,
e.Item.SubItems[4].Text + " / " + e.Item.SubItems[1].Text + " (" + e.Item.SubItems[3].Text + ") " + e.Item.SubItems[5].Text + e.Item.SubItems[6].Text + " [" + e.Item.SubItems[7].Text + "]",
fnt,
rctB,
if (drawLineCount == 1)
{
- TextRenderer.DrawText(e.Graphics,
- text,
- e.Item.Font,
- Rectangle.Round(rct),
- color,
- TextFormatFlags.SingleLine |
- TextFormatFlags.EndEllipsis |
- TextFormatFlags.GlyphOverhangPadding |
- TextFormatFlags.NoPrefix |
- TextFormatFlags.VerticalCenter);
+ TextRenderer.DrawText(
+ e.Graphics,
+ text,
+ e.Item.Font,
+ Rectangle.Round(rct),
+ color,
+ TextFormatFlags.SingleLine |
+ TextFormatFlags.EndEllipsis |
+ TextFormatFlags.GlyphOverhangPadding |
+ TextFormatFlags.NoPrefix |
+ TextFormatFlags.VerticalCenter);
}
else
{
- TextRenderer.DrawText(e.Graphics,
- text,
- e.Item.Font,
- Rectangle.Round(rct),
- color,
- TextFormatFlags.WordBreak |
- TextFormatFlags.EndEllipsis |
- TextFormatFlags.GlyphOverhangPadding |
- TextFormatFlags.NoPrefix);
+ TextRenderer.DrawText(
+ e.Graphics,
+ text,
+ e.Item.Font,
+ Rectangle.Round(rct),
+ color,
+ TextFormatFlags.WordBreak |
+ TextFormatFlags.EndEllipsis |
+ TextFormatFlags.GlyphOverhangPadding |
+ TextFormatFlags.NoPrefix);
}
}
}
// 更新不要
if (!startup)
{
- var msgtext = string.Format(Properties.Resources.CheckNewVersionText7,
- MyCommon.GetReadableVersion(), MyCommon.GetReadableVersion(versionInfo.Version));
+ var msgtext = string.Format(
+ Properties.Resources.CheckNewVersionText7,
+ MyCommon.GetReadableVersion(),
+ MyCommon.GetReadableVersion(versionInfo.Version));
msgtext = MyCommon.ReplaceAppName(msgtext);
- MessageBox.Show(msgtext,
+ MessageBox.Show(
+ msgtext,
MyCommon.ReplaceAppName(Properties.Resources.CheckNewVersionText2),
- MessageBoxButtons.OK, MessageBoxIcon.Information);
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
}
return;
}
this.StatusLabel.Text = Properties.Resources.CheckNewVersionText9;
if (!startup)
{
- MessageBox.Show(Properties.Resources.CheckNewVersionText10,
+ MessageBox.Show(
+ Properties.Resources.CheckNewVersionText10,
MyCommon.ReplaceAppName(Properties.Resources.CheckNewVersionText2),
- MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Exclamation,
+ MessageBoxDefaultButton.Button2);
}
}
}
var match = Twitter.StatusUrlRegex.Match(inputText);
if (!match.Success)
{
- MessageBox.Show(this, Properties.Resources.OpenURL_InvalidFormat,
- Properties.Resources.OpenURL_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBox.Show(
+ this,
+ Properties.Resources.OpenURL_InvalidFormat,
+ Properties.Resources.OpenURL_Caption,
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
return;
}
{
var tab = this.CurrentTab;
- var rslt = MessageBox.Show(string.Format(Properties.Resources.SaveLogMenuItem_ClickText1, Environment.NewLine),
- Properties.Resources.SaveLogMenuItem_ClickText2,
- MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
+ var rslt = MessageBox.Show(
+ string.Format(Properties.Resources.SaveLogMenuItem_ClickText1, Environment.NewLine),
+ Properties.Resources.SaveLogMenuItem_ClickText2,
+ MessageBoxButtons.YesNoCancel,
+ MessageBoxIcon.Question);
if (rslt == DialogResult.Cancel) return;
this.SaveFileDialog1.FileName = $"{ApplicationSettings.AssemblyName}Posts{DateTimeUtc.Now.ToLocalTime():yyMMdd-HHmmss}.tsv";
if (isFollowing)
{
if (MessageBox.Show(
- Properties.Resources.GetFriendshipInfo7 + System.Environment.NewLine + result, Properties.Resources.GetFriendshipInfo8,
+ Properties.Resources.GetFriendshipInfo7 + System.Environment.NewLine + result,
+ Properties.Resources.GetFriendshipInfo8,
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2) == DialogResult.Yes)
/// <summary>
/// attachment_url に指定可能な URL を判定する正規表現
/// </summary>
- public static readonly Regex AttachmentUrlRegex = new Regex(@"https?://(
+ public static readonly Regex AttachmentUrlRegex = new Regex(
+ @"https?://(
twitter\.com/[0-9A-Za-z_]+/status/[0-9]+
| mobile\.twitter\.com/[0-9A-Za-z_]+/status/[0-9]+
| twitter\.com/messages/compose\?recipient_id=[0-9]+(&.+)?
-)$", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
+)$",
+ RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
/// <summary>
/// FavstarやaclogなどTwitter関連サービスのパーマリンクURLからステータスIDを抽出する正規表現
/// </summary>
- public static readonly Regex ThirdPartyStatusUrlRegex = new Regex(@"https?://(?:[^.]+\.)?(?:
+ public static readonly Regex ThirdPartyStatusUrlRegex = new Regex(
+ @"https?://(?:[^.]+\.)?(?:
favstar\.fm/users/[a-zA-Z0-9_]+/status/ # Favstar
| favstar\.fm/t/ # Favstar (short)
| aclog\.koba789\.com/i/ # aclog
| frtrt\.net/solo_status\.php\?status= # RtRT
-)(?<StatusId>[0-9]+)", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
+)(?<StatusId>[0-9]+)",
+ RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
/// <summary>
/// DM送信かどうかを判定する正規表現
return null;
}
- var response = await this.Api.StatusesUpdate(param.Text, param.InReplyToStatusId, param.MediaIds,
- param.AutoPopulateReplyMetadata, param.ExcludeReplyUserIds, param.AttachmentUrl)
+ var response = await this.Api.StatusesUpdate(
+ param.Text,
+ param.InReplyToStatusId,
+ param.MediaIds,
+ param.AutoPopulateReplyMetadata,
+ param.ExcludeReplyUserIds,
+ param.AttachmentUrl
+ )
.ConfigureAwait(false);
var status = await response.LoadJsonAsync()
this.CreateDirectMessagesEventFromJson(events, users, apps, read);
}
- private void CreateDirectMessagesEventFromJson(IEnumerable<TwitterMessageEvent> events, IReadOnlyDictionary<string, TwitterUser> users,
- IReadOnlyDictionary<string, TwitterMessageEventList.App> apps, bool read)
+ private void CreateDirectMessagesEventFromJson(
+ IEnumerable<TwitterMessageEvent> events,
+ IReadOnlyDictionary<string, TwitterUser> users,
+ IReadOnlyDictionary<string, TwitterMessageEventList.App> apps,
+ bool read)
{
foreach (var eventItem in events)
{
private async void ButtonUnFollow_Click(object sender, EventArgs e)
{
- if (MessageBox.Show(this._displayUser.ScreenName + Properties.Resources.ButtonUnFollow_ClickText1,
- Properties.Resources.ButtonUnFollow_ClickText2,
- MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
+ if (MessageBox.Show(
+ this._displayUser.ScreenName + Properties.Resources.ButtonUnFollow_ClickText1,
+ Properties.Resources.ButtonUnFollow_ClickText2,
+ MessageBoxButtons.YesNo,
+ MessageBoxIcon.Warning,
+ MessageBoxDefaultButton.Button2) == DialogResult.Yes)
{
using (ControlTransaction.Disabled(this.ButtonUnFollow))
{
private async void ButtonBlock_Click(object sender, EventArgs e)
{
- if (MessageBox.Show(this._displayUser.ScreenName + Properties.Resources.ButtonBlock_ClickText1,
- Properties.Resources.ButtonBlock_ClickText2,
- MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
+ if (MessageBox.Show(
+ this._displayUser.ScreenName + Properties.Resources.ButtonBlock_ClickText1,
+ Properties.Resources.ButtonBlock_ClickText2,
+ MessageBoxButtons.YesNo,
+ MessageBoxIcon.Warning,
+ MessageBoxDefaultButton.Button2) == DialogResult.Yes)
{
using (ControlTransaction.Disabled(this.ButtonBlock))
{
private async void ButtonReportSpam_Click(object sender, EventArgs e)
{
- if (MessageBox.Show(this._displayUser.ScreenName + Properties.Resources.ButtonReportSpam_ClickText1,
- Properties.Resources.ButtonReportSpam_ClickText2,
- MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
+ if (MessageBox.Show(
+ this._displayUser.ScreenName + Properties.Resources.ButtonReportSpam_ClickText1,
+ Properties.Resources.ButtonReportSpam_ClickText2,
+ MessageBoxButtons.YesNo,
+ MessageBoxIcon.Warning,
+ MessageBoxDefaultButton.Button2) == DialogResult.Yes)
{
using (ControlTransaction.Disabled(this.ButtonReportSpam))
{
private async void ButtonBlockDestroy_Click(object sender, EventArgs e)
{
- if (MessageBox.Show(this._displayUser.ScreenName + Properties.Resources.ButtonBlockDestroy_ClickText1,
- Properties.Resources.ButtonBlockDestroy_ClickText2,
- MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
+ if (MessageBox.Show(
+ this._displayUser.ScreenName + Properties.Resources.ButtonBlockDestroy_ClickText1,
+ Properties.Resources.ButtonBlockDestroy_ClickText2,
+ MessageBoxButtons.YesNo,
+ MessageBoxIcon.Warning,
+ MessageBoxDefaultButton.Button2) == DialogResult.Yes)
{
using (ControlTransaction.Disabled(this.ButtonBlockDestroy))
{
if (e.Data.GetDataPresent(DataFormats.FileDrop) &&
!e.Data.GetDataPresent(DataFormats.Html, false)) // WebBrowserコントロールからの絵文字画像D&Dは弾く
{
- var ret = MessageBox.Show(this, Properties.Resources.ChangeIconToolStripMenuItem_Confirm,
- ApplicationSettings.ApplicationName, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
+ var ret = MessageBox.Show(
+ this,
+ Properties.Resources.ChangeIconToolStripMenuItem_Confirm,
+ ApplicationSettings.ApplicationName,
+ MessageBoxButtons.OKCancel,
+ MessageBoxIcon.Question);
if (ret != DialogResult.OK)
return;
{
this.ocxServiceProvider.QueryService(
ref WebBrowserAPI.SID_SProfferService,
- ref WebBrowserAPI.IID_IProfferService, out this.profferServicePtr);
+ ref WebBrowserAPI.IID_IProfferService,
+ out this.profferServicePtr);
}
catch (SEHException ex)
{
}
}
- int WebBrowserAPI.IServiceProvider.QueryService(ref Guid guidService,
- ref Guid riid, out IntPtr ppvObject)
+ int WebBrowserAPI.IServiceProvider.QueryService(
+ ref Guid guidService,
+ ref Guid riid,
+ out IntPtr ppvObject)
{
ppvObject = IntPtr.Zero;