Beispiel #1
0
        IView CreateHeader()
        {
            var container = new StackLayout();

            var title = new Label
            {
                FontSize       = 24,
                FontAttributes = FontAttributes.Bold,
                TextColor      = SampleColors.LightTextColor,
                Text           = "Introducing Microsoft.Maui.Graphics.Controls",
                Margin         = new Thickness(0, 12)
            };

            title.SetAppThemeColor(Label.TextColorProperty, SampleColors.LightTextColor, SampleColors.DarkTextColor);

            container.Add(title);

            var subTitle = new Label
            {
                FontSize  = 16,
                TextColor = SampleColors.LightTextColor,
                Text      = "A .NET MAUI experiment that offers drawn controls allowing to choose between Cupertino, Fluent and Material."
            };

            subTitle.SetAppThemeColor(Label.TextColorProperty, SampleColors.LightTextColor, SampleColors.DarkTextColor);

            container.Add(subTitle);

            return(container);
        }
Beispiel #2
0
        void SetupMauiLayout()
        {
            var verticalStack = new StackLayout()
            {
                Spacing = 5, BackgroundColor = Colors.AntiqueWhite
            };

            verticalStack.Add(new Label {
                Text = "This should be TOP text!", FontSize = 24, HorizontalOptions = LayoutOptions.End
            });

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddBlazorWebView();
            //serviceCollection.AddSingleton<AppState>(_appState);

            var bwv = new BlazorWebView
            {
                BackgroundColor      = Colors.Orange,
                Services             = serviceCollection.BuildServiceProvider(),
                HeightRequest        = 400,
                MinimumHeightRequest = 400,
                HostPage             = @"wwwroot/index.html",
            };

            bwv.RootComponents.Add(new RootComponent {
                Selector = "#app", ComponentType = typeof(Main)
            });
            verticalStack.Add(bwv);
            verticalStack.Add(new Label {
                Text = "This should be BOTTOM text!", FontSize = 24, HorizontalOptions = LayoutOptions.End
            });

            Content = verticalStack;
        }
        public GalleryPageCSharp()
        {
            Title = "C# Gallery";

            this.SetAppThemeColor(BackgroundColorProperty, SampleColors.LightPageBackgroundColor, SampleColors.DarkPageBackgroundColor);

            var scrollView = new ScrollView();

            var verticalStack = new StackLayout()
            {
                Margin = 2
            };

            verticalStack.Add(CreateButton());
            verticalStack.Add(CreateCheckBox());
            verticalStack.Add(CreateDatePicker());
            verticalStack.Add(CreateEditor());
            verticalStack.Add(CreateEntry());
            verticalStack.Add(CreateProgressBar());
            verticalStack.Add(CreateSlider());
            verticalStack.Add(CreateStepper());
            verticalStack.Add(CreateSwitch());
            verticalStack.Add(CreateTimePicker());

            scrollView.Content = verticalStack;

            Content = scrollView;
        }
            public WelcomePage()
            {
                Title   = "QuickUI Demo";
                Content = mainLayout = new StackLayout
                {
                    Padding         = new Thickness(20, 20, 20, 100),
                    Spacing         = 10,
                    Orientation     = StackLayout.StackOrientation.Vertical,
                    VerticalOptions = LayoutOptions.Center
                };

                mainLayout.Add(new Label
                {
                    Text   = "Welcome to the QuickUI Demo App!",
                    XAlign = TextAlignment.Center
                });

                mainLayout.Add(usernameEntry = new Entry {
                    Placeholder = "Username"
                });
                mainLayout.Add(passwordEntry = new Entry
                {
                    Placeholder = "Password",
                    Password    = true
                });
                mainLayout.Add(loginButton = new Button
                {
                    Text      = "Login",
                    IsEnabled = false
                });
            }
