Ejemplo n.º 1
0
        public static UIBarButtonItem ToBarButtonItem(this IReactiveCommand @this, UIBarButtonSystemItem item)
        {
            var button = new UIBarButtonItem(item, (s, e) => @this.ExecuteIfCan());

            button.EnableIfExecutable(@this);
            return(button);
        }
Ejemplo n.º 2
0
 public static UIBarButtonItem ToBarButtonItem(this IReactiveCommand @this, UIBarButtonSystemItem item)
 {
     if (@this == null)
         return null;
     var button = new UIBarButtonItem(item, (s, e) => @this.ExecuteIfCan(s));
     button.EnableIfExecutable(@this);
     return button;
 }
Ejemplo n.º 3
0
 public UIBarButtonItem(UIBarButtonSystemItem systemItem, EventHandler handler)
     : this(systemItem, new Callback (), actionSel)
 {
     callback = (Callback) Target;
     callback.container = this;
     clicked += handler;
     MarkDirty ();
 }
Ejemplo n.º 4
0
 public UIBarButtonItem(UIBarButtonSystemItem systemItem, EventHandler handler)
     : this(systemItem, new Callback(), actionSel)
 {
     callback           = (Callback)Target;
     callback.container = this;
     clicked           += handler;
     MarkDirty();
 }
Ejemplo n.º 5
0
        public static void SetCommand(this UINavigationItem navigationItem, UIBarButtonSystemItem systemItem,
                                      ICommand command, bool left)
        {
            var item = new UIBarButtonItem(
                systemItem,
                (sender, e) => command?.Execute(sender));

            navigationItem.AddButtonItem(item, left);
        }
Ejemplo n.º 6
0
        public static UIBarButtonItem CreateSystemItem(UIBarButtonSystemItem systemItem, Action action)
        {
            var button = new UIBarButtonItem(
                systemItem,
                (sender, args) => action()
                );

            button.SetTitleTextAttributes(barButtonTextAttributes, UIControlState.Normal);
            button.SetTitleTextAttributes(barButtonTextAttributes, UIControlState.Highlighted);

            return(button);
        }
Ejemplo n.º 7
0
        // Sets a IOS specific System Icon
        // -------------------------------
        void SetSystemBarButton(UIBarButtonSystemItem systemButton = UIBarButtonSystemItem.Stop)
        {
            var topVC = this.TopViewController;
            // create the image back button
            var backButton = new UIBarButtonItem(
                systemButton,
                (sender, args) =>
            {
                topVC.NavigationController.PopViewController(true);
            });

            topVC.NavigationItem.LeftBarButtonItem = backButton;
        }
Ejemplo n.º 8
0
        void ObserveCurrentRate(NSObservedChange change)
        {
            // Update playPauseButton type.
            var newRate = ((NSNumber)change.NewValue).DoubleValue;

            UIBarButtonSystemItem style = (Math.Abs(newRate) < float.Epsilon) ? UIBarButtonSystemItem.Play : UIBarButtonSystemItem.Pause;
            var newPlayPauseButton      = new UIBarButtonItem(style, PlayPauseButtonWasPressed);

            // Replace the current button with the updated button in the toolbar.
            UIBarButtonItem[] items = Toolbar.Items;

            var playPauseItemIndex = Array.IndexOf(items, PlayPauseButton);

            if (playPauseItemIndex >= 0)
            {
                items[playPauseItemIndex] = newPlayPauseButton;
                PlayPauseButton           = newPlayPauseButton;
                Toolbar.SetItems(items, false);
            }
        }
Ejemplo n.º 9
0
	public override void ViewDidLoad ()
	{
		base.ViewDidLoad ();

		Title = "Toolbar";

		View.BackgroundColor = UIColor.GroupTableViewBackgroundColor;
		toolbar = new UIToolbar() {
			BarStyle = UIBarStyle.Default
		};
		toolbar.SizeToFit ();
		float toolbarHeight = toolbar.Frame.Height;
		var mainViewBounds = View.Bounds;
		toolbar.Frame = new RectangleF (mainViewBounds.X, (float)(mainViewBounds.Y + mainViewBounds.Height - toolbarHeight * 2 + 2),
						mainViewBounds.Width, toolbarHeight);
		View.AddSubview (toolbar);
		currentSystemItem = UIBarButtonSystemItem.Done;
		CreateToolbarItems ();

		systemButtonPicker.Model = new ItemPickerModel (this);
	}
