public void NADA()
		{
			var binding = new BindingContext(MonoMobileApplication.MainView, MonoMobileApplication.Title);
			var controller = new DialogViewController(UITableViewStyle.Grouped, binding, true) { Autorotate = true };
		
			controller.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;
controller.ModalTransitionStyle = UIModalTransitionStyle.CoverVertical;
			Application.NavigationController.PresentModalViewController(controller, true);
		}
Esempio n. 2
0
		private void Startup()
		{
			using (var pool = new NSAutoreleasePool()) 
			{
				InvokeOnMainThread(delegate 
				{
					var binding = new BindingContext(new MovieListView(), "MVVM Sample");
					navigation.ViewControllers = new UIViewController[] { new DialogViewController(UITableViewStyle.Grouped, binding, true) };//{Autorotate = true } };
				});
			}
		}
		private void Startup()
		{
			using (var pool = new NSAutoreleasePool()) 
			{
				InvokeOnMainThread(delegate 
				{
					var binding = new BindingContext(MonoMobileApplication.MainView, MonoMobileApplication.Title);
					_Navigation.ViewControllers = new UIViewController[] { new DialogViewController(UITableViewStyle.Grouped, binding, true) { Autorotate = true } };

					UIView.BeginAnimations("fadeIn");
					UIView.SetAnimationDuration(0.3f);
					_Navigation.View.Alpha = 1.0f;
					UIView.CommitAnimations();
				});
			}
		}
		private static IRoot CreateObjectRoot(IRoot root)
		{
			IRoot newRoot = null;
			UIView view = null;
			object context = root.DataContext;

			try
			{				
				if (root.ViewBinding.ViewType != null)
				{
					view = Activator.CreateInstance(root.ViewBinding.ViewType) as UIView;
				}

				var dataContext = view as IDataContext;
				if (dataContext != null)
				{
					dataContext.DataContext = context;

					var lifetime = context as ISupportInitialize;
					if (lifetime != null)
						lifetime.BeginInit();
					
					lifetime = dataContext as ISupportInitialize;
					if (lifetime != null)
						lifetime.BeginInit();
				}
				
				var bindingContext = new BindingContext(view, root.Caption, root.Theme);

				newRoot = (IRoot)bindingContext.Root;
				newRoot.ViewBinding = root.ViewBinding;
				newRoot.ViewBinding.View = view;
			}
			catch(MissingMethodException)
			{
			}
			
			return newRoot;
		}
		public DialogViewController(BindingContext binding, bool pushing) : this(UITableViewStyle.Grouped, binding, pushing)
		{
		}
		public DialogViewController(UITableViewStyle style, BindingContext binding, bool pushing) : base(style)
		{
			if (binding == null)
				throw new ArgumentNullException("binding");
			_Pushing = pushing;
			Style = style;
			
			PrepareRoot(binding.Root);
		}
Esempio n. 7
0
		protected override void OnDataContextChanged()
		{
			base.OnDataContextChanged();
			
			if (ContentView is IView && ContentView != null)
			{
				var binding = new BindingContext(ContentView, Caption, Theme);
				if (binding.Root != null)
				{
					Sections = binding.Root.Sections;
				}
			}

//			if (DetailTextLabel != null && Value != null)
//			{
//				DetailTextLabel.Text = Value.ToString();
//			}
		}
		public static DialogViewController CreateDialogViewController(UIView view)
		{
			Theme theme = null;
			
			if (CurrentDialogViewController != null)
			{
				theme = CurrentDialogViewController.Root.Theme;
				theme.TableViewStyle = UITableViewStyle.Grouped;
			}
			
			var title = MonoMobileApplication.Title;
			if (view is IView)
				title = ((IView)view).Caption;
			
			var binding = new BindingContext(view, title, theme);
			var dvc = new DialogViewController(UITableViewStyle.Grouped, binding, true) { Autorotate = true };
			dvc.IsModal = true;

			return dvc;
		}
		private void Startup()
		{
			using (var pool = new NSAutoreleasePool()) 
			{
				InvokeOnMainThread(delegate 
				{
					foreach(var view in MonoMobileApplication.Views)
					{	
						var title = MonoMobileApplication.Title;
						if (view is IView)
							title = ((IView)view).Caption;

						var binding = new BindingContext(view, title);
						MonoMobileApplication.DialogViewControllers.Add(new DialogViewController(UITableViewStyle.Grouped, binding, true) { Autorotate = true } );
					}

					_Navigation.ViewControllers = MonoMobileApplication.DialogViewControllers.ToArray();

					MonoMobileApplication.CurrentDialogViewController = _Navigation.ViewControllers.First() as DialogViewController;

					UIView.BeginAnimations("fadeIn");
					UIView.SetAnimationDuration(0.3f);
					_Navigation.View.Alpha = 1.0f;
					UIView.CommitAnimations();
				});
			}
		}
