/// <summary>
        /// 获取数据
        /// </summary>
        public bool GetDataList()
        {
            string functionName = "GetDataList";

            try
            {
                List <AMS.Model.AMS_Province> modellist = new List <Model.AMS_Province>();
                //TODO:获取数据
                modellist = AMS.ServiceProxy.IProvinceService.GetProvinceList();
                ProvinceList.Clear();
                foreach (AMS.Model.AMS_Province model in modellist)
                {
                    ProvinceList.Add(model);
                }
                return(true);
            }
            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
                return(false);
            }
            #endregion
        }
Пример #2
0
        /// <summary>
        /// 初始化编辑时地址下拉框
        /// </summary>
        /// <param name="user"></param>
        public void InitialEditAddress(DataOfUserDetial user)
        {
            CountryList.Clear();
            ProvinceList.Clear();
            CityList.Clear();
            AreaList.Clear();
            var countryList = new Areas()
            {
                parent_id = 0, type = 1
            }.GetChildrenList();
            var provinceList = new Areas()
            {
                parent_id = 1 /*user.countryId*/, type = 2
            }.GetChildrenList();
            var cityList = new Areas()
            {
                parent_id = user.provinceId, type = 3
            }.GetChildrenList();
            var areaList = new Areas()
            {
                parent_id = user.cityId, type = 4
            }.GetChildrenList();

            CountryList.AddRange(countryList.ToObservableCollection());
            ProvinceList.AddRange(provinceList.ToObservableCollection());
            CityList.AddRange(cityList.ToObservableCollection());
            AreaList.AddRange(areaList.ToObservableCollection());

            CountryIndex  = 1; //user.countryId;
            ProvinceIndex = user.provinceId;
            CityIndex     = user.cityId;
            AreaIndex     = user.areaId;
        }
Пример #3
0
        public static void ImportProvince( string source, string target, ExportMode mode )
        {
            Console.WriteLine( "Opening source file \"{0}\"...", Path.GetFileName( source ) );
            ProvinceList provinces = new ProvinceList();
            FileStream stream = null;
            try {
                stream = new FileStream( source, FileMode.Open, FileAccess.Read, FileShare.Read );
                if ( mode == ExportMode.XML ) {
                    System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                    doc.Load( stream );
                    provinces.ReadFrom( doc );
                }
                else {
                    provinces.ReadFrom( new EU2.IO.CSVReader( stream ) );
                }
            }
            finally {
                if ( stream != null ) stream.Close();
            }

            Console.WriteLine( "Opening target file \"{0}\"...", Path.GetFileName( target ) );
            EU2.Edit.File file = new EU2.Edit.File();
            try {
                file.ReadFrom( target );
            }
            catch ( EU2.Edit.InvalidFileFormatException ) {
                Console.WriteLine( "The specified target file is not an EU2Map file, or is corrupt." );
                return;
            }

            file.Provinces = provinces;

            file.WriteTo( target );
            Console.WriteLine( "Import successful." );
        }
        private void populateComboBoxProvince(ComboBox comboBox)
        {
            try
            {
                // Clear ComboBox first so that this method can be called again later if
                // necessary.
                comboBox.Items.Clear();

                ProvinceList provinces = ProvinceRepository.GetProvinces();

                foreach (Province province in provinces)
                {
                    string provinceAbbreviation = province.Abbreviation;
                    comboBox.Items.Add(provinceAbbreviation);
                }
            }

            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message, "DB Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Processing Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #5
0
 public DefaultCompressor( int rx, int ry, int zoom, ProvinceList provinces, AdjacencyTable adjacent, IDMap idmap )
 {
     this.rx = rx;
     this.ry = ry;
     this.zoom = zoom;
     this.provinces = provinces;
     this.adjacent = adjacent;
     this.idmap = idmap;
 }
Пример #6
0
        private Lightmap( int zoom, ProvinceList provinces, AdjacencyTable adjacent, IDMap idmap )
        {
            if ( zoom < 0 ) throw new InvalidZoomFactorException( zoom );
            this.zoom = zoom;
            this.provinces = provinces;
            this.adjacent = adjacent;
            this.idmap = idmap;
            this.volatiledecompression = false;

            Size sz = CoordMap.ActualToZoomedBlocks( BaseSize );
            blocks = new GenericMapBlock[sz.Width*sz.Height];
        }
Пример #7
0
        public async Task GetProvinceAsync()
        {
            this.ProvinceList.Clear();
            ApiResponse apiResponse = await ApiHelper.Get <List <Province> >("api/provinces", false, false);

            List <Province> data = (List <Province>)apiResponse.Content;

            foreach (var item in data)
            {
                ProvinceList.Add(item);
            }
        }
Пример #8
0
        public static ProvinceList GetProvinces()
        {
            ProvinceList provinces = new ProvinceList();


            using (SqlConnection conn = new SqlConnection(connString))
            {
                string query = $@"SELECT ProvinceId, Sort, Abbreviation, Name
                                    FROM {provinceTableName}
                                    ORDER BY Sort";

                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = query;
                    cmd.Connection  = conn;

                    conn.Open();

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        int    provinceId;
                        int    sort;
                        string abbreviation;
                        string name = null;

                        while (reader.Read())
                        {
                            provinceId   = (int)reader["ProvinceId"];
                            sort         = (int)reader["Sort"];
                            abbreviation = reader["Abbreviation"] as string;

                            if (!reader.IsDBNull(reader.GetOrdinal("Name")))
                            {
                                name = reader["Name"] as string;
                            }

                            provinces.Add(new Province
                            {
                                ProvinceId   = provinceId,
                                Sort         = sort,
                                Abbreviation = abbreviation,
                                Name         = name
                            });

                            name = null;
                        }
                    }
                }
            }

            return(provinces);
        }