Ejemplo n.º 10
0
    public override void ViewDidLoad()
    {
        base.ViewDidLoad();

        Title = "Toolbar";

        View.BackgroundColor = UIColor.GroupTableViewBackgroundColor;
        toolbar = new UIToolbar()
        {
            BarStyle = UIBarStyle.Default
        };
        toolbar.SizeToFit();
        float toolbarHeight  = toolbar.Frame.Height;
        var   mainViewBounds = View.Bounds;

        toolbar.Frame = new RectangleF(mainViewBounds.X, (float)(mainViewBounds.Y + mainViewBounds.Height - toolbarHeight * 2 + 2),
                                       mainViewBounds.Width, toolbarHeight);
        View.AddSubview(toolbar);
        currentSystemItem = UIBarButtonSystemItem.Done;
        CreateToolbarItems();

        systemButtonPicker.Model = new ItemPickerModel(this);
    }
Ejemplo n.º 11
0
		public CommandBarButtonItem(UIBarButtonSystemItem systemItem): base(systemItem, (s, e) => Command.Execute(null)) {}
Ejemplo n.º 12
0
		public virtual UIBarButtonItem CreateBarButton (UIImage image, EventHandler handler, UIBarButtonSystemItem fallback = UIBarButtonSystemItem.Add)
		{
			if (image == null)
				return new UIBarButtonItem (fallback, handler);

			return new UIBarButtonItem (image, UIBarButtonItemStyle.Plain, handler);
		}
Ejemplo n.º 13
0
 public CommandBarButtonItem(UIBarButtonSystemItem systemItem) : base(systemItem, (s, e) => Execute(CommandParameter))
 {
 }
Ejemplo n.º 14
0
 public CommandBarButtonItem(UIBarButtonSystemItem systemItem) : base(systemItem, (s, e) => Command.Execute(null))
 {
 }
Ejemplo n.º 15
0
 public UIBarButtonItem(UIBarButtonSystemItem systemItem)
     : this(systemItem, null, null)
 {
 }
Ejemplo n.º 16
0
 public CommandBarButtonItem(UIBarButtonSystemItem systemItem) : base(systemItem)
 {
 }
Ejemplo n.º 17
0
        public virtual UIBarButtonItem CreateBarButton(UIImage image, EventHandler handler, UIBarButtonSystemItem fallback = UIBarButtonSystemItem.Add)
        {
            if (image == null)
            {
                return(new UIBarButtonItem(fallback, handler));
            }

            return(new UIBarButtonItem(image, UIBarButtonItemStyle.Plain, handler));
        }
Ejemplo n.º 18
0
 public UIBarBtn(UIBarButtonSystemItem si, EventHandler handler)
     : base(si,handler)
 {
 }
Ejemplo n.º 19
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;
		}
		public CommandBarButtonItem(UIBarButtonSystemItem systemItem): base(systemItem) {}
Ejemplo n.º 21
0
 public UIBarButtonItemEx(UIBarButtonSystemItem systemItem)
     : base(systemItem)
 {
 }
Ejemplo n.º 22
0
 public EditButtonAttribute(UIBarButtonSystemItem buttonType)
 {
     ButtonType = buttonType;
 }
Ejemplo n.º 23
0
 public static IDisposable ToBarButtonItem(this IObservable<IReactiveCommand> @this, UIBarButtonSystemItem systemItem, Action<UIBarButtonItem> assignment)
 {
     return ToBarButtonItem(@this, () => new UIBarButtonItem(systemItem), assignment);
 }
Ejemplo n.º 24
0
		public override UIBarButtonItem CreateBarButton (UIImage image, EventHandler handler, UIBarButtonSystemItem fallback = UIBarButtonSystemItem.Add)
		{
			if (image == null)
				return new UIBarButtonItem (fallback, handler);

			if (IsModern)
				return new UIBarButtonItem (image, UIBarButtonItemStyle.Plain, handler);

			var button = UIButton.FromType (UIButtonType.Custom);
			var sz = image.Size;
			sz.Width = Math.Max (44, 44);
			sz.Height = 44;
			button.Frame = new CGRect (CGPoint.Empty, sz);
			button.SetImage (image, UIControlState.Normal);
			button.ShowsTouchWhenHighlighted = true;
			button.TouchUpInside += handler;
			return new UIBarButtonItem (button);
		}
Ejemplo n.º 25
0
 public UIBarButtonItem(UIBarButtonSystemItem barButtonSystemItem, [Optional] AnyObject target, Selector action)
 {
 }
