Пример #1
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            // Allow saved page state to override the initial item to display
            if (pageState != null)
            {
                if (pageState.ContainsKey(ITEM_VIEW_MODEL))
                {
                    if (pageState[ITEM_VIEW_MODEL] != null)
                    {
                        this.itemViewModel = pageState[ITEM_VIEW_MODEL] as ItemViewModel;
                    }
                }
            }

            if (itemViewModel == null)
            {
                if (navigationParameter != null)
                {
                    repo = navigationParameter as RepoItem;
                    itemViewModel = new ItemViewModel(repo);

                }
            }

            if (itemViewModel != null)
            {
                this.DataContext = itemViewModel;
            }
        }
        private Style GetItemStyle(RepoItem item)
        {
            Style style = CplusplusStyle;

            switch (item.language)
            {

                case "C++":
                    style = CplusplusStyle;
                    break;
                case "Java":
                    style = JavaStyle;
                    break;
                case "JavaScript":
                    style = JavaScriptStyle;
                    break;
                case "C":
                    style = CStyle;
                    break;
                case "C#":
                    style = CsharpStyle;
                    break;
                case "Ruby":
                    style = RubyStyle;
                    break;
                default:
                    style = XSLTStyle;
                    break;

            }
            return style;
        }
Пример #3
0
 public ItemViewModel(RepoItem repo)
 {
     this.Repo = repo;
 }