Esempio n. 10
0
		private void Push(View view)
		{ 
			var binding = new BindingContext(view, "");
			NavigationController.PushViewController(new DialogViewController(binding.Root, true), true);
		}
Esempio n. 11
0
		protected override void OnValueChanged()
		{
			base.OnValueChanged();
			
			if (ContentView is IView && ContentView != null)
			{
				var binding = new BindingContext(ContentView, Caption, Theme);
				if (binding.Root != null)
				{
					Sections = binding.Root.Sections;
				}
			}
			if (Sections != null)
			{
				var radio = Groups.FirstOrDefault() as RadioGroup;
				var section = Sections.FirstOrDefault();
				if (radio != null && section != null && !section.IsMultiselect) 
				{
					var selected = EnumExtensions.GetValueFromString(radio.EnumType, (string)Value);
					radio.Selected = selected;
					foreach (RadioElement element in section)
					{
						element.UpdateSelected(element, false);
					}

					((RadioElement)section[selected]).Value = true;
				}
			}

			if (Groups != null && DetailTextLabel != null)
			{
				DetailTextLabel.Text = ToString();
			}
		}
Esempio n. 12
0
		public void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path)
		{
			BindingContext bindingContext = null;
			if (ViewBinding != null)
			{
				switch (ViewBinding.DataContextCode)
				{
					case DataContextCode.Object:
					{
						object view = ViewBinding.CurrentView;

						if (view == null)
						{
							if (ViewBinding.DataContext != null && ViewBinding.DataContext is UIView)
							{
								view = ViewBinding.DataContext as UIView;
							}
							else if (ViewBinding.ViewType != null) 
							{
								view = Activator.CreateInstance(ViewBinding.ViewType);
								var dataContext = view as IDataContext;
								if (dataContext != null)
								{
									if (dataContext.DataContext == null)
										dataContext.DataContext = ViewBinding.DataContext;
	
									var lifetime = dataContext.DataContext as ISupportInitialize;
									if (lifetime != null)
										lifetime.BeginInit();
									
									lifetime = view as ISupportInitialize;
									if (lifetime != null)
										lifetime.BeginInit();
								}

							}
						}
			
						bindingContext = new BindingContext(view, Caption, Root.Theme);

						var root = (RootElement)bindingContext.Root;
						root.ActivateController(dvc, tableView, path);
		
						return;
					}
					case DataContextCode.Enum: break;
					case DataContextCode.EnumCollection: break;
					case DataContextCode.Enumerable:
					{
						Sections.Clear();
						IElement element = null;
	
						var items = (IEnumerable)ViewBinding.DataContext;
	
						var genericType = items.GetType().GetGenericArguments().SingleOrDefault();
					
						if (genericType is IView)
						{
							Sections.Add(new Section());

							foreach (var e in items)
							{
								element = new RootElement(e.ToString()) { ViewBinding = ViewBinding, Theme = Theme };
								element.ViewBinding.DataContextCode = DataContextCode.Object;
			
								Sections[0].Add(element);
							}
						}
						else
						{
							var section = BindingContext.CreateEnumSection(this, items, null, true);
							Sections.Add(section);
						}

						break;
					}
				}
			}

			ActivateController(dvc, tableView, path);
		}
