public string Save(IMenu menu)
        {
            if (_menuRepository == null)
                throw new ArgumentNullException("MenuRepository cannot be null");
            if (menu.Id == 0)
            {
                // new menu
                menu.DateCreated = DateTime.Now;
                menu.Active = true;
                menu.DateModified = null;
                _menuRepository.Add((DF.Domain.Concrete.Menu)menu);

                _menuRepository.UnitOfWork.Commit();

            }
            else
            {
                var oMenu = _menuRepository.Where(u => u.Id == menu.Id).SingleOrDefault();

                if (oMenu == null)
                    throw new ArgumentNullException("menu");

                menu.DateCreated = oMenu.DateCreated;

                Magically.CopyPropertyValues(ref oMenu, (Menu)menu);

                _menuRepository.UnitOfWork.Commit();

            }

            return string.Format("Successfully saved menu {0}", menu.DisplayText);
        }
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            // Inflate the menu
            MenuInflater.Inflate (Resource.Menu.ActionBarActionProvider, menu);

            // Set file with share history to the provider and set the share intent.
            var action_item = menu.FindItem (Resource.Id.menu_item_share_action_provider_action_bar);
            var action_provider = (ShareActionProvider)action_item.ActionProvider;

            action_provider.SetShareHistoryFileName (ShareActionProvider.DefaultShareHistoryFileName);

            // Note that you can set/change the intent any time,
            // say when the user has selected an image.
            action_provider.SetShareIntent (CreateShareIntent ());

            // Set file with share history to the provider and set the share intent.
            var overflow_item = menu.FindItem (Resource.Id.menu_item_share_action_provider_overflow);
            var overflow_provider = (ShareActionProvider)overflow_item.ActionProvider;

            overflow_provider.SetShareHistoryFileName (ShareActionProvider.DefaultShareHistoryFileName);

            // Note that you can set/change the intent any time,
            // say when the user has selected an image.
            overflow_provider.SetShareIntent (CreateShareIntent ());

            return true;
        }
Example #3
0
        /// <summary>
        /// http://mgroves.com/monodroid-creating-an-options-menu/ 
        /// </summary>
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            var item = menu.Add(Menu.None, 1, 1, new Java.Lang.String("Schedule"));
            //item.SetIcon(Resource.Drawable.calendar);

            item = menu.Add(Menu.None, 2, 2, new Java.Lang.String("Speakers"));  // HACK: todo - add 'using' statement around Java.Lang.Strings for GC (as per novell hint)
            //item.SetIcon(Resource.Drawable.microphone);

            item = menu.Add(Menu.None, 3, 3, new Java.Lang.String("Sessions"));
            //item.SetIcon(Resource.Drawable.bullhorn);

            item = menu.Add(Menu.None, 4, 4, new Java.Lang.String("Map"));
            //item.SetIcon(Resource.Drawable.map);

            item = menu.Add(Menu.None, 5, 5, new Java.Lang.String("Favorites"));
            //item.SetIcon(Resource.Drawable.star);

            item = menu.Add(Menu.None, 6, 6, new Java.Lang.String("News"));
            //item.SetIcon(Resource.Drawable.star);

            item = menu.Add(Menu.None, 7, 7, new Java.Lang.String("Twitter"));
            //item.SetIcon(Resource.Drawable.star);

            item = menu.Add(Menu.None, 8, 8, new Java.Lang.String("Exhibitors"));
            //item.SetIcon(Resource.Drawable.star);

            item = menu.Add(Menu.None, 9, 9, new Java.Lang.String("About Xamarin"));
            //item.SetIcon(Resource.Drawable.star);

            return true;
        }
