Ejemplo n.º 1
1
        public MenuCell()
        {
            image = new Image {
                HeightRequest = 20,
                WidthRequest = 20,
            };

            image.Opacity = 0.5;
               // image.SetBinding(Image.SourceProperty, ImageSrc);

            label = new Label
            {

                YAlign = TextAlignment.Center,
                TextColor = Color.Gray,
            };

            var layout = new StackLayout
            {
               // BackgroundColor = Color.FromHex("2C3E50"),
                BackgroundColor = Color.White,

                Padding = new Thickness(20, 0, 0, 0),
                Orientation = StackOrientation.Horizontal,
                Spacing = 20,
                //HorizontalOptions = LayoutOptions.StartAndExpand,
                Children = { image,label }
            };
            View = layout;
        }
Ejemplo n.º 2
0
        public Playlist(MainPage sender, string[] playlist, Xamarin.Forms.StackLayout parent)
        {
            PlaylistName  = "Eminem&Vladko";
            ButtonText    = ("Play/Pause");
            this.sender   = sender;
            this.playlist = playlist;

            DomuClick      = new Command(Domu);
            PlaylistyClick = new Command(Playlisty);
            ButtonClick    = new Command(Button);
            PlayClick      = new Command <string>(Play);

            foreach (string s in playlist)
            {
                var song = new Button()
                {
                    Text             = s,
                    Command          = PlayClick,
                    CommandParameter = s
                };
                parent.Children.Add(song);
            }

            //    CrossMediaManager.Current.Init();
            //    CrossMediaManager.Current.Play("http://tulak.host/song2.mp3");
        }
Ejemplo n.º 3
0
        protected override void RenderContentView(Xamarin.Forms.StackLayout parent)
        {
            lblTitle.Text = HeaderTitle;
            var position = new Position(24.230388, 55.733529);
            var pin      = new Pin
            {
                Type     = PinType.Place,
                Position = position,
                Label    = "Al-Ain Hospital"
            };

            var map = new Map(MapSpan.FromCenterAndRadius(pin.Position, Distance.FromMiles(0.2)))
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                IsShowingUser     = true
            };

            map.Pins.Add(pin);

            var stackLayout = new StackLayout()
            {
                Padding = 15, Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand
            };

            stackLayout.Children.Add(map);
            parent.Children.Add(stackLayout);
        }
Ejemplo n.º 4
0
        public Setting()
        {
            var stack = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Spacing = 10
            };

            var stack2 = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Spacing = 10,
                Padding = 10
            };

            var about = new Label
            {
                Font = Font.SystemFontOfSize(NamedSize.Medium),
                Text = "Setting",
                LineBreakMode = LineBreakMode.WordWrap
            };

            stack2.Children.Add(about);
            stack.Children.Add(new ScrollView { VerticalOptions = LayoutOptions.FillAndExpand, Content = stack2 });
            Content = stack;

        }
		public CardDetailsView (Card card)
		{
			BackgroundColor = Color.White;

			Label TitleText = new Label () {
				FormattedText = card.Title,
				FontSize = 18,
				TextColor = StyleKit.LightTextColor
			};

			Label DescriptionText = new Label () {
				FormattedText = card.Description,
				FontSize = 12,
				TextColor = StyleKit.LightTextColor
			};

			var stack = new StackLayout () {
				Spacing = 0,
				Padding = new Thickness (10, 0, 0, 0),
				VerticalOptions = LayoutOptions.CenterAndExpand,
				Children = {
					TitleText,
					DescriptionText,
					new DateTimeView (card)
				}
			};

			Content = stack;
		}
		public WithoutDataTemplatePageCS ()
		{
			Title = "Without a Data Template";
			Icon = "csharp.png";

			var people = new List<Person> {
				new Person ("Steve", 21, "USA"),
				new Person ("John", 37, "USA"),
				new Person ("Tom", 42, "UK"),
				new Person ("Lucas", 29, "Germany"),
				new Person ("Tariq", 39, "UK"),
				new Person ("Jane", 30, "USA")
			};

			var listView = new ListView { ItemsSource = people };

			Content = new StackLayout { 
				Padding = new Thickness (0, 20, 0, 0),
				Children = {
					new Label {
						Text = "ListView without a Data Template",
						FontAttributes = FontAttributes.Bold,
						HorizontalOptions = LayoutOptions.Center
					},
					listView
				}
			};
		}
Ejemplo n.º 7
0
        internal ReplaceRoomViewModel(Xamarin.Forms.Page element, Xamarin.Forms.StackLayout spList, Xamarin.Forms.ControlTemplate ctControlTemplate)
        {
            this._element = element;

            this._spList            = spList;
            this._ctControlTemplate = ctControlTemplate;
        }
Ejemplo n.º 8
0
		public MenuPage ()
		{
			Title = "LoginPattern";
			Icon = "slideout.png";

			var section = new TableSection () {
				new TextCell {Text = "Sessions"},
				new TextCell {Text = "Speakers"},
				new TextCell {Text = "Favorites"},
				new TextCell {Text = "Room Plan"},
				new TextCell {Text = "Map"},
			};

			var root = new TableRoot () {section} ;

			tableView = new TableView ()
			{ 
				Root = root,
				Intent = TableIntent.Menu,
			};

			var logoutButton = new Button { Text = "Logout" };
			logoutButton.Clicked += (sender, e) => {
				App.Current.Logout();
			};

			Content = new StackLayout {
				BackgroundColor = Color.Gray,
				VerticalOptions = LayoutOptions.FillAndExpand,
				Children = {
					tableView, 
					logoutButton
				}
			};
		}
        public BlogDetailsView(FeedItem item)
        {
            BindingContext = item;
            var webView = new WebView
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            webView.Source = new HtmlWebViewSource
            {
                Html = item.Description
            };
            Content = new StackLayout
            {
                Children =
        {
          webView
        }
            };
            var share = new ToolbarItem
            {
                Icon = "ic_share.png",
                Text = "Share",
                Command = new Command(() => DependencyService.Get<IShare>()
                  .ShareText("Be sure to read @shanselman's " + item.Title + " " + item.Link))
            };

            ToolbarItems.Add(share);
        }
Ejemplo n.º 10
0
        public RoomListViewModel(Page _element, Xamarin.Forms.StackLayout spList, Xamarin.Forms.ControlTemplate ctControlTemplate)
        {
            this._element = _element;

            this._spList            = spList;
            this._ctControlTemplate = ctControlTemplate;
        }
Ejemplo n.º 11
0
        protected override void OnAppearing()
        {
            base.OnAppearing ();

            var goXamlButton = new Button { Text = " Go With Xaml " , TextColor= Color.Black, BackgroundColor= Color.Gray};
            goXamlButton.Clicked += (sender, e) => {
                Navigation.PushAsync (new MenuPage());
            };

            var goCodeButton = new Button { Text = " Go With Code Only " , TextColor= Color.Black, BackgroundColor= Color.Gray };
            goCodeButton.Clicked += (sender, e) => {
                Navigation.PushAsync (new TodoListPage());
            };
            // The root page of your application
            Content = new StackLayout {
                VerticalOptions = LayoutOptions.Center,
                Children = {
                    new Label {
                        XAlign = TextAlignment.Center,
                        Text = "Welcome " + ((UserProfile)BindingContext).Name
                    },
                    goCodeButton,
                    goXamlButton
                }
            };
        }
Ejemplo n.º 12
0
        public BookChapterLabel()
        {
            this.Orientation = StackOrientation.Horizontal;
            this.HorizontalOptions = LayoutOptions.FillAndExpand;
            this.VerticalOptions = LayoutOptions.StartAndExpand;

            // Book & chapter layout
            StackLayout bookChapter = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Spacing = 0,
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };

            this.chapterLabel = new ChapterLabel();
            bookChapter.Children.Add(chapterLabel);

            this.bookLabel = new BookLabel();
            bookChapter.Children.Add(this.bookLabel);

            // Main layout
            this.settingsLabel = new SettingsLabel();
            this.Children.Add(this.settingsLabel);

            this.Children.Add(bookChapter);

            this.verseLabel = new VerseLabel();
            this.Children.Add(this.verseLabel);
        }
