Inheritance: NSObject
Ejemplo n.º 1
0
		public BindingContext(UIView view, string title, Theme currentTheme)
		{
			if (view == null)
				throw new ArgumentNullException("view");
			
			var parser = new ViewParser();

			parser.Parse(view, title, currentTheme);
			Root = parser.Root;

			var viewContext = view as IBindingContext;
			if (viewContext != null)
			{
				viewContext.BindingContext = this;
				var dataContext = view as IDataContext;
				if (dataContext != null)
				{
					var vmContext = dataContext.DataContext as IBindingContext;
					if (vmContext != null)
					{
						vmContext.BindingContext = this;
					}
				}
			}
		}
Ejemplo n.º 2
0
        public override void UpdateCell(UITableViewCell cell, NSIndexPath indexPath)
        {
            base.UpdateCell(cell, indexPath);

            if (PerformActionIfCellListElement(cell, indexPath, (listSource) => listSource.UpdateCell(cell, indexPath)))
            {
                return;
            }

            var memberData = GetMemberData(indexPath);

            if (memberData.Value != null && cell.DetailTextLabel != null)
            {
                cell.DetailTextLabel.Text = memberData.Value.ToString();
            }

            foreach (var section in Sections.Values)
            {
                if (section.Views.ContainsKey(cell))
                {
                    var views = section.Views[cell];

                    if (views.Count > 0)
                    {
                        foreach (var view in views)
                        {
                            var viewCaption = view as ICaption;
                            if (viewCaption != null && string.IsNullOrEmpty(viewCaption.Caption))
                            {
                                viewCaption.Caption = ViewParser.GetCaption(memberData.Member);
                            }

                            var dc = view as IDataContext <MemberData>;
                            if (dc != null)
                            {
                                if (dc.DataContext != memberData)
                                {
                                    dc.DataContext = memberData;
                                }
                            }

                            var themeable = view as IThemeable;
                            if (themeable != null)
                            {
                                if (themeable.Theme != null)
                                {
                                    themeable.Theme.Cell = cell;
                                }

                                themeable.InitializeTheme(cell);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        protected virtual void Prepare()
        {
            CommandMap.Clear();

            _ActualActionSheet            = new UIActionSheet(Title);
            _ActualActionSheet.Dismissed += HandleDismissed;

            var methods = GetType().GetMethods().Where((methodInfo) => methodInfo.GetCustomAttribute <ButtonAttribute>(true) != null).ToList();

            ICommand command       = null;
            var      destroyMethod = methods.Where((methodInfo) => methodInfo.Name == "Destroy").SingleOrDefault();

            if (destroyMethod != null)
            {
                command = ViewParser.GetCommandForMember(this, destroyMethod);
                var destroyIndex = AddButtonToSheet(GetTitle(destroyMethod), command);
                if (destroyIndex > -1)
                {
                    _ActualActionSheet.DestructiveButtonIndex = destroyIndex;
                }
            }

            foreach (var method in methods)
            {
                if (method.Name != "Cancel" && method.Name != "Destroy")
                {
                    command = ViewParser.GetCommandForMember(this, method);
                    AddButtonToSheet(GetTitle(method), command);
                }
            }

            var cancelMethod = methods.Where((methodInfo) => methodInfo.Name == "Cancel").SingleOrDefault();

            if (cancelMethod != null)
            {
                command = ViewParser.GetCommandForMember(this, cancelMethod);
                var cancelIndex = AddButtonToSheet(GetTitle(cancelMethod), command);
                if (cancelIndex > -1)
                {
                    _ActualActionSheet.CancelButtonIndex = cancelIndex;
                }
            }
        }
Ejemplo n.º 4
0
        private void CreateTableView(object view, MemberInfo member, Theme theme)
        {
            Theme = Theme.CreateTheme(theme);
            var themeable = view as IThemeable;

            if (themeable != null)
            {
                var themeAttribute = view.GetType().GetCustomAttribute <ThemeAttribute>();
                if (themeAttribute != null)
                {
                    var viewTheme = Theme.CreateTheme(themeAttribute.ThemeType);
                    themeable.Theme = viewTheme;
                    var newTheme = Theme.CreateTheme(viewTheme);

                    Theme           = newTheme;
                    themeable.Theme = Theme;
                }
            }

            using (var parser = new ViewParser())
            {
                var source = parser.Parse(this, view, member);

                var tableViewStyle = Theme.TableViewStyle;
                var tableStyle     = source as ITableViewStyle;
                if (tableStyle != null)
                {
                    tableViewStyle = tableStyle.TableViewStyle;
                }

                if (source != null)
                {
                    _TableView        = MakeTableView(UIScreen.MainScreen.Bounds, tableViewStyle);
                    _TableView.Source = source;

                    TableView        = _TableView;
                    DisableScrolling = view.GetType().GetCustomAttribute <DisableScrollingAttribute>() != null;
                }
            }
        }
Ejemplo n.º 5
0
        private void ConfigureRowEditing()
        {
            if (Controller != null && Controller.RootView != null)
            {
                var cellEditingStyle = Controller.RootView.GetType().GetCustomAttribute <CellEditingStyleAttribute>();
                if (cellEditingStyle == null)
                {
                    if (MemberData != null)
                    {
                        cellEditingStyle = MemberData.Member.GetCustomAttribute <CellEditingStyleAttribute>();
                    }
                }

                if (cellEditingStyle != null)
                {
                    _EditingStyle  = cellEditingStyle.EditingStyle;
                    _CanEditSource = Controller.RootView;
                    _CanEditMember = GetMemberFromView(cellEditingStyle.CanEditMemberName);
                    if (_CanEditMember == null)
                    {
                        _CanEditMember = GetMemberFromViewModel(cellEditingStyle.CanEditMemberName);

                        var dc = Controller.RootView as IDataContext <object>;
                        if (dc != null && dc.DataContext != null)
                        {
                            _CanEditSource = dc.DataContext;
                        }
                    }

                    if (!string.IsNullOrEmpty(cellEditingStyle.EditCommandMemberName))
                    {
                        var commandMember = _CanEditSource.GetType().GetMember(cellEditingStyle.EditCommandMemberName).FirstOrDefault();
                        if (commandMember != null)
                        {
                            _EditCommand = ViewParser.GetCommandForMember(_CanEditSource, commandMember);
                        }
                    }
                }
            }
        }
		private void CreateTableView(object view, MemberInfo member, Theme theme)
		{
			Theme = Theme.CreateTheme(theme);
			var themeable = view as IThemeable;
			if (themeable != null)
			{
				var themeAttribute = view.GetType().GetCustomAttribute<ThemeAttribute>();
				if (themeAttribute != null)
				{
					var viewTheme = Theme.CreateTheme(themeAttribute.ThemeType);
					themeable.Theme = viewTheme;
					var newTheme = Theme.CreateTheme(viewTheme);

					Theme = newTheme;
					themeable.Theme = Theme;
				}
			}

			using(var parser = new ViewParser())
			{
				var source = parser.Parse(this, view, member);
				
				var tableViewStyle = Theme.TableViewStyle;
				var tableStyle = source as ITableViewStyle;
				if (tableStyle != null)
				{
					tableViewStyle = tableStyle.TableViewStyle;
				}
				
				if (source != null)
				{
					_TableView = MakeTableView(UIScreen.MainScreen.Bounds, tableViewStyle);
					_TableView.Source = source;
					
					TableView = _TableView;
					DisableScrolling = view.GetType().GetCustomAttribute<DisableScrollingAttribute>() != null;
				}
			}
		}