Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="thrift"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        async void GoNoTarget(ThirftService thrift, long startTime, long endTime)
        {
            List <TargetedAnalysis> formapResult     = new List <TargetedAnalysis>();
            IList <TmpSnapInfo>     forsuspectResult = new List <TmpSnapInfo>();

            SusipciousInfo = new CameraSnapPerson();

            await Task.Run(() =>
            {
                LoadingVisiblity = Visibility.Visible;
                OnPropertyChanged("LoadingVisiblity");

                formapResult     = formapResult = AsyncSelectNoTargetForMap(thrift, startTime, endTime).Result;
                forsuspectResult = AsyncSelectNoTargetForSusipcious(thrift, startTime, endTime).Result;
            });

            try
            {
                NoTargetControlContent.MainMap.Points =
                    GMapForWpf.SetMapAnchor <TargetedAnalysis>(formapResult,
                                                               new Uri("pack://application:,,,/Images/home-icon-bluecamera.png"));

                if (NoTargetControlContent.MainMap.Points.Count > 0)
                {
                    NoTargetControlContent.MainMap.CurrentPosition = NoTargetControlContent.MainMap.Points[NoTargetControlContent.MainMap.Points.Count - 1].Point;
                }
                else
                {
                    NoTargetControlContent.MainMap.CurrentPosition = new GMap.NET.PointLatLng(GlobalCache.Latitude, GlobalCache.Longitude);
                }

                if (forsuspectResult.Count > 0)
                {
                    var temp = tempSuspectObject;
                    //SusipciousInfo = temp;//给SusipciousInfo赋值,导致异常
                    if (temp.PhotoByteArray.Length == 0)
                    {
                        Dispatcher.CurrentDispatcher.Invoke(() =>
                        {
                            SusipciousInfo.Photo = ImageConvert.ToImageSource("pack://application:,,,/Images/unkonw.png");
                            OnPropertyChanged("SusipciousInfo");
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                Logger <MainControlViewModel> .Log.Error("GoNoTarget", ex);
            }
            finally
            {
                LoadingVisiblity = Visibility.Collapsed;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="thrift"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        async void GoTarget(ThirftService thrift, long startTime, long endTime)
        {
            try
            {
                ChartValues <double> chartVals = new ChartValues <double>();
                if (ForTargetPage != null && ForTargetPage.PhotoByteArray.Length > 0)
                {
                    await Task.Run(() =>
                    {
                        SnapPersonItems = AsyncGetTargetAnalysisResult(thrift, string.Empty, ForTargetPage.PhotoByteArray, -1, startTime, endTime).Result;
                    });

                    Parallel.Invoke(
                        () =>
                    {
                        ArrayList array = new ArrayList();
                        #region LiveCharts
                        for (int i = 0; i < 10; i++)
                        {
                            int count = SnapPersonItems.Count;
                            if (count > i)
                            {
                                chartVals.Add(Convert.ToDouble(SnapPersonItems[i].CameraInfo.SnapPersonCount));
                                array.Add(SnapPersonItems[i].Name);
                            }
                            else
                            {
                                chartVals.Add(0);
                                array.Add("区域" + i.ToString());
                            }
                        }

                        var s = Enumerable.Reverse <string>(array.Cast <string>().ToList());
                        CameraForLiveCharts = s.ToList();

                        ChartValues <double> cv = new ChartValues <double>();
                        for (int i = chartVals.Count - 1; i >= 0; i--)
                        {
                            cv.Add(chartVals[i]);
                        }

                        initBarCharts(false, cv);
                        #endregion
                    },
                        () =>
                    {
                    });

                    #region To map anchor

                    ObservableCollection <PointLatLngImg> Points = GMapForWpf.SetMapAnchor <CameraSnapPerson>(SnapPersonItems, ForTargetPage.PhotoByteArray, ForTargetPage.Name);
                    var p = Enumerable.Reverse <PointLatLngImg>(Points);

                    TargetControlContent.MainMap.Points = p as ObservableCollection <PointLatLngImg>;

                    if (TargetControlContent.MainMap.Points.Count > 0)
                    {
                        TargetControlContent.MainMap.CurrentPosition = TargetControlContent.MainMap.Points[TargetControlContent.MainMap.Points.Count - 1].Point;
                    }
                    else
                    {
                        TargetControlContent.MainMap.CurrentPosition = new GMap.NET.PointLatLng(GlobalCache.Latitude, GlobalCache.Longitude);
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                Logger <MainControlViewModel> .Log.Error("GoTarget", ex);
            }
            finally
            {
                LoadingVisiblity = Visibility.Collapsed;
            }
        }