Esempio n. 1
0
        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;
                }
            }
        }
Esempio n. 2
0
 private void RefreshButton_Click(object sender, EventArgs e)
 {
     this.RefreshLists();
     this.ListsList.Items.Clear();
     this.ListsList.Items.AddRange(TabInformations.GetInstance().SubscribableLists.ToArray());
     if (this.ListsList.Items.Count > 0)
     {
         this.ListsList.SelectedIndex = 0;
     }
 }
Esempio n. 3
0
 private void SetTabnamesToDialog()
 {
     tabdialog.ClearTab();
     foreach (string key in _sts.Tabs.Keys)
     {
         if (TabInformations.GetInstance().IsDistributableTab(key))
         {
             tabdialog.AddTab(key);
         }
     }
 }
Esempio n. 4
0
        private async Task <IReadOnlyList <ListElement> > FetchListsAsync()
        {
            using var dialog = new WaitingDialog(Properties.Resources.ListsGetting);
            var cancellationToken = dialog.EnableCancellation();

            var task = this.tw.GetListsApi();
            await dialog.WaitForAsync(this, task);

            cancellationToken.ThrowIfCancellationRequested();

            return(TabInformations.GetInstance().SubscribableLists);
        }
Esempio n. 5
0
        private async Task <IReadOnlyList <ListElement> > FetchListsAsync()
        {
            using var dialog = new WaitingDialog("Getting Lists...");
            var cancellationToken = dialog.EnableCancellation();

            var tw   = ((TweenMain)this.Owner).TwitterInstance;
            var task = tw.GetListsApi();
            await dialog.WaitForAsync(this, task);

            cancellationToken.ThrowIfCancellationRequested();

            return(TabInformations.GetInstance().SubscribableLists);
        }
Esempio n. 6
0
        private void FilterDialog_Shown(object sender, EventArgs e)
        {
            _sts = TabInformations.GetInstance();
            ListTabs.Items.Clear();
            foreach (string key in _sts.Tabs.Keys)
            {
                ListTabs.Items.Add(key);
            }
            SetTabnamesToDialog();

            ComboSound.Items.Clear();
            ComboSound.Items.Add("");
            DirectoryInfo oDir = new DirectoryInfo(Application.StartupPath + Path.DirectorySeparatorChar);

            if (Directory.Exists(Path.Combine(Application.StartupPath, "Sounds")))
            {
                oDir = oDir.GetDirectories("Sounds")[0];
            }
            foreach (FileInfo oFile in oDir.GetFiles("*.wav"))
            {
                ComboSound.Items.Add(oFile.Name);
            }

            idlist.Clear();
            foreach (string tmp in ((TweenMain)this.Owner).AtIdSupl.GetItemList())
            {
                idlist.Add(tmp.Remove(0, 1));  // @文字削除
            }
            UID.AutoCompleteCustomSource.Clear();
            UID.AutoCompleteCustomSource.AddRange(idlist.ToArray());

            ExUID.AutoCompleteCustomSource.Clear();
            ExUID.AutoCompleteCustomSource.AddRange(idlist.ToArray());

            //選択タブ変更
            if (ListTabs.Items.Count > 0)
            {
                if (_cur.Length > 0)
                {
                    for (int i = 0; i < ListTabs.Items.Count; i++)
                    {
                        if (_cur == ListTabs.Items[i].ToString())
                        {
                            ListTabs.SelectedIndex = i;
                            //tabdialog.TabList.Items.Remove(_cur);
                            break;
                        }
                    }
                }
            }
        }
Esempio n. 7
0
 private void ListManage_Load(object sender, EventArgs e)
 {
     this.UserList_SelectedIndexChanged(null, EventArgs.Empty);
     if (TabInformations.GetInstance().SubscribableLists.Count == 0)
     {
         this.RefreshLists();
     }
     foreach (ListElement listItem in TabInformations.GetInstance().SubscribableLists.FindAll((i) => i.Username == this.tw.Username))
     {
         this.ListsList.Items.Add(listItem);
     }
     if (this.ListsList.Items.Count > 0)
     {
         this.ListsList.SelectedIndex = 0;
     }
     this.ListsList.Focus();
 }
