public FavoritesItemSettings(UserFilter Filter, bool Create)
        {
            this.create = Create;
            this.filter = Filter;

            if (create == true)
                this.Description = "NEW FAVORITE";
            else
                this.Description = "EDIT FAVORITE";
            this.commands = new ArrayListDataSet(this);

            //save command
            Command saveCmd = new Command();
            saveCmd.Description = "Save";
            saveCmd.Invoked += new EventHandler(saveCmd_Invoked);
            this.commands.Add(saveCmd);

            //cancel command
            Command cancelCmd = new Command();
            cancelCmd.Description = "Cancel";
            cancelCmd.Invoked += new EventHandler(cancelCmd_Invoked);
            this.commands.Add(cancelCmd);

            this.SetupFavoriteItem();
        }
        public FavoritesCommand(IModelItem Owner, UserFilter Filter)
            : base(Owner)
        {
            this.filter = Filter;
            this.edit = new Command(this);
            this.edit.Invoked += delegate(object Sender, EventArgs Args)
            {
                //navigate to edit page
                Dictionary<string, object> properties = new Dictionary<string, object>();

                Library.Code.V3.FavoritesItemSettings page = new Library.Code.V3.FavoritesItemSettings(this.filter, false);
                properties["Page"] = page;
                properties["Application"] = OMLApplication.Current;

                OMLApplication.Current.Session.GoToPage("resx://Library/Library.Resources/V3_FavoritesItemSettings", properties);
            };
        }
        public GenreItem(UserFilter title, IModelItem owner, List<TitleFilter> filter)
            : base(owner)
        {
            this.Description = title.Name;

            this.Invoked += delegate(object sender, EventArgs args)
            {
                OMLProperties properties = new OMLProperties();
                properties.Add("Application", OMLApplication.Current);
                properties.Add("I18n", I18n.Instance);
                Command CommandContextPopOverlay = new Command();
                properties.Add("CommandContextPopOverlay", CommandContextPopOverlay);

                Library.Code.V3.GalleryPage gallery = new Library.Code.V3.GalleryPage(filter, title.Name);

                properties.Add("Page", gallery);
                OMLApplication.Current.Session.GoToPage(@"resx://Library/Library.Resources/V3_GalleryPage", properties);
            };
        }
        // this is the context from the Media Center menu
        public void Startup(string context)
        {            
            OMLApplication.DebugLine("[OMLApplication] Startup({0}) {1}", context, IsExtender ? "Extender" : "Native");
            // DISABLE THIS UNTIL ITS READY -- DJShultz 01/13/2009

            //if (!IsExtender) {
            OperatingSystem os = Environment.OSVersion;
            if (os.Version.Major >= 6 && os.Version.Minor >= 1)
                Properties.Settings.Default.IsWindows7 = true;
            else
                Properties.Settings.Default.IsWindows7 = false;

            Properties.Settings.Default.Save();
            //}
            //should we update?
            if (OMLSettings.EnableAutomaticUpdates)
            {
                bool enableBetaUpdates = OMLSettings.EnableAutomaticUpdatesDailyBuilds;
                OMLUpdater updater = new OMLUpdater();
                ThreadPool.QueueUserWorkItem(new WaitCallback(updater.checkUpdate), enableBetaUpdates);
            }

#if LAYOUT_V3

            #region v3POC

            SetPrimaryBackgroundImage();
            //this.MediaCenterEnvironment.Dialog(
            //            string.Format("Loading MC UI"),
            //            "TEST", DialogButtons.Ok, 5, false);
            //this.GoToWizard(new List<OMLEngine.TitleFilter>(), "Movies");
            //return;
            switch (context)
            {
                case "Settings":
                    {
                        Dictionary<string, object> properties = new Dictionary<string, object>();

                        Library.Code.V3.SettingsManager page = new Library.Code.V3.SettingsManager();
                        properties["Page"] = page;
                        properties["Application"] = OMLApplication.Current;

                        OMLApplication.Current.Session.GoToPage("resx://Library/Library.Resources/V3_Settings_SettingsManager", properties);
                        return;
                    }
                case "Search":
                    {
                        Dictionary<string, object> properties = new Dictionary<string, object>();

                        Library.Code.V3.MoviesSearchPage page = new Library.Code.V3.MoviesSearchPage();
                        properties["Page"] = page;
                        properties["Application"] = OMLApplication.Current;

                        OMLApplication.Current.Session.GoToPage("resx://Library/Library.Resources/V3_MoviesSearchPage", properties);
                        return;
                    }
                case "Trailers":
                    {
                        OMLProperties properties = new OMLProperties();
                        properties.Add("Application", this);
                        properties.Add("I18n", I18n.Instance);
                        Library.Code.V3.TrailerPage gallery = new Library.Code.V3.TrailerPage("trailers");
                        Command CommandContextPopOverlay = new Command();
                        properties.Add("CommandContextPopOverlay", CommandContextPopOverlay);
                        properties.Add("Page", gallery);
                        _session.GoToPage(@"resx://Library/Library.Resources/V3_GalleryPage", properties);
                        return;
                    }
                case "Custom1":
                    {
                        UserFilter filt = new UserFilter(OMLEngine.Properties.Settings.Default.StartMenuCustom1);
                        this.GoHome(filt.Filters, filt.Name);
                        return;
                    }
                case "Custom2":
                    {
                        UserFilter filt = new UserFilter(OMLEngine.Properties.Settings.Default.StartMenuCustom1);
                        this.GoHome(filt.Filters, filt.Name);
                        return;
                    }
                case "Custom3":
                    {
                        UserFilter filt = new UserFilter(OMLEngine.Properties.Settings.Default.StartMenuCustom1);
                        this.GoHome(filt.Filters, filt.Name);
                        return;
                    }
                case "Custom4":
                    {
                        UserFilter filt = new UserFilter(OMLEngine.Properties.Settings.Default.StartMenuCustom1);
                        this.GoHome(filt.Filters, filt.Name);
                        return;
                    }
                case "Custom5":
                    {
                        UserFilter filt = new UserFilter(OMLEngine.Properties.Settings.Default.StartMenuCustom1);
                        this.GoHome(filt.Filters, filt.Name);
                        return;
                    }
                case "FirstRun":
                    {
                        Dictionary<string, object> properties = new Dictionary<string, object>();

                        Library.Code.V3.FirstRun page = new Library.Code.V3.FirstRun();
                        properties["Page"] = page;

                        OMLApplication.Current.Session.GoToPage("resx://Library/Library.Resources/V3_FirstRunBackground", properties);
                        return;
                    }
                case "TV":
                    {
                        List<OMLEngine.TitleFilter> filters = new List<OMLEngine.TitleFilter>();
                        filters.Add(new OMLEngine.TitleTypeFilter(OMLEngine.TitleTypes.TVShow));
                        this.GoHome(filters, "TV");
                        return;
                    }
                case "Movies":
                    {
                        this.GoHome(new List<OMLEngine.TitleFilter>(), "Movies");
                        return;
                    }
                default:
                    {
                        ////everything else for now
                        //OMLProperties properties = new OMLProperties();
                        //properties.Add("Application", this);
                        ////properties.Add("UISettings", new UISettings());
                        ////properties.Add("Settings", new Settings());
                        //properties.Add("I18n", I18n.Instance);
                        ////v3 main gallery
                        //Library.Code.V3.GalleryPage gallery = new Library.Code.V3.GalleryPage(new List<OMLEngine.TitleFilter>(), "OML");
                        ////description
                        //gallery.Description = "OML";
                        //Command CommandContextPopOverlay = new Command();
                        //properties.Add("CommandContextPopOverlay", CommandContextPopOverlay);
                        //properties.Add("Page", gallery);
                        //_session.GoToPage(@"resx://Library/Library.Resources/V3_GalleryPage", properties);
                        ////this.mediaChangers = new Library.Code.V3.MediaChangeManager();
                        if (Properties.Settings.Default.CompletedFirstRun == false)
                        {
                            Dictionary<string, object> properties = new Dictionary<string, object>();

                            Library.Code.V3.FirstRun page = new Library.Code.V3.FirstRun();
                            properties["Page"] = page;

                            OMLApplication.Current.Session.GoToPage("resx://Library/Library.Resources/V3_FirstRunBackground", properties);
                        }
                        else
                            this.GoHome(new List<OMLEngine.TitleFilter>(), "OML");
                        return;
                    }
            }
            #endregion v3POC
            //return;
#endif

        }
        void addFavoritesCmd_Invoked(object sender, EventArgs e)
        {
            //this.m_filters
            //IList<UserFilter> oldFilters = OMLSettings.UserFilters;
            //UserFilter[] newFilters = new UserFilter[oldFilters.Count + 1];
            ////deal with the existing userfilters
            //for (int i = 0; i < oldFilters.Count; i++)
            //{
            //    newFilters[i] = oldFilters[i];
            //}

            OMLEngine.TitleFilter[] newFilter = new OMLEngine.TitleFilter[this.m_filters.Count];
            for (int i = 0; i < this.m_filters.Count; i++)
            {
                newFilter[i]=this.m_filters[i];
            }

            UserFilter filter = new UserFilter(this.ContentLabel.Replace("|","").Replace(" OML Home",""), newFilter);
            Dictionary<string, object> properties = new Dictionary<string, object>();

            Library.Code.V3.FavoritesItemSettings page = new Library.Code.V3.FavoritesItemSettings(filter, true);
            properties["Page"] = page;
            properties["Application"] = OMLApplication.Current;

            OMLApplication.Current.CatchMoreInfo();
            OMLApplication.Current.Session.GoToPage("resx://Library/Library.Resources/V3_FavoritesItemSettings", properties);
            //newFilters[oldFilters.Count] = filter;
            //OMLSettings.UserFilters = newFilters;
        }
 private object GetCommandForItem(UserFilter item)
 {
     return new Library.Code.V3.FilterItem(item, this, item.Filters);
 }
        /// <summary>
        /// saving settings
        /// </summary>
        public void Save()
        {
            if (this.create)
            {
                IList<UserFilter> oldFilters = OMLSettings.UserFilters;
                UserFilter[] newFilters = new UserFilter[oldFilters.Count + 1];
                //deal with the existing userfilters
                for (int i = 0; i < oldFilters.Count; i++)
                {
                    newFilters[i] = oldFilters[i];
                }

                UserFilter filter = new UserFilter(this.name.Value, this.filter.Filters);

                newFilters[oldFilters.Count] = filter;
                OMLSettings.UserFilters = newFilters;
            }
            else
            {
                //update the only prop we are currently modifying - name
                UserFilter newFilter = new UserFilter(this.name.Value, this.filter.Filters);
                IList<UserFilter> oldFilters = OMLSettings.UserFilters;
                //deal with the existing userfilters
                for (int i = 0; i < oldFilters.Count; i++)
                {
                    if (this.filter.Name == oldFilters[i].Name && this.filter.Filters==oldFilters[i].Filters)
                    {
                        oldFilters[i] = newFilter;
                    }
                }

                OMLSettings.UserFilters = oldFilters;
            }
        }
        private void SetupFavorites()
        {
            foreach (UserFilter filt in OMLSettings.UserFilters)
            {
                FavoritesCommand cmd = new FavoritesCommand(this, filt);
                cmd.Description = filt.Name;
                cmd.Invoked += delegate(object favoritesSender, EventArgs favoritesArgs)
                {
                    if (favoritesSender is FavoritesCommand)
                    {
                        string strDelete = string.Format("Are you sure you want to delete {0}?", ((FavoritesCommand)favoritesSender).Name);
                        DialogResult res = OMLApplication.Current.MediaCenterEnvironment.Dialog(strDelete, "DELETE FAVORITE", DialogButtons.Yes | DialogButtons.No, -1, true);
                        if (res == DialogResult.Yes)
                        {
                            //delete
                            IList<UserFilter> oldFilters = OMLSettings.UserFilters;
                            UserFilter[] newFilters = new UserFilter[oldFilters.Count -1];
                            //deal with the existing userfilters
                            this.favoritesArray.Remove(cmd);

                            for (int i = 0; i < oldFilters.Count-1; i++)
                            {
                                if (oldFilters[i] != ((FavoritesCommand)favoritesSender).Filter)
                                    newFilters[i] = ((FavoritesCommand)this.favoritesArray[i]).Filter;
                            }

                            OMLSettings.UserFilters = newFilters;

                        }
                    }
                };
                this.favoritesArray.Add(cmd);
            }
        }
        void addFavoritesCmd_Invoked(object sender, EventArgs e)
        {
            //this.m_filters
            IList<UserFilter> oldFilters = OMLSettings.UserFilters;
            UserFilter[] newFilters = new UserFilter[oldFilters.Count + 1];
            //deal with the existing userfilters
            for (int i = 0; i < oldFilters.Count; i++)
            {
                newFilters[i] = oldFilters[i];
            }

            OMLEngine.TitleFilter[] newFilter = new OMLEngine.TitleFilter[this.m_filters.Count];
            for (int i = 0; i < this.m_filters.Count; i++)
            {
                newFilter[i]=this.m_filters[i];
            }

            UserFilter filter = new UserFilter(this.Description, newFilter);
            newFilters[oldFilters.Count] = filter;
            OMLSettings.UserFilters = newFilters;

            OMLApplication.Current.CatchMoreInfo();
        }
        public void TEST_USER_FILTERS()
        {
            UserFilter filter = new UserFilter("Horror Comedies", new TitleFilter[] { new TitleFilter(TitleFilterType.Genre, "Horror"), new TitleFilter(TitleFilterType.Genre, "Comedy") });

            OMLSettings.UserFilters = new UserFilter[] { filter };

            /*foreach (UserFilter filter in OMLSettings.UserFilters)
            {
                foreach (Title title in filter.GetFilteredTitles())
                {
                    Console.WriteLine(title.Name);
                }
            }*/
        }