Ejemplo n.º 13
0
		void CreateControls()
		{
			_picker = new DatePicker { Format = "D" };

			_manExpense = new Entry { Placeholder = "Exemple : 0,00", Keyboard = Keyboard.Numeric };
			_manExpense.TextChanged += numberEntry_TextChanged;
			_womanExpense = new Entry { Placeholder = "Exemple : 0,00", Keyboard = Keyboard.Numeric };
			_womanExpense.TextChanged += numberEntry_TextChanged;
			_details = new Editor { BackgroundColor = AppColors.Gray.MultiplyAlpha(0.15d), HeightRequest = 150 };

			Content = new StackLayout
				{ 
					Padding = new Thickness(20),
					Spacing = 10,
					Children =
						{
							new Label { Text = "Date" },
							_picker,
							new Label { Text = "Man expense" },
							_manExpense,
							new Label { Text = "Woman expense" },
							_womanExpense,
							new Label { Text = "Informations" },
							_details
						}
					};
		}
Ejemplo n.º 14
0
		public ListItemTemplate ()
		{
			var photo = new Image { HeightRequest = 44, WidthRequest = 44 };
			photo.SetBinding (Image.SourceProperty, "Photo");

			var nameLabel = new Label { 
				VerticalTextAlignment = TextAlignment.Center,
				FontAttributes = FontAttributes.None,
				FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label)),
			};

			nameLabel.SetBinding (Label.TextProperty, "Name");

			var titleLabel = new Label { 
				VerticalTextAlignment = TextAlignment.Center,
				FontAttributes = FontAttributes.None,
				FontSize = Device.GetNamedSize (NamedSize.Micro, typeof(Label)),
			};

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

			var information = new StackLayout {
				Padding = new Thickness (5, 0, 0, 0),
				VerticalOptions = LayoutOptions.StartAndExpand,
				Orientation = StackOrientation.Vertical,
				Children = { nameLabel, titleLabel }
			};

			View = new StackLayout {
				Orientation = StackOrientation.Horizontal,
				Children = { photo, information }
			};
		}
Ejemplo n.º 15
0
        private StackLayout BuildContent()
        {
            var layout = new StackLayout ();

            _list = new ListView {
                //VerticalOptions = LayoutOptions.FillAndExpand,
                ItemTemplate = new DataTemplate(typeof(ListItemView)),
                RowHeight = 90,
            };

            _list.ItemTapped +=	(sender, e) => {
                var todoListPage = new TodoListPage ();
                Navigation.PushAsync (todoListPage);
            };

            _list.ItemSelected += (sender, e) => {
                var todoListPage = new TodoListPage ();
                Navigation.PushAsync (todoListPage);
            };

            _list.SetBinding(ListView.ItemsSourceProperty, "Data");

            layout.Children.Add (_list);
            layout.VerticalOptions = LayoutOptions.FillAndExpand;
            layout.BackgroundColor = Color.Yellow;

            return layout;
        }
Ejemplo n.º 16
0
        public Login()
        {
            Entry usuario = new Entry { Placeholder = "Usuario" };
            Entry clave = new Entry { Placeholder = "Clave", IsPassword = true };

            Button boton = new Button {
                Text = "Login",
                TextColor = Color.White,
                BackgroundColor = Color.FromHex ("77D065")
            };

            boton.Clicked += (sender, e) => {

            };

            //Stacklayout permite apilar los controles verticalmente
            StackLayout stackLayout = new StackLayout
            {
                Spacing = 20,
                Padding = 50,
                VerticalOptions = LayoutOptions.Center,
                Children =
                {
                    usuario,
                    clave,
                    boton
                }
            };

            //Como esta clase hereda de ContentPage, podemos usar estas propiedades directamente
            this.Content = stackLayout;
            this.Padding = new Thickness (5, Device.OnPlatform (20, 5, 5), 5, 5);
        }
Ejemplo n.º 17
0
        public LoginPage()
        {
            user = new Entry {
                Placeholder = "Usuario"
            };
            pass = new Entry {
                IsPassword = true,
                Placeholder = "****"
            };

            Content = new StackLayout {
                Children = {
                    new Label {
                        Text = "Usuario"
                    },
                    user,
                    new Label {
                        Text = "Contraseña"
                    },
                    pass,
                    new Button {
                        Text = "Ingresar",
                        Command = new Command (Acceder)
                    }
                }
            };
        }
Ejemplo n.º 18
0
        public RssFeedView2()
        {
            this.viewModel = new RssFeedViewModel();
            this.BindingContext = viewModel;
            this.Title = "Rss Feed";

            var refresh = new ToolbarItem(){ Command = viewModel.ReloadCommand, Name = "Reload", Priority = 0 };
            ToolbarItems.Add(refresh);

            var stack = new StackLayout(){ Orientation = StackOrientation.Vertical };
            var activity = new ActivityIndicator(){ Color = Color.Blue, IsEnabled = true };
            activity.SetBinding(ActivityIndicator.IsVisibleProperty, "ShowActivityIndicator");
            activity.SetBinding(ActivityIndicator.IsRunningProperty, "ShowActivityIndicator");

            stack.Children.Add(activity);

            var listview = new ListView();
            listview.ItemsSource = viewModel.Records;
            var cell = new DataTemplate(typeof(ImageCell));
            cell.SetBinding(ImageCell.TextProperty, "Title");
            cell.SetBinding(ImageCell.ImageSourceProperty, "Image");
            listview.ItemTemplate = cell;
            listview.ItemSelected += async (sender, e) => {
                await Navigation.PushAsync(new RssWebView((RssRecordViewModel)e.SelectedItem));
                listview.SelectedItem = null;
            };

            stack.Children.Add(listview);

            Content = stack;
        }
		public RequiredFieldTriggerPage ()
		{
			var l = new Label {
				Text = "Entry requires length>0 before button is enabled",
			};
			l.FontSize = Device.GetNamedSize (NamedSize.Small, l); 

			var e = new Entry { Placeholder = "enter name" };

			var b = new Button { Text = "Save",

				HorizontalOptions = LayoutOptions.Center
			};
			b.FontSize = Device.GetNamedSize (NamedSize.Large ,b);

			var dt = new DataTrigger (typeof(Button));
			dt.Binding = new Binding ("Text.Length", BindingMode.Default, source: e);
			dt.Value = 0;
			dt.Setters.Add (new Setter { Property = Button.IsEnabledProperty, Value = false });
			b.Triggers.Add (dt);

			Content = new StackLayout { 
				Padding = new Thickness(0,20,0,0),
				Children = {
					l,
					e,
					b
				}
			};
		}
Ejemplo n.º 20
0
		public TodoItemCell ()
		{
			StyleId = "Cell";

			var label = new Label {
				StyleId = "CellLabel",
				YAlign = TextAlignment.Center,
				HorizontalOptions = LayoutOptions.StartAndExpand
			};
			label.SetBinding (Label.TextProperty, "Name");

			var tick = new Image {
				StyleId = "CellTick",
				Source = FileImageSource.FromFile ("check"),
				HorizontalOptions = LayoutOptions.End
			};
			tick.SetBinding (Image.IsVisibleProperty, "Done");

			var layout = new StackLayout {
				Padding = new Thickness(20, 0, 20, 0),
				Orientation = StackOrientation.Horizontal,
				HorizontalOptions = LayoutOptions.FillAndExpand,
				Children = {label, tick}
			};
			View = layout;
		}
