예제 #1
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);
                    }
                }
            }
        }
예제 #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();
                        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);
                }
            }
        }
예제 #3
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);
                    }
                }
            }
        }
        /// <summary>
        /// This 
        /// </summary>
        /// <param name="contact"></param>
        private void SelectControl(ControlInfoDataItem control)
        {
            if (control != null)
            {
                ControlDetails.Visibility = Visibility.Visible;

                BitmapImage image = new BitmapImage(new Uri(control.ImagePath));
                ControlImage.Source = image;

                ControlTitle.Text = control.Title;
                ControlSubtitle.Text = control.Subtitle;
            }
        }
        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);
                    }
                }
            }
        }