private View GetControlLayout(MasterSample sampleList) { if (sampleList.Samples.Count == 1) { var type = Type.GetType(sampleList.Samples[0].Type); if (type == null) { return(rootContentView); } var samplePage = Activator.CreateInstance(type) as SamplePage; SelectSample(samplePage); } else if (sampleList.Samples.Count > 1) { listView = new ListView { ItemsSource = sampleList.Samples, RowHeight = 40, ItemTemplate = new DataTemplate(typeof(SampleListCell)), BackgroundColor = Color.FromHex("#FFEDEDEB") }; rootContentView.Children.Add(listView); SampleDetails sampleDetails = null; SamplePage previouseSeletedSample = null; listView.ItemSelected += (sender, args) => { if (listView.SelectedItem == null) { return; } if (previouseSeletedSample != null) { previouseSeletedSample.OnDisappear(); } if (sampleDetails != null) { sampleDetails.IsSelected = false; } sampleDetails = args.SelectedItem as SampleDetails; App.SelectedSample = sampleDetails.Title; sampleDetails.IsSelected = true; var type = Type.GetType(sampleDetails.Type); if (type != null) { var samplePage = Activator.CreateInstance(type) as SamplePage; SelectSample(samplePage); previouseSeletedSample = samplePage; } listView.SelectedItem = null; }; listView.SelectedItem = sampleList.Samples[0]; } return(rootContentView); }
private void PopulateSamplesList() { var assembly = typeof (App).GetTypeInfo().Assembly; var stream = assembly.GetManifestResourceStream("SampleBrowser.SampleList.SampleList.xml"); using (var reader = new StreamReader(stream)) { var xmlReader = XmlReader.Create(reader); xmlReader.Read(); while (!xmlReader.EOF) { if (xmlReader.Name == "Group" && xmlReader.IsStartElement()) { var masterSampleList = new MasterSample { Title = GetDataFromXmlReader(xmlReader, "Title"), ImageID = GetDataFromXmlReader(xmlReader, "ImageId"), }; bool isPreview; bool.TryParse(GetDataFromXmlReader(xmlReader, "IsPreview"), out isPreview); if (isPreview) masterSampleList.Type = "Preview"; if (!isPreview) { bool isNew; bool.TryParse(GetDataFromXmlReader(xmlReader, "IsNew"), out isNew); if (isNew) masterSampleList.Type = "New"; } MasterSampleLists.Add(masterSampleList); } else if (xmlReader.Name == "Sample" && xmlReader.IsStartElement()) { var sampleList = MasterSampleLists[MasterSampleLists.Count - 1]; var sampleDetails = new SampleDetails { Title = GetDataFromXmlReader(xmlReader, "Title"), ImageId = GetDataFromXmlReader(xmlReader, "ImageID") }; xmlReader.MoveToAttribute("Type"); sampleDetails.Type = xmlReader.Value; bool isUpdated; bool.TryParse(GetDataFromXmlReader(xmlReader, "IsUpdated"), out isUpdated); if (isUpdated) sampleDetails.SampleType = "Updated"; var isNew = false; if (!isUpdated) { bool.TryParse(GetDataFromXmlReader(xmlReader, "IsNew"), out isNew); if (isNew) sampleDetails.SampleType = "New"; } if (sampleList.Type == null && (isUpdated || isNew)) { sampleList.Type = "Updated"; } sampleList.Samples.Add(sampleDetails); } xmlReader.Read(); } } }
private void PopulateSamplesList() { var assembly = typeof(App).GetTypeInfo().Assembly; var stream = assembly.GetManifestResourceStream("SampleBrowser.SampleList.SampleList.xml"); bool isSkipGroup = false; using (var reader = new StreamReader(stream)) { var xmlReader = XmlReader.Create(reader); xmlReader.Read(); while (!xmlReader.EOF) { if (xmlReader.Name == "Group" && xmlReader.IsStartElement()) { var masterSampleList = new MasterSample { Title = GetDataFromXmlReader(xmlReader, "Title"), ImageID = GetDataFromXmlReader(xmlReader, "ImageId"), }; if (Device.OS == TargetPlatform.iOS && masterSampleList.Title == "PDFViewer") { double IOS_Version = DependencyService.Get <IIOSVersionDependencyService>().GetIOSVersion(); if (IOS_Version < 9.0) { isSkipGroup = true; continue; } } if (Device.OS == TargetPlatform.Android && masterSampleList.Title == "PDFViewer") { int androidVersion = DependencyService.Get <IAndroidVersionDependencyService>().GetAndroidVersion(); if (androidVersion < 21) { isSkipGroup = true; continue; } } isSkipGroup = false; bool isPreview; bool.TryParse(GetDataFromXmlReader(xmlReader, "IsPreview"), out isPreview); if (isPreview) { masterSampleList.Type = "Preview"; } if (!isPreview) { bool isNew; bool.TryParse(GetDataFromXmlReader(xmlReader, "IsNew"), out isNew); if (isNew) { masterSampleList.Type = "New"; } } MasterSampleLists.Add(masterSampleList); } else if (xmlReader.Name == "Sample" && xmlReader.IsStartElement()) { var sampleList = MasterSampleLists[MasterSampleLists.Count - 1]; var sampleDetails = new SampleDetails { Title = GetDataFromXmlReader(xmlReader, "Title"), ImageId = GetDataFromXmlReader(xmlReader, "ImageID") }; if (isSkipGroup) { continue; } // iOS Word viewer doesn't preserves the Charts in the document, So hide the Chart samples from the Xamarin.Forms.iOS samplebrowser if (App.Platform == Platforms.iOS && sampleList.Title == "DocIO" && (sampleDetails.Title == "Bar Chart" || sampleDetails.Title == "Pie Chart")) { continue; } xmlReader.MoveToAttribute("Type"); sampleDetails.Type = xmlReader.Value; bool isUpdated; bool.TryParse(GetDataFromXmlReader(xmlReader, "IsUpdated"), out isUpdated); if (isUpdated) { sampleDetails.SampleType = "Updated"; } var isNew = false; if (!isUpdated) { bool.TryParse(GetDataFromXmlReader(xmlReader, "IsNew"), out isNew); if (isNew) { sampleDetails.SampleType = "New"; } } if (sampleList.Type == null && (isUpdated || isNew)) { sampleList.Type = "Updated"; } sampleList.Samples.Add(sampleDetails); } xmlReader.Read(); } } }
private void PopulateSamplesList() { var assembly = typeof(App).GetTypeInfo().Assembly; var stream = assembly.GetManifestResourceStream("SampleBrowser.SampleList.SampleList.xml"); using (var reader = new StreamReader(stream)) { var xmlReader = XmlReader.Create(reader); xmlReader.Read(); while (!xmlReader.EOF) { if (xmlReader.Name == "Group" && xmlReader.IsStartElement()) { var masterSampleList = new MasterSample { Title = GetDataFromXmlReader(xmlReader, "Title"), ImageID = GetDataFromXmlReader(xmlReader, "ImageId"), }; bool isPreview; bool.TryParse(GetDataFromXmlReader(xmlReader, "IsPreview"), out isPreview); if (isPreview) { masterSampleList.Type = "Preview"; } if (!isPreview) { bool isNew; bool.TryParse(GetDataFromXmlReader(xmlReader, "IsNew"), out isNew); if (isNew) { masterSampleList.Type = "New"; } } MasterSampleLists.Add(masterSampleList); } else if (xmlReader.Name == "Sample" && xmlReader.IsStartElement()) { var sampleList = MasterSampleLists[MasterSampleLists.Count - 1]; var sampleDetails = new SampleDetails { Title = GetDataFromXmlReader(xmlReader, "Title"), ImageId = GetDataFromXmlReader(xmlReader, "ImageID") }; xmlReader.MoveToAttribute("Type"); sampleDetails.Type = xmlReader.Value; bool isUpdated; bool.TryParse(GetDataFromXmlReader(xmlReader, "IsUpdated"), out isUpdated); if (isUpdated) { sampleDetails.SampleType = "Updated"; } var isNew = false; if (!isUpdated) { bool.TryParse(GetDataFromXmlReader(xmlReader, "IsNew"), out isNew); if (isNew) { sampleDetails.SampleType = "New"; } } if (sampleList.Type == null && (isUpdated || isNew)) { sampleList.Type = "Updated"; } sampleList.Samples.Add(sampleDetails); } xmlReader.Read(); } } }