Ejemplo n.º 21
0
        public GuidePageView()
        {
            this.BackgroundColor = Color.Black;

            var layout = new StackLayout{ Padding = new Thickness (5, 10) };
            this.Title = "Help Page";
            layout.Children.Add (new Label {
                Text = "This will contain some helpful information.",
                FontSize = 30,
                TextColor = Color.White
            });

            var browser = new WebView ();
            var htmlSource = new HtmlWebViewSource ();
            htmlSource.Html = @"<iframe width=""300"" height=""200"" src=""https://www.youtube.com/embed/Y7bxlR-MxxM"" frameborder=""0"" allowfullscreen></iframe>";
            browser.Source = htmlSource;
            browser.HeightRequest = 215.0;
            browser.WidthRequest = 320.0;

            layout.Children.Add (browser);
            layout.Children.Add (
                new Button () {Text = "I'm ready to start",
                    Command = new Command (() => this.Navigation.PushAsync (new MainListViews ()))
                });
            this.Content = layout;
        }
        public StackLayout CreateNewCountLayout()
        {
            var lblCount = new Label()
            {
                HorizontalOptions = LayoutOptions.Start,
                FontSize = 24,
            };
            lblCount.SetBinding(Label.TextProperty, new Binding("Count" , stringFormat: "#{0}"));

            var lblPrice = new Label()
            {
                HorizontalOptions = LayoutOptions.End,
                FontSize = 24,
            };
            lblPrice.SetBinding(Label.TextProperty, new Binding("Price", stringFormat: "\t\t\t{0:C2}"));

            var countLayout = new StackLayout()
            {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Orientation = StackOrientation.Horizontal,
                Children = { lblCount, lblPrice }
            };

            return countLayout;
        }
		static StackLayout CreateMiddleLayout()
		{

			//			var preBlank = new Label {
			//				Text = "",
			//				FontSize = 11
			//			};
			var preAbv = new Label {
				Text = "Abv",
				FontSize = 11,
				FontAttributes = FontAttributes.Bold
			};

			var preIbu = new Label {
				Text = "Ibu",
				FontSize = 11,
				FontAttributes = FontAttributes.Bold
			};


			var ctrlayout = new StackLayout()
			{
				//HorizontalOptions = LayoutOptions.Start,
				VerticalOptions = LayoutOptions.Center,
				Orientation = StackOrientation.Vertical,
				Children = {preIbu, preAbv }
			};

			return ctrlayout;
		}
		public LoadResourceXml ()
		{
			#region How to load an XML file embedded resource
			var assembly = typeof(LoadResourceText).GetTypeInfo().Assembly;
			Stream stream = assembly.GetManifestResourceStream("WorkingWithFiles.PCLXmlResource.xml");

			List<Monkey> monkeys;
			using (var reader = new System.IO.StreamReader (stream)) {
				var serializer = new XmlSerializer(typeof(List<Monkey>));
				monkeys = (List<Monkey>)serializer.Deserialize(reader);
			}
			#endregion

			var listView = new ListView ();
			listView.ItemsSource = monkeys;


			Content = new StackLayout {
				Padding = new Thickness (0, 20, 0, 0),
				VerticalOptions = LayoutOptions.StartAndExpand,
				Children = {
					new Label { Text = "Embedded Resource XML File (PCL)", 
						FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label)),
						FontAttributes = FontAttributes.Bold
					}, listView
				}
			};

			// NOTE: use for debugging, not in released app code!
			//foreach (var res in assembly.GetManifestResourceNames()) 
			//	System.Diagnostics.Debug.WriteLine("found resource: " + res);
		}
        public ScrollTranslatePage()
        {
            Title = "Scroll";
            Icon = "128/resizedimageullist.png";

            Content = new StackLayout
            {
                Children =
                {
                    ScrollerStackLayout,
                    AmpmStackLayout,
                    TotalTimeStackLayout
                },
                Orientation = StackOrientation.Vertical,
                Spacing = 10,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                BackgroundColor = Colors.SoftGray
            };

            BackgroundColor = Colors.SoftGray;

            MinutesScroll.Unfocused += (sender, args) => { CalculateTime(); };

            HourScroll.Unfocused += (sender, args) => { CalculateTime(); };

            PastPresentScroll.Unfocused += (sender, args) => { CalculateTime(); };

            AmPmPicker.Unfocused += (sender, args) => { CalculateTime(); };
        }
		public ListOfBeerCell2 ()
		{
			var preBlank = new Label {
				Text = "",
				FontSize = 11
			};

			var image = new Image
			{
				Aspect = Aspect.AspectFill,
				//WidthRequest = 150,

				HorizontalOptions = LayoutOptions.Start,
				VerticalOptions = LayoutOptions.Center
			};
			image.SetBinding(Image.SourceProperty, new Binding("ProName"));

			var rslayout = CreateRightSideLayout ();

			var ctrlayout = CreateMiddleLayout ();

			var ctrrghtlayout = CreateMiddleRightLayout ();

			var leftImageLayout = new StackLayout()
			{
				Spacing = 2,
				Padding = new Thickness (5, 5, 0, 5),
				VerticalOptions = LayoutOptions.Center,
				Orientation = StackOrientation.Horizontal,
				Children = {image, ctrlayout, ctrrghtlayout, rslayout}
			};
			View = leftImageLayout;
		}
Ejemplo n.º 27
0
		public HomePageCS ()
		{
			var rotateButton = new Button { Text = "Rotate Animation" };
			rotateButton.Clicked += OnRotateAnimationButtonClicked;
			var relativeRotateButton = new Button { Text = "Relative Rotate Animation" };
			relativeRotateButton.Clicked += OnRelativeRotateAnimationButtonClicked;
			var rotateAnchorButton = new Button { Text = "Rotate Animation with Anchors" };
			rotateAnchorButton.Clicked += OnRotateAnimationWithAnchorsButtonClicked;
			var multipleRotateButton = new Button { Text = "Multiple Rotations" };
			multipleRotateButton.Clicked += OnMultipleRotationAnimationButtonClicked;
			var scaleButton = new Button { Text = "Scale Animation" };
			scaleButton.Clicked += OnScaleAnimationButtonClicked;
			var relativeScaleButton = new Button { Text = "Relative Scale Animation" };
			relativeScaleButton.Clicked += OnRelativeScaleAnimationButtonClicked;
			var transformButton = new Button { Text = "Transform Animation" };
			transformButton.Clicked += OnTransformAnimationButtonClicked;
			var fadeButton = new Button { Text = "Fade Animation" };
			fadeButton.Clicked += OnFadeAnimationButtonClicked;

			Title = "Basic Animation Demo";
			Content = new StackLayout { 
				Margin = new Thickness (0, 20, 0, 0),
				Children = {
					rotateButton,
					relativeRotateButton,
					rotateAnchorButton,
					multipleRotateButton,
					scaleButton,
					relativeScaleButton,
					transformButton,
					fadeButton
				}
			};
		}
Ejemplo n.º 28
0
        public AcercaDePage() {
            Title = "Acerca de";
            Icon = "info.png";
            
            BackgroundImage = "background.png";
            StackLayout panel = new StackLayout
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Orientation= StackOrientation.Vertical,
                Spacing = 15,
                Padding = new Thickness(20, Device.OnPlatform(40, 20, 20), 20, 20),
            };

            panel.Children.Add(new Label { 
                Text ="Aplicación desarrollada por:",
                TextColor = Color.Black,
            });

            var imagen = new Image
            {
                HorizontalOptions = LayoutOptions.Center,
            };

            imagen.Source = ImageSource.FromFile("csharp.jpeg");
            panel.Children.Add(imagen);

            panel.Children.Add(new Label
            {
                Text = "Rafael Cárdenas",
                TextColor = Color.Black,
            });

            Content = panel;
        }
        public VerticalOptionsDemo()
        {
            Color[] colors = {Color.Yellow, Color.Blue,};
            var flipFlopper = 0;

            // Create Labels sorted by LayoutAlignment property.
            var labels = from field in typeof (LayoutOptions).GetRuntimeFields()
                where field.IsPublic && field.IsStatic
                orderby ((LayoutOptions) field.GetValue(null)).Alignment
                select new Label
                {
                    Text = "VerticalOptions = " + field.Name,
                    VerticalOptions = (LayoutOptions) field.GetValue(null),
                    XAlign = TextAlignment.Center,
                    FontSize = Device.GetNamedSize(NamedSize.Medium, typeof (Label)),
                    TextColor = colors[flipFlopper],
                    BackgroundColor = colors[flipFlopper = 1 - flipFlopper]
                };

            // Transfer to StackLayout.

            var stackLayout = new StackLayout();

            foreach (var label in labels)
            {
                stackLayout.Children.Add(label);
            }

            Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);
            Content = stackLayout;
        }
