public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { ImageSource result = null; TaskPriority?priority = value as TaskPriority?; if (priority != null) { string imageName = null; switch (priority) { case TaskPriority.High: imageName = "PriorityHigh.png"; break; case TaskPriority.Normal: imageName = "PriorityNormal.png"; break; case TaskPriority.Low: imageName = "PriorityLow.png"; break; } if (!string.IsNullOrEmpty(imageName)) { Uri uri = ImageNameToSourceConverter.CreateResourceUri(imageName); result = BitmapFrame.Create(uri); } } return(result); }
private void Sort_Changed(object sender, NotifyCollectionChangedEventArgs e) { SortDescriptionCollection sorting = sender as SortDescriptionCollection; if (sorting != null) { this.resetSort.IsEnabled = sorting.Count > 0; foreach (MenuItem menuItem in this.sort.ContextMenu.Items.OfType <MenuItem>()) { string propertyName = menuItem.Tag as string; if (!string.IsNullOrEmpty(propertyName)) { SortDescription sort; int index; if (TryGetSortDescription(sorting, propertyName, out sort, out index)) { string imageName = sort.Direction == ListSortDirection.Ascending ? "SortAscending.png" : "SortDescending.png"; Uri uri = ImageNameToSourceConverter.CreateResourceUri(imageName); BitmapImage source = new BitmapImage(uri); menuItem.Icon = new Image() { Source = source }; } else { menuItem.Icon = null; } } } XElement status = new XElement("TasksStatus"); foreach (SortDescription sort in sorting) { XElement sortBy = new XElement( "SortBy", new XAttribute("PropertyName", sort.PropertyName), new XAttribute("Direction", sort.Direction)); status.Add(sortBy); } if (!this.isLoading) { Options options = this.Package.Options; options.TasksStatusXml = status.ToString(); options.SaveSettingsToStorage(); } } }