Example #1
0
        public static double KeyRenderYc(this StageVm vm, int keyDex, double stageRenderHeight)
        {
            var vmHeight = vm.StageVmStyle.VPadding +
                           (vm.Order - keyDex) * vm.StageVmStyle.KeyLineHeight;

            return(vm.RenderHeight(vmHeight, stageRenderHeight));
        }
Example #2
0
        public static void DrawSortableValue(this StageVm stageVm, DrawingContext dc,
                                             SortableItemVm sortableVm,
                                             double stageRenderWidth, double stageRenderHeight)
        {
            if ((stageRenderHeight <= 0) || (stageRenderHeight <= 0))
            {
                return;
            }
            if (sortableVm.StagePos == StagePos.Missing)
            {
                return;
            }

            var radius = stageVm.RenderHeight(stageVm.StageVmStyle.KeyLineThickness * 1.5, stageRenderHeight);

            var center = stageVm.GetSortableItemPosition(sortableVm, stageRenderWidth, stageRenderHeight);

            dc.DrawEllipse(sortableVm.BackgroundBrush, null, center, radius, radius);

            if (sortableVm.ShowLabel)
            {
                var txt = new FormattedText(sortableVm.Label.ToString(),
                                            CultureInfo.CurrentCulture,
                                            FlowDirection.LeftToRight,
                                            SortableItemVm.Typeface,
                                            radius, sortableVm.ForegroundBrush, 1.0);

                var upLeft = new Point(center.X - txt.Width / 2, center.Y - txt.Height / 2);
                dc.DrawText(txt, upLeft);
            }
        }
Example #3
0
 public static void DrawKeyLines(this DrawingContext dc, StageVm stageVm,
                                 double stageRenderWidth, double stageRenderHeight)
 {
     for (var keyDex = 0; keyDex < stageVm.Order; keyDex++)
     {
         dc.DrawKeyLine(stageVm, keyDex, stageRenderWidth, stageRenderHeight);
     }
 }
Example #4
0
        public static void DrawKeyLine(this DrawingContext dc, StageVm stageVm, int keyDex,
                                       double stageRenderWidth, double stageRenderHeight)
        {
            var pen        = stageVm.KeyLinePen(stageRenderHeight);
            var renderY    = stageVm.KeyRenderYc(keyDex, stageRenderHeight);
            var pointLeft  = new Point(0, renderY);
            var pointRight = new Point(stageRenderWidth, renderY);

            dc.DrawLine(pen, pointLeft, pointRight);
        }
Example #5
0
 public static StageVm SetStageVmStyle(this StageVm stageVm, StageVmStyle stageVmStyle)
 {
     return(new StageVm(
                stageVmStep: stageVm.StageVmStep,
                stageIndex: stageVm.StageIndex,
                stageVmStyle: stageVmStyle,
                order: stageVm.Order,
                keyPairVms: stageVm.KeyPairVms,
                sortableItemVms: stageVm.SortableItemVms,
                sortableItemVmsOld: stageVm.SortableItemVmsOld
                ));
 }
Example #6
0
 public static StageVm ClearSwitchUses(this StageVm stageVm)
 {
     return(new StageVm(
                stageVmStep: stageVm.StageVmStep,
                stageIndex: stageVm.StageIndex,
                stageVmStyle: stageVm.StageVmStyle,
                order: stageVm.Order,
                keyPairVms: stageVm.KeyPairVms.Select(kpvm => kpvm.ResetUseHistory()),
                sortableItemVms: stageVm.SortableItemVms,
                sortableItemVmsOld: stageVm.SortableItemVmsOld
                ));
 }
Example #7
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);
        }
Example #8
0
        public static void DrawSortableValues(this StageVm stageVm, DrawingContext dc,
                                              double stageRenderWidth, double stageRenderHeight)
        {
            if (stageVm.SortableItemVms == null)
            {
                return;
            }

            foreach (var sortableVm in stageVm.SortableItemVms)
            {
                stageVm.DrawSortableValue(dc, sortableVm, stageRenderWidth, stageRenderHeight);
            }
        }
Example #9
0
        public static void DrawSortableValuesAnimate(
            this StageVm stageVm,
            double pctAlong,
            DrawingContext dc,
            double stageRenderWidth,
            double stageRenderHeight)
        {
            if (stageVm.SortableItemVms == null)
            {
                return;
            }

            for (var i = 0; i < stageVm.SortableItemVms.Length; i++)
            {
                stageVm.DrawSortableValueAnimate(
                    stageVm.SortableItemVmsOld[i],
                    pctAlong,
                    dc,
                    stageVm.SortableItemVms[i],
                    stageRenderWidth,
                    stageRenderHeight);
            }
        }