Ejemplo n.º 30
0
        private UICollectionSynchronizer(IList<CardViewModel> collection, INotifyCollectionChanged collectionChanged, StackLayout stackLayout, GamePageModel gamePageModel)
        {
            this.stackLayout = stackLayout;
            this.gamePageModel = gamePageModel;
            ((INotifyCollectionChanged)collection).CollectionChanged += (object sender, NotifyCollectionChangedEventArgs e) => {
                if (e.Action == NotifyCollectionChangedAction.Reset) {
                    this.stackLayout.Children.Clear ();
                    this.mapper.Clear ();
                } else {
                    if(e.OldItems != null)
                    {
                        foreach (CardViewModel card in e.OldItems) {
                            this.RemoveItem(card);
                        }
                    }

                    if(e.NewItems != null)
                    {
                        foreach (CardViewModel card in e.NewItems) {
                            this.AddItem(card);
                        }
                    }
                }
            };
            foreach (CardViewModel card in collection) {
                this.AddItem (card);
            }
        }
Ejemplo n.º 31
0
        } //end ctor

        private StackLayout BuildView()
        {
            Editor editor = new Editor();
            editor.SetBinding(Editor.TextProperty, "Account.Notes");
         
            TableView tblView = new TableView() 
            {
                Root = new TableRoot() 
                {
                    new TableSection("NOTES")
                }
            };

            StackLayout stack = new StackLayout()
            {
                Padding = 10,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children = 
                {
                    tblView,
                    editor
                }
            };

            return stack;
        } //end BuildView
        protected virtual void WrapView()
        {
            Device.BeginInvokeOnMainThread(() =>
            {
                Xamarin.Forms.Layout <View> OriginalParent = View.Parent as Xamarin.Forms.Layout <View>;
                int Index        = OriginalParent.Children.FindIndexOf(x => x == View);
                Label alertLabel = new Label()
                {
                    TextColor = Color.Red,
                    FontSize  = 14
                };
                alertLabel.SetValue(Label.BindingContextProperty, this);
                alertLabel.SetBinding(Label.TextProperty, path: nameof(ErrorMessage));
                alertLabel.SetBinding(Label.IsVisibleProperty, path: nameof(HasError));

                StackLayout stack = new StackLayout()
                {
                    Spacing = 0, Padding = 0
                };
                OriginalParent.Children.RemoveAt(Index);
                stack.Children.Add(View);
                stack.Children.Add(alertLabel);
                OriginalParent.Children.Insert(Index, stack);
            });
        }
Ejemplo n.º 33
0
        private void InitializeComponents()
        {
            StackLayout layout = new StackLayout ();

            nameLabel = new Label () {
                Text = client.Name,
                FontSize = 18,
                XAlign = TextAlignment.Center
            };

            layout.Children.Add ( nameLabel );

            profileImage = new Image () {
                Source = client.PictureUrl,
                Aspect = Aspect.AspectFit
            };

            layout.Children.Add ( profileImage );

            phoneLabel = new Label () {
                Text = client.Phone,
                FontSize = 14,
                XAlign = TextAlignment.Center
            };

            layout.Children.Add ( phoneLabel );

            Content = layout;
        }
Ejemplo n.º 34
0
		public MenuPage ()
		{
			Icon = "settings.png";
			Title = "Gráficos"; // The Title property must be set.
			BackgroundColor = Color.FromHex ("333333");

			Menu = new MenuListView ();

			var menuLabel = new ContentView {
				Padding = new Thickness (10, 36, 0, 5),
				Content = new Label {
					TextColor = Color.FromHex ("AAAAAA"),
					Text = "Gráficos", 
				}
			};

			var layout = new StackLayout { 
				Spacing = 0, 
				VerticalOptions = LayoutOptions.FillAndExpand
			};
			layout.Children.Add (menuLabel);
			layout.Children.Add (Menu);

			Content = layout;
		}
Ejemplo n.º 35
0
        public ScriptInputGroupPage(InputGroup inputGroup, List<InputGroup> previousInputGroups)
        {
            Title = "Input Group";

            StackLayout contentLayout = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            foreach (StackLayout stack in UiProperty.GetPropertyStacks(inputGroup))
                contentLayout.Children.Add(stack);

            Button editInputsButton = new Button
            {
                Text = "Edit Inputs",
                FontSize = 20,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            editInputsButton.Clicked += async (o, e) =>
            {
                await Navigation.PushAsync(new ScriptInputsPage(inputGroup, previousInputGroups));
            };

            contentLayout.Children.Add(editInputsButton);

            Content = new ScrollView
            {
                Content = contentLayout
            };
        }
Ejemplo n.º 36
0
        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;
                }
            });
        }
        public BubbonPushModalAsyncPage()
        {
            button1 = new Button {
                Text = "No Target"
            };
            button2 = new Button {
                Text = "Target"
            };
            button3 = new Button {
                Text = "Cancel"
            };

            Content = new Xamarin.Forms.StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Children        =
                {
                    button1,
                    button2,
                    button3,
                }
            };

            bubble = new BubblePopup(null)
            {
                Padding         = 25,
                BackgroundColor = Color.Blue,
                //Target = button, // Uncomment this line, and it crashes too
                Content = new Xamarin.Forms.StackLayout
                {
                    Children =
                    {
                        new Xamarin.Forms.Label {
                            Text = "This is a test bubble"
                        }
                    }
                }
            };

            button1.Clicked += (sender, e) => {
                bubble.Target    = null;
                bubble.IsVisible = true;
            };

            button2.Clicked += (sender, e) => {
                bubble.Target    = button1;
                bubble.IsVisible = true;
            };

            button3.Clicked += (sender, e) => {
                //Cancelled?.Invoke(this,new EventArgs());
                Navigation.PopModalAsync();
            };
        }
        public SegmentSelectedBackgroundPage()
        {
            var matSegCtrl = new SegmentedControl
            {
                Padding         = 4,
                BackgroundColor = Color.FromRgb(112, 128, 144),
                OutlineColor    = Color.FromRgb(112, 128, 144).WithLuminosity(0.25),
                Segments        =
                {
                    new Segment {
                        Text = "Orange"
                    },
                    new Segment {
                        Text = "Blue"
                    },
                    new Segment {
                        Text = "Yellow"
                    }
                }
            };

            matSegCtrl.SegmentSelected += (sender, e) =>
            {
                switch (e.Segment.Text)
                {
                case "Orange":
                    matSegCtrl.SelectedBackgroundColor = Color.Orange;
                    matSegCtrl.SelectedTextColor       = Color.Default;
                    break;

                case "Blue":
                    matSegCtrl.SelectedBackgroundColor = Color.Blue;
                    matSegCtrl.SelectedTextColor       = Color.White;
                    break;

                case "Yellow":
                    matSegCtrl.SelectedBackgroundColor = Color.Yellow;
                    matSegCtrl.SelectedTextColor       = Color.Default;
                    break;
                }
            };

            Content = new Xamarin.Forms.StackLayout
            {
                Padding  = new Thickness(20),
                Children =
                {
                    new Xamarin.Forms.Label {
                        Text = "SegmentSelectedBackgroundPage"
                    },
                    matSegCtrl
                }
            };
        }
        public BubbonPushModalAsyncPage()
        {
            Padding = 20;

            button1 = new Forms9Patch.Button("No Target");
            button2 = new Forms9Patch.Button("Target");


            Content = new Xamarin.Forms.StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Children        =
                {
                    button1,
                    button2,
                    returnButton,
                }
            };

            bubble = new BubblePopup(button1)
            {
                Padding         = 25,
                BackgroundColor = Color.Blue,
                //Target = button, // Uncomment this line, and it crashes too
                Content = new Xamarin.Forms.StackLayout
                {
                    Children =
                    {
                        new Xamarin.Forms.Label {
                            Text = "This is a test bubble"
                        }
                    }
                }
            };

            button1.Clicked += (sender, e) =>
            {
                bubble.Target    = null;
                bubble.IsVisible = true;
            };

            button2.Clicked += (sender, e) =>
            {
                bubble.Target    = button1;
                bubble.IsVisible = true;
            };

            returnButton.Clicked += (sender, e) =>
            {
                this.Navigation.PopModalAsync();
            };
        }
        public ImagensFromResource()
        {
            InitializeComponent();
            var layout = new Xamarin.Forms.StackLayout();
            var image  = new Image();
            //Colocar o arquivo em uma pasta e em "Ação de Compilação" colocar "Recurso Inserido", seguir o padrão de nome conforme abaixo ad
            var imagesource = ImageSource.FromResource("AulaXamarinNET.ImagensDoProjeto.background.jpg");

            image.Source = imagesource;

            layout.Children.Add(image);
            Content = layout;
        }
