Example #1
0
        private async Task GetControlInfoDataAsync()
        {
            if (this._groups.Count != 0)
            {
                return;
            }

            Uri dataUri = new Uri("ms-appx:///DataModel/ControlInfoData.json");

            StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(dataUri);

            string jsonText = await FileIO.ReadTextAsync(file);

            JsonObject jsonObject = JsonObject.Parse(jsonText);
            JsonArray  jsonArray  = jsonObject["Groups"].GetArray();

            foreach (JsonValue groupValue in jsonArray)
            {
                JsonObject           groupObject = groupValue.GetObject();
                ControlInfoDataGroup group       = new ControlInfoDataGroup(groupObject["UniqueId"].GetString(),
                                                                            groupObject["Title"].GetString(),
                                                                            groupObject["Subtitle"].GetString(),
                                                                            groupObject["ImagePath"].GetString(),
                                                                            groupObject["Description"].GetString());

                foreach (JsonValue itemValue in groupObject["Items"].GetArray())
                {
                    JsonObject itemObject = itemValue.GetObject();
                    group.Items.Add(new ControlInfoDataItem(itemObject["UniqueId"].GetString(),
                                                            itemObject["Title"].GetString(),
                                                            itemObject["Subtitle"].GetString(),
                                                            itemObject["ImagePath"].GetString(),
                                                            itemObject["Description"].GetString(),
                                                            itemObject["Content"].GetString()));
                }
                this.Groups.Add(group);
            }
        }
Example #2
0
        private async Task GetControlInfoDataAsync()
        {
            lock (_lock)
            {
                if (this.Groups.Count() != 0)
                {
                    return;
                }
            }

            Uri dataUri = new Uri("ms-appx:///DataModel/ControlInfoData.json");

            StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(dataUri);

            string jsonText = await FileIO.ReadTextAsync(file);

            JsonObject jsonObject = JsonObject.Parse(jsonText);
            JsonArray  jsonArray  = jsonObject["Groups"].GetArray();

            lock (_lock)
            {
                foreach (JsonValue groupValue in jsonArray)
                {
                    JsonObject           groupObject = groupValue.GetObject();
                    ControlInfoDataGroup group       = new ControlInfoDataGroup(groupObject["UniqueId"].GetString(),
                                                                                groupObject["Title"].GetString(),
                                                                                groupObject["Subtitle"].GetString(),
                                                                                groupObject["ImagePath"].GetString(),
                                                                                groupObject["Description"].GetString());

                    foreach (JsonValue itemValue in groupObject["Items"].GetArray())
                    {
                        JsonObject itemObject = itemValue.GetObject();

                        string badgeString = null;

                        bool isNew     = itemObject.ContainsKey("IsNew") ? itemObject["IsNew"].GetBoolean() : false;
                        bool isUpdated = itemObject.ContainsKey("IsUpdated") ? itemObject["IsUpdated"].GetBoolean() : false;
                        bool isPreview = itemObject.ContainsKey("IsPreview") ? itemObject["IsPreview"].GetBoolean() : false;

                        if (isNew)
                        {
                            badgeString = "New";
                        }
                        else if (isUpdated)
                        {
                            badgeString = "Updated";
                        }
                        else if (isPreview)
                        {
                            badgeString = "Preview";
                        }

                        var item = new ControlInfoDataItem(itemObject["UniqueId"].GetString(),
                                                           itemObject["Title"].GetString(),
                                                           itemObject["Subtitle"].GetString(),
                                                           itemObject["ImagePath"].GetString(),
                                                           badgeString,
                                                           itemObject["Description"].GetString(),
                                                           itemObject["Content"].GetString(),
                                                           isNew,
                                                           isUpdated,
                                                           isPreview);

                        if (itemObject.ContainsKey("Docs"))
                        {
                            foreach (JsonValue docValue in itemObject["Docs"].GetArray())
                            {
                                JsonObject docObject = docValue.GetObject();
                                item.Docs.Add(new ControlInfoDocLink(docObject["Title"].GetString(), docObject["Uri"].GetString()));
                            }
                        }

                        if (itemObject.ContainsKey("RelatedControls"))
                        {
                            foreach (JsonValue relatedControlValue in itemObject["RelatedControls"].GetArray())
                            {
                                item.RelatedControls.Add(relatedControlValue.GetString());
                            }
                        }

                        group.Items.Add(item);
                    }

                    if (!Groups.Any(g => g.Title == group.Title))
                    {
                        Groups.Add(group);
                    }
                }
            }
        }
        private async Task GetControlInfoDataAsync()
        {
            lock (_lock)
            {
                if (this._groups.Count != 0)
                    return;
            }

            Uri dataUri = new Uri("ms-appx:///DataModel/ControlInfoData.json");

            StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(dataUri);
            string jsonText = await FileIO.ReadTextAsync(file);

            JsonObject jsonObject = JsonObject.Parse(jsonText);
            JsonArray jsonArray = jsonObject["Groups"].GetArray();

            lock (_lock)
            {
                foreach (JsonValue groupValue in jsonArray)
                {
                    JsonObject groupObject = groupValue.GetObject();
                    ControlInfoDataGroup group = new ControlInfoDataGroup(groupObject["UniqueId"].GetString(),
                                                                          groupObject["Title"].GetString(),
                                                                          groupObject["Subtitle"].GetString(),
                                                                          groupObject["ImagePath"].GetString(),
                                                                          groupObject["Description"].GetString());


                    foreach (JsonValue itemValue in groupObject["Items"].GetArray())
                    {
                        JsonObject itemObject = itemValue.GetObject();
                        var item = new ControlInfoDataItem(itemObject["UniqueId"].GetString(),
                                                                itemObject["Title"].GetString(),
                                                                itemObject["Subtitle"].GetString(),
                                                                itemObject["ImagePath"].GetString(),
                                                                itemObject["Description"].GetString(),
                                                                itemObject["Content"].GetString());
                        if (itemObject.ContainsKey("Docs"))
                        {
                            foreach (JsonValue docValue in itemObject["Docs"].GetArray())
                            {
                                JsonObject docObject = docValue.GetObject();
                                item.Docs.Add(new ControlInfoDocLink(docObject["Title"].GetString(), docObject["Uri"].GetString()));
                            }
                        }
                        if (itemObject.ContainsKey("RelatedControls"))
                        {
                            foreach (JsonValue relatedControlValue in itemObject["RelatedControls"].GetArray())
                            {
                                item.RelatedControls.Add(relatedControlValue.GetString());
                            }
                        }
                        group.Items.Add(item);
                    }
                    if (!this.Groups.Any(g => g.Title == group.Title))
                        this.Groups.Add(group);
                }
            }
        }
