Пример #1
0
        public T GetFieldValue <T>(string fieldName)
        {
            object val  = GetFieldValue(fieldName);
            Type   type = typeof(T);

            return((T)Common_liby.Convert2Type(type, val));
        }
Пример #2
0
 public static void CloseMsg()
 {
     Common_liby.InvokeMethodOnMainThread(() =>
     {
         HtmlPage.Window.Invoke("closemsg");
     });
 }
Пример #3
0
        public void DrawPolygon(LocationCollection locations, string msg)
        {
            currentLine = new List <UIElement>();
            Location lastLocation = locations.Last();

            _tag = Common_liby.GetGuidString();

            poly                 = new MapPolygon();
            poly.Locations       = locations;
            poly.StrokeThickness = 2;
            poly.Opacity         = 0.5;
            poly.Stroke          = new SolidColorBrush(Colors.Red);
            poly.Fill            = new SolidColorBrush(Color.FromArgb(200, 253, 128, 68));
            poly.StrokeLineJoin  = PenLineJoin.Round;
            lyr.Children.Add(poly);
            currentLine.Add(poly);

            foreach (Location location in locations)
            {
                AddToMapLayer(CreatePoint(), location, PositionOrigin.Center);
            }

            movePanel = CreatePanel(msg, "");
            AddToMapLayer(movePanel, lastLocation);

            var del = CreateDeleteButton();

            lyr.AddChild(del, lastLocation, new System.Windows.Point(-13, 6));
            currentLine.Add(del);
            dicLines.Add(_tag, currentLine);
        }
Пример #4
0
        public static void Msg(string message, MessageBoxIcon messageIcon = MessageBoxIcon.None, int durtime = 3000)
        {
            short icon = (short)messageIcon;

            Common_liby.InvokeMethodOnMainThread(() =>
            {
                HtmlPage.Window.Invoke("msg", message, icon, durtime);
            });
        }
Пример #5
0
        /// <summary>
        /// 复制一个对象
        /// </summary>
        /// <returns></returns>
        public new SLCar Copy()
        {
            SLCar copyCar = Common_liby.DeepCopy(this);

            if (copyCar != null)
            {
                copyCar._isCopy = true;
                if (copyCar.LastGpsData != null && copyCar.LastGpsData.IsRealTime)
                {
                    copyCar.LastGpsData.IsRealTime = false;
                }
            }
            return(copyCar);
        }
Пример #6
0
 /// <summary>
 /// 数据类型转换
 /// </summary>
 /// <param name="type">类型</param>
 /// <param name="val">数据值</param>
 /// <returns></returns>
 public static object Convert2Type(Type type, object val)
 {
     if (string.IsNullOrWhiteSpace(val?.ToString()) && type.IsValueType)
     {
         return(DBNull.Value);
     }
     //val = val.ToString();   //先转换成String类型再进行转换
     if (val is DBNull)
     {
         return(null);
     }
     else if (type == typeof(BoundaryPoint))
     {
         return(null);
     }
     else
     {
         return(Common_liby.Convert2Type(type, val));
     }
 }
Пример #7
0
        /// <summary>
        /// 数据绑定方法
        /// </summary>
        public void Bind(List <UNIT> units, List <SLCar> cars, bool isOilWell = false)
        {
            if (units != null && cars != null)
            {
                _checkedCars.Clear();
                SelectedCar = null;
                //var t= cars.First(x => string.IsNullOrWhiteSpace(x.LICENSE)); //调试用 找错误数据
                IEnumerable <SLCar> carlist = null;
                if (isOilWell)
                {
                    carlist = cars.Where(x => x.IS_POLL_OIL_SPOT == 1);
                }
                else
                {
                    carlist = cars.Where(x => x.IS_POLL_OIL_SPOT != 1);
                }
                List <UNIT> unitlist = units;

                _rootUnitData.BrowseMode = BrowseMode;  //浏览模式赋值
                _rootUnitData.gwcMode    = gwcMode;
                //DateTime time = DateTime.Now;
                _rootUnitData.FillData(unitlist, carlist);
                //double mis = (DateTime.Now - time).TotalMilliseconds;
                Common_liby.InvokeMethodOnMainThread(() =>
                {
                    tv.Items.Clear();
                    tv.ItemsSource = _rootUnitData.Items; //数据源设置
                    tv.Loaded     += (sender, e) =>
                    {
                        if (_rootUnitData.Items.Count == 1) //子节点只有一个
                        {
                            tv.ExpandToDepth(1);            //展开子节点
                        }
                    };
                });
            }
        }
Пример #8
0
 public SMSReturnCode(string returnStr)
 {
     if (!string.IsNullOrEmpty(returnStr))
     {
         ReturnString = returnStr;
         string[] tmp = returnStr.Split('/');
         ReturnArray = new string[tmp.Length - 1];
         if (ReturnArray.Length > 0)
         {
             Array.Copy(tmp, 1, ReturnArray, 0, ReturnArray.Length);
         }
         int  code = -100;
         bool suc  = Common_liby.IsNumricForInt(tmp[0]);
         if (suc)
         {
             if (int.TryParse(tmp[0], out code))
             {
                 ErrCode   = code;
                 ErrorCode = (IntCode)code;
             }
             IsSuccess = code == 0 || (suc && tmp.Length == 1);
         }
     }
 }
