private async void ListManage_Load(object sender, EventArgs e) { using (ControlTransaction.Disabled(this)) { try { var lists = (IReadOnlyList <ListElement>)TabInformations.GetInstance().SubscribableLists; if (lists.Count == 0) { lists = await this.FetchListsAsync(); } this.UpdateListsListBox(lists); } catch (OperationCanceledException) { this.DialogResult = DialogResult.Cancel; return; } catch (WebApiException) { this.DialogResult = DialogResult.Abort; return; } } }
private async void DeleteUserButton_Click(object sender, EventArgs e) { if (this.ListsList.SelectedItem == null || this.UserList.SelectedItem == null) { return; } using (ControlTransaction.Disabled(this)) { ListElement list = (ListElement)this.ListsList.SelectedItem; UserInfo user = (UserInfo)this.UserList.SelectedItem; if (MessageBox.Show(Properties.Resources.ListManageDeleteUser1, ApplicationSettings.ApplicationName, MessageBoxButtons.OKCancel) == DialogResult.OK) { try { await this.tw.Api.ListsMembersDestroy(list.Id, user.ScreenName) .IgnoreResponse(); } catch (WebApiException ex) { MessageBox.Show(string.Format(Properties.Resources.ListManageDeleteUser2, ex.Message)); return; } int idx = ListsList.SelectedIndex; list.Members.Remove(user); this.ListsList_SelectedIndexChanged(this.ListsList, EventArgs.Empty); if (idx < ListsList.Items.Count) { ListsList.SelectedIndex = idx; } } } }
private async void GetMoreUsersButton_Click(object sender, EventArgs e) { using (ControlTransaction.Disabled(this)) { if (this.ListsList.SelectedItem == null) { return; } this.UserList.Items.Clear(); var list = (ListElement)this.ListsList.SelectedItem; try { await list.GetMoreMembers(); } catch (WebApiException ex) { MessageBox.Show(string.Format(Properties.Resources.ListManageGetListMembersCallback1, ex.Message)); return; } this.ListsList_SelectedIndexChanged(this.ListsList, EventArgs.Empty); this.GetMoreUsersButton.Text = Properties.Resources.ListManageGetMoreUsers1; } }
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) { using (ControlTransaction.Disabled(this.ButtonUnFollow)) { try { await this.twitterApi.FriendshipsDestroy(this._displayUser.ScreenName) .IgnoreResponse(); } catch (WebApiException ex) { MessageBox.Show(Properties.Resources.FRMessage2 + ex.Message); return; } } MessageBox.Show(Properties.Resources.FRMessage3); LabelIsFollowing.Text = Properties.Resources.GetFriendshipInfo2; ButtonFollow.Enabled = true; ButtonUnFollow.Enabled = false; } }
private async void MenuItemDelete_Click(object sender, EventArgs e) { using (ControlTransaction.Disabled(this)) { await this.RemoveFromList((ListElement)this.ListsCheckedListBox.SelectedItem); } }
private async void buttonLogin_Click(object sender, EventArgs e) { if (this.LoginCallback == null) { return; } try { using (ControlTransaction.Disabled(this)) { // AcceptButton によって自動でフォームが閉じられるのを抑制する this.AcceptButton = null; this.LoginSuccessed = await this.LoginCallback(); if (this.LoginSuccessed) { this.DialogResult = DialogResult.OK; } } } finally { this.AcceptButton = this.buttonLogin; } }
private async void ListRefreshButton_Click(object sender, EventArgs e) { using (ControlTransaction.Disabled(this)) { try { await this.RefreshListBox(); } catch (OperationCanceledException) { } catch (WebApiException ex) { MessageBox.Show($"Failed to get lists. ({ex.Message})"); } } }
private async void RefreshButton_Click(object sender, EventArgs e) { using (ControlTransaction.Disabled(this)) { try { var lists = await this.FetchListsAsync(); this.UpdateListsListBox(lists); } catch (OperationCanceledException) { } catch (WebApiException ex) { MessageBox.Show("Failed to get lists. (" + ex.Message + ")"); } } }
private async void RefreshListsButton_Click(object sender, EventArgs e) { using (ControlTransaction.Disabled(this)) { try { var lists = await this.FetchListsAsync(); this.UpdateListsListBox(lists); } catch (OperationCanceledException) { } catch (WebApiException ex) { MessageBox.Show(string.Format(Properties.Resources.ListsDeleteFailed, ex.Message)); } } }
private async void MyLists_Load(object sender, EventArgs e) { using (ControlTransaction.Disabled(this)) { try { await this.RefreshListBox(); } catch (OperationCanceledException) { this.DialogResult = DialogResult.Cancel; } catch (WebApiException ex) { MessageBox.Show($"Failed to get lists. ({ex.Message})"); this.DialogResult = DialogResult.Abort; } } }
private async void StartAuthButton_Click(object sender, EventArgs e) { using (ControlTransaction.Disabled(this.BasedPanel.StartAuthButton)) { try { this.ApplyNetworkSettings(); var newAccount = await this.PinAuth(); if (newAccount == null) { return; } var authUserCombo = this.BasedPanel.AuthUserCombo; var oldAccount = authUserCombo.Items.Cast <UserAccount>() .FirstOrDefault(x => x.UserId == newAccount.UserId); int idx; if (oldAccount != null) { idx = authUserCombo.Items.IndexOf(oldAccount); authUserCombo.Items[idx] = newAccount; } else { idx = authUserCombo.Items.Add(newAccount); } authUserCombo.SelectedIndex = idx; MessageBox.Show(this, Properties.Resources.AuthorizeButton_Click1, "Authenticate", MessageBoxButtons.OK); } catch (WebApiException ex) { var message = Properties.Resources.AuthorizeButton_Click2 + Environment.NewLine + ex.Message; MessageBox.Show(this, message, "Authenticate", MessageBoxButtons.OK); } } }
private async void ButtonFollow_Click(object sender, EventArgs e) { using (ControlTransaction.Disabled(this.ButtonFollow)) { try { await this.twitterApi.FriendshipsCreate(this._displayUser.ScreenName) .IgnoreResponse(); } catch (WebApiException ex) { MessageBox.Show(Properties.Resources.FRMessage2 + ex.Message); return; } } MessageBox.Show(Properties.Resources.FRMessage3); LabelIsFollowing.Text = Properties.Resources.GetFriendshipInfo1; ButtonFollow.Enabled = false; ButtonUnFollow.Enabled = true; }
private async void ListsCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e) { // 他のイベント等で操作中の場合は無視する if (!this.Enabled) { return; } using (ControlTransaction.Disabled(this)) { var list = (ListElement)this.ListsCheckedListBox.Items[e.Index]; if (e.CurrentValue == CheckState.Unchecked) { await this.AddToList(list); } else { await this.RemoveFromList(list); } } }
private async void OKEditButton_Click(object sender, EventArgs e) { if (this.ListsList.SelectedItem == null) { return; } using (ControlTransaction.Disabled(this)) { ListElement listItem = (ListElement)this.ListsList.SelectedItem; if (string.IsNullOrEmpty(this.NameTextBox.Text)) { MessageBox.Show(Properties.Resources.ListManageOKButton1); return; } listItem.Name = this.NameTextBox.Text; listItem.IsPublic = this.PublicRadioButton.Checked; listItem.Description = this.DescriptionText.Text; try { await listItem.Refresh(); } catch (WebApiException ex) { MessageBox.Show(string.Format(Properties.Resources.ListManageOKButton2, ex.Message)); return; } this.ListsList.Items.Clear(); this.ListManage_Load(null, EventArgs.Empty); this.EditCheckBox.AutoCheck = true; this.EditCheckBox.Checked = false; } }
private async void DeleteListButton_Click(object sender, EventArgs e) { if (this.ListsList.SelectedItem == null) { return; } using (ControlTransaction.Disabled(this)) { ListElement list = (ListElement)this.ListsList.SelectedItem; if (MessageBox.Show(Properties.Resources.ListManageDeleteLists1, ApplicationSettings.ApplicationName, MessageBoxButtons.OKCancel) == DialogResult.OK) { try { await this.tw.DeleteList(list.Id); } catch (WebApiException ex) { MessageBox.Show(Properties.Resources.ListManageOKButton2, ex.Message); return; } try { await this.tw.GetListsApi(); } catch (WebApiException ex) { MessageBox.Show(Properties.Resources.ListsDeleteFailed, ex.Message); return; } this.ListsList.Items.Clear(); this.ListManage_Load(this, EventArgs.Empty); } } }
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) { using (ControlTransaction.Disabled(this.ButtonBlockDestroy)) { try { await this.twitterApi.BlocksDestroy(this._displayUser.ScreenName) .IgnoreResponse(); } catch (WebApiException ex) { MessageBox.Show("Err:" + ex.Message + Environment.NewLine + Properties.Resources.ButtonBlockDestroy_ClickText3); return; } MessageBox.Show(Properties.Resources.ButtonBlockDestroy_ClickText4); } } }
private async void ButtonEdit_Click(object sender, EventArgs e) { // 自分以外のプロフィールは変更できない if (this.twitterApi.CurrentUserId != this._displayUser.Id) { return; } using (ControlTransaction.Disabled(this.ButtonEdit)) { if (!IsEditing) { ButtonEditText = ButtonEdit.Text; ButtonEdit.Text = Properties.Resources.UserInfoButtonEdit_ClickText1; TextBoxName.Text = LabelName.Text; TextBoxName.Enabled = true; TextBoxName.Visible = true; LabelName.Visible = false; TextBoxLocation.Text = LabelLocation.Text; TextBoxLocation.Enabled = true; TextBoxLocation.Visible = true; LabelLocation.Visible = false; TextBoxWeb.Text = this._displayUser.Url; TextBoxWeb.Enabled = true; TextBoxWeb.Visible = true; LinkLabelWeb.Visible = false; TextBoxDescription.Text = this._displayUser.Description; TextBoxDescription.Enabled = true; TextBoxDescription.Visible = true; DescriptionBrowser.Visible = false; TextBoxName.Focus(); TextBoxName.Select(TextBoxName.Text.Length, 0); IsEditing = true; } else { Task showUserTask = null; if (TextBoxName.Modified || TextBoxLocation.Modified || TextBoxWeb.Modified || TextBoxDescription.Modified) { try { var response = await this.twitterApi.AccountUpdateProfile( this.TextBoxName.Text, this.TextBoxWeb.Text, this.TextBoxLocation.Text, this.TextBoxDescription.Text); var user = await response.LoadJsonAsync(); showUserTask = this.ShowUserAsync(user); } catch (WebApiException ex) { MessageBox.Show($"Err:{ex.Message}(AccountUpdateProfile)"); return; } } TextBoxName.Enabled = false; TextBoxName.Visible = false; LabelName.Visible = true; TextBoxLocation.Enabled = false; TextBoxLocation.Visible = false; LabelLocation.Visible = true; TextBoxWeb.Enabled = false; TextBoxWeb.Visible = false; LinkLabelWeb.Visible = true; TextBoxDescription.Enabled = false; TextBoxDescription.Visible = false; DescriptionBrowser.Visible = true; ButtonEdit.Text = ButtonEditText; IsEditing = false; if (showUserTask != null) { await showUserTask; } } } }