New file |
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | | using ZigBee.Device;
|
| | |
|
| | | namespace Shared.Phone.UserCenter.HideOption
|
| | | {
|
| | | /// <summary>
|
| | | /// 隐匿功能的网关文件列表界面
|
| | | /// </summary>
|
| | | public class HideOptionGatewayListFileForm : EditorCommonForm
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 网关对象
|
| | | /// </summary>
|
| | | private ZbGateway zbGateway = null;
|
| | | private BottomClickButton btnDelete = null;
|
| | | private List<string> listDeleteFile = new List<string>();
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | /// <param name="i_gateway"></param>
|
| | | public void ShowForm(ZbGateway i_gateway)
|
| | | {
|
| | | HdlFileLogic.Current.CreateDirectory(System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, "MyTempDir"), true);
|
| | | this.zbGateway = i_gateway;
|
| | | //设置标题信息
|
| | | base.SetTitleText("网关文件列表");
|
| | | //初始化中部控件
|
| | | this.InitMiddleFrame();
|
| | |
|
| | | var btnButton = new NormalViewControl(300, 69, true);
|
| | | btnButton.Gravity = Gravity.CenterVertical;
|
| | | btnButton.X = bodyFrameLayout.Width - Application.GetRealWidth(300) - ControlCommonResourse.XXLeft;
|
| | | btnButton.TextColor = UserCenterColor.Current.TopLayoutTitleText;
|
| | | btnButton.TextAlignment = TextAlignment.CenterRight;
|
| | | btnButton.TextSize = 17;
|
| | | btnButton.Text = "一键删除";
|
| | | topFrameLayout.AddChidren(btnButton);
|
| | | btnButton.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | btnDelete.Visible = true;
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化中部控件
|
| | | /// </summary>
|
| | | private void InitMiddleFrame()
|
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | var listview = new VerticalListControl(29);
|
| | | listview.Height = bodyFrameLayout.Height;
|
| | | listview.BackgroundColor = UserCenterColor.Current.White;
|
| | | bodyFrameLayout.AddChidren(listview);
|
| | |
|
| | | this.ShowProgressBar();
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | var result = await zbGateway.FileTransferLsDirAsync();
|
| | |
|
| | | this.CloseProgressBar();
|
| | | if (result == null || result.fileTransferLsDiResponseData == null)
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Tip, "获取列表失败,网关没有回复");
|
| | | return;
|
| | | }
|
| | | if (result.fileTransferLsDiResponseData.Result != 0)
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Tip, "查看失败,好像网关不允许查看这个目录");
|
| | | return;
|
| | | }
|
| | |
|
| | | var listFile = new List<string>();
|
| | | foreach (var data in result.fileTransferLsDiResponseData.Dir)
|
| | | {
|
| | | string[] strArry = data.File.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | listFile.Add(strArry[strArry.Length - 1]);
|
| | | }
|
| | | listFile.Sort();
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | foreach (var fileName in listFile)
|
| | | {
|
| | | var rowContr1 = new RowLayoutControl(listview.rowSpace / 2);
|
| | | listview.AddChidren(rowContr1);
|
| | | rowContr1.frameTable.AddLeftCaption(fileName, 700);
|
| | | rowContr1.frameTable.AddBottomLine();
|
| | |
|
| | | var btnSelect = new IconViewControl(58);
|
| | | btnSelect.UnSelectedImagePath = "Item/ItemSelected.png";
|
| | | btnSelect.Gravity = Gravity.Center;
|
| | | rowContr1.frameTable.AddChidren(btnSelect);
|
| | | btnSelect.Visible = false;
|
| | |
|
| | | var btnDelete = rowContr1.AddDeleteControl();
|
| | | btnDelete.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Confirm, "是否删除网关的这个文件(需谨慎)", async () =>
|
| | | {
|
| | | var result9 = await zbGateway.DelFileOrDirAsync("/etc/hdlDat/" + fileName);
|
| | | if (result9 == null || result9.delFileOrDirResponseData == null)
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Tip, "删除文件失败,网关没有回复");
|
| | | return;
|
| | | }
|
| | | if (result9.delFileOrDirResponseData.Result == 1)
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Tip, "删除文件失败,网关说这个东西不存在");
|
| | | return;
|
| | | }
|
| | | if (result9.delFileOrDirResponseData.Result == 2)
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Tip, "删除文件失败,网关说这个东西不允许删除");
|
| | | return;
|
| | | }
|
| | | if (result9.delFileOrDirResponseData.Result != 0)
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Tip, "删除文件失败,无法识别的状态码(" + result9.delFileOrDirResponseData.Result + ")");
|
| | | return;
|
| | | }
|
| | | rowContr1.RemoveFromParent();
|
| | | this.ShowMassage(ShowMsgType.Tip, "删除文件成功");
|
| | | });
|
| | | };
|
| | | }
|
| | |
|
| | | listview.AdjustRealHeightByBottomButton(Application.GetRealHeight(23));
|
| | |
|
| | | this.btnDelete = new BottomClickButton();
|
| | | btnDelete.Text = "删除";
|
| | | bodyFrameLayout.AddChidren(btnDelete);
|
| | | btnDelete.Visible = false;
|
| | | btnDelete.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Confirm, "确定是否删除这些文件?",async () =>
|
| | | {
|
| | | foreach (var listfile in this.listDeleteFile)
|
| | | {
|
| | | var result9 = await zbGateway.DelFileOrDirAsync("/etc/hdlDat/" + listfile);
|
| | | if (result9 == null || result9.delFileOrDirResponseData == null)
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Tip, "删除文件失败,网关没有回复");
|
| | | this.InitMiddleFrame();
|
| | | this.listDeleteFile = new List<string>();
|
| | | return;
|
| | | }
|
| | | if (result9.delFileOrDirResponseData.Result == 1)
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Tip, "删除文件失败,网关说这个东西不存在");
|
| | | this.InitMiddleFrame();
|
| | | this.listDeleteFile = new List<string>();
|
| | | return;
|
| | | }
|
| | | if (result9.delFileOrDirResponseData.Result == 2)
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Tip, "删除文件失败,网关说这个东西不允许删除");
|
| | | this.InitMiddleFrame();
|
| | | this.listDeleteFile = new List<string>();
|
| | | return;
|
| | | }
|
| | | if (result9.delFileOrDirResponseData.Result != 0)
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Tip, "删除文件失败,无法识别的状态码(" + result9.delFileOrDirResponseData.Result + ")");
|
| | | this.InitMiddleFrame();
|
| | | this.listDeleteFile = new List<string>();
|
| | | return;
|
| | | }
|
| | | }
|
| | | this.InitMiddleFrame();
|
| | | this.listDeleteFile = new List<string>();
|
| | | });
|
| | | };
|
| | | });
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 界面关闭___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 界面关闭
|
| | | /// </summary>
|
| | | public override void CloseFormBefore()
|
| | | {
|
| | | HdlFileLogic.Current.DeleteDirectory(System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, "MyTempDir"));
|
| | | |
| | | base.CloseFormBefore();
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|