Exemplo n.º 1
0
        private void lView_TargetList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lView_TargetList.SelectedItems.Count > 0)
            {
                btn_Remove_Item.IsEnabled = true;
                if (lView_TargetList.SelectedItems.Count == 1)
                {
                    tbx_TitleKeyword.Text = string.IsNullOrEmpty(((ItemToRename)lView_TargetList.SelectedItems[0]).AlterKey) ?
                                            GroupHandler.GetTitleKeyword(Path.GetFileNameWithoutExtension(((ItemToRename)lView_TargetList.SelectedItems[0]).Before)) : ((ItemToRename)lView_TargetList.SelectedItems[0]).AlterKey;

                    OriginalSearchWord = string.IsNullOrEmpty(tbx_TitleKeyword.Text) ? ((ItemToRename)lView_TargetList.SelectedItems[0]).Before : tbx_TitleKeyword.Text;
                    if (string.IsNullOrEmpty(tbx_TitleKeyword.Text))
                    {
                        tbx_TitleKeyword.Text = OriginalSearchWord;
                    }
                    AnidbResult ar = SearchMatchFromBothSources(OriginalSearchWord);
                    if (ar != null)
                    {
                        if (ar.aid == "xxx")
                        {
                            Group presetgroup = groups.Where(x => x.Presenter == ar.presenter).FirstOrDefault();
                            if (presetgroup != null)
                            {
                                lbl_GroupsMatch.Visibility = Visibility.Visible;
                                lView_Groups.SelectedItem  = presetgroup;
                                lView_Groups.Items.Refresh();
                                lView_Groups.ScrollIntoView(presetgroup);
                            }
                        }
                        else
                        {
                            lbl_GroupsMatch.Visibility = Visibility.Hidden;
                            tbx_AnidbID.Text           = ar.aid;
                        }
                        tbx_Presenter.Text    = ar.presenter;
                        tbx_GroupMembers.Text = ar.keywords;
                    }
                    else
                    {
                        tbx_Presenter.Text    = "";
                        tbx_GroupMembers.Text = "";
                    }
                }
            }
            else
            {
                btn_Remove_Item.IsEnabled = false;
            }
        }
Exemplo n.º 2
0
        private void lView_TargetList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lView_TargetList.SelectedItems.Count > 0)
            {
                btn_Remove_Item.IsEnabled = true;
                if (lView_TargetList.SelectedItems.Count == 1)
                {
                    tbx_TitleKeyword.Text = string.IsNullOrEmpty(((ItemToRename)lView_TargetList.SelectedItems[0]).AlterKey) ?
                                            GroupHandler.GetTitleKeyword(((ItemToRename)lView_TargetList.SelectedItems[0]).Before) : ((ItemToRename)lView_TargetList.SelectedItems[0]).AlterKey;

                    OriginalSearchWord = tbx_TitleKeyword.Text;
                    AnidbResult ar = GroupHandler.SearchAniDB(anititles, tbx_TitleKeyword.Text);
                    if (ar != null)
                    {
                        tbx_AnidbID.Text = ar.aid;
                        RichTextBoxHepler.SetText(rtb_Presenter, ar.presenter);
                        RichTextBoxHepler.SetText(rtb_GroupMembers, ar.keywords);
                    }
                    else
                    {
                        Group presetgroup = groups.Where(x => x.Members.ToLowerInvariant().Contains(tbx_TitleKeyword.Text.ToLowerInvariant())).FirstOrDefault();
                        if (presetgroup != null)
                        {
                            RichTextBoxHepler.SetText(rtb_Presenter, presetgroup.Presenter);
                            RichTextBoxHepler.SetText(rtb_GroupMembers, presetgroup.Members);
                            lView_Groups.SelectedItem = presetgroup;
                            lView_Groups.Items.Refresh();
                            lView_Groups.ScrollIntoView(presetgroup);
                        }
                        else
                        {
                            RichTextBoxHepler.SetText(rtb_Presenter, "");
                            RichTextBoxHepler.SetText(rtb_GroupMembers, "");
                        }
                    }
                    //lView_Groups.SelectedItem = null;
                }
            }
            else
            {
                btn_Remove_Item.IsEnabled = false;
            }
        }