static Treeview LoadTreeview(Stream fs) { var obj = new Treeview(ReadString(fs), ReadFont(fs), ReadInt(fs), ReadInt(fs), ReadInt(fs), ReadInt(fs)) { Enabled = ReadBool(fs), Visible = ReadBool(fs), SelectedTextColor = ReadColor(fs), TextColor = ReadColor(fs) }; var len = ReadInt(fs); for (var i = 0; i < len; i++) { obj.AddNode(LoadTreeviewNode(fs)); } return(obj); }
public static string Show(string title, Font titleFont, Font bodyFont) { IContainer prv = Core.ActiveContainer; var frmModal = new Form("modalAlertForm", Colors.Ghost); _result = string.Empty; Core.Screen.SetClippingRectangle(0, 0, frmModal.Width, frmModal.Height); Core.Screen.DrawRectangle(0, 0, 4, 4, frmModal.Width - 8, frmModal.Height - 8, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 256); Core.ShadowRegion(4, 4, frmModal.Width - 8, frmModal.Height - 8); Core.Screen.DrawTextInRect(title, 8, 8, frmModal.Width - 16, titleFont.Height, Bitmap.DT_TrimmingCharacterEllipsis, Colors.Charcoal, titleFont); var tv1 = new Treeview("tv1", bodyFont, 8, 16 + titleFont.Height, frmModal.Width - 16, frmModal.Height - 41 - bodyFont.Height - titleFont.Height); VolumeInfo[] vi = VolumeInfo.GetVolumes(); for (int i = 0; i < vi.Length; i++) { var viNode = new TreeviewNode(vi[i].RootDirectory) { Tag = vi[i].RootDirectory }; if (vi[i].IsFormatted) { if (Directory.GetDirectories(vi[i].RootDirectory).Length > 0) { var ni = new TreeviewNode(string.Empty) { Tag = null }; viNode.AddNode(ni); } } tv1.AddNode(viNode); } tv1.NodeExpanded += tv1_NodeExpanded; frmModal.AddChild(tv1); var btnSelect = new Button("btnSel", "Select", bodyFont, 8, frmModal.Height - 22 - bodyFont.Height) { BorderColor = ColorUtility.ColorFromRGB(13, 86, 124), NormalColorTop = Colors.LightBlue, NormalColorBottom = ColorUtility.ColorFromRGB(26, 129, 182), PressedColorBottom = Colors.LightBlue }; btnSelect.PressedColorTop = btnSelect.NormalColorBottom; btnSelect.NormalTextColor = Colors.White; btnSelect.PressedTextColor = Colors.White; btnSelect.Tap += (sender, e) => ReturnSelection(tv1); frmModal.AddChild(btnSelect); Color cR1 = ColorUtility.ColorFromRGB(226, 92, 79); Color cR2 = ColorUtility.ColorFromRGB(202, 48, 53); var btnCancel = new Button("btnCancel", "Cancel", bodyFont, 0, btnSelect.Y, Colors.White, Colors.White, Colors.DarkRed, Colors.DarkRed) { NormalColorTop = cR1, NormalColorBottom = cR2, PressedColorTop = cR2, PressedColorBottom = cR1 }; btnCancel.X = frmModal.Width - btnCancel.Width - 8; btnCancel.Tap += (sender, e) => _activeBlock.Set(); frmModal.AddChild(btnCancel); Core.SilentlyActivate(frmModal); frmModal.Render(new rect(4, 12 + titleFont.Height, frmModal.Width - 8, frmModal.Height - 20 - titleFont.Height)); Core.Screen.Flush(); ModalBlock(); Core.ActiveContainer = prv; return(_result); }
// ReSharper disable once UnusedMethodReturnValue.Local // ReSharper disable once UnusedParameter.Local //TODO: check why param extensions is not in use private static string CreateDialog(string title, Font titleFont, Font bodyFont, string startDirectory, string[] extentions) { IContainer prv = Core.ActiveContainer; lock (Core.Screen) { var frmModal = new Form("modalAlertForm", Colors.Ghost); _inputResult = string.Empty; Core.Screen.SetClippingRectangle(0, 0, frmModal.Width, frmModal.Height); Core.Screen.DrawRectangle(0, 0, 4, 4, frmModal.Width - 8, frmModal.Height - 8, 0, 0, Colors.Ghost, 0, 0, Colors.Ghost, 0, 0, 256); Core.ShadowRegion(4, 4, frmModal.Width - 8, frmModal.Height - 8); Core.Screen.DrawTextInRect(title, 8, 8, frmModal.Width - 16, titleFont.Height, Bitmap.DT_TrimmingCharacterEllipsis, Colors.Charcoal, titleFont); var tv1 = new Treeview("tv1", bodyFont, 8, 16 + titleFont.Height, 120, frmModal.Height - 45 - bodyFont.Height - titleFont.Height); VolumeInfo[] vi = VolumeInfo.GetVolumes(); for (int i = 0; i < vi.Length; i++) { var viNode = new TreeviewNode(vi[i].RootDirectory) { Tag = vi[i].RootDirectory }; if (vi[i].IsFormatted) { if (Directory.GetDirectories(vi[i].RootDirectory).Length > 0) { var ni = new TreeviewNode(string.Empty) { Tag = null }; viNode.AddNode(ni); } } tv1.AddNode(viNode); } tv1.NodeExpanded += tv1_NodeExpanded; frmModal.AddChild(tv1); var fb1 = new Filebox("fb1", null, bodyFont, 132, tv1.Y, frmModal.Width - 141, tv1.Height); frmModal.AddChild(fb1); Color cR1 = ColorUtility.ColorFromRGB(226, 92, 79); Color cR2 = ColorUtility.ColorFromRGB(202, 48, 53); var btnCancel = new Button("btnCancel", "Cancel", bodyFont, 8, frmModal.Height - 26 - bodyFont.Height, Colors.White, Colors.White, Colors.DarkRed, Colors.DarkRed) { NormalColorTop = cR1, NormalColorBottom = cR2, PressedColorTop = cR2, PressedColorBottom = cR1 }; btnCancel.Height += 4; btnCancel.Tap += (sender, e) => _activeBlock.Set(); var btnSelect = new Button("btnSel", (_isSave) ? "Save File" : "Open File", bodyFont, 8, frmModal.Height - 26 - bodyFont.Height) { BorderColor = ColorUtility.ColorFromRGB(13, 86, 124), NormalColorTop = Colors.LightBlue, NormalColorBottom = ColorUtility.ColorFromRGB(26, 129, 182), PressedColorBottom = Colors.LightBlue }; btnSelect.PressedColorTop = btnSelect.NormalColorBottom; btnSelect.NormalTextColor = Colors.White; btnSelect.PressedTextColor = Colors.White; btnSelect.X = frmModal.Width - btnSelect.Width - 8; btnSelect.Height += 4; btnSelect.Enabled = false; frmModal.AddChild(btnSelect); frmModal.AddChild(btnCancel); var txt1 = new Textbox("txt1", string.Empty, bodyFont, Colors.Charcoal, btnCancel.X + btnCancel.Width + 4, btnCancel.Y, frmModal.Width - 28 - btnCancel.Width - btnSelect.Width, btnSelect.Height, ' ', !_isSave); frmModal.AddChild(txt1); Core.SilentlyActivate(frmModal); frmModal.Render(new rect(4, 12 + titleFont.Height, frmModal.Width - 8, frmModal.Height - 20 - titleFont.Height)); Core.Screen.Flush(); tv1.NodeTapped += (node, e) => tv1_NodeTapped(node, fb1); fb1.PathChanged += (sender, value) => SetTvPath(value, tv1, fb1); fb1.SelectedIndexChanged += (sender, value) => FbIndexChange(fb1, txt1); txt1.TextChanged += (sender, value) => btnSelect.Enabled = txt1.Text != string.Empty; SetTvPath(startDirectory, tv1, fb1); btnSelect.Tap += (sender, e) => ReturnSelection(tv1, txt1); } ModalBlock(); Core.ActiveContainer = prv; return(_inputResult); }