public yPage()
        {
            //InitializeComponent();
            Content = new Xamarin.Forms.Frame()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand,
                /*
                BackgroundImage =new Forms9Patch.Image()
                {
                    Source = Forms9Patch.ImageSource.FromFile("button.9.png"),
                    Fill = Fill.AspectFit,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions = LayoutOptions.FillAndExpand,
                },
                */
                BackgroundColor = Color.Green,
                Content =
                    new Forms9Patch.Label
                    {
                        Text = "Now <b><i>this</i></b> is a label!",
                        TextColor = Color.Blue,
                        BackgroundColor = Color.Red,
                        FontSize = 30
                    },

            };
        }
        /// <summary>
        /// Draw rectangle on face
        /// </summary>
        /// <param name="rectangle">
        /// X, Y width and hight value of face
        /// </param>
        /// <param name="imageUri">
        /// Pass imageUri to display image
        /// </param>
        /// <param name="imageWidth">
        /// Width of image
        /// </param>
        /// <param name="imageHeight">
        /// Height of image
        /// </param>
        public void DrawRectangle(List<Rectangle> rectangle, string imageUri, double imageWidth,
            double imageHeight)
        {
            DisplayImage.Source = imageUri;

            var existingFrames = ResultRelativeLayout.Children.OfType<Frame>().ToList();
            foreach (var existingFrame in existingFrames)
            {
                ResultRelativeLayout.Children.Remove(existingFrame);
            }


            var frame = new Frame { OutlineColor = Color.Red };

            foreach (var face in rectangle)
            {
                var xConstraint = Constraint.RelativeToView(DisplayImage,
                    (rl, v) => face.X / imageWidth * DisplayImage.Width);
                var yConstraint = Constraint.RelativeToView(DisplayImage,
                    (rl, v) => face.Y / imageHeight * DisplayImage.Height);
                var widthConstraint = Constraint.RelativeToView(DisplayImage,
                    (rl, v) => face.Width / imageWidth * DisplayImage.Width);
                var heightConstraint = Constraint.RelativeToView(DisplayImage,
                    (rl, v) => face.Height / imageHeight * DisplayImage.Height);

                ResultRelativeLayout.Children.Add(frame, xConstraint, yConstraint, widthConstraint, heightConstraint);
            }

        }
        public FrameDemoPage()
        {
            Label header = new Label
            {
                Text = "Frame",
				FontSize = 50,
				FontAttributes = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.Center
            };

            Frame frame = new Frame
            {
                OutlineColor = Color.Accent,
                HasShadow = true,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Content = new Label
                {
                    Text = "I've been framed!"
                }
            };

            // Build the page.
            this.Content = new StackLayout
            {
                Children = 
                {
                    header,
                    frame
                }
            };
        }
        public MenuListTemplate()
        {
            List<MenuItem> data = new MenuListData();
            this.ItemsSource = data;
            this.VerticalOptions = LayoutOptions.FillAndExpand;
            this.BackgroundColor = Theme.NavBackgroundColor;
            this.SeparatorColor = Color.Black;
            this.Margin = new Thickness(5);

            var menuDataTemplate = new DataTemplate(() =>
            {
                var pageImage = new Image
                {
                    VerticalOptions = LayoutOptions.Center,
                    HeightRequest = 30,
                    Margin = new Thickness(0, 0, 10, 0)
                };
                var pageLabel = new Label
                {
                    VerticalOptions = LayoutOptions.Center,
                    TextColor = Theme.TextColor,
                    FontSize = 20,
                };

                pageImage.SetBinding(Image.SourceProperty, "IconSource");
                pageLabel.SetBinding(Label.TextProperty, "Name");

                var layout = new StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    VerticalOptions = LayoutOptions.Center,
                    Children =
                    {
                        pageImage,
                        pageLabel
                    }
                };

                var menuFrame = new Frame
                {
                    OutlineColor = Theme.NavBackgroundColor,
                    BackgroundColor = Theme.NavBackgroundColor,
                    VerticalOptions = LayoutOptions.Center,
                    Padding = new Thickness(10),
                    Content = layout
                };

                return new ViewCell { View = menuFrame };
            });



            var cell = new DataTemplate(typeof(ViewCell));
            cell.SetBinding(TextCell.TextProperty, "Name");
            cell.SetValue(TextCell.TextColorProperty, Color.FromHex("2f4f4f"));


            this.ItemTemplate = menuDataTemplate;
            this.SelectedItem = data[0];
        }
        public FrameDemoPage()
        {
            Label header = new Label
            {
                Text = "Frame",
                Font = Font.BoldSystemFontOfSize(50),
                HorizontalOptions = LayoutOptions.Center
            };

            Frame frame = new Frame
            {
                OutlineColor = Color.Accent,
                HasShadow = true,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Content = new Label
                {
                    Text = "I've been framed!"
                }
            };

            // Accomodate iPhone status bar.
            this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

            // Build the page.
            this.Content = new StackLayout
            {
                Children = 
                {
                    header,
                    frame
                }
            };
        }
