Exemplo n.º 1
0
        private void task_TaskUpdate(object sender, DrawTaskEventArgs e)
        {
            DrawLayerTask task    = (DrawLayerTask)sender;
            bool          canShow = true;

            lock (this)
            {
                int index = tasks.IndexOf(task);
                for (int i = 0; i < index; i++)
                {
                    if (tasks[i].layer.Datatable.TableType != DatatableType.Point && tasks[i].layer.Datatable.TableType != DatatableType.Line)
                    {
                        canShow = false;
                        break;
                    }
                }
            }
            if (task.state == 0)//初始状态
            {
                showEngine.Insert(task.layer.LayerID, task.layerIndex, e.bitmap, canShow, false);
                task.state = 1;
            }
            else
            {
                showEngine.Combine(task.layer.LayerID, e.bitmap, canShow, false);
            }
        }
Exemplo n.º 2
0
 private void DoDrawLayers()
 {
     for (int i = _map.Layers.Count - 1; i >= 0; i--)
     {
         Layer         layer = _map.Layers[i];
         DrawLayerTask task  = GetTask(layer);
         if (task != null)
         {
             task.layerIndex = i;
             _mapDrawEngine.InsertTask(task);
         }
     }
     _mapDrawEngine.StartAllTask();
 }
Exemplo n.º 3
0
        private void DoDrawLayer(Layer layer)
        {
            int index = _map.Layers.IndexOf(layer);

            if (index >= 0)
            {
                DrawLayerTask task = GetTask(layer);
                if (task != null)
                {
                    task.layerIndex = index;
                    _mapDrawEngine.InsertTask(task);
                    task.Start();
                }
            }
        }
Exemplo n.º 4
0
 public void InsertTask(DrawLayerTask task)
 {
     lock (this)
     {
         foreach (DrawLayerTask item in tasks)
         {
             if (item.layer.LayerID == task.layer.LayerID)
             {
                 RemoveTask(item);
                 break;
             }
         }
         tasks.Add(task);
         task.TaskComplete += task_TaskComplete;
         task.TaskUpdate   += task_TaskUpdate;
     }
 }
Exemplo n.º 5
0
        private DrawLayerTask GetTask(Layer layer)
        {
            DrawLayerTask task = null;

            if (layer is RasterLayer)
            {
                task = new DrawRasterTask(_workspace, layer as RasterLayer, this.Extent, this.Width, this.Height);
            }
            else if (layer is PointLayer)
            {
                task = new DrawPointTask(_workspace, layer as PointLayer, this.Extent, this.Width, this.Height);
            }
            else if (layer is LineLayer)
            {
                task = new DrawLineTask(_workspace, layer as LineLayer, this.Extent, this.Width, this.Height);
            }
            else if (layer is PolygonLayer)
            {
                task = new DrawPolygonTask(_workspace, layer as PolygonLayer, this.Extent, this.Width, this.Height);
            }
            return(task);
        }
Exemplo n.º 6
0
        private void task_TaskComplete(object sender, DrawTaskEventArgs e)
        {
            lock (this)
            {
                DrawLayerTask        task   = (DrawLayerTask)sender;
                List <DrawLayerTask> ptasks = new List <DrawLayerTask>();
                Console.WriteLine("task_TaskComplete:" + task.layer.AliasName);
//                 if (task.layer.DatatableName=="point")
//                 {
//                     Console.WriteLine("task_TaskComplete:" + tasks.Count);
//                 }
                if (e != null)
                {
                    int index = tasks.Count - 1;
                    if (task.state == 0)
                    {
                        task.state = 3;//insert
                    }
                    else
                    {
                        task.state = 2;//combine
                    }
                    task.drawBitmap = e.bitmap;
                    int lastIndex = -1;
                    for (int i = 0; i < tasks.Count; i++)
                    {
                        if (tasks[i] != task)
                        {
                            if (i < index)
                            {
                                if (tasks[i].state != 2 && tasks[i].state != 3)
                                {
                                    return;
                                }
                                else
                                {
                                    lastIndex = i;
                                }
                            }
                            else
                            {
                                if (tasks[i].state != 2 && tasks[i].state != 3 && tasks[i].layer.Datatable.TableType != DatatableType.Point && tasks[i].layer.Datatable.TableType != DatatableType.Line)
                                {
                                    return;
                                }
                                else if (tasks[i].state != 2 && tasks[i].state != 3)
                                {
                                    lastIndex = i - 1;
                                    break;
                                }
                                else
                                {
                                    lastIndex = i;
                                }
                            }
                        }
                        else
                        {
                            index     = i;
                            lastIndex = i;
                        }
                    }

//                     index = tasks.IndexOf(task);
//                     if (index != 0)
//                     {
//                         if (task.state==0)
//                         {
//                             task.state = 3;
//                         }
//                         else task.state = 2;
//                         task.drawBitmap = e.bitmap;
//                         return;
//                     }
//                     else
//                     {
                    //ptasks.Add(task);
                    List <ulong>  ids        = new List <ulong>();
                    List <int>    indexs     = new List <int>();
                    List <Bitmap> bitmaps    = new List <Bitmap>();
                    List <bool>   isInOrComs = new List <bool>();

//                         ids.Add(task.layer.LayerID);
//                         indexs.Add(task.layerIndex);
//                         bitmaps.Add(e.bitmap);
//                         if (task.state==0)
//                         {
//                             isInOrComs.Add(true);
//                         }
//                         else
//                         {
//                             isInOrComs.Add(false);
//                         }

                    for (int i = 0; i <= /*tasks.Count-1*/ lastIndex; i++)
                    {
//                             if (tasks[i].state!=2&&tasks[i].state!=3)
//                             {
//                                 break;
//                             }
//                             else
//                             {
                        ids.Add(tasks[i].layer.LayerID);
                        indexs.Add(tasks[i].layerIndex);
                        bitmaps.Add(tasks[i].drawBitmap);
                        tasks[i].drawBitmap = null;
                        ptasks.Add(tasks[i]);
                        if (tasks[i].state == 3)
                        {
                            isInOrComs.Add(true);
                        }
                        else
                        {
                            isInOrComs.Add(false);
                        }
                        Console.WriteLine("complete :" + tasks[i].layer.AliasName);
                        //}
                    }

                    showEngine.InsertOrCombine(ids, indexs, bitmaps, isInOrComs, true, true);
//                         if (task.state == 0)
//                         {
//                             showEngine.Insert(task.layer.LayerID, task.layerIndex, e.bitmap, e.canShow, true);
//                             task.state = 2;
//                         }
//                         else showEngine.Combine(task.layer.LayerID, e.bitmap, e.canShow, true);
                    //}
                }
                else
                {
                    ptasks.Add(task);
                    showEngine.Remove(task.layer.LayerID);
                }
                RemoveTask(ptasks.ToArray());
            }
        }