Ejemplo n.º 26
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;
		}
		public EditButtonAttribute(UIBarButtonSystemItem buttonType)
		{
			ButtonType = buttonType;
		}
Ejemplo n.º 28
0
		public ToolbarButtonAttribute(UIBarButtonSystemItem buttonType): this()
		{
			ButtonType = buttonType;
		}
Ejemplo n.º 29
0
 public UIBarButtonItem(UIBarButtonSystemItem systemItem) : this(systemItem, null, null)
 {
 }
Ejemplo n.º 30
0
 public static UIBarButtonItemEx Create(UIBarButtonSystemItem systemItem)
 {
     return new UIBarButtonItemEx(systemItem);
 }
Ejemplo n.º 31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="KSPictureLoginLib.KSBarButtonItem"/> class.
 /// </summary>
 /// <param name="controller">A reference to the <see cref="KSPictureLoginController"/> </param>
 /// <param name="sysItem">a system item.</param>
 public KSBarButtonItem(KSPictureLoginController controller, UIBarButtonSystemItem sysItem)
     : base(sysItem, null)
 {
     this.controller = new WeakReference (controller);
 }
		public CommandBarButtonItem(UIBarButtonSystemItem systemItem, EventHandler handler): base(systemItem, handler) {}
Ejemplo n.º 33
0
        private CommandBarButtonItem CreateCommandBarButton(object view, MemberInfo member, string title, UIView buttonView, UIBarButtonItemStyle style, UIBarButtonSystemItem buttonType, BarButtonLocation location)
        {
            CommandBarButtonItem button = null;

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

            if (methodInfo != null)
            {
                command = new ReflectiveCommand(view, member as MethodInfo, null);
            }

            if (!string.IsNullOrEmpty(title))
            {
                button = new CommandBarButtonItem(title, style, delegate { command.Execute(null); });
            }
            else if (buttonView != null)
            {
                button = new CommandBarButtonItem(buttonView);
            }
            else
            {
                button       = new CommandBarButtonItem(buttonType, delegate { command.Execute(null); });
                button.Style = style;
            }

            button.Enabled  = true;
            button.Location = location;

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

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

            return(button);
        }
		public CommandBarButtonItem(UIBarButtonSystemItem systemItem, NSObject target, Selector action): base(systemItem, target, action) {}
		public CommandBarButtonItem(UIBarButtonSystemItem systemItem): base(systemItem, (s, e) => Execute(CommandParameter)) {}
Ejemplo n.º 36
0
        public override UIBarButtonItem CreateBarButton(UIImage image, EventHandler handler, UIBarButtonSystemItem fallback = UIBarButtonSystemItem.Add)
        {
            if (image == null)
            {
                return(new UIBarButtonItem(fallback, handler));
            }

            if (IsModern)
            {
                return(new UIBarButtonItem(image, UIBarButtonItemStyle.Plain, handler));
            }

            var button = UIButton.FromType(UIButtonType.Custom);
            var sz     = image.Size;

            sz.Width     = Math.Max(44, 44);
            sz.Height    = 44;
            button.Frame = new CGRect(CGPoint.Empty, sz);
            button.SetImage(image, UIControlState.Normal);
            button.ShowsTouchWhenHighlighted = true;
            button.TouchUpInside            += handler;
            return(new UIBarButtonItem(button));
        }
Ejemplo n.º 37
0
		private CommandBarButtonItem CreateCommandBarButton(object view, MemberInfo member, string title, UIBarButtonItemStyle style, UIBarButtonSystemItem buttonType, BarButtonLocation location )
		{
			CommandBarButtonItem button = null;

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

			if(methodInfo != null)
				command = new ReflectiveCommand(view, member as MethodInfo, null);

			if(!string.IsNullOrEmpty(title))
			{
				button = new CommandBarButtonItem(title, style, delegate {command.Execute(null); });
			}
			else
			{
				button = new CommandBarButtonItem(buttonType,  delegate {command.Execute(null); });
				button.Style = style;
			}
		
			button.Enabled = true;
			button.Location = location;

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

			return button;
		}
 public ToolbarButtonAttribute(UIBarButtonSystemItem buttonType) : this()
 {
     ButtonType = buttonType;
 }
