Наследование: UIBarButtonItem, ICommandButton
Пример #1
0
        private static CommandBarButtonItem CreateCommandBarButton(object view, MemberInfo member, string title, UIView buttonView, UIBarButtonItemStyle style, UIBarButtonSystemItem?buttonType, BarButtonLocation location)
        {
            CommandBarButtonItem button = null;

            ReflectiveCommand command = null;
            var methodInfo            = member as MethodInfo;

            if (methodInfo != null)
            {
                command = GetCommandForMember(view, member);
            }

            if (!string.IsNullOrEmpty(title))
            {
                button = new CommandBarButtonItem(title, style, (sender, e) => command.Execute(null));
            }
            else if (buttonView != null)
            {
                button = new CommandBarButtonItem(buttonView);
            }
            else
            {
                if (!buttonType.HasValue)
                {
                    buttonType = UIBarButtonSystemItem.Done;
                }

                button       = new CommandBarButtonItem(buttonType.Value, (sender, e) => command.Execute(null));
                button.Style = style;
            }

            command.CommandButton = button;
            button.Enabled        = true;
            button.Location       = location;
            button.Command        = command;

            var orderAttribute = member.GetCustomAttribute <OrderAttribute>();

            if (orderAttribute != null)
            {
                button.Order = orderAttribute.Order;
            }
            else
            {
                button.Order = 0;
            }

            return(button);
        }
Пример #2
0
		private static CommandBarButtonItem CreateCommandBarButton(object view, MemberInfo member, string title, UIView buttonView, UIBarButtonItemStyle style, UIBarButtonSystemItem? buttonType, BarButtonLocation location)
		{
			ICommandInterceptor commandInterceptor = null;
			CommandBarButtonItem button = null;

			ReflectiveCommand command = null;
			var methodInfo = member as MethodInfo;

			if(methodInfo != null)
			{
				command = GetCommandForMember(view, member);
				var cellViewTemplates = member.GetCustomAttributes<CellViewTemplate>();
				if (cellViewTemplates.Length > 0)
				{
					var interceptorTemplate = cellViewTemplates
						.FirstOrDefault((template) => template.CellViewType != null && template.CellViewType.GetInterfaces()
						       .Any((type)=> type == typeof(ICommandInterceptor))) as CellViewTemplate;
					if (interceptorTemplate != null)
					{
						commandInterceptor = Activator.CreateInstance(interceptorTemplate.CellViewType) as ICommandInterceptor;
					}
				}
			}

			if (!string.IsNullOrEmpty(title))
			{
				button = new CommandBarButtonItem(title, style);
			}
			else if (buttonView != null)
			{
				button = new CommandBarButtonItem(buttonView); 
			}
			else
			{
				if (!buttonType.HasValue)
					buttonType = UIBarButtonSystemItem.Done;

				button = new CommandBarButtonItem(buttonType.Value);
				button.Style = style;
			}
		
			command.CommandButton = button;
			button.Enabled = true;
			button.Location = location;
			button.Command = command;
			button.CommandInterceptor = commandInterceptor;

			var orderAttribute = member.GetCustomAttribute<OrderAttribute>();
			if (orderAttribute != null)
				button.Order = orderAttribute.Order;
			else 
				button.Order = 0;

			return button;
		}
        private static CommandBarButtonItem CreateCommandBarButton(object view, MemberInfo member, string title, UIView buttonView, UIBarButtonItemStyle style, UIBarButtonSystemItem?buttonType, BarButtonLocation location)
        {
            ICommandInterceptor  commandInterceptor = null;
            CommandBarButtonItem button             = null;

            ReflectiveCommand command = null;
            var methodInfo            = member as MethodInfo;

            if (methodInfo != null)
            {
                command = GetCommandForMember(view, member);
                var cellViewTemplates = member.GetCustomAttributes <CellViewTemplate>();
                if (cellViewTemplates.Length > 0)
                {
                    var interceptorTemplate = cellViewTemplates
                                              .FirstOrDefault((template) => template.CellViewType != null && template.CellViewType.GetInterfaces()
                                                              .Any((type) => type == typeof(ICommandInterceptor))) as CellViewTemplate;
                    if (interceptorTemplate != null)
                    {
                        commandInterceptor = Activator.CreateInstance(interceptorTemplate.CellViewType) as ICommandInterceptor;
                    }
                }
            }

            if (!string.IsNullOrEmpty(title))
            {
                button = new CommandBarButtonItem(title, style);
            }
            else if (buttonView != null)
            {
                button = new CommandBarButtonItem(buttonView);
            }
            else
            {
                if (!buttonType.HasValue)
                {
                    buttonType = UIBarButtonSystemItem.Done;
                }

                button       = new CommandBarButtonItem(buttonType.Value);
                button.Style = style;
            }

            command.CommandButton     = button;
            button.Enabled            = true;
            button.Location           = location;
            button.Command            = command;
            button.CommandInterceptor = commandInterceptor;

            var orderAttribute = member.GetCustomAttribute <OrderAttribute>();

            if (orderAttribute != null)
            {
                button.Order = orderAttribute.Order;
            }
            else
            {
                button.Order = 0;
            }

            return(button);
        }
Пример #4
0
		private static CommandBarButtonItem CreateCommandBarButton(object view, MemberInfo member, string title, UIView buttonView, UIBarButtonItemStyle style, UIBarButtonSystemItem? buttonType, BarButtonLocation location)
		{
			CommandBarButtonItem button = null;

			ReflectiveCommand command = null;
			var methodInfo = member as MethodInfo;

			if(methodInfo != null)
				command = GetCommandForMember(view, member);

			if (!string.IsNullOrEmpty(title))
			{
				button = new CommandBarButtonItem(title, style, (sender, e) => command.Execute(null));
			}
			else if (buttonView != null)
			{
				button = new CommandBarButtonItem(buttonView); 
			}
			else
			{
				if (!buttonType.HasValue)
					buttonType = UIBarButtonSystemItem.Done;

				button = new CommandBarButtonItem(buttonType.Value,  (sender, e) => command.Execute(null));
				button.Style = style;
			}
		
			command.CommandButton = button;
			button.Enabled = true;
			button.Location = location;
			button.Command = command;

			var orderAttribute = member.GetCustomAttribute<OrderAttribute>();
			if (orderAttribute != null)
				button.Order = orderAttribute.Order;
			else 
				button.Order = 0;

			return button;
		}