Esempio n. 8
0
 private void ListAvailable_Shown(object sender, EventArgs e)
 {
     if (TabInformations.GetInstance().SubscribableLists.Count == 0)
     {
         this.RefreshLists();
     }
     this.ListsList.Items.AddRange(TabInformations.GetInstance().SubscribableLists.ToArray());
     if (this.ListsList.Items.Count > 0)
     {
         this.ListsList.SelectedIndex = 0;
     }
     else
     {
         this.UsernameLabel.Text        = "";
         this.NameLabel.Text            = "";
         this.StatusLabel.Text          = "";
         this.MemberCountLabel.Text     = "0";
         this.SubscriberCountLabel.Text = "0";
         this.DescriptionText.Text      = "";
     }
 }
Esempio n. 9
0
        private void SetFilters(string tabName)
        {
            if (ListTabs.Items.Count == 0)
            {
                return;
            }

            ListFilters.Items.Clear();
            ListFilters.Items.AddRange(_sts.Tabs[tabName].GetFilters());
            if (ListFilters.Items.Count > 0)
            {
                ListFilters.SelectedIndex = 0;
            }

            if (TabInformations.GetInstance().IsDefaultTab(tabName))
            {
                CheckLocked.Checked = true;
                CheckLocked.Enabled = false;
            }
            else
            {
                CheckLocked.Checked = _sts.Tabs[tabName].Locked;
                CheckLocked.Enabled = true;
            }

            CheckManageRead.Checked = _sts.Tabs[tabName].UnreadManage;
            CheckNotifyNew.Checked  = _sts.Tabs[tabName].Notify;

            int idx = ComboSound.Items.IndexOf(_sts.Tabs[tabName].SoundFile);

            if (idx == -1)
            {
                idx = 0;
            }
            ComboSound.SelectedIndex = idx;

            if (_directAdd)
            {
                return;
            }

            ListTabs.Enabled    = true;
            GroupTab.Enabled    = true;
            ListFilters.Enabled = true;
            if (ListFilters.SelectedIndex != -1)
            {
                ShowDetail();
            }
            EditFilterGroup.Enabled = false;
            switch (TabInformations.GetInstance().Tabs[tabName].TabType)
            {
            case MyCommon.TabUsageType.Home:
            case MyCommon.TabUsageType.DirectMessage:
            case MyCommon.TabUsageType.Favorites:
            case MyCommon.TabUsageType.PublicSearch:
            case MyCommon.TabUsageType.Lists:
            case MyCommon.TabUsageType.Related:
            case MyCommon.TabUsageType.UserTimeline:
                ButtonNew.Enabled      = false;
                ButtonEdit.Enabled     = false;
                ButtonDelete.Enabled   = false;
                ButtonRuleUp.Enabled   = false;
                ButtonRuleDown.Enabled = false;
                ButtonRuleCopy.Enabled = false;
                ButtonRuleMove.Enabled = false;
                break;

            default:
                ButtonNew.Enabled = true;
                if (ListFilters.SelectedIndex > -1)
                {
                    ButtonEdit.Enabled     = true;
                    ButtonDelete.Enabled   = true;
                    ButtonRuleUp.Enabled   = true;
                    ButtonRuleDown.Enabled = true;
                    ButtonRuleCopy.Enabled = true;
                    ButtonRuleMove.Enabled = true;
                }
                else
                {
                    ButtonEdit.Enabled     = false;
                    ButtonDelete.Enabled   = false;
                    ButtonRuleUp.Enabled   = false;
                    ButtonRuleDown.Enabled = false;
                    ButtonRuleCopy.Enabled = false;
                    ButtonRuleMove.Enabled = false;
                }
                break;
            }
            switch (TabInformations.GetInstance().Tabs[tabName].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;

            default:
                LabelTabType.Text = "UNKNOWN";
                break;
            }
            ButtonRenameTab.Enabled = true;
            if (TabInformations.GetInstance().IsDefaultTab(tabName) || TabInformations.GetInstance().Tabs[tabName].Locked)
            {
                ButtonDeleteTab.Enabled = false;
            }
            else
            {
                ButtonDeleteTab.Enabled = true;
            }
            ButtonClose.Enabled = true;
        }
