//CRATViewModel实例只会构造一次,发生在窗口创建的时候,也就是每次启动程序创建后,该实例一直存在,更换频带只会更换其成员变量 public CRATViewModel(CRAT curRAT) { m_ComboBoxSelectChangedCommand = new CDelegateCommand(ComboBoxSelectChangedCommand, CanExeComboBoxSelectChangedCommand); M_curBandInfo = new CBandInfo(); //用于绑定当前的频带 M_curBandList = new List <CBandInfo>(); //用于绑定该协议的频带列表 M_RAT = new CRAT(); M_RAT = curRAT; //指明当前协议,并存放所有数据信息 try { M_curBandInfo = M_RAT.M_BandList[0];//初始化的时候,指向第一个频带 M_curBandList = M_RAT.M_BandList; //M_curBandInfo = this.M_curBandList.Find(s => s.M_HisiInfo.M_usIndex==this.M_curBandList.Min(x => x.M_HisiInfo.M_usIndex)); //this.M_BandInfoView.M_BandInfo = M_curBandInfo; M_BandInfoView = new CBandInfoViewModel(M_curBandInfo, this.M_RAT.M_PowerCtrLev); } catch (Exception e) { MessageBox.Show("请检查XML配置文件:" + e.Message, "Fatal Error!", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(0); } //this.M_BandInfoView.ConfigFixedInfo(); m_ScrollCommand = new CDelegateCommand(ScrollCommand, CanExeScrollCommand); //m_DlChannelKeyUpCommand = new CDelegateCommand(DlChannelKeyUpCommand, CanExeDlChannelKeyUpCommand); //刷新当前频率、信道信息 ComboBoxSelectChangedCommand(null); /* * M_strFreDl = (M_BandInfoView.M_BandInfo.M_Frequency.M_FDlmin).ToString("f3"); * M_strFreUl = (M_BandInfoView.M_BandInfo.M_Frequency.M_FUlmin).ToString("f3"); * M_UChanDl = M_BandInfoView.M_BandInfo.M_ChanInfo.M_UDlChanMin; * M_UChanUl = M_BandInfoView.M_BandInfo.M_ChanInfo.M_UUlChanMin;*/ this.M_DScrollBarValue = 0; ScrollCommand(null); M_strWindowTitle = "频率信道计算工具 " + M_RAT.M_strRAT + "(Release:" + M_RAT.M_strRelease + ")"; }
public CBandInfoViewModel(CBandInfo BandInfo, List <CPowerCtrLevInfo> PowerCtrLevInfo) { M_BandInfo = BandInfo; if (PowerCtrLevInfo != null && PowerCtrLevInfo.Count != 0) { M_PowerCtrLev = PowerCtrLevInfo.Find(s => s.M_usPCLIndex == this.M_BandInfo.M_PowerInfo.M_usPCLIndex).M_PowerTable; } }