private async void ListViewItemsChanged(MasterSample item)
        {
            indicator.IsVisible = true;
            if (rootGrid != null)
            {
                rootGrid.IsVisible = false;
            }
            if (rootList != null)
            {
                rootList.IsVisible = false;
            }

            await Task.Delay(5);

            if (Device.OS == TargetPlatform.iOS)
            {
                Title = "Back";
            }

            if (item == null)
            {
                return;
            }

            if (Device.OS == TargetPlatform.WinPhone || (Device.Idiom == TargetIdiom.Phone && Device.OS == TargetPlatform.Windows))
            {
                await Navigation.PushAsync(new MasterSamplePageWP(item));
            }
            else
            {
                await Navigation.PushAsync(new MasterSamplePage(item));
            }

            rootList.SelectedItem = null;
        }
        public MasterSamplePageWindows(MasterSample sample, MultiPage <ContentPage> mainPage, ContentPage rootPage)
        {
            propertyStackLayout = new StackLayout
            {
                Orientation = StackOrientation.Vertical,

                VerticalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor = Color.FromHex("#FFEDEDEB"),
                Padding         = new Thickness(10, 0, 10, 10)
            };

            var headerStackLayout = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HeightRequest     = 50,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            var optionsLabel = new Label
            {
                TextColor = Color.FromHex("#1196CD"),
                Text      = "Options",

                FontSize          = 20,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center
            };

            headerStackLayout.Children.Add(optionsLabel);

            //AbsoluteLayout.SetLayoutBounds(optionsLabel,);

            var optionsHeaderImage = new Image
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.EndAndExpand,
                Aspect            = Aspect.AspectFit,
                Source            = ImageSource.FromFile("Icons/back.png")
            };


            var tapGesture = new TapGestureRecognizer();

            tapGesture.Tapped += tapGesture_Tapped;
            optionsHeaderImage.GestureRecognizers.Add(tapGesture);
            headerStackLayout.Children.Add(optionsHeaderImage);

            propertyStackLayout.Children.Add(headerStackLayout);

            var mainContent = new StackLayout {
                Spacing = 0
            };

            headerView = GetHeaderLayout(sample, mainPage, rootPage);
            mainContent.Children.Add(headerView);
            mainContent.Children.Add(GetControlLayout(sample));
            Content = mainContent;
        }
        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 View GetHeaderLayout(MasterSample sample, MultiPage <ContentPage> mainPage, ContentPage rootPage)
        {
            var stackLayout = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HeightRequest     = 100,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor   = Color.FromHex("#FF1196CD"),
            };

            var controlIcon = new Image
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center,
                //Aspect = Aspect.AspectFit,
                Source = ImageSource.FromFile("Icons/back.png")
            };

            stackLayout.Children.Add(controlIcon);

            var tapGesture = new TapGestureRecognizer();

            tapGesture.Tapped += (sender, args) =>
            {
                mainPage.Children.Clear();
                mainPage.Children.Add(rootPage);
                if (listView != null)
                {
                    listView.SelectedItem = sample.Samples[0];
                }
            };
            controlIcon.GestureRecognizers.Add(tapGesture);

            stackLayout.Children.Add(new Label
            {
                TextColor       = Color.White,
                Text            = sample.Title,
                FontSize        = 40,
                VerticalOptions = LayoutOptions.Center
            });

            optionsImage = new Image
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.EndAndExpand,
                Aspect            = Aspect.AspectFit,
                Source            = ImageSource.FromFile("Icons/options.png")
            };


            tapGesture         = new TapGestureRecognizer();
            tapGesture.Tapped += tapGesture_Tapped;
            optionsImage.GestureRecognizers.Add(tapGesture);

            return(stackLayout);
        }
