using Xamarin.Forms;
using System;
using System.ComponentModel;

namespace CupWorks.Forms.Fluent
{
    public static class ToolbarItemExtension
    {
        public static TSelf ChangeOrder<TSelf>(this TSelf self, ToolbarItemOrder order) where TSelf : ToolbarItem
        {
            self.Order = order;
            return self;
        }
        
        public static TSelf ChangePriority<TSelf>(this TSelf self, int priority) where TSelf : ToolbarItem
        {
            self.Priority = priority;
            return self;
        }
        
        public static TSelf HandleToolbarItemClicked<TSelf>(this TSelf self, EventHandler clicked) where TSelf : ToolbarItem
        {
            self.Clicked += clicked;
            return self;
        }
        
        public static TSelf HandleToolbarItemChildAdded<TSelf>(this TSelf self, EventHandler<ElementEventArgs> childAdded) where TSelf : ToolbarItem
        {
            self.ChildAdded += childAdded;
            return self;
        }
        
        public static TSelf HandleToolbarItemChildRemoved<TSelf>(this TSelf self, EventHandler<ElementEventArgs> childRemoved) where TSelf : ToolbarItem
        {
            self.ChildRemoved += childRemoved;
            return self;
        }
        
        public static TSelf HandleToolbarItemDescendantAdded<TSelf>(this TSelf self, EventHandler<ElementEventArgs> descendantAdded) where TSelf : ToolbarItem
        {
            self.DescendantAdded += descendantAdded;
            return self;
        }
        
        public static TSelf HandleToolbarItemDescendantRemoved<TSelf>(this TSelf self, EventHandler<ElementEventArgs> descendantRemoved) where TSelf : ToolbarItem
        {
            self.DescendantRemoved += descendantRemoved;
            return self;
        }
        
        public static TSelf HandleToolbarItemPropertyChanging<TSelf>(this TSelf self, PropertyChangingEventHandler propertyChanging) where TSelf : ToolbarItem
        {
            self.PropertyChanging += propertyChanging;
            return self;
        }
        
        public static TSelf HandleToolbarItemPropertyChanged<TSelf>(this TSelf self, PropertyChangedEventHandler propertyChanged) where TSelf : ToolbarItem
        {
            self.PropertyChanged += propertyChanged;
            return self;
        }
        
        public static TSelf HandleToolbarItemBindingContextChanged<TSelf>(this TSelf self, EventHandler bindingContextChanged) where TSelf : ToolbarItem
        {
            self.BindingContextChanged += bindingContextChanged;
            return self;
        }
    }
}