Beispiel #5
0
        void SetupCompatibilityLayout()
        {
            var verticalStack = new StackLayout()
            {
                Spacing = 5, BackgroundColor = Color.AntiqueWhite
            };
            var horizontalStack = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal, Spacing = 2, BackgroundColor = Color.CornflowerBlue
            };

            var label = new Label {
                Text = "This will disappear in ~5 seconds", BackgroundColor = Color.Fuchsia
            };

            label.Margin = new Thickness(15, 10, 20, 15);

            verticalStack.Add(label);

            var button = new Button()
            {
                Text = _viewModel.Text, WidthRequest = 200
            };
            var button2 = new Button()
            {
                TextColor       = Color.Green,
                Text            = "Hello I'm a button",
                BackgroundColor = Color.Purple,
                Margin          = new Thickness(12)
            };

            horizontalStack.Add(button);
            horizontalStack.Add(button2);
            horizontalStack.Add(new Label {
                Text = "And these buttons are in a HorizontalStackLayout"
            });

            verticalStack.Add(horizontalStack);
            verticalStack.Add(new Slider());
            verticalStack.Add(new Switch());
            verticalStack.Add(new Switch()
            {
                OnColor = Color.Green
            });
            verticalStack.Add(new Switch()
            {
                ThumbColor = Color.Yellow
            });
            verticalStack.Add(new Switch()
            {
                OnColor = Color.Green, ThumbColor = Color.Yellow
            });

            Content = verticalStack;
        }
Beispiel #6
0
        public async Task CascadeInputTransparentAppliesOnUpdate(bool inputTransparent, bool cascadeInputTransparent, bool expected)
        {
            var control = new StackLayout()
            {
                InputTransparent = inputTransparent, CascadeInputTransparent = cascadeInputTransparent
            };

            _ = await CreateHandlerAsync <LayoutHandler>(control);

            var child0 = new Button()
            {
                InputTransparent = false
            };

            _ = await CreateHandlerAsync <ButtonHandler>(child0);

            await InvokeOnMainThreadAsync(() => control.Add(child0));

            var child1 = new Button()
            {
                InputTransparent = false
            };

            _ = await CreateHandlerAsync <ButtonHandler>(child1);

            await InvokeOnMainThreadAsync(() => control[0] = child1);

            Assert.Equal(expected, child1.InputTransparent);
        }
        public CustomControlsPage()
        {
            Title = "Customize using Microsoft.Maui.Graphics.Controls";

            this.SetAppThemeColor(BackgroundColorProperty, SampleColors.LightPageBackgroundColor, SampleColors.DarkPageBackgroundColor);

            var scrollView = new ScrollView();

            var verticalStack = new StackLayout()
            {
                Margin = 2
            };

            verticalStack.Add(CreateDrawCustomSlider());
            //verticalStack.Add(CreateCustomSliderMapper());
            verticalStack.Add(CreateCustomSliderDrawable());
            verticalStack.Add(CreateColorPicker());
            verticalStack.Add(CreatePersona());

            scrollView.Content = verticalStack;

            Content = scrollView;
        }
        public WelcomePage()
        {
            Title   = "QuickUI Demo";
            Content = mainLayout = new StackLayout {
                Padding         = new Thickness(20, 20, 20, 100),
                Spacing         = 10,
                Orientation     = StackLayout.StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.Center
            };

            mainLayout.Add(new Label {
                Text   = "Welcome to the QuickUI Demo App!",
                XAlign = TextAlignment.Center
            });

            mainLayout.Add(usernameEntry = new Entry {
                Placeholder = "Username"
            });
            mainLayout.Add(passwordEntry = new Entry {
                Placeholder = "Password",
                Password    = true
            });
            mainLayout.Add(loginButton = new Button {
                Text      = "Login",
                IsEnabled = false
            });

            usernameEntry.ValueChanged += (sender, arg) => loginButton.IsEnabled = LoginAvailable();
            passwordEntry.ValueChanged += (sender, arg) => loginButton.IsEnabled = LoginAvailable();

            loginButton.Activated += (sender, args) => {
                if (LoginAvailable())
                {
                    Navigation.Push(new DataPage());
                }
            };
        }
Beispiel #9
0
        public static FrameworkElement Render(TypedElement element, RenderContext context)
        {
            ImageSet imageSet = (ImageSet)element;

#if WPF
            var uiImageSet = new ListBox();
            ScrollViewer.SetHorizontalScrollBarVisibility(uiImageSet, ScrollBarVisibility.Disabled);
            var itemsPanelTemplate = new ItemsPanelTemplate();
            var factory            = new FrameworkElementFactory(typeof(WrapPanel));
            // factory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
            itemsPanelTemplate.VisualTree = factory;
            uiImageSet.ItemsPanel         = itemsPanelTemplate;
#elif XAMARIN
            var uiImageSet = new StackLayout {
                Orientation = StackOrientation.Vertical
            };
#endif

            uiImageSet.Style = context.GetStyle("Adaptive.ImageSet");
            foreach (var image in imageSet.Images)
            {
                if (image.Size == ImageSize.Auto)
                {
                    if (imageSet.ImageSize != ImageSize.Auto)
                    {
                        image.Size = imageSet.ImageSize;
                    }
                    else
                    {
                        image.Size = context.Config.ImageSet.ImageSize;
                    }
                }

                var uiImage = context.Render(image);
                uiImageSet.Add(uiImage);
            }
            return(uiImageSet);
        }
        public WelcomePage()
        {
            Title   = "QuickUI Demo";
            Content = mainLayout = new StackLayout
            {
                Padding         = new Thickness(20, 20, 20, 100),
                Spacing         = 10,
                Orientation     = StackLayout.StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.Center
            };

            mainLayout.Add(new Label
            {
                Text   = "Welcome to the QuickUI Demo App!",
                XAlign = TextAlignment.Center
            });

            mainLayout.Add(cameraButton1 = new Button()
            {
                Text                 = "Take Picture With MediaPickerController",
                IsEnabled            = true,
                MinimumWidthRequest  = 100,
                MinimumHeightRequest = 100
            });

            mainLayout.Add(cameraButton2 = new Button()
            {
                Text                 = "Take Picture With MediaPicker TakePhotoAsync.",
                IsEnabled            = true,
                MinimumWidthRequest  = 100,
                MinimumHeightRequest = 100
            });

            cameraButton1.Activated += (sender, args) =>
            {
                var picker = new MediaPicker();
                MediaPickerController controller = picker.GetTakePhotoUI(new StoreCameraMediaOptions
                {
                    Name      = "test.jpg",
                    Directory = "MediaPickerSample"
                });
                controller.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
                controller.ModalTransitionStyle   = UIModalTransitionStyle.CoverVertical;
                var pageController = this.GetViewController();

                //I tried to add the controller as a child to the pagecontroller, but it hangs the app
                //pageController.AddChildViewController(controller);

                pageController.PresentViewController(controller, true, null);
            };

            cameraButton2.Activated += (sender, args) =>
            {
                var picker = new MediaPicker();
                picker.TakePhotoAsync(new StoreCameraMediaOptions()
                {
                    Name = "test.jpg"
                }).ContinueWith(t =>
                {
                    MediaFile file = t.Result;
                    Console.WriteLine(file.Path);
                }, TaskScheduler.FromCurrentSynchronizationContext());
            };
        }
        public SwipeTransitionModeGallery()
        {
            Title = "SwipeTransitionMode Gallery";

            var scroll = new Microsoft.Maui.Controls.ScrollView();

            var swipeLayout = new StackLayout
            {
                Margin = new Thickness(12)
            };

            var instructions = new Label
            {
                BackgroundColor = Colors.Black,
                TextColor       = Colors.White,
                Text            = "This Gallery use a Platform Specific only available for Android and iOS."
            };

            swipeLayout.Add(instructions);

            var swipeItemSwipeTransitionModeLabel = new Label
            {
                FontSize = 10,
                Text     = "SwipeTransitionMode:"
            };

            swipeLayout.Add(swipeItemSwipeTransitionModeLabel);

            var swipeItemSwipeTransitionModePicker = new Microsoft.Maui.Controls.Picker();

            var swipeTransitionModes = Enum.GetNames(typeof(SwipeTransitionMode)).Select(t => t).ToList();

            swipeItemSwipeTransitionModePicker.ItemsSource   = swipeTransitionModes;
            swipeItemSwipeTransitionModePicker.SelectedIndex = 0;               // Reveal

            swipeLayout.Add(swipeItemSwipeTransitionModePicker);

            var deleteSwipeItem = new SwipeItem
            {
                BackgroundColor = Colors.Red,
                IconImageSource = "calculator.png",
                Text            = "Delete"
            };

            deleteSwipeItem.Invoked += (sender, e) => { DisplayAlert("SwipeView", "Delete Invoked", "Ok"); };

            var swipeItems = new SwipeItems {
                deleteSwipeItem
            };

            swipeItems.Mode = SwipeMode.Reveal;

            var leftSwipeContent = new Grid
            {
                BackgroundColor = Colors.Gray
            };

            var leftSwipeLabel = new Label
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Text = "Swipe to Right"
            };

            leftSwipeContent.Add(leftSwipeLabel);

            var leftSwipeView = new Microsoft.Maui.Controls.SwipeView
            {
                HeightRequest = 60,
                WidthRequest  = 300,
                LeftItems     = swipeItems,
                Content       = leftSwipeContent
            };

            swipeLayout.Add(leftSwipeView);

            var rightSwipeContent = new Grid
            {
                BackgroundColor = Colors.Gray
            };

            var rightSwipeLabel = new Label
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Text = "Swipe to Left"
            };

            rightSwipeContent.Add(rightSwipeLabel);

            var rightSwipeView = new Microsoft.Maui.Controls.SwipeView
            {
                HeightRequest = 60,
                WidthRequest  = 300,
                RightItems    = swipeItems,
                Content       = rightSwipeContent
            };

            swipeLayout.Children.Add(rightSwipeView);

            var topSwipeContent = new Grid
            {
                BackgroundColor = Colors.Gray
            };

            var topSwipeLabel = new Label
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Text = "Swipe to Top"
            };

            topSwipeContent.Add(topSwipeLabel);

            var topSwipeView = new Microsoft.Maui.Controls.SwipeView
            {
                HeightRequest = 60,
                WidthRequest  = 300,
                BottomItems   = swipeItems,
                Content       = topSwipeContent
            };

            swipeLayout.Add(topSwipeView);

            var bottomSwipeContent = new Grid
            {
                BackgroundColor = Colors.Gray
            };

            var bottomSwipeLabel = new Label
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Text = "Swipe to Bottom"
            };

            bottomSwipeContent.Add(bottomSwipeLabel);

            var bottomSwipeView = new Microsoft.Maui.Controls.SwipeView
            {
                HeightRequest = 60,
                WidthRequest  = 300,
                TopItems      = swipeItems,
                Content       = bottomSwipeContent
            };

            swipeLayout.Add(bottomSwipeView);

            swipeItemSwipeTransitionModePicker.SelectedIndexChanged += (sender, e) =>
            {
                var swipeTransitionMode = swipeItemSwipeTransitionModePicker.SelectedItem;

                switch (swipeTransitionMode)
                {
                case "Drag":
                    leftSwipeView.On <Microsoft.Maui.Controls.PlatformConfiguration.Android>().SetSwipeTransitionMode(SwipeTransitionMode.Drag);
                    leftSwipeView.On <Microsoft.Maui.Controls.PlatformConfiguration.iOS>().SetSwipeTransitionMode(SwipeTransitionMode.Drag);

                    rightSwipeView.On <Microsoft.Maui.Controls.PlatformConfiguration.Android>().SetSwipeTransitionMode(SwipeTransitionMode.Drag);
                    rightSwipeView.On <Microsoft.Maui.Controls.PlatformConfiguration.iOS>().SetSwipeTransitionMode(SwipeTransitionMode.Drag);

                    topSwipeView.On <Microsoft.Maui.Controls.PlatformConfiguration.Android>().SetSwipeTransitionMode(SwipeTransitionMode.Drag);
                    topSwipeView.On <Microsoft.Maui.Controls.PlatformConfiguration.iOS>().SetSwipeTransitionMode(SwipeTransitionMode.Drag);

                    bottomSwipeView.On <Microsoft.Maui.Controls.PlatformConfiguration.Android>().SetSwipeTransitionMode(SwipeTransitionMode.Drag);
                    bottomSwipeView.On <Microsoft.Maui.Controls.PlatformConfiguration.iOS>().SetSwipeTransitionMode(SwipeTransitionMode.Drag);
                    break;

                case "Reveal":
                    leftSwipeView.On <Microsoft.Maui.Controls.PlatformConfiguration.Android>().SetSwipeTransitionMode(SwipeTransitionMode.Reveal);
                    leftSwipeView.On <Microsoft.Maui.Controls.PlatformConfiguration.iOS>().SetSwipeTransitionMode(SwipeTransitionMode.Reveal);

                    rightSwipeView.On <Microsoft.Maui.Controls.PlatformConfiguration.Android>().SetSwipeTransitionMode(SwipeTransitionMode.Drag);
                    rightSwipeView.On <Microsoft.Maui.Controls.PlatformConfiguration.iOS>().SetSwipeTransitionMode(SwipeTransitionMode.Drag);

                    topSwipeView.On <Microsoft.Maui.Controls.PlatformConfiguration.Android>().SetSwipeTransitionMode(SwipeTransitionMode.Drag);
                    topSwipeView.On <Microsoft.Maui.Controls.PlatformConfiguration.iOS>().SetSwipeTransitionMode(SwipeTransitionMode.Drag);

                    bottomSwipeView.On <Microsoft.Maui.Controls.PlatformConfiguration.Android>().SetSwipeTransitionMode(SwipeTransitionMode.Drag);
                    bottomSwipeView.On <Microsoft.Maui.Controls.PlatformConfiguration.iOS>().SetSwipeTransitionMode(SwipeTransitionMode.Drag);
                    break;
                }
            };

            scroll.Content = swipeLayout;

            Content = scroll;
        }
Beispiel #12
0
        void SetupCompatibilityLayout()
        {
            var verticalStack = new StackLayout()
            {
                Spacing = 5, BackgroundColor = Color.AntiqueWhite
            };
            var horizontalStack = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal, Spacing = 2, BackgroundColor = Color.CornflowerBlue
            };

            var label = new Label {
                Text = "This will disappear in ~5 seconds", BackgroundColor = Color.Fuchsia
            };

            label.Margin = new Thickness(15, 10, 20, 15);

            verticalStack.Add(label);

            var button = new Button()
            {
                Text = _viewModel.Text, WidthRequest = 200
            };
            var button2 = new Button()
            {
                TextColor       = Color.Green,
                Text            = "Hello I'm a button",
                BackgroundColor = Color.Purple,
                Margin          = new Thickness(12)
            };

            horizontalStack.Add(button);
            horizontalStack.Add(button2);
            horizontalStack.Add(new Label {
                Text = "And these buttons are in a HorizontalStackLayout"
            });

            verticalStack.Add(horizontalStack);
            verticalStack.Add(new Slider());
            verticalStack.Add(new Switch());
            verticalStack.Add(new Switch()
            {
                OnColor = Color.Green
            });
            verticalStack.Add(new Switch()
            {
                ThumbColor = Color.Yellow
            });
            verticalStack.Add(new Switch()
            {
                OnColor = Color.Green, ThumbColor = Color.Yellow
            });
            verticalStack.Add(new DatePicker());
            verticalStack.Add(new TimePicker());
            verticalStack.Add(new Image()
            {
                Source =
                    new UriImageSource()
                {
                    Uri = new System.Uri("https://github.com/dotnet/maui/blob/main/src/ControlGallery/src/Xamarin.Forms.ControlGallery.Android/Resources/drawable/FlowerBuds.jpg?raw=true")
                }
            });

            Content = verticalStack;
        }
        public LoginPage()
        {
            BackgroundColor = Color.FromRgb(57, 57, 57);

            isPhone = Device.Idiom == TargetIdiom.Phone;

            var logo = new Image {
                Source            = "hexagon.png",
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                IsTappable        = true
            };

            logo.Tapped += (s, e) => {
                System.Diagnostics.Debug.WriteLine("Show Backup");
                var hiddenUsersPage = new HiddenUsersPage(HiddenViewType.BackupLog);
                Navigation.Push(hiddenUsersPage);
            };

            if (isPhone)
            {
                logo.WidthRequest  = 175;
                logo.HeightRequest = 175;
            }
            else
            {
                logo.WidthRequest  = 250;
                logo.HeightRequest = 250;
            }

            var winPrizeLabel = new Label {
                Text              = "Win a Xamarin Prize",
                XAlign            = TextAlignment.Center,
                YAlign            = TextAlignment.Center,
                TextColor         = Color.White,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Center,
                HeightRequest     = 100,
                IsTappable        = true
            };

            winPrizeLabel.Tapped += (s, e) => {
                System.Diagnostics.Debug.WriteLine("Show Sync");
                var hiddenUsersPage = new HiddenUsersPage(HiddenViewType.SyncView);
                Navigation.Push(hiddenUsersPage);
            };

            if (isPhone)
            {
                Device.OnPlatform(iOS: () => winPrizeLabel.Font     = Font.FontForSize("HelveticaNeue-UltraLight", 30));
                Device.OnPlatform(Android: () => winPrizeLabel.Font = Font.FontForSize("HelveticaNeue-Light", 30));
            }
            else
            {
                Device.OnPlatform(iOS: () => winPrizeLabel.Font     = Font.FontForSize("HelveticaNeue-UltraLight", 50));
                Device.OnPlatform(Android: () => winPrizeLabel.Font = Font.FontForSize("Roboto-Light", 50));
            }

            StackLayout form = MakeForm();

            form.VerticalOptions = LayoutOptions.FillAndExpand;

            var formView = new ContentView {
                Content           = form,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            var spinButton = new Button {
                Text              = "Spin",
                BackgroundColor   = Color.Gray,
                TextColor         = Color.White,
                WidthRequest      = 100,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            };

            spinButton.Activated += (s, e) => {
                var handler = SpinButtonPressed;
                if (handler != null)
                {
                    string name               = nameEntry.Text ?? "";
                    string email              = emailEntry.Text ?? "";
                    string company            = companyEntry.Text ?? "";
                    bool   completedChallenge = false;
                    var    args               = new SpinButtonPressedArgs(name, email, company, completedChallenge);
                    handler(this, args);
                }
            };

            var spinButtonView = new ContentView {
                Content       = spinButton,
                WidthRequest  = 250,
                HeightRequest = 150
            };

            var mainLayout = new StackLayout {
                Spacing = 20
            };

            mainLayout.Add(logo);
            mainLayout.Add(winPrizeLabel);
            mainLayout.Add(formView);
            mainLayout.Add(spinButtonView);

            var scollView = new ScrollView {
                Content = mainLayout
            };

            Content = new BackgroundImageContainer("blurredbackground.png")
            {
                Content = scollView
            };
        }
        StackLayout MakeForm()
        {
            nameEntry = new Entry {
                Placeholder         = "Full Name",
                MinimumWidthRequest = 50,
            };

            emailEntry = new Entry {
                Placeholder         = "Email",
                MinimumWidthRequest = 50,
            };

            companyEntry = new Entry {
                Placeholder         = "Company",
                MinimumWidthRequest = 50,
            };

            var switchLabel = new Label {
                Text                = "Completed Azure Mobile Services Challenge?",
                TextColor           = Color.White,
                VerticalOptions     = LayoutOptions.Center,
                MinimumWidthRequest = 50,
            };


            Device.OnPlatform(iOS: () => switchLabel.Font      = Font.FontForNamedSize("HelveticaNeue-UltraLight", NamedSize.Small));
            Device.OnPlatform(Android: () => switchLabel.Font  = Font.FontForNamedSize("Sans-Serif-Light", NamedSize.Small));
            Device.OnPlatform(WinPhone: () => switchLabel.Font = Font.SystemFontOfSize(10));

            challengeSwitch = new Xamarin.QuickUI.Switch();

            var switchContainer = new StackLayout {
                Orientation = StackLayout.StackOrientation.Horizontal,
            };

            switchContainer.Add(switchLabel);
            switchContainer.Add(challengeSwitch);

            var entryContainer = new StackLayout {
                Padding         = new Thickness(0, 0, 10, 0),
                VerticalOptions = LayoutOptions.Center,
                Spacing         = 15
            };

            entryContainer.Add(nameEntry);
            entryContainer.Add(emailEntry);
            entryContainer.Add(companyEntry);
            entryContainer.Add(switchContainer);

            var qrButton = new Image {
                Source            = "qrcode.png",
                WidthRequest      = 165,
                HeightRequest     = 165,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center,
            };

            var result = new StackLayout {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center,
            };

            if (isPhone)
            {
                result.Orientation = StackLayout.StackOrientation.Vertical;
            }
            else
            {
                result.Orientation = StackLayout.StackOrientation.Horizontal;
            }

            result.Add(entryContainer);
            result.Add(qrButton);

            result.SizeChanged += (sender, args) => System.Diagnostics.Debug.WriteLine(result.Bounds);

            return(result);
        }
Beispiel #15
0
        public OpenGLGallery()
        {
            var view = new OpenGLView {
                HasRenderLoop = true
            };
            var toggle = new Switch {
                IsToggled = true
            };
            var button = new Button {
                Text = "Display"
            };

            view.HeightRequest = 300;
            view.WidthRequest  = 300;

            view.OnDisplay = r => {
                /*
                 * if (!inited) {
                 *      var shader = GL.CreateShader (All.VertexShader);
                 *      int length = 0;
                 *      GL.ShaderSource (shader, 1, new string [] { "void main() { gl_FragColor = vec4(0.6, 1.0, 0.0, 1.0); }"}, ref length);
                 *      GL.CompileShader (shader);
                 *      int status = 0;
                 *      GL.GetShader (shader, All.CompileStatus, ref status);
                 *      if (status == 0) {
                 *              GL.DeleteShader (shader);
                 *              throw new Exception();
                 *      }
                 *
                 *      inited = true;
                 * }
                 */
                GL.ClearColor(red, green, blue, 1.0f);
                GL.Clear((ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit));

                red += 0.01f;
                if (red >= 1.0f)
                {
                    red -= 1.0f;
                }
                green += 0.02f;
                if (green >= 1.0f)
                {
                    green -= 1.0f;
                }
                blue += 0.03f;
                if (blue >= 1.0f)
                {
                    blue -= 1.0f;
                }
            };

            toggle.Toggled   += (s, a) => { view.HasRenderLoop = toggle.IsToggled; };
            button.Activated += (s, a) => view.Display();

            var stack = new StackLayout {
                Padding = new Size(20, 20)
            };

            stack.Add(view);
            stack.Add(toggle);
            stack.Add(button);

            Content = stack;
        }
Beispiel #16
0
        public InboxContentsPage() : base()
        {
            this.model = ServiceContainer.Resolve <InboxContentViewModel> ();

            this.BindingContext = this.model;

            this.Title = "Inbox Messages";

            // TODO: Remove this hack if toolbar buttons are fixed in Android!
            Button androidRefreshButton = null;
            Button androidExportButton  = null;

            if (Device.OS != TargetPlatform.Android)
            {
                var refreshBtn = new ToolbarItem("Refresh", null, () => {
                    if (this.model.RefreshMessagesCommand.CanExecute(null))
                    {
                        this.model.RefreshMessagesCommand.Execute(null);
                    }
                });
                this.ToolbarItems.Add(refreshBtn);

                var exportBtn = new ToolbarItem("Export", null, () => this.NavigateTo(new ExportAccountPage()));
                this.ToolbarItems.Add(exportBtn);
            }
            else
            {
                // ToolbarItems don't work on Android. Create a normal button and add it to the layout.
                androidRefreshButton = new Button {
                    Text = "Refresh"
                };
                androidRefreshButton.SetBinding(Button.CommandProperty, new Binding("RefreshMessagesCommand"));

                androidExportButton = new Button {
                    Text = "Export"
                }.WhenActivated((sender, args) => this.NavigateTo(new ExportAccountPage()));
            }

            // TODO: Use custom cell to make it look nicer!
            var messageList = new ListView {
                // There is no direct way of binding an ICommand to a TextCellTemplate, hence the workaround using DataTemplate<T>.
                ItemTemplate = DataTemplate <Cell> .Create(() => {
                    var cell = new TextCell {
                        Command = this.model.MessageSelectedCommand
                    };
                    return((Cell)cell);
                })
            };

            // Bind the source of the list view to the list of messages in the view model.
            messageList.SetBinding(ListView.ItemSourceProperty, new Binding("Messages"));

            messageList.ItemTemplate.SetBinding(TextCell.TextProperty, new Binding("From.Address"));
            messageList.ItemTemplate.SetBinding(TextCell.DetailProperty, new Binding("Subject"));
            // Bind the MailMessage itself to the command property. Figured that out by trial and error: simply "."!
            messageList.ItemTemplate.SetBinding(TextCell.CommandParameterProperty, new Binding("."));

            var layout = new StackLayout {
                Orientation = StackLayout.StackOrientation.Vertical
            };

            if (androidRefreshButton != null)
            {
                layout.Add(androidRefreshButton);
            }

            if (androidExportButton != null)
            {
                layout.Add(androidExportButton);
            }

            layout.Add(messageList);

            this.Content = layout;

            // Log user in if required. Show modal to prevent the login page being pushed onto the stack.
            if (!ImapClientApp.MainApp.IsUserAuthenticated)
            {
                this.NavigateTo(new LoginPage(), true);
            }
        }