Пример #9
0
        /// <summary>
        /// Initialize the province list.
        /// </summary>
        private static void InitializeProvince()
        {
            lock (DataModel.SyncRoot)
            {
                CountryRow countryRow = DataModel.Country.CountryKeyExternalId0.Find("US");

                Application.Current.Dispatcher.BeginInvoke(new WaitCallback(delegate(object data)
                {
                    StateComboBox.stateList = new ProvinceList((Guid)data);
                }), countryRow.CountryId);
            }
        }
Пример #10
0
        public TerrainShader( ColorScales scales, ProvinceList provinces, IDMap idmap )
        {
            this.shades = scales.Shades;
            this.provinces = provinces;

            // Build the range check array
            rangecheck = new byte[512];
            for( int r=0; r<512; r++ ) {
                if ( r >= 256 ) rangecheck[r] = 127;
                else if ( r >= 132 ) rangecheck[r] = (byte)(r-128);
                else rangecheck[r] = 4;
            }
        }
Пример #11
0
        public ColoredShader( ColorScales scales, ProvinceList provinces, bool drawborders )
        {
            this.shades = scales.Shades;
            this.provinces = provinces;
            this.drawborders = drawborders;

            this.rangecheck = new byte[512];
            for( int r=0; r<512; r++ ) {
                if ( r >= 256 ) rangecheck[r] = 127;
                else if ( r >= 132 ) rangecheck[r] = (byte)(r-128);
                else rangecheck[r] = 4;
            }
        }
        public EditProfilePageViewModel(INavigationService navigationService)
        {
            NavigationService = navigationService;

            IsPermissionSettingOpen = false;
            MessagingCenter.Subscribe <string, Position>(this, "LocationAddress", (sender, pickedposition) =>
            {
                Street = AddressfromGPS = sender.ToString();
                AddressPositionfromGPS = pickedposition;
            });

            IsLoaderBusy    = false;
            IsLocationFetch = false;
            GetMaritalStatusList();
            if (BaseViewModel.countryDataModels != null && BaseViewModel.countryDataModels.Count > 0 && BaseViewModel.provienceDataModels != null && BaseViewModel.provienceDataModels.Count > 0)
            {
                if (Application.Current.Properties.ContainsKey("AppLocale") && !string.IsNullOrEmpty(Application.Current.Properties["AppLocale"].ToString()))
                {
                    var languageculture = Application.Current.Properties["AppLocale"].ToString();
                    Country = languageculture.Equals("en-US") ? BaseViewModel.countryDataModels.FirstOrDefault().country_name : BaseViewModel.countryDataModels.FirstOrDefault().arabic_country_name;
                }
                else
                {
                    Country = BaseViewModel.countryDataModels.FirstOrDefault().country_name;
                }

                foreach (var item in BaseViewModel.provienceDataModels)
                {
                    if (Application.Current.Properties.ContainsKey("AppLocale") && !string.IsNullOrEmpty(Application.Current.Properties["AppLocale"].ToString()))
                    {
                        var languageculture = Application.Current.Properties["AppLocale"].ToString();
                        item.display_province_name = languageculture.Equals("en-US") ? item.province_name : item.arabic_province_name;
                    }
                    else
                    {
                        item.display_province_name = item.province_name;
                    }
                    ProvinceList.Add(item);
                }


                //ProviencePickerSelectedindex = ProvinceList.IndexOf(ProvinceList.Where(x => x.province_name.ToLower().Contains("sana") || x.arabic_province_name.Contains("sana")).ToList().FirstOrDefault());
            }

            MessagingCenter.Subscribe <ImagesModel>(this, "ProfilePicture", (sender) =>
            {
                GallData = sender;
                UserPic  = GallData.Image;
            });
        }
Пример #13
0
        public BlockVisualiser( ColorScales scales, ProvinceList provinces )
        {
            this.shades = scales.Shades;
            this.provinces = provinces;

            this.rangecheck = new byte[512];
            for( int r=0; r<512; r++ ) {
                if ( r >= 256 ) rangecheck[r] = 127;
                else if ( r >= 132 ) rangecheck[r] = (byte)(r-128);
                else rangecheck[r] = 4;
            }

            imagestack = new Stack();
        }
Пример #14
0
        /// <summary>
        /// 初始化地址
        /// </summary>
        /// <param name="user">对应的用户</param>
        public void InitialViewAddress(DataOfUserDetial user)
        {
            MyDetialPage = 0;
            CountryList.Clear();
            ProvinceList.Clear();
            CityList.Clear();
            AreaList.Clear();
            var countryList = new Areas()
            {
                parent_id = 0, type = 1
            }.GetChildrenList();

            CountryList.AddRange(countryList.ToObservableCollection());
            var currentCoun = countryList.FirstOrDefault(c => c.id == user.countryId);

            DCountry = (currentCoun == null) ? "" : currentCoun.name;//设置国家名称

            var provinceList = new Areas()
            {
                parent_id = user.countryId == 0 ? (1) : (user.countryId), type = 2
            }.GetChildrenList();                                                                                                    //如果未选择国家则默认为中国

            ProvinceList.AddRange(provinceList.ToObservableCollection());
            var currentProvin = provinceList.FirstOrDefault(c => c.id == user.provinceId);

            DProvince = (currentProvin == null) ? "" : currentProvin.name;//设置省份名称

            var cityList = new Areas()
            {
                parent_id = user.provinceId, type = 3
            }.GetChildrenList();

            CityList.AddRange(cityList.ToObservableCollection());
            var cuttentCity = cityList.FirstOrDefault(c => c.id == user.cityId);

            DCity = cuttentCity == null ? "" : cuttentCity.name;//设置城市名称

            var areaList = new Areas()
            {
                parent_id = user.cityId, type = 4
            }.GetChildrenList();

            AreaList.AddRange(areaList.ToObservableCollection());
            var currentArea = areaList.FirstOrDefault(c => c.id == user.areaId);

            DArea = currentArea == null ? "" : currentArea.name;//设置区域名称
        }
