From d6fb0646531172f23648441c224cdcccd721b894 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期一, 14 十二月 2020 09:59:01 +0800 Subject: [PATCH] 请合并代码,完成晾衣架最终功能。 --- ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionSearchAllFile.cs | 287 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 287 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionSearchAllFile.cs b/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionSearchAllFile.cs new file mode 100644 index 0000000..3e3b151 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionSearchAllFile.cs @@ -0,0 +1,287 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace Shared.Phone.UserCenter.HideOption +{ + /// <summary> + /// 鏌ョ湅鍏ㄩ儴鏂囦欢 + /// </summary> + public class HideOptionSearchAllFile : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 瑙e瘑 + /// </summary> + private bool decryptPassword = false; + private string nowDirectory = string.Empty; + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm(string directory) + { + this.nowDirectory = directory; + //璁剧疆澶撮儴淇℃伅 + base.SetTitleText("鏂囦欢鍒楄〃"); + + var btnButton = new NormalViewControl(200, 69, true); + btnButton.Gravity = Gravity.CenterVertical; + btnButton.X = bodyFrameLayout.Width - Application.GetRealWidth(200) - ControlCommonResourse.XXLeft; + btnButton.TextColor = UserCenterColor.Current.TopLayoutTitleText; + btnButton.TextAlignment = TextAlignment.BottomRight; + btnButton.TextSize = 17; + btnButton.Text = "缈昏瘧"; + topFrameLayout.AddChidren(btnButton); + btnButton.ButtonClickEvent += (sender, e) => + { + if (this.decryptPassword == false) + { + this.decryptPassword = true; + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(nowDirectory); + } + }; + + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(nowDirectory); + + this.BackButtonClickEvent = (btnContr) => + { + string rootPath = Shared.IO.FileUtils.RootPath.Trim('/'); + if (this.nowDirectory.Trim('/') == rootPath) + { + this.CloseForm(); + return; + } + string[] Arry = this.nowDirectory.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries); + string nextDir = string.Empty; + for (int i = 0; i < Arry.Length - 1; i++) + { + nextDir += Arry[i] + "/"; + } + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(nextDir); + }; + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame(string directory) + { + this.nowDirectory = directory; + this.ClearBodyFrame(); + + var listDirectory = new List<string>(); + var listAllFile = new List<string>(); + + //string rootPath = Shared.IO.FileUtils.RootPath.Trim('/'); + //if (this.nowDirectory.Trim('/') == rootPath) + //{ + // //鏍圭洰褰曞彧瑕佷袱涓氨鍙互浜� + // listDirectory.Add(Common.Config.Instance.Guid); + // listDirectory.Add(Application.Skin != null ? Application.Skin : "Phone"); + //} + //else + { + var files = System.IO.Directory.GetDirectories(directory); + foreach (var file in files) + { + string[] arry = file.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries); + listDirectory.Add(arry[arry.Length - 1]); + } + listDirectory.Sort(); + + listAllFile = HdlFileLogic.Current.GetFileFromDirectory(directory.TrimEnd('/')); + listAllFile.Sort(); + } + + var listView = new VerticalListControl(23); + listView.BackgroundColor = UserCenterColor.Current.White; + listView.Height = bodyFrameLayout.Height; + bodyFrameLayout.AddChidren(listView); + + if (listDirectory.Count > 0) + { + var row1 = new RowLayoutControl(listView.rowSpace / 2); + listView.AddChidren(row1); + row1.frameTable.UseClickStatu = false; + row1.frameTable.AddLeftCaption("銆愭枃浠跺す鍒楄〃銆�", 800); + + for (int i = 0; i < listDirectory.Count; i++) + { + this.AddDirectoryRowControl(listView, listDirectory[i], directory, i != listDirectory.Count - 1); + } + } + + if (listAllFile.Count > 0) + { + var row1 = new RowLayoutControl(listView.rowSpace / 2); + listView.AddChidren(row1); + row1.frameTable.UseClickStatu = false; + row1.frameTable.AddLeftCaption("銆愭枃浠跺垪琛ㄣ��", 800); + for (int i = 0; i < listAllFile.Count; i++) + { + this.AddFileRowControl(listView, listAllFile[i], directory, i != listAllFile.Count - 1); + } + } + listView.AdjustRealHeightByBottomButton(Application.GetRealHeight(50)); + + var btnButon = new BottomClickButton(); + btnButon.Text = "鍒犻櫎鏂囦欢澶�"; + bodyFrameLayout.AddChidren(btnButon); + btnButon.ButtonClickEvent += (sender, e) => + { + this.ShowMassage(ShowMsgType.Confirm, "鏄惁娓呴櫎璇ユ枃浠跺す", () => + { + try + { + System.IO.Directory.Delete(directory, true); + this.CloseForm(); + } + catch (Exception ex) + { + this.ShowMassage(ShowMsgType.Error, "娓呴櫎缂撳瓨鏂囦欢澶瑰紓甯�"); + HdlLogLogic.Current.WriteLog(ex, "娓呴櫎缂撳瓨鏂囦欢澶瑰紓甯�"); + } + }); + }; + if (directory == Common.Config.Instance.FullPath) + { + btnButon.CanClick = false; + } + } + + private void AddDirectoryRowControl(VerticalListControl listView, string directoryName, string directory, bool addLine) + { + string dirNewName = directoryName; + if (decryptPassword == true) + { + try + { + dirNewName = UserCenterLogic.DecryptPassword(UserCenterResourse.FileEncryptKey, directoryName); + } + catch { dirNewName = directoryName; } + } + + var row1 = new RowLayoutControl(listView.rowSpace / 2); + listView.AddChidren(row1); + var btnName = row1.frameTable.AddLeftCaption(dirNewName, 800); + btnName.IsMoreLines = true; + if (addLine == true) + { + row1.frameTable.AddBottomLine(); + } + row1.frameTable.AddRightArrow(); + + row1.frameTable.ButtonClickEvent += (sender, e) => + { + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.decryptPassword = false; + this.InitMiddleFrame(System.IO.Path.Combine(directory, directoryName)); + }; + } + + private void AddFileRowControl(VerticalListControl listView, string fileName, string directory, bool addLine) + { + string fileNewName = fileName; + if (decryptPassword == true && fileName.StartsWith("Device_") == false) + { + try + { + fileNewName = UserCenterLogic.DecryptPassword(UserCenterResourse.FileEncryptKey, fileName); + } + catch { fileNewName = fileName; } + } + + var row1 = new RowLayoutControl(listView.rowSpace / 2); + listView.AddChidren(row1); + var btnName = row1.frameTable.AddLeftCaption(fileNewName, 800); + btnName.IsMoreLines = true; + if (addLine == true) + { + row1.frameTable.AddBottomLine(); + } + row1.frameTable.AddRightArrow(); + + var btnReName = row1.AddDeleteControl(); + btnReName.Text = "閲嶅懡鍚�"; + btnReName.ButtonClickEvent += (sender, e) => + { + //鐢熸垚涓�涓脊绐楃敾闈� + var dialogForm = new DialogInputControl(360); + //淇濆瓨妯℃澘鍒癆pp + dialogForm.SetTitleText("閲嶅懡鍚�"); + //璇疯緭鍏ユ柊鍚嶅瓧 + dialogForm.SetTipText("璇疯緭鍏ユ柊鍚嶅瓧"); + dialogForm.Text = fileName; + + //鎸変笅纭鎸夐挳 + dialogForm.ComfirmClickEvent += ((textValue) => + { + //鐢婚潰鍏抽棴 + dialogForm.CloseDialog(); + if (textValue == string.Empty) + { + return; + } + HdlFileLogic.Current.MoveFileToDirectory(System.IO.Path.Combine(directory, fileName), System.IO.Path.Combine(directory, textValue)); + + fileNewName = textValue; + fileName = textValue; + btnName.Text = textValue; + }); + }; + + var btnUpLoad = row1.AddEditorControl(); + btnUpLoad.Text = "涓婁紶"; + btnUpLoad.ButtonClickEvent += (sender, e) => + { + this.ShowMassage(ShowMsgType.Confirm, "鏄惁涓婁紶璇ユ枃浠�(娴嬭瘯)?", () => + { + HdlThreadLogic.Current.RunThread(() => + { + string tagrtFile = System.IO.Path.Combine(directory, fileName); + HdlBackupLogic.Current.UpLoadByteDataToOptionBackup(fileNewName, HdlFileLogic.Current.ReadFileByteContent(tagrtFile)); + }); + }); + }; + + var btnDelete = row1.AddDeleteControl(); + btnDelete.ButtonClickEvent += (sender, e) => + { + this.ShowMassage(ShowMsgType.Confirm, "鏄惁娓呴櫎璇ョ紦瀛樻枃浠�", () => + { + var myFile = System.IO.Path.Combine(directory, fileName); + try + { + System.IO.File.Delete(myFile); + row1.RemoveFromParent(); + } + catch (Exception ex) + { + this.ShowMassage(ShowMsgType.Error, "娓呴櫎缂撳瓨鏂囦欢寮傚父"); + HdlLogLogic.Current.WriteLog(ex, "娓呴櫎缂撳瓨鏂囦欢寮傚父"); + } + }); + }; + + row1.frameTable.ButtonClickEvent += (sender, e) => + { + var form = new HideOptionFileContentForm(); + form.AddForm(System.IO.Path.Combine(directory, fileName)); + }; + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + #endregion + } +} -- Gitblit v1.8.0