public ScanBoardConfigManager_VM() { #region 设计器测试数据 if (this.IsInDesignMode) { DataGradItemInfoList.Clear(); DataGradItemInfo data = new DataGradItemInfo(); data.CascadeType = "从左到右"; data.ChipType = ChipType.Chip_MBI5036; data.ScanBoardName = "shasddas"; data.ScanBoardSize = "128x6400"; DataGradItemInfoList.Add(data); data = new DataGradItemInfo(); data.CascadeType = "从上到下"; data.ChipType = ChipType.Chip_MBI5036; data.ScanBoardName = "aaaaaaaaa"; data.ScanBoardSize = "1028x64"; DataGradItemInfoList.Add(data); } #endregion 设计器数据 CmdDeleteConfig = new RelayCommand(DeleteConfigData,OnDeleteButtonCanExecute); CmdExportConfifFile = new RelayCommand(OpenExportConfigFile, OnDeleteButtonCanExecute); CmdImortConfigFile = new RelayCommand(OpenImportConfigFile); string scanFile = "接收卡配置文件"; GetLangString(scanFile, "Lang_Global_ScannerFile", out scanFile); string allFile = "所有文件"; GetLangString(allFile, "Lang_Gloabal_AllFile", out allFile); string filter=scanFile + "(*.rcfg)|*.rcfg|"+ allFile + "(*.*)|*.*"; OpenFile.FileFilter = filter; OpenFile.IsMultiselect = true; #if Test InitializeFileNameList.Clear();//需修改 InitializeFileNameList.Add(@"D:\text\5555555.rcfg");//需修改 InitializeFileNameList.Add(@"D:\text\sssaaas.rcfg");//需修改 _saveFileName = @"D:\TEST"; #endif if (!this.IsInDesignMode) { _initializeFileNameList = _globalParams.OriginalScanFiles; } _saveFilePath = SCANCONFIGFILES_LIB_PATH; Initialize();//TODO:需修改 }
private bool IsExistList(DataGradItemInfo item) { for (int i = 0; i < DataGradItemInfoList.Count; i++) { DataGradItemInfo info = DataGradItemInfoList[i]; if (info.ScanBoardName == item.ScanBoardName) { return true; } } return false; }
private void Initialize() { DataGradItemInfoList.Clear(); if (_initializeFileNameList.Count <= 0) { return; } ScanBoardProperty scanBDproData; DataGradItemInfo info; for (int i = 0; i < _initializeFileNameList.Count; i++) { if (LoadScanProFile(_initializeFileNameList[i], out scanBDproData)) { if (scanBDproData != null) { info = new DataGradItemInfo(); info.IsCheckedEvent += new IsCheckedDel(OnIsCheckedChanged); info.ChipType = scanBDproData.StandardLedModuleProp.DriverChipType; info.ScanBoardName = Path.GetFileNameWithoutExtension(_initializeFileNameList[i]); info.ScanBoardSize = scanBDproData.Width + "x" + scanBDproData.Height; info.CascadeType = GetModCascadeType(scanBDproData.ModCascadeType); info.FileName = _initializeFileNameList[i]; info.SaveFilePath = _initializeFileNameList[i]; DataGradItemInfoList.Add(info); CopyDirectory(_initializeFileNameList[i], _saveFilePath); } } } if (DataGradItemInfoList.Count > 0) { SelectedValue = DataGradItemInfoList[0]; } }
private void ImportCfgFileNotifycationCallBack(ObservableCollection<DataGradItemInfo> info) { if (_saveFilePath==string.Empty) { return; } if (!Directory.Exists(_saveFilePath)) { Directory.CreateDirectory(_saveFilePath); } string sourceDirName = ""; DataGradItemInfo dataInfo = null; for (int i = 0; i < info.Count; i++) { DataGradItemInfo data = info[i]; if ((data.DataHandleWay == HandleWay.Add || data.DataHandleWay == HandleWay.Replace) && data.DataHandelSatate != DataSatate.None) { sourceDirName = Path.GetDirectoryName(data.FileName); CopyDirectory(data.FileName, _saveFilePath); dataInfo = new DataGradItemInfo(); dataInfo.IsCheckedEvent += new IsCheckedDel(OnIsCheckedChanged); dataInfo.CascadeType = data.CascadeType; dataInfo.ChipType = data.ChipType; dataInfo.DataHandelSatate = data.DataHandelSatate; dataInfo.DataHandleWay = data.DataHandleWay; dataInfo.FileName = data.FileName; dataInfo.SaveFilePath = data.SaveFilePath; dataInfo.ScanBoardName = data.ScanBoardName; dataInfo.ScanBoardSize = data.ScanBoardSize; if (data.DataHandleWay == HandleWay.Add) { DataGradItemInfoList.Add(dataInfo); _initializeFileNameList.Add(dataInfo.SaveFilePath); } else if (data.DataHandleWay == HandleWay.Replace) { int count = DataGradItemInfoList.Count; int index = -1; for (int m = 0; m < count; m++ ) { if (DataGradItemInfoList[m].ScanBoardName == dataInfo.ScanBoardName) { index = m; break; } } DataGradItemInfoList[index] = dataInfo; } #region 添加到箱体库 string originalFile = info[i].FileName; ScanBoardProperty scanBdProp = new ScanBoardProperty(); if (CustomTransform.LoadScanProFile(originalFile, ref scanBdProp)) { ScannerCofigInfo scanConfig = new ScannerCofigInfo(); scanConfig.DataGroup = scanBdProp.StandardLedModuleProp.DataGroup; scanConfig.DisplayName = Path.GetFileNameWithoutExtension(originalFile); scanConfig.ScanBdProp = scanBdProp; string strCascade = scanBdProp.ModCascadeType.ToString(); CommonStaticMethod.GetLanguageString(strCascade, strCascade, out strCascade); scanConfig.StrCascadeType = strCascade; string strDriverChip = scanBdProp.StandardLedModuleProp.DriverChipType.ToString(); CommonStaticMethod.GetLanguageString(strDriverChip, strDriverChip, out strDriverChip); scanConfig.StrChipType = strDriverChip; string strScanType = scanBdProp.StandardLedModuleProp.ScanType.ToString(); CommonStaticMethod.GetLanguageString(strScanType, strScanType, out strScanType); scanConfig.StrScanType = strScanType; if (info[i].DataHandleWay == HandleWay.Add) { int index = _globalParams.ScannerConfigCollection.IndexOf(scanConfig); if (_globalParams.ScannerConfigCollection.Count == 0) { _globalParams.ScannerConfigCollection.Add(scanConfig); } else { _globalParams.ScannerConfigCollection.Insert(_globalParams.ScannerConfigCollection.Count - 1, scanConfig); } } else if (info[i].DataHandleWay == HandleWay.Replace) { //ObservableCollection<ScannerCofigInfo> find = int count = _globalParams.ScannerConfigCollection.Count; int index = -1; for (int m = 0; m < count; m++) { if (_globalParams.ScannerConfigCollection[m].DisplayName == data.ScanBoardName) { index = m; break; } } if (index >= 0 && _globalParams.ScannerConfigCollection != null && _globalParams.ScannerConfigCollection.Count != 0) { _globalParams.ScannerConfigCollection.RemoveAt(index); _globalParams.ScannerConfigCollection.Insert(index, scanConfig); } } } #endregion } } OnIsCheckedChanged(false); }
private void GetOneFileDataInfo(string fileName,out DataGradItemInfo info) { info = new DataGradItemInfo(); ScanBoardProperty scanBDproData; if (LoadScanProFile(fileName,out scanBDproData)) { if (scanBDproData != null) { info.ChipType = scanBDproData.StandardLedModuleProp.DriverChipType; info.ScanBoardName = Path.GetFileNameWithoutExtension(fileName); info.ScanBoardSize = scanBDproData.Width + "x" + scanBDproData.Height; info.CascadeType = GetModCascadeType(scanBDproData.ModCascadeType); info.FileName = fileName; string fileNameWithExt = Path.GetFileName(fileName); info.SaveFilePath = _saveFilePath + fileNameWithExt; return; } } info = null; }
private void Initialize() { DataGradItemInfoList.Clear(); //if (_initializeFileNameList.Count <= 0) //{ // return; //} //ScanBoardProperty scanBDproData; DataGradItemInfo info; SQLiteAccessor sqlLiteAccessor = SQLiteAccessor.Instance; List<ScannerCofigInfo> scannerConfigList = sqlLiteAccessor.GetAllScannerCofig(); //for (int i = 0; i < _initializeFileNameList.Count; i++) for (int i = 0; i < scannerConfigList.Count; i++) { info = new DataGradItemInfo(); info.IsCheckedEvent += new IsCheckedDel(OnIsCheckedChanged); info.ChipType = scannerConfigList[i].StrChipType; info.ScanBoardName = scannerConfigList[i].DisplayName; info.ScanBoardSize =string.Format("{0}*{1}", scannerConfigList[i].ScanBdProp.Height,scannerConfigList[i].ScanBdProp.Width); info.CascadeType = scannerConfigList[i].StrCascadeType; DataGradItemInfoList.Add(info); //if (LoadScanProFile(_initializeFileNameList[i], out scanBDproData)) //{ //if (scanBDproData != null) //{ // info = new DataGradItemInfo(); // info.IsCheckedEvent += new IsCheckedDel(OnIsCheckedChanged); // info.ChipType = scanBDproData.StandardLedModuleProp.DriverChipType; // info.ScanBoardName = Path.GetFileNameWithoutExtension(_initializeFileNameList[i]); // info.ScanBoardSize = scanBDproData.Width + "x" + scanBDproData.Height; // info.CascadeType = GetModCascadeType(scanBDproData.ModCascadeType); // info.FileName = _initializeFileNameList[i]; // info.SaveFilePath = _initializeFileNameList[i]; // DataGradItemInfoList.Add(info); // CopyDirectory(_initializeFileNameList[i], _saveFilePath); //} //} } if (DataGradItemInfoList.Count > 0) { SelectedValue = DataGradItemInfoList[0]; } }