using System;
|
namespace Shared.SimpleControl.Phone
|
{
|
public class SystemCurtainRoller : FrameLayout
|
{
|
public VerticalScrolViewLayout VerticalScrolViewBottom;
|
|
public void SystemCurtainRollerShow (CurtainRoller curtainRoller, Common common)
|
{
|
#region top
|
RowLayout TopView = new RowLayout () {
|
Height = Application.GetRealHeight (100),
|
Width = LayoutParams.MatchParent,
|
BackgroundColor = SkinStyle.Current.ViewColor
|
};
|
AddChidren (TopView);
|
|
Button backButton = new Button () {
|
X = Application.GetRealWidth (0),
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (85),
|
UnSelectedImagePath = "Item/Back.png",
|
SelectedImagePath = "Item/BackSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
backButton.MouseUpEventHandler += (sender, e) => {
|
(Parent as PageLayout).PageIndex -= 1;
|
//SystemEquipmentBase.RefreshView (common);
|
};
|
TopView.AddChidren (backButton);
|
|
EditText textButton = new EditText () {
|
X = Application.GetRealWidth (4) + backButton.Right,
|
Height = Application.GetRealHeight (50),
|
Width = Application.GetRealWidth (400),
|
Text = curtainRoller.Name,
|
Gravity = Gravity.CenterVertical,
|
TextAlignment = TextAlignment.CenterLeft,
|
BackgroundColor = SkinStyle.Current.Transparent,
|
SelectedBackgroundColor = SkinStyle.Current.SysEditBox,
|
Enable = false,
|
TextColor = SkinStyle.Current.TextColor1
|
};
|
TopView.AddChidren (textButton);
|
|
Button editor = new Button () {
|
X = Application.GetRealWidth (520),
|
Height = Application.GetRealHeight (100),
|
Width = Application.GetRealWidth (67),
|
UnSelectedImagePath = "Item/Editor.png",
|
SelectedImagePath = "Item/EditorSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
if (common.isMixBox == false)
|
TopView.AddChidren (editor);
|
editor.MouseUpEventHandler += (sender, e) => {
|
if (editor.IsSelected) {
|
MainPage.Loading.Start ();
|
editor.IsSelected = textButton.IsSelected = textButton.Enable = false;
|
byte [] remakeBytes = CommonPage.MyEncodingGB2312.GetBytes (textButton.Text.Trim ());
|
System.Threading.Tasks.Task.Run (() => {
|
byte [] updateBytes = Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] {
|
curtainRoller.BigClass,curtainRoller.MinClass,curtainRoller.LoopID
|
});
|
if (updateBytes == null) {
|
Application.RunOnMainThread (() => {
|
new Alert ("", Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
MainPage.Loading.Hide ();
|
});
|
return;
|
}
|
byte [] uBytes = new byte [20];
|
Array.Copy (remakeBytes, 0, uBytes, 0, remakeBytes.Length < 20 ? remakeBytes.Length : 20);
|
Array.Copy (uBytes, 0, updateBytes, 3, 20 < uBytes.Length ? 20 : uBytes.Length);
|
var reBytes = Control.ControlBytesSendHasReturn (Command.SetDeviceLoopInfo, curtainRoller.SubnetID, curtainRoller.DeviceID, updateBytes);
|
if (reBytes != null) {
|
Application.RunOnMainThread (() => {
|
curtainRoller.Name = textButton.Text.Trim ();
|
IO.FileUtils.SaveEquipmentMessage (curtainRoller, curtainRoller.LoopID.ToString ());
|
MainPage.Loading.Hide ();
|
});
|
} else {
|
Application.RunOnMainThread (() => {
|
new Alert ("", Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
MainPage.Loading.Hide ();
|
});
|
}
|
});
|
} else {
|
textButton.Enable = textButton.IsSelected = editor.IsSelected = true;
|
}
|
};
|
|
#endregion
|
|
VerticalScrolViewBottom = new VerticalScrolViewLayout () {
|
Y = Application.GetRealHeight (100),
|
Height = Height - TopView.Height,
|
Width = LayoutParams.MatchParent,
|
BackgroundColor = SkinStyle.Current.ViewColor
|
};
|
|
AddChidren (VerticalScrolViewBottom);
|
#region ---测试电机方向---
|
Button btnMotorTravelDirection = new Button () {
|
Width = Application.GetRealWidth (400),
|
Height = Application.GetRealHeight (50),
|
X = Application.GetRealWidth (55),
|
Y = Application.GetRealHeight (20),
|
TextID = R.MyInternationalizationString.MotorTravelDirection,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
VerticalScrolViewBottom.AddChidren (btnMotorTravelDirection);
|
|
FrameLayout MotorRotationView = new FrameLayout () {
|
Height = Application.GetRealHeight (180),
|
};
|
VerticalScrolViewBottom.AddChidren (MotorRotationView);
|
|
Button MotorForward = new Button () {
|
Width = Application.GetRealWidth (130),
|
Height = Application.GetRealHeight (50),
|
X = Application.GetRealWidth (120),
|
Y = Application.GetRealHeight (20),
|
TextID = R.MyInternationalizationString.Up,
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
};
|
MotorRotationView.AddChidren (MotorForward);
|
MotorForward.MouseUpEventHandler += (sender, e) => {
|
MotorForward.IsSelected = false;
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] {
|
curtainRoller.LoopID, 0 });
|
};
|
MotorForward.MouseDownEventHandler += (sender, e) => {
|
MotorForward.IsSelected = true;
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] {
|
curtainRoller.LoopID, 1 });
|
};
|
|
Button MotorBackforward = new Button () {
|
Width = Application.GetRealWidth (130),
|
Height = Application.GetRealHeight (50),
|
X = MotorForward.Right + Application.GetRealWidth (130),
|
Y = Application.GetRealHeight (20),
|
TextID = R.MyInternationalizationString.Down,
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
};
|
MotorRotationView.AddChidren (MotorBackforward);
|
MotorBackforward.MouseUpEventHandler += (sender, e) => {
|
MotorBackforward.IsSelected = false;
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] {
|
curtainRoller.LoopID, 0 });
|
};
|
MotorBackforward.MouseDownEventHandler += (sender, e) => {
|
MotorBackforward.IsSelected = true;
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] {
|
curtainRoller.LoopID, 2});
|
};
|
|
Button btnMotorRotationChange = new Button () {
|
X = MotorForward.X,
|
Y = MotorForward.Bottom + Application.GetRealHeight (30),
|
Width = Application.GetRealWidth (390),
|
Height = Application.GetRealHeight (50),
|
TextID = R.MyInternationalizationString.SwicthingMotorRotation,
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
};
|
MotorRotationView.AddChidren (btnMotorRotationChange);
|
btnMotorRotationChange.MouseUpEventHandler += (sender, e) => {
|
btnMotorRotationChange.IsSelected = false;
|
};
|
btnMotorRotationChange.MouseDownEventHandler += (sender, e) => {
|
btnMotorRotationChange.IsSelected = true;
|
if (curtainRoller.MotorRotation == 1)
|
curtainRoller.MotorRotation = 0;
|
else
|
curtainRoller.MotorRotation = 1;
|
Console.WriteLine ("MotorRotation ==" + curtainRoller.MotorRotation.ToString ());
|
Control.ControlBytesSend (Command.CommandCurtainUserseting, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] { curtainRoller.MotorRotation, 0, 0, 0, 0, 0, 0, 0, 0 });
|
};
|
#endregion
|
|
#region
|
Button btnInitSetting = new Button () {
|
Width = Application.GetRealWidth (390),
|
Height = Application.GetRealHeight (50),
|
X = Application.GetRealWidth (55),
|
TextID = R.MyInternationalizationString.Initialinstallationsettings,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
VerticalScrolViewBottom.AddChidren (btnInitSetting);
|
|
FrameLayout InstallationView = new FrameLayout () {
|
Width = LayoutParams.MatchParent,
|
Height = Application.GetRealHeight (180),
|
};
|
VerticalScrolViewBottom.AddChidren (InstallationView);
|
|
Button btnInstallationDebugging = new Button () {
|
X = MotorForward.X,
|
Width = Application.GetRealWidth (390),
|
Height = Application.GetRealHeight (70),
|
TextID = R.MyInternationalizationString.InitializationSettings,
|
TextAlignment = TextAlignment.Center,
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
};
|
InstallationView.AddChidren (btnInstallationDebugging);
|
|
Button btnTipInit = new Button () {
|
X = MotorForward.X,
|
Width = Application.GetRealWidth (390),
|
Height = Application.GetRealHeight (40),
|
TextID = R.MyInternationalizationString.LongPressConfigurationHeight,
|
Visible = false,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
InstallationView.AddChidren (btnTipInit);
|
|
Button btnInitUp = new Button () {
|
Width = Application.GetMinRealAverage (170),
|
Height = Application.GetMinRealAverage (120),
|
X = Application.GetRealWidth (120),
|
Y = Application.GetRealHeight (50),
|
TextID = R.MyInternationalizationString.Up,
|
TextAlignment = TextAlignment.Center,
|
Enable = false,
|
Visible = false,
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 1,
|
Radius = 5,
|
};
|
InstallationView.AddChidren (btnInitUp);
|
|
Button btnInitDown = new Button () {
|
Width = Application.GetMinRealAverage (170),
|
Height = Application.GetMinRealAverage (120),
|
X = btnInitUp.Right + Application.GetRealWidth (50),
|
Y = Application.GetRealHeight (50),
|
TextID = R.MyInternationalizationString.Down,
|
TextAlignment = TextAlignment.Center,
|
Enable = false,
|
Visible = false,
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 1,
|
Radius = 5,
|
};
|
InstallationView.AddChidren (btnInitDown);
|
|
bool initOk = false;
|
btnInitUp.MouseDownEventHandler += (sender, e) => {
|
btnInitUp.IsSelected = true;
|
if (Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] { 1, 1 }) != null) {
|
|
}
|
};
|
btnInitUp.MouseUpEventHandler += (sender, e) => {
|
btnInitUp.IsSelected = false;
|
Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] { 33, 1 });
|
|
Dialog dialog = new Dialog () {
|
BackgroundColor = SkinStyle.Current.TextColor1,
|
Width = Application.GetRealWidth (480),
|
Height = Application.GetRealHeight (480),
|
};
|
int btnX = Application.GetRealWidth (420);
|
Button btnFineTuneTitle = new Button () {
|
Width = dialog.Width,
|
Height = Application.GetRealHeight (85),
|
BackgroundColor = SkinStyle.Current.TitileView,
|
TextID = R.MyInternationalizationString.FineTune,
|
TextAlignment = TextAlignment.Center,
|
Radius = 1,
|
};
|
dialog.AddChidren (btnFineTuneTitle);
|
Button btnFineTuneUp = new Button () {
|
X = Application.GetRealWidth (30),
|
Y = Application.GetRealHeight (125),
|
Width = btnX,
|
Height = Application.GetRealHeight (65),
|
TextID = R.MyInternationalizationString.Up,
|
TextAlignment = TextAlignment.Center,
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
};
|
dialog.AddChidren (btnFineTuneUp);
|
DateTime sendFlag = DateTime.MinValue;
|
btnFineTuneUp.MouseUpEventHandler += (sender2, e2) => {
|
btnFineTuneUp.IsSelected = false;
|
};
|
btnFineTuneUp.MouseDownEventHandler += (sender2, e2) => {
|
btnFineTuneUp.IsSelected = true;
|
System.Threading.Tasks.Task.Run (() => {
|
while (btnFineTuneUp.IsSelected) {
|
if ((DateTime.Now - sendFlag).TotalMilliseconds > 200) {
|
Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] { 33, 1 });
|
sendFlag = DateTime.Now;
|
}
|
}
|
});
|
};
|
Button btnFineTuneDown = new Button () {
|
X = Application.GetRealWidth (30),
|
Y = btnFineTuneUp.Y + btnFineTuneUp.Height + Application.GetRealHeight (50),
|
Width = btnX,
|
Height = Application.GetRealHeight (65),
|
TextID = R.MyInternationalizationString.Down,
|
TextAlignment = TextAlignment.Center,
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
};
|
dialog.AddChidren (btnFineTuneDown);
|
btnFineTuneDown.MouseUpEventHandler += (sender2, e2) => {
|
btnFineTuneDown.IsSelected = false;
|
};
|
btnFineTuneDown.MouseDownEventHandler += (sender2, e2) => {
|
btnFineTuneDown.IsSelected = true;
|
System.Threading.Tasks.Task.Run (() => {
|
while (btnFineTuneDown.IsSelected) {
|
if ((DateTime.Now - sendFlag).TotalMilliseconds > 200) {
|
Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] { 33, 2 });
|
sendFlag = DateTime.Now;
|
}
|
}
|
});
|
};
|
Button btnSave = new Button () {
|
Width = Application.GetRealWidth (480),
|
Height = Application.GetRealHeight (85),
|
BackgroundColor = SkinStyle.Current.TitileView,
|
Y = Application.GetRealHeight (480) - Application.GetRealHeight (85),
|
TextID = R.MyInternationalizationString.SAVE,
|
TextAlignment = TextAlignment.Center,
|
Radius = 1,
|
};
|
btnSave.MouseUpEventHandler += (s, e1) => {
|
var bytesRe = Control.ControlBytesSendHasReturn (Command.UpdataCurtainLocalFinish, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] { 3 });
|
if (bytesRe != null && bytesRe.Length >= 2) {
|
if (bytesRe != null) {
|
btnInitUp.Enable = false;
|
if (!initOk) {
|
initOk = true;
|
btnMotorTravelDirection.IsSelected = false;
|
} else {
|
Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] { 17, 238 });
|
btnInstallationDebugging.Enable = btnInstallationDebugging.Visible = true;
|
btnTipInit.Visible = btnInitUp.Enable = btnInitUp.Visible = btnInitDown.Enable = btnInitDown.Visible = false;
|
new Alert ("",
|
Language.StringByID (R.MyInternationalizationString.ThePerationWasSuccessful),
|
Language.StringByID (R.MyInternationalizationString.Confrim)).Show ();
|
initOk = false;
|
}
|
}
|
}
|
dialog.Close ();
|
};
|
dialog.AddChidren (btnSave);
|
dialog.Show ();
|
|
};
|
|
btnInitDown.MouseDownEventHandler += (sender, e) => {
|
btnInitDown.IsSelected = true;
|
if (Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] { 1, 2 }) != null) {
|
|
}
|
};
|
btnInitDown.MouseUpEventHandler += (sender, e) => {
|
btnInitDown.IsSelected = false;
|
Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] { 33, 2 });
|
Dialog dialog = new Dialog () {
|
BackgroundColor = SkinStyle.Current.TextColor1,
|
Width = Application.GetRealWidth (480),
|
Height = Application.GetRealHeight (480),
|
};
|
int btnX = Application.GetRealWidth (420);
|
Button btnFineTuneTitle = new Button () {
|
Width = dialog.Width,
|
Height = Application.GetRealHeight (85),
|
BackgroundColor = SkinStyle.Current.TitileView,
|
TextID = R.MyInternationalizationString.FineTune,
|
TextAlignment = TextAlignment.Center,
|
Radius = 1,
|
};
|
dialog.AddChidren (btnFineTuneTitle);
|
Button btnFineTuneUp = new Button () {
|
X = Application.GetRealWidth (30),
|
Y = Application.GetRealHeight (125),
|
Width = btnX,
|
Height = Application.GetRealHeight (65),
|
TextID = R.MyInternationalizationString.Up,
|
TextAlignment = TextAlignment.Center,
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
};
|
dialog.AddChidren (btnFineTuneUp);
|
DateTime sendFlag = DateTime.MinValue;
|
btnFineTuneUp.MouseUpEventHandler += (sender2, e2) => {
|
btnFineTuneUp.IsSelected = false;
|
};
|
btnFineTuneUp.MouseDownEventHandler += (sender2, e2) => {
|
btnFineTuneUp.IsSelected = true;
|
System.Threading.Tasks.Task.Run (() => {
|
while (btnFineTuneUp.IsSelected) {
|
if ((DateTime.Now - sendFlag).TotalMilliseconds > 200) {
|
Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] { 33, 1 });
|
sendFlag = DateTime.Now;
|
}
|
}
|
});
|
};
|
Button btnFineTuneDown = new Button () {
|
X = Application.GetRealWidth (30),
|
Y = btnFineTuneUp.Y + btnFineTuneUp.Height + Application.GetRealHeight (50),
|
Width = btnX,
|
Height = Application.GetRealHeight (65),
|
TextID = R.MyInternationalizationString.Down,
|
TextAlignment = TextAlignment.Center,
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
};
|
dialog.AddChidren (btnFineTuneDown);
|
btnFineTuneDown.MouseUpEventHandler += (sender2, e2) => {
|
btnFineTuneDown.IsSelected = false;
|
};
|
btnFineTuneDown.MouseDownEventHandler += (sender2, e2) => {
|
btnFineTuneDown.IsSelected = true;
|
System.Threading.Tasks.Task.Run (() => {
|
while (btnFineTuneDown.IsSelected) {
|
if ((DateTime.Now - sendFlag).TotalMilliseconds > 200) {
|
Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] { 33, 2 });
|
sendFlag = DateTime.Now;
|
}
|
}
|
});
|
};
|
Button btnSave = new Button () {
|
Width = Application.GetRealWidth (480),
|
Height = Application.GetRealHeight (85),
|
BackgroundColor = SkinStyle.Current.TitileView,
|
Y = Application.GetRealHeight (480) - Application.GetRealHeight (85),
|
TextID = R.MyInternationalizationString.SAVE,
|
TextAlignment = TextAlignment.Center,
|
Radius = 1,
|
};
|
btnSave.MouseUpEventHandler += (s, e1) => {
|
var bytesRe = Control.ControlBytesSendHasReturn (Command.UpdataCurtainLocalFinish, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] { 2 });
|
if (bytesRe != null && bytesRe.Length >= 2) {
|
if (bytesRe != null) {
|
btnInitDown.Enable = false;
|
if (!initOk) {
|
initOk = true;
|
btnMotorTravelDirection.IsSelected = false;
|
} else {
|
Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] { 17, 238 });
|
btnInstallationDebugging.Enable = btnInstallationDebugging.Visible = true;
|
btnTipInit.Visible = btnInitUp.Enable = btnInitUp.Visible = btnInitDown.Enable = btnInitDown.Visible = false;
|
new Alert ("",
|
Language.StringByID (R.MyInternationalizationString.ThePerationWasSuccessful),
|
Language.StringByID (R.MyInternationalizationString.Confrim)).Show ();
|
initOk = false;
|
}
|
}
|
}
|
dialog.Close ();
|
};
|
dialog.AddChidren (btnSave);
|
dialog.Show ();
|
};
|
|
|
btnInstallationDebugging.MouseUpEventHandler += (sender, e) => {
|
Alert alert = new Alert ("", Language.StringByID (R.MyInternationalizationString.TipInitializeSettings),
|
Language.StringByID (R.MyInternationalizationString.Cancel), Language.StringByID (R.MyInternationalizationString.Confrim));
|
alert.Show ();
|
alert.ResultEventHandler += (sender3, e3) => {
|
if (e3) {
|
var bytesRe = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] { 17, 238 });
|
if (bytesRe != null && bytesRe.Length >= 3) {
|
if (bytesRe != null) {
|
btnInstallationDebugging.Enable = btnInstallationDebugging.Visible = false;
|
btnTipInit.Visible = btnInitUp.Enable = btnInitUp.Visible = btnInitDown.Enable = btnInitDown.Visible = true;
|
|
} else {
|
new Alert ("", Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
}
|
}
|
}
|
};
|
|
};
|
#endregion
|
|
#region ---开关停测试---
|
Button TextRunTest = new Button () {
|
Width = Application.GetRealWidth (600),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (55),
|
TextID = R.MyInternationalizationString.Test,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
VerticalScrolViewBottom.AddChidren (TextRunTest);
|
|
FrameLayout ControlCurtainView = new FrameLayout () {
|
Width = LayoutParams.MatchParent,
|
Height = Application.GetRealHeight (200),
|
};
|
VerticalScrolViewBottom.AddChidren (ControlCurtainView);
|
|
Button btnControlUp = new Button () {
|
Width = Application.GetMinRealAverage (124),
|
Height = Application.GetMinRealAverage (124),
|
X = Application.GetRealWidth (90),
|
UnSelectedImagePath = "Curtain/CurtainRollerUp.png",
|
SelectedImagePath = "Curtain/CurtainRollerUpOn.png",
|
};
|
ControlCurtainView.AddChidren (btnControlUp);
|
Button btnUpLbl = new Button () {
|
Width = Application.GetMinRealAverage (124),
|
Height = Application.GetRealHeight (30),
|
X = Application.GetRealWidth (90),
|
Y = btnControlUp.Bottom,
|
TextID = R.MyInternationalizationString.Up,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
ControlCurtainView.AddChidren (btnUpLbl);
|
|
Button btnStopCurtain = new Button () {
|
Width = Application.GetMinRealAverage (124),
|
Height = Application.GetMinRealAverage (124),
|
X = btnControlUp.Right + Application.GetRealWidth (40),
|
UnSelectedImagePath = "Curtain/CurtainTimeOut.png",
|
SelectedImagePath = "Curtain/CurtainTimeOutSelected.png",
|
};
|
ControlCurtainView.AddChidren (btnStopCurtain);
|
Button btnStopLbl = new Button () {
|
Width = Application.GetMinRealAverage (124),
|
Height = Application.GetRealHeight (30),
|
X = btnControlUp.Right + Application.GetRealWidth (40),
|
Y = btnStopCurtain.Bottom,
|
TextID = R.MyInternationalizationString.Stop,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
ControlCurtainView.AddChidren (btnStopLbl);
|
|
Button btnCurtainDown = new Button () {
|
Width = Application.GetMinRealAverage (124),
|
Height = Application.GetMinRealAverage (124),
|
X = btnStopCurtain.Right + Application.GetRealWidth (40),
|
UnSelectedImagePath = "Curtain/CurtainRollerDown.png",
|
SelectedImagePath = "Curtain/CurtainRollerDownOn.png",
|
};
|
ControlCurtainView.AddChidren (btnCurtainDown);
|
Button btnDownLbl = new Button () {
|
Width = Application.GetMinRealAverage (124),
|
Height = Application.GetRealHeight (30),
|
X = btnStopCurtain.Right + Application.GetRealWidth (40),
|
Y = btnCurtainDown.Bottom,
|
TextID = R.MyInternationalizationString.Down,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
ControlCurtainView.AddChidren (btnDownLbl);
|
|
btnCurtainDown.MouseDownEventHandler += (sender3, e3) => {
|
CurtainControl (curtainRoller, 2);
|
btnStopCurtain.IsSelected = false;
|
btnCurtainDown.IsSelected = true;
|
btnControlUp.IsSelected = false;
|
};
|
btnCurtainDown.MouseUpEventHandler += (sender3, e3) => {
|
btnStopCurtain.IsSelected = false;
|
btnCurtainDown.IsSelected = false;
|
btnControlUp.IsSelected = false;
|
};
|
btnControlUp.MouseDownEventHandler += (sender3, e3) => {
|
CurtainControl (curtainRoller, 1);
|
btnStopCurtain.IsSelected = false;
|
btnCurtainDown.IsSelected = false;
|
btnControlUp.IsSelected = true;
|
};
|
btnControlUp.MouseUpEventHandler += (sender3, e3) => {
|
btnStopCurtain.IsSelected = false;
|
btnCurtainDown.IsSelected = false;
|
btnControlUp.IsSelected = false;
|
};
|
btnStopCurtain.MouseDownEventHandler += (sender3, e3) => {
|
CurtainControl (curtainRoller, 0);
|
btnStopCurtain.IsSelected = true;
|
btnCurtainDown.IsSelected = false;
|
btnControlUp.IsSelected = false;
|
};
|
btnStopCurtain.MouseUpEventHandler += (sender3, e3) => {
|
btnStopCurtain.IsSelected = false;
|
btnCurtainDown.IsSelected = false;
|
btnControlUp.IsSelected = false;
|
};
|
#endregion
|
}
|
|
static void CurtainControl (CurtainRoller curtainRoller, byte status)
|
{
|
byte [] usefulBytes = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtainRoller.SubnetID, curtainRoller.DeviceID, new byte [] {
|
curtainRoller.LoopID,
|
status
|
});
|
|
if (usefulBytes == null) {
|
Application.RunOnMainThread (() => {
|
new Alert ("", Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
});
|
} else {
|
curtainRoller.Status = (CurtainStatus)status;
|
IO.FileUtils.SaveEquipmentMessage (curtainRoller, curtainRoller.LoopID.ToString ());
|
}
|
}
|
}
|
}
|