Example #1
0
        private static int ProcessTransitions(StateElement stateElement, List <TransitionElement> transEls)
        {
            var trans      = TransByState(stateElement.State, transEls);
            var transWidth = (trans.Count() - 1) * TransitionSeparation;
            var width      = StateWidth + Math.Max(0, transWidth + 2 * PaddingX - StateWidth);
            var start      = stateElement.X + (width - transWidth) / 2;

            foreach (var transEl in trans)
            {
                transEl.Y = stateElement.Y + StateHeight;
                transEl.H = (transEl.Depth + 1) * TransitionStepHeight;
                transEl.SetCoords(stateElement.State, start);
                start += TransitionSeparation;
            }
            return(width);
        }
Example #2
0
        internal static CanvasData Arrange(StateDisplayInfo stateDisplayInfo)
        {
            var transitionElements = new List <TransitionElement>();
            var stateElements      = new List <StateElement>();
            var stateX             = Left;
            var stateY             = Top;
            var crumbs             = StateController.Crumbs.Select((c, i) => new { Crumb = c, Index = i })
                                     .ToDictionary(c => c.Crumb.State, c => new { Crumb = c.Crumb, c.Index });

            foreach (Dialog dialog in StateInfoConfig.Dialogs)
            {
                stateX = Left;
                var depths = CalculateDepths(dialog, transitionElements);
                foreach (State state in dialog.States)
                {
                    var stateElement = new StateElement(state);
                    stateElements.Add(stateElement);
                    stateElement.X       = stateX;
                    stateElement.Y       = stateY;
                    stateElement.H       = StateHeight;
                    stateElement.Page    = state.Page;
                    stateElement.Route   = state.Route;
                    stateElement.Theme   = state.Theme;
                    stateElement.Masters = state.Masters.ToList();
                    if (state == StateContext.State)
                    {
                        stateElement.Current = state == StateContext.State;
                        stateElement.Data    = StateContext.Data;
                        stateElement.Page    = stateDisplayInfo.Page;
                        stateElement.Route   = stateDisplayInfo.Route;
                        stateElement.Theme   = stateDisplayInfo.Theme;
                        stateElement.Masters = stateDisplayInfo.Masters;
                    }
                    stateElement.Previous = state == StateContext.PreviousState;
                    stateElement.Back     = 0;
                    if (crumbs.ContainsKey(state))
                    {
                        stateElement.Back = crumbs.Count - crumbs[state].Index;
                        stateElement.Data = crumbs[state].Crumb.Data;
                    }
                    if (stateElement.Data == null)
                    {
                        stateElement.Data = new NavigationData();
                        foreach (string key in stateElement.State.Defaults.Keys)
                        {
                            stateElement.Data[key] = stateElement.State.Defaults[key];
                        }
                    }
                    stateElement.W = ProcessTransitions(stateElement, transitionElements);
                    stateX        += stateElement.W + StateSeparation;
                }
                stateY += Top + StateHeight + depths.Count * TransitionStepHeight + FontSize;
            }
            var selected            = stateElements.FirstOrDefault(s => s.Current) ?? new StateElement(new State());
            var selectedDialogTrans = transitionElements.Where(t => t.Transition.Parent.Parent == selected.State.Parent).DefaultIfEmpty();
            var lastState           = stateElements.Last();

            return(new CanvasData
            {
                States = stateElements,
                Transitions = transitionElements,
                X = Math.Min(0, Width - Math.Min(selected.X + selected.W + Left, selected.X + Width - Left)),
                Y = Math.Min(0, Height - Math.Min(Math.Max(selected.Y + selected.H, selectedDialogTrans.Max(t => t != null ? t.Y + t.H : 0)) + PaddingY + FontSize, selected.Y + Height - Top)),
                W = Math.Max(Width, stateElements.Max(s => s.X + s.W) + Left),
                H = Math.Max(Height, Math.Max(lastState.Y + lastState.H, transitionElements.DefaultIfEmpty().Max(t => t != null ? t.Y + t.H : 0)) + PaddingY + FontSize)
            });
        }
