public static ApplicationJumpItemInfo Unwrap(JumpItem jumpItem)
        {
            ApplicationJumpTaskWrap applicationJumpTaskWrap = jumpItem as ApplicationJumpTaskWrap;

            if (applicationJumpTaskWrap != null)
            {
                return(applicationJumpTaskWrap.ApplicationJumpTask);
            }
            ApplicationJumpPathWrap applicationJumpPathWrap = jumpItem as ApplicationJumpPathWrap;

            if (applicationJumpPathWrap != null)
            {
                return(applicationJumpPathWrap.ApplicationJumpPath);
            }
            throw new ArgumentException(string.Empty, "jumpItem");
        }
        public static void FillWrapProperties(JumpItem jumpItem)
        {
            ApplicationJumpTaskWrap applicationJumpTaskWrap = jumpItem as ApplicationJumpTaskWrap;

            if (applicationJumpTaskWrap != null)
            {
                applicationJumpTaskWrap.CustomCategory = applicationJumpTaskWrap.ApplicationJumpTask.CustomCategory;
                applicationJumpTaskWrap.Title          = applicationJumpTaskWrap.ApplicationJumpTask.Title;
                applicationJumpTaskWrap.Description    = applicationJumpTaskWrap.ApplicationJumpTask.Description;
                return;
            }
            ApplicationJumpPathWrap applicationJumpPathWrap = jumpItem as ApplicationJumpPathWrap;

            if (applicationJumpPathWrap != null)
            {
                applicationJumpPathWrap.CustomCategory = applicationJumpPathWrap.ApplicationJumpPath.CustomCategory;
                applicationJumpPathWrap.Path           = applicationJumpPathWrap.ApplicationJumpPath.Path;
                return;
            }
            throw new ArgumentException(string.Empty, "jumpItem");
        }
        public static string GetJumpItemCommandId(JumpItem jumpItem)
        {
            ApplicationJumpTaskWrap jumpTask = jumpItem as ApplicationJumpTaskWrap;

            return(jumpTask == null ? null : jumpTask.ApplicationJumpTask.CommandId);
        }
 void PrepareTask(ApplicationJumpTaskWrap task) {
     IApplicationJumpTaskInfoInternal taskInternal = task.ApplicationJumpTask;
     if(taskInternal.IsInitialized) return;
     string iconResourceName;
     if(task.ApplicationJumpTask.Icon == null) {
         task.IconResourcePath = task.ApplicationJumpTask.IconResourcePath;
         task.IconResourceIndex = task.ApplicationJumpTask.IconResourceIndex;
         iconResourceName = string.Format("{0}_{1}", task.IconResourcePath, task.IconResourceIndex);
     } else {
         if(task.ApplicationJumpTask.IconResourcePath != null)
             throw new ApplicationJumpTaskBothIconAndIconResourcePathSpecifiedException();
         string iconResourcePath;
         if(!IconStorage.TryStoreIconToFile(task.ApplicationJumpTask.Icon, NativeResourceManager.ExpandVariables(IconStorageFolder), out iconResourceName, out iconResourcePath))
             throw new ApplicationJumpTaskInvalidIconException();
         task.IconResourcePath = iconResourcePath;
         task.IconResourceIndex = 0;
     }
     if(task.ApplicationJumpTask.CommandId == null)
         taskInternal.SetAutoGeneratedCommandId(string.Format("{0}${1}${2}", task.ApplicationJumpTask.CustomCategory, task.ApplicationJumpTask.Title, iconResourceName));
 }
 public virtual bool AddOrReplace(ApplicationJumpTaskInfo jumpTask) {
     if(InteractionHelper.IsInDesignMode(this)) {
         designModeItems.Add(jumpTask);
         return true;
     }
     ApplicationJumpTaskWrap jumpTaskWrap = new ApplicationJumpTaskWrap(jumpTask);
     PrepareTask(jumpTaskWrap);
     ISupportInitialize itemInit = jumpTask;
     itemInit.EndInit();
     JumpItem existingItem = nativeJumpList.Find(jumpTask.CommandId);
     if(existingItem != null) {
         nativeJumpList[nativeJumpList.IndexOf(existingItem)] = jumpTaskWrap;
         return false;
     }
     nativeJumpList.Add(jumpTaskWrap);
     return true;
 }