Exemplo n.º 1
0
        /*
         * ============================================
         * Private
         * ============================================
         */

        /// <summary>
        /// Initialize the window's content.
        /// </summary>
        private void InitContent(Entity.Season season = null)
        {
            this.Owner = App.Current.MainWindow;
            List <Entity.Studio> studios = Repository.Studio.Instance.GetAll();

            foreach (Entity.Studio studio in studios)
            {
                this.AddCommboBoxItem(this.ComboBox_Studio, studio.Name, studio.Id);

                if (season != null && studio.Id == season.StudioId)
                {
                    this.SelectValue(this.ComboBox_Studio, studio.Name);
                }
            }

            // Add types
            foreach (Constants.Type type in Enum.GetValues(typeof(Constants.Type)))
            {
                this.AddCommboBoxItem(this.ComboBox_Type, Lang.Content(type.ToString().ToLower()), type);
            }

            // Add sources
            foreach (Constants.Source source in Enum.GetValues(typeof(Constants.Source)))
            {
                this.AddCommboBoxItem(this.ComboBox_Source, Lang.Content(source.ToString().ToLower()), source);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Start fetching online covers.
        /// </summary>
        /// <param name="animeTitle"></param>
        private void StartSearch()
        {
            // Search only if we have a valid text
            if (String.IsNullOrWhiteSpace(this.TextBox_Title.Text))
            {
                return;
            }

            this.isSearching             = true;
            this.label_Loading.Content   = Lang.Content("loading");
            this.label_Loading.Opacity   = 1;
            this.Button_Search.Content   = Lang.Content("cancel");
            this.button_Select.IsEnabled = false;

            this.Covers.Children.Clear();

            this.TextBox_Type.Clear();
            this.TextBox_Episodes.Clear();
            this.TextBox_Seasonal.Clear();
            this.TextBox_Year.Clear();
            this.TextBox_Genres.Clear();
            this.TextBox_Source.Clear();
            this.ComboBox_Studio.Items.Clear();

            this.searchThread = new Thread(new ParameterizedThreadStart(FindDataFromMal));
            this.searchThread.Start(this.TextBox_Title.Text);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Remove all the files kept in the cache folder.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem_EmptyCache_(object sender, RoutedEventArgs e)
        {
            string cacheDir = Hieda.App.appFolder + @"\cache\";
            int    deleted  = 0;

            if (Directory.Exists(cacheDir))
            {
                string[] files = Directory.GetFiles(cacheDir);

                foreach (string file in files)
                {
                    try {
                        File.Delete(file);

                        deleted++;
                    } catch { }
                }
            }

            this.Notify(
                Constants.Notify.Notif,
                Lang.OPERATION_FINISHED_TITLE,
                String.Format(Lang.Content("fileRemovalSuccess"), deleted)
                );
        }
Exemplo n.º 4
0
        /// <summary>
        /// Upload the local database file to Dropbox.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Button_UploadDb_Click(object sender, RoutedEventArgs e)
        {
            this.PrepareAction(true, Lang.Content("uploading", "Uploading") + "...");
            this.DisconnectDb(false);

            await this.dropboxTool.Upload(this.localDbPath, REMOTE_DB_PATH);

            this.ReconnectDb();
            this.PrepareAction(false, Lang.Content("uploaded", "Uploaded") + ".", 100);
        }
Exemplo n.º 5
0
        private void StopSearch()
        {
            if (this.searchThread.IsAlive)
            {
                this.searchThread.Abort();
            }

            this.isSearching           = false;
            this.Button_Search.Content = Lang.Content("search");
        }
Exemplo n.º 6
0
        /*
         * ============================================
         * Private
         * ============================================
         */

        /// <summary>
        /// Try to log into Dropbox then enable the buttons if successful.
        /// </summary>
        private void TryLogin()
        {
            if (this.dropboxTool.HasAccessToken && this.dropboxTool.Login())
            {
                this.Button_Download.IsEnabled = true;
                this.Button_Upload.IsEnabled   = true;

                this.Label_Authenticated.Content   = Lang.Content("dropboxLogged");
                this.Label_Action.Content          = Lang.Content("authenticated") + ".";
                this.Button_Authenticate.IsEnabled = false;

                this.SetAccountLabel();
            }
        }
Exemplo n.º 7
0
        /*
         * ============================================
         * Public
         * ============================================
         */

        /// <summary>
        /// Configure the window for adding multiple seasons.
        /// </summary>
        public void ConfigureForSeasons()
        {
            // Add types
            foreach (int i in System.Enum.GetValues(typeof(Constants.Type)))
            {
                this.ComboBox_Type.Items.Add(new ComboBoxItem()
                {
                    Content = Lang.Content(System.Enum.GetName(typeof(Constants.Type), i).ToLower())
                });
            }

            this.ComboBox_Type.SelectedIndex = (byte)Constants.Type.None;
            this.ComboBox_Type.IsEnabled     = true;
            this.TextBox_Title.Text          = Tools.UpperFirst(Lang.SEASON) + " %number%";
        }
Exemplo n.º 8
0
        /// <summary>
        /// Add user stats in the Status combobox.
        /// </summary>
        /// <param name="userStatusList"></param>
        private void SetStatusInCombo(List <Entity.UserStatus> userStatusList)
        {
            // Add default status
            this.AddCommboBoxItem(this.ComboBox_Status, Lang.Content("none"), Entity.DefaultStatus.None);
            this.AddCommboBoxItem(this.ComboBox_Status, Lang.Content("toWatch"), Entity.DefaultStatus.ToWatch);
            this.AddCommboBoxItem(this.ComboBox_Status, Lang.Content("current"), Entity.DefaultStatus.Current);
            this.AddCommboBoxItem(this.ComboBox_Status, Lang.Content("standBy"), Entity.DefaultStatus.StandBy);
            this.AddCommboBoxItem(this.ComboBox_Status, Lang.Content("finished"), Entity.DefaultStatus.Finished);
            this.AddCommboBoxItem(this.ComboBox_Status, Lang.Content("dropped"), Entity.DefaultStatus.Dropped);

            this.ComboBox_Status.Items.Add(new Separator());

            // Add user status
            foreach (Entity.UserStatus userStatus in userStatusList)
            {
                this.AddCommboBoxItem(this.ComboBox_Status, userStatus.Text, userStatus.Id);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Download the database file from Dropbox.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Button_DownloadDb_Click(object sender, RoutedEventArgs e)
        {
            this.PrepareAction(true, Lang.Content("downloading", "Downloading") + "...");
            this.DisconnectDb(true);

            if (System.IO.File.Exists(this.localDbPath))
            {
                System.IO.File.Delete(this.localDbPath);
            }

            await this.dropboxTool.Download(REMOTE_DB_PATH, this.localDbPath);

            this.ReconnectDb();
            this.PrepareAction(false, Lang.Content("downloaded", "Downloaded") + ".", 100);

            // Will reload the collection
            this.needReload = true;

            // Check DB version for migration
            App.db.CheckForUpdates();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Remove images from covers/full and covers/thumb folders not referenced in DB.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuitem_DeleteUnusedCoverFiles_Click(object sender, RoutedEventArgs e)
        {
            this.Collection.Blackout(true);

            TwoButtonsDialog dialog = new TwoButtonsDialog(
                Lang.Text("removeUnusedCovers", "This operation will remove unused covers from disk."),
                Lang.Text("deleteUnusedCover", "Delete unused cover files"), Lang.START, Lang.ABORT
                );

            dialog.Owner = this;

            if (dialog.Open())
            {
                int deleted = this.DeleteUnusedCoverFiles();

                this.Notify(
                    Constants.Notify.Notif,
                    Lang.OPERATION_FINISHED_TITLE,
                    String.Format(Lang.Content("fileRemovalSuccess"), deleted)
                    );
            }

            this.Collection.Blackout(false);
        }
Exemplo n.º 11
0
        /*
         * ============================================
         * Event
         * ============================================
         */

        #region Event

        /// <summary>
        /// Called when the value of the Width slider changes.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Slider_Width_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            this.Label_Width.Content = String.Format(Lang.Content("thumbnailWidth"), (int)this.Slider_Width.Value);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Called one a search has ended.
 /// </summary>
 private void SearchEnded()
 {
     this.isSearching             = false;
     this.Button_Search.Content   = Lang.Content("search");
     this.button_Select.IsEnabled = true;
 }
Exemplo n.º 13
0
        /*
         * ============================================
         * Protected
         * ============================================
         */

        #region Protected

        protected ContextMenu GetSerieAndSeasonContextMenu(string cover)
        {
            ContextMenu context = new ContextMenu();

            // Note: this may be false when running from Visual Studio, as rights restrict access to the filesystem
            bool coverExists = this.CoverExists(cover);

            // Go to seasons
            MenuItem item = new MenuItem();

            item.Header = Lang.GO_TO_NEXT_LEVEL;
            item.Click += this.ContextMenu_MenuItem_Click;
            item.Tag    = "goToNextLevel";
            context.Items.Add(item);
            context.Items.Add(new Separator());
            // Continue
            item        = new MenuItem();
            item.Header = Lang.CONTINUE;
            item.Click += this.ContextMenu_MenuItem_Click;
            //item.IsEnabled = false;
            item.Tag = "continue";
            context.Items.Add(item);
            // Edit
            item        = new MenuItem();
            item.Header = Lang.EDIT;
            item.Click += this.ContextMenu_MenuItem_Click;
            item.Tag    = "edit";
            context.Items.Add(item);
            // Delete
            item        = new MenuItem();
            item.Header = Lang.DELETE;
            item.Click += this.ContextMenu_MenuItem_Click;
            item.Tag    = "delete";
            context.Items.Add(item);
            // Season only
            if (Collection.ItemLevel == Constants.Level.Season)
            {
                item        = new MenuItem();
                item.Header = Lang.Content("move");
                item.Click += this.ContextMenu_MenuItem_Click;
                item.Tag    = "moveItems";
                context.Items.Add(item);
            }
            // Relocate episodes
            item        = new MenuItem();
            item.Header = Lang.Header("relocateEpisodes");
            item.Tag    = "relocateEpisodes";
            item.Click += this.ContextMenu_MenuItem_Click;
            context.Items.Add(item);

            context.Items.Add(new Separator());

            // Cover
            item        = new MenuItem();
            item.Header = Lang.COVER;
            context.Items.Add(item);
            // View full
            MenuItem subItem = new MenuItem();

            subItem.Header    = Lang.VIEW_FULL;
            subItem.Click    += this.ContextMenu_MenuItem_Click;
            subItem.IsEnabled = coverExists;
            subItem.Tag       = "viewFull";
            item.Items.Add(subItem);
            // Copy file
            subItem           = new MenuItem();
            subItem.Header    = Lang.COPY_FILE;
            subItem.Click    += this.ContextMenu_MenuItem_Click;
            subItem.IsEnabled = coverExists;
            subItem.Tag       = "copyFile";
            item.Items.Add(subItem);
            // Change
            subItem        = new MenuItem();
            subItem.Header = Lang.CHANGE;
            subItem.Click += this.ContextMenu_MenuItem_Click;
            subItem.Tag    = "change";
            item.Items.Add(subItem);
            // Remove
            subItem           = new MenuItem();
            subItem.Header    = Lang.REMOVE;
            subItem.Click    += this.ContextMenu_MenuItem_Click;
            subItem.Tag       = "removeCover";
            subItem.IsEnabled = !String.IsNullOrEmpty(cover);
            item.Items.Add(subItem);
            // Online cover search
            subItem        = new MenuItem();
            subItem.Header = Lang.Content("search");
            subItem.Click += this.ContextMenu_MenuItem_Click;
            subItem.Tag    = "onlineCover";
            item.Items.Add(subItem);

            // Status
            this.AddStatusSubContext(ref context);

            return(context);
        }
Exemplo n.º 14
0
        protected ContextMenu GetEpisodeContextMenu(string cover)
        {
            ContextMenu context     = new ContextMenu();
            bool        coverExists = this.CoverExists(cover);

            // Edit
            MenuItem item = new MenuItem();

            item.Header = Lang.EDIT;
            item.Click += this.ContextMenu_MenuItem_Click;
            item.Tag    = "edit";
            context.Items.Add(item);
            // Delete
            item        = new MenuItem();
            item.Header = Lang.DELETE;
            item.Click += this.ContextMenu_MenuItem_Click;
            item.Tag    = "delete";
            context.Items.Add(item);
            // Move
            item        = new MenuItem();
            item.Header = Lang.Content("move");
            item.Click += this.ContextMenu_MenuItem_Click;
            item.Tag    = "moveItems";
            context.Items.Add(item);
            // -
            context.Items.Add(new Separator());
            // Play with
            item        = new MenuItem();
            item.Header = Lang.Header("playWith");
            context.Items.Add(item);
            // Default player
            MenuItem subItem = new MenuItem();

            subItem.Header    = Lang.Header("defaultPlayer");
            subItem.Click    += this.ContextMenu_MenuItem_Click;
            subItem.IsEnabled = !this.error;
            subItem.Tag       = "playWithDefault";
            item.Items.Add(subItem);
            // VLC
            subItem           = new MenuItem();
            subItem.Header    = "VLC";
            subItem.Click    += this.ContextMenu_MenuItem_Click;
            subItem.IsEnabled = !this.error;
            subItem.Tag       = "playWithVlc";
            item.Items.Add(subItem);
            // MPC-HC
            subItem           = new MenuItem();
            subItem.Header    = "MPC-HC";
            subItem.Click    += this.ContextMenu_MenuItem_Click;
            subItem.IsEnabled = !this.error;
            subItem.Tag       = "playWithMpcHc";
            item.Items.Add(subItem);
            // mpv
            subItem           = new MenuItem();
            subItem.Header    = "mpv";
            subItem.Click    += this.ContextMenu_MenuItem_Click;
            subItem.IsEnabled = !this.error;
            subItem.Tag       = "playWithMpv";
            item.Items.Add(subItem);
            // Linked file
            item        = new MenuItem();
            item.Header = Lang.LINKED_FILE;
            context.Items.Add(item);
            // Copy
            subItem           = new MenuItem();
            subItem.Header    = Lang.COPY;
            subItem.Click    += this.ContextMenu_MenuItem_Click;
            subItem.IsEnabled = !this.error;
            subItem.Tag       = "copy";
            item.Items.Add(subItem);
            // Copy path
            subItem           = new MenuItem();
            subItem.Header    = Lang.COPY_PATH;
            subItem.Click    += this.ContextMenu_MenuItem_Click;
            subItem.IsEnabled = !this.error;
            subItem.Tag       = "copyLinkedPath";
            item.Items.Add(subItem);
            // Delete
            subItem           = new MenuItem();
            subItem.Header    = Lang.DELETE;
            subItem.Click    += this.ContextMenu_MenuItem_Click;
            subItem.Tag       = "deleteLinkedFile";
            subItem.IsEnabled = !this.error;
            item.Items.Add(subItem);
            // Relocate
            subItem        = new MenuItem();
            subItem.Header = Lang.Header("relocate");
            subItem.Click += this.ContextMenu_MenuItem_Click;
            subItem.Tag    = "relocateEpisode";
            item.Items.Add(subItem);
            // Open folder
            subItem           = new MenuItem();
            subItem.Header    = Lang.OPEN_FOLDER;
            subItem.Click    += this.ContextMenu_MenuItem_Click;
            subItem.IsEnabled = !this.error;
            subItem.Tag       = "openFolder";
            item.Items.Add(subItem);
            // Import subtitle
            subItem           = new MenuItem();
            subItem.Header    = Lang.IMPORT_SUBTITLE;
            subItem.Click    += this.ContextMenu_MenuItem_Click;
            subItem.IsEnabled = !this.error;
            subItem.Tag       = "importSubtitle";
            item.Items.Add(subItem);
            // Cover
            item        = new MenuItem();
            item.Header = Lang.COVER;
            context.Items.Add(item);
            // View full
            subItem        = new MenuItem();
            subItem.Header = Lang.VIEW_FULL;
            subItem.Click += this.ContextMenu_MenuItem_Click;
            subItem.Tag    = "viewFull";
            item.Items.Add(subItem);
            subItem.IsEnabled = coverExists;
            // Copy file
            subItem        = new MenuItem();
            subItem.Header = Lang.COPY_FILE;
            subItem.Click += this.ContextMenu_MenuItem_Click;
            subItem.Tag    = "copyFile";
            item.Items.Add(subItem);
            subItem.IsEnabled = coverExists;
            // Change
            subItem        = new MenuItem();
            subItem.Header = Lang.CHANGE;
            subItem.Click += this.ContextMenu_MenuItem_Click;
            subItem.Tag    = "change";
            item.Items.Add(subItem);
            // Remove
            subItem           = new MenuItem();
            subItem.Header    = Lang.REMOVE;
            subItem.Click    += this.ContextMenu_MenuItem_Click;
            subItem.Tag       = "removeCover";
            subItem.IsEnabled = !String.IsNullOrEmpty(cover);
            item.Items.Add(subItem);
            // Online cover search
            subItem        = new MenuItem();
            subItem.Header = Lang.Content("search");
            subItem.Click += this.ContextMenu_MenuItem_Click;
            subItem.Tag    = "onlineCover";
            item.Items.Add(subItem);
            // Generate thumbnail
            subItem           = new MenuItem();
            subItem.Header    = Lang.Content("generate");
            subItem.Click    += this.ContextMenu_MenuItem_Click;
            subItem.IsEnabled = !this.error;
            subItem.Tag       = "generateThumbnail";
            item.Items.Add(subItem);
            // Mark as watched
            CheckBox checkItem = new CheckBox();

            checkItem.Content   = Lang.MARK_AS_WATCHED;
            checkItem.IsChecked = this.watched;
            checkItem.Click    += this.ContextMenu_MenuItem_Click;
            checkItem.Tag       = "markAsWatched";
            context.Items.Add(checkItem);

            return(context);
        }