private async Task <bool> ExecuteLink(string link) { var matchRes = Regex.Match(link, @"about:blank#res\?r_id=(?<Id>[0-9]+)"); var matchSend = Regex.Match(link, @"about:blank#send\?r_id=(?<Id>[0-9]+)"); var matchUser = Regex.Match(link, @"about:blank#user\?u_id=(?<Id>[0-9]+)|https?://askmona.org/user/(?<Id>[0-9]+)"); var matchAnchor = Regex.Match(link, @"about:blank#res_.+"); var matchAskMona = Regex.Match(link, @"https?://askmona.org/(?<Id>[0-9]+)"); if (matchRes.Success) { if (mPostResponseDialog != null) { mPostResponseDialog.UpdateTopic(mTopic, matchRes.Groups["Id"].Value); } else { mPostResponseDialog = new PostResponseDialog(this, mSettings.Options, mAskMonaApi, mImgurApi, mTopic, matchRes.Groups["Id"].Value); mPostResponseDialog.LoadSettings(mSettings.PostResponseDialogSettings); mPostResponseDialog.FormClosed += OnPostResponseDialogClosed; mPostResponseDialog.Show(this); } } else if (matchSend.Success) { var sendMonaDialog = new SendMonaDialog(this, mSettings.Options, mAskMonaApi, mTopic, int.Parse(matchSend.Groups["Id"].Value)); sendMonaDialog.LoadSettings(mSettings.SendMonaDialogSettings); sendMonaDialog.ShowDialog(); mSettings.SendMonaDialogSettings = sendMonaDialog.SaveSettings(); } else if (matchAskMona.Success) { var topicId = int.Parse(matchAskMona.Groups["Id"].Value); UpdateConnectionStatus("通信中"); toolStripComboBox1.Text = "https://askmona.org/" + topicId; if (!(await UpdateResponse(topicId))) { UpdateConnectionStatus("受信失敗"); } } else if (matchUser.Success) { var viewProfileDialog = new ViewProfileDialog(this, mSettings.Options, mAskMonaApi, int.Parse(matchUser.Groups["Id"].Value)); viewProfileDialog.LoadSettings(mSettings.ViewProfileDialogSettings); viewProfileDialog.ShowDialog(); mSettings.ViewProfileDialogSettings = viewProfileDialog.SaveSettings(); } else if (matchAnchor.Success) { return(false); } else { System.Diagnostics.Process.Start(link); } return(true); }
private void toolStripButton6_Click(object sender, EventArgs e) { if (mTopic == null || mPostResponseDialog != null) { return; } mPostResponseDialog = new PostResponseDialog(this, mSettings.Options, mAskMonaApi, mImgurApi, mTopic); mPostResponseDialog.LoadSettings(mSettings.PostResponseDialogSettings); mPostResponseDialog.FormClosed += OnPostResponseDialogClosed; mPostResponseDialog.Show(this); }