public static bool ProcessMenuItemSelected(this IParentMenu parentMenu, IMenuItem item)
        {
#warning TODO - make this OO - let the _parentMenu respond to commands itself...
            foreach (var child in parentMenu.Children)
            {
                if (child == null)
                {
                    throw new MvxException("Child is not a CaptionAndIconMenu - is null");
                }

                var childCast = child as CaptionAndIconMenu;
                if (childCast == null)
                {
                    throw new MvxException("Child is not a CaptionAndIconMenu - is a {0}", child.GetType().Name);
                }
                if (childCast != null &&
                    childCast.UniqueId == item.ItemId)
                {
                    childCast.Command?.Execute(null);
                    return(true);
                }
            }

            return(false);
        }
        public static bool CreateOptionsMenu(this Context context, IParentMenu parentMenu, Android.Views.IMenu menu)
        {
            if (parentMenu == null)
            {
                return(false);
            }

#warning TODO - make this OO - let the _parentMenu render itself...
            foreach (var child in parentMenu.Children)
            {
                var childCast = child as CaptionAndIconMenu;

                if (childCast != null)
                {
                    var item = menu.Add(1, childCast.UniqueId, 0, childCast.Caption);
                    if (!string.IsNullOrEmpty(childCast.Icon))
                    {
#warning TODO - cannot use Resourcein library code! Should we use reflection here? Or some other mechaniasm?
                        var resourceId = context.Resources.GetIdentifier(childCast.Icon, "drawable", context.PackageName);
                        if (resourceId > 0)
                        {
                            item.SetIcon(resourceId);
                        }
                    }
                }
            }
            return(true);
        }
Exemple #3
0
        public static void ShowOptionsMenu(this UIViewController vc, IParentMenu parentMenu)
        {
            if (parentMenu == null)
            {
                return;
            }

            var actionSheet = new UIActionSheet();

#warning TODO - make this OO - let the _parentMenu render itself...
            var actions = new List <ICommand>();
            foreach (var child in parentMenu.Children)
            {
                var childCast = child as CaptionAndIconMenu;

#warning More to do here - e.g. check for null!
                actionSheet.AddButton(childCast?.Caption);
                actions.Add(childCast?.Command);
            }

            actionSheet.Clicked += (object sender, UIButtonEventArgs e) =>
            {
                if (e.ButtonIndex >= 0)
                {
                    actions[(int)e.ButtonIndex].Execute(null);
                }
            };

#warning More to do here - e.g. check for null!
            //if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
            //	actionSheet.ShowFromToolbar(NavigationController.Toolbar);
            //else
            actionSheet.ShowFrom(vc.NavigationItem.RightBarButtonItem, true);
        }
        public static bool CreateOptionsMenu(this Context context, IParentMenu parentMenu, Android.Views.IMenu menu)
        {
            if (parentMenu == null)
            {
                return false;
            }

#warning TODO - make this OO - let the _parentMenu render itself...
            foreach (var child in parentMenu.Children)
            {
                var childCast = child as CaptionAndIconMenu;

                if (childCast != null)
                {
                    var item = menu.Add(1, childCast.UniqueId, 0, childCast.Caption);
                    if (!string.IsNullOrEmpty(childCast.Icon))
                    {
#warning TODO - cannot use Resourcein library code! Should we use reflection here? Or some other mechaniasm?
                        var resourceId = context.Resources.GetIdentifier(childCast.Icon, "drawable", context.PackageName);
                        if (resourceId > 0)
                        {
                            item.SetIcon(resourceId);
                        }
                    }
                }
            }
            return true;
        }
        public static void ShowOptionsMenu(this UIViewController vc, IParentMenu parentMenu)
        {
            if (parentMenu == null)
            {
                return;
            }

            var actionSheet = new UIActionSheet();

#warning TODO - make this OO - let the _parentMenu render itself...
            var actions = new List<ICommand>();
            foreach (var child in parentMenu.Children)
            {
                var childCast = child as CaptionAndIconMenu;

#warning More to do here - e.g. check for null!
                actionSheet.AddButton(childCast.Caption);
                actions.Add(childCast.Command);
            }

            actionSheet.Clicked += (object sender, UIButtonEventArgs e) =>
                {
                    if (e.ButtonIndex >= 0)
                    {
                        actions[e.ButtonIndex].Execute(null);
                    }
                };

#warning More to do here - e.g. check for null!
            //if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
            //	actionSheet.ShowFromToolbar(NavigationController.Toolbar);
            //else
            actionSheet.ShowFrom(vc.NavigationItem.RightBarButtonItem, true);
        }
 protected override void OnViewModelSet()
 {
     base.OnViewModelSet();
     using (new MvxBindingContextStackRegistration<IMvxAndroidBindingContext>((IMvxAndroidBindingContext)BindingContext))
     {
         Root = this.LoadDialogRoot<Element, RootElement>();
         this._parentMenu = this.LoadMenu();
     }
 }
