public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { HotKeyList kl = value as HotKeyList; DlgKeys dlg = new DlgKeys(); dlg.LoadData(kl); if (edSvc.ShowDialog(dlg) == DialogResult.OK) { kl = new HotKeyList(); foreach (Key k in dlg.Results.HotKeys.Values) { if (!kl.ContainsKey(k.KeyName)) { kl.AddKey(k); } } value = kl; } } } return(value); }
public object Clone() { HotKeyList kl = new HotKeyList(); if (_hotKeys != null) { foreach (Key k in _hotKeys.Values) { kl.AddKey(k); } } return(kl); }
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { string s = value as string; if (s != null) { XmlDocument doc = new XmlDocument(); doc.LoadXml(s); HotKeyList kl = new HotKeyList(); kl.OnReadFromXmlNode(null, doc.DocumentElement); return(kl); } return(base.ConvertFrom(context, culture, value)); }
public void LoadData(HotKeyList list) { if (list == null) { Results = new HotKeyList(); } else { Results = (HotKeyList)list.Clone(); } foreach (Key k in Results.HotKeys.Values) { listBox1.Items.Add(k); } }
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (typeof(string).Equals(destinationType)) { HotKeyList kl = value as HotKeyList; if (kl != null) { XmlDocument doc = new XmlDocument(); XmlNode node = doc.CreateElement("Keys"); doc.AppendChild(node); kl.OnWriteToXmlNode(null, node); return(node.OuterXml); } } return(base.ConvertTo(context, culture, value, destinationType)); }