Example #4
0
        /// <summary>
        /// 不包括http、域名、application path和网址后缀(仅仅是path)
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="menu"></param>
        /// <returns></returns>
        public static String getMenuFullPath( MvcContext ctx, IMenu menu )
        {
            String url = menu.RawUrl;
            String ownerPathAndUrl = getMemberPathUrlByMenu( menu );

            // 带http的完整网址
            Boolean isFullUrl = PathHelper.IsFullUrl( url );
            if (isFullUrl) return url;

            // 包括完整的ownerPath
            if (url.StartsWith( "/" )) {
                return url + MvcConfig.Instance.UrlExt;
            }

            String result = url;
            if (url.StartsWith( ctx.url.AppPath )) {
                result = strUtil.TrimStart( url, ctx.url.AppPath );
            }

            if (result.StartsWith( ownerPathAndUrl )) {
                result = strUtil.TrimStart( result, ownerPathAndUrl );
            }
            if (result.StartsWith( "/" + ownerPathAndUrl ) && strUtil.HasText( ownerPathAndUrl )) {
                result = strUtil.TrimStart( result, "/" + ownerPathAndUrl );
            }

            String location = strUtil.Join( ctx.url.AppPath, ownerPathAndUrl );
            result = strUtil.Join( location, result );
            return result;
        }
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            this.MenuInflater.Inflate (Resource.Menu.ActionBarMenu, menu);
            var addFeedButton = menu.FindItem (Resource.Id.AddFeedItem);

            return base.OnCreateOptionsMenu (menu);
        }
 public virtual void Inflate(int menuRes, IMenu menu, object parent)
 {
     using (XmlReader reader = _context.Resources.GetLayout(menuRes))
     {
         //NOTE XDocument throws an error.
         var document = new XmlDocument();
         document.Load(reader);
         if (IsDefaultMenu(document))
         {
             MenuInflater menuInflater = NestedMenuInflater;
             if (menuInflater == null)
                 base.Inflate(menuRes, menu);
             else
                 menuInflater.Inflate(menuRes, menu);
         }
         else
         {
             using (var stringReader = new StringReader(PlatformExtensions.XmlTagsToUpper(document.InnerXml)))
             {
                 var menuWrapper = (MenuTemplate)Serializer.Deserialize(stringReader);
                 menuWrapper.Apply(menu, _context, parent);
             }
         }
     }
 }
		public override void OnCreateOptionsMenu(IMenu menu, MenuInflater inflater)
		{
			var conferencesScheduleViewModel = this.DataContext as ConferencesScheduleViewModel;

			inflater.Inflate(Resource.Menu.ConferencesListActionItems, menu);

			var searchView = (SearchView)menu.FindItem(Resource.Id.menu_search).ActionView;

			var textChangedLastTime = DateTime.Now;
			searchView.QueryTextChange += async (object sender, SearchView.QueryTextChangeEventArgs e) => 
			{
				var changedSpan = DateTime.Now.Subtract(textChangedLastTime);
				if (changedSpan.TotalMilliseconds > 200)
				{
					await conferencesScheduleViewModel.SearchAsync(e.NewText);
				}
				textChangedLastTime = DateTime.Now;
			};

			searchView.Close += async (sender, e) => 
			{
				await conferencesScheduleViewModel.LoadConferencesAsync(LoadRequest.Load);
				searchView.ClearFocus();
				searchView.OnActionViewCollapsed();
			};

			searchView.QueryTextSubmit += async (sender, e) => {
				await conferencesScheduleViewModel.SearchAsync(e.Query);
				searchView.ClearFocus();
				searchView.OnActionViewCollapsed(); 
			};
		}
Example #8
0
 /// <summary>
 /// Overrides this to enable SVG in toolbar icons.
 /// </summary>
 public override bool OnPrepareOptionsMenu(IMenu menu)
 {
     //don't call base version.
     //var ok=base.OnPrepareOptionsMenu(menu);
     //SvgImageRenderer.PrepareMenu(this, menu);
     return true;
 }
