Exemplo n.º 1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            //MyApplicationBarMenuItem s = (MyApplicationBarMenuItem)sender;

            //PanoramaItem[] tempSug = new PanoramaItem[_basePanorama.Items.Count];
            //int selectedItemIndex = -1;
            //for (int i = 0; i < _basePanorama.Items.Count; ++i)
            //{
            //    var item = _basePanorama.Items[i] as PanoramaItem;
            //    if (item != null)
            //    {
            //        tempSug[i] = item;
            //        if (item == s.MyPanoramaItem)
            //        {
            //            selectedItemIndex = i;
            //        }
            //    }
            //}

            bool isSame = true;
            int nextItem = 0;
            var newList = App.Config.Lists.Where(l => l.IsVisible).OrderBy(l => l.SortPriority).ToList();
            PanoramaItem[] tempSug = new PanoramaItem[newList.Count];
            //foreach (var list in App.Config.Lists.Where(l => l.IsVisible).OrderBy(l => l.SortPriority))
            foreach (var list in newList)
            {
                bool foundControl = false;
                for (int i = 0; i < _basePanorama.Items.Count; ++i)
                {
                    var item = _basePanorama.Items[i] as PanoramaItem;                    
                    var controlItem = item.Content as MakeSuggestionCtl;
                    if ((controlItem != null) && (controlItem.Id == list.Id))
                    {
                        if (nextItem != i)
                        {
                            isSame = false;
                        }
                        tempSug[nextItem++] = item;
                        foundControl = true;
                        break;
                    }
                }
                if (!foundControl)
                {
                    var sug = new MakeSuggestionCtl
                    {
                        Id = list.Id,
                        FileName = list.ListFileName,
                        PluralName = list.PluralName,
                        SingularName = list.SingularName,
                        HistoryCount = list.HistoryCount
                    };
                    var panItem = new PanoramaItem
                    {
                        FontSize = 42
                    };
                    sug.DoSelect();
                    panItem.Content = sug;
                    tempSug[nextItem++] = panItem;
                    //foundControl = true;
                }
            }

            if (!isSame)
            {
                _basePanorama.Items.Clear();
                foreach (var item in tempSug)
                {
                    _basePanorama.Items.Add(item);
                }
            }
            //if (selectedItemIndex != -1)
            //{
            //    _basePanorama.DefaultItem = _basePanorama.Items[selectedItemIndex];
            //}
        }
Exemplo n.º 2
0
        private static MakeSuggestionCtl addMakeSuggestionCtlToPanorama(Panorama para, IApplicationBar applicationBar, int id, string header, string fileName, string pluralName, string singularName, int historyCount, EventHandler newItemClick)
        {            
            var item = new PanoramaItem
            {
                FontSize = 42
            };
            var sug = new MakeSuggestionCtl
            {
                Id = id,
                FileName = fileName,
                PluralName = pluralName,
                SingularName = singularName,
                HistoryCount = historyCount                
            };
            sug.DoSelect();
            item.Content = sug;
            para.Items.Add(item);

            var newItem = new MyApplicationBarMenuItem
            {
                Text = pluralName,
                MyMakeSuggestionCtl = sug,
                MyPanoramaItem = item
            };
            newItem.Click += newItemClick;
            applicationBar.MenuItems.Add(newItem);

            return sug;
        }