Example #1
0
 private void lView_Groups_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (lView_Groups.SelectedItems.Count == 0)
     {
         btn_UpdateGroup.IsEnabled = false;
         btn_MoveUp.IsEnabled      = false;
         btn_MoveDn.IsEnabled      = false;
         btn_RemoveGroup.IsEnabled = false;
         return;
     }
     else if (lView_Groups.SelectedItems.Count == 1)
     {
         RichTextBoxHepler.SetText(rtb_GroupMembers, ((Group)lView_Groups.SelectedItem).Members);
         RichTextBoxHepler.SetText(rtb_Presenter, ((Group)lView_Groups.SelectedItem).Presenter);
         btn_UpdateGroup.IsEnabled = true;
         btn_MoveUp.IsEnabled      = true;
         btn_MoveDn.IsEnabled      = true;
         btn_RemoveGroup.IsEnabled = true;
         //lView_TargetList.SelectedItem = null;
         if (lView_TargetList.SelectedItem == null)
         {
             btn_SetAlterKey.IsEnabled = false;
         }
     }
 }
Example #2
0
 private void btn_AddGroup_Click(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrEmpty(RichTextBoxHepler.GetText(rtb_GroupMembers)) && !string.IsNullOrEmpty(RichTextBoxHepler.GetText(rtb_Presenter)))
     {
         string presenter = RichTextBoxHepler.GetText(rtb_Presenter).Replace(":", ":").Replace("/", "/").Replace("?", "?").Replace(",", "][").Trim();
         string members   = RichTextBoxHepler.GetText(rtb_GroupMembers).Replace(":", ":").Trim();
         if (!string.IsNullOrEmpty(OriginalSearchWord) && OriginalSearchWord != tbx_TitleKeyword.Text)
         {
             members = members + "," + OriginalSearchWord;
         }
         if (presenter.LastIndexOf(',') == presenter.Length - 1)
         {
             presenter = presenter.Substring(0, presenter.Length - 2);
         }
         groups.Add(new Group
         {
             Enable    = true,
             Presenter = "[" + presenter + "]",
             Members   = members
         });
         groups = new ObservableCollection <Group>(groups.OrderBy(i => i.Presenter));
         lView_Groups.ItemsSource = groups;
         lView_Groups.Items.Refresh();
         RichTextBoxHepler.SetText(rtb_Presenter, "");
         RichTextBoxHepler.SetText(rtb_GroupMembers, "");
         tbx_TitleKeyword.Text            = "";
         tbx_AnidbID.Text                 = "";
         cbox_AddKeywordToGroup.IsChecked = false;
     }
 }
Example #3
0
 private void btn_Undo_Click(object sender, RoutedEventArgs e)
 {
     if (lView_TargetList.Items.Count > 0)
     {
         List <ItemToRename> UndoList = new List <ItemToRename>();
         foreach (ItemToRename vi in lView_TargetList.Items)
         {
             ItemToRename ftr = new ItemToRename()
             {
                 Path     = vi.Path,
                 Before   = vi.Before,
                 AlterKey = vi.AlterKey,
                 After    = vi.After,
                 Result   = vi.Result
             };
             UndoList.Add(ftr);
         }
         if (UndoList.Any())
         {
             foreach (ItemToRename fileCandidate in UndoList)
             {
                 if (string.IsNullOrEmpty(fileCandidate.After))
                 {
                     fileCandidate.Result = GlobalConst.EMPTY_STRING;
                     continue;
                 }
                 if (Directory.Exists(Directory.GetParent(fileCandidate.Path).FullName + "\\" + fileCandidate.After))
                 {
                     try
                     {
                         Directory.Move(Directory.GetParent(fileCandidate.Path).FullName + "\\" + fileCandidate.After, fileCandidate.Path);
                         fileCandidate.Result = GlobalConst.RESULT_UNDO_OK;
                     }
                     catch (Exception)
                     {
                         fileCandidate.Result = GlobalConst.RESULT_UNDO_FAIL;
                     }
                 }
             }
             for (int i = 0; i < UndoList.Count; i++)
             {
                 int index = Targets.IndexOf(Targets.Where(X => X.Path == UndoList[i].Path).FirstOrDefault());
                 Targets[index].Result = UndoList[i].Result;
             }
         }
         UndoList.Clear();
         lView_TargetList.Items.Refresh();
         btn_Undo.IsEnabled    = false;
         tbx_TitleKeyword.Text = "";
         tbx_AnidbID.Text      = "";
         RichTextBoxHepler.SetText(rtb_GroupMembers, "");
         RichTextBoxHepler.SetText(rtb_Presenter, "");
         MessageBox.Show("Undo Completed!");
     }
 }