Example #9
0
        public override bool OnPrepareOptionsMenu(IMenu menu)
        {
            menu.GetItem (4).SetVisible (true);	// add
            switch (ViewModel.State) {
            case 0:	// idle
                menu.GetItem (0).SetVisible (false);	// go
                menu.GetItem (1).SetVisible (false);	// pause
                menu.GetItem (2).SetVisible (false);	// resume
                menu.GetItem (3).SetVisible (false);	// finish
                break;

            case 1:	// go
                menu.GetItem (0).SetVisible (false);	// go
                menu.GetItem (1).SetVisible (true);		// pause
                menu.GetItem (2).SetVisible (false);	// resume
                menu.GetItem (3).SetVisible (true);		// finish
                break;

            case 2:	// pause
                menu.GetItem (0).SetVisible (false);	// go
                menu.GetItem (1).SetVisible (false);	// pause
                menu.GetItem (2).SetVisible (true);		// resume
                menu.GetItem (3).SetVisible (true);		// finish
                break;

            default:
                throw new NotImplementedException ();
            }

            return true;
        }
        public override bool OnPrepareOptionsMenu(IMenu menu)
        {
            var refresh = menu.FindItem(Resource.Id.mvxplugins_action_relogin);
            refresh.SetVisible(_showRefresh);

            return base.OnPrepareOptionsMenu(menu);
        }
Example #11
0
        public override void OnCreateOptionsMenu(IMenu menu, MenuInflater inflater)
        {
            Activity.MenuInflater.Inflate (Resource.Menu.schedule_menu, menu);

            //Handle share action provider
            var shareMenuItem = menu.FindItem (Resource.Id.action_schedule_share);
            var shareActionProvider =
                (ShareActionProvider)shareMenuItem.ActionProvider;
            shareActionProvider.SetShareIntent (CreateIntent ());

            //Handle search action provider
            var searchOption = menu.FindItem(Resource.Id.action_schedule_search);

            //Handle expand/colapse of action bar
            MenuItemCompat.SetOnActionExpandListener(searchOption, new SearchViewExpandListener(_adapter));

            var searchItem = MenuItemCompat.GetActionView(searchOption);
            _searchView = searchItem.JavaCast<SearchView>();
            _searchView.QueryTextChange += (s, e) => _adapter.Filter.InvokeFilter(e.NewText);

            _searchView.QueryTextSubmit += (s, e) =>
            {
                Toast.MakeText(Activity, "Searched for: " + e.Query, ToastLength.Short).Show();
                e.Handled = true;
            };
        }
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            if (MenuId > 0)
                MenuInflater.Inflate(MenuId, menu);

            return base.OnCreateOptionsMenu(menu);
        }
Example #13
0
 private void deleteDefaulHtml( IMenu menu )
 {
     String defaultHtml = getDefaultPagePath();
     if (file.Exists( defaultHtml )) {
         file.Delete( defaultHtml );
     }
 }
        public override bool OnPrepareOptionsMenu(IMenu menu)
        {
            menuLockItem = menu.FindItem(Resource.Id.menu_lock);
            ToggleLockBtnTitle();

            return base.OnPrepareOptionsMenu(menu);
        }
        public override void OnPrepareOptionsMenu(IMenu menu)
        {
            IMenuItem fav_item = menu.FindItem(Resource.Id.favorite_action_button);
            fav_item.SetVisible(true);

            base.OnPrepareOptionsMenu(menu);
        }
Example #16
0
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            MenuInflater.Inflate (Resource.Menu.Main, menu);

            /*var searchMenu = menu.Add ("Search");
            searchMenu.SetVisible (true);
            searchMenu.SetShowAsAction (ShowAsAction.IfRoom);
            searchMenu.SetActionView(new SearchView(this));*/

            var addMenu = menu.Add (1, (int)MenuConstants.MainAdd, 1, "Add");
            addMenu.SetIcon (Resource.Drawable.Add);
            addMenu.SetShowAsAction (ShowAsAction.IfRoom);

            var refreshMenu = menu.Add (1, (int)MenuConstants.MainRefresh, 2, "Refresh");
            refreshMenu.SetIcon (Resource.Drawable.Refresh);
            refreshMenu.SetShowAsAction (ShowAsAction.IfRoom);

            /*var facebookMenu = menu.Add (2, (int)MenuConstants.MainFacebook, 3, "Authorize Facebook");
            facebookMenu.SetIcon (Resource.Drawable.Facebook);
            facebookMenu.SetShowAsAction (ShowAsAction.IfRoom);

            var twitterMenu = menu.Add (2, (int)MenuConstants.MainTwitter, 4, "Authorize Twitter");
            twitterMenu.SetIcon (Resource.Drawable.Twitter);
            twitterMenu.SetShowAsAction (ShowAsAction.IfRoom);*/

            return base.OnCreateOptionsMenu (menu);
        }
 public override bool OnCreateOptionsMenu(IMenu menu)
 {
     base.OnCreateOptionsMenu (menu);
     var inflater = MenuInflater;
     inflater.Inflate(Resource.Menu.main, menu); // main
     return true;
 }