Exemple #6
0
		public SearchView ()
		{
			BackgroundColor = App.MainNavigationPage.BarBackgroundColor;

			SearchEntry.BackgroundColor = Color.White;


			var frame = new Frame {
				HasShadow = false,
		//		OutlineColor = Color.Silver,
				Padding = 25,
				Content = new StackLayout {
					Spacing = 20,
					Children = { SearchEntry, SuggestionListView},
					VerticalOptions = LayoutOptions.FillAndExpand,
					HorizontalOptions = LayoutOptions.FillAndExpand,
				},
				VerticalOptions = LayoutOptions.CenterAndExpand,
				HorizontalOptions = LayoutOptions.FillAndExpand,
			};
			

			Content = new StackLayout {
				Orientation = StackOrientation.Vertical,
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
				Children = {new Label() {FontSize = 25, Text = " "}, CloseBtn, TitleLabel, frame, 
					new Label() {FontSize = 175, Text = " "}}
			};

			SuggestionListView.IsVisible = false;
			SearchEntry.Focus ();
		
		}
Exemple #7
0
        public yPage()
        {
            //InitializeComponent();
            Content = new Xamarin.Forms.Frame()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,

                /*
                 * BackgroundImage =new Forms9Patch.Image()
                 * {
                 * Source = Forms9Patch.ImageSource.FromFile("button.9.png"),
                 * Fill = Fill.AspectFit,
                 * HorizontalOptions = LayoutOptions.FillAndExpand,
                 * VerticalOptions = LayoutOptions.FillAndExpand,
                 * },
                 */
                BackgroundColor = Color.Green,
                Content         =
                    new Forms9Patch.Label
                {
                    Text            = "Now <b><i>this</i></b> is a label!",
                    TextColor       = Color.Blue,
                    BackgroundColor = Color.Red,
                    FontSize        = 30
                },
            };
        }
        public ShadowBoxCell(View content, double boxHeight, double boxWidth)
        {
            BoxWidth = boxWidth;
            BoxHeight = boxHeight;

            var frameImage = new Frame {
                Padding = 5,
                Content = content,
                BackgroundColor = Color.White,
                HasShadow = false,
                VerticalOptions = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center,
                OutlineColor = Color.Black,
                HeightRequest = BoxHeight,
                WidthRequest = BoxWidth,
                MinimumHeightRequest = BoxHeight,
                MinimumWidthRequest = BoxWidth,
            };

            var frameBackground1 = new Frame {
                Padding = 5,
                BackgroundColor = Color.Gray,
                HasShadow = false,
                VerticalOptions = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center,
                OutlineColor = Color.Black,
                HeightRequest = BoxHeight,
                WidthRequest = BoxWidth,
                MinimumHeightRequest = BoxHeight,
                MinimumWidthRequest = BoxWidth,
            };

            var grid = new Grid {
                RowSpacing = 0,
                Padding = new Thickness (0, 0, 0, 0),
            };

            grid.RowDefinitions.Add (new RowDefinition { Height = new GridLength (300) });
            grid.ColumnDefinitions.Add (new ColumnDefinition { Width = new GridLength (300) });

            var relativeLayout = new RelativeLayout ();

            relativeLayout.Children.Add (frameBackground1,
                Constraint.Constant (2),
                Constraint.Constant (2)
            );

            relativeLayout.Children.Add (frameImage,
                Constraint.RelativeToView (frameBackground1, (parent, sibling) => {
                    return sibling.X - 1;
                }),
                Constraint.RelativeToView (frameBackground1, (parent, sibling) => {
                    return sibling.Y - 1;
                }));

            grid.Children.Add (relativeLayout, 0, 0);

            Content = grid;
        }
        private static void ViewMessage(DateTime Timestamp, DataType Type, Byte[] Data, bool IsMyMessage)
        {
            Xamarin.Forms.Device.BeginInvokeOnMainThread(delegate
            {
                var MessageLocalTime = Timestamp.ToLocalTime();
                var PaddingLeft      = 5; var PaddingRight = 5;
                Xamarin.Forms.Color Background;
                if (IsMyMessage)
                {
                    PaddingLeft = 20;
                    Background  = Config.Settings.Graphics.BackgroundMyMessage;
                }
                else
                {
                    Background   = Config.Settings.Graphics.BackgroundMessage;
                    PaddingRight = 20;
                }
                var Frame = new Xamarin.Forms.Frame()
                {
                    CornerRadius = 10, BackgroundColor = Background, Padding = 0
                };
                var Box = new Xamarin.Forms.StackLayout()
                {
                    Padding = new Xamarin.Forms.Thickness(PaddingLeft, 5, PaddingRight, 5)
                };
                Frame.Content = Box;
                var Container = Views.ChatRoom.Messages;
                Container.Children.Insert(0, Frame);
                var TimeLabel       = new Xamarin.Forms.Label();
                TimeSpan Difference = DateTime.Now - MessageLocalTime;
                if (Difference.TotalDays < 1)
                {
                    TimeLabel.Text = MessageLocalTime.ToLongTimeString();
                }
                else
                {
                    TimeLabel.Text = MessageLocalTime.ToLongDateString() + " - " + MessageLocalTime.ToLongTimeString();
                }
                TimeLabel.FontSize = 8;
                Box.Children.Add(TimeLabel);
                switch (Type)
                {
                case DataType.Text:
                    var Label  = new Xamarin.Forms.Label();
                    Label.Text = Encoding.Unicode.GetString(Data);
                    Box.Children.Add(Label);
                    break;

                case DataType.Image:
                    break;

                case DataType.Audio:
                    break;

                default:
                    break;
                }
            });
        }
 private void InitializeComponent()
 {
     this.LoadFromXaml(typeof(MainPage));
     MainContainer = this.FindByName <Grid>("MainContainer");
     GridSettingsContainer = this.FindByName <StackLayout>("GridSettingsContainer");
     BoundaryEditContainer = this.FindByName <StackLayout>("BoundaryEditContainer");
     SettingsContainer = this.FindByName <Frame>("SettingsContainer");
 }