Ejemplo n.º 39
0
 public static IDisposable ToBarButtonItem(this IObservable <ReactiveCommand> @this, UIBarButtonSystemItem systemItem, Action <UIBarButtonItem> assignment)
 {
     return(ToBarButtonItem(@this, () => new UIBarButtonItem(systemItem), assignment));
 }
Ejemplo n.º 40
0
 public CommandBarButtonItem(UIBarButtonSystemItem systemItem, EventHandler handler) : base(systemItem, handler)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="KSPictureLoginLib.KSBarButtonItem"/> class.
 /// </summary>
 /// <param name="sysItem">a system item.</param>
 public KSPictureLoginBarButtonItem( UIBarButtonSystemItem sysItem)
     : base(sysItem)
 {
     this.Initialize ();
 }
Ejemplo n.º 42
0
 public CommandBarButtonItem(UIBarButtonSystemItem systemItem, NSObject target, Selector action) : base(systemItem, target, action)
 {
 }
        public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
        {
            if (context != IntPtr.Zero)
            {
                base.ObserveValue(keyPath, ofObject, change, context);
                return;
            }

            var ch = new NSObservedChange(change);

            if (keyPath == "currentItem.duration")
            {
                // Update `TimeSlider` and enable/disable controls when `duration` > 0.0

                CMTime newDuration;
                var    newDurationAsValue = ch.NewValue as NSValue;
                newDuration = (newDurationAsValue != null) ? newDurationAsValue.CMTimeValue : CMTime.Zero;
                var hasValidDuration   = newDuration.IsNumeric && newDuration.Value != 0;
                var newDurationSeconds = hasValidDuration ? newDuration.Seconds : 0;

                TimeSlider.MaxValue = (float)newDurationSeconds;

                var currentTime = Player.CurrentTime.Seconds;
                TimeSlider.Value = (float)(hasValidDuration ? currentTime : 0);

                PlayPauseButton.Enabled = hasValidDuration;
                TimeSlider.Enabled      = hasValidDuration;
            }
            else if (keyPath == "rate")
            {
                // Update playPauseButton type.
                var newRate = ((NSNumber)ch.NewValue).DoubleValue;

                UIBarButtonSystemItem style = (newRate == 0) ? UIBarButtonSystemItem.Play : UIBarButtonSystemItem.Pause;
                var newPlayPauseButton      = new UIBarButtonItem(style, PlayPauseButtonWasPressed);

                // Replace the current button with the updated button in the toolbar.
                UIBarButtonItem[] items = Toolbar.Items;

                var playPauseItemIndex = Array.IndexOf(items, PlayPauseButton);
                if (playPauseItemIndex >= 0)
                {
                    items [playPauseItemIndex] = newPlayPauseButton;
                    PlayPauseButton            = newPlayPauseButton;
                    Toolbar.SetItems(items, false);
                }
            }
            else if (keyPath == "currentItem.status")
            {
                // Display an error if status becomes Failed

                var newStatusAsNumber        = ch.NewValue as NSNumber;
                AVPlayerItemStatus newStatus = (newStatusAsNumber != null)
                                        ? (AVPlayerItemStatus)newStatusAsNumber.Int32Value
                                        : AVPlayerItemStatus.Unknown;

                if (newStatus == AVPlayerItemStatus.Failed)
                {
                    HandleError(Player.CurrentItem.Error);
                }
                else if (newStatus == AVPlayerItemStatus.ReadyToPlay)
                {
                    var asset = Player.CurrentItem != null ? Player.CurrentItem.Asset : null;
                    if (asset != null)
                    {
                        // First test whether the values of `assetKeysRequiredToPlay` we need
                        // have been successfully loaded.
                        foreach (var key in assetKeysRequiredToPlay)
                        {
                            NSError error;
                            if (asset.StatusOfValue(key, out error) == AVKeyValueStatus.Failed)
                            {
                                HandleError(error);
                                return;
                            }
                        }

                        if (!asset.Playable || asset.ProtectedContent)
                        {
                            // We can't play this asset.
                            HandleError(null);
                            return;
                        }

                        // The player item is ready to play,
                        // setup picture in picture.
                        SetupPictureInPicturePlayback();
                    }
                }
            }
            else if (keyPath == "pictureInPicturePossible")
            {
                // Enable the `PictureInPictureButton` only if `PictureInPicturePossible`
                // is true. If this returns false, it might mean that the application
                // was not configured as shown in the AppDelegate.
                PictureInPictureButton.Enabled = ((NSNumber)ch.NewValue).BoolValue;
            }
        }