Exemple #1
0
        // Tạo ma trận file text các Tile 16x16 được đánh số theo SetTiles
        static List <List <int> > CreateMatrix16x16Tile(List <List <Bitmap> > MapTiles, HashSet <Bitmap> SetTiles)
        {
            var MatrixTiles  = new List <List <int> >();
            var ListSetTiles = CreateSet16x16Tile(MapTiles).ToList();
            var TileComparer = new TileComparer();

            foreach (var RowTiles in MapTiles)
            {
                var Row = new List <int>();
                foreach (var Tile in RowTiles)
                {
                    foreach (var TypeTile in SetTiles)
                    {
                        if (TileComparer.Equals(TypeTile, Tile))
                        {
                            Row.Add(ListSetTiles.IndexOf(TypeTile));
                            break;
                        }
                    }
                }
                MatrixTiles.Add(Row);
            }
            return(MatrixTiles);
        }
 private void Complated()
 {
     TileComparer comparer = new TileComparer();
     List<string> needRemoveKeys = _inContainer.Values.Except(needShowTiles, comparer).Distinct(comparer).Select(c => c.TileKey).ToList();
     foreach (string key in needRemoveKeys)
     {
         bool suc = _inContainer.Remove(key);
         Container.Children.Remove(Container.FindName(key) as UIElement);
     }
 }
        /// <summary>
        /// 获取当前进度。
        /// </summary>
        /// <returns></returns>
        private int GetProgress()
        {
            TileComparer comparer = new TileComparer();
            int progress = 0;
            if (needShowTiles.Count == 0)
            {
                //可能存在此处needShowTiles.Count=0的情况,比如迅速将地图移出Bounds的范围。
                return 100;
            }
            progress = _inContainer.Values.Intersect(needShowTiles).ToList().Count * 100 / needShowTiles.Count;

            return progress;
        }
        internal override void Draw(UpdateParameter updateParameter)
        {
            base.Draw(updateParameter);
            if ((base.IsInitialized && base.IsVisible) && (!Rectangle2D.IsNullOrEmpty(ViewBounds)) && (base.Container != null))
            {
                if (GetCachedResolutions() != null)
                {
                    realResolutions = this.GetCachedResolutions();
                }
                else
                {
                    realResolutions = updateParameter.Resolutions;
                }
                double resolution = MathUtil.GetNearest(updateParameter.Resolution,realResolutions,MinVisibleResolution,MaxVisibleResolution);

                int[] span = this.GetTileSpanWithin(ViewBounds, resolution);

                int level = -1;
                needShowTiles = NeedShowTiles(resolution, span, updateParameter.UseTransitions, out level);
                TileComparer comparer = new TileComparer();
                List<Tile> needDownload = needShowTiles.Except<Tile>(_inContainer.Values, comparer).ToList();
                if (needDownload.Count > 0)
                {
                    _queueSystem.InputTiles(uniqueLayerId, needDownload);
                }
            }
        }