Exemple #11
0
        public MainPage()
        {
            InitializeComponent();

            var grid = new Grid
                {
                    VerticalOptions = LayoutOptions.FillAndExpand,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    RowDefinitions =
                        {
                            new RowDefinition { Height = new GridLength(100, GridUnitType.Absolute) },
                            new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }
                        },
                    ColumnDefinitions =
                        {
                            new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
                        }
                    };

            var container = new Frame
            {
                Content = new SubPage1().Content,
                BackgroundColor = Color.Aqua,
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            var button1 = new Button() { Text = "SubPage1" };

            button1.Clicked += (object sender, EventArgs e) => {
                container.Content = new SubPage1().Content;
            };

            var button2 = new Button() { Text = "SubPage2" };

            button2.Clicked += (object sender, EventArgs e) => {
                container.Content = new SubPage2().Content;
            };

            grid.Children.Add(new StackLayout {
                Children = {
                    button1,
                    button2
                },
                BackgroundColor = Color.Aqua,
                Padding = new Thickness(10),
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            }, 0, 0);

            grid.Children.Add(container, 0, 1);

            grid.BackgroundColor = Color.Gray;
            this.Padding = new Thickness(20);
            Content = grid;
        }
Exemple #12
0
        public AbsolutePageCS()
        {
            AddListItem(n);

            var cell = new DataTemplate(typeof(TextCell));
            cell.SetBinding(TextCell.TextProperty, "TextItem");
            cell.SetBinding(TextCell.DetailProperty, "DetailItem");

            listLayer = new ListView
            {
                ItemsSource = listItems,
                ItemTemplate = cell,
            };
            listLayer.ItemAppearing += ListLayer_ItemAppearing;

            frameLayer = new Frame
            {
                //BackgroundColor = Color.Black.MultiplyAlpha(0.7d),
                BackgroundColor = Color.White,
                IsVisible = false,
                Content = new StackLayout
                {
                    Children =
                    {
                        new ActivityIndicator {
                            IsRunning = true,
                            Color = Device.OnPlatform(Color.White, Color.Default, Color.Accent),
                        },
                        new Label {
                            Text = "Data loading...",
                            TextColor = Color.Black,
                            XAlign = TextAlignment.Center,
                        },
                    }
                },
            };


            bgLayer = new ContentView
            {
                BackgroundColor = Color.Black.MultiplyAlpha(0.4d),
                IsVisible = false,
            };

            var abs = new AbsoluteLayout();

            abs.Children.Add(listLayer);
            abs.Children.Add(bgLayer);
            abs.Children.Add(frameLayer);

            this.Title = "AbsoluteIndicator";
            this.Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);
            this.Content = abs;

            SizeChanged += AbsolutePageCS_SizeChanged;
        }
Exemple #13
0
 public SubPage1()
 {
     Content = new Frame {
         Content = new Label { Text = "This is Xamarin Forms Content!", TextColor = Color.White },
         BackgroundColor = Color.Maroon,
         Padding = new Thickness(20),
         VerticalOptions = LayoutOptions.FillAndExpand,
         HorizontalOptions = LayoutOptions.FillAndExpand,
     };
 }