Пример #9
0
        /// <summary>
        /// 历史回放模式
        /// </summary>
        //public bool HistoryMode { get; set; }

        bool RefreshState(NEWTRACK gps, string fieldName = null, bool noWeb = false)
        {
            if (gps == null)
            {
                return(false);
            }

            CarStatus.RefreshStatus(gps.STATUS, gps.STOPTIME);  //车辆状态
            OnPropertyChanged(nameof(CarStatus), true);
            AlarmStatus.RefreshAlarmStatus(gps.ALARM);
            OnPropertyChanged(nameof(AlarmStatus), true);

            if (gps.IsRealTime || _isCopy || (!gps.IsRealTime && !_isCopy))
            {     //在线或者历史回放状态刷新
                if (!_isCopy && (CarStatus.offline == true || !gps.IsRealTime))
                { //车辆下线
                    CarState = CarState.OffLine;
                }
                else
                {
                    //在线状态下
                    if (AlarmStatus.HasAlarm)
                    {
                        //报警状态
                        CarState = CarState.Alarm;
                        if (!_isCopy)
                        {
                            OnHaveNewAlarm(AlarmType.Normal); //新的报警
                        }
                    }
                    else if (gps.LOCATE != 1) //不定位
                    {
                        CarState = CarState.NoGps;
                    }
                    else if (gps.SPEED >= 3)    //行驶中
                    {
                        CarState = CarState.Run;
                    }
                    else
                    {   //速度小于3km/h 认定为停车(可去除部分漂移)
                        CarState = CarState.Stop;
                    }
                }
            }
            else
            {
                //不在线状态判断
                CarState = CarState.OffLine;
            }

            if (noWeb)
            {
                return(true);
            }
            if (!gps.IsRealTime)
            {
                return(true);
            }
            if (CarStatus.blindarea_status)
            {
                return(true);
            }
            if (!NEWTRACK.IsWebPosition)
            {
                return(true);
            }
            if (!IsInView)
            {
                return(true);
            }
            if (!GPSTool.CheckLaLo(gps.LATITUDE, gps.LONGITUDE))
            {
                return(true);
            }

            GeoLatLng geo = GPSTool.wgs84togcj02(gps.LONGITUDE, gps.LATITUDE);

            geo.longitude = Math.Round(geo.longitude, 6);
            geo.latitude  = Math.Round(geo.latitude, 6);
            Common_liby.InvokeMethodOnMainThread(() =>
            {
                HtmlPage.Window.Invoke("GetWebPosition", geo.longitude, geo.latitude, MAC);
            });
            return(false);
        }
Пример #10
0
 /// <summary>
 /// 获得model类指定列名
 /// </summary>
 /// <typeparam name="Tmodel"></typeparam>
 /// <param name="exp"></param>
 /// <returns></returns>
 protected string FieldName(Expression <Func <Tmodel, object> > exp)
 {
     return(Common_liby.FieldName(exp));
 }
Пример #11
0
        public static void Show(string title, string message, MessageBoxIcon messageIcon, MessageBoxButton messageButton, Action okEvent = null, Action cancelEvent = null)
        {
            short icon = (short)messageIcon;

            if (icon < 0)
            {
                icon = 0;
            }

            StringBuilder btn = new StringBuilder("确定");

            if (messageButton == MessageBoxButton.OKCancel)
            {
                btn.AppendFormat(",{0}", "取消");
            }

            string token = null;

            if (okEvent != null || cancelEvent != null)
            {
                Action[] eventActions = new Action[2];
                if (okEvent != null)
                {
                    eventActions[0] = okEvent;
                }
                if (cancelEvent != null)
                {
                    eventActions[1] = cancelEvent;
                }

                token = Common_liby.GetGuidString();
                DicJsEventCallBack.Add(token, eventActions);
            }

            Common_liby.InvokeMethodOnMainThread(() =>
                                                 HtmlPage.Window.Invoke("lalert", title, message, icon, btn.ToString(), token));

            #region 旧版弹窗

            //if (_instance != null)
            //{
            //    _instance.Close();
            //    _instance = null;
            //}
            //Instance.Title = title;
            //Instance.TextMessage.Text = message;
            //Size fontSize = Common.MeasureString(message, Instance.TextMessage.FontFamily, Instance.TextMessage.FontSize);
            //double width = 10 + 50 + fontSize.Width + 22 + 10;
            //if (width < 177)
            //    width = 177;
            //Instance.Width = width;
            //double height = 28 + 13 + fontSize.Height < 30 ? 30 : fontSize.Height + 13 + 42;
            //if (height < 124)
            //    height = 124;
            //Instance.Height = height;
            //string imgurl = string.Format("/Images/icon_{0}.png", ((int)messageIcon).ToString("D2"));
            //Instance.ImageIcon.Source = new BitmapImage(new Uri(imgurl, UriKind.Relative));
            //if (messageButton == MessageBoxButton.OK)
            //{
            //    Instance.CancelButton.Visibility = Visibility.Collapsed;
            //    Instance.OKButton.Margin = Instance.CancelButton.Margin;
            //}
            //Instance.CancelButton.Focus();

            //Instance.Closed += (x, y) =>
            //{
            //    if (Instance.DialogResult == true)
            //    {
            //        Instance = null;
            //        if (okEvent != null)
            //            okEvent();
            //    }
            //    else
            //    {
            //        Instance = null;
            //        if (cancelEvent != null)
            //            cancelEvent();
            //    }
            //};
            //Instance.Show();

            #endregion
        }
Пример #12
0
 /// <summary>
 /// 数据类型转换
 /// </summary>
 /// <typeparam name="T">类型</typeparam>
 /// <param name="val">数据值</param>
 /// <returns></returns>
 public static T Convert2Type <T>(object val)
 {
     return(Common_liby.Convert2Type <T>(val));
 }