public void StartPressed40911()
        {
            var loginViewController = new NSViewController {
                View = { }
            };
            var button = NSButtonExtensions.CreateButton("Login", () =>
            {
                Xamarin.Forms.Application.Current.MainPage = new ContentPage {
                    Content = new Label {
                        Text = "40911 Success"
                    }
                };
                //loginViewController.DismissViewController()true, null);
            });

            button.Frame = new CGRect(20, 100, 200, 44);
            loginViewController.View.AddSubview(button);

            var window = NSApplication.SharedApplication.KeyWindow;
            var vc     = window.ContentViewController;

            while (vc.PresentedViewControllers.Length > 0)
            {
                vc = vc.PresentedViewControllers[0];
            }

            //vc.PresentViewController(loginViewController, new NSViewControllerPresentationAnimator();
        }
示例#2
0
        public SoundControlView()
        {
            TranslatesAutoresizingMaskIntoConstraints = false;

            MuteButton = NSButtonExtensions.ImageButton("Speaker");
            LoudButton = NSButtonExtensions.ImageButton("SpeakerLoud");

            VolumeSlider = new NSSlider();
            VolumeSlider.TranslatesAutoresizingMaskIntoConstraints = false;

            AddSubview(MuteButton);
            AddSubview(VolumeSlider);
            AddSubview(LoudButton);

            BuildConstraints();
        }
示例#3
0
        public PlayerControlsView()
        {
            TranslatesAutoresizingMaskIntoConstraints = false;

            RewindButton = NSButtonExtensions.ImageButton("Rewind");

            PlayButton            = NSButtonExtensions.ImageButton("Play");
            PlayButton.Activated += (s, e) => ShowPauseButton();

            PauseButton            = NSButtonExtensions.ImageButton("Pause");
            PauseButton.Activated += (s, e) => ShowPlayButton();

            ForwardButton = NSButtonExtensions.ImageButton("Forward");

            AddSubview(RewindButton);
            AddSubview(PlayButton);
            AddSubview(ForwardButton);

            BuildConstraints();
        }
        void AddNativeBindings(NativeBindingGalleryPage page)
        {
            if (page.NativeControlsAdded)
            {
                return;
            }

            StackLayout sl = page.Layout;

            int width = 200;
            int heightCustomLabelView = 100;

            var uilabel = new NSTextField(new CGRect(0, 0, width, heightCustomLabelView))
            {
                BackgroundColor      = NSColor.Clear,
                Editable             = false,
                Bezeled              = false,
                DrawsBackground      = false,
                MaximumNumberOfLines = 0,
                LineBreakMode        = NSLineBreakMode.ByWordWrapping,
                Font        = NSFont.FromFontName("Helvetica", 24f),
                StringValue = "DefaultText"
            };

            var uibuttonColor = NSButtonExtensions.CreateButton("Toggle Text Color Binding", () => uilabel.TextColor = NSColor.Blue);

            uibuttonColor.Font = NSFont.FromFontName("Helvetica", 14f);

            uilabel.SetBinding("StringValue", new Binding("NativeLabel"));
            uilabel.SetBinding(nameof(uilabel.TextColor), new Binding("NativeLabelColor", converter: new ColorConverter()));

            sl?.Children.Add(uilabel);
            sl?.Children.Add(uibuttonColor.ToView());
            //var colorPicker = new NSColorWell();
            //colorPicker.SetBinding("SelectedColor", new Binding("NativeLabelColor", BindingMode.TwoWay, new ColorConverter()), "ColorPicked");
            //sl?.Children.Add(colorPicker);
            page.NativeControlsAdded = true;
        }
        void AddNativeControls(NestedNativeControlGalleryPage page)
        {
            if (page.NativeControlsAdded)
            {
                return;
            }

            StackLayout sl = page.Layout;

            // Create and add a native UILabel
            var originalText = "I am a native UILabel";
            var longerText   =
                "I am a native UILabel with considerably more text. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";

            var uilabel = new NSTextField
            {
                StringValue          = originalText,
                MaximumNumberOfLines = 0,
                LineBreakMode        = NSLineBreakMode.ByWordWrapping,
                Font = NSFont.FromFontName("Helvetica", 24f)
            };

            sl?.Children.Add(uilabel);

            // Create and add a native Button
            var uibutton = NSButtonExtensions.CreateButton("Toggle Text Amount", () =>
            {
                uilabel.StringValue = uilabel.StringValue == originalText ? longerText : originalText;
                uilabel.SizeToFit();
            });

            uibutton.Font = NSFont.FromFontName("Helvetica", 14f);


            sl?.Children.Add(uibutton.ToView());

            // Create some control which we know don't behave correctly with regard to measurement
            var difficultControl0 = new BrokenNativeControl
            {
                Font = NSFont.FromFontName("Helvetica", 14f),
                MaximumNumberOfLines = 0,
                LineBreakMode        = NSLineBreakMode.ByWordWrapping,
                StringValue          = "Doesn't play nice with sizing. That's why there's a big gap around it."
            };

            var difficultControl1 = new BrokenNativeControl
            {
                Font = NSFont.FromFontName("Helvetica", 14f),
                MaximumNumberOfLines = 0,
                LineBreakMode        = NSLineBreakMode.ByWordWrapping,
                StringValue          = "Custom size fix specified. No gaps."
            };

            var explanation0 = new NSTextField
            {
                StringValue          = "The next control is a customized label with a bad SizeThatFits implementation.",
                MaximumNumberOfLines = 0,
                LineBreakMode        = NSLineBreakMode.ByWordWrapping,
                Font = NSFont.FromFontName("Helvetica", 14f),
            };

            var explanation1 = new NSTextField
            {
                StringValue          = "The next control is the same broken class as above, but we pass in an override to the GetDesiredSize method.",
                MaximumNumberOfLines = 0,
                LineBreakMode        = NSLineBreakMode.ByWordWrapping,
                Font = NSFont.FromFontName("Helvetica", 14f),
            };

            // Add a misbehaving control
            sl?.Children.Add(explanation0);
            sl?.Children.Add(difficultControl0);

            // Add the misbehaving control with a custom delegate for FixSize
            sl?.Children.Add(explanation1);
            sl?.Children.Add(difficultControl1, FixSize);

            page.NativeControlsAdded = true;
        }