Exemple #14
0
 public SubPage2()
 {
     Content = new Frame {
         Content = new Label { Text = "SubPage2", TextColor = Color.White },
         BackgroundColor = Color.Olive,
         Padding = new Thickness(50),
         VerticalOptions = LayoutOptions.FillAndExpand,
         HorizontalOptions = LayoutOptions.FillAndExpand
     };
 }
        public LibraryCellTemplate()
        {
            var nameLabel = new Label () {
                FontSize = UIConstants.GetHomePageFontSize (),
                TextColor = Color.White,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions = LayoutOptions.Center,
            };
            nameLabel.SetBinding (Label.TextProperty, "CategoryName");

            var tapImage = new Image () {
                Source = ImageConstants.nextIcon,
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions = LayoutOptions.Center,
            };

            Grid grid = new Grid {
                Padding = 5,
                VerticalOptions = LayoutOptions.Start,
                RowDefinitions = {
                    new RowDefinition { Height = GridLength.Auto },
                },
                ColumnDefinitions = {
                    new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
                    new ColumnDefinition { Width = GridLength.Auto },
                }
            };

            grid.Children.Add (nameLabel, 0, 0);
            grid.Children.Add (tapImage, 1, 0);

            var frame = new Frame {
                OutlineColor = ColorConstants.SemiOpaqueOutline,
                HasShadow = true,
                HorizontalOptions = LayoutOptions.Center,
                BackgroundColor = ColorConstants.SemiOpaqueBackground,
                VerticalOptions = LayoutOptions.Center,
                Content = new StackLayout {
                    Padding = 0,
                    Children = {
                        grid
                    }
                }
            };

            if (Device.Idiom == TargetIdiom.Phone) {
                frame.Padding = 5;
            } else {
                frame.Padding = 10;
            }

            this.View = frame;
        }
Exemple #16
0
        public TestPage()
        {
            Title = "Test";

            var nextButton = new Button
            {
                Text = "Next"
            };

            var backButton = new Button
            {
                Text = "Back"
            };

            _buttonGrid = new Grid
            {
                ColumnDefinitions =
                {
                    new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star)},
                    new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star)}
                }
            };

            _buttonGrid.Children.Add(backButton, 0 , 0);
            _buttonGrid.Children.Add(nextButton, 1, 0);
            nextButton.Clicked += NextButtonOnClicked;
            backButton.Clicked += BackButtonOnClicked;

            _mainStack = new StackLayout
            {
                BackgroundColor = Color.White
            };

            CreateStacks();

            _mainStack.Children.Add(_stack);
            _mainStack.Children.Add(_buttonGrid);
            position = Position.one;
            _close = true;

            var frame = new Frame
            {
                OutlineColor = Color.Red,
                HasShadow = true,
                Content = _mainStack
            };

            var rel = new RelativeLayout();
            rel.Children.Add(frame, Constraint.Constant(15), Constraint.Constant(15), Constraint.RelativeToParent((parent) => parent.Width - 30), Constraint.RelativeToParent((parent)=> parent.Height - 30));

            Content = rel;
        }
        public MapView()
        {
            BindingContext = new MapViewModel();
            var frame = new Frame {
                Padding = new Thickness(0, 0, 0, 0)
            };

            var map = new Map(MapSpan.FromCenterAndRadius(new Position(-15, -50),
                Distance.FromMiles(1100)));
            ViewModel.LoadPins().ForEach(m => map.Pins.Add(m));

            frame.Content = map;
            Content = frame;
        }
 public FramedTextPage()
 {
     Padding = new Thickness(20);
     Content = new Frame
     {
         OutlineColor = Color.Accent,
         Content = new Label
         {
             Text = "I've been framed!",
             FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
             HorizontalOptions = LayoutOptions.Center,
             VerticalOptions = LayoutOptions.Center
         }
     };
 }
        public SearchItemTemplate()
        {
            var nameLabel = new Label () {
                FontSize = Device.GetNamedSize (NamedSize.Small, typeof(Label)),
                HorizontalOptions = LayoutOptions.StartAndExpand,
            };
            nameLabel.SetBinding (Label.TextProperty, "SearchText");

            var tapImage = new Image () {
                Source = "corningimages/nextblack.png",
                HorizontalOptions = LayoutOptions.End,
                HeightRequest = 18,
                WidthRequest=18,
            };

            Grid grid = new Grid
            {
                Padding = 5,
                VerticalOptions = LayoutOptions.Start,
                RowDefinitions =
                {
                    new RowDefinition { Height = GridLength.Auto },
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
                    new ColumnDefinition { Width = GridLength.Auto },
                }
                };

            grid.Children.Add (nameLabel, 0, 0);
            grid.Children.Add (tapImage, 1, 0);

            var frame = new Frame {
                HasShadow = true,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.Center,
                Padding= 5,
                Content = new StackLayout {
                    Padding=0,
                    Children = {
                        grid
                    }
                }
            };

            this.View =  frame;
        }
