From 95d9356edef73a1ad5b04e62b7aef6b77697a226 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期四, 05 九月 2024 10:13:30 +0800 Subject: [PATCH] 1 --- DataLoader/ResWin.xaml.cs | 36 +++++++++++++++++++++++++++++++++--- 1 files changed, 33 insertions(+), 3 deletions(-) diff --git a/DataLoader/ResWin.xaml.cs b/DataLoader/ResWin.xaml.cs index 4810d55..44894e2 100644 --- a/DataLoader/ResWin.xaml.cs +++ b/DataLoader/ResWin.xaml.cs @@ -7,6 +7,8 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; +using CefSharp.Callback; +using System.Windows.Media; namespace DataLoader { @@ -35,6 +37,7 @@ FindTreeItems(dirs, items, 0); this.tvResTree.ItemsSource = items.Child; + //SetCheckedBox(); } private void FindTreeItems(List<SysDir> list, TreeItem ti, int pid) @@ -49,9 +52,35 @@ item.Name = dir.name; item.FullName = dir.fullName; item.IsExpanded = true; + item.IsChecked = CommonProp.dirId == dir.id; ti.Child.Add(item); FindTreeItems(list, item, dir.id); + } + } + } + + private void SetCheckedBox() + { + if (CommonProp.dirId == 0) return; + + foreach (var item in this.tvResTree.Items) + { + TreeViewItem tvItem = this.tvResTree.ItemContainerGenerator.ContainerFromItem(item) as TreeViewItem; + if (null == tvItem) continue; //((System.Windows.Controls.Panel)tvItem.VisualParent).Children + + for (int i = 0, c = VisualTreeHelper.GetChildrenCount(tvItem); i < c; i++) + { + DependencyObject child = VisualTreeHelper.GetChild(this.tvResTree, i); + if (child is CheckBox) + { + CheckBox cb = child as CheckBox; + if (cb.IsChecked == true) + { + this.cbLast = cb; + return; + } + } } } } @@ -75,12 +104,13 @@ SysDir dir = null; if (this.cbLast != null) { - int id = int.Parse(this.cbLast.Tag.ToString()); - dir = (from d in dirs where d.id == id select d).First<SysDir>(); + CommonProp.dirId = int.Parse(this.cbLast.Tag.ToString()); + dir = (from d in dirs where d.id == CommonProp.dirId select d).First<SysDir>(); } - CommonProp.Owner.resWin = null; + this.Hide(); CommonProp.Owner.SetRes(null == dir ? null : dir.code, null == dir ? null : dir.fullName); + e.Cancel = true; } } } -- Gitblit v1.9.3