Example #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 = _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;
        }
Example #2
0
        private void OpenContextMenu(ClassCardViewMode classCard)
        {
            var model = classCard.DataContext as ClassCardViewModel;

            if (model == null)
            {
                return;
            }
            var cm = new ContextMenu();

            cm.Items.Add(new MenuItem {
                Header = "Редактировать", Command = EditClassCommand
            });
            cm.Items.Add(new MenuItem {
                Header = "Скопировать", Command = CopyClassCommand, InputGestureText = "Ctrl+C"
            });
            cm.Items.Add(new MenuItem {
                Header = "Вставить", Command = PasteClassCommand, InputGestureText = "Ctrl+V"
            });
            cm.Items.Add(new MenuItem {
                Header = "Вырезать", Command = CutClassCommand, InputGestureText = "Ctrl+X"
            });
            cm.Items.Add(new MenuItem {
                Header = "Удалить", Command = DeleteClassCommand, InputGestureText = "Del"
            });
            //cm.Items.Add(new MenuItem { Header = "Send to Clipboard", Command = SendToCardClipboardCommand });
            cm.IsOpen = true;
        }
Example #3
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
            {
                ClassesCards[row][col].DataContext = new ClassCardViewModel(null)
                {
                    Project = Project
                };;
            }
            UpdateSelection(row, col);
        }
Example #4
0
        private void UpdateSelection(ClassCardViewMode card)
        {
            var row = Grid.GetRow(card) - TitleRowsCount;
            var col = Grid.GetColumn(card) - TimeColumnsCount;

            UpdateSelection(row, col);
        }
Example #5
0
 private void RemoveClassCardHandlers(ClassCardViewMode card)
 {
     card.MouseLeftButtonUp    -= ClassCardOnMouseLeftButtonUp;
     card.MouseRightButtonUp   -= ClassCardOnMouseRightButtonUp;
     card.MouseEnter           -= CardOnMouseEnter;
     card.MouseLeave           -= CardOnMouseLeave;
     card.MouseLeftButtonDown  -= CardOnMouseLeftButtonDown;
     card.MouseRightButtonDown -= CardOnMouseRightButtonDown;
 }
Example #6
0
 private void AddClassCardHandlers(ClassCardViewMode card)
 {
     card.MouseLeftButtonUp    += ClassCardOnMouseLeftButtonUp;
     card.MouseRightButtonUp   += ClassCardOnMouseRightButtonUp;
     card.MouseEnter           += CardOnMouseEnter;
     card.MouseLeave           += CardOnMouseLeave;
     card.MouseLeftButtonDown  += CardOnMouseLeftButtonDown;
     card.MouseRightButtonDown += CardOnMouseRightButtonDown;
 }
Example #7
0
        private void UpdateSelection(ClassCardViewMode card)
        {
            var row = Grid.GetRow(card) - TitleRowsCount;
            var col = Grid.GetColumn(card) - TimeColumnsCount;

            _selectedRow    = row;
            _selectedColumn = col;
            _selectedCard   = ClassesCards[row][col].DataContext as ClassCardViewModel;
            if (_selectedCard == null)
            {
                return;
            }
            _selectedCard.IsSelected = true;
        }
Example #8
0
 private void InitLectureCards()
 {
     ClassesRowsCount    = _classesTable.RowsCount();
     ClassesColumnsCount = _classesTable.ColumnsCount();
     ClassesCards        = new ClassCardViewMode[ClassesRowsCount][];
     for (var row = 0; row < ClassesRowsCount; row++)
     {
         ClassesCards[row] = new ClassCardViewMode[ClassesColumnsCount];
         for (var col = 0; col < ClassesColumnsCount; col++)
         {
             ClassesCards[row][col] = CreateClassCard(row, col);
         }
     }
 }
Example #9
0
        private ClassCardViewMode CreateClassCard(int row, int column)
        {
            var viewModel = new ClassCardViewModel(_classesTable.Table[row][column])
            {
                Project = Project
            };
            var classCard = new ClassCardViewMode {
                DataContext = viewModel
            };

            Grid.SetRow(classCard, row + TitleRowsCount);
            Grid.SetColumn(classCard, column + TimeColumnsCount);
            AddClassCardHandlers(classCard);
            return(classCard);
        }
Example #10
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);
        }
Example #11
0
        private void OpenContextMenu(ClassCardViewMode classCard)
        {
            var model = classCard.DataContext as ClassCardViewModel;

            if (model == null)
            {
                return;
            }
            var cm = new ContextMenu();

            cm.Items.Add(new MenuItem {
                Header = "Copy", Command = CopyClassCommand
            });
            cm.Items.Add(new MenuItem {
                Header = "Paste", Command = PasteClassCommand
            });
            cm.Items.Add(new MenuItem {
                Header = "Send to Clipboard", Command = SendToCardClipboardCommand
            });
            cm.IsOpen = true;
        }