wxr
2021-03-31 3532db3610381f37eca1a6ac783d882517847c91
HDL_ON/UI/UI2/FuntionControlView/Video/MainView.cs
@@ -1,17 +1,28 @@
using System;
using HDL_ON.UI.Music;
using System.Collections.Generic;
using Shared;
using HDL_ON.Stan;
using ZXing.QrCode.Internal;
using static HDL_ON.UI.UI2.FuntionControlView.Video.VideoMethod;
namespace HDL_ON.UI.UI2.FuntionControlView.Video
{
    public class MainView : FrameLayout
    {
        public void Show()
        /// <summary>
        /// 加载可视对讲UI
        /// </summary>
        /// <param name="listVideo">门口机列表</param>
        /// <param name="listCall">通话记录列表</param>
        /// <param name="video">当前的可视对讲</param>
        public void Show(List<VideoMethod.FlVideo> listVideo, List<CallView> listCall, VideoClouds video)
        {
            #region 布局界面
            this.BackgroundColor = MusicColor.ViewColor;
            var topView = new TopView();
            this.AddChidren(topView.TopFLayoutView());
            topView.topNameBtn.Text = "可视对讲";
            topView.topNameBtn.TextID = StringId.keshiduijiang;
            topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
            {
                RemoveFromParent();
@@ -28,8 +39,8 @@
            pageView.AddChidren(view1);
            var view2 = new FrameLayout();
            pageView.AddChidren(view2);
            View1(view1);
            View2(view2);
            View1(view1, listVideo, video);
            View2(view2, listCall, video);
            Button btn11 = new Button
            {
                X = Application.GetRealWidth(170),
@@ -78,22 +89,25 @@
                if (pageView.PageIndex == 0)
                {
                    topView.topNameBtn.Text = "可视对讲";
                    topView.topNameBtn.TextID = StringId.keshiduijiang;
                }
                else
                {
                    topView.topNameBtn.Text = "通话记录";
                    topView.topNameBtn.TextID = StringId.tonghuajilu;
                }
            };
            #endregion
        }
        /// <summary>
        /// 第一个界面
        /// </summary>
        /// <param name="view1">父控件</param>
        void View1(FrameLayout view1)
        /// <param name="list">门口机列表</param>
        /// <param name="videoClouds">当前的可视对讲</param>
        void View1(FrameLayout view1, List<VideoMethod.FlVideo> list, VideoClouds videoClouds)
        {
            #region 布局界面
            var bjFl = new FrameLayout
            {
                Y = Application.GetRealHeight(24),
@@ -115,7 +129,8 @@
                TextColor = MusicColor.MusicTxet14Color,
                TextSize = TextSize.Text24,
                TextAlignment = TextAlignment.CenterLeft,
                Text = "可视对讲",
                //Text = "可视对讲",
                TextID = StringId.keshiduijiang,
            };
            bjFl.AddChidren(nameBtn);
            /// <summary>
@@ -146,7 +161,7 @@
                SelectedImagePath = "MusicIcon/collectSelected.png",
            };
            bjFl.AddChidren(collectIconBtn);
            ///可视对讲图标
            Button intercomBtnIcon = new Button
            {
                X = Application.GetRealWidth(84),
@@ -158,24 +173,30 @@
            };
            bjFl.AddChidren(intercomBtnIcon);
            var vv = new VerticalScrolViewLayout {
            var vv = new VerticalScrolViewLayout
            {
                Y = Application.GetRealHeight(306),
                Height = Application.GetRealHeight(220),
                Width = Application.GetRealWidth(327),
            };
            bjFl.AddChidren(vv);
            if (list.Count > 0)
            {
                //门禁二维码固定有的,虚拟一个出来
                list.Add(new VideoMethod.FlVideo { aliasName =Language.StringByID(StringId.menjinerweima), devType = "100" });
            }
            //数组个数
            int value = 15;
            //int value = 15;
            //先计算数据所需要的很高度;
            int l = 0;
            if (value % 3 == 0)
            if (list.Count % 3 == 0)
            {
                l = value / 3;
                l = list.Count / 3;
            }
            else
            {
                l = (value / 3) + 1;
                l = (list.Count / 3) + 1;
            }
            var fL = new FrameLayout
            {
@@ -184,8 +205,11 @@
            };
            vv.AddChidren(fL);
            int line = 0;
            for (int i = 1, j = 0; i <= value; i++, j++)
            #endregion
            for (int i = 1, j = 0; i <= list.Count; i++, j++)
            {
                var video = list[i - 1];
                #region
                var fLayout = new FrameLayout
                {
                    Width = Application.GetRealWidth(50),
@@ -205,7 +229,7 @@
                };
                fLayout.AddChidren(iconBtn);
                var iconNameBtn = new Button
                var deviceNameBtn = new Button
                {
                    Y = iconBtn.Bottom + Application.GetRealHeight(6),
                    Width = Application.GetRealWidth(50),
@@ -213,11 +237,12 @@
                    TextSize = TextSize.Text10,
                    TextColor = CSS.CSS_Color.TextualColor,
                    TextAlignment = TextAlignment.Center,
                    Text="查看单元机"
                    Text = video.aliasName,
                };
                fLayout.AddChidren(iconNameBtn);
                fLayout.AddChidren(deviceNameBtn);
                var clickBtn = new Button { Tag = i };
                var clickBtn = new Button { Tag = video };
                fLayout.AddChidren(clickBtn);
                if (i % 3 == 0)
                {
@@ -225,38 +250,42 @@
                    j = -1;
                    line += 1;
                }
                // GetIconAndText(i, deviceIconBtn, iconNameBtn);
                getIconAndText(video, iconBtn);
                #endregion
                //门口机的点击事件
                clickBtn.MouseUpEventHandler += (sender, e) =>
                {
                    var flVideo = clickBtn.Tag as VideoMethod.FlVideo;
                    if (flVideo.devType == "100")
                    {
                        //门禁二维码固定有的
                        VideoSend.GetQRcode(this, videoClouds, (tag, paw) =>
                        {
                            if (tag)
                            {
                                //注意:密码有可能延时1分钟生效
                                View.ShowDialog showDialog = new View.ShowDialog();
                                showDialog.QRcode(paw);
                            }
                        });
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(flVideo.uuid))
                        {
                            new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.peizhicanshuyouyichang));
                        }
                        ESVideoInfo eSVideoInfo = new ESVideoInfo
                        {
                            ESVideoUUID = getUuid(flVideo.uuid),
                            DeviceName = flVideo.aliasName,
                            roomno = videoClouds.flRoomId,
                            unitno = videoClouds.flBuildingId,
                        };
                        ESOnVideo.Current.ShowESVideoMonitor(eSVideoInfo);
                    }
                    ////1=空调;2=电视;3=风扇;4=机顶盒;5=DVD/EVD/VCD;6=投影仪;7=自定义;
                    //int if_value = int.Parse(clickBtn.Tag.ToString());
                    //if (if_value == 7)
                    //{
                    //    Method method = new Method();
                    //    method.AddControl(this, (control) =>
                    //    {
                    //        AddButton addButton = new AddButton();
                    //        MainPage.BasePageView.AddChidren(addButton);
                    //        addButton.Show(control);
                    //        MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                    //    });
                    //}
                    //else
                    //{
                    //    if (DeviceTypeList.Count == 0)
                    //    {
                    //        GetDeviceTypeList(true, () =>
                    //        {
                    //            DeviceTypeViewClick(if_value);
                    //        });
                    //    }
                    //    else
                    //    {
                    //        DeviceTypeViewClick(if_value);
                    //    }
                    //}
                };
            }
@@ -266,9 +295,11 @@
        /// 第二个界面
        /// </summary>
        /// <param name="view2">父控件</param>
        void View2(FrameLayout view2)
        /// <param name="listCall">通话记录列表</param>
        /// <param name="video">当前的可视对讲</param>
        void View2(FrameLayout view2, List<CallView> listCall, VideoClouds video)
        {
            var bjFl = new FrameLayout
            {
                Y = Application.GetRealHeight(24),
@@ -290,7 +321,7 @@
                TextColor = MusicColor.MusicTxet14Color,
                TextSize = TextSize.Text24,
                TextAlignment = TextAlignment.CenterLeft,
                Text = "通话记录",
                TextID = StringId.tonghuajilu,
            };
            bjFl.AddChidren(nameBtn);
            /// <summary>
@@ -305,11 +336,11 @@
                TextColor = MusicColor.SelectedColor,
                TextSize = TextSize.Text12,
                TextAlignment = TextAlignment.CenterLeft,
                Text = "*云端照片只保留30天"
                TextID = StringId.baolu30,
            };
            bjFl.AddChidren(regionBtn);
            var vv = new VerticalScrolViewLayout
            var vv = new VerticalRefreshLayout
            {
                X = Application.GetRealWidth(16),
                Y = Application.GetRealHeight(58),
@@ -317,24 +348,175 @@
                Width = Application.GetRealWidth(295),
            };
            bjFl.AddChidren(vv);
            for (int i = 0; i < 6; i++)
            vv.BeginHeaderRefreshingAction += () =>
            {
                if (i == 0|| i == 2)
                {
                    View.FrameLayout50 frameLayout50 = new View.FrameLayout50();
                    vv.AddChidren(frameLayout50.FLayoutView());
                }
                else
                {
                    View.FrameLayout60 frameLayout60 = new View.FrameLayout60();
                    vv.AddChidren(frameLayout60.FLayoutView());
                }
            }
                VideoMethod videoMethod = new VideoMethod();
                var list = videoMethod.getCall(video.id);
                RefreshView(vv, list);
                //关闭刷新View;
                vv.EndHeaderRefreshing();
            };
            RefreshView(vv, listCall);
        }
        /// <summary>
        /// 通话记录刷新界面
        /// </summary>
        /// <param name="vv">上下滑动控件</param>
        /// <param name="listCall">通话记录列表</param>
        public void RefreshView(VerticalRefreshLayout vv, List<CallView> listCall)
        {
            vv.RemoveAll();
            for (int i = 0; i < listCall.Count; i++)
            {
                var year = listCall[i];
                //年文本父控件
                View.FrameLayout50 frameLayout50 = new View.FrameLayout50();
                vv.AddChidren(frameLayout50.FLayoutView());
                frameLayout50.btnText.Text = year.year + Language.StringByID(StringId.nian);//年
                for (int j = 0; j < year.callList.Count; j++)
                {
                    var call = year.callList[j];
                    //门口机状态父控件
                    View.FrameLayout60 frameLayout60 = new View.FrameLayout60();
                    vv.AddChidren(frameLayout60.FLayoutView());
                    ///呼叫时间
                    frameLayout60.btnTime.Text = getTime(call.callTime);
                    ///呼叫状态(0:未接;1:已接;2:拒接);是否开锁;
                    frameLayout60.btnStateText.Text = getStateText(call.callStatus) + "," + getUnlockText(call.isUnlock);
                }
            }
        }
        /// <summary>
        /// 显示图标
        /// </summary>
        /// <param name="flVideo"></param>
        /// <param name="iconBtn">图标</param>
        private void getIconAndText(FlVideo flVideo, Button iconBtn)
        {
            //(1室内机,2室外机,3围墙机,4管理机,5二次确认机)
            string iconstr = "";
            switch (flVideo.devType)
            {
                case "1":
                    {
                        iconstr = "VideoIcon/danyuanji.png";
                    }
                    break;
                case "2":
                    {
                        iconstr = "VideoIcon/danyuanji.png";
                    }
                    break;
                case "3":
                    {
                        iconstr = "VideoIcon/weiqiangji.png";
                    }
                    break;
                case "4":
                    {
                        iconstr = "VideoIcon/weiqiangji.png";
                    }
                    break;
                case "5":
                    {
                        iconstr = "VideoIcon/weiqiangji.png";
                    }
                    break;
                case "100":
                    {
                        iconstr = "VideoIcon/menjin.png";
                    }
                    break;
                default:
                    {
                        iconstr = "VideoIcon/weiqiangji.png";
                    }
                    break;
            }
            iconBtn.UnSelectedImagePath = iconstr;
        }
        /// <summary>
        /// 获取显示时间文本
        /// </summary>
        /// <param name="str">utcTime</param>
        /// <returns></returns>
        private string getTime(string str)
        {
            var utcTime = Convert.ToDateTime(str);
            var dateTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, TimeZoneInfo.Local);
            return dateTime.ToString("HH") + ":" + dateTime.ToString("mm");
        }
        /// <summary>
        /// 获取呼叫状态文本
        /// </summary>
        /// <param name="str">状态值0:未接;1:已接;2:拒接</param>
        /// <returns></returns>
        private string getStateText(string str)
        {
            string s = "";
            switch (str)
            {
                case "0":
                    {
                        s = Language.StringByID(StringId.weijieting);
                    }
                    break;
                case "1":
                    {
                        Language.StringByID(StringId.yijieting);
                    }
                    break;
                case "2":
                    {
                        Language.StringByID(StringId.yijujue);
                    }
                    break;
            }
            return s;
        }
        /// <summary>
        /// 获取开锁状态文本
        /// </summary>
        /// <param name="if_bool"></param>
        /// <returns></returns>
        private string getUnlockText(bool if_bool)
        {
            string s = "";
            if (if_bool)
            {
                s = Language.StringByID(StringId.yikaisuo);
            }
            else
            {
                s = Language.StringByID(StringId.weikaisuo);
            }
            return s;
        }
        /// <summary>
        /// 获取uuid
        /// </summary>
        /// <param name="uuid"></param>
        /// <returns></returns>
        private string getUuid(string uuid)
        {
            if (uuid.Contains(","))
            {
                var uuid1 = uuid.Split(',');
                return uuid1[0];
            }
            else
            {
                return uuid;
            }
        }
    }
}