From ca4c281f3e2f52b1e0cbb9caaf75581286d58a52 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期二, 22 八月 2023 16:44:48 +0800 Subject: [PATCH] 修改资源树的选择功能 --- DataLoader/ResWin.xaml | 2 +- DataLoader/MainWindow.xaml.cs | 5 ++--- DataLoader/ResWin.xaml.cs | 36 +++++++++++++++++++++++++++++++++--- DataLoader/MainWindow.xaml | 2 +- DataLoader/LoginWin.xaml | 2 +- DataLoader/Model/CommonProp.cs | 5 +++++ 6 files changed, 43 insertions(+), 9 deletions(-) diff --git a/DataLoader/LoginWin.xaml b/DataLoader/LoginWin.xaml index 2474aac..2583e78 100644 --- a/DataLoader/LoginWin.xaml +++ b/DataLoader/LoginWin.xaml @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Chrome="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf" - Loaded="Window_Loaded" Title="鐧诲綍绐楀彛" ShowInTaskbar="False" WindowStyle="None" + Loaded="Window_Loaded" Title="鐧诲綍绐楀彛" ShowInTaskbar="True" WindowStyle="None" Height="500" Width="750" WindowStartupLocation="CenterScreen"> <Grid> <Chrome:ChromiumWebBrowser x:Name="web" Margin="1" Grid.Row="1" /> diff --git a/DataLoader/MainWindow.xaml b/DataLoader/MainWindow.xaml index 0646370..d62efb8 100644 --- a/DataLoader/MainWindow.xaml +++ b/DataLoader/MainWindow.xaml @@ -168,7 +168,7 @@ <Label Grid.Row="1" Grid.Column="2" Content="鍏冩暟鎹被鍨嬶細" VerticalAlignment="Center" HorizontalAlignment="Right" /> <!--<TextBox Grid.Row="1" Grid.Column="3" Style="{StaticResource tb}" x:Name="tbAcqTim2e"/>--> <!--<ComboBox Grid.Row="1" Grid.Column="3" IsReadOnly="True" DisplayMemberPath="Name" Style="{StaticResource ComboBoxStyle}" Width="320" Height="30" HorizontalAlignment="Left" x:Name="cbMetaType"></ComboBox>--> - <ComboBox Grid.Row="1" Grid.Column="3" HorizontalAlignment="Left" VerticalContentAlignment="Center" Background="White" SelectedIndex="0" Width="322" Height="38" BorderThickness="0" x:Name="cbMetaType"> + <ComboBox Grid.Row="1" Grid.Column="3" HorizontalAlignment="Left" VerticalContentAlignment="Center" Cursor="Hand" Background="White" SelectedIndex="0" Width="322" Height="38" BorderThickness="0" x:Name="cbMetaType"> <ComboBoxItem>璇烽�夋嫨</ComboBoxItem> <ComboBoxItem>鏁板瓧姝e皠褰卞儚鍥�</ComboBoxItem> <ComboBoxItem>鏁板瓧楂樼▼妯″瀷</ComboBoxItem> diff --git a/DataLoader/MainWindow.xaml.cs b/DataLoader/MainWindow.xaml.cs index 18ce32d..6610d73 100644 --- a/DataLoader/MainWindow.xaml.cs +++ b/DataLoader/MainWindow.xaml.cs @@ -83,14 +83,13 @@ // 璧勬簮鐩綍 private void Dir_MouseLeftButtonDown(object sender, RoutedEventArgs e) { - resWin = new ResWin(); + if (null == resWin) resWin = new ResWin(); this.Hide(); - resWin.Show(); + this.resWin.Show(); } public void SetRes(string dircode, string fullName) { - if (resWin != null) resWin.Close(); this.Show(); if (!string.IsNullOrEmpty(dircode)) diff --git a/DataLoader/Model/CommonProp.cs b/DataLoader/Model/CommonProp.cs index b015a67..5a38914 100644 --- a/DataLoader/Model/CommonProp.cs +++ b/DataLoader/Model/CommonProp.cs @@ -61,6 +61,11 @@ public static string Depname; /// <summary> + /// 鐩綍ID + /// </summary> + public static int dirId; + + /// <summary> /// 鐩綍缂栫爜 /// </summary> public static string Dircode; diff --git a/DataLoader/ResWin.xaml b/DataLoader/ResWin.xaml index fd8a6e8..af7914b 100644 --- a/DataLoader/ResWin.xaml +++ b/DataLoader/ResWin.xaml @@ -1,7 +1,7 @@ 锘�<Window x:Class="DataLoader.ResWin" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - ShowInTaskbar="False" Loaded="Window_Loaded" Closing="Window_Closing" + Loaded="Window_Loaded" Closing="Window_Closing" xmlns:model="clr-namespace:DataLoader.Model" Background="Transparent" Title="璇烽�夋嫨璧勬簮" Height="750" Width="600" WindowStartupLocation="CenterScreen"> <Window.Resources> 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