Ejemplo n.º 41
0
        public ButtonTapped()
        {
            Padding = 40;

            var button = new Forms9Patch.Button
            {
                Text            = "Button",
                TextColor       = Color.Pink,
                FontSize        = 20,
                HeightRequest   = 30,
                WidthRequest    = 200,
                OutlineColor    = Color.Pink,
                OutlineRadius   = 5,
                OutlineWidth    = 2,
                IsVisible       = true,
                BackgroundColor = Color.White,
            };

            button.Tapped += OnTapped;

            var stateButton = new StateButton
            {
                Text            = "StateButton",
                TextColor       = Color.Green,
                FontSize        = 20,
                HeightRequest   = 30,
                WidthRequest    = 200,
                OutlineColor    = Color.Green,
                OutlineRadius   = 5,
                OutlineWidth    = 2,
                IsVisible       = true,
                BackgroundColor = Color.White
            };

            stateButton.Tapped += OnTapped;

            Content = new Xamarin.Forms.StackLayout
            {
                Children =
                {
                    button, stateButton
                }
            };
        }
        public SegmentSelectedBackgroundPage()
        {
            borderSegCtrl.SegmentSelected += OnSegmentSelected;
            segCtrl.SegmentSelected       += OnSegmentSelected;

            Content = new Xamarin.Forms.StackLayout
            {
                Padding  = new Thickness(20),
                Children =
                {
                    new Xamarin.Forms.Label {
                        Text = "SegmentSelectedBackgroundPage"
                    },
                    borderSegCtrl,
                    segCtrl,
                    boxView,
                    runReduceWidthRequestButton
                }
            };
        }
Ejemplo n.º 43
0
        private static XF.ContentPage GetErrorPageForException(Exception exception)
        {
            var stackLayout = new XF.StackLayout
            {
                Padding = 10,
            };

            stackLayout.Children.Add(
                new XF.Label
            {
                FontAttributes = XF.FontAttributes.Bold,
                FontSize       = XF.Device.GetNamedSize(XF.NamedSize.Large, typeof(XF.Label)),
                Text           = "Unhandled exception",
            });
            stackLayout.Children.Add(
                new XF.Label
            {
                Text = exception?.Message,
            });
            stackLayout.Children.Add(
                new XF.ScrollView
            {
                Content =
                    new XF.Label
                {
                    FontSize = XF.Device.GetNamedSize(XF.NamedSize.Small, typeof(XF.Label)),
                    Text     = exception?.StackTrace,
                },
            });

            var errorPage = new XF.ContentPage()
            {
                Title   = "Unhandled exception",
                Content = stackLayout,
            };

            return(errorPage);
        }
Ejemplo n.º 44
0
        public PopupsPage()
        {
            Padding = 20;

            var showModalButton   = new Forms9Patch.Button("ModalPopup");
            var cancelModalButton = new Forms9Patch.Button("CANCEL");
            var modal             = new ModalPopup
            {
                Content = new Xamarin.Forms.StackLayout
                {
                    Children =
                    {
                        new Forms9Patch.Label("ModalPopup")
                        {
                            FontAttributes = FontAttributes.Bold
                        },
                        cancelModalButton
                    }
                }
            };

            cancelModalButton.Clicked += (sender, e) => modal.Cancel();
            showModalButton.Clicked   += (sender, e) => modal.IsVisible = true;

            var showBubbleButton   = new Forms9Patch.Button("BubblePopup");
            var cancelBubbleButton = new Forms9Patch.Button("CANCEL");
            var bubble             = new BubblePopup(showBubbleButton)
            {
                Content = new Xamarin.Forms.StackLayout
                {
                    Children =
                    {
                        new Forms9Patch.Label("BubblePopup")
                        {
                            FontAttributes = FontAttributes.Bold
                        },
                        cancelBubbleButton
                    }
                }
            };

            cancelBubbleButton.Clicked += (sender, e) => bubble.Cancel();
            showBubbleButton.Clicked   += (sender, e) => bubble.IsVisible = true;

            var showActivityButton = new Forms9Patch.Button("ActivityIndicatorPopup");

            showActivityButton.Clicked += (sender, e) =>
            {
                var activity = Forms9Patch.ActivityIndicatorPopup.Create();
                activity.CancelOnPageOverlayTouch = true;
            };

            var showPermissionButton = new Forms9Patch.Button("PermissionPopup");

            showPermissionButton.Clicked += (sender, e) =>
            {
                var permission = PermissionPopup.Create("PermissionPopup", "Do you agree?");
            };

            var showToastButton = new Forms9Patch.Button("Toast");

            showToastButton.Clicked += (sender, e) => Toast.Create("Toast", "... of the town!");

            var showTargetedToash = new Forms9Patch.Button("TargetedToast");

            showTargetedToash.Clicked += (sender, e) => TargetedToast.Create(showTargetedToash, "TargetedToast", "... has the far getted most!");

            Content = new Xamarin.Forms.StackLayout
            {
                Children = { showModalButton, showBubbleButton, showActivityButton, showPermissionButton, showToastButton, showTargetedToash }
            };
        }
Ejemplo n.º 45
0
        public MainListViewModel(Page _element, Xamarin.Forms.StackLayout spList, Xamarin.Forms.ControlTemplate ctControlTemplate)
        {
            this._element = _element;

            this._spList            = spList;
            this._ctControlTemplate = ctControlTemplate;

            // 菜单列表填充一下



            _addInnerBill = new MainListModel()
            {
                Name = "InnerBill", GoCommand = this.GoCommand
            };
            AddList(_addInnerBill);
            _addOuterBill = new MainListModel()
            {
                Name = "OuterBill", GoCommand = this.GoCommand
            };
            AddList(_addOuterBill);
            _importManager = new MainListModel()
            {
                Name = "ExpenditureManager", GoCommand = this.GoCommand
            };
            AddList(_importManager);
            _financeLog = new MainListModel()
            {
                Name = "FinanceLog", GoCommand = this.GoCommand
            };
            AddList(_financeLog);
            _openCashDrawer = new MainListModel()
            {
                Name = "OpenCashDrawer", GoCommand = this.GoCommand
            };
            AddList(_openCashDrawer);
            _balanceManager = new MainListModel()
            {
                Name = "BalanceManager", GoCommand = this.GoCommand
            };
            AddList(_balanceManager);
            _statistic = new MainListModel()
            {
                Name = "Statistic", GoCommand = this.GoCommand
            };
            AddList(_statistic);
            //AddList(new MainListModel() { Name = "ChangeLanguage", GoCommand = this.GoCommand });
            AddList(new MainListModel()
            {
                Name = "ChangePassword", GoCommand = this.GoCommand
            });
            AddList(new MainListModel()
            {
                Name = "About", GoCommand = this.GoCommand
            });
            AddList(new MainListModel()
            {
                Name = "Exit", GoCommand = this.GoCommand
            });


            Notification.Instance.NotificationLanguage += (obj, value, args) => { Device.BeginInvokeOnMainThread(() => { LoginRefresh(); }); };
            Notification.Instance.NotificationLogin    += (obj, value, args) => { Device.BeginInvokeOnMainThread(() => { LoginRefresh(); }); };

            // 设置语言
            LoginRefresh();



            foreach (var item in Res.Instance.AllLangList.OrderBy(x => x.Value.LangOrder))
            {
                Dict dict = new Dict()
                {
                    Name = Res.Instance.GetString("LangName", item.Value.Culture), Value = item.Value.LangIndex
                };
                AllLang.Add(dict);
            }
        }