Exemple #20
0
        /// <summary>
        /// On UWP, Xamarin.Forms uses a Border control to render its Frame elements
        /// Only the gods know, why they chose to render another Panel control around the Border and give
        /// BackgroundColor to the Panel instead of the Border directly. This avoids Border Radius to work properly
        /// and confuses touch events. Here is a workaround to fix that.
        /// </summary>
        /// <param name="frame"></param>
        private void FixFormsBackgroundColor(Xamarin.Forms.Frame frame)
        {
            var color = new Windows.UI.Color
            {
                A = Convert.ToByte(frame.BackgroundColor.A * 255),
                R = Convert.ToByte(frame.BackgroundColor.R * 255),
                G = Convert.ToByte(frame.BackgroundColor.G * 255),
                B = Convert.ToByte(frame.BackgroundColor.B * 255)
            };

            if (Control.Parent is Panel parent)
            {
                parent.Background = null;
            }

            Control.Background = new SolidColorBrush(color);
        }
        public Frame HomeButtonView(string MainHeader, string SubHeader, string details)
        {
            Label label = new Label {
                Text = MainHeader,
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions = LayoutOptions.Center,
                TextColor = Color.White,
            };

            Label tinyLabel = new Label {
                Text = SubHeader,
                FontSize = Device.GetNamedSize (NamedSize.Micro, typeof(Label)),
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions = LayoutOptions.Center,
                TextColor = Color.Blue,
            };

            Label tinydetailsLabel = new Label {
                Text = details,
                FontSize = Device.GetNamedSize (NamedSize.Micro, typeof(Label)),
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions = LayoutOptions.Center,
                TextColor = Color.White,
            };

            //this.Padding = new Thickness (3);
            var frame = new Frame {
                OutlineColor = Color.FromRgba(255,255,255,0.1),
                BackgroundColor = Color.FromRgba(255,255,255,0.1),
                //Padding = new Thickness (5, 10, 5, 0),
                Content = new StackLayout {
                    Spacing = 0,
                    Children = {
                        label,
                        tinyLabel,
                        tinydetailsLabel
                    }
                }
            };

            //this.Content = frame;

            // Don't let touch pass us by.
            this.BackgroundColor = Color.Transparent;
            return frame;
        }
        public View SetContent()
        {
            Button btnGo = new Button()
            {
                Text = "Let's Find Out",
                HorizontalOptions = LayoutOptions.Center,
            };
            btnGo.Clicked += btnGo_Clicked;

            Frame frameMap = new Frame() { Padding = 1, VerticalOptions = LayoutOptions.FillAndExpand };
            map = new Map(
                MapSpan.FromCenterAndRadius(
                    viewModel.Location, Distance.FromMiles(2000)))
                    {
                        VerticalOptions = LayoutOptions.FillAndExpand,
                    };
            frameMap.Content = map;

            slider = new Slider(1, 18, 9);
            slider.ValueChanged += slider_ValueChanged;

            StackLayout stackGPS = this.GetGPSLayout();
            StackLayout stackAddr = this.GetAddrLayout();

            StackLayout stack = new StackLayout()
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Padding = new Thickness(10, Device.OnPlatform(0, 0, 0), 10, 10),
                Spacing = 5,
                Orientation = StackOrientation.Vertical,
                Children =
                {
                   btnGo,
                   stackGPS,
                   stackAddr,
                   frameMap,
                   slider,
                },

            };

            return stack;
        }
 private Frame GetRadioFrame()
 {
     _radioButton = new XamRadioButton
     {
         HeightRequest = 80,
         WidthRequest = 100,
         TextColor = Device.OnPlatform(Color.White, Color.White, Color.Black)
     };
     var radioFrame = new Frame
     {
         HeightRequest = 120,
         WidthRequest = 120,
         Content = _radioButton,
         Padding = new Thickness(5, 5, 5, 5),
         BackgroundColor = Device.OnPlatform(Color.White, Color.White, Color.Black)
     };
     _radioButton.CheckedChanged += OnRadioStateChanged;
     return radioFrame;
 }
        public FramedTextPage()
        {
            BackgroundColor = Color.Aqua;

            Content = new Frame
            {
                OutlineColor = Color.Black,
                BackgroundColor = Color.Yellow,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.Center,

                Content = new Label
                {
                    Text = "I've been framed!",
                    FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                    FontAttributes = FontAttributes.Italic,
                    TextColor = Color.Blue
                }
            };
        }
		public TapInsideFrame()
		{
			var frame = new Frame
			{
				OutlineColor = Color.Accent,
				BackgroundColor = Color.Transparent,
				Padding = new Thickness(20, 100),
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.CenterAndExpand,
				Content = new Label
				{
					Text = "Tap Inside Frame",
					FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
				}
			};


			var tapGestureRecognizer = 
				new TapGestureRecognizer();
			//tapGestureRecognizer.NumberOfTapsRequired = 2; // double-tap
			tapGestureRecognizer.Tapped += OnTapGestureRecognizerTapped;
			frame.GestureRecognizers.Add(tapGestureRecognizer);


		 	label = new Label
			{
				Text = " ",
				FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.CenterAndExpand
			};

			Content = new StackLayout
			{
				Children =
				{
					frame,
					label
				}
			};
		}
