private void OpenCardEditor(ClassCardViewMode card) { Point position = card.PointToScreen(new Point(0d, 0d)); var centerY = position.Y + (card.ActualHeight) / 2; var centerX = position.X + (card.ActualWidth) / 2; var row = Grid.GetRow(card) - TitleRowsCount; var col = Grid.GetColumn(card) - TimeColumnsCount; var @class = _classesTable.Table[row][col]; if (@class == null) { _classesTable.Table[row][col] = new ClassRecord(); @class = _classesTable.Table[row][col]; } var model = new ClassCardViewModel(@class) { Project = Project }; var edit = new ClassCardEditMode(centerX, centerY) { DataContext = model }; edit.ShowDialog(); ClassesCards[row][col].DataContext = model; _selectedCard = model; }
private void OpenCardEditor(ClassCardViewMode card) { Point position = card.PointToScreen(new Point(0d, 0d)); var centerY = position.Y + (card.ActualHeight) / 2; var centerX = position.X + (card.ActualWidth) / 2; var row = Grid.GetRow(card) - TitleRowsCount; var col = Grid.GetColumn(card) - TimeColumnsCount; var @class = _groupClasses.GetClass(row, col) ?? new ClassRecord(); var model = new ClassCardViewModel(@class) { Project = Project }; var edit = new ClassCardEditMode(centerX, centerY) { DataContext = model }; edit.ShowDialog(); if (@class.Classroom != null || @class.Lecturer != null || @class.Subject != null) { _groupClasses.SetClass(row, col, @class); ClassesCards[row][col].DataContext = model; } else { ClassesCards[row][col].DataContext = new ClassCardViewModel(null) { Project = Project };; } UpdateSelection(row, col); }