public ListSource(DialogViewController controller, IList list, IEnumerable<Type> viewTypes) : base(controller) { Sections = new Dictionary<int, Section>(); var section = new Section(controller) { DataContext = list }; IList<Type> viewTypesList = null; if (viewTypes != null) viewTypesList = viewTypes.ToList(); var genericType = list.GetType().GetGenericArguments().FirstOrDefault(); CellId = new NSString(genericType.ToString()); section.ViewTypes.Add(CellId, viewTypesList); Sections.Add(0, section); SelectedItems = list.GetType().CreateGenericListFromEnumerable(null); CellFactory = new TableCellFactory<UITableViewCell>(CellId); //SelectionDisplayMode = SelectionDisplayMode.Collapsed; //CollapsedList = new List<object>(); // foreach(var item in Sections[0].DataContext) // { // CollapsedList.Add(item); // } // Sections[0].DataContext.Clear(); // //IsCollapsed = true; }
private static Section CreateSection(DialogViewController controller, MemberData memberData, List<Type> viewTypes) { var listSources = new SortedList<int, ListSource>(); listSources.Add(memberData.Order, null); var memberOrder = 0; memberData.Order = memberOrder; var sectionMembers = new List<MemberData>(); var section = new Section(controller) { DataContext = sectionMembers }; var sectionAttribute = memberData.Member.GetCustomAttribute<SectionAttribute>(); if (sectionAttribute != null) { section.HeaderText = sectionAttribute.Caption; section.FooterText = sectionAttribute.Footer; } section.ViewTypes.Add(memberData.Id.ToString(), viewTypes); return section; }
public static IRoot CreateViewEnumerableRoot(IRoot root) { IRoot newRoot = null; Type elementType = root.ViewBinding.ElementType; if (elementType == null) elementType = typeof(RootElement); newRoot = new RootElement() { ViewBinding = root.ViewBinding, EditingStyle = root.EditingStyle }; var section = new Section() { ViewBinding = root.ViewBinding, Parent = newRoot as IElement }; newRoot.Sections.Add(section); section = CreateSection(newRoot, section, root.DataContext, elementType, false); Theme.ApplyElementTheme(root.Theme, newRoot, null); return newRoot; }
public static Section CreateSection(IRoot root, Section section, object dataContext, Type elementType, bool popOnSelection) { var items = dataContext as IEnumerable; if (items != null) { if (section == null) section = new Section(); //section.Clear(); section.Parent = root; foreach (var item in items) { var element = CreateElementFromObject(item, root, elementType); section.Add(element); } } return section; }
public int Add(Section section) { if (Sections.ContainsKey(section.Index)) { Sections[section.Index] = section; } else { Sections.Add(section.Index, section); } section.Controller = Controller; return section.Index; }
public void PerformFilter(string text) { if (_OriginalSections == null) return; OnSearchTextChanged(text); var newSections = new List<ISection>(); var searchable = Root as ISearchBar; if (searchable != null) { if (searchable.SearchCommand == null) { for (int sidx = 0; sidx < _OriginalSections.Length; sidx++) { ISection newSection = null; var section = _OriginalSections[sidx]; IElement[] elements = _OriginalElements[sidx]; for (int eidx = 0; eidx < elements.Length; eidx++) { var searchableView = elements[eidx] as ISearchable; if ((searchableView != null && searchableView.Matches(text)) || (elements[eidx].Caption != null) && elements[eidx].Caption.Contains(text)) { if (newSection == null) { newSection = new Section(section.HeaderText, section.FooterText) { FooterView = section.FooterView, HeaderView = section.HeaderView }; newSections.Add(newSection); } newSection.Add(elements[eidx]); } } } } else { newSections = searchable.SearchCommand.Execute(_OriginalSections, text); } } Root.Sections = newSections; ReloadData(); }
public DataContextBinder(DialogViewController controller, Section section) { Section = section; Controller = controller; }
private void ReplaceRow(Section section, object oldItem, object newItem, UITableViewRowAnimation animation = UITableViewRowAnimation.Fade) { RemovePropertyChangedHandler(oldItem); AddPropertyChangedHandler(newItem); var row = section.DataContext.IndexOf(oldItem); section.DataContext[row] = newItem; if (Controller == MonoMobileApplication.CurrentViewController) { var indexPaths = new NSIndexPath[] { NSIndexPath.FromRowSection(row, section.Index) }; InvokeOnMainThread(()=> Controller.TableView.ReloadRows(indexPaths, animation)); } }
private void InsertRow(Section section, int row, object item, UITableViewRowAnimation animation = UITableViewRowAnimation.Fade) { AddPropertyChangedHandler(item); section.DataContext.Insert(row, item); if (Controller == MonoMobileApplication.CurrentViewController) { var indexPaths = new NSIndexPath[] { NSIndexPath.FromRowSection(row, section.Index) }; InvokeOnMainThread(()=> Controller.TableView.InsertRows(indexPaths, animation)); } }
private void RemoveRow(Section section, object item, UITableViewRowAnimation animation = UITableViewRowAnimation.Fade) { RemovePropertyChangedHandler(item); var row = section.DataContext.IndexOf(item); section.DataContext.Remove(item); if (Controller == MonoMobileApplication.CurrentViewController) { var indexPaths = new NSIndexPath[] { NSIndexPath.FromRowSection(row, section.Index) }; Controller.TableView.DeleteRows(indexPaths, animation); } }