Ejemplo n.º 46
0
        void SetContent()
        {
            View content = null;

            if (_layoutTypeControl.SelectedSegments[0].Text == "StackLayout")
            {
                _grid?.Children.Clear();
                if (_stack == null)
                {
                    _stack = new Xamarin.Forms.StackLayout
                    {
                        BackgroundColor = Color.LightBlue,
                        Padding         = 0,
                        Margin          = 0,
                        Spacing         = 10,
                    };
                    var stackListener = FormsGestures.Listener.For(_stack);
                    SetupTouchEvents(stackListener);
                }
                _stack.Children.Add(_boxView);
                _stack.Children.Add(_slider);
                _stack.Children.Add(new Xamarin.Forms.StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    Children    =
                    {
                        new Xamarin.Forms.Label {
                            Text = "Content in ScrollView"
                        },
                        _inScrollViewSwitch,
                    }
                });
                _stack.Children.Add(new Xamarin.Forms.StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    Children    =
                    {
                        new Xamarin.Forms.Label {
                            Text = "Long Press Enabled"
                        },
                        _longPressEnabledSwitch,
                    }
                });
                _stack.Children.Add(new Xamarin.Forms.StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    Children    =
                    {
                        new Xamarin.Forms.Label {
                            Text = "Dark Background"
                        },
                        _darkBackgroundSwitch,
                    }
                });
                _stack.Children.Add(new Xamarin.Forms.StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    Children    =
                    {
                        new Xamarin.Forms.Label {
                            Text = "Page Padding"
                        },
                        _pagePadding,
                    }
                });
                _stack.Children.Add(_f9pButton);
                _stack.Children.Add(_xfButton);
                _stack.Children.Add(_layoutTypeControl);
                _stack.Children.Add(_touchType1);
                _stack.Children.Add(_touchType2);

                content = _stack;
            }
            else
            {
                _stack?.Children.Clear();
                if (_grid == null)
                {
                    _grid = new Xamarin.Forms.Grid
                    {
                        BackgroundColor = Color.LightGreen,
                        RowDefinitions  = new RowDefinitionCollection
                        {
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                        },
                        ColumnDefinitions = new ColumnDefinitionCollection
                        {
                            new ColumnDefinition {
                                Width = new GridLength(2, GridUnitType.Star)
                            },
                            new ColumnDefinition {
                                Width = GridLength.Star
                            }
                        }
                    };
                    var gridListener = FormsGestures.Listener.For(_grid);
                    SetupTouchEvents(gridListener);
                }
                int row = 0;
                _grid.Children.Add(_boxView, 0, 2, row, ++row);
                _grid.Children.Add(_slider, 0, 2, row, ++row);
                _grid.Children.Add(new Xamarin.Forms.Label {
                    Text = "Content in ScrollView"
                }, 0, 1, row, row + 1);
                _grid.Children.Add(_inScrollViewSwitch, 1, 2, row, ++row);
                _grid.Children.Add(new Xamarin.Forms.Label {
                    Text = "Long Press Enabled"
                }, 0, 1, row, row + 1);
                _grid.Children.Add(_longPressEnabledSwitch, 1, 2, row, ++row);
                _grid.Children.Add(new Xamarin.Forms.Label {
                    Text = "Dark Background"
                }, 0, 1, row, row + 1);
                _grid.Children.Add(_darkBackgroundSwitch, 1, 2, row, ++row);
                _grid.Children.Add(new Xamarin.Forms.Label {
                    Text = "Page Padding"
                }, 0, 1, row, row + 1);
                _grid.Children.Add(_pagePadding, 1, 2, row, ++row);
                _grid.Children.Add(_f9pButton, 0, 2, row, ++row);
                _grid.Children.Add(_xfButton, 0, 2, row, ++row);
                _grid.Children.Add(_layoutTypeControl, 0, 2, row, ++row);
                _grid.Children.Add(_touchType1, 0, 2, row, ++row);
                _grid.Children.Add(_touchType2, 0, 2, row, ++row);
                content = _grid;
            }
            if (_inScrollViewSwitch.IsToggled)
            {
                scrollView.Content = content;
            }
            else
            {
                Content = content;
            }
        }
        public CSharpAbsoluteLayout()
        {
            InitializeComponent();

            var absoluteLayout = new Xamarin.Forms.AbsoluteLayout();

            //LayoutBounds X,Y,Width,Height 为比例(最大1)
            var stackLayout_1 = new Xamarin.Forms.StackLayout();

            stackLayout_1.BackgroundColor = Color.FromHex("#f9d33c");
            stackLayout_1.Children.Add(new Label()
            {
                Text = "0,0,0.3,0.1,All"
            });
            Xamarin.Forms.AbsoluteLayout.SetLayoutBounds(stackLayout_1, new Rectangle(0, 0, 0.3, 0.1));
            Xamarin.Forms.AbsoluteLayout.SetLayoutFlags(stackLayout_1, AbsoluteLayoutFlags.All);
            absoluteLayout.Children.Add(stackLayout_1);

            //LayoutBounds X,Y,Width,Height 为绝对值
            var stackLayout_2 = new Xamarin.Forms.StackLayout();

            stackLayout_2.BackgroundColor = Color.FromHex("#f9d33c");
            stackLayout_2.Children.Add(new Label()
            {
                Text = "100,100,150,25,None"
            });
            Xamarin.Forms.AbsoluteLayout.SetLayoutBounds(stackLayout_2, new Rectangle(100, 100, 150, 25));
            Xamarin.Forms.AbsoluteLayout.SetLayoutFlags(stackLayout_2, AbsoluteLayoutFlags.None);
            absoluteLayout.Children.Add(stackLayout_2);

            //LayoutBounds Width 为比例,X,Y,Height 为绝对值
            var stackLayout_3 = new Xamarin.Forms.StackLayout();

            stackLayout_3.BackgroundColor = Color.FromHex("#f9d33c");
            stackLayout_3.Children.Add(new Label()
            {
                Text = "100,130,0.7,30,WidthProportional"
            });
            Xamarin.Forms.AbsoluteLayout.SetLayoutBounds(stackLayout_3, new Rectangle(100, 130, 0.7, 30));
            Xamarin.Forms.AbsoluteLayout.SetLayoutFlags(stackLayout_3, AbsoluteLayoutFlags.WidthProportional);
            absoluteLayout.Children.Add(stackLayout_3);

            //LayoutBounds Height为比例,X,Y,Width 为绝对值
            var stackLayout_4 = new Xamarin.Forms.StackLayout();

            stackLayout_4.BackgroundColor = Color.FromHex("#f9d33c");
            stackLayout_4.Children.Add(new Label()
            {
                Text = "20,180,260,0.05,HeightProportional"
            });
            Xamarin.Forms.AbsoluteLayout.SetLayoutBounds(stackLayout_4, new Rectangle(20, 180, 260, 0.05));
            Xamarin.Forms.AbsoluteLayout.SetLayoutFlags(stackLayout_4, AbsoluteLayoutFlags.HeightProportional);
            absoluteLayout.Children.Add(stackLayout_4);

            //LayoutBounds X 为比例,Y,Width,Height 为绝对值
            var stackLayout_5 = new Xamarin.Forms.StackLayout();

            stackLayout_5.BackgroundColor = Color.FromHex("#f9d33c");
            stackLayout_5.Children.Add(new Label()
            {
                Text = "0.6,250,330,30,XProportional"
            });
            Xamarin.Forms.AbsoluteLayout.SetLayoutBounds(stackLayout_5, new Rectangle(0.6, 250, 330, 30));
            Xamarin.Forms.AbsoluteLayout.SetLayoutFlags(stackLayout_5, AbsoluteLayoutFlags.XProportional);
            absoluteLayout.Children.Add(stackLayout_5);

            //LayoutBounds Y 为比例,X,Width,Height 为绝对值
            var stackLayout_6 = new Xamarin.Forms.StackLayout();

            stackLayout_6.BackgroundColor = Color.FromHex("#f9d33c");
            stackLayout_6.Children.Add(new Label()
            {
                Text = "0,0.45,260,30,YProportional"
            });
            Xamarin.Forms.AbsoluteLayout.SetLayoutBounds(stackLayout_6, new Rectangle(0, 0.45, 260, 30));
            Xamarin.Forms.AbsoluteLayout.SetLayoutFlags(stackLayout_6, AbsoluteLayoutFlags.YProportional);
            absoluteLayout.Children.Add(stackLayout_6);

            //LayoutBounds X,Y 为比例,Width,Height 为绝对值
            var stackLayout_7 = new Xamarin.Forms.StackLayout();

            stackLayout_7.BackgroundColor = Color.FromHex("#f9d33c");
            stackLayout_7.Children.Add(new Label()
            {
                Text = "0.01,0.5,260,30,PositionProportional"
            });
            Xamarin.Forms.AbsoluteLayout.SetLayoutBounds(stackLayout_7, new Rectangle(0.01, 0.5, 260, 30));
            Xamarin.Forms.AbsoluteLayout.SetLayoutFlags(stackLayout_7, AbsoluteLayoutFlags.PositionProportional);
            absoluteLayout.Children.Add(stackLayout_7);

            //LayoutBounds Width,Height 为比例,X,Y 为绝对值
            var stackLayout_8 = new Xamarin.Forms.StackLayout();

            stackLayout_8.BackgroundColor = Color.FromHex("#f9d33c");
            stackLayout_8.Children.Add(new Label()
            {
                Text = "10,400,0.5,0.05,SizeProportional"
            });
            Xamarin.Forms.AbsoluteLayout.SetLayoutBounds(stackLayout_8, new Rectangle(10, 400, 0.5, 0.05));
            Xamarin.Forms.AbsoluteLayout.SetLayoutFlags(stackLayout_8, AbsoluteLayoutFlags.SizeProportional);
            absoluteLayout.Children.Add(stackLayout_8);

            //AbsoluteLayout可以重叠,先Render的被后Render的元素覆盖
            var stackLayout_9 = new Xamarin.Forms.StackLayout();

            stackLayout_9.BackgroundColor = Color.Red;
            stackLayout_9.Children.Add(new Label()
            {
                Text = "AbsoluteLayout可以重叠"
            });
            Xamarin.Forms.AbsoluteLayout.SetLayoutBounds(stackLayout_9, new Rectangle(10, 450, 0.5, 0.05));
            Xamarin.Forms.AbsoluteLayout.SetLayoutFlags(stackLayout_9, AbsoluteLayoutFlags.SizeProportional);
            absoluteLayout.Children.Add(stackLayout_9);

            var stackLayout_10 = new Xamarin.Forms.StackLayout();

            stackLayout_10.BackgroundColor = Color.Blue;
            stackLayout_10.Children.Add(new Label()
            {
                Text = "AbsoluteLayout可以重叠"
            });
            Xamarin.Forms.AbsoluteLayout.SetLayoutBounds(stackLayout_10, new Rectangle(10, 460, 0.5, 0.05));
            Xamarin.Forms.AbsoluteLayout.SetLayoutFlags(stackLayout_10, AbsoluteLayoutFlags.SizeProportional);
            absoluteLayout.Children.Add(stackLayout_10);

            Content = absoluteLayout;
        }