Example #3
0
 internal static CanvasData Arrange(StateDisplayInfo stateDisplayInfo)
 {
     var transitionElements = new List<TransitionElement>();
     var stateElements = new List<StateElement>();
     var stateX = Left;
     var stateY = Top;
     var crumbs = StateController.Crumbs.Select((c, i) => new { Crumb = c, Index = i })
         .ToDictionary(c => c.Crumb.State, c => new { Crumb = c.Crumb, c.Index });
     foreach (Dialog dialog in StateInfoConfig.Dialogs)
     {
         stateX = Left;
         var depths = CalculateDepths(dialog, transitionElements);
         foreach (State state in dialog.States)
         {
             var stateElement = new StateElement(state);
             stateElements.Add(stateElement);
             stateElement.X = stateX;
             stateElement.Y = stateY;
             stateElement.H = StateHeight;
             stateElement.Page = state.Page;
             stateElement.Route = state.Route;
             stateElement.Theme = state.Theme;
             stateElement.Masters = state.Masters.ToList();
             if (state == StateContext.State)
             {
                 stateElement.Current = state == StateContext.State;
                 stateElement.Data = StateContext.Data;
                 stateElement.Page = stateDisplayInfo.Page;
                 stateElement.Route = stateDisplayInfo.Route;
                 stateElement.Theme = stateDisplayInfo.Theme;
                 stateElement.Masters = stateDisplayInfo.Masters;
             }
             stateElement.Previous = state == StateContext.PreviousState;
             stateElement.Back = 0;
             if (crumbs.ContainsKey(state))
             {
                 stateElement.Back = crumbs.Count - crumbs[state].Index;
                 stateElement.Data = crumbs[state].Crumb.Data;
             }
             if (stateElement.Data == null)
             {
                 stateElement.Data = new NavigationData();
                 foreach (string key in stateElement.State.Defaults.Keys)
                     stateElement.Data[key] = stateElement.State.Defaults[key];
             }
             stateElement.W = ProcessTransitions(stateElement, transitionElements);
             stateX += stateElement.W + StateSeparation;
         }
         stateY += Top + StateHeight + depths.Count * TransitionStepHeight + FontSize;
     }
     var selected = stateElements.FirstOrDefault(s => s.Current) ?? new StateElement(new State());
     var selectedDialogTrans = transitionElements.Where(t => t.Transition.Parent.Parent == selected.State.Parent).DefaultIfEmpty();
     var lastState = stateElements.Last();
     return new CanvasData
     {
         States = stateElements,
         Transitions = transitionElements,
         X = Math.Min(0, Width - Math.Min(selected.X + selected.W + Left, selected.X + Width - Left)),
         Y = Math.Min(0, Height - Math.Min(Math.Max(selected.Y + selected.H, selectedDialogTrans.Max(t => t != null ? t.Y + t.H : 0)) + PaddingY + FontSize, selected.Y + Height - Top)),
         W = Math.Max(Width, stateElements.Max(s => s.X + s.W) + Left),
         H = Math.Max(Height, Math.Max(lastState.Y + lastState.H, transitionElements.DefaultIfEmpty().Max(t => t != null ? t.Y + t.H : 0)) + PaddingY + FontSize)
     };
 }
Example #4
0
 private static int ProcessTransitions(StateElement stateElement, List<TransitionElement> transEls)
 {
     var trans = TransByState(stateElement.State, transEls);
     var transWidth = (trans.Count() - 1) * TransitionSeparation;
     var width = StateWidth + Math.Max(0, transWidth + 2 * PaddingX - StateWidth);
     var start = stateElement.X + (width - transWidth) / 2;
     foreach (var transEl in trans)
     {
         transEl.Y = stateElement.Y + StateHeight;
         transEl.H = (transEl.Depth + 1) * TransitionStepHeight;
         transEl.SetCoords(stateElement.State, start);
         start += TransitionSeparation;
     }
     return width;
 }