using System; using System.Linq; namespace Vanara.Windows.Shell { internal class JumpListItemCollectionEditor : System.ComponentModel.Design.CollectionEditor { /// Initializes a new instance of the class. public JumpListItemCollectionEditor() : base(typeof(JumpList)) { } /// Creates the collection form. /// protected override CollectionForm CreateCollectionForm() { var f = base.CreateCollectionForm(); f.Text = "JumpList Item Collection Editor"; return f; } /// Creates the new item types. /// protected override Type[] CreateNewItemTypes() => new[] { typeof(JumpListDestination), typeof(JumpListTask), typeof(JumpListSeparator) }; /// Sets the items. /// The edit value. /// The value. /// protected override object SetItems(object editValue, object[] value) { if (editValue is JumpList c) { c.Clear(); foreach (var i in value.Cast()) c.Add(i); } return editValue; } protected override object CreateInstance(Type itemType) { if (itemType == typeof(JumpListDestination)) return new JumpListDestination("[Category name]", "[File path]"); if (itemType == typeof(JumpListSeparator)) return new JumpListSeparator(); if (itemType == typeof(JumpListTask)) return new JumpListTask("[Title]", "[Application path]"); return base.CreateInstance(itemType); } protected override string GetDisplayText(object value) => value is JumpListSeparator ? "-----------" : value.ToString(); /*protected override string HelpTopic => base.HelpTopic; public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value) { return base.EditValue(context, provider, value); } protected override CollectionForm CreateCollectionForm() => new JumpListItemCollectionEditorForm(this); protected class JumpListItemCollectionEditorForm : CollectionForm { public JumpListItemCollectionEditorForm(CollectionEditor editor) : base(editor) { } protected override void OnEditValueChanged(); }*/ } }