Example #4
0
        private void tbx_AnidbID_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
        {
            AnidbResult ar = GroupHandler.SearchAniDBByID(anititles, tbx_AnidbID.Text.Trim());

            if (ar != null)
            {
                RichTextBoxHepler.SetText(rtb_GroupMembers, ar.keywords);
                RichTextBoxHepler.SetText(rtb_Presenter, ar.presenter);
            }
            else
            {
                RichTextBoxHepler.SetText(rtb_Presenter, "");
            }
        }
Example #5
0
 private void btn_UpdateGroup_Click(object sender, RoutedEventArgs e)
 {
     if (lView_Groups.SelectedItems.Count == 1 && !string.IsNullOrEmpty(RichTextBoxHepler.GetText(rtb_GroupMembers)) && !string.IsNullOrEmpty(RichTextBoxHepler.GetText(rtb_Presenter)))
     {
         ((Group)lView_Groups.SelectedItem).Members   = RichTextBoxHepler.GetText(rtb_GroupMembers);
         ((Group)lView_Groups.SelectedItem).Presenter = RichTextBoxHepler.GetText(rtb_Presenter);
         btn_UpdateGroup.IsEnabled = false;
         //lView_Groups.SelectedItem = null;
         groups = new ObservableCollection <Group>(groups.OrderBy(i => i.Presenter));
         lView_Groups.ItemsSource = groups;
         lView_Groups.Items.Refresh();
         RichTextBoxHepler.SetText(rtb_GroupMembers, "");
         RichTextBoxHepler.SetText(rtb_Presenter, "");
     }
 }
Example #6
0
 private void btn_Reset_Filelist_Click(object sender, RoutedEventArgs e)
 {
     Targets.Clear();
     lbl_TargetCounts.Content     = "No. of Items : 0";
     lView_TargetList.ItemsSource = null;
     lView_TargetList.Items.Clear();
     lView_TargetList.Items.Refresh();
     listView_CollectionChanged(lView_Groups, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
     btn_Remove_Item.IsEnabled = false;
     btn_Undo.IsEnabled        = false;
     tbx_TitleKeyword.Text     = "";
     tbx_AnidbID.Text          = "";
     RichTextBoxHepler.SetText(rtb_GroupMembers, "");
     RichTextBoxHepler.SetText(rtb_Presenter, "");
 }
Example #7
0
        private void tbx_TitleKeyword_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
        {
            AnidbResult ar = GroupHandler.SearchAniDB(anititles, tbx_TitleKeyword.Text.Trim());

            if (ar != null)
            {
                tbx_AnidbID.Text = ar.aid;
                RichTextBoxHepler.SetText(rtb_GroupMembers, ar.keywords);
                //if (string.IsNullOrEmpty(RichTextBoxHepler.GetText(rtb_Presenter)))
                //{
                RichTextBoxHepler.SetText(rtb_Presenter, ar.presenter);
                //}
            }
            else
            {
                RichTextBoxHepler.SetText(rtb_Presenter, "");
            }
        }
Example #8
0
 private void btn_Remove_Item_Click(object sender, RoutedEventArgs e)
 {
     if (lView_TargetList.SelectedItems.Count != 0)
     {
         IEditableCollectionView items = lView_TargetList.Items;
         while (lView_TargetList.SelectedItems.Count != 0)
         {
             if (items.CanRemove)
             {
                 items.Remove(lView_TargetList.SelectedItems[0]);
                 tbx_TitleKeyword.Text = "";
                 tbx_AnidbID.Text      = "";
                 RichTextBoxHepler.SetText(rtb_GroupMembers, "");
                 RichTextBoxHepler.SetText(rtb_Presenter, "");
             }
         }
     }
     lbl_TargetCounts.Content = "No. of Items : " + Targets.Count;
 }
Example #9
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;
            }
        }