Пример #15
0
        public List <SelectListItemSurrogate> GetProvinces()
        {
            var result = ProvinceList.Select(province => new SelectListItemSurrogate
            {
                Text  = province.strRegionName,
                Value = (province.idfsRegion > 0)
                    ? province.idfsRegion.ToString()
                    : null,
                Selected = (province.idfsRegion == ProvinceId)
            }).ToList();

            if (!IsRequired)
            {
                FilterHelper.InsertEmptyItem(result);
            }
            return(result);
        }
Пример #16
0
 public void InitProvinceDistrict()
 {
     using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
     {
         ProvinceList   = RegionLookup.Accessor.Instance(null).SelectList(manager, EidssSiteContext.Instance.CountryID, null);
         m_DistrictList = ThaiDistrictLookup.Accessor.Instance(null).SelectList(manager, null, null, null);
         Province       = ProvinceList.Find(p => p.idfsRegion == EidssSiteContext.Instance.RegionID);
         var organization = Organization.Accessor.Instance(null)
                            .SelectDetail(manager, EidssSiteContext.Instance.OrganizationID) as Organization;
         long?defRayon = null;
         if (organization != null && organization.Address != null && organization.Address.Rayon != null)
         {
             defRayon = organization.Address.Rayon.idfsRayon;
         }
         District = DistrictList.Find(
             d =>
             (d.idfsDistrict == defRayon && d.idfsParentDistrict == null) ||
             (d.idfsParentDistrict != null && d.idfsParentDistrict == defRayon));
     }
 }
