using FATrace.WPLApp.Core; using FATrace.WPLApp.ModelDto; using FATrace.WPLApp.Services; using FATrace.WPLApp.Views; using Prism.Commands; using Prism.Events; using Prism.Regions; using Prism.Services.Dialogs; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FATrace.WPLApp.ViewModels { public class MainViewModel : NavigationViewModel { public MainViewModel(IRegionManager regionManager, IDialogService dialogService, IEventAggregator eventAggregator, NavigationServices navigationServices) { this.regionManager = regionManager; DialogService = dialogService; NavigationServices = navigationServices; NavigationItems = NavigationServices.NavItemDtos; this.regionManager.RegisterViewWithRegion("FootRegion", typeof(FootView)); this.regionManager.RegisterViewWithRegion("HeadRegion", typeof(HeadView)); //this.regionManager.RegisterViewWithRegion("ContentRegion", typeof(ProFlowView)); } private IRegionManager regionManager { get; set; } public IDialogService DialogService { get; } public NavigationServices NavigationServices { get; } public ObservableCollection NavigationItems { get; set; } private string titel = string.Empty; /// /// 标题 /// public string Title { get { return titel; } set { titel = value; RaisePropertyChanged(); } } private DelegateCommand _OpenCommand; /// /// 命令 /// public DelegateCommand OpenCommand { get { if (_OpenCommand == null) { _OpenCommand = new DelegateCommand((p) => OpenCommandMethod(p)); } return _OpenCommand; } } private void OpenCommandMethod(object obj) { switch (obj.ToString()) { case "Dashboard": this.regionManager.Regions["ContentRegion"].RequestNavigate("DashBoardView"); //this.regionManager.Regions["ContentRegion"].Activate(viewA); break; case "3D工艺流程": this.regionManager.Regions["ContentRegion"].RequestNavigate("ProFlowView"); //this.regionManager.Regions["DriveTree"].RequestNavigate("DeviceProtocolTreeView"); //this.regionManager.Regions["ContentRegion"].Activate(viewB); break; case "管道线路": DialogService.ShowDialog("DialogLineSelectView", new DialogParameters() { { "TabIndex", "SeletedGroupTabIndex" } }, (par) => { if (par.Result == ButtonResult.OK) { //程序名称 var ReturnValue = par.Parameters.GetValue("Name"); //返回数据,刷新Chart } else if (par.Result == ButtonResult.Cancel) { //取消 } }); break; case "报表数据": this.regionManager.Regions["ContentRegion"].RequestNavigate("ReportView"); //this.regionManager.Regions["ContentRegion"].Activate(viewB); break; case "原料使用查询": this.regionManager.Regions["ContentRegion"].RequestNavigate("RawProUseView"); break; case "原料入库查询": this.regionManager.Regions["ContentRegion"].RequestNavigate("RawProInputView"); break; case "历史报警": this.regionManager.Regions["ContentRegion"].RequestNavigate("HistoryAlarmView"); //this.regionManager.Regions["ContentRegion"].Activate(viewB); break; case "用户登录": this.regionManager.Regions["ContentRegion"].RequestNavigate("UserView"); //this.regionManager.Regions["ContentRegion"].Activate(Shift); break; case "使用手册": this.regionManager.Regions["ContentRegion"].RequestNavigate("HelpManualView"); //弹窗 break; default: break; } //this.regionManager.RegisterViewWithRegion("ContentRegion", typeof(CoreShift.Views.Shift.Index)); //MessageBox.Show(obj.ToString()); } } }