Example #10
0
 private void btn_Preview_Click(object sender, RoutedEventArgs e)
 {
     if (lView_Groups.Items.Count > 0 && lView_TargetList.Items.Count > 0)
     {
         lView_TargetList.ItemsSource = null;
         List <ItemToRename> newFilenameList = new List <ItemToRename>();
         foreach (ItemToRename vi in Targets)
         {
             ItemToRename ftr = new ItemToRename()
             {
                 Path     = vi.Path,
                 AlterKey = vi.AlterKey,
                 Before   = vi.Before
             };
             newFilenameList.Add(ftr);
         }
         if (groups.Any())
         {
             newFilenameList = GroupHandler.ReplaceFolderName(newFilenameList, groups.ToList());
             for (int i = 0; i < Targets.Count; i++)
             {
                 int index = Targets.IndexOf(Targets.Where(X => X.Path == newFilenameList[i].Path).FirstOrDefault());
                 if (Targets[index].Before != newFilenameList[i].Before)
                 {
                     Targets[index].After = newFilenameList[i].Before;
                 }
             }
         }
         newFilenameList.Clear();
         lView_TargetList.ItemsSource = Targets;
         lView_TargetList.Items.Refresh();
         tbx_TitleKeyword.Text = "";
         tbx_AnidbID.Text      = "";
         RichTextBoxHepler.SetText(rtb_GroupMembers, "");
         RichTextBoxHepler.SetText(rtb_Presenter, "");
     }
 }
Example #11
0
 private void btn_GO_Click(object sender, RoutedEventArgs e)
 {
     btn_Preview_Click(null, null);
     if (lView_Groups.Items.Count > 0 && lView_TargetList.Items.Count > 0)
     {
         lView_TargetList.ItemsSource = null;
         List <ItemToRename> RenameList = new List <ItemToRename>();
         foreach (ItemToRename vi in Targets)
         {
             ItemToRename ftr = new ItemToRename()
             {
                 Path     = vi.Path,
                 Before   = vi.Before,
                 AlterKey = vi.AlterKey,
                 After    = vi.After
             };
             RenameList.Add(ftr);
         }
         if (RenameList.Any())
         {
             foreach (ItemToRename fileCandidate in RenameList)
             {
                 if (Directory.Exists(fileCandidate.Path))
                 {
                     try
                     {
                         if (string.IsNullOrEmpty(fileCandidate.After))
                         {
                             fileCandidate.Result = GlobalConst.EMPTY_STRING;
                             continue;
                         }
                         if (!string.IsNullOrEmpty(Directory.GetParent(fileCandidate.Path).FullName + "\\" + fileCandidate.After))
                         {
                             if (fileCandidate.Path != Directory.GetParent(fileCandidate.Path).FullName + "\\" + fileCandidate.After)
                             {
                                 log.Info(Directory.GetParent(fileCandidate.Path).FullName + "\\" + fileCandidate.After);
                                 Directory.Move(fileCandidate.Path, Directory.GetParent(fileCandidate.Path).FullName + "\\" + fileCandidate.After);
                                 fileCandidate.Result = GlobalConst.RESULT_RENAME_OK;
                             }
                             else
                             {
                                 fileCandidate.Result = GlobalConst.RESULT_NO_RENAME;
                             }
                         }
                         else
                         {
                             fileCandidate.Result = GlobalConst.RESULT_INVALID_NEW_FOLDERNAME;
                         }
                     }
                     catch (Exception ex)
                     {
                         log.Error(ex.ToString());
                         fileCandidate.Result = GlobalConst.RESULT_RENAME_FAIL;
                     }
                 }
             }
         }
         for (int i = 0; i < RenameList.Count; i++)
         {
             int index = Targets.IndexOf(Targets.Where(X => X.Path == RenameList[i].Path).FirstOrDefault());
             Targets[index].Result = RenameList[i].Result;
         }
         RenameList.Clear();
         lView_TargetList.ItemsSource = Targets;
         lView_TargetList.Items.Refresh();
         btn_Undo.IsEnabled    = true;
         tbx_TitleKeyword.Text = "";
         tbx_AnidbID.Text      = "";
         RichTextBoxHepler.SetText(rtb_GroupMembers, "");
         RichTextBoxHepler.SetText(rtb_Presenter, "");
         MessageBox.Show("Rename Completed!");
     }
 }