Пример #17
0
 /// <summary>
 /// 初始化行政区划
 /// </summary>
 private void InitPCAS()
 {
     try
     {
         var assembly = IntrospectionExtensions.GetTypeInfo(typeof(EditAddressViewModel)).Assembly;
         using (var reader = new StreamReader(assembly.GetManifestResourceStream("XMart.Util.pcas.json")))
         {
             var     jsonData      = reader.ReadToEnd();
             JObject questionsList = (JObject)JsonConvert.DeserializeObject(jsonData);
             AllPlaces = questionsList;
             foreach (var item in AllPlaces)
             {
                 ProvinceList.Add(item.Key);
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #18
0
 public ushort FindClosestLand( int x, int y, ushort skipid, ProvinceList provinces )
 {
     return FindClosestLand( x, y, skipid, Lightmap.BlockSize, provinces, null );
 }
Пример #19
0
 public ushort FindClosestLand( int x, int y, ProvinceList provinces, int range )
 {
     return FindClosestLand( x, y, this[x,y], range, provinces, null );
 }
Пример #20
0
 public ushort FindClosestLand( int x, int y, ProvinceList provinces )
 {
     return FindClosestLand( x, y, this[x,y], Lightmap.BlockSize, provinces, null );
 }
Пример #21
0
 public ushort[] BuildAdjacencyTable( AdjacencyTable mergeWith, Rectangle region, ProvinceList provinces )
 {
     return mergeWith.Merge( BuildAdjacencyTable( region, provinces ) );
 }
Пример #22
0
 public static Lightmap FromFile( int zoom, ProvinceList provinces, AdjacencyTable adjacent, IDMap idmap, string path )
 {
     FileStream stream = null;
     try {
         stream = new FileStream( path, FileMode.Open, FileAccess.Read, FileShare.Read );
         return new Lightmap( zoom, provinces, adjacent, idmap, new BinaryReader( stream ) );
     }
     finally {
         if ( stream != null ) stream.Close();
     }
 }
Пример #23
0
        public void FindNearest( int x, int y, int perimeter, ProvinceList provinces, out ushort id, out double distance )
        {
            ushort[] ids;
            double[] distances;

            FindNearest( x, y, perimeter, 1, provinces, out ids, out distances );

            id = ids[0];
            distance = distances[0];
        }
Пример #24
0
        public void FindNearest( int x, int y, int perimeter, int count, ProvinceList provinces, out ushort[] ids, out double[] distances )
        {
            int halfperimeter = (perimeter/2);
            // Get all ids around this point (in the specfied perimeter)
            ushort[] idlist = GetIDs( x-halfperimeter, y-halfperimeter, perimeter, perimeter, GetIDOptions.SkipTI | GetIDOptions.SkipRivers, provinces );
            ushort[,] area = GetPerimeterMap( x, y, perimeter );

            // Calculate distances for the found ids
            double[] distlist = new double[idlist.Length];
            for ( int i=0; i<idlist.Length; ++i ) {
                if ( idlist[i] != Province.TerraIncognitaID )
                    distlist[i] = CalcDistance( area, idlist[i] );
                else
                    distlist[i] = MaxDistance;
            }

            ids = new ushort[count];
            distances = new double[count];
            for ( int i=0; i<count; ++i ) {
                ids[i] = Province.TerraIncognitaID;
                distances[i] = MaxDistance;
            }

            Array.Sort( distlist, idlist );

            // Copy to result set
            Array.Copy( idlist, 0, ids, 0, idlist.Length < count ? idlist.Length : count );
            Array.Copy( distlist, 0, distances, 0, distlist.Length < count ? distlist.Length : count );
        }
Пример #25
0
        public CompleteProfilePageViewModel(INavigationService navigationService)
        {
            NavigationService = navigationService;

            MessagingCenter.Subscribe <string, Position>(this, "LocationAddress", (sender, pickedposition) =>
            {
                Street = AddressfromGPS = sender.ToString();
                AddressPositionfromGPS = pickedposition;
            });
            IsLocationFetch = false;
            IsLoaderBusy    = false;

            //UserPic = "logo.png";
            IsLoaderBusy       = false;
            HasCurrentLocation = false;
            Street             = AppResource.cyp_StreetPlaceholder;
            DOB = AppResource.cyp_DOBPlaceholder;
            TermConditionCheck = "resource://Khadamat_CustomerApp.SvgImages.blank_check_box.svg";

            //GetCurrentlocation();
            MaritalStatusList.Add(new MaritalStatusPickerModel
            {
                MaritalStatusDisplay   = Common.GetLanguage() != "ar-AE" ? Common.GetEnumDescription(MartialStatusEnum.Single) : Common.GetEnumDescription(MartialStatusArabicEnum.Single),
                MaritalStatusEnumValue = Convert.ToInt32(MartialStatusEnum.Single)
            });
            //MaritalStatusList.Add(new MaritalStatusPickerModel
            //{
            //    MaritalStatusDisplay = Common.GetLanguage() != "ar-AE" ? Common.GetEnumDescription(MartialStatusEnum.InARelationship) : Common.GetEnumDescription(MartialStatusArabicEnum.InARelationship),
            //    MaritalStatusEnumValue = Convert.ToInt32(MartialStatusEnum.InARelationship)
            //});
            //MaritalStatusList.Add(new MaritalStatusPickerModel
            //{
            //    MaritalStatusDisplay = Common.GetLanguage() != "ar-AE" ? Common.GetEnumDescription(MartialStatusEnum.Engaged) : Common.GetEnumDescription(MartialStatusArabicEnum.Engaged),
            //    MaritalStatusEnumValue = Convert.ToInt32(MartialStatusEnum.Engaged)
            //});
            MaritalStatusList.Add(new MaritalStatusPickerModel
            {
                MaritalStatusDisplay   = Common.GetLanguage() != "ar-AE" ? Common.GetEnumDescription(MartialStatusEnum.Married) : Common.GetEnumDescription(MartialStatusArabicEnum.Married),
                MaritalStatusEnumValue = Convert.ToInt32(MartialStatusEnum.Married)
            });
            //MaritalStatusList.Add(new MaritalStatusPickerModel
            //{
            //    MaritalStatusDisplay = Common.GetLanguage() != "ar-AE" ? Common.GetEnumDescription(MartialStatusEnum.ItsComplicated) : Common.GetEnumDescription(MartialStatusArabicEnum.ItsComplicated),
            //    MaritalStatusEnumValue = Convert.ToInt32(MartialStatusEnum.ItsComplicated)
            //});
            //MaritalStatusList.Add(new MaritalStatusPickerModel
            //{
            //    MaritalStatusDisplay = Common.GetLanguage() != "ar-AE" ? Common.GetEnumDescription(MartialStatusEnum.InAnOpenRelationship) : Common.GetEnumDescription(MartialStatusArabicEnum.InAnOpenRelationship),
            //    MaritalStatusEnumValue = Convert.ToInt32(MartialStatusEnum.InAnOpenRelationship)
            //});
            MaritalStatusList.Add(new MaritalStatusPickerModel
            {
                MaritalStatusDisplay   = Common.GetLanguage() != "ar-AE" ? Common.GetEnumDescription(MartialStatusEnum.Divorced) : Common.GetEnumDescription(MartialStatusArabicEnum.Divorced),
                MaritalStatusEnumValue = Convert.ToInt32(MartialStatusEnum.Divorced)
            });
            if (BaseViewModel.countryDataModels != null && BaseViewModel.countryDataModels.Count > 0 && BaseViewModel.provienceDataModels != null && BaseViewModel.provienceDataModels.Count > 0)
            {
                if (Application.Current.Properties.ContainsKey("AppLocale") && !string.IsNullOrEmpty(Application.Current.Properties["AppLocale"].ToString()))
                {
                    var languageculture = Application.Current.Properties["AppLocale"].ToString();
                    Country = languageculture.Equals("en-US") ? BaseViewModel.countryDataModels.FirstOrDefault().country_name : BaseViewModel.countryDataModels.FirstOrDefault().arabic_country_name;
                }
                else
                {
                    Country = BaseViewModel.countryDataModels.FirstOrDefault().country_name;
                }

                foreach (var item in BaseViewModel.provienceDataModels)
                {
                    if (Application.Current.Properties.ContainsKey("AppLocale") && !string.IsNullOrEmpty(Application.Current.Properties["AppLocale"].ToString()))
                    {
                        var languageculture = Application.Current.Properties["AppLocale"].ToString();
                        item.display_province_name = languageculture.Equals("en-US") ? item.province_name : item.arabic_province_name;
                    }
                    else
                    {
                        item.display_province_name = item.province_name;
                    }
                    ProvinceList.Add(item);
                }


                ProviencePickerSelectedindex = ProvinceList.IndexOf(ProvinceList.Where(x => x.province_name.ToLower().Contains("sana") || x.arabic_province_name.Contains("sana")).ToList().FirstOrDefault());
            }
            //GetCountriesApi();

            MessagingCenter.Subscribe <ImagesModel>(this, "ProfilePicture", (sender) =>
            {
                GallData = sender;
                UserPic  = GallData.Image;
            });


            MessagingCenter.Send("CompleteProfilePage", "CompleteProfilePage");
        }
Пример #26
0
        public static IncognitaGrid Build( IDMap idmap, ProvinceList provinces, IDGrid idgrid )
        {
            IncognitaGrid result = new IncognitaGrid();

            double scansize = (double)(Lightmap.BlockSize << 1);
            double scanfactor = 256.0 / Math.Sqrt( (scansize/2.0) * (scansize/2.0) );

            Random rnd = new Random();
            int halfscan = (int)(scansize/2);
            for( int y=0; y<Lightmap.BaseHeight; y+=Lightmap.BlockSize ) {
                for( int x=0; x<Lightmap.BaseWidth; x+=Lightmap.BlockSize ) {
                    ushort[] list = idmap.GetIDs( x-halfscan, y-halfscan, (int)scansize, (int)scansize, GetIDOptions.SkipTI | GetIDOptions.SkipRivers, provinces );

                    if ( list.Length > 1 ) {
                        double[] distances;
                        ushort[] idlist;
                        int weight;

                        idmap.FindNearest( x, y, (int)scansize, 4, provinces, out idlist, out distances );
                        for ( int i=0; i<4; ++i ) {
                            if ( idlist[i] > Province.MaxID ) idlist[i] = Province.TerraIncognitaID;
                            weight = (int)(distances[i]*scanfactor);
                            weight = weight - 15 + (rnd.Next(0x7fff) & 31);
                            if ( weight < 0 ) weight = 0;
                            else if ( weight > 255 ) weight = 255;

                            result.grid[x >> Lightmap.BlockFactor,y >> Lightmap.BlockFactor].data[i].id = idgrid.MapID( x, y, idlist[i] );
                            result.grid[x >> Lightmap.BlockFactor,y >> Lightmap.BlockFactor].data[i].weight = (byte)weight;
                        }
                    }
                    else {
                        ushort id =  Province.TerraIncognitaID;
                        if ( list.Length > 0 ) {
                            id = list[0];
                            if ( id > Province.MaxID ) id = Province.TerraIncognitaID;
                        }

                        result.grid[x >> Lightmap.BlockFactor, y >> Lightmap.BlockFactor].data[0].id = idgrid.MapID( x, y, id );
                        result.grid[x >> Lightmap.BlockFactor, y >> Lightmap.BlockFactor].data[0].weight = 0;

                        result.grid[x >> Lightmap.BlockFactor, y >> Lightmap.BlockFactor].data[1].id = 0;
                        result.grid[x >> Lightmap.BlockFactor, y >> Lightmap.BlockFactor].data[1].weight = 255;

                        result.grid[x >> Lightmap.BlockFactor, y >> Lightmap.BlockFactor].data[2].id = 0;
                        result.grid[x >> Lightmap.BlockFactor, y >> Lightmap.BlockFactor].data[2].weight = 255;

                        result.grid[x >> Lightmap.BlockFactor, y >> Lightmap.BlockFactor].data[3].id = 0;
                        result.grid[x >> Lightmap.BlockFactor, y >> Lightmap.BlockFactor].data[3].weight = 255;
                    }
                }
            }

            return result;
        }
Пример #27
0
        public ushort[] GetIDs( int x, int y, int width, int height, GetIDOptions options, ProvinceList provinces )
        {
            // Check for valid coordinates and adjust if needed
            bool includeTI = (options & GetIDOptions.SkipTI) == 0;
            bool inclusive = (options & GetIDOptions.OnlyInclusiveProvinces) > 0;
            bool skipRivers = (options & GetIDOptions.SkipRivers) > 0 && (provinces != null);

            x = Lightmap.BaseNormalizeX( x );
            width += x;
            if ( y < 0 ) {
                height += y;
                y = 0;
            }
            height += y;
            if ( height > Lightmap.BaseHeight ) height = Lightmap.BaseHeight;

            int[] tagged = new int[Province.InternalCount];
            // Reset all items to 0
            for ( int i=0; i<Province.Count; ++i ) tagged[i] = 0;

            // Walk over the zones for each line, and tag each time we encounter a province id
            for ( ; y<height; ++y ) {
                lines[y].TagIDs( tagged, x, width, inclusive );
            }

            // Count items in list
            int count = 0;
            ushort start = (ushort )(includeTI ? 0 : 1);
            for ( int i=start; i<Province.InternalCount; ++i ) {
                if ( tagged[i] > 0 && (!skipRivers || (skipRivers && !provinces[i].IsRiver()) ) ) count++;
            }

            ushort[] list = new ushort[count];
            count = 0;
            for ( ushort i=start; i<Province.InternalCount; ++i ) {
                if ( tagged[i] > 0 && (!skipRivers || !provinces[i].IsRiver()) ) list[count++] = i;
            }

            return list;
        }
Пример #28
0
 private Lightmap( int zoom, ProvinceList provinces, AdjacencyTable adjacent, IDMap idmap, BinaryReader reader )
     : this(zoom, provinces, adjacent, idmap)
 {
     ReadFrom( reader );
 }
Пример #29
0
 public void Attach( ProvinceList provinces, AdjacencyTable adjacent, IDMap idmap )
 {
     this.provinces = provinces;
     this.adjacent = adjacent;
     this.idmap = idmap;
 }
Пример #30
0
 public static Lightmap FromStream( int zoom, ProvinceList provinces, AdjacencyTable adjacent, IDMap idmap, BinaryReader reader )
 {
     return new Lightmap( zoom, provinces, adjacent, idmap, reader );
 }
Пример #31
0
 public ushort FindClosestLand( int x, int y, ushort skipid, ProvinceList provinces, AdjacencyTable adjacent )
 {
     return FindClosestLand( x, y, skipid, Lightmap.BlockSize, provinces, adjacent);
 }
Пример #32
0
 public static IncognitaGrid Build( IDMap idmap, ProvinceList provinces )
 {
     return Build( idmap, provinces, IDGrid.Build( idmap ) );
 }
Пример #33
0
        public ushort FindClosestLand( int x, int y, ushort skipid, int range, ProvinceList provinces, AdjacencyTable adjacent )
        {
            int halfwidth = (range >> 1);
            int halfheight = (range >> 1);

            ushort closest_id = skipid;

            // -- Build a bitmap around this point
            x = Lightmap.BaseNormalizeX( x );

            int max_distance = MaxDistance;
            ushort[,] map = ExportBitmapGrid( x-halfwidth, y-halfheight, range, range );
            for ( int my=0; my<range; ++my ) {
                for ( int mx=0; mx<range; ++mx ) {
                    // -- Skip for TI and pixels belonging to this province
                    if ( map[mx,my] == Province.TerraIncognitaID || map[mx,my] == skipid ) continue;
                    if ( !provinces[map[mx,my]].IsLandNoTI() ) continue; // Only land

                    // Also check if adjacency exists
                    if ( adjacent != null && skipid != 0 ) {
                        int adj = adjacent.GetAdjacencyIndex( skipid, map[mx,my] );
                        if ( adj < 0 || adj >= 16 ) continue;
                    }

                    // -- This pixel qualifies: check the distance.
                    // Normally, we should need a sqrt() too, but it doesn't really matter here,
                    // as we just want "the smallest" and not how small it actually is.
                    int distance = ((mx-halfwidth)*(mx-halfwidth)) + ((my-halfheight)*(my-halfheight));
                    if ( distance < max_distance ) {
                        max_distance = distance;
                        closest_id = map[mx,my];
                    }
                }
            }

            return closest_id;
        }
        public void OnNavigatedTo(INavigationParameters parameters)
        {
            if (parameters.ContainsKey("ProfileData"))
            {
                profiledata = (UserModel)parameters["ProfileData"];

                try
                {
                    if (profiledata != null)
                    {
                        Profiledata = profiledata;
                        Name        = Profiledata.name;
                        Email       = Profiledata.email;
                        DOB         = profiledata.dob;
                        UserPic     = Common.IsImagesValid(profiledata.profile_pic);
                        PhoneNumber = profiledata.phone_number;
                        CurrentJob  = profiledata.current_job;
                        Street      = !string.IsNullOrEmpty(profiledata.street) && !string.IsNullOrWhiteSpace(profiledata.street) ? profiledata.street : AppResource.cyp_StreetPlaceholder;
                        if (!string.IsNullOrEmpty(DOB) && !string.IsNullOrWhiteSpace(DOB))
                        {
                            var dobdata = DOB.Split('/');

                            DOBDatePickerSelectedindex  = DOBDateList.IndexOf(dobdata[0]);
                            DOBMonthPickerSelectedindex = DOBMonthList.IndexOf(dobdata[1]);
                            DOBYearPickerSelectedindex  = DOBYearList.IndexOf(dobdata[2]);
                        }



                        if (profiledata.longitude.HasValue && profiledata.latitude.HasValue)
                        {
                            AddressPositionfromGPS = new Position(profiledata.latitude.Value, profiledata.longitude.Value);
                            location = new Plugin.Geolocator.Abstractions.Position(profiledata.latitude.Value, profiledata.longitude.Value);
                        }
                        Location = profiledata.description_location;

                        if (profiledata.martial_status.HasValue)
                        {
                            switch (profiledata.martial_status.Value)
                            {
                            case 1:
                                MaritalStatusPickerSelectedindex = 0;
                                break;

                            case 2:
                                MaritalStatusPickerSelectedindex = 1;
                                break;

                            case 3:
                                MaritalStatusPickerSelectedindex = 2;
                                break;

                            case 4:
                                MaritalStatusPickerSelectedindex = 3;
                                break;

                            case 5:
                                MaritalStatusPickerSelectedindex = 4;
                                break;

                            case 6:
                                MaritalStatusPickerSelectedindex = 5;
                                break;

                            case 7:
                                MaritalStatusPickerSelectedindex = 6;
                                break;

                            default:
                                MaritalStatusPickerSelectedindex = -1;
                                break;
                            }
                        }
                        if (profiledata.province.HasValue)
                        {
                            ProviencePickerSelectedindex = ProvinceList.IndexOf(ProvinceList.Where(x => x.province_id == (int)profiledata.province.Value).ToList().FirstOrDefault());
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Пример #35
0
 public void FindNearest( Point location, int perimeter, int count, ProvinceList provinces, out ushort[] ids, out double[] distances )
 {
     FindNearest( location.X, location.Y, perimeter, count, provinces, out ids, out distances );
 }
Пример #36
0
 public AdjacencyTable BuildAdjacencyTable( ProvinceList provinces )
 {
     return BuildAdjacencyTable( new Rectangle( 0, 0, Lightmap.BaseWidth, Lightmap.BaseHeight ), provinces );
 }
Пример #37
0
 public void FindNearest( Point location, int perimeter, ProvinceList provinces, out ushort id, out double distance )
 {
     FindNearest( location.X, location.Y, perimeter, provinces, out id, out distance );
 }
Пример #38
0
 public static Lightmap CreateEmpty( int zoom, ProvinceList provinces, AdjacencyTable adjacent, IDMap idmap )
 {
     Lightmap result = new Lightmap( zoom, provinces, adjacent, idmap );
     for ( int i=0; i<result.blocks.Length; ++i ) result.blocks[i] = new MapBlock();
     return result;
 }
Пример #39
0
        public AdjacencyTable BuildAdjacencyTable( Rectangle region, ProvinceList provinces )
        {
            const int Offset = 2; // 1 is too small, it seems...
            AdjacencyTable table = new AdjacencyTable();

            // Build a matrix of provinces by walking over the map and marking each adjacency in the matrix.
            int[,] matrix = new int[Province.InternalCount,Province.InternalCount];
            int[,] rivers = new int[Province.InternalCount,Province.InternalCount];

            // Fix region
            if ( region.Right > Lightmap.BaseWidth ) region.Width =  Lightmap.BaseWidth - region.X;
            if ( region.Bottom > Lightmap.BaseHeight ) region.Height =  Lightmap.BaseHeight - region.Y;

            ushort[] histogram = null;

            // Enlarge region (only if it's not encompassing the whole map).
            // This is necessary to detect changed on the border of the region specified...
            if ( region.X != 0 || region.Y != 0 || region.Width < Lightmap.BaseWidth || region.Width < Lightmap.BaseHeight ) {
                // Need to enlarge the region so that it *completely* encompasses all provinces in the original region

                // First, Get a map of all the IDs in the original region
                histogram = GetHistogram( region );

                // Get all ids in the region
                ushort[] ids = GetIDs( region, false );
                ProvinceBoundBox[] boxes = CalculateBoundBoxes();
                for ( int i=0; i<ids.Length; ++i ) {
                    region = Rectangle.Union( region, boxes[ids[i]].Box );
                }

                // Fix region, again.
                if ( region.Right > Lightmap.BaseWidth ) region.Width =  Lightmap.BaseWidth - region.X;
                if ( region.Bottom > Lightmap.BaseHeight ) region.Height =  Lightmap.BaseHeight - region.Y;
            }

            int id1, id2;
            int[] places = new int[] { Offset*2, 0, 0, -Offset*2,
                                       Offset*4, -Offset*2, Offset*2, -Offset*4,
                                       Offset*6, -Offset*4, Offset*4, -Offset*6,
                                       Offset*8, -Offset*6, Offset*6, -Offset*8 };
            for ( int y=region.Top; y<region.Bottom; ++y ) {
                // Walk over zones on this row
                int zleft = lines[y].LookupZoneIndex( region.Left );
                int zright = lines[y].LookupZoneIndex( region.Right );

                for ( int z=zleft; z<=zright; ++z ) {
                    // Skip if we're TI
                    if ( lines[y].GetZone( z ).ID == Province.TerraIncognitaID ) continue;

                    // Process this zone.
                    int left = lines[y].GetZone( z ).X;
                    int right = left + lines[y].GetZoneLength( z );
                    for ( int x=left; x<right; ++x ) {
                        #region Left/Right check
                        // -- Left/right check first
                        id1 = this[x-Offset,y];
                        id2 = this[x+Offset,y];

                        if ( id1 != Province.TerraIncognitaID && id2 != Province.TerraIncognitaID ) {
                            if ( provinces[id2].IsRiver() ) {
                                // The right one is a river...
                                ++matrix[id1,id2];
                                ++matrix[id2,id1];

                                // Look for land...
                                for ( int i=0; i<places.Length; i+=2 ) {
                                    id2 = this[x+places[i],y+places[i+1]];
                                    if ( provinces[id2].IsLand() ) {
                                        ++matrix[id1,id2];
                                        ++matrix[id2,id1];
                                        // Also mark river adjacency
                                        ++rivers[id1,id2];
                                        ++rivers[id2,id1];
                                        break;
                                    }
                                }

                                // If not found, don't mark a thing
                            }
                            else {
                                ++matrix[id1,id2];
                                ++matrix[id2,id1];
                            }
                        }
                        #endregion

                        #region Up/down check
                        // -- Up/down check next
                        id1 = this[x,y-Offset];
                        id2 = this[x,y+Offset];

                        if ( id1 != 0 && id2 != 0 ) {
                            if ( provinces[id2].IsRiver() ) {
                                // The bottom one is a river...
                                ++matrix[id1,id2];
                                ++matrix[id2,id1];

                                // Look further down for land...
                                for ( int i=0; i<places.Length; i+=2 ) {
                                    id2 = this[x+(-places[i+1]),y+places[i]];
                                    if ( provinces[id2].IsLand() ) {
                                        ++matrix[id1,id2];
                                        ++matrix[id2,id1];
                                        // Also mark river adjacency
                                        ++rivers[id1,id2];
                                        ++rivers[id2,id1];
                                        break;
                                    }
                                }

                                // If not found, don't mark a thing
                            }
                            else {
                                ++matrix[id1,id2];
                                ++matrix[id2,id1];
                            }
                        }
                        #endregion
                    }
                }
            }

            // Walk over the matrix, and build an actual list of adjacencies for each province.
            const int Threshold = 8; // we need a certain amount of matches to have adjacency...

            // Start iterating at 1, no need to incorporate TI...
            for ( ushort ph=1; ph<Province.Count; ++ph ) {
                // Skip ids not present in the original region
                if ( histogram != null && histogram[ph] <= 0 ) continue;

                // Do "normal" adjacencies first
                for ( ushort pv=1; pv<Province.Count; ++pv ) {
                    if ( ph == pv || provinces[pv].IsRiver() ) continue;
                    // Check for the threshold
                    if ( matrix[ph,pv] <= Threshold ) continue;

                    table.Add( ph, new Adjacent( pv, rivers[ph,pv] == matrix[ph,pv] ? AdjacencyType.River : AdjacencyType.Normal ) );
                }

                // Do "river" adjacencies next
                for ( ushort pv=1; pv<Province.Count; ++pv ) {
                    if ( ph == pv || !provinces[pv].IsRiver() ) continue;
                    // Check for the threshold
                    if ( matrix[ph,pv] <= Threshold ) continue;

                    table.Add( ph, new Adjacent( pv, AdjacencyType.Normal ) );
                }
            }

            return table;
        }
Пример #40
0
        public CompressedBlock Compress( int xreal, int yreal, int zoom, ProvinceList provinces, AdjacencyTable adjacent, IDMap idmap )
        {
            // Walk the tree, storing the info along the way
            MapBlockHandling.Compressor compressor;
            if ( provinces == null || adjacent == null || idmap == null )
                compressor = new MapBlockHandling.LesserCompressor();
            else
                compressor = new MapBlockHandling.DefaultCompressor( xreal, yreal, zoom, provinces, adjacent, idmap );
            WalkTree( compressor );

            // Write away idtable
            int datasize = compressor.IDCount*2 + compressor.Tree.Length + (compressor.LeafCount+3)/4*3;
            if ( compressor.IDCount == 2 )
                datasize += (compressor.LeafCount+7)/8;
            else if ( compressor.IDCount == 3 || compressor.IDCount == 4 )
                datasize += (compressor.LeafCount+3)/4;
            else if ( compressor.IDCount > 4 && compressor.IDCount <= 16 )
                datasize += (compressor.LeafCount+1)/2;
            else if ( compressor.IDCount > 16 )
                datasize += compressor.LeafCount;

            byte[] data = new byte[datasize];
            int dataindex = 0;

            // Copy IDTable
            /*
            for ( int i=0; i<compressor.IDCount; ++i ) {
                data[dataindex++] = (byte)(compressor.IDTable[i] & 255);
                data[dataindex++] = (byte)(compressor.IDTable[i] >> 8);
            }
            */
            byte[] idtable = compressor.IDTable;
            for ( int i=0; i<compressor.IDCount; ++i ) {
                for ( int t=0; t<ushort.MaxValue; ++t ) {
                    if ( idtable[t] == i ) {
                        data[dataindex++] = (byte)(t & 255);
                        data[dataindex++] = (byte)(t >> 8);
                        break;
                    }
                }
            }
            data[dataindex-1] |= Terminator;

            byte[] tree = compressor.Tree;
            for ( int i=0; i<tree.Length; ++i ) {
                data[dataindex++] = tree[i];
            }

            if ( compressor.IDCount == 2 ) {
                for ( int i=0; i<compressor.LeafCount; i+=8 ) {
                    data[dataindex++] = (byte)(
                        (compressor.Owners[i]) |
                        (compressor.Owners[i+1] << 1) |
                        (compressor.Owners[i+2] << 2) |
                        (compressor.Owners[i+3] << 3) |
                        (compressor.Owners[i+4] << 4) |
                        (compressor.Owners[i+5] << 5) |
                        (compressor.Owners[i+6] << 6) |
                        (compressor.Owners[i+7] << 7) );
                }
            }
            else if ( compressor.IDCount == 3 || compressor.IDCount == 4 ) {
                for ( int i=0; i<compressor.LeafCount; i+=4 ) {
                    data[dataindex++] = (byte)(
                        (compressor.Owners[i]) |
                        (compressor.Owners[i+1] << 2) |
                        (compressor.Owners[i+2] << 4) |
                        (compressor.Owners[i+3] << 6) );
                }
            }
            else if ( compressor.IDCount > 4 && compressor.IDCount <= 16 ) {
                for ( int i=0; i<compressor.LeafCount; i+=2 ) {
                    data[dataindex++] = (byte)(
                        (compressor.Owners[i]) |
                        (compressor.Owners[i+1] << 4) );
                }
            }
            else if ( compressor.IDCount > 16 ) {
                for ( int i=0; i<compressor.LeafCount; ++i ) {
                    data[dataindex++] = (byte)(compressor.Owners[i]);
                }
            }

            // Finally, the 6-bit color values
            for ( int i=0; i<compressor.LeafCount; i+=4) {
                data[dataindex++] = (byte)((compressor.Colors[i] & 63) | ((compressor.Colors[i+1] & 63) << 6));
                data[dataindex++] = (byte)(((compressor.Colors[i+1] & 63) >> 2) | ((compressor.Colors[i+2] & 63) << 4));
                data[dataindex++] = (byte)(((compressor.Colors[i+2] & 63) >> 4) | ((compressor.Colors[i+3] & 63) << 2));
            }

            return new CompressedBlock( data );
        }