public static void VerifyFilterMenu() { DBMenu <DBTrackInfo> menu = mvCentralCore.Settings.FilterMenu; if (menu.RootNodes.Count == 0) { int position = 1; DBNode <DBTrackInfo> unwatchedNode = new DBNode <DBTrackInfo>(); unwatchedNode.Name = "${UnwatchedmvCentral}"; unwatchedNode.DynamicNode = false; unwatchedNode.Filter = new DBFilter <DBTrackInfo>(); DBCriteria <DBTrackInfo> criteria = new DBCriteria <DBTrackInfo>(); criteria.Field = DBField.GetFieldByDBName(typeof(DBUserMusicVideoSettings), "watched"); criteria.Relation = DBRelation.GetRelation(typeof(DBTrackInfo), typeof(DBUserMusicVideoSettings), ""); criteria.Operator = DBCriteria <DBTrackInfo> .OperatorEnum.EQUAL; criteria.Value = "0"; unwatchedNode.Filter.Criteria.Add(criteria); unwatchedNode.SortPosition = position++; unwatchedNode.DBManager = mvCentralCore.DatabaseManager; menu.RootNodes.Add(unwatchedNode); DBNode <DBTrackInfo> genreNode = new DBNode <DBTrackInfo>(); genreNode.DynamicNode = true; genreNode.BasicFilteringField = DBField.GetFieldByDBName(typeof(DBTrackInfo), "genres"); genreNode.Name = "${Genre}"; genreNode.DBManager = mvCentralCore.DatabaseManager; genreNode.SortPosition = position++; menu.RootNodes.Add(genreNode); DBNode <DBTrackInfo> dateNode = new DBNode <DBTrackInfo>(); dateNode.DynamicNode = true; dateNode.BasicFilteringField = DBField.GetFieldByDBName(typeof(DBTrackInfo), "date_added"); dateNode.Name = "${DateAdded}"; dateNode.DBManager = mvCentralCore.DatabaseManager; dateNode.SortPosition = position++; menu.RootNodes.Add(dateNode); menu.Commit(); } foreach (DBNode <DBTrackInfo> currNode in menu.RootNodes) { currNode.UpdateDynamicNode(); currNode.Commit(); } }
public static void VerifyCategoryMenu() { DBMenu <DBTrackInfo> menu = mvCentralCore.Settings.CategoriesMenu; if (menu.RootNodes.Count == 0) { int position = 1; DBNode <DBTrackInfo> allNode = new DBNode <DBTrackInfo>(); allNode.Name = "${AllmvCentral}"; allNode.DynamicNode = false; allNode.Filter = new DBFilter <DBTrackInfo>(); allNode.SortPosition = position++; allNode.DBManager = mvCentralCore.DatabaseManager; menu.RootNodes.Add(allNode); DBNode <DBTrackInfo> unwatchedNode = new DBNode <DBTrackInfo>(); unwatchedNode.Name = "${UnwatchedMusicVideo}"; unwatchedNode.DynamicNode = false; unwatchedNode.Filter = new DBFilter <DBTrackInfo>(); DBCriteria <DBTrackInfo> criteria = new DBCriteria <DBTrackInfo>(); criteria.Field = DBField.GetFieldByDBName(typeof(DBUserMusicVideoSettings), "watched"); criteria.Relation = DBRelation.GetRelation(typeof(DBTrackInfo), typeof(DBUserMusicVideoSettings), ""); criteria.Operator = DBCriteria <DBTrackInfo> .OperatorEnum.EQUAL; criteria.Value = "0"; unwatchedNode.Filter.Criteria.Add(criteria); unwatchedNode.SortPosition = position++; unwatchedNode.DBManager = mvCentralCore.DatabaseManager; menu.RootNodes.Add(unwatchedNode); DBNode <DBTrackInfo> recentNode = new DBNode <DBTrackInfo>(); recentNode.Name = "${RecentlyAddedmvCentral}"; recentNode.DynamicNode = false; recentNode.Filter = new DBFilter <DBTrackInfo>(); recentNode.SortPosition = position++; recentNode.DBManager = mvCentralCore.DatabaseManager; DBCriteria <DBTrackInfo> recentCriteria = new DBCriteria <DBTrackInfo>(); recentCriteria.Field = DBField.GetFieldByDBName(typeof(DBTrackInfo), "date_added"); recentCriteria.Operator = DBCriteria <DBTrackInfo> .OperatorEnum.GREATER_THAN; recentCriteria.Value = "-30d"; recentNode.Filter.Criteria.Add(recentCriteria); DBMusicVideoNodeSettings additionalSettings = new DBMusicVideoNodeSettings(); additionalSettings.UseDefaultSorting = false; // additionalSettings.SortField = SortingFields.DateAdded; // additionalSettings.SortDirection = SortingDirections.Descending; recentNode.AdditionalSettings = additionalSettings; menu.RootNodes.Add(recentNode); DBNode <DBTrackInfo> genreNode = new DBNode <DBTrackInfo>(); genreNode.DynamicNode = true; genreNode.BasicFilteringField = DBField.GetFieldByDBName(typeof(DBTrackInfo), "genres"); genreNode.Name = "${Genres}"; genreNode.SortPosition = position++; genreNode.DBManager = mvCentralCore.DatabaseManager; menu.RootNodes.Add(genreNode); menu.Commit(); } foreach (DBNode <DBTrackInfo> currNode in menu.RootNodes) { currNode.UpdateDynamicNode(); currNode.Commit(); } }