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; }
public override void Selected(DialogViewController controller, UITableView tableView, object item, NSIndexPath indexPath) { if (ProgressButtonData.IndicatorStyle == IndicatorStyle.Hud) { var progress = new ProgressHud() { TitleText = ProgressButtonData.Title, DetailText = ProgressButtonData.DetailText, MinimumShowTime = ProgressButtonData.MinimumShowTime, GraceTime = ProgressButtonData.GraceTime }; Action asyncCompleted = null; asyncCompleted = progress.ShowWhileAsync(() => { if (DataContext != null) { InvokeOnMainThread(() => { ExecuteMethod(asyncCompleted); }); } }, true); } else { base.Selected(controller, tableView, item, indexPath); } tableView.DeselectRow(indexPath, true); }
public UITableViewSource Parse(DialogViewController controller, object view, MemberInfo member) { UITableViewSource source = null; if (view != null) { view = GetActualView(view); controller.RootView = view; controller.ToolbarButtons = CheckForToolbarItems(view); controller.NavbarButtons = CheckForNavbarItems(view); if (member != null) { using (var memberData = new MemberData(view, member)) { source = ParseList(controller, memberData, null); } } if (source == null) { source = ParseView(controller, view); } InitializeSearch(view, source); } return source; }
public void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath indexPath) { if (Parent != null) { if (Root != null) { var section = Root.Sections[indexPath.Section]; var selectedIndex = -1; var index = 0; if (Container != null) { Container.SelectedItems.Clear(); foreach (var e in section.Elements) { var radioView = e as RadioElement; UpdateSelected(radioView, this == radioView); if (this == radioView) { selectedIndex = index; Container.SelectedItem = Item; Container.SelectedItems.Add(Item); } index++; } } Root.Index = selectedIndex; var property = BindableProperty.GetBindableProperty(Container, "SelectedItemProperty"); if (property != null) property.Update(); property = BindableProperty.GetBindableProperty(Container, "SelectedItemsProperty"); if (property != null) property.Update(); property = BindableProperty.GetBindableProperty(Container, "IndexProperty"); if (property != null) property.Update(); property = BindableProperty.GetBindableProperty(Root, "DataContextProperty"); if (property != null) property.Update(Caption); } } DataContext = true; UpdateSelected(); if (PopOnSelect) dvc.NavigationController.PopViewControllerAnimated(true); }
public void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path) { if (ElementView != null) { ElementView.InvokeOnMainThread(() => { ElementView.BecomeFirstResponder(); }); } }
public DialogViewListDataSource(DialogViewController container) : base(container) { if (container != null && container.RootView != null) { var notifyDataContextChanged = container.RootView as INotifyDataContextChanged; if (notifyDataContextChanged != null) { notifyDataContextChanged.DataContextChanged += DataContextChanged; } } }
public BaseDialogViewSource(DialogViewController controller) { Controller = controller; RowHeights = new Dictionary<NSIndexPath, float>(); SelectedAccessoryViews = new Dictionary<UITableViewCell, UIView>(); UnselectedAccessoryViews = new Dictionary<UITableViewCell, UIView>(); Sections = new Dictionary<int, Section>(); TableViewStyle = UITableViewStyle.Grouped; }
public virtual void Selected(DialogViewController controller, UITableView tableView, object item, NSIndexPath indexPath) { if (Animating) { return; } Animating = true; var executeCommandThread = new Thread(ExecuteCommandThread as ThreadStart); executeCommandThread.Start(); tableView.DeselectRow(indexPath, true); }
public virtual void Selected(DialogViewController controller, UITableView tableView, object item, NSIndexPath indexPath) { if (DataContext.Value == null) { DataContext.Value = Activator.CreateInstance(DataContext.Member.GetMemberType()); } // if (typeof(Enum).IsAssignableFrom(DataContext.Type)) // { // var parser = new ViewParser(); // // var source = parser.ParseList(null, DataContext.Source, DataContext.Member, null); // } if (DataContext.Value != null) { var view = DataContext.Value; if (NavigateToViewType != null && !view.GetType().Equals(NavigateToViewType)) { view = ViewCreator.Create(NavigateToViewType, DataContext.Value); } var dvc = new DialogViewController(Caption, view, controller.Theme, true) { Autorotate = true }; var nav = controller.ParentViewController as UINavigationController; if (IsModal) { dvc.ModalTransitionStyle = TransitionStyle; var navController = new NavigationController() { ViewControllers = new UIViewController[] { dvc } }; nav.PresentModalViewController(navController, true); } else { nav.PushViewController(dvc, true); } } }
public virtual void Selected(DialogViewController controller, UITableView tableView, object item, NSIndexPath indexPath) { if (NavigateToViewType == null) { return; } var dataContext = DataContext.Value; if (dataContext == null) { dataContext = Activator.CreateInstance(DataContext.Member.GetMemberType()); } if (dataContext != null) { var view = dataContext; if (!view.GetType().Equals(NavigateToViewType)) { view = ViewCreator.Create(NavigateToViewType, dataContext); } var dvc = new DialogViewController(Caption, view, controller.Theme, true) { Autorotate = true }; var nav = controller.ParentViewController as UINavigationController; if (IsModal) { dvc.ModalTransitionStyle = TransitionStyle; var navController = new NavigationController() { ViewControllers = new UIViewController[] { dvc } }; nav.PresentModalViewController(navController, true); } else { nav.PushViewController(dvc, true); } } }
public void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path) { tableView.DeselectRow(path, true); if (ShowHud) { _ProgressHud = new ProgressHud() { TitleText = Title, DetailText = DetailsText, Mode = HudProgressMode.Indeterminate }; if (Command != null && Command.CanExecute(CommandParameter)) { _ProgressHud.ShowWhileExecuting(()=>Command.Execute(CommandParameter), true); } } else { ShowIndicator(()=>Command.Execute(CommandParameter)); } }
public void Selected(DialogViewController controller, UITableView tableView, object item, NSIndexPath path) { var list = DataContext.Value as IEnumerable <CLLocationCoordinate2D>; if (list == null) { list = new List <CLLocationCoordinate2D>() { (CLLocationCoordinate2D)DataContext.Value }; } var mapViewController = new MapViewController(list) { Title = Caption }; controller.ActivateController(mapViewController, controller); }
public virtual void Selected(DialogViewController controller, UITableView tableView, object item, NSIndexPath indexPath) { if (ButtonData != null) { if (ButtonData.Command != null) { ButtonData.Command.Execute(ButtonData.CommandParameter); } else { if (DataContext != null) { var method = DataContext.Member as MethodInfo; method.Invoke(DataContext.Source, null); } } } tableView.DeselectRow(indexPath, true); }
public void NavigateToView() { var viewType = NavigationViewType; if (viewType == null) { viewType = ViewContainer.GetView(SelectedItem.GetType()); } if (viewType != null) { var disposable = NavigationView as IDisposable; if (disposable != null) { disposable.Dispose(); } NavigationView = Activator.CreateInstance(viewType); var dc = NavigationView as IDataContext <object>; if (dc != null) { dc.DataContext = SelectedItem; } else { NavigationView = SelectedItem; } var initializable = NavigationView as IInitializable; if (initializable != null) { initializable.Initialize(); } Caption = SelectedItem.ToString(); var dvc = new DialogViewController(Caption, NavigationView, Controller.Theme, true); Controller.NavigationController.PushViewController(dvc, true); } }
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; }
public void Selected(DialogViewController controller, UITableView tableView, object item, NSIndexPath indexPath) { var source = controller.TableView.Source as ViewSource; indexPath = source.ResetIndexPathRow(indexPath); var listSource = source.GetListSource(indexPath); if (listSource.Sections[0].DataContext.Count > 0) { // var isMultiselect = listSource.SelectionAction == SelectionAction.Multiselection; // var listAttribute = DataContext.Member.GetCustomAttribute<ListAttribute>(); // // var navigateToView = DataContext.Member.GetCustomAttribute<NavigateToViewAttribute>(); // if (navigateToView != null) // { // listSource.ModalTransitionStyle = navigateToView.TransitionStyle; // listSource.IsModal = navigateToView.ShowModal; // listSource.NavigationViewType = navigateToView.ViewType; // listSource.IsSelectable = listAttribute != null && isMultiselect; // } listSource.RowSelected(tableView, indexPath); } }
public void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path) { var mapViewController = new MapViewController((CLLocationCoordinate2D)DataContext) { Title = Caption }; dvc.ActivateController(mapViewController, dvc); }
private static DialogViewController CreateDialogViewController(UIView view, bool isModal) { Theme theme = null; if (CurrentDialogViewController != null) { theme = CurrentDialogViewController.Root.Theme; theme.TableViewStyle = UITableViewStyle.Grouped; } string title = null; var hasCaption = view as IView; if (hasCaption != null) { title = hasCaption.Caption; } if (string.IsNullOrEmpty(title)) title = MonoMobileApplication.Title; var dvc = new DialogViewController(title, view, true) { Autorotate = true }; dvc.IsModal = isModal; return dvc; }
public UITableViewSource ParseView(DialogViewController controller, object view) { var members = view.GetType().GetMembers(false); var sections = new SortedList<int, Section>(); var memberLists = new SortedList<int, SortedList<int, MemberData>>(); var sectionIndex = 0; var memberOrder = 0; foreach (var member in members) { var attributes = member.GetCustomAttributes(false); var memberData = new MemberData(view, member) { Section = sectionIndex }; var defaultValueAttribute = member.GetCustomAttribute<DefaultValueAttribute>(); if (defaultValueAttribute != null) { memberData.Value = defaultValueAttribute.Value; } var pullToRefreshAttribute = member.GetCustomAttribute<PullToRefreshAttribute>(); if (pullToRefreshAttribute != null) { ((DialogViewController)controller).PullToRefreshCommand = GetCommandForMember(view, member); ((DialogViewController)controller).RefreshKey = pullToRefreshAttribute.SettingsKey; ((DialogViewController)controller).EnablePullToRefresh = true; } var toolbarButtonAttribute = member.GetCustomAttribute<ToolbarButtonAttribute>(); var navbarButtonAttribute = member.GetCustomAttribute<NavbarButtonAttribute>(); var skipAttribute = member.GetCustomAttribute<SkipAttribute>(); if (skipAttribute != null || toolbarButtonAttribute != null || navbarButtonAttribute != null || pullToRefreshAttribute != null || (attributes.Length == 0 && typeof(MethodInfo) == memberData.Type)) { memberData.Dispose(); continue; } var themeAttribute = member.GetCustomAttribute<ThemeAttribute>(); if (themeAttribute != null) { var theme = Theme.CreateTheme(themeAttribute.ThemeType); if (theme != null && theme.CellHeight > 0) { memberData.RowHeight = theme.CellHeight; theme.Dispose(); } } else { var themeable = view as IThemeable; if (themeable != null && themeable.Theme != null && themeable.Theme.CellHeight > 0) { memberData.RowHeight = themeable.Theme.CellHeight; } } var rowHeightAttribute = member.GetCustomAttribute<RowHeightAttribute>(); if (rowHeightAttribute != null) memberData.RowHeight = rowHeightAttribute.RowHeight; var listAttribute = member.GetCustomAttribute<ListAttribute>(); var isList = (listAttribute != null && listAttribute.DisplayMode == DisplayMode.List) && !typeof(string).IsAssignableFrom(memberData.Type) && (typeof(IEnumerable).IsAssignableFrom(memberData.Type) || typeof(Enum).IsAssignableFrom(memberData.Type)); var orderAttribute = member.GetCustomAttribute<OrderAttribute>(); if (orderAttribute != null) { // make sure assigned order is an even number to fit in between the default order // allowing the values int.MinValue and int.MaxValue for the first and Last positions memberData.Order = orderAttribute.Order > int.MaxValue / 2 ? int.MaxValue : orderAttribute.Order * 2; } else { // make sure all default memberOrder is odd; memberOrder = memberOrder + (memberOrder % 2) + 1; memberData.Order = memberOrder; } var sectionAttribute = member.GetCustomAttribute<SectionAttribute>(); if (sectionAttribute != null || isList) { if (sections.Count > 0) { sectionIndex++; } memberData.Section = sectionIndex; if (sectionAttribute != null && orderAttribute != null) { memberData.Section = orderAttribute.Order == 0 ? sectionIndex : orderAttribute.Order; } else { memberData.Section = sectionIndex; } } var viewTypes = GetViewTypes(memberData); if (!sections.ContainsKey(memberData.Section)) { var section = CreateSection(controller, memberData, viewTypes); sections.Add(memberData.Section, section); } else { if (viewTypes != null) { IList<Type> list = null; var key = memberData.Id.ToString(); var viewTypesList = sections[memberData.Section].ViewTypes; if (viewTypesList.ContainsKey(key)) { list = viewTypesList[key]; } else { list = new List<Type>(); viewTypesList.Add(key, list); } foreach(var viewType in viewTypes) { if (!list.Contains(viewType)) { list.Add(viewType); } } } } if (memberLists.ContainsKey(memberData.Section)) { memberLists[memberData.Section].Add(memberData.Order, memberData); } else { var sortedList = new SortedList<int, MemberData>(); sortedList.Add(memberData.Order, memberData); memberLists.Add(memberData.Section, sortedList); } } foreach(var kvp in memberLists) { var listSources = new SortedList<int, ListSource>(); var index = 0; var list = kvp.Value.Values.ToList(); list.ForEach(data => data.Order = index++); foreach(var memberData in list) { var viewTypes = GetViewTypes(memberData); if ((!typeof(string).IsAssignableFrom(memberData.Type) && typeof(IEnumerable).IsAssignableFrom(memberData.Type)) || typeof(Enum).IsAssignableFrom(memberData.Type)) { var listSource = ParseList(controller, memberData, viewTypes) as ListSource; listSource.MemberData = memberData; listSource.Sections[0].Index = memberData.Section; listSources.Add(memberData.Order, listSource); } else listSources.Add(memberData.Order, null); sections[memberData.Section].ListSources = listSources; sections[memberData.Section].Index = memberData.Section; var lastListSource = listSources.Values.Last(); if (lastListSource != null) memberData.DataContextBinder = new DataContextBinder(controller, lastListSource.Sections[0]); } sections[kvp.Key].DataContext = list; } var keyIndex = 0; var sectionList = sections.Select(kvp => kvp.Value).ToDictionary((value) => keyIndex++); // If there is only one list property return the ListSource rather than create a ViewSource if (sectionList.Count == 1 && sectionList[0].DataContext.Count == 1 && sectionList[0].ListSources[0] != null && !sectionList[0].ListSources[0].IsRootCell) { sectionList[0].ListSources[0].TableViewStyle = UITableViewStyle.Plain; return sectionList[0].ListSources[0]; } var source = new ViewSource(controller) { Sections = sectionList }; return source; }
public void NavigateToList() { var section = Sections[0]; var data = GetSectionData(0); if (string.IsNullOrEmpty(Caption)) { Caption = data.ToString(); } var dvc = new DialogViewController(Caption, null, Controller.Theme, true) { ToolbarButtons = null, NavbarButtons = null }; if (NavigationSource == null) { NavigationSource = new ListSource(dvc, data, section.ViewTypes[CellId]); } NavigationSource.SelectionAction = SelectionAction; NavigationSource.IsSelectable = (SelectionAction == SelectionAction.PopOnSelection || SelectionAction == SelectionAction.Selection || SelectionAction == SelectionAction.Multiselection); NavigationSource.NavigationViewType = null; var viewType = NavigationViewType; if (viewType == null && SelectionAction == SelectionAction.NavigateToView) { var genericType = data.GetType().GetGenericArguments().FirstOrDefault(); viewType = ViewContainer.GetView(genericType); } if (viewType != null) { NavigationSource.IsNavigable = viewType == typeof(ObjectCellView <object>); NavigationSource.NavigationViewType = viewType; } NavigationSource.IsNavigable = !PopOnSelection && NavigationSource.IsNavigable && SelectionAction != SelectionAction.Custom; NavigationSource.CellFactory = CellFactory; NavigationSource.SelectedItem = SelectedItem; NavigationSource.SelectedItems = SelectedItems; NavigationSource.UnselectionBehavior = UnselectionBehavior; NavigationSource.IsMultiselect = IsMultiselect; // NavigationSource.IsSelectable = IsSelectable; if (data.Count > 0 && (data[0].GetType().IsPrimitive || data[0].GetType().IsEnum)) { NavigationSource.IsSelectable = true; } NavigationSource.PopOnSelection = PopOnSelection; NavigationSource.NibName = NibName; NavigationSource.TableViewStyle = TableViewStyle; NavigationSource.IsSearchbarHidden = IsSearchbarHidden; NavigationSource.EnableSearch = EnableSearch; NavigationSource.IncrementalSearch = IncrementalSearch; NavigationSource.SearchPlaceholder = SearchPlaceholder; NavigationSource.SearchCommand = SearchCommand; NavigationSource.SelectedAccessoryViewType = SelectedAccessoryViewType; NavigationSource.UnselectedAccessoryViewType = UnselectedAccessoryViewType; NavigationSource.MemberData = new MemberData(MemberData.Source, MemberData.Member); if (NavigationSource.NavigationViewType != null) { var rowHeightAttribute = NavigationSource.NavigationViewType.GetCustomAttribute <RowHeightAttribute>(); if (rowHeightAttribute != null) { NavigationSource.MemberData.RowHeight = rowHeightAttribute.RowHeight; } } NavigationSource.Controller = dvc; dvc.TableView.Source = NavigationSource; Controller.NavigationController.PushViewController(dvc, true); }
public void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path) { var root = BindingContext.CreateRootedView(this); if (root != null) { ((RootElement)root).ActivateController(dvc, tableView, path); } else { ActivateController(dvc, tableView, path); } }
public virtual void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path) { }
private static DialogViewController CreateDialogViewController(object view, bool isModal, bool pushing) { Theme theme = null; if (CurrentDialogViewController != null) { theme = CurrentDialogViewController.Theme; theme = Theme.CreateTheme(theme); theme.TableViewStyle = UITableViewStyle.Grouped; } string title = null; var hasCaption = view as ICaption; if (hasCaption != null) { title = hasCaption.Caption; } if (string.IsNullOrEmpty(title)) title = MonoMobileApplication.Title; var dvc = new DialogViewController(title, view, theme, pushing) { Autorotate = true, IsModal = isModal }; return dvc; }
public void NavigateToList() { var section = Sections[0]; var data = GetSectionData(0); if (string.IsNullOrEmpty(Caption)) { Caption = data.ToString(); } var dvc = new DialogViewController(Caption, null, Controller.Theme, true) { ToolbarButtons = null, NavbarButtons = null }; if (NavigationSource == null) NavigationSource = new ListSource(dvc, data, section.ViewTypes[CellId]); NavigationSource.SelectionAction = SelectionAction; NavigationSource.IsSelectable = (SelectionAction == SelectionAction.PopOnSelection || SelectionAction == SelectionAction.Selection || SelectionAction == SelectionAction.Multiselection); NavigationSource.NavigationViewType = null; var viewType = NavigationViewType; if (viewType == null && SelectionAction == SelectionAction.NavigateToView) { var genericType = data.GetType().GetGenericArguments().FirstOrDefault(); viewType = ViewContainer.GetView(genericType); } if (viewType != null) { NavigationSource.IsNavigable = viewType == typeof(ObjectCellView<object>); NavigationSource.NavigationViewType = viewType; } NavigationSource.IsNavigable = !PopOnSelection && NavigationSource.IsNavigable && SelectionAction != SelectionAction.Custom; NavigationSource.CellFactory = CellFactory; NavigationSource.SelectedItem = SelectedItem; NavigationSource.SelectedItems = SelectedItems; NavigationSource.UnselectionBehavior = UnselectionBehavior; NavigationSource.IsMultiselect = IsMultiselect; // NavigationSource.IsSelectable = IsSelectable; if (data.Count > 0 && (data[0].GetType().IsPrimitive || data[0].GetType().IsEnum)) NavigationSource.IsSelectable = true; NavigationSource.PopOnSelection = PopOnSelection; NavigationSource.NibName = NibName; NavigationSource.TableViewStyle = TableViewStyle; NavigationSource.IsSearchbarHidden = IsSearchbarHidden; NavigationSource.EnableSearch = EnableSearch; NavigationSource.IncrementalSearch = IncrementalSearch; NavigationSource.SearchPlaceholder = SearchPlaceholder; NavigationSource.SearchCommand = SearchCommand; NavigationSource.SelectedAccessoryViewType = SelectedAccessoryViewType; NavigationSource.UnselectedAccessoryViewType = UnselectedAccessoryViewType; NavigationSource.MemberData = new MemberData(MemberData.Source, MemberData.Member); if (NavigationSource.NavigationViewType != null) { var rowHeightAttribute = NavigationSource.NavigationViewType.GetCustomAttribute<RowHeightAttribute>(); if (rowHeightAttribute != null) { NavigationSource.MemberData.RowHeight = rowHeightAttribute.RowHeight; } } NavigationSource.Controller = dvc; dvc.TableView.Source = NavigationSource; Controller.NavigationController.PushViewController(dvc, true); }
public void NavigateToView() { var viewType = NavigationViewType; if (viewType == null) { viewType = ViewContainer.GetView(SelectedItem.GetType()); } if (viewType != null) { var disposable = NavigationView as IDisposable; if (disposable != null) { disposable.Dispose(); } NavigationView = Activator.CreateInstance(viewType); var dc = NavigationView as IDataContext<object>; if (dc != null) { dc.DataContext = SelectedItem; } else { NavigationView = SelectedItem; } var initializable = NavigationView as IInitializable; if (initializable != null) { initializable.Initialize(); } Caption = SelectedItem.ToString(); var dvc = new DialogViewController(Caption, NavigationView, Controller.Theme, true); Controller.NavigationController.PushViewController(dvc, true); } }
public ViewSource(DialogViewController controller, string title) : this(controller) { Caption = title; }
public ViewSource(DialogViewController controller) : base(controller) { CellFactory = new TableCellFactory<UITableViewCell>("cell"); }
/// <summary> /// Creates the UIViewController that will be pushed by this RootElement /// </summary> protected virtual UIViewController MakeViewController(UITableViewStyle style) { if (_ViewControllerFactory != null) return _ViewControllerFactory(this); var dvc = new DialogViewController(style, this, true) { Autorotate = true }; return dvc; }
public void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path) { if (picker == null) picker = new UIImagePickerController(); picker.Delegate = new MyDelegate(this, tableView, path); switch (UIDevice.CurrentDevice.UserInterfaceIdiom) { case UIUserInterfaceIdiom.Pad: RectangleF useRect; popover = new UIPopoverController(picker); var cell = tableView.CellAt(path); if (cell == null) useRect = rect; else useRect = cell.Frame; popover.PresentFromRect(useRect, dvc.View, UIPopoverArrowDirection.Any, true); break; default: case UIUserInterfaceIdiom.Phone: dvc.ActivateController(picker, dvc); break; } currentController = dvc; }
public void ActivateController(DialogViewController dvc, UITableView tableView, NSIndexPath path) { var newDvc = MakeViewController(dvc.Style); PrepareDialogViewController(newDvc); dvc.ActivateController(newDvc, dvc); tableView.DeselectRow(path, false); }
public DialogViewSearchDelegate(DialogViewController container) { _Container = container; }
protected override void Dispose(bool disposing) { if (disposing) { Controller = null; if (CellFactory != null) { CellFactory.Dispose(); CellFactory = null; } foreach(var section in Sections.Values) { var disposable = section as IDisposable; if (disposable != null) { disposable.Dispose(); disposable = null; } } } base.Dispose(disposing); }
public DataContextBinder(DialogViewController controller, Section section) { Section = section; Controller = controller; }
public static UITableViewSource ParseList(DialogViewController controller, MemberData memberData, List<Type> viewTypes) { object memberValue = memberData.Value; var member = memberData.Member; var type = memberData.Type; var isList = typeof(IEnumerable).IsAssignableFrom(type) || typeof(Enum).IsAssignableFrom(type); if (isList) { var data = type.CreateGenericListFromEnumerable(memberValue); var source = new ListSource(controller, (IList)data, viewTypes); if (source != null) { if (type.IsEnum) { source.SelectedItem = memberValue; source.SelectedItems.Add(source.SelectedItem); } else if (data != null && data.Count == 1) { source.SelectedItem = data[0]; source.SelectedItems.Add(source.SelectedItem); } source.Caption = GetCaption(member); var listAttribute = member.GetCustomAttribute<ListAttribute>(); if (listAttribute != null) { source.DisplayMode = listAttribute.DisplayMode; source.SelectionAction = listAttribute.SelectionAction; source.IsMultiselect = listAttribute.SelectionAction == SelectionAction.Multiselection; source.IsSelectable = source.SelectionAction != SelectionAction.NavigateToView; source.IsNavigable = listAttribute.DisplayMode != DisplayMode.Collapsable || listAttribute.SelectionAction == SelectionAction.NavigateToView; source.SelectedAccessoryViewType = listAttribute.SelectedAccessoryViewType; source.UnselectedAccessoryViewType = listAttribute.UnselectedAccessoryViewType; source.UnselectionBehavior = listAttribute.UnselectionBehavior; source.ReplaceCaptionWithSelection = listAttribute.ReplaceCaptionWithSelection; if (!string.IsNullOrEmpty(listAttribute.SelectedItemMemberName)) { source.SelectedItemMemberName = listAttribute.SelectedItemMemberName; } if (!string.IsNullOrEmpty(listAttribute.SelectedItemsMemberName)) { source.SelectedItemsMemberName = listAttribute.SelectedItemsMemberName; } } source.PopOnSelection = source.SelectionAction == SelectionAction.PopOnSelection; var memberAttributes = member.GetCustomAttributes(false); foreach(var memberAttribute in memberAttributes) { var navigable = memberAttribute as INavigable; if (navigable != null) { source.IsSelectable = false; source.NavigationViewType = navigable.NavigateToViewType; source.IsNavigable = navigable.NavigateToViewType != null; } } source.IsRootCell = source.DisplayMode != DisplayMode.List; return source; } } return null; }
public void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath indexPath) { if (Command != null && Command.CanExecute(CommandParameter)) Command.Execute(CommandParameter); }
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 void Selected(DialogViewController dvc, UITableView tableView, MonoTouch.Foundation.NSIndexPath path) { // do nothing }
public static void PresentModelView(UIView view, UIModalTransitionStyle transistionStyle) { _PreviousController = CurrentViewController; _PreviousDialogViewController = CurrentDialogViewController; CurrentDialogViewController = CreateDialogViewController(view, true); _NavigationController = new UINavigationController(); _NavigationController.ViewControllers = new UIViewController[] { CurrentDialogViewController }; CurrentViewController = _NavigationController; CurrentViewController.ModalTransitionStyle = transistionStyle; NavigationController.PresentModalViewController(_NavigationController, true); }
/// <summary> /// Activates a nested view controller from the DialogViewController. /// If the view controller is hosted in a UINavigationController it /// will push the result. Otherwise it will show it as a modal /// dialog /// </summary> public void ActivateController(UIViewController controller, DialogViewController oldController) { _Dirty = true; var parent = ParentViewController; var nav = parent as UINavigationController; if (typeof(DialogViewController) == controller.GetType()) { var dialog = (DialogViewController)controller; dialog.TableView.Opaque = false; if (dialog.BackgroundImage == null) dialog.TableView.BackgroundColor = oldController.TableView.BackgroundColor; } // We can not push a nav controller into a nav controller if (nav != null && !(controller is UINavigationController)) nav.PushViewController(controller, true); else PresentModalViewController(controller, true); }
public ViewSource(DialogViewController controller) : base(controller) { CellFactory = new TableCellFactory <UITableViewCell>("cell"); }
public static UITableViewSource ParseList(DialogViewController controller, MemberData memberData, List <Type> viewTypes) { object memberValue = memberData.Value; var member = memberData.Member; var type = memberData.Type; var isList = typeof(IEnumerable).IsAssignableFrom(type) || typeof(Enum).IsAssignableFrom(type); if (isList) { var data = type.CreateGenericListFromEnumerable(memberValue); var source = new ListSource(controller, (IList)data, viewTypes); if (source != null) { if (type.IsEnum) { source.SelectedItem = memberValue; source.SelectedItems.Add(source.SelectedItem); } else if (data != null && data.Count == 1) { source.SelectedItem = data[0]; source.SelectedItems.Add(source.SelectedItem); } source.Caption = GetCaption(member); var listAttribute = member.GetCustomAttribute <ListAttribute>(); if (listAttribute != null) { source.DisplayMode = listAttribute.DisplayMode; source.SelectionAction = listAttribute.SelectionAction; source.IsMultiselect = listAttribute.SelectionAction == SelectionAction.Multiselection; source.IsSelectable = source.SelectionAction != SelectionAction.NavigateToView; source.IsNavigable = listAttribute.DisplayMode != DisplayMode.Collapsable || listAttribute.SelectionAction == SelectionAction.NavigateToView; source.SelectedAccessoryViewType = listAttribute.SelectedAccessoryViewType; source.UnselectedAccessoryViewType = listAttribute.UnselectedAccessoryViewType; source.UnselectionBehavior = listAttribute.UnselectionBehavior; source.ReplaceCaptionWithSelection = listAttribute.ReplaceCaptionWithSelection; if (!string.IsNullOrEmpty(listAttribute.SelectedItemMemberName)) { source.SelectedItemMemberName = listAttribute.SelectedItemMemberName; } if (!string.IsNullOrEmpty(listAttribute.SelectedItemsMemberName)) { source.SelectedItemsMemberName = listAttribute.SelectedItemsMemberName; } } source.PopOnSelection = source.SelectionAction == SelectionAction.PopOnSelection; var memberAttributes = member.GetCustomAttributes(false); foreach (var memberAttribute in memberAttributes) { var navigable = memberAttribute as INavigable; if (navigable != null) { source.IsSelectable = false; source.NavigationViewType = navigable.NavigateToViewType; source.IsNavigable = navigable.NavigateToViewType != null; } } source.IsRootCell = source.DisplayMode != DisplayMode.List; return(source); } } return(null); }
public DialogViewDataSource(DialogViewController container) { Container = container; Root = container.Root; }
public UITableViewSource ParseView(DialogViewController controller, object view) { var members = view.GetType().GetMembers(false); var sections = new SortedList <int, Section>(); var memberLists = new SortedList <int, SortedList <int, MemberData> >(); var sectionIndex = 0; var memberOrder = 0; foreach (var member in members) { var attributes = member.GetCustomAttributes(false); var memberData = new MemberData(view, member) { Section = sectionIndex }; var defaultValueAttribute = member.GetCustomAttribute <DefaultValueAttribute>(); if (defaultValueAttribute != null) { memberData.Value = defaultValueAttribute.Value; } var pullToRefreshAttribute = member.GetCustomAttribute <PullToRefreshAttribute>(); if (pullToRefreshAttribute != null) { ((DialogViewController)controller).PullToRefreshCommand = GetCommandForMember(view, member); ((DialogViewController)controller).RefreshKey = pullToRefreshAttribute.SettingsKey; ((DialogViewController)controller).EnablePullToRefresh = true; } var toolbarButtonAttribute = member.GetCustomAttribute <ToolbarButtonAttribute>(); var navbarButtonAttribute = member.GetCustomAttribute <NavbarButtonAttribute>(); var skipAttribute = member.GetCustomAttribute <SkipAttribute>(); if (skipAttribute != null || toolbarButtonAttribute != null || navbarButtonAttribute != null || pullToRefreshAttribute != null || (attributes.Length == 0 && typeof(MethodInfo) == memberData.Type)) { memberData.Dispose(); continue; } var themeAttribute = member.GetCustomAttribute <ThemeAttribute>(); if (themeAttribute != null) { var theme = Theme.CreateTheme(themeAttribute.ThemeType); if (theme != null && theme.CellHeight > 0) { memberData.RowHeight = theme.CellHeight; theme.Dispose(); } } else { var themeable = view as IThemeable; if (themeable != null && themeable.Theme != null && themeable.Theme.CellHeight > 0) { memberData.RowHeight = themeable.Theme.CellHeight; } } var rowHeightAttribute = member.GetCustomAttribute <RowHeightAttribute>(); if (rowHeightAttribute != null) { memberData.RowHeight = rowHeightAttribute.RowHeight; } var listAttribute = member.GetCustomAttribute <ListAttribute>(); var isList = (listAttribute != null && listAttribute.DisplayMode == DisplayMode.List) && !typeof(string).IsAssignableFrom(memberData.Type) && (typeof(IEnumerable).IsAssignableFrom(memberData.Type) || typeof(Enum).IsAssignableFrom(memberData.Type)); var orderAttribute = member.GetCustomAttribute <OrderAttribute>(); if (orderAttribute != null) { // make sure assigned order is an even number to fit in between the default order // allowing the values int.MinValue and int.MaxValue for the first and Last positions memberData.Order = orderAttribute.Order > int.MaxValue / 2 ? int.MaxValue : orderAttribute.Order * 2; } else { // make sure all default memberOrder is odd; memberOrder = memberOrder + (memberOrder % 2) + 1; memberData.Order = memberOrder; } var sectionAttribute = member.GetCustomAttribute <SectionAttribute>(); if (sectionAttribute != null || isList) { if (sections.Count > 0) { sectionIndex++; } memberData.Section = sectionIndex; if (sectionAttribute != null && orderAttribute != null) { memberData.Section = orderAttribute.Order == 0 ? sectionIndex : orderAttribute.Order; } else { memberData.Section = sectionIndex; } } var viewTypes = GetViewTypes(memberData); if (!sections.ContainsKey(memberData.Section)) { var section = CreateSection(controller, memberData, viewTypes); sections.Add(memberData.Section, section); } else { if (viewTypes != null) { IList <Type> list = null; var key = memberData.Id.ToString(); var viewTypesList = sections[memberData.Section].ViewTypes; if (viewTypesList.ContainsKey(key)) { list = viewTypesList[key]; } else { list = new List <Type>(); viewTypesList.Add(key, list); } foreach (var viewType in viewTypes) { if (!list.Contains(viewType)) { list.Add(viewType); } } } } if (memberLists.ContainsKey(memberData.Section)) { memberLists[memberData.Section].Add(memberData.Order, memberData); } else { var sortedList = new SortedList <int, MemberData>(); sortedList.Add(memberData.Order, memberData); memberLists.Add(memberData.Section, sortedList); } } foreach (var kvp in memberLists) { var listSources = new SortedList <int, ListSource>(); var index = 0; var list = kvp.Value.Values.ToList(); list.ForEach(data => data.Order = index++); foreach (var memberData in list) { var viewTypes = GetViewTypes(memberData); if ((!typeof(string).IsAssignableFrom(memberData.Type) && typeof(IEnumerable).IsAssignableFrom(memberData.Type)) || typeof(Enum).IsAssignableFrom(memberData.Type)) { var listSource = ParseList(controller, memberData, viewTypes) as ListSource; listSource.MemberData = memberData; listSource.Sections[0].Index = memberData.Section; listSources.Add(memberData.Order, listSource); } else { listSources.Add(memberData.Order, null); } sections[memberData.Section].ListSources = listSources; sections[memberData.Section].Index = memberData.Section; var lastListSource = listSources.Values.Last(); if (lastListSource != null) { memberData.DataContextBinder = new DataContextBinder(controller, lastListSource.Sections[0]); } } sections[kvp.Key].DataContext = list; } var keyIndex = 0; var sectionList = sections.Select(kvp => kvp.Value).ToDictionary((value) => keyIndex++); // If there is only one list property return the ListSource rather than create a ViewSource if (sectionList.Count == 1 && sectionList[0].DataContext.Count == 1 && sectionList[0].ListSources[0] != null && !sectionList[0].ListSources[0].IsRootCell) { sectionList[0].ListSources[0].TableViewStyle = UITableViewStyle.Plain; return(sectionList[0].ListSources[0]); } var source = new ViewSource(controller) { Sections = sectionList }; return(source); }