Exemple #26
0
        private Frame BuildDrawingFrame()
        {
            DrawingImage = new ImageWithTouch {
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor = Color.White,
                CurrentLineColor = Color.Black
            };

            DrawingImage.SetBinding (ImageWithTouch.CurrentLineColorProperty, "CurrentLineColor");

            var palleteFrame = new Frame {
                BackgroundColor = Color.White,
                Padding = 5,
                HasShadow = false,
                OutlineColor = Color.Black,
                Content = DrawingImage
            };

            return palleteFrame;
        }
		public SettingsPage ()
		{
			Style = AppStyle.SettingsPageStyle;

			var pageTitle = new Frame () {
				Style = AppStyle.PageTitleLabelFrameStyle,
				Padding = new Thickness(0,Device.OnPlatform(15,0,0),0,10),
				Content = new Label { 
					Style = AppStyle.PageTitleLabelStyle,
					Text = "Settings",
				}
			};

			var signoutButton = new Button () {
				VerticalOptions = LayoutOptions.EndAndExpand,
				HorizontalOptions = LayoutOptions.Center,
				Text = "Sign Out",
				TextColor = AppStyle.DarkLabelColor,
			};

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.FillAndExpand,
				Padding = new Thickness (20),
				Children = {
					pageTitle,
					new BoxView() {
						HeightRequest = 1,
						BackgroundColor = AppStyle.DarkLabelColor,
					},
					new SettingsUserView(),
					new SyncView (),
					new SettingsSwitchView ("GPS"),
					new SettingsSwitchView ("Jobs Alert"),
					signoutButton,
					new StatusBarView()
				}
			};
		}
        public void DrawRectangle(List<Rectangle> rectangle, double imageWidth, double imageHeight)
        {
            //DisplayImage.Source = imageUri;
            var height = VideoPlayer.Height;
            var width = VideoPlayer.Width;
            var existingFrames = ResultRelativeLayout.Children.OfType<Frame>().ToList();
            foreach (var existingFrame in existingFrames)
            {
                ResultRelativeLayout.Children.Remove(existingFrame);
            }
            var frame = new Frame() { OutlineColor = Color.Red };


            //ResultRelativeLayout.Children.Add(frame, Constraint.RelativeToView(VideoPlayer, (ResultRelativeLayout, DisplayImage) => (rectangle[1].X * this.VideoPlayer.Width)), Constraint.RelativeToView(VideoPlayer, (ResultRelativeLayout, DisplayImage) => (rectangle[1].Y * VideoPlayer.Height)), Constraint.RelativeToView(VideoPlayer, (ResultRelativeLayout, DisplayImage) => this.VideoPlayer.Width - (rectangle[1].Width * VideoPlayer.Width)), Constraint.RelativeToView(VideoPlayer, (ResultRelativeLayout, DisplayImage) => this.VideoPlayer.Height - (rectangle[1].Height * VideoPlayer.Height)));
            foreach (var face in rectangle)
            {
                ResultRelativeLayout.Children.Add(frame,
                    Constraint.RelativeToView(VideoPlayer, (ResultRelativeLayout, DisplayImage) => (face.X * this.VideoPlayer.Width)),
                    Constraint.RelativeToView(VideoPlayer, (ResultRelativeLayout, DisplayImage) => (face.Y * VideoPlayer.Height)),
                    Constraint.RelativeToView(VideoPlayer, (ResultRelativeLayout, DisplayImage) => this.VideoPlayer.Width - (face.Width * VideoPlayer.Width)),
                    Constraint.RelativeToView(VideoPlayer, (ResultRelativeLayout, DisplayImage) => this.VideoPlayer.Height - (face.Height * VideoPlayer.Height)));
            }
        }
        public FloatingActionControl()
        {
            Spacing = 10;
            Orientation = StackOrientation.Horizontal;
            HorizontalOptions = LayoutOptions.End;

            _floatingActionButton = new FloatingActionButton {
                HorizontalOptions = LayoutOptions.End,
                Source = FLOATING_BUTTON_IMAGE,
                SizeRequest = 30
            };
            _tooltipLabel = new CustomFontLabel {TextColor = Color.Black, CustomFontSize = NamedSize.Micro};

            _tooltipLayout = new Frame {
                BackgroundColor = Color.White,
                Padding = new Thickness(10, 0),
                HasShadow = false,
                Content = _tooltipLabel
            };

            Children.Add(_tooltipLayout);
            Children.Add(_floatingActionButton);
        }
 internal void SetAppFrame(Frame viewFrame)
 {
     _appFrame = viewFrame;
 }
 public static FluentFrame Frame(Frame instance = null)
 {
     return new FluentFrame (instance);
 }
