/// <summary> /// 获取控件接口 /// </summary> /// <param name="controlObj"></param> /// <returns></returns> private IControl GetIControl(ControlDetailForPage obj) { IControl control = null; #region 根据控件类型实例化相应控件 if (xinLongyuControlType.buttonType.Equals(obj.ctrl_type)) { control = new xinlongyuButton(); //control = new xinlongyuTextBox(); } else if (xinLongyuControlType.inputType.Equals(obj.ctrl_type)) { control = new xinlongyuTextBox(); } else if (xinLongyuControlType.superViewType.Equals(obj.ctrl_type)) { control = new xinlongyuParentControl(); } else if (xinLongyuControlType.pageType.Equals(obj.ctrl_type)) { control = new xinlongyuPage(); } else if (xinLongyuControlType.imgType.Equals(obj.ctrl_type)) { control = new xinlongyuImageControl(); } else if (xinLongyuControlType.textType.Equals(obj.ctrl_type)) { control = new xinlongyuLable(); } else if (xinLongyuControlType.pcnavigationBarType.Equals(obj.ctrl_type)) { control = new xinlongyuNavigationControl(); } else if (xinLongyuControlType.pcnavigationBarItemType.Equals(obj.ctrl_type)) { control = new xinlongyuNavigationItem(); } else if (xinLongyuControlType.articleEditorType.Equals(obj.ctrl_type)) { control = new xinlongyuArticleEditor(); } else if (xinLongyuControlType.PCGrid.Equals(obj.ctrl_type)) { control = new xinlongyuDataGird(); } else if (xinLongyuControlType.reviewControlType.Equals(obj.ctrl_type)) { control = new xinlongyuReviewControl(); } else if (xinLongyuControlType.comboboxMenuType.Equals(obj.ctrl_type)) { control = new xinlongyuCombobox(); } else if (xinLongyuControlType.cacheType.Equals(obj.ctrl_type)) { control = new xinlongyuCacher(); } else if (xinLongyuControlType.pageCacheType.Equals(obj.ctrl_type)) { control = new xinlongyuPageCacher(); } else if (xinLongyuControlType.tooltipType.Equals(obj.ctrl_type)) { control = new xinlongyuToolTip(); } else if (xinLongyuControlType.LogicJudgmentType.Equals(obj.ctrl_type)) { control = new xinlongyuLogicControl(); } else if (xinLongyuControlType.getDataType.Equals(obj.ctrl_type)) { control = new xinlongyuGetData(); } else if (xinLongyuControlType.fileUploader.Equals(obj.ctrl_type)) { control = new xinlongyuUploadControl(); } else if (xinLongyuControlType.checkboxType.Equals(obj.ctrl_type)) { control = new xinlongyuCheckBoxControl(); } else { return(null); } #endregion //设置一些附属的属性 (control as FrameworkElement).Name = ConfigManagerSection.ControlNamePrefix + obj.ctrl_id.ToString(); //设置名称标记 (control as FrameworkElement).VerticalAlignment = VerticalAlignment.Top; (control as FrameworkElement).HorizontalAlignment = HorizontalAlignment.Left; (control as FrameworkElement).Tag = obj; return(control); }
/// <summary> /// 添加标题栏 /// </summary> /// <param name="gridControl"></param> private void AddTitleBar(xinlongyuParentControl gridControl, ControlDetailForPage pageObj, bool isNavigationWindow) { //设置为两行,一行显示返回按钮以及刷新按钮,另外一行显示内容 RowDefinition gridRowTitle = new RowDefinition(); gridRowTitle.Height = GridLength.Auto; RowDefinition gridRowContent = new RowDefinition(); gridRowContent.Height = new GridLength(1, GridUnitType.Star); gridControl.RowDefinitions.Add(gridRowTitle); gridControl.RowDefinitions.Add(gridRowContent); StackPanel gridTitle = new StackPanel(); //gridTitle.Background = new SolidColorBrush(CommonConverter.ConvertStringToColor("#0080C0")); gridTitle.Orientation = Orientation.Horizontal; gridTitle.HorizontalAlignment = HorizontalAlignment.Stretch; gridTitle.VerticalAlignment = VerticalAlignment.Top; //返回按钮 xinlongyuButton btnBack = new xinlongyuButton(); Image imgBack = new Image(); //imgBack.Stretch = Stretch.Fill; imgBack.Source = new BitmapImage( new Uri("pack://application:,,,/xinlongyuOfWpf;component/Resources/mybackbutton.png")); btnBack.Content = imgBack; btnBack.Width = 36; btnBack.Height = 36; btnBack.Background = Brushes.Transparent; btnBack.Margin = new Thickness(5); btnBack.BorderThickness = new Thickness(0); //刷新按钮 xinlongyuButton btnRefresh = new xinlongyuButton(); Image imgRefresh = new Image(); imgRefresh.Stretch = Stretch.Fill; imgRefresh.Source = new BitmapImage( new Uri("pack://application:,,,/xinlongyuOfWpf;component/Resources/refreshButton.png")); btnRefresh.Content = imgRefresh; btnRefresh.Background = Brushes.Transparent; btnRefresh.Width = 25; btnRefresh.Height = 25; btnRefresh.Margin = new Thickness(5); btnRefresh.BorderThickness = new Thickness(0); gridTitle.Children.Add(btnBack); gridTitle.Children.Add(btnRefresh); gridTitle.SetValue(Grid.RowProperty, 0); gridControl.Children.Add(gridTitle); //添加事件 btnBack.Click += (s, e) => { var window = Window.GetWindow(btnBack); var listPage = window.Tag as List <Page>; if (!object.Equals(listPage, null) && listPage.Count > 1) { //CommonFunction.ShowWaitingForm(window); window.Content = null; listPage.RemoveAt(listPage.Count - 1); var page = listPage[listPage.Count - 1]; window.Content = page; window.Width = page.Width; window.Height = page.Height + ConfigManagerSection.TitleBarHeight; //页面初始化事件 //gridControl.SetP7(pageObj.p7); } }; //刷新事件 btnRefresh.Click += async(s, e) => { var window = Window.GetWindow(btnRefresh); var page = window.Content as xinlongyuForm; var listPage = window.Tag as List <Page>; if (!object.Equals(page, null)) { listPage.RemoveAt(listPage.Count - 1); PageFactory pageFactory = new PageFactory(); await pageFactory.ShowPage(window, page.PageId, listPage).ConfigureAwait(false); MessageBox.Show("刷新成功"); } }; //这里不考虑处于导航栏中的情况,直接隐藏这两个按钮 if (isNavigationWindow) { btnBack.Visibility = Visibility.Hidden; btnRefresh.Visibility = Visibility.Hidden; } }