Пример #1
0
        /// <summary>
        /// 生成轨迹记录
        /// </summary>
        private void MarkTracking()
        {
            var model = new TruckTrackingModel();

            model.TruckNo      = "001";
            model.TruckNum     = "sdfsdfdfs";
            model.ListPoint    = GetCTLine();
            truckTrackingModel = model;

            ContainerTruckDot ct = new ContainerTruckDot();

            canvasRoot.Children.Add(ct);
            this.ct = ct;

            //生成所有的轨迹线,先隐藏
            Line line = null;

            for (int i = 1; i < model.ListPoint.Count; i++)
            {
                line            = MakeLine(model.ListPoint[i - 1].Value, model.ListPoint[i].Value);
                line.Visibility = Visibility.Collapsed;
                canvasRoot.Children.Add(line);
                Lines.Add(new KeyValuePair <DateTime, Line>(model.ListPoint[i].Key, line));
            }

            ucSlider.Slider.Maximum = progressMaxnum = (truckTrackingModel.EndTime - truckTrackingModel.StartTime).TotalSeconds;
        }
Пример #2
0
        /// <summary>
        /// 设置集卡位置
        /// </summary>
        /// <param name="ct">集卡</param>
        /// <param name="point">比例坐标</param>
        private void SetCTPostion(ContainerTruckDot ct, Point point)
        {
            var newX = point.X * canvasRoot.ActualWidth - ct.ActualWidth / 2;
            var newY = point.Y * canvasRoot.ActualHeight - ct.ActualHeight / 2;

            ct.X = newX;
            ct.Y = newY;
        }
Пример #3
0
        private void StartNewTask()
        {
            ContainerTruckDot ct = new ContainerTruckDot();

            canvasRoot.Children.Add(ct);
            Task.Factory.StartNew(() =>
            {
                var model       = new TruckTrackingModel();
                model.TruckNo   = "001";
                model.TruckNum  = "sdfsdfdfs";
                model.ListPoint = GetCTLine();
                var listPath    = model.ListPoint;
                Point tempPoint = new Point();

                for (int i = 0; i < listPath.Count; i++)
                {
                    var item = listPath[i].Value;

                    if (tempPoint.X == 0 || tempPoint.Y == 0)
                    {
                        tempPoint = item;
                    }

                    this.Dispatcher.Invoke(new Action(() =>
                    {
                        var newX = item.X * canvasRoot.ActualWidth - ct.ActualWidth / 2;
                        var newY = item.Y * canvasRoot.ActualHeight - ct.ActualHeight / 2;

                        //if (ShowTracking && tempPoint != item)
                        //{
                        //    var line = new Line();
                        //    line.X1 = tempPoint.X * canvasRoot.ActualWidth;
                        //    line.Y1 = tempPoint.Y * canvasRoot.ActualHeight;
                        //    line.X2 = item.X * canvasRoot.ActualWidth;
                        //    line.Y2 = item.Y * canvasRoot.ActualHeight;
                        //    line.Stroke = Brushes.Red;
                        //    line.StrokeThickness = 1;
                        //    {
                        //        canvasRoot.Children.Add(line);
                        //        Lines.Add(new KeyValuePair<DateTime, Line>(listPath[i].Key, line));
                        //    }
                        //}
                        ct.X = newX;
                        ct.Y = newY;
                    }));
                    Thread.Sleep(1 * 30);
                    tempPoint = item;
                }
            });
        }