Ejemplo n.º 1
0
        /// <summary>
        /// Method to execute whenever the Library selection changes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ComboLibraries_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // Assign the selected Library
            SelectedLibrary = comboLibraries.SelectedItem as Library;

            // Get all content from the select library
            MainManager.Families = Unifi.GetContentFromLibrary(SelectedLibrary.Id);

            // Loop through all Content and retrieve Manufacturer and Model parameter data
            foreach (var c in MainManager.Families)
            {
                c.Manufacturer = Unifi.GetParameterByName(c, "Manufacturer").Value;
                c.Model        = Unifi.GetParameterByName(c, "Model").Value;
            }

            // Display list of Content objects in main DataGrid
            dataGridMain.ItemsSource = MainManager.Families;

            // Update status message
            textBoxStatus.Text = SelectedLibrary.Name + ": " + MainManager.Families.Count().ToString();
        }
        /// <summary>
        /// Method to execute whenever the Library selection changes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ComboLibraries_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!(comboLibraries.SelectedItem is Library selectedLib))
            {
                return;
            }

            // Get all content from the select library
            var contentList = Unifi.GetContentFromLibrary(Secrets.ApiKey, selectedLib.Id);

            // Loop through all Content and retrieve Manufacturer and Model parameter data
            foreach (var c in contentList)
            {
                var parameters = new List <Parameter>();
                parameters = c.Parameters.ToList();

                // Loop through all parameters to retrieve the Manufacturer and Model parameter values for display in DataGrid
                foreach (var p in parameters)
                {
                    // Pass parameter values to Content object
                    if (p.Name == "Manufacturer")
                    {
                        c.Manufacturer = p.Value;
                    }

                    if (p.Name == "Model")
                    {
                        c.Model = p.Value;
                    }
                }
            }

            // Display list of Content objects in main DataGrid
            dataGridMain.ItemsSource = contentList;

            // Update status message
            textBoxStatus.Text = selectedLib.Name + ": " + contentList.Count().ToString();
        }