wxr
2022-07-19 bb4bcd1b320502b36d19aacec52ed886a975249a
HDL_ON/UI/UI2/FuntionControlView/Video/VideoMainView.cs
@@ -5,11 +5,14 @@
using HDL_ON.Stan;
using ZXing.QrCode.Internal;
using static HDL_ON.UI.UI2.FuntionControlView.Video.VideoMethod;
using HDL_ON.UI.CSS;
namespace HDL_ON.UI.UI2.FuntionControlView.Video
{
    public class VideoMainView : FrameLayout
    {
        List<Video> xiMoVideoList = new List<Video>();
        /// <summary>
        /// 加载可视对讲UI
        /// </summary>
@@ -17,6 +20,7 @@
        /// <param name="videoList">可视对讲列表</param>
        public void Show(List<CallView> listCall, List<Video> videoList)
        {
            xiMoVideoList = videoList.FindAll((obj) => obj.spk == "door.gate");
            #region 布局界面
            this.BackgroundColor = MusicColor.ViewColor;
            var topView = new TopView();
@@ -198,11 +202,17 @@
            };
            bjFl.AddChidren(vv);
            bool bol = haveFlVideo(videoList);
            bool bol = haveQRCodeVideo(videoList);
            if (bol)
            {
                //门禁二维码固定有的,虚拟一个出来
                videoList.Add(new Video { deviceName = Language.StringByID(StringId.menjinerweima), interphoneType = "100" });
                videoList.Add(new Video { deviceName = Language.StringByID(StringId.menjinerweima), interphoneType = "100" ,devType = "100" });
            }
            if (xiMoVideoList.Count > 0)
            {
                //徘徊报警
                videoList.Add(new Video { deviceName = Language.StringByID(StringId.WanderingAlarm), interphoneType = "222", devType = "222" });
            }
            //数组个数
            //int value = 15;
@@ -277,16 +287,24 @@
                    var video2 = clickBtn.Tag as Video;
                    if (video2.devType == "100")
                    {
                        //门禁二维码固定有的
                        VideoSend.GetQRcode(this, video2, (tag, paw) =>
                        {
                            if (tag)
                            {
                                //注意:密码有可能延时1分钟生效
                                View.ShowDialog showDialog = new View.ShowDialog();
                                showDialog.QRcode(paw);
                            }
                        });
                        ChooseVideoShowQRCode();
                        ////门禁二维码固定有的
                        //VideoSend.GetQRcode(this, video2, (tag, paw) =>
                        //{
                        //    if (tag)
                        //    {
                        //        //注意:密码有可能延时1分钟生效
                        //        View.ShowDialog showDialog = new View.ShowDialog();
                        //        showDialog.QRcode(paw);
                        //    }
                        //});
                    }
                    else if (video2.devType == "222")
                    {
                        ChooseAlarmShow();
                    }
                    else
                    {
@@ -553,20 +571,273 @@
        //判断是否有 丰林可视对讲
        private bool haveFlVideo(List<Video> videoList)
        private bool haveQRCodeVideo(List<Video> videoList)
        {
            bool bol = false;
            for (int i = 0; i < videoList.Count; i++)
            {
                var _video = videoList[i];
                if (_video.interphoneType == "FLVI")
                if (_video.interphoneType == "FLVI" || _video.spk == "door.gate")
                    return true;
            }
            return bol;
        }
        /// <summary>
        /// 获取门禁二维码
        /// </summary>
        public void ChooseVideoShowQRCode()
        {
            Dialog dialog = new Dialog()
            {
                BackgroundColor = CSS_Color.DialogTransparentColor1,
            };
            FrameLayout dialogView = new FrameLayout();
            dialog.AddChidren(dialogView);
            dialogView.MouseUpEventHandler = (sender, e) => {
                dialog.Close();
            };
            var contentView = new FrameLayout()
            {
                Gravity = Gravity.Center,
                Width = Application.GetRealWidth(270),
                Height = Application.GetRealHeight(200),
                BackgroundColor = CSS_Color.MainBackgroundColor,
                BorderColor = 0x00000000,
                BorderWidth = 0,
                Radius = (uint)Application.GetMinRealAverage(10),
            };
            dialogView.AddChidren(contentView);
            var btnTitle = new Button()
            {
                Height = Application.GetRealHeight(64),
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextID = StringId.menjinerweima,
                TextSize = CSS_FontSize.SubheadingFontSize,
            };
            contentView.AddChidren(btnTitle);
            var listView = new VerticalScrolViewLayout()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(70),
                Width = Application.GetRealWidth(230),
                Height = Application.GetRealHeight(200),
            };
            contentView.AddChidren(listView);
            //if (ximoVideoList.Count == 1)
            {
                Loading loading = new Loading();
                contentView.AddChidren(loading);
                loading.Start("");
                new System.Threading.Thread(() =>
                {
                    try
                    {
                        var pack = VideoSend.GetQRcode();
                        var pairs = Newtonsoft.Json.JsonConvert.DeserializeObject<List<AccessControlQRode>>(pack.Data.ToString());
                        if (pairs.Count > 0)
                        {
                            Application.RunOnMainThread(() =>
                            {
                                ImageView codeImage = new ImageView()
                                {
                                    Gravity = Gravity.Center,
                                    Height = Application.GetRealWidth(320),
                                    Width = Application.GetRealWidth(320),
                                    ImageBytes = Scan.BytesFromText(pairs[0].qrcode, Application.GetRealWidth(200), Application.GetRealWidth(200)),
                                };
                                dialogView.AddChidren(codeImage);
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        MainPage.Log($"获取门禁二维码异常:{ex.Message}");
                    }
                    finally
                    {
                        Application.RunOnMainThread(() =>
                        {
                            if (loading != null)
                            {
                                loading.Hide();
                                loading.RemoveFromParent();
                            }
                        });
                    }
                })
                { IsBackground = true }.Start();
            }
            //else
            //{
            //    foreach (var v in ximoVideoList)
            //    {
            //        Button btnMsg = new Button()
            //        {
            //            Gravity = Gravity.CenterHorizontal,
            //            Height = Application.GetRealHeight(50),
            //            Width = Application.GetRealHeight(160),
            //            TextAlignment = TextAlignment.Center,
            //            TextColor = CSS_Color.TextualColor,
            //            TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
            //            Text = v.deviceName,
            //            Radius = (uint)Application.GetRealWidth(5),
            //            BackgroundColor = CSS_Color.DividingLineColor,
            //            IsMoreLines = true,
            //        };
            //        listView.AddChidren(btnMsg);
            //        listView.AddChidren(new Button() { Height = Application.GetRealHeight(12) });
            //        btnMsg.MouseUpEventHandler = (sender, e) =>
            //        {
            //            if (v.spk == "door.gate")
            //            {
            //                return;
            //            }
            //            //门禁二维码固定有的
            //            VideoSend.GetQRcode(this, v, (tag, paw) =>
            //            {
            //                if (tag)
            //                {
            //                //注意:密码有可能延时1分钟生效
            //                View.ShowDialog showDialog = new View.ShowDialog();
            //                    showDialog.QRcode(paw);
            //                }
            //            });
            //            dialog.Close();
            //        };
            //    }
            //}
            dialog.Show();
        }
        /// <summary>
        /// 选择徘徊报警列表显示
        /// </summary>
        public void ChooseAlarmShow()
        {
            if (xiMoVideoList.Count == 1)
            {
                var wanderingAlarmPage = new WanderingAlarmPage(xiMoVideoList[0].deviceId);
                MainPage.BasePageView.AddChidren(wanderingAlarmPage);
                wanderingAlarmPage.LoadPage();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            }
            else
            {
                Dialog dialog = new Dialog()
                {
                    BackgroundColor = CSS_Color.DialogTransparentColor1,
                };
                FrameLayout dialogView = new FrameLayout();
                dialog.AddChidren(dialogView);
                dialogView.MouseUpEventHandler = (sender, e) =>
                {
                    dialog.Close();
                };
                var contentView = new FrameLayout()
                {
                    Gravity = Gravity.Center,
                    Width = Application.GetRealWidth(270),
                    Height = Application.GetRealHeight(280),
                    BackgroundColor = CSS_Color.MainBackgroundColor,
                    BorderColor = 0x00000000,
                    BorderWidth = 0,
                    Radius = (uint)Application.GetMinRealAverage(10),
                };
                dialogView.AddChidren(contentView);
                var btnTitle = new Button()
                {
                    Height = Application.GetRealHeight(64),
                    TextAlignment = TextAlignment.Center,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    TextID = StringId.WanderingAlarm,
                    TextSize = CSS_FontSize.SubheadingFontSize,
                };
                contentView.AddChidren(btnTitle);
                var listView = new VerticalScrolViewLayout()
                {
                    Gravity = Gravity.CenterHorizontal,
                    Y = Application.GetRealHeight(70),
                    Width = Application.GetRealWidth(230),
                    Height = Application.GetRealHeight(200),
                };
                contentView.AddChidren(listView);
                foreach (var v in xiMoVideoList)
                {
                    Button btnMsg = new Button()
                    {
                        Gravity = Gravity.CenterHorizontal,
                        Height = Application.GetRealHeight(50),
                        Width = Application.GetRealHeight(160),
                        TextAlignment = TextAlignment.Center,
                        TextColor = CSS_Color.TextualColor,
                        TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                        Text = v.deviceName,
                        Radius = (uint)Application.GetRealWidth(5),
                        BackgroundColor = CSS_Color.DividingLineColor,
                        IsMoreLines = true,
                    };
                    listView.AddChidren(btnMsg);
                    listView.AddChidren(new Button() { Height = Application.GetRealHeight(12) });
                    btnMsg.MouseUpEventHandler = (sender, e) =>
                    {
                        var wanderingAlarmPage = new WanderingAlarmPage(v.deviceId);
                        MainPage.BasePageView.AddChidren(wanderingAlarmPage);
                        wanderingAlarmPage.LoadPage();
                        MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                        dialog.Close();
                    };
                }
                dialog.Show();
            }
        }
    }
    /// <summary>
    /// 门禁二维码数据
    /// </summary>
    public class AccessControlQRode
    {
        public string title = string.Empty;
        public string codeType = string.Empty;
        public string userName = string.Empty;
        public string houseFullName = string.Empty;
        public string communityName = string.Empty;
        public string desc = string.Empty;
        public string businessType = string.Empty;
        public string qrcode = string.Empty;
    }
}