public void NotesContent_WritesDayModel()
        {
            Calculations.NowTime = new DateTime(2017, 1, 27);
            TimeMerge.Model.SingleDayData dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = Calculations.NowTime.Day, IsNoWorkDay = false
            };
            var dayViewModel = new SingleDayViewModel();

            dayViewModel.ReInit(dayData, null, null);
            var fakeMonthVM = new FakeMonthViewModel()
            {
                ForcedYearMonth = Calculations.NowTime
            };

            fakeMonthVM.AddDayVM(dayViewModel);
            var dayModel = (from dayVM in fakeMonthVM.Days.AsQueryable()
                            where dayVM.GetDayData().Day == Calculations.NowTime.Day
                            select dayVM.GetDayData()).FirstOrDefault();
            var notesPanelVM = new NotesPanelViewModel(fakeMonthVM, Calculations.NowTime.Day);

            notesPanelVM.NotesContent = "abc\ndef";

            Assert.AreEqual(notesPanelVM.NotesContent, dayModel.NotesContent);
        }
Beispiel #2
0
        private void onNotesClicked(SingleDayViewModel currentDay)
        {
            m_AnyModalPanel = new TimeMerge.View.NotesPanel();
            prepareModalPanel(m_AnyModalPanel, new NotesPanelViewModel(_mainWindowVM.MonthViewModel, currentDay.Day));

            // Show the SettingsPanel
            m_AnyModalPanel.Show();
        }
Beispiel #3
0
 public void AddDayVM(SingleDayViewModel dayVM)
 {
     this._days.Add(dayVM);
 }
Beispiel #4
0
        private void DataGrid_ContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            ContextMenu interruptTypeContextMenu = this.Resources["interruptionTypeContextMenu"] as ContextMenu;

            interruptTypeContextMenu.Items.Clear();

            DataGridColumn     currentCol = this.dataGrid.CurrentColumn;
            SingleDayViewModel currentDay = this.dataGrid.CurrentItem as SingleDayViewModel;
            // DataGridCellInfo currentCellInfo = this.dataGrid.CurrentCell;

            var    notesPanelVM       = new NotesPanelViewModel(_mainWindowVM.MonthViewModel, currentDay.Day);
            string noteMenuItemText   = notesPanelVM.NotesTitleText;
            var    noteForDayMenuItem = new MenuItem()
            {
                Header = noteMenuItemText
            };

            noteForDayMenuItem.Click += (noteClickSender, noteClickArgs) => onNotesClicked(currentDay);
            interruptTypeContextMenu.Items.Add(noteForDayMenuItem);
            interruptTypeContextMenu.Items.Add(new Separator());

            if (currentCol != null && currentDay != null) // do no context menu when right clicking e.g. on border between two cells
            {
                int clickedWorkSpanIndex     = (currentCol.DisplayIndex - _firstWorkSpanDataGridColumnIndex) / 2;
                int clickedInterruptionIndex = (currentCol.DisplayIndex - _firstInterruptionDataGridColumnIndex) / 2;

                if (currentCol.DisplayIndex >= _firstInterruptionDataGridColumnIndex) // right-click over any of the "Interruptions" columns
                {
                    // bool isStartClicked = (currentCol.DisplayIndex - _firstInterruptionDataGridColumnIndex) % 2 == 0;

                    foreach (TimeMerge.Model.WorkInterruption.WorkInterruptionType interruptionType in Enum.GetValues(typeof(TimeMerge.Model.WorkInterruption.WorkInterruptionType)))
                    {
                        var menuItem = new MenuItem()
                        {
                            Header = interruptionType, IsCheckable = true
                        };
                        Binding b = new Binding(string.Format("Interrupt{0}Type", clickedInterruptionIndex));
                        b.Source             = currentDay;
                        b.Converter          = new InterruptTypeConverter();
                        b.ConverterParameter = interruptionType;
                        b.Mode = BindingMode.TwoWay;
                        menuItem.SetBinding(MenuItem.IsCheckedProperty, b);

                        interruptTypeContextMenu.Items.Add(menuItem);
                    }

                    interruptTypeContextMenu.Items.Add(new Separator());
                }

                if (currentCol.DisplayIndex >= _firstWorkSpanDataGridColumnIndex)
                {
                    // "Add Lunch Time" menu item
                    var lunchTimeMenuItem = new MenuItem()
                    {
                        Header = "Pridať prestávku na obed 20 min."
                    };
                    var lunchTimeCommandArgs = new SingleDayViewModel.AddLunchTimeInterruptionArgs();
                    lunchTimeCommandArgs.IsInterruption = currentCol.DisplayIndex >= _firstInterruptionDataGridColumnIndex;
                    lunchTimeCommandArgs.WorkSpanIndex  = lunchTimeCommandArgs.IsInterruption ? clickedInterruptionIndex : clickedWorkSpanIndex;
                    lunchTimeCommandArgs.FailAction     = new Action <string>((errorMessage) =>
                    {
                        _mainWindowVM.MessageBarVM.AddRow(errorMessage);
                    });
                    lunchTimeMenuItem.Click += (clickSender, clickArgs) => currentDay.AddLunchTimeInterruptionCommand.Execute(lunchTimeCommandArgs);
                    interruptTypeContextMenu.Items.Add(lunchTimeMenuItem);

                    interruptTypeContextMenu.Items.Add(new Separator());

                    // "Clear Correction" menu item
                    var menuItem = new MenuItem()
                    {
                        Header = "Zrušiť túto korekciu"
                    };
                    var commandArgs = new SingleDayViewModel.ClearWorkSpanCorrectionArgs();
                    commandArgs.IsInterruption = currentCol.DisplayIndex >= _firstInterruptionDataGridColumnIndex;
                    commandArgs.WorkSpanIndex  = commandArgs.IsInterruption ? clickedInterruptionIndex : clickedWorkSpanIndex;
                    menuItem.Click            += (clickSender, clickArgs) => currentDay.ClearWorkSpanCommand.Execute(commandArgs);
                    interruptTypeContextMenu.Items.Add(menuItem);
                }
            }

            if (interruptTypeContextMenu.Items.Count == 0)
            {
                e.Handled = true;
            }
        }