コード例 #1
0
        private void SetupUserInterface()
        {
            BackgroundColor = Color.Black;
            NavigationPage.SetHasNavigationBar(this, false);

            colorButton = new Image {
                Source = Images.Paintbrush
            };

            clockButton = new Image {
                Source = Images.ClockButton
            };

            sendButton = new Image {
                Source = Images.SendMomentButton
            };

            cancelButton = new Image {
                Source            = Images.CancelButton,
                HorizontalOptions = LayoutOptions.Start,
                HeightRequest     = 22,
                WidthRequest      = 22
            };

            var moment = new Image {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Source            = ImageSource.FromStream(() => new MemoryStream(ViewModel.Image))
            };

            var drawableMoment = new DrawableImage {
                BackgroundColor = Color.Transparent
            };

            drawableMoment.SetBinding(DrawableImage.CurrentLineColorProperty, "PenColor");

            mainLayout = new RelativeLayout()
            {
                Padding = new Thickness(0)
            };

            mainLayout.Children.Add(moment,
                                    Constraint.Constant(0),
                                    Constraint.Constant(0),
                                    Constraint.RelativeToParent((parent) => { return(parent.Width); }),
                                    Constraint.RelativeToParent((parent) => { return(parent.Height); }));

            mainLayout.Children.Add(drawableMoment,
                                    Constraint.Constant(0),
                                    Constraint.Constant(0),
                                    Constraint.RelativeToParent((parent) => { return(parent.Width); }),
                                    Constraint.RelativeToParent((parent) => { return(parent.Height); }));

            mainLayout.Children.Add(colorButton,
                                    Constraint.RelativeToParent((parent) => { return(parent.Width - 40); }),
                                    Constraint.Constant(15),
                                    Constraint.Constant(30),
                                    Constraint.Constant(30));

            mainLayout.Children.Add(cancelButton,
                                    Constraint.RelativeToParent((parent) => { return(15); }),
                                    Constraint.Constant(15),
                                    Constraint.Constant(30),
                                    Constraint.Constant(30));

            mainLayout.Children.Add(clockButton,
                                    Constraint.Constant(15),
                                    Constraint.RelativeToParent((parent) => { return(parent.Height - 40); }),
                                    Constraint.Constant(30),
                                    Constraint.Constant(30));

            mainLayout.Children.Add(sendButton,
                                    Constraint.RelativeToParent((parent) => { return(parent.Width - 40); }),
                                    Constraint.RelativeToParent((parent) => { return(parent.Height - 40); }),
                                    Constraint.Constant(30),
                                    Constraint.Constant(30));

            picker = new MomentsPicker();
            GetTimePickerItems();
            SetupBindings();
            mainLayout.Children.Add(picker,
                                    Constraint.Constant(15),
                                    Constraint.RelativeToParent((parent) => { return(parent.Height - 40); }),
                                    Constraint.Constant(30),
                                    Constraint.Constant(30));

            Content = mainLayout;
        }
コード例 #2
0
ファイル: DrawMomentPage.cs プロジェクト: pabalexa/Moments
		private void SetupUserInterface ()
		{
			BackgroundColor = Color.Black;
			NavigationPage.SetHasNavigationBar (this, false);

			colorButton = new Image {
				Source = Images.Paintbrush
			};

			clockButton = new Image {
				Source = Images.ClockButton
			};

			sendButton = new Image {
				Source = Images.SendMomentButton
			};

			cancelButton = new Image {
				Source = Images.CancelButton,
				HorizontalOptions = LayoutOptions.Start,
				HeightRequest = 22,
				WidthRequest = 22
			};

			var moment = new Image {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
				Source = ImageSource.FromStream(() => new MemoryStream (ViewModel.Image))
			};

			var drawableMoment = new DrawableImage {
				BackgroundColor = Color.Transparent
			};
			drawableMoment.SetBinding (DrawableImage.CurrentLineColorProperty, "PenColor");

			mainLayout = new RelativeLayout () {
				Padding = new Thickness (0)
			};

			mainLayout.Children.Add (moment, 
				Constraint.Constant (0), 
				Constraint.Constant (0), 
				Constraint.RelativeToParent ((parent) => { return parent.Width; }),
				Constraint.RelativeToParent ((parent) => { return parent.Height; }));

			mainLayout.Children.Add (drawableMoment, 
				Constraint.Constant (0), 
				Constraint.Constant (0), 
				Constraint.RelativeToParent ((parent) => { return parent.Width; }),
				Constraint.RelativeToParent ((parent) => { return parent.Height; }));

			mainLayout.Children.Add (colorButton, 
				Constraint.RelativeToParent ((parent) => { return parent.Width - 40; }),
				Constraint.Constant (15),
				Constraint.Constant (30), 
				Constraint.Constant (30));

			mainLayout.Children.Add (cancelButton, 
				Constraint.RelativeToParent ((parent) => { return 15; }),
				Constraint.Constant (15),
				Constraint.Constant (30), 
				Constraint.Constant (30));

			mainLayout.Children.Add (clockButton, 
				Constraint.Constant (15),
				Constraint.RelativeToParent ((parent) => { return parent.Height - 40; }),
				Constraint.Constant (30), 
				Constraint.Constant (30));

			mainLayout.Children.Add (sendButton, 
				Constraint.RelativeToParent ((parent) => { return parent.Width - 40; }),
				Constraint.RelativeToParent ((parent) => { return parent.Height - 40; }),
				Constraint.Constant (30), 
				Constraint.Constant (30));

			picker = new MomentsPicker ();
			GetTimePickerItems ();
			SetupBindings ();
			mainLayout.Children.Add (picker, 				
				Constraint.Constant (15),
				Constraint.RelativeToParent ((parent) => { return parent.Height - 40; }),
				Constraint.Constant (30), 
				Constraint.Constant (30));

			Content = mainLayout;
		}