public void AddOrder(object target, object source, IDropInfo dropInfo) { Console.WriteLine("AddOrder"); //ObservableCollection<Models.Task> tasks = dropInfo.TargetCollection as ObservableCollection<Models.Task>; ScheduleTasks tasks = null; BookedOrder order = source as BookedOrder; DateTime start = Start; if (tasks.Count > 0) { start = tasks.Last().End.AddMinutes(1); } var procTime = order.BookQty / order.WPD; DateTime end = Start.AddDays((double)procTime); ScheduleTask task = new ScheduleTask() { Description = String.Format("{0} {1}", order.CustShortName, order.CustSpecNickName, order.OrdNum, order.OrdItem), Start = start, End = end }; tasks.Add(task); }
private void ShowFinishMenu() { // show window of finishing selected process var menuFinish = new ScheduleMenuFinish(); var vmFinish = menuFinish.DataContext as ScheduleMenuFinishViewModel; if (vmFinish is null) { return; } vmFinish.Path = $"{SelectedProcess.Name} will be finished: Warining: undefined behavior!"; vmFinish.Id = SelectedProcess.Id; try { // timepicker (Extended.Wpf.Toolkit nuget) // throw exception when select a ':' in time value menuFinish.ShowDialog(); } catch (InvalidOperationException) { MessageBox.Show( "wpfToolkit:TimePicker throw exception.\r\n" + "Don't select ':' while changing value of time.\r\n" + "Window will be closed. Try again...", "TimePicker error", MessageBoxButton.OK, MessageBoxImage.Stop); // close window Application.Current.Windows .OfType <Window>() .FirstOrDefault(window => window.Title == "Start process") ?.Close(); } // get info about task back if (vmFinish.Task is null) { return; } ScheduleTasks.Add(vmFinish.Task); taskLogger.Save(vmFinish.Task); }
private void ShowStartMenu() { // show window of starting new program var menuStart = new ScheduleMenuStart(); var vmStart = menuStart.DataContext as ScheduleMenuStartViewModel; if (vmStart is null) { return; } try { // timepicker (Extended.Wpf.Toolkit nuget) // throw exception when select a ':' in time value menuStart.ShowDialog(); } catch (InvalidOperationException) { MessageBox.Show( "wpfToolkit:TimePicker throw exception.\r\n" + "Don't select ':' while changing value of time.\r\n" + "Window will be closed. Try again...", "TimePicker error", MessageBoxButton.OK, MessageBoxImage.Stop); // close window Application.Current.Windows .OfType <Window>() .FirstOrDefault(window => window.Title == "Start process") ?.Close(); } // get info about task back if (vmStart.Task is null) { return; } ScheduleTasks.Add(vmStart.Task); taskLogger.Save(vmStart.Task); }