Beispiel #1
0
        public void DeleteStartMenuItem(StartMenuItem item)
        {
            int idx = this.StartMenuItems.IndexOf(item);

            StartMenuItems.Remove(item);
            this.SaveStartMenu();
        }
Beispiel #2
0
        private void GetStartMenuItems()
        {
            this.StartMenuItems = new List <StartMenuItem>();
            RegistryKey subKey = Registry.CurrentUser;

            subKey = subKey.OpenSubKey(OMLCategoryRegKey, false);
            if (subKey != null)
            {
                foreach (string sub in subKey.GetSubKeyNames())
                {
                    RegistryKey entryPoint = Registry.CurrentUser;
                    entryPoint = subKey.OpenSubKey(sub, true);
                    double dblSortTimeStamp = GetTimeStampFromDateTime(DateTime.Now);
                    double.TryParse(entryPoint.GetValue("TimeStamp", string.Empty).ToString(), out dblSortTimeStamp);
                    entryPoint = Registry.CurrentUser;
                    entryPoint = entryPoint.OpenSubKey(string.Format(@"{0}\{1}", EntryPointRegKey, sub), true);
                    if (entryPoint != null)
                    {
                        StartMenuItem entryPointItem = this.GetEntryPointFromRegistry(entryPoint);
                        entryPointItem.ItemId        = sub;
                        entryPointItem.SortTimeStamp = dblSortTimeStamp;
                        StartMenuItems.Add(entryPointItem);
                    }
                }
            }
            this.StartMenuItems = this.SortStartMenu(StartMenuItems) as List <StartMenuItem>;
        }
        public StartMenuCommand(IModelItem Owner, StartMenuHelper helper, StartMenuItem Item)
            : base(Owner)
        {
            this.entryPoint = Item;
            this.edit = new Command(this);

            //this.edit.Invoked += new EventHandler(edit_Invoked);
            this.edit.Invoked += delegate(object Sender, EventArgs Args)
                {
                    //navigate to edit page
                    Dictionary<string, object> properties = new Dictionary<string, object>();

                    Library.Code.V3.StartMenuItemSettings page = new Library.Code.V3.StartMenuItemSettings(entryPoint, helper);
                    properties["Page"] = page;
                    properties["Application"] = OMLApplication.Current;

                    OMLApplication.Current.Session.GoToPage("resx://Library/Library.Resources/V3_StartMenuItemSettings", properties);
                };

            this.moveUp = new Command(this);
            this.moveUp.Invoked += delegate(object Sender, EventArgs Args)
            {
                helper.MoveItemUp(this.entryPoint);
            };
            this.moveDown = new Command(this);
            this.moveDown.Invoked += delegate(object Sender, EventArgs Args)
            {
                helper.MoveItemDown(this.entryPoint);
            };
        }
 public void AddStartMenuItem(StartMenuItem item)
 {
     item.AddIn = OMLAddIn;
     item.AppId = OMLApplicationId;
     item.ItemId = GenerateNewAppId();
     this.StartMenuItems.Add(item);
     this.SaveStartMenu();
 }
Beispiel #5
0
 public void AddStartMenuItem(StartMenuItem item)
 {
     item.AddIn  = OMLAddIn;
     item.AppId  = OMLApplicationId;
     item.ItemId = GenerateNewAppId();
     this.StartMenuItems.Add(item);
     this.SaveStartMenu();
 }
 public void MoveItemUp(StartMenuItem item)
 {
     int idx = this.StartMenuItems.IndexOf(item);
     if (idx > 0)
     {
         StartMenuItems.Remove(item);
         StartMenuItems.Insert(idx - 1, item);
     }
     this.SaveStartMenu();
 }
 public void MoveItemDown(StartMenuItem item)
 {
     int idx = this.StartMenuItems.IndexOf(item);
     if (idx < 3)
     {
         StartMenuItems.Remove(item);
         StartMenuItems.Insert(idx + 1, item);
     }
     this.SaveStartMenu();
 }
Beispiel #8
0
        public void MoveItemDown(StartMenuItem item)
        {
            int idx = this.StartMenuItems.IndexOf(item);

            if (idx < 3)
            {
                StartMenuItems.Remove(item);
                StartMenuItems.Insert(idx + 1, item);
            }
            this.SaveStartMenu();
        }
Beispiel #9
0
        public void MoveItemUp(StartMenuItem item)
        {
            int idx = this.StartMenuItems.IndexOf(item);

            if (idx > 0)
            {
                StartMenuItems.Remove(item);
                StartMenuItems.Insert(idx - 1, item);
            }
            this.SaveStartMenu();
        }
