예제 #1
0
        /// <summary>
        /// Add a category of <see cref="JumpListLink"/>s, the links are unpinnable
        /// </summary>
        /// <param name="Title">The title of the category</param>
        /// <param name="Links">The links category will contain</param>
        public void AddCategory(string Title, params JumpListLink[] Links)
        {
            NativeMethods.IObjectCollection collection = (NativeMethods.IObjectCollection) new CollectionInstance();
            foreach (JumpListLink Link in Links)
            {
                collection.AddObject(Link.NativeInterface);
            }
            NativeMethods.IObjectArray array = (NativeMethods.IObjectArray)collection;
            int result = dest.AppendCategory(Title, array);

            if (NativeMethods.Failed(result))
            {
                throw Marshal.GetExceptionForHR(result);
            }
        }
예제 #2
0
        /// <summary>
        /// Add <see cref="JumpListLink"/>s to the Tasks category, user tasks cannot be unpinned
        /// </summary>
        /// <param name="Tasks">The list of tasks to add</param>
        public void AddUserTasks(params JumpListLink[] Tasks)
        {
            if (Tasks == null)
            {
                throw new ArgumentNullException("Tasks", "The array is null");
            }
            if (Tasks.Length == 0)
            {
                throw new ArgumentException("Tasks", "The array is empty");
            }
            NativeMethods.IObjectCollection collection = (NativeMethods.IObjectCollection) new CollectionInstance();
            foreach (JumpListLink Link in Tasks)
            {
                collection.AddObject(Link.NativeInterface);
            }
            NativeMethods.IObjectArray array = (NativeMethods.IObjectArray)collection;
            int result = dest.AddUserTasks(array);

            if (NativeMethods.Failed(result))
            {
                throw Marshal.GetExceptionForHR(result);
            }
        }