Example #4
0
        private async Task GetControlInfoDataAsync()
        {
            lock (_lock)
            {
                if (this.Groups.Count() != 0)
                {
                    return;
                }
            }

            Uri dataUri = new Uri("ms-appx:///DataModel/ControlInfoData.json");

            StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(dataUri);

            string jsonText = await FileIO.ReadTextAsync(file);

            JsonObject jsonObject = JsonObject.Parse(jsonText);
            JsonArray  jsonArray  = jsonObject["Groups"].GetArray();

            lock (_lock)
            {
                var    loader   = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
                string pageRoot = loader.GetString("PageStringRoot");

                foreach (JsonValue groupValue in jsonArray)
                {
                    JsonObject           groupObject = groupValue.GetObject();
                    ControlInfoDataGroup group       = new ControlInfoDataGroup(groupObject["UniqueId"].GetString(),
                                                                                groupObject["Title"].GetString(),
                                                                                groupObject["Subtitle"].GetString(),
                                                                                groupObject["ImagePath"].GetString(),
                                                                                groupObject["Description"].GetString());

                    foreach (JsonValue itemValue in groupObject["Items"].GetArray())
                    {
                        JsonObject itemObject = itemValue.GetObject();

                        string badgeString = null;

                        bool isNew     = itemObject.ContainsKey("IsNew") ? itemObject["IsNew"].GetBoolean() : false;
                        bool isUpdated = itemObject.ContainsKey("IsUpdated") ? itemObject["IsUpdated"].GetBoolean() : false;
                        bool isPreview = itemObject.ContainsKey("IsPreview") ? itemObject["IsPreview"].GetBoolean() : false;

                        if (isNew)
                        {
                            badgeString = "New";
                        }
                        else if (isUpdated)
                        {
                            badgeString = "Updated";
                        }
                        else if (isPreview)
                        {
                            badgeString = "Preview";
                        }

                        var item = new ControlInfoDataItem(itemObject["UniqueId"].GetString(),
                                                           itemObject["Title"].GetString(),
                                                           itemObject["Subtitle"].GetString(),
                                                           itemObject["ImagePath"].GetString(),
                                                           badgeString,
                                                           itemObject["Description"].GetString(),
                                                           itemObject["Content"].GetString(),
                                                           isNew,
                                                           isUpdated,
                                                           isPreview);

                        {
                            string pageString = pageRoot + item.UniqueId + "Page";
                            Type   pageType   = Type.GetType(pageString);

                            if (pageType != null)
                            {
                                item.IncludedInBuild = new SolidColorBrush(Windows.UI.Colors.Transparent);
                            }
                            else
                            {
                                item.IncludedInBuild = new SolidColorBrush(Windows.UI.Colors.Red);
                            }
                        }

                        if (itemObject.ContainsKey("Docs"))
                        {
                            foreach (JsonValue docValue in itemObject["Docs"].GetArray())
                            {
                                JsonObject docObject = docValue.GetObject();
                                item.Docs.Add(new ControlInfoDocLink(docObject["Title"].GetString(), docObject["Uri"].GetString()));
                            }
                        }

                        if (itemObject.ContainsKey("RelatedControls"))
                        {
                            foreach (JsonValue relatedControlValue in itemObject["RelatedControls"].GetArray())
                            {
                                item.RelatedControls.Add(relatedControlValue.GetString());
                            }
                        }

                        group.Items.Add(item);
                    }

                    if (!Groups.Any(g => g.Title == group.Title))
                    {
                        Groups.Add(group);
                    }
                }
            }
        }
        //private async void controlsSearchBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
        //{
        //    var groups = await AppUIBasics.Data.ControlInfoDataSource.GetGroupsAsync();
        //    var suggestions = new List<ControlInfoDataItem>();

        //    foreach (var group in groups)
        //    {
        //        var matchingItems = group.Items.Where(
        //            item => item.Title.Contains(sender.Text));

        //        foreach (var item in matchingItems)
        //        {
        //            suggestions.Add(item);
        //        }
        //    }
        //    controlsSearchBox.ItemsSource = suggestions;
        //}

        //private void controlsSearchBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
        //{
        //    var itemId = (args.SelectedItem as ControlInfoDataItem).UniqueId;
        //    this.Frame.Navigate(typeof(ItemPage), itemId);

        //}

        /// <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="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            var group = await ControlInfoDataSource.GetGroupAsync((String)e.NavigationParameter);
            Group = group;
        }
        private void GetControlInfoData()
        {
            lock (_lock)
            {
                if (this.Groups.Count() != 0)
                {
                    return;
                }
            }
            string jsonText = "";
            Uri    dataUri  = new Uri("/XamlControlsGallerySL;component/DataModel/ControlInfoData.json", UriKind.Relative);

            using (Stream s = Application.GetResourceStream(dataUri).Stream)
            {
                var reader = new StreamReader(s);
                jsonText = reader.ReadToEnd();
            }

            JsonObject jsonObject = (JsonObject)JsonObject.Parse(jsonText);
            JsonArray  jsonArray  = (JsonArray)jsonObject["Groups"];

            lock (_lock)
            {
                foreach (JsonValue groupValue in jsonArray)
                {
                    JsonObject groupObject = (JsonObject)groupValue;
                    JsonValue  grouppage;
                    groupObject.TryGetValue("Page", out grouppage);

                    ControlInfoDataGroup group = new ControlInfoDataGroup(groupObject["UniqueId"],
                                                                          groupObject["Title"],
                                                                          groupObject["Subtitle"],
                                                                          groupObject["ImagePath"],
                                                                          groupObject["Description"],
                                                                          grouppage);

                    foreach (JsonValue itemValue in groupObject["Items"])
                    {
                        JsonObject itemObject = (JsonObject)itemValue;

                        string badgeString = null;

                        bool isNew     = itemObject.ContainsKey("IsNew") ? (bool)itemObject["IsNew"] : false;
                        bool isUpdated = itemObject.ContainsKey("IsUpdated") ? (bool)itemObject["IsUpdated"] : false;
                        bool isPreview = itemObject.ContainsKey("IsPreview") ? (bool)itemObject["IsPreview"] : false;

                        if (isNew)
                        {
                            badgeString = "New";
                        }
                        else if (isUpdated)
                        {
                            badgeString = "Updated";
                        }
                        else if (isPreview)
                        {
                            badgeString = "Preview";
                        }
                        JsonValue page;
                        itemObject.TryGetValue("Page", out page);
                        var item = new ControlInfoDataItem(itemObject["UniqueId"],
                                                           itemObject["Title"],
                                                           itemObject["Subtitle"],
                                                           itemObject["ImagePath"],
                                                           page,
                                                           badgeString,
                                                           itemObject["Description"],
                                                           itemObject["Content"],
                                                           isNew,
                                                           isUpdated,
                                                           isPreview);

                        if (itemObject.ContainsKey("Docs"))
                        {
                            foreach (JsonValue docValue in itemObject["Docs"])
                            {
                                JsonObject docObject = (JsonObject)docValue;
                                item.Docs.Add(new ControlInfoDocLink(docObject["Title"], docObject["Uri"]));
                            }
                        }

                        if (itemObject.ContainsKey("RelatedControls"))
                        {
                            foreach (JsonValue relatedControlValue in itemObject["RelatedControls"])
                            {
                                item.RelatedControls.Add(relatedControlValue);
                            }
                        }

                        group.Items.Add(item);
                    }

                    if (!Groups.Any(g => g.Title == group.Title))
                    {
                        Groups.Add(group);
                    }
                }
            }
        }