private Place Internal_GetBuildingFromRoom(Room room)
        {
            Place building = null;

            for (int i = 0; i < pointsOfInterestGroup.Count; i++)
            {
                PointOfInterestGroup pointOfInterest = pointsOfInterestGroup[i];

                for (int j = 0; j < pointOfInterest.placeCollectionCount; j++)
                {
                    PlaceCollection placeCollection = pointOfInterest.GetPlaceCollection(j);

                    if (placeCollection == null)
                    {
                        continue;
                    }

                    if (placeCollection.HasRoom(room))
                    {
                        building = placeCollection.GetPlace();
                        break;
                    }
                }
            }

            return(building);
        }
        private Place[] Internal_GetAllBuildings()
        {
            List <Place> buildings = new List <Place>();

            for (int i = 0; i < pointsOfInterestGroup.Count; i++)
            {
                PointOfInterestGroup pointOfInterest = pointsOfInterestGroup[i];

                for (int j = 0; j < pointOfInterest.placeCollectionCount; j++)
                {
                    PlaceCollection placeCollection = pointOfInterest.GetPlaceCollection(j);

                    if (placeCollection == null)
                    {
                        continue;
                    }

                    Place place = placeCollection.GetPlace();

                    if (place != null)
                    {
                        buildings.Add(place);
                    }
                }
            }

            return(buildings.ToArray());
        }
Exemplo n.º 3
0
        public ReportStudent(JHStudentRecord student)
        {
            Scores        = new TokenScoreCollection();
            Places        = new PlaceCollection();
            Id            = student.ID;
            Name          = student.Name;
            RefClassID    = student.RefClassID;
            SeatNo        = student.SeatNo + "";
            StudentNumber = student.StudentNumber;

            string RuleID = "";

            // 先使用學生
            if (student.OverrideScoreCalcRuleID != null)
            {
                RuleID = student.OverrideScoreCalcRuleID;
            }
            else
            {
                if (Utility.tmpClassRuleIDDict.ContainsKey(RefClassID))
                {
                    RuleID = Utility.tmpClassRuleIDDict[RefClassID];
                }
            }

            // 成績計算規則進位方式
            if (RuleID != "")
            {
                if (Utility.tmpScoreCalculatorDict.ContainsKey(RuleID))
                {
                    StudScoreCalculator = Utility.tmpScoreCalculatorDict[RuleID];
                }
            }
        }
        private bool Internal_PlaceHasTrivia(Place place)
        {
            bool evaluation = false;

            for (int i = 0; i < pointsOfInterestGroup.Count; i++)
            {
                PointOfInterestGroup pointOfInterest = pointsOfInterestGroup[i];

                for (int j = 0; j < pointOfInterest.placeCollectionCount; j++)
                {
                    PlaceCollection placeCollection = pointOfInterest.GetPlaceCollection(j);

                    if (placeCollection == null)
                    {
                        continue;
                    }

                    if (placeCollection.GetPlace() == place)
                    {
                        evaluation = place.trivia != null;
                        break;
                    }
                }
            }

            return(evaluation);
        }
            /// <summary>
            /// Reads the JSON representation of the object.
            /// </summary>
            /// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader"/> to read from.</param>
            /// <param name="objectType">Type of the object.</param>
            /// <param name="existingValue">The existing value of object being read.</param>
            /// <param name="serializer">The calling serializer.</param>
            /// <returns>The object value.</returns>
            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                PlaceCollection result = new PlaceCollection();

                reader.Read();
                reader.Read();

                bool hasReachedTheQuery = false;

                while (reader.Read())
                {
                    if (reader.TokenType == JsonToken.PropertyName && (string)reader.Value == "query")
                    {
                        hasReachedTheQuery = true;
                    }

                    if (hasReachedTheQuery)
                    {
                        continue;
                    }

                    if (reader.TokenType == JsonToken.StartObject)
                    {
                        result.Add(serializer.Deserialize <Place>(reader));
                    }
                }

                return(result);
            }
Exemplo n.º 6
0
 public RatingStudent(JHStudentRecord student)
 {
     Scores        = new TokenScoreCollection();
     Places        = new PlaceCollection();
     Id            = student.ID;
     Name          = student.Name;
     RefClassID    = student.RefClassID;
     SeatNo        = student.SeatNo + "";
     StudentNumber = student.StudentNumber;
 }
