Esempio n. 1
0
        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;
                    }
                }
            }
        }