public static void DrawSortableValuesAnimate( this DrawingContext dc, SortableVm sortableVm, double stageRenderWidth, double stageRenderHeight) { if (sortableVm?.CurrentSortableItemVms == null) { return; } if (sortableVm?.PastSortableItemVms == null) { return; } for (var i = 0; i < sortableVm.CurrentSortableItemVms.Length; i++) { dc.DrawSortableValueAnimate( animationPct: sortableVm.AnimationPct, sortableVmStyle: sortableVm.SortableVmStyle, sortableItemVmOld: sortableVm.PastSortableItemVms[i], sortableItemVm: sortableVm.CurrentSortableItemVms[i], stageRenderWidth: stageRenderWidth, stageRenderHeight: stageRenderHeight); } }
public static Tuple <StageVm, SortableVm> ToNextTicOld(this StageVm stageVm, double animationPct, SortableVm sortableVm = null) { if (stageVm.SortableVm == null) { if (sortableVm == null) { return(new Tuple <StageVm, SortableVm>( item1: stageVm, item2: null)); } return(new Tuple <StageVm, SortableVm>( item1: new StageVm( stageIndex: stageVm.StageIndex, stageVmStyle: stageVm.StageVmStyle, order: stageVm.Order, keyPairVms: stageVm.KeyPairVms, sortableVm: stageVm.SortableVm.ChangeSectionCount(stageVm.StageVmStyle.SortableVmStyle.SectionCount) .ChangeAnimationPct(animationPct)), item2: null)); } else { return(new Tuple <StageVm, SortableVm>( item1: new StageVm( stageIndex: stageVm.StageIndex, stageVmStyle: stageVm.StageVmStyle, order: stageVm.Order, keyPairVms: stageVm.KeyPairVms, sortableVm: stageVm.SortableVm.ChangeAnimationPct(animationPct)), item2: null)); } }
public static SortableVm ToInitStep(this SortableVm sortableVm) { return(new SortableVm( order: sortableVm.Order, sortableVmStyle: sortableVm.SortableVmStyle, currentSortableItemVms: sortableVm.CurrentSortableItemVms, pastSortableItemVms: null, stageVmStep: StageVmStep.Init, animationPct: 0)); }
public static SortableVm ToPostSortStep(this SortableVm sortableVm) { return(new SortableVm( order: sortableVm.Order, sortableVmStyle: sortableVm.SortableVmStyle, currentSortableItemVms: sortableVm.CurrentSortableItemVms .Select(svm => svm.ToRightSortableItemVm()) .ToArray(), pastSortableItemVms: sortableVm.CurrentSortableItemVms, stageVmStep: StageVmStep.PostSort, animationPct: 0)); }
public static void DrawSortableValues(this DrawingContext dc, SortableVm sortableVm, double stageRenderWidth, double stageRenderHeight) { if (sortableVm?.CurrentSortableItemVms == null) { return; } foreach (var sortableItemVm in sortableVm.CurrentSortableItemVms) { dc.DrawSortableValue(sortableVm.SortableVmStyle, sortableItemVm, stageRenderWidth, stageRenderHeight); } }
public static SortableVm ToLeftStep(this SortableVm sortableVm, IEnumerable <KeyPairVm> keyPairVms) { return(new SortableVm( order: sortableVm.Order, sortableVmStyle: sortableVm.SortableVmStyle, currentSortableItemVms: sortableVm.CurrentSortableItemVms .Select(svm => svm.ToPresortSortableItemVm(keyPairVms)) .ToArray(), pastSortableItemVms: sortableVm.CurrentSortableItemVms .Select(svm => svm.ToLeftSortableItemVm()) .ToArray(), stageVmStep: StageVmStep.Left, animationPct: 0)); }
public StageVm( int stageIndex, StageVmStyle stageVmStyle, int order, IEnumerable <KeyPairVm> keyPairVms, SortableVm sortableVm ) { StageIndex = stageIndex; StageVmStyle = stageVmStyle; Order = order; _keyPairVms = keyPairVms.ToList(); SortableVm = sortableVm; SectionCount = _keyPairVms.MaxOr(vm => vm.StageSection, 0) + 1; }
public static StageVm SwitchBlocksToStageVm( this core.Sorting.ISwitch[][] switchBlocks, int stageIndex, StageVmStyle stageVmStyle, int order, SortableVm sortableVm) { var kpVms = switchBlocks.ToKeyPairVms(stageIndex, stageVmStyle); return(new StageVm( stageIndex: stageIndex, stageVmStyle: stageVmStyle.ChangeSectionCount(switchBlocks.Length), order: order, keyPairVms: kpVms, sortableVm: sortableVm.ChangeSectionCount(switchBlocks.Length) )); }
public static SortableVm ChangeAnimationPct(this SortableVm sortableVm, double animationPct) { if (sortableVm == null) { return(null); } return(new SortableVm ( sortableVmStyle: sortableVm.SortableVmStyle, order: sortableVm.Order, currentSortableItemVms: sortableVm.CurrentSortableItemVms, pastSortableItemVms: sortableVm.PastSortableItemVms, stageVmStep: sortableVm.StageVmStep, animationPct: animationPct )); }
public static SortableVm ChangeSectionCount(this SortableVm sortableVm, int sectionCount) { if (sortableVm == null) { return(null); } return(new SortableVm ( sortableVmStyle: sortableVm.SortableVmStyle.ChangeSectionCount(sectionCount), order: sortableVm.Order, currentSortableItemVms: sortableVm.CurrentSortableItemVms, pastSortableItemVms: sortableVm.PastSortableItemVms, stageVmStep: sortableVm.StageVmStep, animationPct: sortableVm.AnimationPct )); }
public static List <StageVm> Tic( this IEnumerable <StageVm> stageVms, SortableVm sortableVm, double animationPct) { var curSortableVm = sortableVm; var lst = new List <StageVm>(); //foreach (var stageVm in stageVms) //{ // var res = stageVm.ToNextStep(curSortableVm); // lst.Add(res.Item1); // curSortableVm = null; //} //return lst; return(stageVms.Select(vm => vm.ToNextTic(animationPct)) .ToList()); }
public static List <StageVm> Step(this IEnumerable <StageVm> stageVms, SortableVm sortableVm) { var curSortableVm = sortableVm; var stageVmList = stageVms.ToList(); var lstRet = new List <StageVm>(); //if (curSortableVm != null) //{ // curSortableVm = curSortableVm.ToLeftStep(stageVmList[0].KeyPairVms.ToArray()); //} foreach (var stageVm in stageVmList) { var res = stageVm.ToNextStep(curSortableVm); lstRet.Add(res.Item1); curSortableVm = res.Item2; } return(lstRet); }
public static SortableVm ToPreSortStep(this SortableVm sortableVm, IEnumerable <KeyPairVm> keyPairVms) { var newSortableVm = new SortableVm( order: sortableVm.Order, sortableVmStyle: sortableVm.SortableVmStyle, currentSortableItemVms: sortableVm.CurrentSortableItemVms.UpdateSortableVms(keyPairVms).ToArray(), pastSortableItemVms: sortableVm.CurrentSortableItemVms, stageVmStep: sortableVm.StageVmStep, animationPct: 0); return(new SortableVm( order: sortableVm.Order, sortableVmStyle: sortableVm.SortableVmStyle, currentSortableItemVms: newSortableVm.CurrentSortableItemVms .Select(svm => svm.ToPostSortSortableItemVm(keyPairVms)) .ToArray(), pastSortableItemVms: sortableVm.CurrentSortableItemVms, stageVmStep: StageVmStep.Presort, animationPct: 0)); }
public static Tuple <StageVm, SortableVm> ToNextStep(this StageVm stageVm, SortableVm sortableVm = null) { if (stageVm.SortableVm == null) { if (sortableVm == null) { return(new Tuple <StageVm, SortableVm>( item1: stageVm, item2: null)); } return(new Tuple <StageVm, SortableVm>( item1: new StageVm( stageIndex: stageVm.StageIndex, stageVmStyle: stageVm.StageVmStyle, order: stageVm.Order, keyPairVms: stageVm.KeyPairVms, sortableVm: sortableVm.ChangeSectionCount(stageVm.StageVmStyle.SortableVmStyle.SectionCount)), item2: null)); } if (stageVm.SortableVm.StageVmStep == StageVmStep.PostSort) { if (sortableVm == null) { return(new Tuple <StageVm, SortableVm>( item1: stageVm, item2: null)); } return(new Tuple <StageVm, SortableVm>( item1: new StageVm( stageIndex: stageVm.StageIndex, stageVmStyle: stageVm.StageVmStyle, order: stageVm.Order, keyPairVms: stageVm.KeyPairVms, sortableVm: sortableVm.ChangeSectionCount(stageVm.StageVmStyle.SortableVmStyle.SectionCount) ), item2: null)); } switch (stageVm.SortableVm.StageVmStep) { case StageVmStep.Init: return(new Tuple <StageVm, SortableVm>( item1: new StageVm( stageIndex: stageVm.StageIndex, stageVmStyle: stageVm.StageVmStyle, order: stageVm.Order, keyPairVms: stageVm.KeyPairVms, sortableVm: stageVm.SortableVm.ToLeftStep(stageVm.KeyPairVms.ToArray())), item2: null)); case StageVmStep.Left: return(new Tuple <StageVm, SortableVm>( item1: new StageVm( stageIndex: stageVm.StageIndex, stageVmStyle: stageVm.StageVmStyle, order: stageVm.Order, keyPairVms: stageVm.KeyPairVms, sortableVm: stageVm.SortableVm.ToPreSortStep(stageVm.KeyPairVms.ToArray())), item2: null)); case StageVmStep.Presort: return(new Tuple <StageVm, SortableVm>( item1: new StageVm( stageIndex: stageVm.StageIndex, stageVmStyle: stageVm.StageVmStyle, order: stageVm.Order, keyPairVms: stageVm.KeyPairVms.UpdateKeyPairVms(stageVm.SortableVm.PastSortableItemVms), sortableVm: stageVm.SortableVm.ToPostSortStep()), item2: stageVm.SortableVm.ToInitStep())); case StageVmStep.PostSort: return(new Tuple <StageVm, SortableVm>( item1: new StageVm( stageIndex: stageVm.StageIndex, stageVmStyle: stageVm.StageVmStyle, order: stageVm.Order, keyPairVms: stageVm.KeyPairVms, sortableVm: null), item2: null)); default: throw new Exception($"{stageVm.SortableVm.StageVmStep} not handled"); } }