예제 #1
0
        private void label_settle_MouseUp(object sender, MouseButtonEventArgs e)
        {
            //label_settle.Background = new ImageBrush(new BitmapImage(
            //    new Uri("res\\button\\settle-hover.png", System.UriKind.Relative)));
            IntPtr      bitmap = global::Tracking.Properties.Resources.settle_hover.GetHbitmap();
            ImageSource source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                bitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());

            label_settle.Background = new ImageBrush(source);

            //修改逻辑表项
            foreach (TreeModel t in arrivedCheckedList)
            {
                //写入数据库
                DBO.newRecord(t.Name, t.dst, t.dst, RES.SETTLED);
                //修改逻辑表,从勾选状态进入已结算状态
                //arrivedCheckedList.Remove(t);
                settledList.Add(t);
            }
            //修改UI表结构
            List <TreeModel> bills = new List <TreeModel>();

            foreach (ZsmTreeView[] trees in treeList)
            {
                ZsmTreeView tree = trees[2];
                for (int i = 1; i < tree.ItemsSourceData.Count(); i++)
                {
                    IList <TreeModel> childrenList = tree.ItemsSourceData.ElementAt <TreeModel>(i).Children;
                    foreach (TreeModel t in arrivedCheckedList)
                    {
                        if (childrenList.Contains(t))
                        {
                            childrenList.Remove(t);
                            tree.ItemsSourceData.ElementAt <TreeModel>(0).Children.Add(t);
                        }
                    }
                }
                tree.tvZsmTree.BeginInit();
                tree.tvZsmTree.EndInit();
            }
            //取消所有勾选
            //修改UI表项
            foreach (ZsmTreeView[] trees in treeList)
            {
                trees[2].menuUnSelectAll_Click(null, null);
            }
            arrivedCheckedList.RemoveRange(0, arrivedCheckedList.Count());
        }
예제 #2
0
        private void label_send_MouseUp(object sender, MouseButtonEventArgs e)
        {
            // todo : 暂停timer
            runTimer.Enabled = false;
            //label_send.Background = new ImageBrush(new BitmapImage(
            //new Uri("res\\button\\send-hover.png", System.UriKind.Relative)));
            IntPtr      bitmap = global::Tracking.Properties.Resources.send_hover.GetHbitmap();
            ImageSource source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                bitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());

            label_send.Background = new ImageBrush(source);

            Distance[] Nodes = new Distance[RES.LOC_MAX];
            for (int i = 0; i < Nodes.Length; i++)
            {
                Nodes[i] = new Distance(i);
            }

            foreach (TreeModel t in sitCheckedList)
            {
                //写入数据库
                //DBO.newRecord(t.Name, t.src, t.src, 2);     //此处存疑,该表项表示发货但是仍未到达第一站
                //不需要写入数据库,实际发送操作有timer完成,这里只修改状态。
                //修改逻辑表,从勾选状态进入发送状态
                sendingList.Add(t);
            }
            //修改界面表,将之从仓库表移至运送中表
            //移除同样属于发送操作,交由timer完成。
            //修改UI表结构
            List <TreeModel> bills = new List <TreeModel>();

            foreach (ZsmTreeView[] trees in treeList)
            {
                ZsmTreeView tree = trees[0];
                tree.tvZsmTree.BeginInit();
                for (int i = 0; i < tree.ItemsSourceData.Count(); i++)
                {
                    IList <TreeModel> childrenList = tree.ItemsSourceData.ElementAt <TreeModel>(i).Children;
                    foreach (TreeModel t in sitCheckedList)
                    {
                        if (childrenList.Contains(t))
                        {
                            childrenList.Remove(t);
                            int dateIndex = trees[1].ItemsSourceData.Count();
                            while (dateIndex-- > 0)
                            {
                                TreeModel date2 = trees[1].ItemsSourceData.ElementAt <TreeModel>(dateIndex);
                                if (t.Parent.Name.Equals(date2.Name))
                                {
                                    break;
                                }
                            }
                            if (dateIndex == -1)
                            {
                                TreeModel newDate = new TreeModel(t.Parent.Name);
                                newDate.type     = TreeModel.DATE;
                                newDate.Children = new List <TreeModel>();
                                newDate.Children.Add(t);
                                trees[1].ItemsSourceData.Add(newDate);
                            }
                            else
                            {
                                trees[1].ItemsSourceData.ElementAt <TreeModel>(dateIndex).Children.Add(t);
                            }
                        }
                    }
                }
                tree.tvZsmTree.EndInit();
            }
            //取消所有勾选
            foreach (ZsmTreeView[] trees in treeList)
            {
                trees[0].menuUnSelectAll_Click(null, null);
            }
            //从逻辑表中移除他们
            sitCheckedList.RemoveRange(0, arrivedCheckedList.Count());
            // todo : 继续timer
            runTimer.Enabled = true;
        }
