2 * Copyright(c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.Collections.Generic;
20 using System.Collections.ObjectModel;
21 using System.ComponentModel;
23 using Tizen.NUI.Binding;
25 public class Animal : INotifyPropertyChanged
28 private string _scientificName;
29 private string _imageUrl = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/images/animals/";
31 public event PropertyChangedEventHandler PropertyChanged;
32 private void OnPropertyChanged(string propertyName) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); }
35 public Animal(string name, string scientificName)
38 _scientificName = scientificName;
47 OnPropertyChanged("Name");
51 public string ScientificName
53 get => _scientificName;
56 _scientificName = value;
57 OnPropertyChanged("ScientificName");
61 public string ImagePath
65 string filename = _name.Replace(" ", "");
66 filename = filename.ToLower() + ".jpg";
67 return _imageUrl + filename;
75 (string Name,string ScientificName)[] namePool = {
76 ("Bald Eagle", "Haliaeetus leucocephalus"),
78 ("Cat", "Felis catus"),
79 ("Chicken", "Gallus gallus domesticus"),
80 ("Cow", "Bos taurus"),
82 ("Dog", "Canis lupus familiaris"),
84 ("Elephant", "Elephantidae"),
85 ("Emperor Penguin", "Aptenodytes forsteri"),
86 ("Giraffe", "Giraffa"),
87 ("Horse", "Equus ferus"),
88 ("Leopard", "Panthera pardus"),
89 ("Lion", "Panthera leo"),
90 ("Panda", "Ailuropoda melanoleuca"),
91 ("Peacock", "Pavo cristatus"),
92 ("Pig", "Sus scrofa domesticus"),
93 ("Pigeon", "Columba livia"),
94 ("Red Fox", "Vulpes vulpes"),
95 ("Seagull", "Larus canus"),
96 ("Squirrel", "Sciurus vulgaris"),
97 ("Tiger", "Panthera tigris"),
98 ("Wolf", "Canis lupus"),
99 ("Zebra", "Hippotigris"),
101 public ObservableCollection<Animal> Source {get; private set; } = new ObservableCollection<Animal>();
105 for (int i = 0; i < namePool.Length; i++)
106 Source.Add(new Animal(namePool[i].Name, namePool[i].ScientificName));