Ejemplo n.º 1
0
        public void OpenTaskWindow()
        {
            NewJumpTaskWindowViewModel taskAddition = ViewModelSource.Create(() => new NewJumpTaskWindowViewModel());
            IDataErrorInfo             errorInfo    = (IDataErrorInfo)taskAddition;
            UICommand okCommand = new UICommand()
            {
                Caption   = "OK",
                IsCancel  = false,
                IsDefault = true,
                Command   = new DelegateCommand <CancelEventArgs>(x => { }, x => string.IsNullOrEmpty(errorInfo["Title"]))
            };
            UICommand cancelCommand = new UICommand()
            {
                Caption   = "Cancel",
                IsCancel  = true,
                IsDefault = false,
            };

            if (DialogService.ShowDialog(new List <UICommand>()
            {
                okCommand, cancelCommand
            }, "Add Jump List Task", "NewJumpTaskWindow", taskAddition) == okCommand)
            {
                AddTask(taskAddition);
            }
        }
Ejemplo n.º 2
0
        void AddTask(NewJumpTaskWindowViewModel task)
        {
            string customCategory = string.IsNullOrEmpty(task.CustomCategory) ? null : task.CustomCategory;

            ApplicationJumpListService.Items.AddOrReplace(customCategory, task.Title, task.Icon.Icon, task.Description,
                                                          () => MessageBoxService.Show(task.MessageText));
            IEnumerable <RejectedApplicationJumpItem> rejectedItems = ApplicationJumpListService.Apply();

            foreach (var rejectedItem in rejectedItems)
            {
                var rejectedTask = (ApplicationJumpTaskInfo)rejectedItem.JumpItem;
                MessageBoxService.Show(string.Format("Error: {0}", rejectedItem.Reason), rejectedTask.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }