コード例 #1
0
        private static void OnTypePropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            ImageSource color = null;

            switch ((String)newValue)
            {
            case "New":
                color = ImageSource.FromResource("SampleBrowser.Icons.New.png");
                break;

            case "Preview":
                color = ImageSource.FromResource("SampleBrowser.Icons.Preview.png");
                break;

            case "Updated":
                color = ImageSource.FromResource("SampleBrowser.Icons.Updated.png");
                break;
            }
            var icon = new Image
            {
                Source            = color,
                HeightRequest     = DeviceExt.OnPlatform(55, 20, 30),
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.End,
                WidthRequest      = DeviceExt.OnPlatform(70, 100, 100),
                Aspect            = Aspect.AspectFit,
            };

            ((ControlListCellMobile)bindable).rootLayout.Children.Add(icon, 2, 0);
        }
コード例 #2
0
        protected override void OnSizeAllocated(double width, double height)
        {
            if (Device.Idiom == TargetIdiom.Tablet)
            {
                int maxColumnCount;
                int maxRowCount;
                if (width > height)
                {
                    //Landscape
                    maxColumnCount = DeviceExt.OnPlatform(5, 6, 0);
                    maxRowCount    = DeviceExt.OnPlatform(4, 3, 0);
                    if (Device.OS == TargetPlatform.Android)
                    {
                        rootGrid.HeightRequest = 800;
                    }
                }
                else
                {
                    //Portrait
                    maxColumnCount = 5;
                    maxRowCount    = 5;
                    if (Device.OS == TargetPlatform.Android)
                    {
                        rootGrid.HeightRequest = 1200;
                    }
                }

                var currentColumn = 0;
                var currentRow    = 0;

                Grid.SetRow(dummyContent, maxRowCount - 1);
                Grid.SetColumn(dummyContent, maxColumnCount - 1);

                foreach (var child in rootGrid.Children.Where(child => !(child is Label)))
                {
                    Grid.SetColumn(child, currentColumn);
                    Grid.SetRow(child, currentRow);

                    currentColumn++;
                    if (currentColumn != maxColumnCount)
                    {
                        continue;
                    }
                    currentColumn = 0;
                    currentRow++;
                }
            }

            base.OnSizeAllocated(width, height);
        }
コード例 #3
0
        public SampleListCell()
        {
            this.SetBinding(TypeProperty, "SampleType");

            var sampleName = new LabelExt {
                VerticalOptions = LayoutOptions.Center
            };

            sampleName.SetBinding(Label.TextProperty, "Title");
            sampleName.VerticalOptions = LayoutOptions.Center;
            //if (Device.OS == TargetPlatform.Windows && Device.Idiom == TargetIdiom.Phone)
            //    sampleName.HorizontalOptions = LayoutOptions.FillAndExpand;

            if (Device.Idiom == TargetIdiom.Desktop || Device.Idiom == TargetIdiom.Tablet)
            {
                sampleName.WidthRequest = 210;
            }
            sampleName.FontSize = Device.Idiom == TargetIdiom.Tablet
                ? DeviceExt.OnPlatform(15, 15, 25)
                : DeviceExt.OnPlatform(13, 13, 25);

            sampleName.VerticalOptions = LayoutOptions.Center;
            if ((Device.OS == TargetPlatform.Windows && Device.Idiom == TargetIdiom.Phone) || Device.OS == TargetPlatform.WinPhone)
            {
                sampleName.TextColor = Color.White;
                sampleName.FontSize  = 23;
            }
            else
            {
                sampleName.TextColor = Color.Black;
            }

            if (App.Platform == Platforms.UWP && Device.Idiom == TargetIdiom.Phone)
            {
                sampleName.FontSize = 15;
            }

            rootLayout = new Grid
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(60, GridUnitType.Absolute)
                    }
                }
            };

            if (Device.OS != TargetPlatform.Android)
            {
                rootLayout.BackgroundColor = Color.White;
            }
            sampleName.TextColor = Color.FromHex("#333D47");
            if (Device.Idiom != TargetIdiom.Phone && Device.OS == TargetPlatform.Windows)
            {
                sampleName.FontSize = 15;
                sampleName.SetBinding(Label.TextColorProperty, new Binding("ForegroundColor"));
                rootLayout.SetBinding(Layout.BackgroundColorProperty, new Binding("BackgroundColor"));
            }

            rootLayout.VerticalOptions = LayoutOptions.Center;

            if (Device.OS == TargetPlatform.Android)
            {
                rootLayout.HorizontalOptions = LayoutOptions.StartAndExpand;
            }
            else
            {
                rootLayout.HorizontalOptions = LayoutOptions.Center;
            }

            rootLayout.Children.Add(sampleName, 0, 0);

            rootLayout.Padding = DeviceExt.OnPlatform(new Thickness(15, 10, 5, 5), new Thickness(15, 10, 5, 5),
                                                      new Thickness(4, 3, 5, 3));

            if (Ext.IsWinPhone())
            {
                StackLayout stackLayout = new StackLayout
                {
                    Children        = { rootLayout },
                    BackgroundColor = Color.White,
                    Padding         = 0,
                    Spacing         = 0,
                    VerticalOptions = LayoutOptions.FillAndExpand,
                };

                View = stackLayout;
            }
            else
            {
                View = rootLayout;
            }
        }
コード例 #4
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.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();
            }
        }