Exemplo n.º 7
0
        public void PlacesPlacesForUserContinentHasRegionsTest()
        {
            Flickr f = AuthInstance;

            // Test place ID of '6dCBhRRTVrJiB5xOrg' is Europe
            PlaceCollection p = f.PlacesPlacesForUser(PlaceType.Region, null, "6dCBhRRTVrJiB5xOrg");

            foreach (Place place in p)
            {
                Assert.IsNotNull(place.PlaceId, "PlaceId should not be null.");
                Assert.IsNotNull(place.WoeId, "WoeId should not be null.");
                Assert.IsNotNull(place.Description, "Description should not be null.");
                Assert.IsNotNull(place.PlaceUrl, "PlaceUrl should not be null");
                Assert.AreEqual(PlaceType.Region, place.PlaceType, "PlaceType should be Region.");
            }
        }
        private Location Internal_GetLocationFromSearch(int index, out PointOfInterest pointOfInterest)
        {
            pointOfInterest = null;

            if (index < 0 || searchKeys == null || searchKeys.Count == 0 || index >= searchKeys.Count)
            {
                return(null);
            }

            SearchKey searchItem = searchKeys[index];

            if (pointsOfInterestGroup == null || pointsOfInterestGroup.Count == 0 || searchItem.poiIndex >= pointsOfInterestGroup.Count || searchItem.poiIndex < 0)
            {
                return(null);
            }

            PointOfInterestGroup pointOfInterestGroup = pointsOfInterestGroup[searchItem.poiIndex];

            if (pointOfInterestGroup == null)
            {
                return(null);
            }

            pointOfInterest = pointOfInterestGroup.pointOfInterest;

            PlaceCollection placeCollection = pointOfInterestGroup.GetPlaceCollection(searchItem.placeIndex);
            Location        location        = null;

            if (placeCollection == null)
            {
                return(null);
            }

            int locationIndex = searchItem.locationIndex - 1;

            if (locationIndex == -1)
            {
                location = placeCollection.GetPlaceLocation();
            }
            else
            {
                location = placeCollection.GetRoomLocation(locationIndex);
            }

            return(location);
        }
Exemplo n.º 9
0
        public void PlacesPlacesForUserHasContinentsTest()
        {
            Flickr          f      = AuthInstance;
            PlaceCollection places = f.PlacesPlacesForUser();

            foreach (Place place in places)
            {
                Assert.IsNotNull(place.PlaceId, "PlaceId should not be null.");
                Assert.IsNotNull(place.WoeId, "WoeId should not be null.");
                Assert.IsNotNull(place.Description, "Description should not be null.");
                Assert.AreEqual(PlaceType.Continent, place.PlaceType, "PlaceType should be continent.");
            }

            Assert.AreEqual("6dCBhRRTVrJiB5xOrg", places[0].PlaceId);
            Assert.AreEqual("Europe", places[0].Description);
            Assert.AreEqual("l5geY0lTVrLoNkLgeQ", places[1].PlaceId);
            Assert.AreEqual("North America", places[1].Description);
        }
Exemplo n.º 10
0
        public MainViewModel(IConfiguration configuraiton)
        {
            _drawingContext = new MapDrawingContext();
            _drawingContext.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == nameof(MapDrawingContext.ActiveGeometry))
                {
                    RaisePropertyChanged(nameof(ActiveGeometry));
                }
            };
            _drawingContext.GeometryDrawn += (sender, e) =>
            {
                if (ActiveCollection == null)
                {
                    Collections.Add(ActiveCollection = new PlaceCollection {
                        Name = "New Collection"
                    });
                }

                ActiveCollection.Geometries.Add(e.Geometry);
            };

            BingMapsKey = configuraiton["BingMapsKey"];

            BrowseCommand        = new RelayCommand(() => _drawingContext.Browse());
            AddPushpinCommand    = new RelayCommand(() => _drawingContext.AddPoint());
            AddPolylineCommand   = new RelayCommand(() => _drawingContext.AddLineString());
            AddPolygonCommand    = new RelayCommand(() => _drawingContext.AddPolygon());
            AddCollectionCommand = new RelayCommand(() => Collections.Add(new PlaceCollection {
                Name = "New Collection"
            }));
            ViewChangeEndCommand = new RelayCommand <IPolygon>(ViewChangeEnd);
            MouseMoveCommand     = new RelayCommand <(Coordinate position, Handleable handleable)>(
                x => MouseMove(x.position));
            MouseDoubleClickCommand = new RelayCommand <(Coordinate position, Handleable handleable)>(
                x => MouseDoubleClick(x.position, x.handleable));
            MouseClickCommand = new RelayCommand <Coordinate>(MouseClick);
        }
Exemplo n.º 11
0
        private string GetPlaceString(PlaceCollection places, string placeKey)
        {
            Place   place      = places[placeKey];
            decimal percentage = (100m * ((decimal)place.Level / (decimal)place.Radix));

            string result = string.Empty;

            if (PrintSetting.PrintRank)
            {
                result = place.Level.ToString();
            }

            if (PrintSetting.PrintRankPercentage)
            {
                result = Math.Round(percentage, 0, MidpointRounding.AwayFromZero) + "%";
            }

            if (PrintSetting.PrintRank && PrintSetting.PrintRankPercentage)
            {
                result = string.Format("{0}/{1}%", place.Level, Math.Round(percentage, 0, MidpointRounding.AwayFromZero));
            }

            return(result);
        }
Exemplo n.º 12
0
 /// <summary>
 /// 取得排名百分比
 /// </summary>
 /// <param name="places"></param>
 /// <param name="placeKey"></param>
 /// <returns></returns>
 private int? GetRankPercent(PlaceCollection places, string placeKey)
 {
     if (places.Contains(placeKey))
         return places[placeKey].Percentage;
     else
         return null;
 }
Exemplo n.º 13
0
 /// <summary>
 /// 取得成績
 /// </summary>
 /// <param name="places"></param>
 /// <param name="placeKey"></param>
 /// <returns></returns>
 private decimal? GetScore(PlaceCollection places, string placeKey)
 {
     if (places.Contains(placeKey))
         return places[placeKey].Score;
     else
         return null;
 }
Exemplo n.º 14
0
 protected WorldBase()
 {
     Places = new PlaceCollection();
     Terrain = new TerrainCollection(this);
 }
Exemplo n.º 15
0
        public void Open(string guid, string kladr)
        {
            connection.ConnectionString = ConnectionString;
            connection.Open();
            CustomReloadCollection(RegionCollection, FiasSql.RegionSql, null);

            var searchResult = new Dictionary <string, string>();

            using (var transaction = connection.BeginTransaction())
            {
                using (var query = new DbQuery(connection, transaction))
                {
                    query.SqlText = "select ID_REGION, ID_AUTO, ID_AREA, ID_CITY, ID_CTAR, ID_PLACE, ID_STREET, ID_HOUSE from PR_FIAS_EXTRACT(@ID_GUID, @ID_KLADR)";
                    query.Parameters.Add(query.GetNewParameter("ID_GUID", guid == string.Empty ? null : guid));
                    query.Parameters.Add(query.GetNewParameter("ID_KLADR", kladr == string.Empty ? null : kladr));
                    query.ExecuteDataReader();
                    if (query.DataReader.Read())
                    {
                        for (var i = 0; i < query.DataReader.FieldCount; i++)
                        {
                            searchResult.Add(query.DataReader.GetName(i), query.DataReader[i].ToString());
                        }
                    }
                }
            }
            if (searchResult.Count == 0)
            {
                return;
            }
            if (searchResult["ID_REGION"] != string.Empty)
            {
                SelectedRegion = RegionCollection.FirstOrDefault(a => a.Id == searchResult["ID_REGION"]);
            }
            if (searchResult["ID_AUTO"] != string.Empty)
            {
                SelectedAuto = AutoCollection.FirstOrDefault(a => a.Id == searchResult["ID_AUTO"]);
            }
            if (searchResult["ID_AREA"] != string.Empty)
            {
                SelectedArea = AreaCollection.FirstOrDefault(a => a.Id == searchResult["ID_AREA"]);
            }
            if (searchResult["ID_CITY"] != string.Empty)
            {
                SelectedCity = CityCollection.FirstOrDefault(a => a.Id == searchResult["ID_CITY"]);
            }
            if (searchResult["ID_CTAR"] != string.Empty)
            {
                SelectedCtar = CtarCollection.FirstOrDefault(a => a.Id == searchResult["ID_CTAR"]);
            }
            if (searchResult["ID_PLACE"] != string.Empty)
            {
                SelectedPlace = PlaceCollection.FirstOrDefault(a => a.Id == searchResult["ID_PLACE"]);
            }
            if (searchResult["ID_STREET"] != string.Empty)
            {
                SelectedStreet = StreetCollection.FirstOrDefault(a => a.Id == searchResult["ID_STREET"]);
            }
            if (searchResult["ID_HOUSE"] != string.Empty)
            {
                SelectedHouse = HouseCollection.FirstOrDefault(a => a.Id == searchResult["ID_HOUSE"]);
            }
        }
Exemplo n.º 16
0
        private string GetPlaceString(PlaceCollection places, string placeKey)
        {
            Place place = places[placeKey];
            //decimal percentage = (100m * ((decimal)place.Level / (decimal)place.Radix));

            ////小於1%的話,就是1%。
            //if (percentage < 1) percentage = 1;

            string result = string.Empty;
            result = place.Percentage.ToString();

            //result = string.Format("{0}/{1}%", place.Level, place.Percentage);
            return result;
        }
        private string GetPlaceString(PlaceCollection places, string placeKey)
        {
            Place place = places[placeKey];
            decimal percentage = (100m * ((decimal)place.Level / (decimal)place.Radix));

            string result = string.Empty;

            if (PrintSetting.PrintRank)
                result = place.Level.ToString();

            if (PrintSetting.PrintRankPercentage)
                result = Math.Round(percentage, 0, MidpointRounding.AwayFromZero) + "%";

            if (PrintSetting.PrintRank && PrintSetting.PrintRankPercentage)
                result = string.Format("{0}/{1}%", place.Level, Math.Round(percentage, 0, MidpointRounding.AwayFromZero));

            return result;
        }