示例#1
0
        public void RemoveMenuItem(AppbarMenuItem menu)
        {
            if (_menus == null)
            {
                return;
            }

            for (int i = 0; i < _menus.Length; i++)
            {
                if (_menus[i] == menu)
                {
                    RemoveMenuItemAt(i);
                    return;
                }
            }
        }
示例#2
0
        public void AddMenuItem(AppbarMenuItem menu)
        {
            if (_menus == null)
            {
                _menus = new[] { menu };
            }
            else
            {
                var tmp = new AppbarMenuItem[_menus.Length + 1];
                Array.Copy(_menus, tmp, _menus.Length);
                tmp[tmp.Length - 1] = menu;
                _menus = tmp;
            }

            if (_expanded)
            {
                Invalidate();
            }
        }
示例#3
0
        public void RemoveMenuItemAt(int index)
        {
            if (_menus == null || index < 0 || index >= _menus.Length)
            {
                return;
            }

            if (_menus.Length == 1)
            {
                ClearMenuItems();
                return;
            }

            if (_expanded)
            {
                Suspended = true;
            }

            var tmp = new AppbarMenuItem[_menus.Length - 1];
            int c   = 0;

            for (int i = 0; i < _menus.Length; i++)
            {
                if (i != index)
                {
                    tmp[c++] = _menus[i];
                }
            }

            _menus = tmp;

            if (_expanded)
            {
                Suspended = false;
            }
        }