Ejemplo n.º 1
0
        public static double RenderYKeyLineCenter(this SortableVmStyle sortableVmStyle, int keyDex, double stageRenderHeight)
        {
            var vmHeight = sortableVmStyle.VPadding +
                           (sortableVmStyle.Order - keyDex) * sortableVmStyle.KeyHeight;

            return(RenderUtils.ChildRenderHeight(parentVmHeight: sortableVmStyle.StageVmHeight(),
                                                 childVmHeight: vmHeight,
                                                 parentRenderHeight: stageRenderHeight));
        }
Ejemplo n.º 2
0
 public SortableVm(
     SortableVmStyle sortableVmStyle,
     int order,
     SortableItemVm[] currentSortableItemVms,
     SortableItemVm[] pastSortableItemVms,
     StageVmStep stageVmStep,
     double animationPct)
 {
     SortableVmStyle        = sortableVmStyle;
     Order                  = order;
     CurrentSortableItemVms = currentSortableItemVms;
     PastSortableItemVms    = pastSortableItemVms;
     StageVmStep            = stageVmStep;
     AnimationPct           = animationPct;
 }
Ejemplo n.º 3
0
        public static Point GetSortableItemPosition(this SortableItemVm sortableItemVm,
                                                    SortableVmStyle sortableVmStyle,
                                                    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 = sortableVmStyle.RenderYKeyLineCenter(sortableItemVm.KeyLinePos, stageRenderHeight);

            var radius =
                RenderUtils.ChildRenderHeight(
                    parentVmHeight: sortableVmStyle.StageVmHeight(),
                    childVmHeight: sortableVmStyle.Radius,
                    parentRenderHeight: stageRenderHeight);

            var renderX = 0.0;

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

            case StagePos.Center:
                renderX = sortableVmStyle
                          .RenderXMidStageSection(
                    sortableItemVm.StageSection, stageRenderWidth);
                break;

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

            default:
                break;
            }

            return(new Point(renderX, renderY));
        }
Ejemplo n.º 4
0
        public static void DrawSortableValue(this DrawingContext dc,
                                             SortableVmStyle sortableVmStyle,
                                             SortableItemVm sortableItemVm,
                                             double stageRenderWidth,
                                             double stageRenderHeight)
        {
            if ((stageRenderHeight <= 0) || (stageRenderHeight <= 0))
            {
                return;
            }
            if (sortableItemVm.StagePos == StagePos.Missing)
            {
                return;
            }

            var radius = RenderUtils.ChildRenderHeight(
                parentVmHeight: sortableVmStyle.StageVmHeight(),
                childVmHeight: sortableVmStyle.Radius,
                parentRenderHeight: stageRenderHeight);

            var sortableItemPosition = sortableItemVm.GetSortableItemPosition(
                sortableVmStyle: sortableVmStyle,
                stageRenderWidth: stageRenderWidth,
                stageRenderHeight: stageRenderHeight);

            dc.DrawEllipse(sortableItemVm.BackgroundBrush, SortableBorderPen, sortableItemPosition, radius, radius);

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

                var textUpLeft = new Point(
                    x: sortableItemPosition.X - txt.Width / 2,
                    y: sortableItemPosition.Y - txt.Height / 2);

                dc.DrawText(txt, textUpLeft);
            }
        }
Ejemplo n.º 5
0
        public static void DrawSortableValueAnimate(
            this DrawingContext dc,
            double animationPct,
            SortableVmStyle sortableVmStyle,
            SortableItemVm sortableItemVmOld,
            SortableItemVm sortableItemVm,
            double stageRenderWidth,
            double stageRenderHeight)
        {
            if ((stageRenderHeight <= 0) || (stageRenderHeight <= 0))
            {
                return;
            }
            if (sortableItemVm.StagePos == StagePos.Missing)
            {
                return;
            }
            var radius =
                RenderUtils.ChildRenderHeight(parentVmHeight: sortableVmStyle.StageVmHeight(),
                                              childVmHeight: sortableVmStyle.Radius,
                                              parentRenderHeight: stageRenderHeight);

            var centerO = sortableItemVmOld.GetSortableItemPosition(sortableVmStyle, stageRenderWidth, stageRenderHeight);
            var centerN = sortableItemVm.GetSortableItemPosition(sortableVmStyle, stageRenderWidth, stageRenderHeight);

            var center = centerO.Interpolate(centerN, animationPct);

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

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

                var upLeft = new Point(center.X - txt.Width / 2, center.Y - txt.Height / 2);
                dc.DrawText(txt, upLeft);
            }
        }
Ejemplo n.º 6
0
 public static double RenderWidth(this SortableVmStyle vms, double widthInVm, double stageRenderWidth)
 {
     return((stageRenderWidth * widthInVm) / vms.StageVmWidth());
 }
Ejemplo n.º 7
0
        public static double RenderXMidStageSection(this SortableVmStyle sortableVmStyle, int sectionDex, double stageRenderWidth)
        {
            var vmX = (sectionDex + 0.5) * (sortableVmStyle.SectionWidth);

            return(sortableVmStyle.RenderWidth(vmX, stageRenderWidth));
        }
Ejemplo n.º 8
0
 public static SortableVm InitSortableVm(this SortableItemVm[] sortableItemVms, SortableVmStyle sortableVmStyle)
 {
     if (sortableVmStyle == null)
     {
         var s = 5;
     }
     return(new SortableVm
            (
                sortableVmStyle: sortableVmStyle,
                order: sortableItemVms.Length,
                currentSortableItemVms: sortableItemVms,
                pastSortableItemVms: null,
                stageVmStep: StageVmStep.Init,
                animationPct: 0
            ));
 }