using System; using System.Collections.Generic; namespace Shared.SimpleControl.Pad { public class URLMonitor : Shared.Dialog { string type = "URL"; public URLMonitor () { backNoticeObject = this; BackgroundColor = 0xFF2f2f2f; showVideoMonitoring (); } static URLMonitor backNoticeObject; static void backNotice () { if (backNoticeObject != null) { backNoticeObject.Close (); } new MonitorType ().Show (); } void showVideoMonitoring () { #region 标题 var topView = new FrameLayout () { Height = Application.GetRealHeight (150), BackgroundColor = 0xff000000, }; AddChidren (topView); var title = new Button () { TextAlignment = TextAlignment.Center, Text = Language.StringByID (R.MyInternationalizationString.VideoMonitoring), TextSize = 19, Y = Application.GetRealHeight (10), }; topView.AddChidren (title); var back = new Button () { Height = Application.GetRealHeight (90), Width = Application.GetRealWidth (85), UnSelectedImagePath = "Item/Back.png", SelectedImagePath = "Item/BackSelected.png", Y = Application.GetRealHeight (35), X = Application.GetRealWidth (10), }; topView.AddChidren (back); back.MouseUpEventHandler += (sender, e) => { Close (); }; var btnl = new Button () { Height = 1, BackgroundColor = 0xFF2F2F2F, Y = topView.Height - 1 }; topView.AddChidren (btnl); #endregion #region monitorAdd var monitorAdd = new Button () { X = Application.GetRealWidth (1893), Y = Application.GetRealHeight (30), Width = Application.GetMinReal (85), Height = Application.GetMinReal (100), Text = "+", TextSize = 30, TextColor = 0xffffffff, }; topView.AddChidren (monitorAdd); monitorAdd.MouseUpEventHandler += (sender, e) => { addURLMonitor (showVideoMonitoring, null); }; #endregion #region URL var VerticalScrolViewMiddle = new VerticalScrolViewLayout () { Y = topView.Bottom, Height = Application.GetRealHeight (Application.DesignHeight - 150), BackgroundColor = 0xff2c2d2f, }; AddChidren (VerticalScrolViewMiddle); FrameLayout RowView = new FrameLayout () { Height = Application.GetRealHeight (1300 / 2), }; VerticalScrolViewMiddle.AddChidren (RowView); int monitorIndex = 0; foreach (var monitorFilePath in MonitorInfo.FilePathList) { var monitorInfo = MonitorInfo.GetMonitorByFilePath (monitorFilePath); if (null == monitorInfo) { continue; } VerticalScrolViewMiddle.AddChidren (new Button () { Height = Application.GetRealHeight (11), BackgroundColor = 0xFF000000, }); if (monitorIndex != 0 && monitorIndex % 2 == 0) { RowView = new FrameLayout () { Height = Application.GetRealHeight (1386 / 2), }; VerticalScrolViewMiddle.AddChidren (RowView); VerticalScrolViewMiddle.AddChidren (new Button () { Height = Application.GetRealHeight (28), BackgroundColor = 0xFF000000, }); } else if (monitorIndex != 0 && monitorIndex % 2 == 1) { RowView.AddChidren (new Button () { X = Application.GetRealWidth (1000), Width = Application.GetRealWidth (28), BackgroundColor = 0xFF000000 }); } monitorIndex++; var cameraView = new FrameLayout () { X = monitorIndex % 2 == 1 ? 0 : Application.GetRealWidth (1028), Width = Application.GetRealWidth (1000), BackgroundColor = 0x66323232, BackgroundImagePath = "Monitor/Monitor_door.png", }; RowView.AddChidren (cameraView); var btnName = new Button () { Width = LayoutParams.MatchParent, Height = Application.GetRealHeight (120), Text = monitorFilePath.Split ('_') [1], TextAlignment = TextAlignment.Center, BackgroundColor = 0x99323232, }; cameraView.AddChidren (btnName); var monitorSet = new Button () { Width = Application.GetRealWidth (78), Height = Application.GetRealHeight (78), UnSelectedImagePath = "Monitor/Monitor_edit.png", SelectedImagePath = "Monitor/Monitor_edit_on.png", Y = Application.GetRealHeight (40), X = Application.GetRealWidth (850), }; cameraView.AddChidren (monitorSet); monitorSet.MouseUpEventHandler += (sender1, e1) => { addURLMonitor (showVideoMonitoring, monitorFilePath); }; var urlMonitor = new UrlMonitor () { UserName = monitorInfo.UserName, Password = monitorInfo.Password, URL = monitorInfo.URL, }; var monitorPlay = new Button () { Width = Application.GetRealHeight (139 * 2), Height = Application.GetRealHeight (139 * 2), UnSelectedImagePath = "Monitor/Monitor_play.png", SelectedImagePath = "Monitor/Monitor_play_on.png", Gravity = Gravity.Center, }; cameraView.AddChidren (monitorPlay); monitorPlay.MouseDownEventHandler += (sender, e) => { monitorPlay.IsSelected = true; }; monitorPlay.MouseUpEventHandler += (sender, e) => { monitorPlay.IsSelected = false; urlMonitor.RemoveFromParent (); Shared.Dialog diaLog = new Dialog (); diaLog.Show (); diaLog.AddChidren (urlMonitor); var dialogFrameLayout = new FrameLayout () { Width = Application.GetRealWidth (59), Height = Application.GetRealHeight (70), BackgroundColor = 0x22ff0000, X = Application.GetRealWidth (1880), Y = Application.GetRealHeight (1447), }; diaLog.AddChidren (dialogFrameLayout); var tempBack = new Button { Width = Application.GetRealWidth (39), Height = Application.GetRealHeight (50), UnSelectedImagePath = "Monitor/Monitor_close.png", SelectedImagePath = "Monitor/Monitor_close_on.png", X = Application.GetRealWidth (9), Y = Application.GetRealHeight (10), }; dialogFrameLayout.AddChidren (tempBack); tempBack.MouseDownEventHandler += (sender1, e1) => { tempBack.IsSelected = true; diaLog.Close (); }; tempBack.MouseUpEventHandler += (sender1, e1) => { tempBack.IsSelected = false; }; urlMonitor.Start (); }; } #endregion } /// /// 添加或修改摄像头 /// void addURLMonitor (Action showMonitorList, string monitorFilePath = "") { var monitorInfo = MonitorInfo.GetMonitorByFilePath (monitorFilePath); if (null == monitorInfo) { monitorInfo = new MonitorInfo (); } #region SetMonitor var dialog = new Dialog () { Width = Application.GetRealWidth (600), Height = Application.GetRealHeight (550), }; var bodyView = new FrameLayout () { BackgroundColor = 0xF0F5F6F9, Radius = 5, BorderWidth = 1, BorderColor = 0xFF575757, }; dialog.AddChidren (bodyView); var btnTitle1 = new Button () { Height = Application.GetRealHeight (80), BackgroundColor = 0xF04a4849, TextID = R.MyInternationalizationString.URLCameraInfomation, TextAlignment = TextAlignment.Center, Gravity = Gravity.CenterHorizontal, }; bodyView.AddChidren (btnTitle1); var dialogFrameLayout = new FrameLayout () { Width = Application.GetRealWidth (520 + 80), Height = Application.GetRealHeight (390), Y = btnTitle1.Bottom, }; bodyView.AddChidren (dialogFrameLayout); var btnCameraName = new Button () { Width = Application.GetRealWidth (110 + 80), Height = Application.GetRealHeight (60), X = Application.GetRealWidth (20), Y = Application.GetRealHeight (20), TextAlignment = TextAlignment.CenterLeft, TextColor = 0xff1d1d1d, TextID = R.MyInternationalizationString.PleaseEnterMonitorName }; dialogFrameLayout.AddChidren (btnCameraName); var etName = new EditText () { Y = btnCameraName.Y, X = btnCameraName.Right + Application.GetRealWidth (10), Width = Application.GetRealWidth (340), Height = Application.GetRealHeight (60), Radius = 3, BorderColor = 0xF0CDCDCD, TextColor = 0xff1d1d1d, BorderWidth = 1, Text = monitorInfo.Name, TextAlignment = TextAlignment.Center, }; dialogFrameLayout.AddChidren (etName); var btnURL = new Button () { Width = Application.GetRealWidth (110 + 80), Height = Application.GetRealHeight (60), X = Application.GetRealWidth (20), Y = etName.Bottom + Application.GetRealHeight (40), TextID = R.MyInternationalizationString.URL, TextAlignment = TextAlignment.CenterLeft, TextColor = 0xff1d1d1d, }; dialogFrameLayout.AddChidren (btnURL); var etURL = new EditText () { Y = btnURL.Y - Application.GetRealHeight (20), X = btnURL.Right + Application.GetRealWidth (10), Width = Application.GetRealWidth (340), Height = Application.GetRealHeight (110), Radius = 3, BorderColor = 0xF0CDCDCD, TextColor = 0xff1d1d1d, BorderWidth = 1, TextAlignment = TextAlignment.Center, Text = monitorInfo.URL, //Text = "http://192.168.2.210/tmpfs/auto.jpg", }; dialogFrameLayout.AddChidren (etURL); var btnUserName = new Button () { Width = Application.GetRealWidth (110 + 80), Height = Application.GetRealHeight (60), X = Application.GetRealWidth (20), Y = etURL.Bottom + Application.GetRealHeight (20), TextAlignment = TextAlignment.CenterLeft, TextSize = 13, TextColor = 0xff1d1d1d, TextID = R.MyInternationalizationString.UserName, }; dialogFrameLayout.AddChidren (btnUserName); var etUserName = new EditText () { Y = btnUserName.Y, X = btnUserName.Right + Application.GetRealWidth (10), Width = Application.GetRealWidth (340), Height = Application.GetRealHeight (60), Radius = 3, BorderColor = 0xF0CDCDCD, TextColor = 0xff1d1d1d, BorderWidth = 1, TextAlignment = TextAlignment.Center, Text = monitorInfo.UserName, //Text = "admin" }; dialogFrameLayout.AddChidren (etUserName); var btnPassword = new Button () { Width = Application.GetRealWidth (110 + 80), Height = Application.GetRealHeight (60), X = Application.GetRealWidth (20), Y = btnUserName.Bottom + Application.GetRealHeight (20), TextAlignment = TextAlignment.CenterLeft, TextSize = 13, TextColor = 0xff1d1d1d, TextID = R.MyInternationalizationString.PASSWORD, }; dialogFrameLayout.AddChidren (btnPassword); var etPassword = new EditText () { Y = btnPassword.Y, X = btnPassword.Right + Application.GetRealWidth (10), Width = Application.GetRealWidth (340), Height = Application.GetRealHeight (60), Radius = 3, BorderColor = 0xF0CDCDCD, TextColor = 0xff1d1d1d, BorderWidth = 1, TextAlignment = TextAlignment.Center, Text = monitorInfo.Password, //Text = "admin" }; dialogFrameLayout.AddChidren (etPassword); var BottomView = new FrameLayout () { Width = LayoutParams.MatchParent, Height = Application.GetRealHeight (90), BackgroundColor = 0xF0121212, Y = dialog.Height - Application.GetRealHeight (89), }; bodyView.AddChidren (BottomView); var btnBack = new Button () { Width = Application.GetRealWidth (119), Height = LayoutParams.MatchParent, UnSelectedImagePath = "Item/PositioningDialogBack.png", SelectedImagePath = "Item/PositioningDialogBack.png", }; BottomView.AddChidren (btnBack); btnBack.MouseUpEventHandler += (sender1, e1) => { dialog.Close (); }; var btnLineH = new Button () { Width = 1, Height = LayoutParams.MatchParent, BackgroundColor = 0xF02c2c2c, X = btnBack.Right, }; BottomView.AddChidren (btnLineH); var btnSave = new Button () { Width = Application.GetRealWidth (400), Height = LayoutParams.MatchParent, X = btnLineH.Right, TextID = R.MyInternationalizationString.SAVE, TextAlignment = TextAlignment.Center, Radius = 1, }; BottomView.AddChidren (btnSave); //可修改的摄像头 if (!string.IsNullOrEmpty (monitorFilePath)) { btnTitle1.TextID = R.MyInternationalizationString.ChangeInformation; btnSave.Width = Application.GetRealWidth (200); var btnLineH2 = new Button () { Width = 1, Height = LayoutParams.MatchParent, BackgroundColor = 0xF02c2c2c, X = btnSave.Right, }; BottomView.AddChidren (btnLineH2); var btnDel = new Button () { Width = Application.GetRealWidth (199), Height = btnBack.Height, X = btnLineH2.Right, Y = btnBack.Y, TextID = R.MyInternationalizationString.Delete, TextAlignment = TextAlignment.Center, }; BottomView.AddChidren (btnDel); btnDel.MouseUpEventHandler += (sender, e) => { Alert alert = new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipDeleteRoomMessage), Language.StringByID (R.MyInternationalizationString.Cancel), Language.StringByID (R.MyInternationalizationString.Confrim)); alert.ResultEventHandler += (object sender2, bool e2) => { if (e2) { MonitorInfo.Remove (monitorFilePath); showVideoMonitoring (); dialog.Close (); } }; alert.Show (); }; } #endregion btnSave.MouseUpEventHandler += (sender1, e1) => { if (string.IsNullOrEmpty (etName.Text.Trim ()) || string.IsNullOrEmpty (etURL.Text.Trim ()) || string.IsNullOrEmpty (etUserName.Text.Trim ()) || string.IsNullOrEmpty (etPassword.Text.Trim ())) { new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PleaseWriteTheCompleteContent), Language.StringByID (R.MyInternationalizationString.Close)).Show (); return; } //if (string.IsNullOrEmpty (Monitor_Edit_Kuang.Text.Trim ())) { // new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.InputMonitorName), // Language.StringByID (R.MyInternationalizationString.Close)).Show (); return; //} //if (string.IsNullOrEmpty (Monitor_URC_kuang.Text.Trim ())) { // new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.InputURL), // Language.StringByID (R.MyInternationalizationString.Close)).Show (); // return; //} //if (string.IsNullOrEmpty (Monitor_UserName_kuang.Text.Trim ())) { // new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.InputUserName), // Language.StringByID (R.MyInternationalizationString.Close)).Show (); // return; //} //if (string.IsNullOrEmpty (Monitor_password_kuang.Text.Trim ())) { // new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.InputPassword), // Language.StringByID (R.MyInternationalizationString.Close)).Show (); return; //} string newMonitorFilePath = typeof (MonitorInfo).Name + "_" + etName.Text.Trim (); //string newMonitorFilePath = etName.Text.Trim (); monitorInfo.Name = etName.Text.Trim (); monitorInfo.URL = etURL.Text.Trim (); monitorInfo.Type = type; monitorInfo.UserName = etUserName.Text.Trim (); monitorInfo.Password = etPassword.Text.Trim (); //新建摄像头 if (string.IsNullOrEmpty (monitorFilePath)) { //新建摄像头但是摄像头名为空或者已经存在房摄像头名 if (IO.FileUtils.Exists (newMonitorFilePath)) { new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.HaveTheSame), Language.StringByID (R.MyInternationalizationString.Close)).Show (); return; } monitorInfo.Add (newMonitorFilePath); showMonitorList (); } else { //如果更改后的名称存在,就不允许保存 if (monitorFilePath != newMonitorFilePath && IO.FileUtils.Exists (newMonitorFilePath)) { new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.HaveTheSame), Language.StringByID (R.MyInternationalizationString.Close)).Show (); return; } monitorInfo.ReEdit (monitorFilePath, newMonitorFilePath); showMonitorList (); } dialog.Close (); }; dialog.Show (); } } }