Ejemplo n.º 48
0
        public EmbeddedResourceFontEffectPage()
        {
            Forms9Patch.EmbeddedResourceFontEffect.ApplyTo(_label);
            _editor.Effects.Add(new Forms9Patch.EmbeddedResourceFontEffect());
            _entry.Effects.Add(new Forms9Patch.EmbeddedResourceFontEffect());

            Forms9Patch.SegmentedControl segmentedControl = new SegmentedControl
            {
                Margin     = new Thickness(10, 0),
                FontFamily = "Forms9PatchDemo.Resources.Fonts.Pacifico.ttf",
                Segments   =
                {
                    new Forms9Patch.Segment("label"),
                    new Forms9Patch.Segment("editor"),
                    new Forms9Patch.Segment("entry"),
                }
            };

            Content = new Xamarin.Forms.StackLayout
            {
                Children =
                {
                    _label,
                    _editor,
                    _entry,
                    new Xamarin.Forms.Label {
                        Text = "Focus:"
                    },
                    segmentedControl
                }
            };

            segmentedControl.SegmentTapped += (sender, e) =>
            {
                switch (e.Segment.Text)
                {
                case "label": _label.HardwareKeyFocus(); break;

                case "editor": _editor.HardwareKeyFocus(); break;

                case "entry": _entry.HardwareKeyFocus(); break;
                }
            };

            HardwareKeyPage.FocusedElementChanged += (sender, e) =>
            {
                if (sender == _label)
                {
                    segmentedControl.SelectIndex(0);
                }
                else if (sender == _editor)
                {
                    segmentedControl.SelectIndex(1);
                }
                else if (sender == _entry)
                {
                    segmentedControl.SelectIndex(2);
                }
                else
                {
                    segmentedControl.DeselectAll();
                }
            };

            _label.Focused  += (sender, e) => System.Diagnostics.Debug.WriteLine("label.Focused " + e.IsFocused);
            _editor.Focused += (sender, e) => System.Diagnostics.Debug.WriteLine("editor.Focused " + e.IsFocused);
            _entry.Focused  += (sender, e) => System.Diagnostics.Debug.WriteLine("entry.Focused " + e.IsFocused);

            _label.Unfocused  += (sender, e) => System.Diagnostics.Debug.WriteLine("label.Unfocused " + e.IsFocused);
            _editor.Unfocused += (sender, e) => System.Diagnostics.Debug.WriteLine("editor.Unfocused " + e.IsFocused);
            _entry.Unfocused  += (sender, e) => System.Diagnostics.Debug.WriteLine("entry.Unfocused " + e.IsFocused);

            _label.FocusChangeRequested  += (object sender, FocusRequestArgs e) => System.Diagnostics.Debug.WriteLine("label.FocusChangeRequested ");
            _editor.FocusChangeRequested += (object sender, FocusRequestArgs e) => System.Diagnostics.Debug.WriteLine("editor.FocusChangeRequested ");
            _entry.FocusChangeRequested  += (object sender, FocusRequestArgs e) => System.Diagnostics.Debug.WriteLine("entry.FocusChangeRequested ");

            this.AddHardwareKeyListener("ç", OnHardwareKeyPressed);
            this.AddHardwareKeyListener("é", OnHardwareKeyPressed);
            this.AddHardwareKeyListener("ф", OnHardwareKeyPressed);

            this.AddHardwareKeyListener("A", OnHardwareKeyPressed);
            this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.PlatformKey, OnHardwareKeyPressed);
            this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.Control, OnHardwareKeyPressed);
            this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.Alternate, OnHardwareKeyPressed);
            this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.CapsLock, OnHardwareKeyPressed);
            this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.FunctionKey, OnHardwareKeyPressed);
            this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.Shift, OnHardwareKeyPressed);
            this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.Shift | HardwareKeyModifierKeys.Alternate, OnHardwareKeyPressed);
            this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.Shift | HardwareKeyModifierKeys.Control, OnHardwareKeyPressed);
            this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.Shift | HardwareKeyModifierKeys.PlatformKey, OnHardwareKeyPressed);
            this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.Control | HardwareKeyModifierKeys.Alternate, OnHardwareKeyPressed);
            this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.Control | HardwareKeyModifierKeys.PlatformKey, OnHardwareKeyPressed);


            this.AddHardwareKeyListener("5", OnHardwareKeyPressed);
            this.AddHardwareKeyListener("5", HardwareKeyModifierKeys.NumericPadKey, OnHardwareKeyPressed);
            this.AddHardwareKeyListener("5", HardwareKeyModifierKeys.PlatformKey, OnHardwareKeyPressed);
            this.AddHardwareKeyListener("5", HardwareKeyModifierKeys.Control, OnHardwareKeyPressed);
            this.AddHardwareKeyListener("5", HardwareKeyModifierKeys.Alternate, OnHardwareKeyPressed);
            this.AddHardwareKeyListener("5", HardwareKeyModifierKeys.CapsLock, OnHardwareKeyPressed);
            this.AddHardwareKeyListener("5", HardwareKeyModifierKeys.FunctionKey, OnHardwareKeyPressed);
            this.AddHardwareKeyListener("5", HardwareKeyModifierKeys.Shift, OnHardwareKeyPressed);



            this.AddHardwareKeyListener("/", OnHardwareKeyPressed);
            this.AddHardwareKeyListener("/", HardwareKeyModifierKeys.Alternate, OnHardwareKeyPressed);

            this.AddHardwareKeyListener(HardwareKey.UpArrowKeyInput, OnHardwareKeyPressed);
            this.AddHardwareKeyListener(HardwareKey.DownArrowKeyInput, OnHardwareKeyPressed);
            this.AddHardwareKeyListener(HardwareKey.LeftArrowKeyInput, OnHardwareKeyPressed);
            this.AddHardwareKeyListener(HardwareKey.RightArrowKeyInput, OnHardwareKeyPressed);
            this.AddHardwareKeyListener(HardwareKey.EscapeKeyInput, OnHardwareKeyPressed);
            this.AddHardwareKeyListener(HardwareKey.BackspaceDeleteKeyInput, OnHardwareKeyPressed);
            this.AddHardwareKeyListener(HardwareKey.ForwardDeleteKeyInput, OnHardwareKeyPressed);
            this.AddHardwareKeyListener(HardwareKey.InsertKeyInput, OnHardwareKeyPressed);
            this.AddHardwareKeyListener(HardwareKey.TabKeyInput, OnHardwareKeyPressed);
            this.AddHardwareKeyListener(HardwareKey.EnterReturnKeyInput, OnHardwareKeyPressed);
            this.AddHardwareKeyListener(HardwareKey.PageUpKeyInput, OnHardwareKeyPressed);
            this.AddHardwareKeyListener(HardwareKey.PageDownKeyInput, OnHardwareKeyPressed);
            this.AddHardwareKeyListener(HardwareKey.HomeKeyInput, OnHardwareKeyPressed);
            this.AddHardwareKeyListener(HardwareKey.EndKeyInput, OnHardwareKeyPressed);

            _entry.AddHardwareKeyListener(HardwareKey.UpArrowKeyInput, OnHardwareKeyPressed);
            _entry.AddHardwareKeyListener(HardwareKey.DownArrowKeyInput, OnHardwareKeyPressed);
            _entry.AddHardwareKeyListener(HardwareKey.LeftArrowKeyInput, OnHardwareKeyPressed);
            _entry.AddHardwareKeyListener(HardwareKey.RightArrowKeyInput, OnHardwareKeyPressed);
            _entry.AddHardwareKeyListener(HardwareKey.EscapeKeyInput, OnHardwareKeyPressed);

            _editor.AddHardwareKeyListener(HardwareKey.UpArrowKeyInput, OnHardwareKeyPressed);
            _editor.AddHardwareKeyListener(HardwareKey.DownArrowKeyInput, OnHardwareKeyPressed);
            _editor.AddHardwareKeyListener(HardwareKey.LeftArrowKeyInput, OnHardwareKeyPressed);
            _editor.AddHardwareKeyListener(HardwareKey.RightArrowKeyInput, OnHardwareKeyPressed);
            _editor.AddHardwareKeyListener(HardwareKey.EscapeKeyInput, OnHardwareKeyPressed);

            _label.AddHardwareKeyListener(HardwareKey.UpArrowKeyInput, OnHardwareKeyPressed);
            _label.AddHardwareKeyListener(HardwareKey.DownArrowKeyInput, OnHardwareKeyPressed);
            _label.AddHardwareKeyListener(HardwareKey.LeftArrowKeyInput, OnHardwareKeyPressed);
            _label.AddHardwareKeyListener(HardwareKey.RightArrowKeyInput, OnHardwareKeyPressed);
            _label.AddHardwareKeyListener(HardwareKey.EscapeKeyInput, OnHardwareKeyPressed);
        }
        public StackLayoutHandler(NativeComponentRenderer renderer, XF.StackLayout stackLayoutControl) : base(renderer, stackLayoutControl)
        {
            StackLayoutControl = stackLayoutControl ?? throw new ArgumentNullException(nameof(stackLayoutControl));

            Initialize(renderer);
        }