Exemple #32
0
        public PromptForInputsPage(InputGroup inputGroup, int stepNumber, int totalSteps, bool showCancelButton, string nextButtonTextOverride, CancellationToken? cancellationToken, string cancelConfirmation, string incompleteSubmissionConfirmation, string submitConfirmation, bool displayProgress, DateTimeOffset? firstPromptTimestamp, Action<Result> disappearanceCallback)
        {
            _displayedInputCount = 0;

            StackLayout contentLayout = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Padding = new Thickness(10, 20, 10, 20),
                Children =
                {
                    new Label
                    {
                        Text = inputGroup.Name,
                        FontSize = 20,
                        HorizontalOptions = LayoutOptions.CenterAndExpand
                    }
                }
            };

            if (displayProgress)
            {
                float progress = (stepNumber - 1) / (float)totalSteps;

                contentLayout.Children.Add(new Label
                    {
                        Text = "Progress:  " + Math.Round(100 * progress) + "%",
                        FontSize = 15,
                        HorizontalOptions = LayoutOptions.CenterAndExpand
                    });

                contentLayout.Children.Add(new ProgressBar
                    {
                        Progress = progress,
                        HorizontalOptions = LayoutOptions.FillAndExpand
                    });
            }

            if (firstPromptTimestamp.HasValue)
            {
                DateTime firstDisplayDateTime = firstPromptTimestamp.Value.ToLocalTime().DateTime;

                string displayLapseDayDesc;
                if (firstDisplayDateTime.Date == DateTime.Now.Date)
                    displayLapseDayDesc = "earlier today";
                else if (firstDisplayDateTime.Date == DateTime.Now.AddDays(-1).Date)
                    displayLapseDayDesc = "yesterday";
                else
                    displayLapseDayDesc = ((int)(DateTime.Now - firstDisplayDateTime).TotalDays) + " days ago (" + firstDisplayDateTime.ToShortDateString() + ")";

                contentLayout.Children.Add(new Label
                    {
                        Text = "These fields were first displayed " + displayLapseDayDesc + " at " + firstDisplayDateTime.ToShortTimeString() + ".",
                        FontSize = 20,
                        HorizontalOptions = LayoutOptions.Start
                    });
            }

            if (inputGroup.Inputs.Any(input => input.Display && input.Required))
                contentLayout.Children.Add(new Label
                    {
                        Text = "Required fields are indicated with *",
                        FontSize = 15,
                        TextColor = Color.Red,
                        HorizontalOptions = LayoutOptions.Start
                    });

            List<Input> displayedInputs = new List<Input>();
            int viewNumber = 1;
            int inputSeparatorHeight = 10;
            foreach (Input input in inputGroup.Inputs)
                if (input.Display)
                {
                    View inputView = input.GetView(viewNumber);
                    if (inputView != null)
                    {
                        if (input.Enabled && input.Frame)
                        {
                            inputView = new Frame
                            {
                                Content = inputView,
                                OutlineColor = Color.Accent,
                                VerticalOptions = LayoutOptions.Start,
                                HasShadow = true,
                                Padding = new Thickness(10)
                            };
                        }

                        // add some vertical separation between inputs
                        if (_displayedInputCount > 0)
                            contentLayout.Children.Add(new BoxView { Color = Color.Transparent, HeightRequest = inputSeparatorHeight });

                        contentLayout.Children.Add(inputView);
                        displayedInputs.Add(input);

                        if (input.DisplayNumber)
                            ++viewNumber;

                        ++_displayedInputCount;
                    }
                }

            if (_displayedInputCount > 0)
                contentLayout.Children.Add(new BoxView { Color = Color.Transparent, HeightRequest = inputSeparatorHeight });

            #region previous/next buttons

            StackLayout previousNextStack = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            #region previous button

            bool previousButtonTapped = false;

            if (stepNumber > 1)
            {
                Button previousButton = new Button
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    FontSize = 20,
                    Text = "Previous"
                };

                previousButton.Clicked += async (o, e) =>
                {
                    previousButtonTapped = true;
                    await Navigation.PopModalAsync(false);
                };

                previousNextStack.Children.Add(previousButton);
            }

            #endregion

            #region next button

            Button nextButton = new Button
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                FontSize = 20,
                Text = stepNumber < totalSteps ? "Next" : "Submit"

                #if UNIT_TESTING
                // set style id so that we can retrieve the button when unit testing
                , StyleId = "NextButton"
                #endif
            };

            if (nextButtonTextOverride != null)
                nextButton.Text = nextButtonTextOverride;

            bool nextButtonTapped = false;

            nextButton.Clicked += async (o, e) =>
            {
                string confirmationMessage = "";

                if (!string.IsNullOrWhiteSpace(incompleteSubmissionConfirmation) && !inputGroup.Valid)
                    confirmationMessage += incompleteSubmissionConfirmation;
                else if (nextButton.Text == "Submit" && !string.IsNullOrWhiteSpace(submitConfirmation))
                    confirmationMessage += submitConfirmation;

                if (string.IsNullOrWhiteSpace(confirmationMessage) || await DisplayAlert("Confirm", confirmationMessage, "Yes", "No"))
                {
                    // if the cancellation token was cancelled while the dialog was up, then we should ignore the dialog. the token
                    // will have already popped this page off the navigation stack.
                    if (!cancellationToken.GetValueOrDefault().IsCancellationRequested)
                    {
                        nextButtonTapped = true;
                        await Navigation.PopModalAsync(stepNumber == totalSteps);
                    }
                }
            };

            previousNextStack.Children.Add(nextButton);

            #endregion

            #endregion

            StackLayout navigationStack = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children = { previousNextStack }
            };

            #region cancel button

            bool cancelButtonTapped = false;

            if (showCancelButton)
            {
                Button cancelButton = new Button
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    FontSize = 20,
                    Text = "Cancel"
                };

                navigationStack.Children.Add(new BoxView { Color = Color.Gray, HorizontalOptions = LayoutOptions.FillAndExpand, HeightRequest = 0.5 });
                navigationStack.Children.Add(cancelButton);

                cancelButton.Clicked += async (o, e) =>
                {
                    string confirmationMessage = "";

                    if (!string.IsNullOrWhiteSpace(cancelConfirmation))
                        confirmationMessage += cancelConfirmation;

                    if (string.IsNullOrWhiteSpace(confirmationMessage) || await DisplayAlert("Confirm", confirmationMessage, "Yes", "No"))
                    {
                        // if the cancellation token was cancelled while the dialog was up, then we should ignore the dialog. the token
                        // will have already popped this page off the navigation stack (see below).
                        if (!cancellationToken.GetValueOrDefault().IsCancellationRequested)
                        {
                            cancelButtonTapped = true;
                            await Navigation.PopModalAsync(true);
                        }
                    }
                };
            }

            #endregion

            contentLayout.Children.Add(navigationStack);

            #region cancellation token

            bool cancellationTokenCanceled = false;

            if (cancellationToken != null)
            {
                // if the cancellation token is cancelled, pop this page off the stack.
                cancellationToken.GetValueOrDefault().Register(() =>
                    {
                        SensusServiceHelper.Get().Logger.Log("Cancellation token was cancelled. Will pop pages.", LoggingLevel.Normal, GetType());

                        cancellationTokenCanceled = true;

                        Device.BeginInvokeOnMainThread(async() =>
                            {
                                SensusServiceHelper.Get().Logger.Log("On UI thread. Ready to pop page.", LoggingLevel.Normal, GetType());

                                if (Navigation.ModalStack.Count > 0 && Navigation.ModalStack.Last() == this)
                                {
                                    await Navigation.PopModalAsync(true);
                                    SensusServiceHelper.Get().Logger.Log("Popped page.", LoggingLevel.Normal, GetType());
                                }
                                else
                                    SensusServiceHelper.Get().Logger.Log("No page to pop.", LoggingLevel.Normal, GetType());
                            });
                    });
            }

            #endregion

            Appearing += (o, e) =>
            {
                foreach (Input input in displayedInputs)
                    input.Viewed = true;
            };

            Disappearing += (o, e) =>
            {
                if (previousButtonTapped)
                    disappearanceCallback(Result.NavigateBackward);
                else if (cancelButtonTapped || cancellationTokenCanceled)
                    disappearanceCallback(Result.Cancel);
                else if (nextButtonTapped)
                    disappearanceCallback(Result.NavigateForward);
                else
                    disappearanceCallback(Result.Cancel);  // the user navigated back, or another activity started and covered the window
            };

            Content = new ScrollView
            {
                Content = contentLayout
            };
        }
Exemple #33
0
 public FrameHandler(NativeComponentRenderer renderer, XF.Frame frameControl) : base(renderer, frameControl)
 {
     FrameControl = frameControl ?? throw new ArgumentNullException(nameof(frameControl));
 }
Exemple #34
0
 private void addNameLabel(ChatMessage msgObj, bool user)
 {
     
     Label message = new Label()
     {
         Text = msgObj.Sender + " - " + msgObj.Time,
         TextColor = Color.Black,
         FontSize = 15,
         FontFamily = "Arial",
         FontAttributes = FontAttributes.Italic,
         HorizontalTextAlignment = user ? TextAlignment.End : TextAlignment.Start
     };
     Frame frame = new Frame()
     {
         Padding = new Thickness(5),
         Content = message,
         HorizontalOptions = user ? LayoutOptions.EndAndExpand : LayoutOptions.StartAndExpand,
         VerticalOptions = LayoutOptions.CenterAndExpand,
     };
     this.messageStack.Children.Add(frame);
 }