private void OnLoadListView(object sender, RoutedEventArgs e) { if (firstLoad) { firstLoad = false; courseTreeView.SelectedItemChanged += new RoutedPropertyChangedEventHandler <object>(courseTreeView_SelectedItemChanged); //courseTreeView.FontFamily = new System.Windows.Media.FontFamily("Microsoft YaHei"); courseTreeView.FontSize = 14; courseTreeView.Height = 584; courseTreeView.Background = null; courseTreeView.Foreground = new SolidColorBrush(Colors.White); courseTreeView.Margin = new Thickness(0); DirectoryInfo folder = new DirectoryInfo(@"Resources\课程学习"); DirectoryInfo[] chldFolders = folder.GetDirectories(); foreach (DirectoryInfo chldFolder in chldFolders) { if (UserInfoStatic.hasAuth(chldFolder.Name)) { TreeViewItem chldNode = new TreeViewItem(); chldNode.Header = chldFolder.Name; chldNode.Tag = chldFolder.FullName; chldNode.Foreground = new SolidColorBrush(Colors.White); //用固态画刷填充前景色 chldNode.IsExpanded = true; GetFiles(chldFolder.FullName, chldNode); courseTreeView.Items.Add(chldNode); } } if (!this.ClassListTreeView.Children.Contains(courseTreeView)) { this.ClassListTreeView.Children.Add(courseTreeView); } } }
private void GetFiles(string filePath, TreeViewItem node) { DirectoryInfo folder = new DirectoryInfo(filePath); //node.Header = folder.Name; //node.Tag = folder.FullName; DirectoryInfo[] chldFolders = folder.GetDirectories(); foreach (DirectoryInfo chldFolder in chldFolders) { if (UserInfoStatic.hasAuth(chldFolder.Name)) { TreeViewItem chldNode = new TreeViewItem(); chldNode.Header = chldFolder.Name; chldNode.Foreground = new SolidColorBrush(Colors.White); //用固态画刷填充前景色 chldNode.IsExpanded = true; chldNode.Tag = chldFolder.FullName; GetFiles(chldFolder.FullName, chldNode); node.Items.Add(chldNode); } } FileInfo[] chldFiles = folder.GetFiles("*.*"); foreach (FileInfo chlFile in chldFiles) { var rs2 = chlFile.Name.Split('.')[0]; if (UserInfoStatic.hasAuth(rs2)) { var rs1 = chlFile.Name.ToLower().Replace(".mp4", ""); if (!rs2.Equals("1")) { TreeViewItem chldNode = new TreeViewItem(); chldNode.Header = rs2; chldNode.Tag = chlFile.FullName; chldNode.Foreground = new SolidColorBrush(Colors.White); //用固态画刷填充前景色 chldNode.IsExpanded = true; node.Items.Add(chldNode); } } } }
public TrainList(Grid Main, Hashtable trainInfo, UserControl parentUI) { InitializeComponent(); tInfo = trainInfo; PUI = parentUI; mainWindow = Main; if (!UserInfoStatic.hasAuth(tInfo["tname"].ToString())) { tInfo["open"] = 0; } //button声音 Grid uiButton = this.Content as Grid; UIElementCollection Childrens = uiButton.Children; foreach (UIElement ui in Childrens) { //ui转成控件 if (ui is Button) { ui.MouseEnter += new MouseEventHandler(ui_MouseEnter); } } }
private void gamePanel_Loaded() { if (UserInfoStatic.hasAuth("荷韵")) { this.GameButton1.Tag = "../Image/Train/game4.png"; this.GameButton1.Click += OnOpenTrain1; } else { this.GameButton1.IsEnabled = false; this.GameButton1.Tag = "../Image/Train/Lock2.png"; } if (UserInfoStatic.hasAuth("梅花")) { this.GameButton2.Tag = "../Image/Train/game3.png"; this.GameButton2.Click += OnOpenTrain2; } else { this.GameButton2.IsEnabled = false; this.GameButton2.Tag = "../Image/Train/Lock2.png"; } if (UserInfoStatic.hasAuth("丝路")) { this.GameButton3.Tag = "../Image/Train/game5.png"; this.GameButton3.Click += OnOpenTrain3; } else { this.GameButton3.IsEnabled = false; this.GameButton3.Tag = "../Image/Train/Lock2.png"; } if (UserInfoStatic.hasAuth("菩提树")) { this.GameButton4.Tag = "../Image/Train/game6.png"; this.GameButton4.Click += OnOpenTrain4; } else { this.GameButton4.IsEnabled = false; this.GameButton4.Tag = "../Image/Train/Lock2.png"; } if (UserInfoStatic.hasAuth("生命之泉")) { this.GameButton5.Tag = "../Image/Train/game8.png"; this.GameButton5.Click += OnOpenTrain5; } else { this.GameButton5.IsEnabled = false; this.GameButton5.Tag = "../Image/Train/Lock2.png"; } if (UserInfoStatic.hasAuth("星空")) { this.GameButton6.Tag = "../Image/Train/game7.png"; this.GameButton6.Click += OnOpenTrain6; } else { this.GameButton6.IsEnabled = false; this.GameButton6.Tag = "../Image/Train/Lock2.png"; } }