コード例 #5
0
        public ControlListCellMobile()
        {
            controlIcon = new Image
            {
                VerticalOptions = LayoutOptions.Center,
                HeightRequest   = DeviceExt.OnPlatform(32, 40, 70),
                WidthRequest    = DeviceExt.OnPlatform(32, 40, 70),
                Aspect          = Aspect.AspectFill
            };


            if (App.Platform == Platforms.UWP && Device.Idiom == TargetIdiom.Phone)
            {
                controlIcon.HeightRequest = 50;
                controlIcon.WidthRequest  = 50;
            }

            this.SetBinding(ImageIDProperty, "ImageID");
            this.SetBinding(TypeProperty, "Type");

            var controlName = new Label
            {
                VerticalOptions = LayoutOptions.Center,
                TextColor       = Color.FromHex("#333D47"),
            };

            controlName.FontSize = DeviceExt.OnPlatform(14, 14, 18);

            if (App.Platform == Platforms.UWP && Device.Idiom == TargetIdiom.Phone)
            {
                controlName.FontSize = 14;
            }

            controlName.SetBinding(Label.TextProperty, "Title");

            rootLayout = new Grid
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = GridLength.Auto
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(100, GridUnitType.Absolute)
                    }
                }
            };

            rootLayout.Children.Add(controlIcon, 0, 0);
            rootLayout.Children.Add(controlName, 1, 0);

            rootLayout.Padding = DeviceExt.OnPlatform(new Thickness(15, 5, 15, 5), new Thickness(15),
                                                      new Thickness(4, 3, 5, 4));

            rootLayout.BackgroundColor = Color.White;

            View = rootLayout;
        }
コード例 #6
0
        public ControlPage()
        {
            rootLayout = new Grid();


            dummyContent = new Label();

            controlList = new ControlListViewModel();

            if (Device.Idiom == TargetIdiom.Tablet)
            {
                Title = DeviceExt.OnPlatform("Essential Studio", "  Essential Studio", "Essential Studio");
                var sampleList = controlList.MasterSampleLists;
                var count      = sampleList.Count;

                rootGrid = new Grid();
                rootLayout.Children.Add(rootGrid);
                rootGrid.Padding = new Thickness(10);

                for (var i = 0; i < count; i++)
                {
                    var control = sampleList[i];

                    StackLayout content;

                    if (Device.OS == TargetPlatform.iOS)
                    {
                        content = new StackLayout {
                            Padding = new Thickness(20, 20, 20, 20), StyleId = i.ToString()
                        };
                    }
                    else
                    {
                        content = new StackLayout {
                            Padding = new Thickness(20, 40, 20, 20), StyleId = i.ToString()
                        };
                    }

                    var tapGestue = new TapGestureRecognizer();
                    content.GestureRecognizers.Add(tapGestue);
                    tapGestue.Tapped += TapGestue_Tapped;

                    var absoluteLayout = new AbsoluteLayout {
                        HeightRequest = 76, WidthRequest = 76
                    };
                    var controlIcon = new Image
                    {
                        HeightRequest = 76,
                        WidthRequest  = 76,
                        Aspect        = Aspect.AspectFit,
                    };
                    if (Device.OS == TargetPlatform.Windows)
                    {
                        controlIcon.Source = ImageSource.FromFile("chart.png");
                    }
                    else
                    {
                        controlIcon.Source = ImageSource.FromResource("SampleBrowser.Icons." + control.ImageID);
                    }
                    var sampleName = new Label
                    {
                        Text              = control.Title,
                        FontSize          = 12,
                        HorizontalOptions = LayoutOptions.Center
                    };

                    content.Children.Add(absoluteLayout);
                    content.Children.Add(sampleName);
                    absoluteLayout.Children.Add(controlIcon);

                    absoluteLayout.HorizontalOptions = LayoutOptions.Center;

                    rootGrid.Children.Add(content);
                }

                if (Device.OS != TargetPlatform.iOS)
                {
                    rootGrid.Children.Add(dummyContent);
                }

                if (Device.OS == TargetPlatform.Android)
                {
                    Content = new ScrollView()
                    {
                        Content = rootLayout
                    }
                }
                ;
                else
                {
                    Content = rootLayout;
                }
            }
            else
            {
                Title = "Essential Studio";

                rootList        = new ListView();
                rootStackLayout = new StackLayout();

                if (!(Device.OS == TargetPlatform.Android || Device.OS == TargetPlatform.iOS))
                {
                    Label title = new Label()
                    {
                        Text = " Essential Studio", FontSize = 30, TextColor = Color.Black
                    };
                    rootStackLayout.Children.Add(title);
                    rootStackLayout.Children.Add(rootList);
                    rootLayout.Children.Add(rootStackLayout);
                }
                else
                {
                    rootLayout.Children.Add(rootList);
                }
                rootList.BackgroundColor   = Color.White;
                rootLayout.BackgroundColor = Color.White;
                aboutContent.Text          =
                    "Syncfusion Essential Studio is a collection of user interface and file format manipulation components that can be used to build line-of-business mobile applications.";
                aboutContent.TranslationX = 10;
                aboutContent.FontSize     = 26;

                Title = Device.OS == TargetPlatform.Android ? "  Essential Studio" : "Essential Studio";
                rootList.ItemsSource         = controlList.MasterSampleLists;
                rootList.ItemSelected       += listview_ItemSelected;
                rootList.SeparatorColor      = Color.FromHex("#B2B2B2");
                rootList.SeparatorVisibility = DeviceExt.OnPlatform(SeparatorVisibility.Default, SeparatorVisibility.Default, SeparatorVisibility.None);

                rootList.RowHeight = DeviceExt.OnPlatform(50, 67, 80);

                if (App.Platform == Platforms.UWP && Device.Idiom == TargetIdiom.Phone)
                {
                    rootList.RowHeight = 55;
                }

                rootList.ItemTemplate = new DataTemplate(typeof(ControlListCellMobile));
                Content = rootLayout;
            }
            rootLayout.Children.Add(indicator);
        }