using System;
|
using System.Collections.Generic;
|
using HDL_ON.Common;
|
using HDL_ON.DAL.Server;
|
using HDL_ON.Entity;
|
using HDL_ON.UI.CSS;
|
using Shared;
|
namespace HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock
|
{
|
public class VideoDoorlockAudioSetupPage : FrameLayout
|
{
|
FrameLayout bodyView;
|
|
Function device;
|
/// <summary>
|
/// 门锁系统音量
|
/// </summary>
|
DoorLockSystemSound doorLockSystemSound;
|
/// <summary>
|
/// 门铃音量
|
/// </summary>
|
int doorbellVol = 0;
|
public VideoDoorlockAudioSetupPage(Function function)
|
{
|
doorLockSystemSound = new DoorLockSystemSound();
|
device = function;
|
bodyView = this;
|
}
|
|
public void LoadPage()
|
{
|
new TopViewDiv(bodyView, Language.StringByID(StringId.AudioSetup)).LoadTopView();
|
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
|
|
|
#region 门锁系统音量
|
var doorlockSystemVolumeView = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(64),
|
Height = Application.GetRealHeight(50),
|
BackgroundColor = CSS.CSS_Color.MainBackgroundColor,
|
};
|
bodyView.AddChidren(doorlockSystemVolumeView);
|
|
var btnDoorlockSystemVolumeRight = new Button()
|
{
|
X = Application.GetRealWidth(339),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage(16),
|
Height = Application.GetMinRealAverage(16),
|
UnSelectedImagePath = "Public/Right.png",
|
};
|
doorlockSystemVolumeView.AddChidren(btnDoorlockSystemVolumeRight);
|
|
var btnDoorlockSystemVolumeStateText = new Button()
|
{
|
X = Application.GetRealWidth(100),
|
Width = Application.GetRealWidth(223),
|
TextAlignment = TextAlignment.CenterRight,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextColor = CSS_Color.PromptingColor1,
|
};
|
doorlockSystemVolumeView.AddChidren(btnDoorlockSystemVolumeStateText);
|
|
var btnDoorlockSystemVolumeText = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextID = StringId.DoorlockSystemVolume,
|
};
|
doorlockSystemVolumeView.AddChidren(btnDoorlockSystemVolumeText);
|
|
btnDoorlockSystemVolumeText.MouseUpEventHandler = (sender, e) =>
|
{
|
LoadEditDialog(StringId.DoorlockSystemVolume, btnDoorlockSystemVolumeStateText,true);
|
};
|
#endregion
|
|
#region 门铃音量
|
var viewDoorbellVolume = new FrameLayout()
|
{
|
Y = doorlockSystemVolumeView.Bottom,
|
Height = Application.GetRealHeight(50),
|
BackgroundColor = CSS.CSS_Color.MainBackgroundColor,
|
};
|
bodyView.AddChidren(viewDoorbellVolume);
|
viewDoorbellVolume.AddChidren(new Button
|
{
|
Height = 1,
|
BackgroundColor = CSS_Color.DividingLineColor,
|
});
|
|
var btnDoorbellVolumeRight = new Button()
|
{
|
X = Application.GetRealWidth(339),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage(16),
|
Height = Application.GetMinRealAverage(16),
|
UnSelectedImagePath = "Public/Right.png",
|
};
|
viewDoorbellVolume.AddChidren(btnDoorbellVolumeRight);
|
|
var btnDoorbellVolumeStateText = new Button()
|
{
|
X = Application.GetRealWidth(100),
|
Width = Application.GetRealWidth(223),
|
TextAlignment = TextAlignment.CenterRight,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextColor = CSS_Color.PromptingColor1,
|
};
|
viewDoorbellVolume.AddChidren(btnDoorbellVolumeStateText);
|
|
var btnDoorbellVolumeText = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextID = StringId.DoorbellVolume,
|
};
|
viewDoorbellVolume.AddChidren(btnDoorbellVolumeText);
|
|
btnDoorbellVolumeText.MouseUpEventHandler = (sender, e) =>
|
{
|
LoadEditDialog(StringId.DoorbellVolume, btnDoorbellVolumeStateText,false);
|
|
};
|
#endregion
|
|
var waitPage = new Loading();
|
bodyView.AddChidren(waitPage);
|
waitPage.Start("");
|
|
new System.Threading.Thread(() => {
|
try
|
{
|
var pack = ApiUtlis.Ins.HttpRequest.GetDoorLockSystemSound(device.deviceId);
|
if (pack != null && pack.Code == StateCode.SUCCESS)
|
{
|
Application.RunOnMainThread(() =>
|
{
|
//更新界面
|
doorLockSystemSound = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLockSystemSound>(pack.Data.ToString());
|
if(doorLockSystemSound != null)
|
{
|
switch (doorLockSystemSound.sound)
|
{
|
case 0:
|
btnDoorlockSystemVolumeStateText.TextID = StringId.Mute;
|
break;
|
case 1:
|
btnDoorlockSystemVolumeStateText.TextID = StringId.Low;
|
break;
|
case 2:
|
btnDoorlockSystemVolumeStateText.TextID = StringId.Moderate;
|
break;
|
case 3:
|
btnDoorlockSystemVolumeStateText.TextID = StringId.High;
|
break;
|
}
|
}
|
});
|
}
|
else
|
{
|
//失败提示
|
Application.RunOnMainThread(() =>
|
{
|
|
if (string.IsNullOrEmpty(pack.message))
|
{
|
pack.message = Language.StringByID(StringId.OperationFailed);
|
}
|
{
|
var tip = new Tip()
|
{
|
MaxWidth = Application.GetRealWidth(300),
|
Text = $"{pack.message}({pack.Code})",
|
CloseTime = 3,
|
Direction = AMPopTipDirection.None
|
};
|
tip.Show(MainPage.BaseView);
|
}
|
});
|
}
|
|
|
pack = ApiUtlis.Ins.HttpRequest.GetDoorBellTone(device.deviceId);
|
if (pack != null && pack.Code == StateCode.SUCCESS)
|
{
|
Application.RunOnMainThread(() =>
|
{
|
//更新界面
|
var doorbellTone = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorBellTone>(pack.Data.ToString());
|
if (doorbellTone != null)
|
{
|
if (doorbellTone.volume == 0)
|
{
|
doorbellVol = 0;
|
btnDoorbellVolumeStateText.TextID = StringId.Mute;
|
}
|
else if (doorbellTone.volume > 0 && doorbellTone.volume < 35)
|
{
|
doorbellVol = 1;
|
btnDoorbellVolumeStateText.TextID = StringId.Low;
|
}
|
else if (doorbellTone.volume > 35 && doorbellTone.volume < 70)
|
{
|
doorbellVol = 2;
|
btnDoorbellVolumeStateText.TextID = StringId.Moderate;
|
}
|
else if (doorbellTone.volume > 70)
|
{
|
doorbellVol = 3;
|
btnDoorbellVolumeStateText.TextID = StringId.High;
|
}
|
}
|
});
|
}
|
else
|
{
|
//失败提示
|
Application.RunOnMainThread(() =>
|
{
|
if (string.IsNullOrEmpty(pack.message))
|
{
|
pack.message = Language.StringByID(StringId.OperationFailed);
|
}
|
{
|
var tip = new Tip()
|
{
|
MaxWidth = Application.GetRealWidth(300),
|
Text = $"{pack.message}({pack.Code})",
|
CloseTime = 3,
|
Direction = AMPopTipDirection.None
|
};
|
tip.Show(MainPage.BaseView);
|
}
|
});
|
}
|
|
|
}
|
catch (Exception ex)
|
{
|
MainPage.Log($"UnlockSettingPage error : {ex.Message}");
|
}
|
finally
|
{
|
Application.RunOnMainThread(() =>
|
{
|
waitPage.Hide();
|
});
|
}
|
|
})
|
{ IsBackground = true }.Start();
|
|
|
|
}
|
|
|
|
/// <summary>
|
/// 加载功能属性数据选择弹窗
|
/// </summary>
|
void LoadEditDialog(int titleId, Button btn,bool isDoorlockSystemVolume)
|
{
|
Button lastButton = new Button();
|
|
var lastText = "";
|
Dialog dialog = new Dialog();
|
|
var pView = new FrameLayout()
|
{
|
BackgroundColor = CSS_Color.DialogTransparentColor1,
|
};
|
dialog.AddChidren(pView);
|
|
var optionBaseView = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(579 - 50 * 4),
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth(343),
|
Height = Application.GetRealHeight(50 * 4 + 50),
|
AnimateSpeed = 0.3f,
|
Animate = Animate.DownToUp,
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
Radius = (uint)Application.GetRealWidth(12),
|
};
|
pView.AddChidren(optionBaseView);
|
|
var topView = new FrameLayout()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth(343),
|
Height = Application.GetRealHeight(50),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
Radius = (uint)Application.GetRealWidth(12),
|
};
|
optionBaseView.AddChidren(topView);
|
|
var btnTitle = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
TextAlignment = TextAlignment.Center,
|
Width = Application.GetRealWidth(150),
|
TextID = titleId,
|
IsBold = true,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
};
|
topView.AddChidren(btnTitle);
|
|
var btnCancel = new Button()
|
{
|
X = Application.GetRealWidth(21),
|
Width = Application.GetRealWidth(100),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.PromptingColor1,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextID = StringId.Cancel,
|
};
|
topView.AddChidren(btnCancel);
|
|
var btnConfrim = new Button()
|
{
|
X = Application.GetRealWidth(200),
|
Width = Application.GetRealWidth(120),
|
TextAlignment = TextAlignment.CenterRight,
|
TextColor = CSS_Color.MainColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextID = StringId.Complete,
|
};
|
topView.AddChidren(btnConfrim);
|
int index = 1;
|
var statusList = new List<string>
|
{
|
Language.StringByID(StringId.High),
|
Language.StringByID(StringId.Moderate),
|
Language.StringByID(StringId.Low),
|
Language.StringByID(StringId.Mute),
|
};
|
|
foreach (var m in statusList)
|
{
|
var row = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(50 * index),
|
Height = Application.GetRealHeight(50),
|
};
|
optionBaseView.AddChidren(row);
|
if (statusList.Count > index)
|
{
|
optionBaseView.AddChidren(new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = row.Bottom,
|
Width = Application.GetRealWidth(343),
|
BackgroundColor = CSS_Color.DividingLineColor,
|
Height = 1,
|
});
|
}
|
|
var btnChoose = new Button()
|
{
|
X = Application.GetRealWidth(303),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage(28),
|
Height = Application.GetMinRealAverage(28),
|
UnSelectedImagePath = "Public/ChooseIcon.png",
|
SelectedImagePath = "Public/ChooseOnIcon.png",
|
Tag = index - 1,
|
};
|
row.AddChidren(btnChoose);
|
if (isDoorlockSystemVolume) {//设置门锁系统音量
|
switch (doorLockSystemSound.sound)
|
{
|
case 0:
|
if (index == 3 + 1)
|
{
|
lastButton = btnChoose;
|
btnChoose.IsSelected = true;
|
}
|
break;
|
case 1:
|
if (index == 2 + 1)
|
{
|
lastButton = btnChoose;
|
btnChoose.IsSelected = true;
|
}
|
break;
|
case 2:
|
if (index == 1 + 1)
|
{
|
lastButton = btnChoose;
|
btnChoose.IsSelected = true;
|
}
|
break;
|
case 3:
|
if (index == 0 + 1)
|
{
|
lastButton = btnChoose;
|
btnChoose.IsSelected = true;
|
}
|
break;
|
}
|
}
|
else//设置门铃音量
|
{
|
switch (doorbellVol)
|
{
|
case 0:
|
if (index == 3 + 1)
|
{
|
lastButton = btnChoose;
|
btnChoose.IsSelected = true;
|
}
|
break;
|
case 1:
|
if (index == 2 + 1)
|
{
|
lastButton = btnChoose;
|
btnChoose.IsSelected = true;
|
}
|
break;
|
case 2:
|
if (index == 1 + 1)
|
{
|
lastButton = btnChoose;
|
btnChoose.IsSelected = true;
|
}
|
break;
|
case 3:
|
if (index == 0 + 1)
|
{
|
lastButton = btnChoose;
|
btnChoose.IsSelected = true;
|
}
|
break;
|
}
|
|
}
|
var btnPropertyTitle = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
Text = m
|
};
|
row.AddChidren(btnPropertyTitle);
|
|
btnPropertyTitle.MouseUpEventHandler = (sender, e) => {
|
if (btnChoose.IsSelected)
|
{
|
return;
|
}
|
btnChoose.IsSelected = true;
|
if (lastButton != null)
|
{
|
lastButton.IsSelected = false;
|
}
|
lastButton = btnChoose;
|
lastText = btnPropertyTitle.Text;
|
};
|
index++;
|
}
|
|
|
|
|
dialog.Show();
|
|
pView.MouseUpEventHandler = (sender, e) => {
|
dialog.Close();
|
};
|
|
btnCancel.MouseUpEventHandler = (sender, e) => {
|
dialog.Close();
|
};
|
btnConfrim.MouseUpEventHandler = (sender, e) => {
|
dialog.Close();
|
var lastData = lastButton.Tag.ToString();
|
|
if (isDoorlockSystemVolume)
|
{
|
|
var waitPage = new Loading();
|
bodyView.AddChidren(waitPage);
|
waitPage.Start("");
|
new System.Threading.Thread(() => {
|
try
|
{
|
int sound = 0;
|
/// 0-静音 1-低音 2-中音 3-高音 4-自动
|
|
switch (lastData)
|
{
|
case "0":
|
sound = 3;
|
break;
|
case "1":
|
sound = 2;
|
break;
|
case "2":
|
sound = 1;
|
break;
|
case "3":
|
sound = 0;
|
break;
|
}
|
|
|
var pack = ApiUtlis.Ins.HttpRequest.SetDoorLockSystemSound(device.deviceId,sound);
|
if (pack != null && pack.Code == StateCode.SUCCESS)
|
{
|
Application.RunOnMainThread(() =>
|
{
|
//更新界面
|
switch (sound)
|
{
|
case 0:
|
doorLockSystemSound.sound = 0;
|
btn.TextID = StringId.Mute;
|
break;
|
case 1:
|
doorLockSystemSound.sound = 1;
|
btn.TextID = StringId.Low;
|
break;
|
case 2:
|
doorLockSystemSound.sound = 2;
|
btn.TextID = StringId.Moderate;
|
break;
|
case 3:
|
doorLockSystemSound.sound = 3;
|
btn.TextID = StringId.High;
|
break;
|
}
|
});
|
}
|
else
|
{
|
//失败提示
|
Application.RunOnMainThread(() =>
|
{
|
if (string.IsNullOrEmpty(pack.message))
|
{
|
pack.message = Language.StringByID(StringId.OperationFailed);
|
}
|
{
|
var tip = new Tip()
|
{
|
MaxWidth = Application.GetRealWidth(300),
|
Text = $"{pack.message}({pack.Code})",
|
CloseTime = 3,
|
Direction = AMPopTipDirection.None
|
};
|
tip.Show(MainPage.BaseView);
|
}
|
});
|
}
|
|
}
|
catch (Exception ex)
|
{
|
MainPage.Log($"{this.GetType()} error 4: {ex.Message}");
|
}
|
finally
|
{
|
Application.RunOnMainThread(() =>
|
{
|
waitPage.Hide();
|
});
|
}
|
|
})
|
{ IsBackground = true }.Start();
|
|
|
|
}
|
else
|
{
|
|
var waitPage = new Loading();
|
bodyView.AddChidren(waitPage);
|
waitPage.Start("");
|
|
new System.Threading.Thread(() => {
|
try
|
{
|
int Vol = 0;
|
switch (lastData)
|
{
|
case "0":
|
Vol = 100;
|
break;
|
case "1":
|
Vol = 70;
|
break;
|
case "2":
|
Vol = 30;
|
break;
|
case "3":
|
Vol = 0;
|
break;
|
}
|
|
var pack = ApiUtlis.Ins.HttpRequest.SetDoorBellTone(device.deviceId,Vol);
|
if (pack != null && pack.Code == StateCode.SUCCESS)
|
{
|
Application.RunOnMainThread(() =>
|
{
|
//更新界面
|
switch (lastData)
|
{
|
case "0":
|
doorbellVol = 3;
|
btn.TextID = StringId.High;
|
break;
|
case "1":
|
doorbellVol = 2;
|
btn.TextID = StringId.Moderate;
|
break;
|
case "2":
|
doorbellVol = 1;
|
btn.TextID = StringId.Low;
|
break;
|
case "3":
|
doorbellVol = 0;
|
btn.TextID = StringId.Mute;
|
break;
|
}
|
});
|
}
|
else
|
{
|
//失败提示
|
Application.RunOnMainThread(() =>
|
{
|
if (string.IsNullOrEmpty(pack.message))
|
{
|
pack.message = Language.StringByID(StringId.OperationFailed);
|
}
|
{
|
var tip = new Tip()
|
{
|
MaxWidth = Application.GetRealWidth(300),
|
Text = $"{pack.message}({pack.Code})",
|
CloseTime = 3,
|
Direction = AMPopTipDirection.None
|
};
|
tip.Show(MainPage.BaseView);
|
}
|
});
|
}
|
|
|
}
|
catch (Exception ex)
|
{
|
MainPage.Log($"{this.GetType()} error 5 : {ex.Message}");
|
}
|
finally
|
{
|
Application.RunOnMainThread(() =>
|
{
|
waitPage.Hide();
|
});
|
}
|
|
})
|
{ IsBackground = true }.Start();
|
|
|
|
}
|
};
|
|
}
|
|
|
|
|
|
}
|
|
/// <summary>
|
/// 门锁系统声音
|
/// </summary>
|
public class DoorLockSystemSound
|
{
|
/// <summary>
|
/// 声音
|
/// 0-静音 1-低音 2-中音 3-高音 4-自动
|
/// </summary>
|
public int sound = 0;
|
}
|
/// <summary>
|
/// 门铃提示音量
|
/// </summary>
|
public class DoorBellTone
|
{
|
/// <summary>
|
/// 音量 范围0-100
|
/// </summary>
|
public int volume = 0;
|
}
|
|
|
|
}
|