Esempio n. 10
0
        private void MyLists_Load(object sender, EventArgs e)
        {
            this.ListsCheckedListBox.ItemCheck -= this.ListsCheckedListBox_ItemCheck;

            this.ListsCheckedListBox.Items.AddRange(TabInformations.GetInstance().SubscribableLists.FindAll((item) => item.Username == this._tw.Username).ToArray());

            for (int i = 0; i < this.ListsCheckedListBox.Items.Count; i++)
            {
                ListElement listItem = (ListElement)this.ListsCheckedListBox.Items[i];

                List <PostClass> listPost  = new List <PostClass>();
                List <PostClass> otherPost = new List <PostClass>();

                foreach (TabClass tab in TabInformations.GetInstance().Tabs.Values)
                {
                    if (tab.TabType == MyCommon.TabUsageType.Lists)
                    {
                        if (listItem.Id == tab.ListInfo.Id)
                        {
                            listPost.AddRange(tab.Posts.Values);
                        }
                        else
                        {
                            otherPost.AddRange(tab.Posts.Values);
                        }
                    }
                }

                //リストが空の場合は推定不能
                if (listPost.Count == 0)
                {
                    this.ListsCheckedListBox.SetItemCheckState(i, CheckState.Indeterminate);
                    continue;
                }

                //リストに該当ユーザーのポストが含まれていれば、リストにユーザーが含まれているとする。
                if (listPost.Exists((item) => item.ScreenName == contextUserName))
                {
                    this.ListsCheckedListBox.SetItemChecked(i, true);
                    continue;
                }

                List <long>   listPostUserIDs         = new List <long>();
                List <string> listPostUserNames       = new List <string>();
                DateTime      listOlderPostCreatedAt  = DateTime.MaxValue;
                DateTime      listNewistPostCreatedAt = DateTime.MinValue;

                foreach (PostClass post in listPost)
                {
                    if (post.UserId > 0 && !listPostUserIDs.Contains(post.UserId))
                    {
                        listPostUserIDs.Add(post.UserId);
                    }
                    if (post.ScreenName != null && !listPostUserNames.Contains(post.ScreenName))
                    {
                        listPostUserNames.Add(post.ScreenName);
                    }
                    if (post.CreatedAt < listOlderPostCreatedAt)
                    {
                        listOlderPostCreatedAt = post.CreatedAt;
                    }
                    if (post.CreatedAt > listNewistPostCreatedAt)
                    {
                        listNewistPostCreatedAt = post.CreatedAt;
                    }
                }

                //リスト中のユーザーの人数がlistItem.MemberCount以上で、かつ該当のユーザーが含まれていなければ、リストにユーザーは含まれていないとする。
                if (listItem.MemberCount > 0 && listItem.MemberCount <= listPostUserIDs.Count && (!listPostUserNames.Contains(contextUserName)))
                {
                    this.ListsCheckedListBox.SetItemChecked(i, false);
                    continue;
                }

                otherPost.AddRange(TabInformations.GetInstance().Posts.Values);

                //リストに該当ユーザーのポストが含まれていないのにリスト以外で取得したポストの中にリストに含まれるべきポストがある場合は、リストにユーザーは含まれていないとする。
                if (otherPost.Exists((item) => (item.ScreenName == this.contextUserName) && (item.CreatedAt > listOlderPostCreatedAt) && (item.CreatedAt < listNewistPostCreatedAt) && ((!item.IsReply) || listPostUserNames.Contains(item.InReplyToUser))))
                {
                    this.ListsCheckedListBox.SetItemChecked(i, false);
                    continue;
                }

                this.ListsCheckedListBox.SetItemCheckState(i, CheckState.Indeterminate);
            }

            this.ListsCheckedListBox.ItemCheck += this.ListsCheckedListBox_ItemCheck;
        }