private void FileListView_SelectionChange(object sender, SelectionChangedEventArgs e) { ListView listView = sender as ListView; if (listView != null) { ExcelFileListItem item = listView.SelectedItem as ExcelFileListItem; _excelItemChoosed = item; } _IDItemSelected = null; if (_excelItemChoosed == null) { idListView.ItemsSource = null; propertyDataGrid.ItemsSource = null; checkBox_changed.IsEnabled = false; checkBox_changed.IsChecked = false; } else { propertyDataGrid.ItemsSource = null; idListView.ItemsSource = GlobalCfg.Instance.GetIDList(_excelItemChoosed.FilePath); GlobalCfg.Instance.ResetPreviousIsNeedGen(); checkBox_changed.IsEnabled = true; checkBox_changed.IsChecked = false; } JudgeMultiFuncBtnState(); EditingModeRender(); if (listView != null && idListView.ItemsSource == null) { listView.SelectedItem = null; } }
//仅修改逻辑缓存中的值,不直接修改配置文件 public void ApplyRow(int branchIdx, IDListItem item) { //if(currentTablediffs.Count > branchIdx && currentTables.Count > branchIdx + 1 && // currentTablediffs[branchIdx] != null && currentTables[branchIdx + 1] != null && // item != null && item.States.Count > branchIdx) //{ //} table lt = currentLuaTableData.tables[0]; //local table table bt = currentLuaTableData.tables[branchIdx + 1]; //branch table tablediff btd = currentLuaTableData.tableDiffs[branchIdx]; //branch tablediff if (bt == null) { bt = new table(lt); currentLuaTableData.tables[branchIdx + 1] = bt; } string status = item.States[branchIdx]; btd.Apply(status, item.ID, bt, lt); if (currentLuaTableData.applyedRows == null) { currentLuaTableData.applyedRows = new Dictionary <string, Dictionary <int, string> >(); } if (!currentLuaTableData.applyedRows.ContainsKey(item.ID)) { currentLuaTableData.applyedRows[item.ID] = new Dictionary <int, string>(); } currentLuaTableData.applyedRows[item.ID][branchIdx] = item.States[branchIdx]; int index = currentLuaTableData.idList.IndexOf(item); _lTableDataDic[currentExcelpath].idList[index].SetStates(STATUS_NONE, branchIdx); }
public void CancelRow(int branchIdx, IDListItem item) { Dictionary <string, Dictionary <int, string> > applyedRows = currentLuaTableData.applyedRows; table bt = currentLuaTableData.tables[branchIdx + 1]; //branch table tablediff btd = currentLuaTableData.tableDiffs[branchIdx]; //branch tablediff if (bt == null) { return; } btd.Cancel(item.ID, bt); int index = currentLuaTableData.idList.IndexOf(item); _lTableDataDic[currentExcelpath].idList[index].SetStates(applyedRows[item.ID][branchIdx], branchIdx); applyedRows[item.ID][branchIdx] = ""; }
private void FileListView_SelectionChange(object sender, SelectionChangedEventArgs e) { ListView listView = sender as ListView; ExcelFileListItem item = listView.SelectedItem as ExcelFileListItem; _listItemChoosed = item; if (item == null) { return; } _IDItemSelected = null; JudgeMultiFuncBtnState(); idListView.ItemsSource = null; propertyDataGrid.ItemsSource = null; ResetGenBtnEnable(); idListView.ItemsSource = GlobalCfg.Instance.GetIDList(item.FilePath); ResetGenBtnState(); }
public ObservableCollection <IDListItem> GetIDList(string excelpath) { previousLuaTableData = currentLuaTableData; currentLuaTableData = InitLuaTableData(excelpath); if (currentLuaTableData == null) { return(null); } currentExcelpath = excelpath; if (currentLuaTableData.tableDiffs.Count <= 0) { for (int i = 1; i < currentLuaTableData.tables.Length; i++) { currentLuaTableData.tableDiffs.Add(CompareTable(currentLuaTableData.tables[0], currentLuaTableData.tables[i])); } } if (currentLuaTableData.idList == null) { currentLuaTableData.idList = new ObservableCollection <IDListItem>(); for (int i = 0; i < currentLuaTableData.tables[0].configs.Count; i++) { currentLuaTableData.idList.Add(new IDListItem { ID = currentLuaTableData.tables[0].configs[i].key, IdDisplay = IDListItem.GenIdDisplay(currentLuaTableData.tables[0].configs[i]), Row = i, States = GetRowAllStatus(currentLuaTableData.tables[0].configs[i].key), }); } Dictionary <string, IDListItem> tmpDic = GetExcelDeletedRow(); foreach (var item in tmpDic.Values) { currentLuaTableData.idList.Add(item); } } return(currentLuaTableData.idList); }
private void FilterItems(ListView list) { switch (list.Name) { case "excelListView": ObservableCollection <ExcelFileListItem> excelRes = excelFiles; if (IsCheckEditing) { excelRes = GetFilteredCollection(excelRes, FILTER_BY_EDITING); } list.ItemsSource = excelRes; if (IsSearchingExcel) { excelRes = GetMatchItem(excelRes, excelSearchKey); } list.ItemsSource = excelRes; break; case "idListView": if (_excelItemChoosed == null) { return; } ObservableCollection <IDListItem> idRes = GlobalCfg.Instance.GetIDList(_excelItemChoosed.FilePath); if (IsCheckChanged) { idRes = GetFilteredCollection(idRes, FILTER_BY_STATES); } list.ItemsSource = idRes; if (IsSearchingId) { idRes = GetMatchItem(idRes, idSearchKey); } list.ItemsSource = idRes; break; } #region 获得搜索数据 ObservableCollection <T> GetMatchItem <T>(ObservableCollection <T> sourceItem, string input) { bool IsMatchFromStart = true; if (input.StartsWith("*")) { IsMatchFromStart = false; input = input.Substring(1); } ObservableCollection <T> searchRes = new ObservableCollection <T>(); for (int i = 0; i < sourceItem.Count; i++) { T item = (T)sourceItem[i]; string ss = null; if (item is ExcelFileListItem) { ExcelFileListItem excelItem = item as ExcelFileListItem; ss = excelItem.Name; } else if (item is IDListItem) { IDListItem idItem = item as IDListItem; ss = idItem.IdDisplay; } else { return(null); } if (StringHelper.StringMatch(ss, input, IsMatchFromStart, false)) { searchRes.Add(item); } } return(searchRes); } #endregion #region 获得过滤后数据 ObservableCollection <T> GetFilteredCollection <T>(ObservableCollection <T> sourceItem, string filterBy) { ObservableCollection <T> filteredCollection = new ObservableCollection <T>(); for (int j = 0; j < sourceItem.Count; j++) { T item = (T)sourceItem[j]; if (item is ExcelFileListItem && filterBy == FILTER_BY_EDITING) { ExcelFileListItem excelItem = item as ExcelFileListItem; if (excelItem.IsEditing) { filteredCollection.Add(item); } } else if (item is IDListItem) { IDListItem idItem = item as IDListItem; if (filterBy == FILTER_BY_STATES) { for (int i = 0; i < idItem.States.Count; i++) { if (idItem.States[i] != "") { filteredCollection.Add(item); break; } else if (idItem.IsApplys[i]) { filteredCollection.Add(item); break; } } } } } return(filteredCollection); } #endregion }
private void IDListView_SelectChange(object sender, SelectionChangedEventArgs e) { IDListItem item = (sender as ListView).SelectedItem as IDListItem; if (item == null) { propertyDataGrid.ItemsSource = null; return; } _IDItemSelected = item; ObservableCollection <PropertyListItem> fieldList = new ObservableCollection <PropertyListItem>(); Excel excel = GlobalCfg.Instance.GetParsedExcel(_excelItemChoosed.FilePath); if (excel == null) { (sender as ListView).SelectedItem = null; return; } List <PropertyInfo> propertyList = excel.Properties; List <lparser.config> configs = GlobalCfg.Instance.GetTableRows(item.ID); lparser.config fullConfig = configs[0]; foreach (lparser.config config in configs) { if (config != null) { if (config.properties.Count > fullConfig.properties.Count) { fullConfig = config; } } } string ename = string.Empty; string cname = string.Empty; for (int i = 0, j = 0; i < fullConfig.properties.Count; i++) { ename = fullConfig.properties[i].name; while (propertyList[j].ename != ename) { j++; } cname = propertyList[j].cname; fieldList.Add(new PropertyListItem() { IsNeedGen = GlobalCfg.Instance.GetIsNeedGen(fullConfig.key, ename), PropertyName = cname + "(" + ename + ")", EnName = ename, LocalContent = configs[0] != null && configs[0].propertiesDic.ContainsKey(ename) ? configs[0].propertiesDic[ename].value4Show : null, Trunk = configs[1] != null && configs[1].propertiesDic.ContainsKey(ename) ? configs[1].propertiesDic[ename].value4Show : null, Studio = configs[2] != null && configs[2].propertiesDic.ContainsKey(ename) ? configs[2].propertiesDic[ename].value4Show : null, TF = configs[3] != null && configs[3].propertiesDic.ContainsKey(ename) ? configs[3].propertiesDic[ename].value4Show : null, Release = configs[4] != null && configs[4].propertiesDic.ContainsKey(ename) ? configs[4].propertiesDic[ename].value4Show : null }); } propertyDataGrid.ItemsSource = fieldList; RefreshGenBtnState(); //刷新单元格颜色 for (int j = 0; j < GlobalCfg.BranchCount; j++) { tablerowdiff trd = GlobalCfg.Instance.GetCellAllStatus(item.ID, j); if (trd == null) { continue; } for (int a = 0; a < fieldList.Count; a++) { if (trd.modifiedcells != null && trd.modifiedcells.ContainsKey(fieldList[a].EnName)) { DataGridCell dataGridCell = WPFHelper.GetCell(propertyDataGrid, a, j + 3); dataGridCell.Background = Brushes.LightBlue; } if (trd.modifiedcells != null && trd.addedcells.ContainsKey(fieldList[a].EnName)) { DataGridCell dataGridCell = WPFHelper.GetCell(propertyDataGrid, a, j + 3); dataGridCell.Background = Brushes.LightPink; } if (trd.modifiedcells != null && trd.deletedcells.ContainsKey(fieldList[a].EnName)) { DataGridCell dataGridCell = WPFHelper.GetCell(propertyDataGrid, a, j + 3); dataGridCell.Background = Brushes.LightBlue; } } } }
private void IDListView_SelectChange(object sender, SelectionChangedEventArgs e) { IDListItem item = (sender as ListView).SelectedItem as IDListItem; if (item == null) { return; } Excel excel = GlobalCfg.Instance.GetParsedExcel(_listItemChoosed.FilePath); List <PropertyInfo> propertyList = excel.Properties; ObservableCollection <PropertyListItem> fieldList = new ObservableCollection <PropertyListItem>(); _IDItemSelected = item; List <lparser.config> configs = GlobalCfg.Instance.GetTableRow(item.ID); string ename = string.Empty; for (int i = 0; i < propertyList.Count; i++) { ename = propertyList[i].ename; fieldList.Add(new PropertyListItem() { PropertyName = propertyList[i].cname, EnName = propertyList[i].ename, Context = configs[0] != null && configs[0].propertiesDic.ContainsKey(ename) ? configs[0].propertiesDic[ename].value : null, Trunk = configs[1] != null && configs[1].propertiesDic.ContainsKey(ename) ? configs[1].propertiesDic[ename].value : null, Studio = configs[2] != null && configs[2].propertiesDic.ContainsKey(ename) ? configs[2].propertiesDic[ename].value : null, TF = configs[3] != null && configs[3].propertiesDic.ContainsKey(ename) ? configs[3].propertiesDic[ename].value : null, Release = configs[4] != null && configs[4].propertiesDic.ContainsKey(ename) ? configs[4].propertiesDic[ename].value : null }); } propertyDataGrid.ItemsSource = fieldList; ResetGenBtnState(); //刷新单元格颜色 for (int j = 0; j < GlobalCfg.BranchCount; j++) { tablerowdiff trd = GlobalCfg.Instance.GetCellAllStatus(item.ID, j); if (trd == null) { continue; } for (int a = 0; a < fieldList.Count; a++) { if (trd.modifiedcells != null && trd.modifiedcells.ContainsKey(fieldList[a].EnName)) { DataGridCell dataGridCell = GetCell(propertyDataGrid, a, j + 3); dataGridCell.Background = Brushes.LightBlue; } if (trd.modifiedcells != null && trd.addedcells.ContainsKey(fieldList[a].EnName)) { DataGridCell dataGridCell = GetCell(propertyDataGrid, a, j + 3); dataGridCell.Background = Brushes.LightPink; } if (trd.modifiedcells != null && trd.deletedcells.ContainsKey(fieldList[a].EnName)) { DataGridCell dataGridCell = GetCell(propertyDataGrid, a, j + 3); dataGridCell.Background = Brushes.LightBlue; } } } }