Esempio n. 13
0
		private List<ISection> CreateSectionList(object view, IRoot root)
		{
			var memberFuncMap = new List<Func<object, MemberInfo[]>>() 
			{
				(T)=>GetFields(T),
				(T)=>GetProperties(T),
				(T)=>GetMethods(T)
			};

			ISection lastSection = new Section() { Order = -1, Parent = root as IElement };

			var sectionList = new List<ISection>() { lastSection };

			IElement newElement = null;
			Theme theme = null;
			var themeable = root as IThemeable;
			if (themeable != null)
			{
				ApplyRootTheme(view, themeable);
				theme = themeable.Theme;
				ApplyElementTheme(theme, lastSection, null);
			}

			foreach(var memberFunc in memberFuncMap)
			{
				var members = memberFunc(view);
	
				foreach (var member in members)
				{
					var pullToRefreshAttribute = member.GetCustomAttribute<PullToRefreshAttribute>();
					if (pullToRefreshAttribute != null)
					{
						root.PullToRefreshCommand = GetCommandForMember(view, member);
						root.DefaultSettingsKey = pullToRefreshAttribute.SettingsKey;
					}
					var skipAttribute = member.GetCustomAttribute<SkipAttribute>(true);
					if (skipAttribute != null) continue;
					
					var inline = member.GetCustomAttribute<InlineAttribute>() != null;
				//	var isRoot = member.GetCustomAttribute<RootAttribute>() != null;
					var listAttribute = member.GetCustomAttribute<ListAttribute>();		
					var isList = listAttribute != null;
					var sectionAttribute = member.GetCustomAttribute<SectionAttribute>();
	
					if (sectionAttribute != null)
					{	
						Theme sectionTheme = null;
						if (sectionAttribute.ThemeType != null)
							 sectionTheme = Activator.CreateInstance(sectionAttribute.ThemeType) as Theme;
						
						lastSection = new Section(sectionAttribute.Caption, sectionAttribute.Footer) { Order = sectionAttribute.Order };
						lastSection.Parent = root as IElement;
						ApplyElementTheme(root.Theme, lastSection, null); 

						ApplyElementTheme(sectionTheme, lastSection, null);
						sectionList.Add(lastSection);
					}
	
					newElement = GetElementForMember(view, member);
					
					if(newElement != null)
					{
						newElement.Theme.MergeTheme(root.Theme);
						ApplyElementTheme(root.Theme, newElement, member);

						//var context = newElement as IView;
					//	var displayInline = (inline || !isRoot) && newElement is IRoot; //&& context != null;
						
						if (isList)
						{
							var newRoot = newElement as IRoot;
							Type viewType = newRoot.ViewBinding.ViewType ?? listAttribute.ViewType;

							string caption = null;
							if (!(view is IDataTemplate))
								caption = newElement.Caption;

							lastSection = new Section(caption,null) { };
							lastSection.Parent = root as IElement;
							ApplyElementTheme(root.Theme, lastSection, null); 
							sectionList.Add(lastSection);
			
							IEnumerable datacontext = null;
							if (view is IDataTemplate)
								datacontext = ((IDataTemplate)view).Items;
							else 
								datacontext = (IEnumerable)GetValue(member, view);

							foreach (var e in datacontext)
							{
								IElement element = null;

								if (e is IViewModel)
								{
									element = new RootElement(e.ToString());
									element.ViewBinding.ViewType = viewType;
									element.ViewBinding.DataContext = e;
									
									((IRoot)element).Theme = Theme.CreateTheme(root.Theme); 
									element.Theme = ((IRoot)element).Theme; 

									if (listAttribute.ThemeType != null)
									{
										var listTheme = Activator.CreateInstance(listAttribute.ThemeType) as Theme;
										var rootTheme = Theme.CreateTheme(((IRoot)element).Theme);
										rootTheme.MergeTheme(listTheme);
										((IRoot)element).Theme = rootTheme;
									}
								}
								else
								{
									element = new RadioElement(e.ToString());
									element.Theme = ((IRoot)element).Theme; 
									
								}
		
								lastSection.Add(element);
							}

						}
						else if (inline)
						{	
							var inlineSection = new Section(string.Empty, null) {  };
							ApplyElementTheme(newElement.Theme, inlineSection, null);
							inlineSection.Parent = root as IElement;
							sectionList.Add(inlineSection);
	
							IRoot inlineRoot = newElement as IRoot;
							if (newElement.ViewBinding.DataContextCode == DataContextCode.Object)
							{
								var bindingContext = new BindingContext(newElement.ViewBinding.CurrentView, newElement.Caption, newElement.Theme);
								inlineRoot = bindingContext.Root;
							}

							inlineSection.Caption = newElement.Caption;
	
							foreach(var element in inlineRoot.Sections[0].Elements)
								inlineSection.Add(element);

							//root.Groups.Add(inlineRoot.Groups[0]);
						}
						else
						{
							lastSection.Add(newElement);
						}
					}
				}
			}
			
			foreach (var section in sectionList)
			{
				var orderedList = section.Elements.OrderBy(e=>e.Order).ToList();
				section.Elements = orderedList;
			}

			var orderedSections = sectionList.Where(s=>s.Elements.Count > 0).OrderBy(section=>section.Order).ToList();
			return orderedSections;
		}