Exemplo n.º 1
0
        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
            {
                _groupClasses.RemoveClass(row, col);
                ClassesCards[row][col].DataContext = new ClassCardViewModel(null) { Project = Project }; ;
            }
            UpdateSelection(row, col);
        }
Exemplo n.º 2
0
 private void UpdateSelection(int row, int col)
 {
     DropSelected();
     _selectedRow = row;
     _selectedColumn = col;
     _selectedCard = ClassesCards[row][col].DataContext as ClassCardViewModel;
     if (_selectedCard == null) return;
     _selectedCard.IsSelected = true;
 }
Exemplo n.º 3
0
 private ClassCardViewMode CreateClassCard(int row, int column)
 {
     var viewModel = new ClassCardViewModel(_groupClasses.GetClass(row, column)) { Project = Project };
     var classCard = new ClassCardViewMode { DataContext = viewModel };
     Grid.SetRow(classCard, row + TitleRowsCount);
     Grid.SetColumn(classCard, column + TimeColumnsCount);
     if (Project.Schedule.TimeLine[row].Number + 1 == ClassesPerDayMax)
     {
         classCard.Margin = new Thickness(0, 0, 0, DayMarginOffset);
     }
     AddClassCardHandlers(classCard);
     return classCard;
 }