Example #18
0
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            MenuInflater menuInflater = new Android.Views.MenuInflater(this);
            menuInflater.Inflate(Resource.Layout.MenuNewsDetails, menu);

            return true;
        }
        //@Override
        public override bool OnCreateOptionsMenu(IMenu menu)
        {

            MenuInflater.Inflate(R.Menu.menu, menu);
            return true;

        }
Example #20
0
 private void AddToolBar(IMenu toolbarModel)
 {
     var toolBar = new ToolBar();
     toolBar.SetResourceReference(ToolBar.StyleProperty, Resources.ToolBarStyleKey);
     toolBar.DataContext = toolbarModel;
     m_toolBarTray.ToolBars.Add(toolBar);
 }
		public override bool OnCreateOptionsMenu (IMenu menu)
		{
			MenuInflater inflater = this.MenuInflater;
			inflater.Inflate(Resource.Menu.codeproject_member_articles_actions, menu);

			return base.OnCreateOptionsMenu (menu);
		}
Example #22
0
		public bool OnCreateActionMode (ActionMode mode, IMenu menu)
		{
			self.MenuInflater.Inflate (Resource.Menu.list_select_menu, menu);
			mode.Title = "Select Items";
			SetSubtitle (mode);
			return true;
		}
Example #23
0
        // ===========================================================
        // Fields
        // ===========================================================

        // ===========================================================
        // Constructors
        // ===========================================================

        // ===========================================================
        // Getter & Setter
        // ===========================================================

        // ===========================================================
        // Methods for/from SuperClass/Interfaces
        // ===========================================================


        public bool OnCreateOptionsMenu(IMenu pMenu)
        {
            //pMenu.Add(MenuConsts.None, MENU_TRACE, MenuConsts.None, "Start Method Tracing");
            //pMenu.Add(MenuConsts.None, MENU_TRACE, MenuConsts.None, (Java.Lang.ICharSequence)"Start Method Tracing");
            pMenu.Add(MenuConsts.None, MENU_TRACE, MenuConsts.None, (Java.Lang.ICharSequence) new Android.Text.SpannableString("Start Method Tracing"));
            return base.OnCreateOptionsMenu(pMenu);
        }
 public override bool OnCreateOptionsMenu(IMenu menu)
 {
     base.OnCreateOptionsMenu (menu);
     MenuInflater inflater = this.MenuInflater;
     inflater.Inflate (Resource.Menu.check_submit, menu);
     return true;
 }
 public override bool OnCreateOptionsMenu(IMenu menu)
 {
     menu.Add("Item 1");
     menu.Add("Item 2");
     menu.Add("Item 3");
     return true;
 }
Example #26
0
 public void NotifyObservers(IMenu menu)
 {
     foreach (var observer in Observers)
     {
         observer.Notify(menu);
     }
 }
		public override bool OnPrepareOptionsMenu (IMenu menu)
		{
			IMenuItem logToggle = menu.FindItem (Resource.Id.menu_toggle_log);
			logToggle.SetVisible (FindViewById (Resource.Id.sample_output) is ViewAnimator);
			logToggle.SetTitle (log_shown ? Resource.String.sample_hide_log : Resource.String.sample_show_log);
			return base.OnPrepareOptionsMenu (menu);
		}
