private void MenuLoadRef() { // 获取用户功能列表 var sysmenu = new SystemModuleBIZ().SelectAll(); foreach (SystemModule data in sysmenu) { ZNC.Component.ImageButton2.DynamicImageButton ImgBtn = new ZNC.Component.ImageButton2.DynamicImageButton { Name = "btn_" + data.Code, Content = data.Name, FontSize = 16, Margin = new Thickness(0, 2, 0, 2), HorizontalContentAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Visibility = Visibility.Visible, Foreground = new SolidColorBrush(Colors.White) }; ImgBtn.IconImage = new BitmapImage(new Uri("pack://siteoforigin:,,,/image/" + data.PicUrl)); //ImgBtn.Click += new RoutedEventHandler(VM.Menu_Click); //this.MenuPanel.Children.Add(ImgBtn); } }
/// <summary> /// 主窗口动态菜单按钮的响应事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> internal void Menu_Click(object sender, RoutedEventArgs e) { ZNC.Component.ImageButton2.DynamicImageButton btn = (ZNC.Component.ImageButton2.DynamicImageButton)sender; string gnbh = btn.Name.Substring(4); // 从第四位开始截取功能编号,“btn_XXXXX” // 动态加工的菜单的功能响应事件 //foreach (LOCATE_YHGN data in App._GMainWindow._locate_yhgnLists) //{ // if (data.GNBH.Trim() == gnbh) // { // if (data.GNLJ.Contains("MainPageView")) // { // //6,14,201,-96 // Thickness tkn = new Thickness(); // tkn.Left = 6; // tkn.Top = 14; // tkn.Right = 201; // tkn.Bottom = -96; // App._GMainWindow.mainFrame.Margin = tkn; // //0,0,6,0 // Thickness tkgrid = new Thickness(); // tkgrid.Left = 0; // tkgrid.Top = 0; // tkgrid.Right = 6; // tkgrid.Bottom = 0; // App._GMainWindow.mainGrid.Margin = tkgrid; // //5,10,201,-96 // Thickness tkrec = new Thickness(); // tkrec.Left = 5; // tkrec.Top = 10; // tkrec.Right = 201; // tkrec.Bottom = -96; // App._GMainWindow.rtmain.Margin = tkrec; // App._GMainWindow.spright.Visibility = Visibility.Visible; // BitmapImage bi = new BitmapImage(new Uri("pack://siteoforigin:,,,/image/main-1.jpg")); // App._GMainWindow.mainImg.Source = bi; // } // else // { // Thickness tkn = new Thickness(); // tkn.Left = 9; // tkn.Top = 14; // tkn.Right = 40; // tkn.Bottom = -96; // App._GMainWindow.mainFrame.Margin = tkn; // Thickness tkgrid = new Thickness(); // tkgrid.Left = 0; // tkgrid.Top = 0; // tkgrid.Right = -1; // tkgrid.Bottom = 0; // App._GMainWindow.mainGrid.Margin = tkgrid; // Thickness tkrec = new Thickness(); // tkrec.Left = 9; // tkrec.Top = 10; // tkrec.Right = 40; // tkrec.Bottom = -96; // App._GMainWindow.rtmain.Margin = tkrec; // App._GMainWindow.spright.Visibility = Visibility.Hidden; // BitmapImage bi = new BitmapImage(new Uri("pack://siteoforigin:,,,/image/background.jpg")); // App._GMainWindow.mainImg.Source = bi; // } // NavigationService.Navigate(new Uri(data.GNLJ, UriKind.RelativeOrAbsolute)); // break; // } //} }