Example #10
0
        public static Point GetSortableItemPosition(this StageVm stageVm,
                                                    SortableItemVm sortableItemVm,
                                                    double stageRenderWidth, double stageRenderHeight)
        {
            if ((stageRenderHeight <= 0) || (stageRenderHeight <= 0))
            {
                return(new Point(0, 0));
            }
            if (sortableItemVm.StagePos == StagePos.Missing)
            {
                return(new Point(0, 0));
            }

            var renderY = stageVm.KeyRenderYc(sortableItemVm.KeyLinePos, stageRenderHeight);
            var radius  = stageVm.RenderHeight(stageVm.StageVmStyle.KeyLineThickness * 1.5, stageRenderHeight);

            var renderX = 0.0;

            switch (sortableItemVm.StagePos)
            {
            case StagePos.Left:
                renderX = radius * -1.2;
                break;

            case StagePos.Center:
                renderX = stageVm.SectionRenderX(sortableItemVm.StageSection, stageRenderWidth);
                break;

            case StagePos.Right:
                renderX = stageRenderWidth - radius * 1.2;
                break;

            default:
                break;
            }
            return(new Point(renderX, renderY));
        }
Example #11
0
        public static StageVm ToNextStep(this StageVm stageVm, SortableItemVm[] sortableItemVms = null)
        {
            switch (stageVm.StageVmStep)
            {
            case StageVmStep.Left:
                return(new StageVm(
                           stageVmStep: StageVmStep.Presort,
                           stageIndex: stageVm.StageIndex,
                           stageVmStyle: stageVm.StageVmStyle,
                           order: stageVm.Order,
                           keyPairVms: stageVm.KeyPairVms,
                           sortableItemVms: stageVm.SortableItemVms.ToPreSortStep(stageVm.KeyPairVms.ToArray()),
                           sortableItemVmsOld: stageVm.SortableItemVms
                           ));

            case StageVmStep.Presort:

                var newKeypairVms      = stageVm.KeyPairVms.UpdateKeyPairVms(stageVm.SortableItemVms);
                var newSortableItemVms = stageVm.SortableItemVms.UpdateSortableVms(stageVm.KeyPairVms);

                return(new StageVm(
                           stageVmStep: StageVmStep.PostSort,
                           stageIndex: stageVm.StageIndex,
                           stageVmStyle: stageVm.StageVmStyle,
                           order: stageVm.Order,
                           keyPairVms: newKeypairVms,
                           sortableItemVms: newSortableItemVms.ToPostSortStep(stageVm.KeyPairVms.ToArray()),
                           sortableItemVmsOld: stageVm.SortableItemVms
                           ));


            case StageVmStep.PostSort:

                return(new StageVm(
                           stageVmStep: StageVmStep.Right,
                           stageIndex: stageVm.StageIndex,
                           stageVmStyle: stageVm.StageVmStyle,
                           order: stageVm.Order,
                           keyPairVms: stageVm.KeyPairVms.Select(kvm => kvm.ToInactive()),
                           sortableItemVms: stageVm.SortableItemVms.ToRightStep(),
                           sortableItemVmsOld: stageVm.SortableItemVms
                           ));

            case StageVmStep.Right:
                return(new StageVm(
                           stageVmStep: StageVmStep.None,
                           stageIndex: stageVm.StageIndex,
                           stageVmStyle: stageVm.StageVmStyle,
                           order: stageVm.Order,
                           keyPairVms: stageVm.KeyPairVms,
                           sortableItemVms: null,
                           sortableItemVmsOld: null
                           ));

            case StageVmStep.None:
                return(new StageVm(
                           stageVmStep: StageVmStep.Left,
                           stageIndex: stageVm.StageIndex,
                           stageVmStyle: stageVm.StageVmStyle,
                           order: stageVm.Order,
                           keyPairVms: stageVm.KeyPairVms,
                           sortableItemVms: sortableItemVms,
                           sortableItemVmsOld: null
                           ));

            default:
                throw new Exception($"{stageVm.StageVmStep} not handled");
            }
        }
Example #12
0
 public static double RenderWidth(this StageVm vm, double widthInVm, double stageRenderWidth)
 {
     return((stageRenderWidth * widthInVm) / vm.VmWidth);
 }
Example #13
0
        public static Pen KeyLinePen(this StageVm stageVm, double stageRenderHeight)
        {
            var brushHeight = stageVm.RenderHeight(stageVm.StageVmStyle.KeyLineThickness, stageRenderHeight);

            return(new Pen(stageVm.StageVmStyle.KeyLineBrush, brushHeight));
        }
Example #14
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));
        }
Example #15
0
        public static double SectionRenderX(this StageVm vm, int sectionDex, double stageRenderWidth)
        {
            var vmX = (sectionDex + 0.5) * (vm.StageVmStyle.SwitchHSpacing);

            return(vm.RenderWidth(vmX, stageRenderWidth));
        }
Example #16
0
 public static double RenderHeight(this StageVm vm, double heightInVm, double stageRenderHeight)
 {
     return((stageRenderHeight * heightInVm) / vm.VmHeight);
 }