Ejemplo n.º 1
0
        internal static void SaveBrowserHistory(NavigationToolbar historyToolbar, ITabState state)
        {
            if (state == null)
            {
                return;
            }

            state.CurrentHistoryItem    = null;
            state.GoBackHistoryItems    = null;
            state.GoForwardHistoryItems = null;

            if (historyToolbar.CurrentItem != null)
            {
                state.CurrentHistoryItem = (ITextImageItem)historyToolbar.CurrentItem.Tag;

                List <ITextImageItem> items = new List <ITextImageItem>(historyToolbar.BackHistoryCount);
                foreach (var hitem in historyToolbar.BackHistory)
                {
                    items.Add((ITextImageItem)hitem.Tag);
                }
                state.GoBackHistoryItems = items.ToArray();

                items = new List <ITextImageItem>(historyToolbar.ForwardHistoryCount);
                foreach (var hitem in historyToolbar.ForwardHistory)
                {
                    items.Add((ITextImageItem)hitem.Tag);
                }
                state.GoForwardHistoryItems = items.ToArray();
            }
        }
Ejemplo n.º 2
0
        internal static void ResetBrowserHistory(NavigationToolbar historyToolbar, ITabState state)
        {
            historyToolbar.ResetNavigationHistory();

            if (state == null || state.CurrentHistoryItem == null)
            {
                return;
            }

            List <NavigationHistoryItem> back    = null;
            List <NavigationHistoryItem> forward = null;

            if (state.GoBackHistoryItems != null && state.GoBackHistoryItems.Length > 0)
            {
                back = new List <NavigationHistoryItem>(state.GoBackHistoryItems.Length);
                for (int i = 0; i < state.GoBackHistoryItems.Length; i++)
                {
                    ITextImageItem item = state.GoBackHistoryItems[i];
                    back.Add(new NavigationHistoryItem(item.Text, item));
                }
            }

            if (state.GoForwardHistoryItems != null && state.GoForwardHistoryItems.Length > 0)
            {
                forward = new List <NavigationHistoryItem>(state.GoForwardHistoryItems.Length);
                for (int i = 0; i < state.GoForwardHistoryItems.Length; i++)
                {
                    ITextImageItem item = state.GoForwardHistoryItems[i];
                    forward.Add(new NavigationHistoryItem(item.Text, item));
                }
            }

            historyToolbar.InitializeHistory(
                back == null ? null : back.ToArray(),
                forward == null ? null : forward.ToArray(),
                new NavigationHistoryItem(state.CurrentHistoryItem.Text, state.CurrentHistoryItem));
        }