Example #28
0
		public override bool OnCreateOptionsMenu (IMenu menu)
		{
			// Inflate your menu.
			SupportMenuInflater.Inflate (Resource.Menu.share_action_provider, menu);

			// Set file with share history to the provider and set the share intent.
			var actionItem = menu.FindItem (Resource.Id.menu_item_share_action_provider_action_bar);
			var actionProvider = (ShareActionProvider)actionItem.ActionProvider;
			actionProvider.SetShareHistoryFileName (ShareActionProvider.DefaultShareHistoryFileName);
			// Note that you can set/change the intent any time,
			// say when the user has selected an image.
			actionProvider.SetShareIntent (CreateShareIntent ());

			//XXX: For now, ShareActionProviders must be displayed on the action bar
			// Set file with share history to the provider and set the share intent.
			//MenuItem overflowItem = menu.findItem(R.id.menu_item_share_action_provider_overflow);
			//ShareActionProvider overflowProvider =
			//    (ShareActionProvider) overflowItem.getActionProvider();
			//overflowProvider.setShareHistoryFileName(
			//    ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
			// Note that you can set/change the intent any time,
			// say when the user has selected an image.
			//overflowProvider.setShareIntent(createShareIntent());

			return true;
		}
 public void Apply(IMenu menu, Context context, object parent)
 {
     PlatformExtensions.ValidateTemplate(ItemsSource, Items);
     var setter = new XmlPropertySetter<IMenu>(menu, context, new BindingSet());
     menu.SetBindingMemberValue(AttachedMembers.Object.Parent, parent);
     setter.SetBinding(nameof(DataContext), DataContext, false);
     setter.SetBoolProperty(nameof(IsVisible), IsVisible);
     setter.SetBoolProperty(nameof(IsEnabled), IsEnabled);
     if (!string.IsNullOrEmpty(Bind))
         setter.BindingSet.BindFromExpression(menu, Bind);
     if (string.IsNullOrEmpty(ItemsSource))
     {
         if (Items != null)
         {
             for (int index = 0; index < Items.Count; index++)
                 Items[index].Apply(menu, context, index, index);
         }
     }
     else
     {
         menu.SetBindingMemberValue(AttachedMembers.Menu.ItemsSourceGenerator, new MenuItemsSourceGenerator(menu, context, ItemTemplate));
         setter.SetBinding(nameof(ItemsSource), ItemsSource, true);
     }
     setter.Apply();
 }
Example #30
0
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            base.OnCreateOptionsMenu(menu);

            menu.Add(0, EDIT_ID, 0, Resource.String.menu_edit)
                .SetShortcut('1', 'e')
                .SetIcon(Resource.Drawable.icon_delete);

            //menu.add(0, HOME_ID, 0, R.string.menu_start).setShortcut('4', 'h')
            //    .setIcon(R.drawable.icon_start);

            menu.Add(0, LIST_ID, 0, Resource.String.menu_recent)
                .SetShortcut('3', 'r')
                .SetIcon(Resource.Drawable.icon_recent);

            menu.Add(0, DELETE_ID, 0, Resource.String.menu_delete)
                .SetShortcut('2', 'd')
                .SetIcon(Resource.Drawable.icon_delete);
            //menu.add(0, ABOUT_ID, 0, R.string.menu_about).setShortcut('5', 'a')
            //    .setIcon(android.R.drawable.ic_dialog_info);
            //menu.add(0, EXPORT_ID, 0, R.string.menu_export).setShortcut('7', 'x')
            //    .setIcon(android.R.drawable.ic_dialog_info);
            //menu.add(0, IMPORT_ID, 0, R.string.menu_import).setShortcut('8', 'm')
            //    .setIcon(android.R.drawable.ic_dialog_info);
            //menu.add(0, EMAIL_ID, 0, R.string.menu_email).setShortcut('6', 'm')
            //    .setIcon(android.R.drawable.ic_dialog_info);
            return true;
        }