Beispiel #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);
            }
        }
Beispiel #2
0
 internal void DoTaskUpdateEvent(DrawTaskEventArgs e)
 {
     if (TaskUpdate != null)
     {
         TaskUpdate(this, e);
     }
 }
Beispiel #3
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());
            }
        }
Beispiel #4
0
        internal virtual void Run()
        {
            DrawTaskEventArgs lastArgs = null;

            try
            {
                if (layer == null || !layer.Visible)
                {
                    return;
                }
                //计算范围
                List <Datarow> rows        = layer.Datatable.Query(extent);
                int            threadCount = 0;
                int            onceCount   = 0;
                CountThread(rows, out threadCount, out onceCount);
                if (threadCount == 0)
                {
                    return;
                }
                for (int i = 0; i < threadCount; i++)
                {
                    if (this.state == -1)
                    {
                        return;
                    }
                    int start = i * onceCount;
                    int end   = (i + 1) * onceCount;
                    if (end > rows.Count)
                    {
                        end = rows.Count;
                    }
                    AsyncThread asyncth = new AsyncThread();
                    asyncth.Call += delegate(object o)
                    {
                        Bitmap   bitmap = new Bitmap(this.width, this.height);
                        Graphics g      = Graphics.FromImage(bitmap);
                        for (int j = start; j < end; j++)
                        {
                            if (this.state == -1)
                            {
                                g.Dispose();
                                bitmap.Dispose();
                                return;
                            }
                            Draw(g, rows[j]);
                        }
                        g.Dispose();
                        DrawTaskEventArgs args = new DrawTaskEventArgs(bitmap, true);
                        if ((int)o + 1 == threadCount)
                        {
                            lastArgs = args;
                        }
                        else
                        {
                            DoTaskUpdateEvent(args);
                        }
                    };
                    asyncth.Start(i);
                    asyncThreads.Add(asyncth);
                }
                foreach (AsyncThread item in asyncThreads)
                {
                    item.Wait();
                    item.Dispose();
                }
            }
            finally
            {
                asyncThreads.Clear();
                DoTaskCompleteEvent(lastArgs);
            }
        }