Beispiel #10
0
        private void saveStartMenuItem(StartMenuItem item, DateTime sortTimeStamp)
        {
            //set the entrypoint
            RegistryKey entryPoint = Registry.CurrentUser;

            entryPoint = entryPoint.CreateSubKey(string.Format(@"{0}\{1}", EntryPointRegKey, item.ItemId));
            entryPoint.SetValue("AddIn", item.AddIn, RegistryValueKind.ExpandString);
            entryPoint.SetValue("AppId", item.AppId, RegistryValueKind.String);
            entryPoint.SetValue("Context", item.Context, RegistryValueKind.ExpandString);
            entryPoint.SetValue("Description", item.Description, RegistryValueKind.ExpandString);
            entryPoint.SetValue("ImageUrl", item.ImageUrl, RegistryValueKind.ExpandString);
            if (!string.IsNullOrEmpty(item.InactiveImageUrl))
            {
                entryPoint.SetValue("InactiveImageUrl", item.InactiveImageUrl, RegistryValueKind.ExpandString);
            }
            entryPoint.SetValue("Title", item.Title, RegistryValueKind.ExpandString);
            entryPoint.SetValue("TimeStamp", GetTimeStampFromDateTime(sortTimeStamp), RegistryValueKind.DWord);
            entryPoint.Close();
            //set the category
            RegistryKey categoryKey = Registry.CurrentUser;

            categoryKey = categoryKey.CreateSubKey(string.Format(@"{0}\{1}", OMLCategoryRegKey, item.ItemId));
            categoryKey.SetValue("AppId", item.AppId, RegistryValueKind.String);
            categoryKey.SetValue("TimeStamp", GetTimeStampFromDateTime(sortTimeStamp), RegistryValueKind.DWord);
            categoryKey.Close();

            switch (item.Context)
            {
            case Context.Custom1:
                Properties.Settings.Default.StartMenuCustom1 = item.ExtendedContext;
                Properties.Settings.Default.Save();
                break;

            case Context.Custom2:
                Properties.Settings.Default.StartMenuCustom2 = item.ExtendedContext;
                Properties.Settings.Default.Save();
                break;

            case Context.Custom3:
                Properties.Settings.Default.StartMenuCustom3 = item.ExtendedContext;
                Properties.Settings.Default.Save();
                break;

            case Context.Custom4:
                Properties.Settings.Default.StartMenuCustom4 = item.ExtendedContext;
                Properties.Settings.Default.Save();
                break;

            case Context.Custom5:
                Properties.Settings.Default.StartMenuCustom5 = item.ExtendedContext;
                Properties.Settings.Default.Save();
                break;
            }
        }
