Ejemplo n.º 1
0
        //替换图片
        public bool Replace(ulong id, Bitmap bitmap, bool canShow, bool isCompelete)
        {
            if (!_enableUpdate)
            {
                return(false);
            }
            lock (this)
            {
                AbortPaintWait();
                int      index    = -1;
                MapImage mapImage = Find(id, out index);
                if (mapImage == null)
                {
                    return(false);
                }
                mapImage.image.Dispose();
                mapImage.image       = bitmap;
                mapImage.canShow     = canShow;
                mapImage.isCompelete = isCompelete;
//                 if (isCompelete)
//                 {
//                     CombineCompelete(mapImage, index);
//                 }
                if (canShow)
                {
                    SetPaintState();
                }
                return(true);
            }
        }
Ejemplo n.º 2
0
 public void InsertOrCombine(List <ulong> ids, List <int> indexs, List <Bitmap> bitmaps, List <bool> isInOrComs, bool canShow, bool isComplete)
 {
     lock (this)
     {
         if (!_enableUpdate)
         {
             return;
         }
         AbortPaintWait();
         int ind;
         for (int i = 0; i < ids.Count; i++)
         {
             MapImage mapImage = Find(ids[i], out ind);
             if (mapImage != null)
             {
                 //Console.WriteLine("InsertOrCombine:Find 1:" + mapImage.index);
                 if (isInOrComs[i])
                 {
                     mapImage.image.Dispose();
                     mapImage.image = bitmaps[i];
                 }
                 else
                 {
                     Combine(mapImage.image, bitmaps[i]);
                     bitmaps[i].Dispose();
                 }
                 mapImage.isOld = false;
                 mapImage.index = indexs[i];
                 // Console.WriteLine("InsertOrCombine:Find 2:" + mapImage.index);
                 mapImage.canShow     = canShow;
                 mapImage.isCompelete = isComplete;
             }
             else
             {
                 mapImage       = new MapImage(bitmaps[i], canShow, isComplete);
                 ind            = 0;
                 mapImage.id    = ids[i];
                 mapImage.index = indexs[i];
                 for (int j = _mapImages.Count - 1; j >= 0; j--)
                 {
                     if (_mapImages[j].index <= indexs[i])
                     {
                         ind = j + 1;
                         break;
                     }
                 }
                 _mapImages.Insert(ind, mapImage);
                 // Console.WriteLine("InsertOrCombine:Insert:" + mapImage.index);
             }
         }
         _mapImages.Sort(Compare);
         if (canShow)
         {
             SetPaintState();
         }
     }
 }
Ejemplo n.º 3
0
 //插入新图片
 public ulong Insert(ulong id, int layerIndex, Bitmap bitmap, bool canShow, bool isCompelete)
 {
     lock (this)
     {
         if (!_enableUpdate)
         {
             return(0);
         }
         MapImage mapImage = null;
         AbortPaintWait();
         int index = 0;
         mapImage = Find(id, out index);
         if (mapImage != null)
         {
             mapImage.image.Dispose();
             mapImage.image       = bitmap;
             mapImage.canShow     = canShow;
             mapImage.isCompelete = isCompelete;
             mapImage.isOld       = false;
             if (mapImage.index != layerIndex)
             {
                 mapImage.index = layerIndex;
                 _mapImages.Sort(Compare);
             }
             Console.WriteLine("Insert Find:" + mapImage.index);
         }
         else
         {
             mapImage       = new MapImage(bitmap, canShow, isCompelete);
             index          = 0;
             mapImage.id    = id;
             mapImage.index = layerIndex;
             for (int i = _mapImages.Count - 1; i >= 0; i--)
             {
                 if (_mapImages[i].index <= layerIndex)
                 {
                     index = i + 1;
                     break;
                 }
             }
             _mapImages.Insert(index, mapImage);
             Console.WriteLine("Insert:" + mapImage.index);
         }
         //                 if (isCompelete)
         //                 {
         //                     CombineCompelete(mapImage, index);
         //                 }
         if (canShow && bitmap != null)
         {
             SetPaintState();
         }
         return(mapImage.id);
     }
 }
Ejemplo n.º 4
0
 //比较图片先后顺序
 private int Compare(MapImage x, MapImage y)
 {
     if (x.index > y.index)
     {
         return(1);
     }
     else if (x.index < y.index)
     {
         return(-1);
     }
     else
     {
         return(0);
     }
 }
Ejemplo n.º 5
0
 //设置图片先后顺序
 public void SetIndex(List <ulong> ids, List <int> layerIndexs)
 {
     lock (this)
     {
         AbortPaintWait();
         for (int i = 0; i < ids.Count; i++)
         {
             int      index;
             MapImage image = Find(ids[i], out index);
             if (image != null)
             {
                 image.index = layerIndexs[i];
             }
         }
         _mapImages.Sort(Compare);
         SetPaintState();
     }
 }
Ejemplo n.º 6
0
 //开始绘制
 private void DoUpdateShow()
 {
     try
     {
         _updateResetEvent.WaitOne();
         if (_lastBitmap != null)
         {
             _lastBitmap.Dispose();
             _lastBitmap = null;
         }
         if (_mapImages.Count > 0)
         {
             _lastBitmap = new Bitmap(_mapImages[_mapImages.Count - 1].image.Width, _mapImages[_mapImages.Count - 1].image.Height);
             Graphics g = null;
             try
             {
                 g = Graphics.FromImage(_lastBitmap);
                 for (int i = _mapImages.Count - 1; i >= 0; i--)
                 {
                     MapImage item = _mapImages[i];
                     if (_isCancelPaint)
                     {
                         return;
                     }
                     if (item.canShow)
                     {
                         if (item.isOld)
                         {
                             g.TranslateTransform(_dx, _dy);
                             g.DrawImage(item.image, 0, 0);
                             g.ResetTransform();
                         }
                         else
                         {
                             g.DrawImage(item.image, 0, 0);
                         }
                     }
                 }
                 g.Dispose();
                 g = null;
                 if (_isCancelPaint)
                 {
                     return;
                 }
             }
             finally
             {
                 if (g != null)
                 {
                     g.Dispose();
                 }
             }
         }
         if (ShowUpdated != null)
         {
             ShowUpdated(this, new EventArgs());
         }
     }
     finally
     {
         _isCancelPaint = false;
         _isPainting    = false;
         _newupdateResetEvent.Set();
     }
 }