Esempio n. 1
0
        public static IEnumerable <KeyPairVm> UpdateKeyPairVms(this IEnumerable <KeyPairVm> keyPairVms, IEnumerable <SortableItemVm> sortableItemVms)
        {
            foreach (var kpvm in keyPairVms)
            {
                var sortableItemsLow = sortableItemVms.FirstOrDefault(
                    swm => (swm.KeyLinePos == kpvm.LowKey));
                var sortableItemHi = sortableItemVms.FirstOrDefault(
                    swm => (swm.KeyLinePos == kpvm.HiKey));

                if (sortableItemsLow.SortableValue > sortableItemHi.SortableValue)
                {
                    var kpv = new KeyPairVm(
                        disabledBrush: kpvm.DisabledBrush,
                        inUseBrush: kpvm.InUseBrush,
                        wasUsedBrush: kpvm.WasUsedBrush,
                        keyPairUse: KeyPairUse.InUse,
                        stageSection: kpvm.StageSection,
                        stageIndex: kpvm.StageIndex,
                        hiKey: kpvm.HiKey,
                        lowKey: kpvm.LowKey,
                        useCount: kpvm.UseCount + 1
                        );
                    yield return(kpv);
                }
                else
                {
                    yield return(kpvm);
                }
            }
        }
Esempio n. 2
0
        public static void DrawSwitch(this DrawingContext dc, StageVm stageVm, KeyPairVm keyPairVm,
                                      double stageRenderWidth, double stageRenderHeight)
        {
            var pen         = stageVm.SwitchLinePen(keyPairVm, stageRenderWidth);
            var renderX     = stageVm.SectionRenderX(keyPairVm.StageSection, stageRenderWidth);
            var renderYLow  = stageVm.KeyRenderYl(keyPairVm.LowKey, stageRenderHeight);
            var renderYHigh = stageVm.KeyRenderYh(keyPairVm.HiKey, stageRenderHeight);
            var pointLow    = new Point(renderX, renderYLow);
            var pointHigh   = new Point(renderX, renderYHigh);

            dc.DrawLine(pen, pointLow, pointHigh);
        }
Esempio n. 3
0
 public static KeyPairVm ResetUseHistory(this KeyPairVm keyPairVm)
 {
     return(new KeyPairVm(
                disabledBrush: keyPairVm.DisabledBrush,
                inUseBrush: keyPairVm.InUseBrush,
                wasUsedBrush: keyPairVm.WasUsedBrush,
                stageSection: keyPairVm.StageSection,
                keyPairUse: (keyPairVm.KeyPairUse == KeyPairUse.InUse) ? KeyPairUse.Enabled : keyPairVm.KeyPairUse,
                stageIndex: keyPairVm.StageIndex,
                hiKey: keyPairVm.HiKey,
                lowKey: keyPairVm.LowKey,
                useCount: 0));
 }
Esempio n. 4
0
        public static Pen SwitchLinePen(this StageVm stageVm, KeyPairVm keyPairVm, double stageRenderWidth)
        {
            var brushWidth = stageVm.RenderWidth(stageVm.StageVmStyle.SwitchLineWidth, stageRenderWidth);

            return(new Pen(keyPairVm.Brush, brushWidth));
        }