/// <summary> /// 手动指定班次估算值 /// </summary> /// <param name="layer"></param> /// <param name="newValue"></param> /// <param name="e"></param> public void ChangeAssignmentTypeCells(object layer, object newValue, WPF.ApplicationFramework.Controls.CellEditRoutedEventArgs e) { if(layer == null) return; var timeRange = new Core.Reflector(layer).Property<TimeRange>("TimeRange"); var dataRowRange = new Core.Reflector(layer).Property<int[]>("DataRowRange"); // HeaderContainer<AssignmentType, DailyCounter<AssignmentType>, DateTime> CellTraversal<int, HeaderContainer<AssignmentType, DailyCounter<AssignmentType>, DateTime>>(timeRange, dataRowRange, newValue, assignmentType => { }, WhenShiftEstimatesChanged, AssignmentTypes, (value, item) => item.SaftyGetProperty<double, DailyCounter<AssignmentType>>(c => c.Max) == value, (value, header, item) => { DateTime? effectDate = null; item.SaftyInvoke<DailyCounter<AssignmentType>>(c => { if (value == c.Max) return; AlterShiftEstimation(c, value); // don't change order //c.Max = value; // don't change order -> move to AlterShiftEstimation method c.IsDirty = true; effectDate = c.Date; }); return effectDate; }, () => { CellChanged = true; }, e); }
private void CellTraversal <TValue, TRootItem>(object layer, object newValue, Action <TRootItem> rootItemPreparing, Action <TRootItem> rootItemCellsValueChanged, IList itemsSource, System.Func <TValue, TRootItem, ITerm, DateTime?> func, Action callback, CellEditRoutedEventArgs e) where TRootItem : IEnumerable { if (layer == null) { return; } var timeRange = new Core.Reflector(layer).Property <TimeRange>("TimeRange"); var dataRowRange = new Core.Reflector(layer).Property <int[]>("DataRowRange"); CellTraversal(timeRange, dataRowRange, newValue, rootItemPreparing, rootItemCellsValueChanged, itemsSource, (value, item) => Equals(value, item), func, callback, e); }
public void SetNewTime(RoutedEventArgs e) { var source = new Core.Reflector(e.OriginalSource); var newPlacement = source.Property <ITerm>("DropedPlacement"); if (newPlacement == null) { return; } newPlacement = new TimeRange(newPlacement.Start.RemoveSeconds(), newPlacement.End.RemoveSeconds()); var target = source.Property <ICanConvertToValueTerm>("PointOutBlock"); var newStart = newPlacement.Start; var newEnd = newPlacement.End; if ((target.Start == newStart && target.End == newEnd)) { return; } var targetIsSubeventInsertRule = !ReferenceEquals(Entity, target); //判断是assignment 或 subeventInsertRule if (targetIsSubeventInsertRule) { // 以下为subeventInsertRule检查 if (!newPlacement.IsInTheRange(Entity.Start, Entity.End)) // 有没有超出 assignment { return; } if (Entity.GetSubEventInsertRules().Any(o => !ReferenceEquals(o, target) && o.IsCoverd(newPlacement))) // 和其他 subeventInsertRule 相交 { return; } } target.SetNewTime(newStart, newEnd); }
/// <summary> /// 手动指定班次估算值 /// </summary> /// <param name="layer"></param> /// <param name="newValue"></param> /// <param name="e"></param> public void ChangeAssignmentTypeCells(object layer, object newValue, WPF.ApplicationFramework.Controls.CellEditRoutedEventArgs e) { if (layer == null) { return; } var timeRange = new Core.Reflector(layer).Property <TimeRange>("TimeRange"); var dataRowRange = new Core.Reflector(layer).Property <int[]>("DataRowRange"); // HeaderContainer<AssignmentType, DailyCounter<AssignmentType>, DateTime> CellTraversal <int, HeaderContainer <AssignmentType, DailyCounter <AssignmentType>, DateTime> >(timeRange, dataRowRange, newValue, assignmentType => { }, WhenShiftEstimatesChanged, AssignmentTypes, (value, item) => item.SaftyGetProperty <double, DailyCounter <AssignmentType> >(c => c.Max) == value, (value, header, item) => { DateTime?effectDate = null; item.SaftyInvoke <DailyCounter <AssignmentType> >(c => { if (value == c.Max) { return; } AlterShiftEstimation(c, value); // don't change order //c.Max = value; // don't change order -> move to AlterShiftEstimation method c.IsDirty = true; effectDate = c.Date; }); return(effectDate); }, () => { CellChanged = true; }, e); }