예제 #1
0
        public DestinationPickPage(string navigationGraphName, CategoryType category)
        {
            InitializeComponent();

            const string resourceId = "IndoorNavigation.Resources.AppResources";

            _resourceManager = new ResourceManager(resourceId, typeof(TranslateExtension).GetTypeInfo().Assembly);

            _destinationItems = new ObservableCollection <DestinationItem>();

            _navigationGraphName = navigationGraphName;

            _navigationGraph = NavigraphStorage.LoadNavigationGraphXML(navigationGraphName);
            if (CrossMultilingual.Current.CurrentCultureInfo.ToString() == "en" || CrossMultilingual.Current.CurrentCultureInfo.ToString() == "en-US")
            {
                _nameInformation = NavigraphStorage.LoadInformationML(navigationGraphName + "_info_en-US.xml");
            }
            else if (CrossMultilingual.Current.CurrentCultureInfo.ToString() == "zh" || CrossMultilingual.Current.CurrentCultureInfo.ToString() == "zh-TW")
            {
                _nameInformation = NavigraphStorage.LoadInformationML(navigationGraphName + "_info_zh.xml");
            }

            NavigationPage.SetBackButtonTitle(this, _resourceManager.GetString("BACK_STRING", CrossMultilingual.Current.CurrentCultureInfo));

            foreach (KeyValuePair <Guid, IndoorNavigation.Models.Region> pairRegion in _navigationGraph.GetRegions())
            {
                string floorName = _nameInformation.GiveRegionName(pairRegion.Value._id);
                if (pairRegion.Value._waypointsByCategory.ContainsKey(category))
                {
                    foreach (Waypoint waypoint in pairRegion.Value._waypointsByCategory[category])
                    {
                        string waypointName = waypoint._name;
                        waypointName = _nameInformation.GiveWaypointName(waypoint._id);
                        if (waypoint._type.ToString() == "terminal" || waypoint._type.ToString() == "landmark")
                        {
                            Console.WriteLine("check type : " + waypoint._type.ToString());
                            _destinationItems.Add(new DestinationItem
                            {
                                _regionID     = pairRegion.Key,
                                _waypointID   = waypoint._id,
                                _waypointName = waypointName,
                                _floor        = floorName
                            });
                        }
                        else
                        {
                            Console.WriteLine("Portal, No need to add!!");
                        }
                    }
                }
            }

            MyListView.ItemsSource = from waypoint in _destinationItems
                                     group waypoint by waypoint._floor into waypointGroup
                                     orderby waypointGroup.Key
                                     select new Grouping <string, DestinationItem>(waypointGroup.Key,
                                                                                   waypointGroup);
        }