private void ChangeUserControl(UserControlType type) { CurrentType = type; mpnl_main.Controls.Clear(); switch (type) { case UserControlType.Home: mpnl_main.Controls.Add(MetroHome); break; case UserControlType.HomeCountry: mpnl_main.Controls.Add(MetroHomeCountry); break; case UserControlType.Overseas: mpnl_main.Controls.Add(MetroOverseas); break; case UserControlType.Setting: mpnl_main.Controls.Add(MetroSetting); break; } }
/// <summary> /// 初始化用户控件 加载相应组件 /// </summary> internal static void ShowUserControl(UserControlType type) { //判断是否初始化Popup if (_popUp == null) { InitPopupManager(); } _popUp.Child = null; _popUp.IsOpen = false; //根据type显示相应的UserControl switch (type) { case UserControlType.LoginControl: _popUp.Child = LoginControl; break; case UserControlType.RegisterControl: _popUp.Child = RegisterControl; break; case UserControlType.CommentControl: _popUp.Child = CommentControl; break; default: System.Diagnostics.Debug.WriteLine("找不到该弹出框{" + type.ToString() + "}"); break; } _popUp.Loaded += new RoutedEventHandler((s, e) => { PopupShowAnimation(); }); _popUp.IsOpen = true; _popUp.Child.Opacity = 0; }
private void ChangeVisbility(UserControlType userControlType) { switch (userControlType) { case UserControlType.Status: grdDate.Visibility = System.Windows.Visibility.Collapsed; grdCommon.Visibility = System.Windows.Visibility.Collapsed; grdStatus.Visibility = System.Windows.Visibility.Visible; cmbstatus.SelectionChanged -= ComboBox_SelectionChanged; cmbstatus.ItemsSource = _listComboBoxItem.Select(x => x.Content.ToString()).ToList(); if (string.IsNullOrEmpty(_selectedItem)) { cmbstatus.SelectedItem = _listComboBoxItem.Where(x => x.IsSelected == true).Select(y => y.Content.ToString()).FirstOrDefault(); } else { cmbstatus.SelectedItem = _selectedItem; } cmbstatus.SelectionChanged += ComboBox_SelectionChanged; break; case UserControlType.StartDate: case UserControlType.EndDate: txtdate_Value.Text = string.Empty; dtpdate_DatePicker.SelectedDate = null; grdStatus.Visibility = System.Windows.Visibility.Collapsed; grdCommon.Visibility = System.Windows.Visibility.Collapsed; grdDate.Visibility = System.Windows.Visibility.Visible; cmbdate.SelectionChanged -= ComboBox_SelectionChanged; cmbdate.ItemsSource = _listComboBoxItem.Select(x => x.Content.ToString()).ToList(); if (string.IsNullOrEmpty(_selectedItem)) { cmbdate.SelectedItem = _listComboBoxItem.Where(x => x.IsSelected == true).Select(y => y.Content.ToString()).FirstOrDefault(); } else { cmbdate.SelectedItem = _selectedItem; } cmbdate.SelectionChanged += ComboBox_SelectionChanged; break; case UserControlType.Common: txtcommon_Value.Text = string.Empty; grdStatus.Visibility = System.Windows.Visibility.Collapsed; grdDate.Visibility = System.Windows.Visibility.Collapsed; grdCommon.Visibility = System.Windows.Visibility.Visible; cmbcommon.SelectionChanged -= ComboBox_SelectionChanged; cmbcommon.ItemsSource = _listComboBoxItem.Select(x => x.Content.ToString()).ToList(); if (string.IsNullOrEmpty(_selectedItem)) { cmbcommon.SelectedItem = _listComboBoxItem.Where(x => x.IsSelected == true).Select(y => y.Content.ToString()).FirstOrDefault(); } else { cmbcommon.SelectedItem = _selectedItem; } cmbcommon.SelectionChanged += ComboBox_SelectionChanged; break; } }
public XtraUserControl GetUserControl(UserControlType type) { ClearUserControlParent(); if (_usercontrols.Where(p => p.Key == type).Count() == 0) { _usercontrols.Add(type, (XtraUserControl)Activator.CreateInstance(Type.GetType(_ns + "." + type.ToString()))); } _usercontrols.Where(p => p.Key == type).FirstOrDefault().Value.Parent = _usercontrolparent; _usercontrols.Where(p => p.Key == type).FirstOrDefault().Value.Dock = DockStyle.Fill; return _usercontrols.Where(p => p.Key == type).FirstOrDefault().Value; }
private void ShowForm(UserControlType uct) { HideAll(); _d[uct].Show(); }
public SearchCriterias(UserControlType userControlType, List <ComboBoxItem> mainComboBoxItemList) { InitializeComponent(); _listComboBoxItem = mainComboBoxItemList; ChangeVisbility(userControlType); }