示例#5
0
        public MasterSamplePage(MasterSample sampleList)
        {
            this.sampleList = sampleList;

            Title = Device.OS == TargetPlatform.Android ? "  " + sampleList.Title : sampleList.Title;

            if (sampleList.Samples.Count == 1)
            {
                var type = Type.GetType(sampleList.Samples[0].Type);
                if (type == null)
                {
                    Detail = new EmptyContent();
                }
                else
                {
                    var samplePage = Activator.CreateInstance(type) as SamplePage;
                    Detail = samplePage;
                }
            }
            else if (sampleList.Samples.Count > 1)
            {
                listView = new ListView
                {
                    ItemsSource     = sampleList.Samples,
                    RowHeight       = 40,
                    ItemTemplate    = new DataTemplate(typeof(SampleListCell)),
                    BackgroundColor = Color.Gray
                };

                Master = listView;

                listView.ItemSelected += (sender, args) =>
                {
                    if (listView.SelectedItem == null)
                    {
                        return;
                    }

                    var sampleDetails = args.SelectedItem as SampleDetails;

                    var type = Type.GetType(sampleDetails.Type);
                    if (type == null)
                    {
                        Detail = new EmptyContent();
                    }
                    else
                    {
                        var samplePage = Activator.CreateInstance(type) as SamplePage;
                        Detail = samplePage;
                    }
                };

                SelectSample();
            }
        }
        private View GetHeaderLayout(MasterSample sample, MultiPage<ContentPage> mainPage, ContentPage rootPage)
        {
            var stackLayout = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                HeightRequest = 100,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor = Color.FromHex("#FF1196CD"),
            };

            var controlIcon = new Image
            {
                VerticalOptions = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center,
                //Aspect = Aspect.AspectFit,
                Source = ImageSource.FromFile("Icons/back.png")
            };
            stackLayout.Children.Add(controlIcon);

            var tapGesture = new TapGestureRecognizer();
            tapGesture.Tapped += (sender, args) =>
            {
                mainPage.Children.Clear();
                mainPage.Children.Add(rootPage);
                if(listView != null)
                    listView.SelectedItem = sample.Samples[0];
            };
            controlIcon.GestureRecognizers.Add(tapGesture);

            stackLayout.Children.Add(new Label
            {
                TextColor = Color.White,
                Text = sample.Title,
                FontSize = 40,
                VerticalOptions = LayoutOptions.Center
            });

            optionsImage = new Image
            {
              
                VerticalOptions = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.EndAndExpand,
                Aspect = Aspect.AspectFit,
                Source = ImageSource.FromFile("Icons/options.png")
            };
            

            tapGesture = new TapGestureRecognizer();
            tapGesture.Tapped += tapGesture_Tapped;
            optionsImage.GestureRecognizers.Add(tapGesture);

            return stackLayout;
        }
        public MasterSamplePageWindows(MasterSample sample, MultiPage<ContentPage> mainPage, ContentPage rootPage)
        {
            propertyStackLayout = new StackLayout
            {
                Orientation = StackOrientation.Vertical,

                VerticalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor = Color.FromHex("#FFEDEDEB"),
                Padding = new Thickness(10,0,10,10)
            };

            var headerStackLayout = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                HeightRequest = 50,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            var optionsLabel = new Label
            {
                TextColor = Color.FromHex("#1196CD"),
                Text = "Options",
                
                FontSize = 20,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.Center
            };
            headerStackLayout.Children.Add(optionsLabel);

            //AbsoluteLayout.SetLayoutBounds(optionsLabel,);

            var optionsHeaderImage = new Image
            {

                VerticalOptions = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.EndAndExpand,
                Aspect = Aspect.AspectFit,
                Source = ImageSource.FromFile("Icons/optionBack.png")
            };


            var tapGesture = new TapGestureRecognizer();
            tapGesture.Tapped += tapGesture_Tapped;
            optionsHeaderImage.GestureRecognizers.Add(tapGesture);
            headerStackLayout.Children.Add(optionsHeaderImage);

            propertyStackLayout.Children.Add(headerStackLayout);

            var mainContent = new StackLayout { Spacing = 0 };
            headerView = GetHeaderLayout(sample, mainPage, rootPage);
            mainContent.Children.Add(headerView);
            mainContent.Children.Add(GetControlLayout(sample));
            Content = mainContent;
        }
        public MasterSamplePage(MasterSample sampleList)
        {
            this.sampleList = sampleList;

            Title = Device.OS == TargetPlatform.Android ? "  " + sampleList.Title : sampleList.Title;

            if (sampleList.Samples.Count == 1)
            {
                var type = Type.GetType(sampleList.Samples[0].Type);
                if (type == null)
                {
                    Detail = new EmptyContent();
                }
                else
                {
                    var samplePage = Activator.CreateInstance(type) as SamplePage;
                    Detail = samplePage;
                }
            }
            else if (sampleList.Samples.Count > 1)
            {
                listView = new ListView
                {
                    ItemsSource = sampleList.Samples,
                    RowHeight = 40,
                    ItemTemplate = new DataTemplate(typeof(SampleListCell)),
                    BackgroundColor = Color.Gray
                };

                Master = listView;

                listView.ItemSelected += (sender, args) =>
                {
                    if (listView.SelectedItem == null)
                        return;

                    var sampleDetails = args.SelectedItem as SampleDetails;

                    var type = Type.GetType(sampleDetails.Type);
                    if (type == null)
                    {
                        Detail = new EmptyContent();
                    }
                    else
                    {
                        var samplePage = Activator.CreateInstance(type) as SamplePage;
                        Detail = samplePage;
                    }
                };

                SelectSample();
            }
        }