Ejemplo n.º 50
0
        public SimpleLabelFitting()
        {
            Title           = "Simple Label Fitting";
            Padding         = new Thickness(0, 60, 0, 0);
            BackgroundColor = "#252525".ToColor();
            Content         = new Xamarin.Forms.StackLayout
            {
                Padding         = 10,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children        =
                {
                    /*
                     * new Forms9Patch.Label
                     * {
                     *  Text = "Lines=0",
                     *  Margin = new Thickness(20,0,20,0),
                     *  FontSize = 60,
                     *  FontAttributes = FontAttributes.Bold,
                     *  HorizontalTextAlignment = TextAlignment.Start,
                     *  TextColor = Color.Red,
                     *  VerticalTextAlignment = TextAlignment.Center,
                     *  HorizontalOptions = LayoutOptions.Fill,
                     *  Lines=0,
                     *  BackgroundColor = Color.Beige,
                     *
                     * },
                     */
                    new Forms9Patch.Label
                    {
                        Text                    = "AutoFit.Width, Lines=0",
                        Margin                  = new Thickness(20, 0, 20, 0),
                        FontSize                = 60,
                        FontAttributes          = FontAttributes.Bold,
                        HorizontalTextAlignment = TextAlignment.Start,
                        TextColor               = Color.Red,
                        VerticalTextAlignment   = TextAlignment.Center,
                        HorizontalOptions       = LayoutOptions.Fill,
                        Lines                   = 0,
                        AutoFit                 = AutoFit.Width,
                        BackgroundColor         = Color.Beige,
                    },

                    /*
                     * new Forms9Patch.Label
                     * {
                     *  Text = "AutoFit.Width, Lines=1",
                     *  Margin = new Thickness(20,0,20,0),
                     *  FontSize = 60,
                     *  Lines=1,
                     *  FontAttributes = FontAttributes.Bold,
                     *  HorizontalTextAlignment = TextAlignment.Start,
                     *  TextColor = Color.Red,
                     *  VerticalTextAlignment = TextAlignment.Center,
                     *  HorizontalOptions = LayoutOptions.Fill,
                     *  AutoFit=AutoFit.Width,
                     *  BackgroundColor = Color.Beige,
                     * },
                     * new Forms9Patch.Frame
                     * {
                     *  Padding = 2,
                     *  OutlineColor = Color.DarkGray,
                     *  OutlineRadius = 3,
                     *  OutlineWidth = 1,
                     *  HeightRequest = 50,
                     *  Content = new Forms9Patch.Label
                     *  {
                     *      Text = "Lines=0",
                     *      Margin = new Thickness(20,0,20,0),
                     *      FontSize = 60,
                     *      FontAttributes = FontAttributes.Bold,
                     *  HorizontalTextAlignment = TextAlignment.Start,
                     *  TextColor = Color.Red,
                     *  VerticalTextAlignment = TextAlignment.Center,
                     *  HorizontalOptions = LayoutOptions.Fill,
                     *      Lines=0,
                     *      BackgroundColor = Color.Beige,
                     *  }
                     * },
                     * new Forms9Patch.Frame
                     * {
                     *  Padding = 2,
                     *  OutlineColor = Color.DarkGray,
                     *  OutlineRadius = 3,
                     *  OutlineWidth = 1,
                     *  HeightRequest = 50,
                     *  Content = new Forms9Patch.Label
                     *  {
                     *      Text = "AutoFit.Width, Lines=1",
                     *      Margin = new Thickness(20,0,20,0),
                     *      FontSize = 60,
                     *      FontAttributes = FontAttributes.Bold,
                     *  HorizontalTextAlignment = TextAlignment.Start,
                     *  TextColor = Color.Red,
                     *  VerticalTextAlignment = TextAlignment.Center,
                     *  HorizontalOptions = LayoutOptions.Fill,
                     *      Lines=1,
                     *      AutoFit=AutoFit.Width,
                     *      BackgroundColor = Color.Beige,
                     *  },
                     * },
                     * new Forms9Patch.Frame
                     * {
                     *  Padding = 2,
                     *  OutlineColor = Color.DarkGray,
                     *  OutlineRadius = 3,
                     *  OutlineWidth = 1,
                     *  HeightRequest = 50,
                     *  Content = new Forms9Patch.Label
                     *  {
                     *      Text = "AutoFit.Lines, Lines=1",
                     *      Margin = new Thickness(20,0,20,0),
                     *      FontSize = 60,
                     *      FontAttributes = FontAttributes.Bold,
                     *  HorizontalTextAlignment = TextAlignment.Start,
                     *  TextColor = Color.Red,
                     *  VerticalTextAlignment = TextAlignment.Center,
                     *  HorizontalOptions = LayoutOptions.Fill,
                     *      Lines=1,
                     *      AutoFit=AutoFit.Lines,
                     *      BackgroundColor = Color.Beige,
                     *  }
                     * },
                     */
                }
            };
        }