Beispiel #11
0
        //public List<StartMenuItem> GetStartMenuItemsOld()
        //{
        //    List<StartMenuItem> startMenuItems =new List<StartMenuItem>();
        //    RegistryKey subKey = Registry.CurrentUser;
        //    subKey = subKey.OpenSubKey(EntryPointRegKey, false);
        //    foreach (string sub in subKey.GetSubKeyNames())
        //    {
        //        RegistryKey entryPoint = Registry.CurrentUser;
        //        entryPoint = subKey.OpenSubKey(sub, true);
        //        if (entryPoint.GetValue("AppId", string.Empty).ToString() == OMLApplicationId)
        //        {
        //            startMenuItems.Add(this.GetEntryPointFromRegistry(entryPoint));
        //        }
        //    }
        //    return startMenuItems;
        //}

        private StartMenuItem GetEntryPointFromRegistry(RegistryKey key)
        {
            //http://blogs.msdn.com/astebner/archive/2006/08/22/713468.aspx
            StartMenuItem entryPoint = new StartMenuItem();

            entryPoint.AddIn            = OMLAddIn;
            entryPoint.AppId            = OMLApplicationId;
            entryPoint.Context          = GetContextFromString(key.GetValue("Context", string.Empty).ToString());
            entryPoint.Description      = key.GetValue("Description", string.Empty).ToString();
            entryPoint.ImageUrl         = key.GetValue("ImageUrl", string.Empty).ToString();
            entryPoint.InactiveImageUrl = key.GetValue("InactiveImageUrl", string.Empty).ToString();

            double dblTimeStamp = GetTimeStampFromDateTime(DateTime.Now);

            double.TryParse(key.GetValue("TimeStamp", string.Empty).ToString(), out dblTimeStamp);
            entryPoint.TimeStamp = dblTimeStamp;
            entryPoint.Title     = key.GetValue("Title", string.Empty).ToString();

            switch (entryPoint.Context)
            {
            case Context.Custom1:
                entryPoint.ExtendedContext = Properties.Settings.Default.StartMenuCustom1;
                break;

            case Context.Custom2:
                entryPoint.ExtendedContext = Properties.Settings.Default.StartMenuCustom2;
                break;

            case Context.Custom3:
                entryPoint.ExtendedContext = Properties.Settings.Default.StartMenuCustom3;
                break;

            case Context.Custom4:
                entryPoint.ExtendedContext = Properties.Settings.Default.StartMenuCustom4;
                break;

            case Context.Custom5:
                entryPoint.ExtendedContext = Properties.Settings.Default.StartMenuCustom5;
                break;
            }

            return(entryPoint);
        }
        public StartMenuItemSettings(StartMenuItem SelectedItem, StartMenuHelper Helper)
        {
            this.helper = Helper;
            this.selectedItem = SelectedItem;

            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.SetupStartMenu();
        }
 private void CreateDefaultStartMenuItems()
 {
     //create movies
     StartMenuItem moviesItem = new StartMenuItem();
     moviesItem.Title = "movies";
     moviesItem.Context = Context.Movies;
     moviesItem.ExtendedContext = string.Empty;
     moviesItem.Description = "Movies";
     moviesItem.ImageUrl = Path.GetFullPath(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)) + @"\Open Media Library\Application.png";
     this.helper.AddStartMenuItem(moviesItem);
     //create tv
     StartMenuItem tvItem = new StartMenuItem();
     tvItem.Title = "tv";
     tvItem.Context = Context.TV;
     tvItem.ExtendedContext = string.Empty;
     tvItem.Description = "TV";
     tvItem.ImageUrl = Path.GetFullPath(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)) + @"\Open Media Library\Application.png";
     this.helper.AddStartMenuItem(tvItem);
     //create trailers
     StartMenuItem trailersItem = new StartMenuItem();
     trailersItem.Title = "trailers";
     trailersItem.Context = Context.Trailers;
     trailersItem.ExtendedContext = string.Empty;
     trailersItem.Description = "Trailers";
     trailersItem.ImageUrl = Path.GetFullPath(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)) + @"\Open Media Library\Application.png";
     this.helper.AddStartMenuItem(trailersItem);
     //create search
     StartMenuItem searchItem = new StartMenuItem();
     searchItem.Title = "search";
     searchItem.Context = Context.Search;
     searchItem.ExtendedContext = string.Empty;
     searchItem.Description = "Search";
     searchItem.ImageUrl = Path.GetFullPath(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)) + @"\Open Media Library\Application.png";
     this.helper.AddStartMenuItem(searchItem);
 }
        void newCmd_Invoked(object sender, EventArgs e)
        {
            if (this.helper.StartMenuItems.Count < 5)
            {
                StartMenuItem newEntryPoint = new StartMenuItem();
                newEntryPoint.Context = Context.Home;

                //navigate to edit page
                Dictionary<string, object> properties = new Dictionary<string, object>();

                Library.Code.V3.StartMenuItemSettings page = new Library.Code.V3.StartMenuItemSettings(newEntryPoint, helper);
                properties["Page"] = page;
                properties["Application"] = OMLApplication.Current;

                OMLApplication.Current.Session.GoToPage("resx://Library/Library.Resources/V3_StartMenuItemSettings", properties);
            }
            else
            {
                DialogResult res = OMLApplication.Current.MediaCenterEnvironment.Dialog("You can have only five entries on the start menu?", "START MENU FULL", DialogButtons.Ok, -1, true);
            }
        }
        private void saveStartMenuItem(StartMenuItem item, DateTime sortTimeStamp)
        {
            //set the entrypoint
            RegistryKey entryPoint = Registry.CurrentUser;
            entryPoint = entryPoint.CreateSubKey(string.Format(@"{0}\{1}", EntryPointRegKey, item.ItemId));
            entryPoint.SetValue("AddIn", item.AddIn, RegistryValueKind.ExpandString);
            entryPoint.SetValue("AppId", item.AppId, RegistryValueKind.String);
            entryPoint.SetValue("Context", item.Context, RegistryValueKind.ExpandString);
            entryPoint.SetValue("Description", item.Description, RegistryValueKind.ExpandString);
            entryPoint.SetValue("ImageUrl", item.ImageUrl, RegistryValueKind.ExpandString);
            if (!string.IsNullOrEmpty(item.InactiveImageUrl))
                entryPoint.SetValue("InactiveImageUrl", item.InactiveImageUrl, RegistryValueKind.ExpandString);
            entryPoint.SetValue("Title", item.Title, RegistryValueKind.ExpandString);
            entryPoint.SetValue("TimeStamp", GetTimeStampFromDateTime(sortTimeStamp), RegistryValueKind.DWord);
            entryPoint.Close();
            //set the category
            RegistryKey categoryKey = Registry.CurrentUser;
            categoryKey = categoryKey.CreateSubKey(string.Format(@"{0}\{1}", OMLCategoryRegKey, item.ItemId));
            categoryKey.SetValue("AppId", item.AppId, RegistryValueKind.String);
            categoryKey.SetValue("TimeStamp", GetTimeStampFromDateTime(sortTimeStamp), RegistryValueKind.DWord);
            categoryKey.Close();

            switch (item.Context)
            {
                case Context.Custom1:
                    Properties.Settings.Default.StartMenuCustom1 = item.ExtendedContext;
                    Properties.Settings.Default.Save();
                    break;

                case Context.Custom2:
                    Properties.Settings.Default.StartMenuCustom2 = item.ExtendedContext;
                    Properties.Settings.Default.Save();
                    break;

                case Context.Custom3:
                    Properties.Settings.Default.StartMenuCustom3 = item.ExtendedContext;
                    Properties.Settings.Default.Save();
                    break;
                case Context.Custom4:
                    Properties.Settings.Default.StartMenuCustom4 = item.ExtendedContext;
                    Properties.Settings.Default.Save();
                    break;
                case Context.Custom5:
                    Properties.Settings.Default.StartMenuCustom5 = item.ExtendedContext;
                    Properties.Settings.Default.Save();
                    break;
            }
        }
 public void DeleteStartMenuItem(StartMenuItem item)
 {
     int idx = this.StartMenuItems.IndexOf(item);
     StartMenuItems.Remove(item);
     this.SaveStartMenu();
 }
        //public List<StartMenuItem> GetStartMenuItemsOld()
        //{
        //    List<StartMenuItem> startMenuItems =new List<StartMenuItem>();
        //    RegistryKey subKey = Registry.CurrentUser;
        //    subKey = subKey.OpenSubKey(EntryPointRegKey, false);
        //    foreach (string sub in subKey.GetSubKeyNames())
        //    {
        //        RegistryKey entryPoint = Registry.CurrentUser;
        //        entryPoint = subKey.OpenSubKey(sub, true);
        //        if (entryPoint.GetValue("AppId", string.Empty).ToString() == OMLApplicationId)
        //        {
        //            startMenuItems.Add(this.GetEntryPointFromRegistry(entryPoint));
        //        }
        //    }
        //    return startMenuItems;
        //}
        private StartMenuItem GetEntryPointFromRegistry(RegistryKey key)
        {
            //http://blogs.msdn.com/astebner/archive/2006/08/22/713468.aspx
            StartMenuItem entryPoint = new StartMenuItem();
            entryPoint.AddIn = OMLAddIn;
            entryPoint.AppId = OMLApplicationId;
            entryPoint.Context = GetContextFromString(key.GetValue("Context", string.Empty).ToString());
            entryPoint.Description = key.GetValue("Description", string.Empty).ToString();
            entryPoint.ImageUrl = key.GetValue("ImageUrl", string.Empty).ToString();
            entryPoint.InactiveImageUrl = key.GetValue("InactiveImageUrl", string.Empty).ToString();

            double dblTimeStamp = GetTimeStampFromDateTime(DateTime.Now);
            double.TryParse(key.GetValue("TimeStamp", string.Empty).ToString(), out dblTimeStamp);
            entryPoint.TimeStamp = dblTimeStamp;
            entryPoint.Title = key.GetValue("Title", string.Empty).ToString();

            switch (entryPoint.Context)
            {
                case Context.Custom1:
                    entryPoint.ExtendedContext = Properties.Settings.Default.StartMenuCustom1;
                    break;

                case Context.Custom2:
                    entryPoint.ExtendedContext = Properties.Settings.Default.StartMenuCustom2;
                    break;

                case Context.Custom3:
                    entryPoint.ExtendedContext = Properties.Settings.Default.StartMenuCustom3;
                    break;
                case Context.Custom4:
                    entryPoint.ExtendedContext = Properties.Settings.Default.StartMenuCustom4;
                    break;
                case Context.Custom5:
                    entryPoint.ExtendedContext = Properties.Settings.Default.StartMenuCustom5;
                    break;
            }

            return entryPoint;
        }