Exemple #7
0
 protected override void OnViewModelSet()
 {
     base.OnViewModelSet();
     using (new MvxBindingContextStackRegistration <IMvxAndroidBindingContext>((IMvxAndroidBindingContext)BindingContext))
     {
         Root        = this.LoadDialogRoot <Element, RootElement>();
         _parentMenu = this.LoadMenu();
     }
 }
Exemple #8
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Root        = this.LoadDialogRoot <Element, RootElement>();
            _parentMenu = this.LoadMenu();

            if (_parentMenu != null)
            {
                NavigationItem.SetRightBarButtonItem(
                    new UIBarButtonItem(UIBarButtonSystemItem.Action,
                                        (sender, e) => { ShowActionMenu(); }),
                    false);
            }
        }
        protected override void OnViewModelSet()
        {
            base.OnViewModelSet();

            this._parentMenu = this.LoadMenu();
            this._list = this.LoadList<GeneralListLayout>();

            using (
                new MvxBindingContextStackRegistration<IMvxAndroidBindingContext>((IMvxAndroidBindingContext)BindingContext)
                )
            {
                var listView = this._list.InitializeListView(this);
                this.SetContentView(listView);
            }
        }
Exemple #10
0
        protected override void OnViewModelSet()
        {
            base.OnViewModelSet();

            this._parentMenu = this.LoadMenu();
            this._list       = this.LoadList <GeneralListLayout>();

            using (
                new MvxBindingContextStackRegistration <IMvxAndroidBindingContext>((IMvxAndroidBindingContext)BindingContext)
                )
            {
                var listView = this._list.InitializeListView(this);
                this.SetContentView(listView);
            }
        }
        public static bool ProcessMenuItemSelected(this IParentMenu parentMenu, IMenuItem item)
        {
#warning TODO - make this OO - let the _parentMenu respond to commands itself...
            foreach (var child in parentMenu.Children)
            {
                var childCast = child as CaptionAndIconMenu;
                if (childCast.UniqueId == item.ItemId)
                {
                    childCast.Command.Execute(null);
                    return(true);
                }
            }

            return(false);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Root = this.LoadDialogRoot<Element, RootElement>();
            this._parentMenu = this.LoadMenu();

            if (this._parentMenu != null)
            {
                NavigationItem.SetRightBarButtonItem(
                    new UIBarButtonItem(UIBarButtonSystemItem.Action,
                                        (sender, e) => { this.ShowActionMenu(); }),
                    false);
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _parentMenu = this.LoadMenu();

            _list = this.LoadList<GeneralListLayout>();
            var source = _list.InitialiseSource(TableView);
            TableView.Source = source;
            TableView.ReloadData();

            if (_parentMenu != null)
            {
                NavigationItem.SetRightBarButtonItem(
                    new UIBarButtonItem(UIBarButtonSystemItem.Action,
                                        (sender, e) => { ShowActionMenu(); }),
                    false);
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _parentMenu = this.LoadMenu();

            _list = this.LoadList <GeneralListLayout>();
            var source = _list.InitialiseSource(TableView);

            TableView.Source = source;
            TableView.ReloadData();

            if (_parentMenu != null)
            {
                NavigationItem.SetRightBarButtonItem(
                    new UIBarButtonItem(UIBarButtonSystemItem.Action,
                                        (sender, e) => { ShowActionMenu(); }),
                    false);
            }
        }
Exemple #15
0
 public virtual void SetParentMenu(IParentMenu parent)
 {
     this.parentScreen = parent;
 }