Beispiel #1
0
 public CompareRowVM(List<string> studyUnitGuids)
 {
     rowModel = new CompareRow();
     this.studyUnitGuids = studyUnitGuids;
     diffOptions = new ObservableCollection<DiffOption>();
     selectedDiffOptions = new ObservableCollection<DiffOption>();
     foreach (string guid in studyUnitGuids)
     {
         selectedDiffOptions.Add(null);
     }
     backSelectedDiffOptions = new List<DiffOption>();
 }
Beispiel #2
0
 private void UpdateViewModel(ObservableCollection<CompareRowVM> rows, CompareRow existRowModel)
 {
     if (existRowModel == null)
     {
         return;
     }
     //タイトルは常に最新のものを使用する
     //メモは既存のものを反映する
     Memo = existRowModel.Memo;
     //セルの値を更新
     selectedDiffOptions.Clear();
     foreach (CompareCell cell in rowModel.Cells)
     {
         //セルに対応した既存のセルを取得
         CompareCell existCell = existRowModel.FindCell(cell.ColumnStudyUnitId);
         //既存のセルが存在するならばそれに対応したDiffOptionに変換
         DiffOption diffOption = FindDiffOption(rows, existCell);
         //DiffOptionに追加(画面上ではselectedDiffOptionsが更新される)。
         selectedDiffOptions.Add(diffOption);
     }
 }
Beispiel #3
0
 public void Init(ObservableCollection<CompareRowVM> rows, CompareRow existRowModel)
 {
     //選択肢の生成
     CreateDiffOptions(rows);
     //セルの生成
     CreateCells();
     //既存のモデルの値を使ってViewModelを更新する
     UpdateViewModel(rows, existRowModel);
 }
Beispiel #4
0
        private static ICollection<CompareRow> CreateCompareRows(List<CompareItem> compareItems)
        {
            Dictionary<string, CompareRow> rowMap = new Dictionary<string, CompareRow>();
            foreach (CompareItem compareItem in compareItems)
            {
                CompareRow row = null;
                if (rowMap.ContainsKey(compareItem.TargetTitle))
                {
                    row = rowMap[compareItem.TargetTitle];
                }
                else
                {
                    row = new CompareRow();
                    row.Memo = compareItem.Memo;
                    row.Title = compareItem.TargetTitle;
                    rowMap[row.Title] = row;
                }
                row.RowGroupIds.Add(compareItem.TargetId); //あくまでもターゲットが基本

                if (compareItem.IsMatch)
                {
                    CompareCell sourceCell = row.FindCell(compareItem.SourceId.StudyUnitId);
                    if (sourceCell == null)
                    {
                        sourceCell = new CompareCell();
                        sourceCell.CompareValue = Options.COMPARE_VALUE_MATCH_CODE;
                        sourceCell.ColumnStudyUnitId = compareItem.SourceId.StudyUnitId;
                        row.Cells.Add(sourceCell);
                    }
                }
                CompareCell targetCell = row.FindCell(compareItem.TargetId.StudyUnitId);
                if (targetCell == null)
                {
                    targetCell = new CompareCell();
                    targetCell.CompareValue = compareItem.IsMatch ? Options.COMPARE_VALUE_MATCH_CODE : Options.COMPARE_VALUE_PARTIALMATCH_CODE; //一致してないのは書き出していないはず
                    if (compareItem.IsPartialPatch)
                    {
                        targetCell.TargetTitle = compareItem.SourceTitle;
                    }
                    targetCell.ColumnStudyUnitId = compareItem.TargetId.StudyUnitId;
                    row.Cells.Add(targetCell);
                }
            }
            return rowMap.Values;
        }