public void OnItemSourceChanged(IList oldValue, IList newValue) { m_listType = null; Type oldType = oldValue != null?oldValue.GetType() : null; var oldListType = oldType != null?oldType.GetGenericArguments()[0].GetGenericArguments()[0] : null; if (newValue != null) { Items.Clear(); foreach (IList item in newValue) { Items.Add((IList)CreateClone(item)); } Type type = newValue.GetType(); m_listType = type.GetGenericArguments()[0].GetGenericArguments()[0]; if (!NewItemTypes.Contains(m_listType)) { NewItemTypes.Insert(0, m_listType); } if (oldListType != null && m_listType != oldListType && !m_listType.IsSubclassOf(oldListType)) { NewItemTypes.Remove(oldListType); } } }
/// <summary> /// Show the dialog /// </summary> /// <param name="title">The title to display for this dialog</param> /// <param name="parentContext">The parent contextual to the new object to add</param> /// <param name="itemType">The type of new item to suggest in the dialog</param> /// <param name="dialogStyle">The layout display style</param> /// <returns>The dialog user's choice (will either be OK or Cancel)</returns> public DialogResult ShowDialog(string title, ILuaEditDocumentGroup parentContext, NewItemTypes itemType, NewItemDialogStyle dialogStyle) { string location = parentContext != null?Path.GetDirectoryName(parentContext.FileName) : string.Empty; return(this.ShowDialog(title, parentContext, location, itemType, dialogStyle)); }
protected virtual void ItemsSourceTypeChanged(Type oldValue, Type newValue) { Type listType = GetListItemType(newValue); if (!NewItemTypes.Contains(listType)) { NewItemTypes.Add(listType); } }
/// <summary> /// Show the dialog /// </summary> /// <param name="title">The title to display for this dialog</param> /// <param name="parentContext">The parent contextual to the new object to add</param> /// <param name="location">The location directory to suggest</param> /// <param name="itemType">The type of new item to suggest in the dialog</param> /// <param name="dialogStyle">The layout display style</param> /// <returns>The dialog user's choice (will either be OK or Cancel)</returns> public DialogResult ShowDialog(string title, ILuaEditDocumentGroup parentContext, string location, NewItemTypes itemType, NewItemDialogStyle dialogStyle) { this.DialogStyle = dialogStyle; this.Text = title; btnAdd.Text = parentContext == null ? "OK" : "Add"; _parentContext = parentContext; _itemType = itemType; lvwNewItems.SmallImageList = DocumentFactory.Instance.DocumentSmallImages; lvwNewItems.LargeImageList = DocumentFactory.Instance.DocumentLargeImages; txtLocation.Text = location; FillList(); if (lvwNewItems.Items.Count > 0) { lvwNewItems.Items[0].Selected = true; } return(this.ShowDialog(FrameworkManager.Instance.MainDialog)); }
/// <summary> /// Show the dialog /// </summary> /// <param name="title">The title to display for this dialog</param> /// <param name="itemType">The type of new item to suggest in the dialog</param> /// <param name="dialogStyle">The layout display style</param> /// <returns>The dialog user's choice (will either be OK or Cancel)</returns> public DialogResult ShowDialog(string title, NewItemTypes itemType, NewItemDialogStyle dialogStyle) { return(this.ShowDialog(title, null, itemType, dialogStyle)); }