示例#9
0
        private async void ListViewItemsChanged(MasterSample item)
        {
            await Task.Delay(5);

            if (Device.OS == TargetPlatform.iOS)
            {
                Title = "Back";
            }

            if (item == null)
            {
                return;
            }

            Children.Clear();
            Children.Add(new MasterSamplePageWindows(item, this, homePage));
        }
        public MasterSamplePage(MasterSample sampleList)
        {
            this.sampleList = sampleList;

            Title = Device.OS == TargetPlatform.Android ? "  " + sampleList.Title : sampleList.Title;

            if (sampleList.Samples.Count == 1)
            {
                var type = Type.GetType(sampleList.Samples[0].Type);
                if (type == null)
                {
                    Detail = new EmptyContent();
                }
                else
                {
                    var samplePage = Activator.CreateInstance(type) as SamplePage;
                    Detail = samplePage;
                }
            }
            else if (sampleList.Samples.Count > 1)
            {
                listView = new ListView
                {
                    ItemsSource     = sampleList.Samples,
                    RowHeight       = 40,
                    ItemTemplate    = new DataTemplate(typeof(SampleListCell)),
                    BackgroundColor = Color.White,
                };

                if (Device.OS == TargetPlatform.iOS)
                {
                    StackLayout listStack = new StackLayout()
                    {
                        Padding = new Thickness(0, 0, 0, 74)
                    };
                    listStack.Children.Add(listView);
                    Master = listStack;
                }
                else
                {
                    Master = listView;
                }

                listView.SeparatorColor      = Color.FromHex("#B2B2B2");
                listView.SeparatorVisibility = DeviceExt.OnPlatform(SeparatorVisibility.Default, SeparatorVisibility.Default, SeparatorVisibility.None);
                listView.ItemSelected       += (sender, args) =>
                {
                    if (listView.SelectedItem == null)
                    {
                        return;
                    }

                    var sampleDetails = args.SelectedItem as SampleDetails;

                    var type = Type.GetType(sampleDetails.Type);
                    if (type == null)
                    {
                        Detail = new EmptyContent();
                    }
                    else
                    {
                        var samplePage = Activator.CreateInstance(type) as SamplePage;
                        Detail = samplePage;
                    }
                };

                SelectSample();
            }
        }
        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();
                }
            }
        }
示例#12
0
        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();
                }
            }
        }
示例#13
0
        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 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;
                listView.ItemSelected += (sender, args) =>
                {
                    if (listView.SelectedItem == null)
                        return;
                    if (sampleDetails != null)
                        sampleDetails.IsSelected = false;
                    sampleDetails = args.SelectedItem as SampleDetails;
                    sampleDetails.IsSelected = true;
                    var type = Type.GetType(sampleDetails.Type);
                    if (type != null)
                    {
                        var samplePage = Activator.CreateInstance(type) as SamplePage;
                        SelectSample(samplePage);
                    }
                    listView.SelectedItem = null;
                };

                listView.SelectedItem = sampleList.Samples[0];
            }

            return rootContentView;
        }
        private async void ListViewItemsChanged(MasterSample item)
        {
            indicator.IsVisible = true;
            if (rootGrid != null)
                rootGrid.IsVisible = false;
            if (rootList != null)
                rootList.IsVisible = false;
            
            await Task.Delay(5);

			if (Device.OS == TargetPlatform.iOS)
			{
				Title = "Back";
			}

            if (item == null) return;

            if (Device.OS == TargetPlatform.WinPhone || (Device.Idiom == TargetIdiom.Phone && Device.OS == TargetPlatform.Windows))
            {
                await Navigation.PushAsync(new MasterSamplePageWP(item));
            }
            else
            {
                await Navigation.PushAsync(new MasterSamplePage(item));
            }

            rootList.SelectedItem = null;
        }