예제 #3
0
        private void OnTimerEvent(Object source, ElapsedEventArgs e)
        {
            this.Enabled = false;


            if (runningList.Count() <= 0)
            {
                return;
            }
            foreach (Distance d in nodes)
            {
                d.calcMinDistance();
            }
            List <TreeModel> toRemove = new List <TreeModel>();

            foreach (TreeModel t in runningList)
            {
                if (t.trackRoute == null)
                {
                    t.trackRoute = nodes[t.src].getNextNode(t.dst);
                }
                t.trackRoute.distance -= 100;
                if (t.trackRoute.distance <= 0)
                {
                    this.Enabled = false;
                    //到达目的地
                    if (t.trackRoute.next == t.dst)
                    {
                        NextNode n = t.trackRoute;
                        //写入数据库
                        DBO.newRecord(t.Name, t.trackRoute.current, t.trackRoute.next, RES.SENDING);
                        DBO.newRecord(t.Name, t.trackRoute.next, t.trackRoute.next, RES.ARRIVED);
                        //修改UI表项
                        ZsmTreeView currentTree = treeList[n.current][1];
                        ZsmTreeView nextTree    = treeList[n.next][2];
                        foreach (TreeModel dateNode in currentTree.ItemsSourceData)
                        {
                            if (dateNode.Children.Contains(t))
                            {
                                dateNode.Children.Remove(t);
                                IList <TreeModel> nextSource = nextTree.ItemsSourceData;
                                int dateIndex = nextSource.Count();
                                while (dateIndex-- > 0)
                                {
                                    TreeModel date2 = nextSource.ElementAt <TreeModel>(dateIndex);
                                    if (dateNode.Name.Equals(date2.Name))
                                    {
                                        break;
                                    }
                                }
                                if (dateIndex == -1)
                                {
                                    TreeModel newDate = new TreeModel(dateNode.Name);
                                    newDate.type     = TreeModel.DATE;
                                    newDate.Children = new List <TreeModel>();
                                    newDate.Children.Add(t);
                                    nextSource.Add(newDate);
                                }
                                else
                                {
                                    nextSource.ElementAt <TreeModel>(dateIndex).Children.Add(t);
                                }
                            }
                        }
                        toRemove.Add(t);
                        if (t.IsChecked)
                        {
                            context.moveToArrivedCheckedList(t);
                        }
                    }
                    //到达下一站
                    else
                    {
                        NextNode n = nodes[t.trackRoute.next].getNextNode(t.dst);
                        //写入数据库
                        DBO.newRecord(t.Name, t.trackRoute.current, t.trackRoute.next, RES.SENDING);
                        //修改UI表项
                        ZsmTreeView currentTree = treeList[n.current][1];
                        ZsmTreeView nextTree    = treeList[n.next][1];
                        foreach (TreeModel dateNode in treeList[t.trackRoute.current][1].ItemsSourceData)
                        {
                            if (dateNode.Children.Contains(t))
                            {
                                dateNode.Children.Remove(t);
                                IList <TreeModel> nextSource = treeList[t.trackRoute.next][1].ItemsSourceData;
                                int dateIndex = nextSource.Count();
                                while (dateIndex-- > 0)
                                {
                                    TreeModel date2 = nextSource.ElementAt <TreeModel>(dateIndex);
                                    if (dateNode.Name.Equals(date2.Name))
                                    {
                                        break;
                                    }
                                }
                                if (dateIndex == -1)
                                {
                                    TreeModel newDate = new TreeModel(dateNode.Name);
                                    newDate.type     = TreeModel.DATE;
                                    newDate.Children = new List <TreeModel>();
                                    newDate.Children.Add(t);
                                    nextSource.Add(newDate);
                                }
                                else
                                {
                                    nextSource.ElementAt <TreeModel>(dateIndex).Children.Add(t);
                                }
                            }
                        }
                        //进入下一节点
                        t.trackRoute = n;
                    }
                }
            }
            foreach (TreeModel t in toRemove)
            {
                runningList.Remove(t);
            }
            this.Enabled = true;
            foreach (ZsmTreeView[] trees in treeList)
            {
                foreach (ZsmTreeView tree in trees)
                {
                    sync.Post(context.startUpdateUI, tree);
                    sync.Post(context.endUpdateUI, tree);
                }
            }
        }