Beispiel #1
1
        /// <summary>
        /// Creates a new menu form.
        /// </summary>
        /// <param name="title">Window title.</param>
        /// <param name="itemNames">Item names.</param>
        /// <param name="actions">Actions.</param>
        public MenuForm(string title, string[] itemNames, Action[] actions)
        {
            Title = title;
            SelectedIndex = -1;

            if (itemNames == null || actions == null)
                return;
            if (itemNames.Length != actions.Length)
                return;

            var stackLayout = new StackLayout {Orientation = Orientation.Vertical, HorizontalContentAlignment = HorizontalAlignment.Stretch };

            for (int i = 0; i < itemNames.Length; i++)
            {
                var idx = i;

                var button = new Button { Text = itemNames[idx], Size = new Size(240, 60) }; 
                button.Click += (s, e) =>
                {
                    actions[idx]();
                    SelectedIndex = idx;
                    this.Close();
                };

                stackLayout.Items.Add(new StackLayoutItem(button, true));
            }

            Content = stackLayout;
            Size = new Size(-1, -1);
        }
		public void GetsCorrectSizeRequestWithWrappingContent (ScrollOrientation orientation)
		{
			var scrollView = new ScrollView {
				IsPlatformEnabled = true,
				Orientation = orientation,
				Platform = new UnitPlatform (null, true)
			};

			var hLayout = new StackLayout {
				IsPlatformEnabled = true,
				Orientation = StackOrientation.Horizontal,
				Children = {
					new Label {Text = "THIS IS A REALLY LONG STRING", IsPlatformEnabled = true},
					new Label {Text = "THIS IS A REALLY LONG STRING", IsPlatformEnabled = true},
					new Label {Text = "THIS IS A REALLY LONG STRING", IsPlatformEnabled = true},
					new Label {Text = "THIS IS A REALLY LONG STRING", IsPlatformEnabled = true},
					new Label {Text = "THIS IS A REALLY LONG STRING", IsPlatformEnabled = true},
				}
			};

			scrollView.Content = hLayout;

			var r = scrollView.GetSizeRequest (100, 100);

			Assert.AreEqual (10, r.Request.Height);
		}
Beispiel #3
0
        protected override void Init ()
        {
            var picker = new Picker () { Items = {"Leonardo", "Donatello", "Raphael", "Michaelangelo" } };
            var label = new Label () {Text = "This test is successful if the picker below spans the width of the screen. If the picker is just a sliver on the left edge of the screen, this test has failed." };

            Content = new StackLayout () { Children = {label, picker}};
        }
Beispiel #4
0
		public PreviewEditorView(Control editor, Func<string> getCode)
		{
			Editor = editor;
			this.getCode = getCode;

			Orientation = Orientation.Vertical;
			FixedPanel = SplitterFixedPanel.None;
			RelativePosition = 0.4;

			previewPanel = new Panel();
			errorPanel = new Panel { Padding = new Padding(5), Visible = false, BackgroundColor = new Color(Colors.Red, .4f) };

			Panel1 = new StackLayout
			{
				HorizontalContentAlignment = HorizontalAlignment.Stretch,
				Items =
				{
					new StackLayoutItem(previewPanel, expand: true),
					errorPanel
				}
			};
			Panel2 = editor;

			timer = new UITimer { Interval = RefreshTime };
			timer.Elapsed += Timer_Elapsed;
		}
Beispiel #5
0
		protected override void Init ()
		{
			var generatedImage = new Image { Aspect = Aspect.AspectFit };

			var btn = new Button { Text="generate" };

			btn.Clicked += (sender, e) => {
				var source =  GenerateBmp (60, 60, Color.Red);
				generatedImage.Source = source;

			};

			Content = new StackLayout {
				Children = {
						btn,
#pragma warning disable 618
                    new Label {Text = "GeneratedImage", Font=Font.BoldSystemFontOfSize(NamedSize.Medium)},
#pragma warning restore 618
                    generatedImage
                },
				Padding = new Thickness (0, 20, 0, 0),
				VerticalOptions = LayoutOptions.StartAndExpand,
				HorizontalOptions = LayoutOptions.CenterAndExpand
			};
		}
Beispiel #6
0
		protected override void Init ()
		{
			var instructions = new Label {
				Text =
					"The label in the red box below should be centered horizontally and vertically. If it's not, this test has failed."
			};


			var label = new Label {
				BackgroundColor = Color.Red,
				TextColor = Color.White,
				HorizontalTextAlignment = TextAlignment.Center,
				VerticalTextAlignment = TextAlignment.Center,
				HeightRequest = 200,
				HorizontalOptions = LayoutOptions.Fill,
				Text = "Should be centered horizontally and vertically"
			};


			Content = new StackLayout {
				HorizontalOptions = LayoutOptions.Fill,
				VerticalOptions = LayoutOptions.Fill,
				Children = {
					instructions,
					label
				}
			};
		}
		protected override void Init()
		{
			var stack = new StackLayout();

			map1 = new Maps.Map
			{
				IsShowingUser = false,
				WidthRequest = 320,
				HeightRequest = 200
			};

			map2 = new Maps.Map
			{
				IsShowingUser = false,
				WidthRequest = 320,
				HeightRequest = 200
			};


			var btn = new Button { Text = "Show" };
			btn.Clicked += (sender, e) =>
			{
				map2.IsVisible = !map2.IsVisible;
			};

			stack.Children.Add(map1);
			stack.Children.Add(map2);
			stack.Children.Add(btn);
			DisplayMaps();
			Content = stack;
		}
Beispiel #8
0
		public ComplexListView()
		{
			Performance.Clear();

			var showPerf = new Button { Text = "Performance" };
			showPerf.Clicked += (sender, args) => {
				Performance.DumpStats();
				Performance.Clear();
			};

			Content = new StackLayout {
				Orientation = StackOrientation.Vertical,
				Children = {
					showPerf,
					new ListView {
						ItemTemplate = new DataTemplate (typeof (ComplexViewCell)),
						ItemsSource =
							new[] {
								"a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c", "a",
								"b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c"
							}
					}
				}
			};
		}
Beispiel #9
0
		protected override void Init ()
		{
			Label header = new Label {
				Text = "Search Bar",
				FontAttributes = FontAttributes.Bold,
				FontSize = 50,
				HorizontalOptions = LayoutOptions.Center
			};

			SearchBar searchBar = new SearchBar {
				Placeholder = "Enter anything",
				CancelButtonColor = Color.Red
			};

			Label reproSteps = new Label {
				Text =
					"Tap on the search bar and enter some text. The 'Cancel' button should appear. If the 'Cancel' button is not red, this is broken.",
				HorizontalOptions = LayoutOptions.Center
			};

			Content = new StackLayout {
				Children = {
					header,
					searchBar,
					reproSteps
				}
			};
		}
Beispiel #10
0
		public void RemoveItemsIndividuallyShouldClearParent()
		{
			TestUtils.Invoke(() =>
			{
				var stackLayout = new StackLayout();

				var items = new Control[] { new Label(), new Button(), new TextBox() };

				foreach (var item in items)
					stackLayout.Items.Add(item);

				CollectionAssert.AreEqual(items, stackLayout.Children, "#1. Items do not match");

				foreach (var item in items)
					Assert.AreEqual(stackLayout, item.Parent, "#2. Items should have parent set to stack layout");

				stackLayout.Items.RemoveAt(0);
				Assert.IsNull(items[0].Parent, "#3. Item should have parent cleared when removed from stack layout");

				stackLayout.Items[0] = new Button();
				Assert.IsNull(items[1].Parent, "#4. Item should have parent cleared when replaced with another item in the stack layout");

				Assert.AreEqual(stackLayout, items[2].Parent, "#5. Item should not have changed parent as it is still in the stack layout");
			});
		}
Beispiel #11
0
		protected override void Init ()
		{
			var layout = new StackLayout ();
			var button = new Button { Text = "Click" };
			var tablesection = new TableSection { Title = "Switches" };
			var tableview = new TableView { Intent = TableIntent.Form, Root = new TableRoot { tablesection } };
			var viewcell1 = new ViewCell {
				View = new StackLayout {
					HorizontalOptions = LayoutOptions.FillAndExpand,
					Orientation = StackOrientation.Horizontal,
					Children = {
						new Label { Text = "Switch 1", HorizontalOptions = LayoutOptions.StartAndExpand },
						new Switch { AutomationId = "switch1", HorizontalOptions = LayoutOptions.End, IsToggled = true }
					}
				}
			};
			var viewcell2 = new ViewCell {
				View = new StackLayout {
					HorizontalOptions = LayoutOptions.FillAndExpand,
					Orientation = StackOrientation.Horizontal,
					Children = {
						new Label { Text = "Switch 2", HorizontalOptions = LayoutOptions.StartAndExpand },
						new Switch { AutomationId = "switch2", HorizontalOptions = LayoutOptions.End, IsToggled = true }
					}
				}
			};
			Label label = new Label { Text = "Switch 3", HorizontalOptions = LayoutOptions.StartAndExpand };
			Switch switchie = new Switch { AutomationId = "switch3", HorizontalOptions = LayoutOptions.End, IsToggled = true, IsEnabled = false };
			switchie.Toggled += (sender, e) => {
				label.Text = "FAIL";
			};
			var viewcell3 = new ViewCell {
				View = new StackLayout {
					HorizontalOptions = LayoutOptions.FillAndExpand,
					Orientation = StackOrientation.Horizontal,
					Children = {
						label,
						switchie,
					}
				}
			};

			tablesection.Add (viewcell1);
			tablesection.Add (viewcell2);
			tablesection.Add (viewcell3);

			button.Clicked += (sender, e) => {
				if (_removed)
					tablesection.Insert (1, viewcell2);
				else
					tablesection.Remove (viewcell2);

				_removed = !_removed;
			};

			layout.Children.Add (button);
			layout.Children.Add (tableview);

			Content = layout;
		}
Beispiel #12
0
        protected override void Init()
        {
            var label = new Label { Text = "Label" };
            var entry = new Entry { AutomationId = "entry" };
            var grid = new Grid();

            grid.Children.Add(label, 0, 0);
            grid.Children.Add(entry, 1, 0);
            var tableView = new TableView
            {
                Root = new TableRoot
                {
                    new TableSection
                    {
                        new ViewCell
                        {
                            View = grid
                        }
                    }
                }
            };

            Content = new StackLayout
            {
                Children = { tableView }
            };
        }
		protected override void Init ()
		{
			var entry = new Entry {
				Text = "Setec Astronomy",
				FontFamily = "Comic Sans MS",
				HorizontalTextAlignment = TextAlignment.Center,
				Keyboard = Keyboard.Chat
			};

			var label = new Label ();
			var binding = new Binding ("Text") { Source = entry };

			var otherEntry = new Entry ();
			var otherBinding = new Binding ("Text") { Source = entry, Mode = BindingMode.TwoWay };
			otherEntry.SetBinding (Entry.TextProperty, otherBinding);

			label.SetBinding (Label.TextProperty, binding);

			var explanation = new Label() {Text = @"The Text value of the entry at the top should appear in the label and entry below, regardless of whether 'IsPassword' is on. 
Changes to the value in the entry below should be reflected in the entry at the top."};

			var button = new Button { Text = "Toggle IsPassword" };
			button.Clicked += (sender, args) => { entry.IsPassword = !entry.IsPassword; };

			Content = new StackLayout {
				Children = { entry, button, explanation, label, otherEntry }
			};
		}
Beispiel #14
0
		public Issue1875()
		{
			Button loadData = new Button { Text = "Load", HorizontalOptions = LayoutOptions.FillAndExpand };
			ListView mainList = new ListView {
				VerticalOptions = LayoutOptions.FillAndExpand,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};

			mainList.SetBinding (ListView.ItemsSourceProperty, "Items");

			_viewModel = new MainViewModel ();
			BindingContext = _viewModel;
			loadData.Clicked += async (sender, e) => {
				await LoadData ();
			};

			mainList.ItemAppearing += OnItemAppearing;

			Content = new StackLayout {
				Children = {
					loadData,
					mainList
				}
			};
		}
		public StackLayoutGallery ()
		{
			Device.OnPlatform (iOS: () => {
				if (Device.Idiom == TargetIdiom.Tablet) {
					Padding = new Thickness (0, 0, 0, 60);
				}
			});

			var stack = new StackLayout { Orientation = StackOrientation.Vertical };
			Button b1 = new Button { Text = "Boring", HeightRequest = 500, MinimumHeightRequest = 50 };
			Button b2 = new Button {
				Text = "Exciting!",
				VerticalOptions = LayoutOptions.FillAndExpand,
				HorizontalOptions = LayoutOptions.CenterAndExpand
			};
			Button b3 = new Button { Text = "Amazing!", VerticalOptions = LayoutOptions.FillAndExpand };
			Button b4 = new Button { Text = "Meh", HeightRequest = 400, MinimumHeightRequest = 50 };
			b1.Clicked += (sender, e) => {
				b1.Text = "clicked1";
			};
			b2.Clicked += (sender, e) => {
				b2.Text = "clicked2";
			};
			b3.Clicked += (sender, e) => {
				b3.Text = "clicked3";
			};
			b4.Clicked += (sender, e) => {
				b4.Text = "clicked4";
			};
			stack.Children.Add (b1);
			stack.Children.Add (b2);
			stack.Children.Add (b3);
			stack.Children.Add (b4);
			Content = stack;
		}
Beispiel #16
0
			public ChildPage(int pageNumber)
			{
				var layout = new StackLayout();
				var MyLabel = new Label {
					VerticalOptions = LayoutOptions.Center,
					HorizontalOptions = LayoutOptions.Center,
					FontSize = 21,
					TextColor = Color.White,
					Text = $"This is page {pageNumber}"
				};
				var TestBtn = new Button {
					Text = "Go to Page 2",
					IsEnabled = false,
					BackgroundColor = Color.White
				};

				if (pageNumber != 2)
				{
					TestBtn.IsEnabled = true;
					TestBtn.Clicked += TestBtn_Clicked;
				}

				layout.Children.Add(MyLabel);
				layout.Children.Add(TestBtn);
				Content = layout;
			}
		protected override void Init ()
		{
			var instructions = new Label { FontSize = 24, Text = "The first ListView below should have a Xamarin logo visible in it. The second should have a pink image with white writing. If either image is not displayed, this test has failed." };

			ImageSource remoteSource =
				ImageSource.FromUri (new Uri ("https://xamarin.com/content/images/pages/branding/assets/xamagon.png"));
			ImageSource localSource = ImageSource.FromFile ("oasis.jpg");

			var remoteImage = new Image { Source = remoteSource, BackgroundColor = Color.Red };
			var localImage = new Image { Source = localSource, BackgroundColor = Color.Red };

			var listViewRemoteImage = new ListView {
				BackgroundColor = Color.Green,
				ItemTemplate = new DataTemplate (() => new TestCellGridImage (remoteImage)),
				ItemsSource = new List<string> { "1" }
			};

			var listViewLocalImage = new ListView {
				BackgroundColor = Color.Green,
				ItemTemplate = new DataTemplate (() => new TestCellGridImage (localImage)),
				ItemsSource = new List<string> { "1" }
			};

			Content = new StackLayout {
				Children = {
					instructions,
					listViewRemoteImage,
					listViewLocalImage
				}
			};
		}
Beispiel #18
0
		protected override void Init ()
		{
#pragma warning disable 618
			var label = new Label () { XAlign = TextAlignment.Center };
#pragma warning restore 618
			var image = new Image ();

			image.PropertyChanged += (sender, e) => {
				if (e.PropertyName == "IsLoading")
					label.Text = image.IsLoading ? "Loading" : "Done";
			};

			var btnSetOrClear = new Button () { Text = KSetImageSource, AutomationId = "btnLoad" };

			btnSetOrClear.Clicked += delegate {
				if (btnSetOrClear.Text == KSetImageSource) {
					ClearImageCache ();
					image.Source =
						"http://www.public-domain-image.com/free-images/miscellaneous/big-high-border-fence.jpg";
					btnSetOrClear.Text = KClearImageSource;
				} else {
					image.Source = null;
					btnSetOrClear.Text = KSetImageSource;
				}
			};

			Content = new StackLayout {
				Orientation = StackOrientation.Vertical, 
				Padding = new Thickness (10),
				Children = { btnSetOrClear, image, label }
			};
		}
Beispiel #19
0
		public PixelOffsetTransforms()
		{
			HorizontalContentAlignment = HorizontalAlignment.Stretch;
			Spacing = 5;

			var canvas = new TestCanvas();

			var offsetMode = new EnumDropDown<PixelOffsetMode>();
			offsetMode.SelectedValueBinding.Bind(canvas, c => c.PixelOffsetMode);

			var testDropDown = new DropDown();
			testDropDown.ItemTextBinding = Binding.Property((TestInfo t) => t.Name);
			testDropDown.SelectedValueBinding.Cast<TestInfo>().Bind(canvas, c => c.Test);
			testDropDown.DataStore = tests;
			testDropDown.SelectedIndex = 0;

			var options = new StackLayout
			{
				Orientation = Orientation.Horizontal,
				VerticalContentAlignment = VerticalAlignment.Center,
				Spacing = 5,
				Padding = new Padding(10),
				Items =
				{
					"PixelOffsetMode",
					offsetMode,
					"Test",
					testDropDown
				}
			};

			Items.Add(options);
			Items.Add(new StackLayoutItem(canvas, true));
		}
Beispiel #20
0
		protected override void Init ()
		{
			var rootGrid = new Grid {
				RowDefinitions = new RowDefinitionCollection
														  {
															 new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
															 new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) },
														 },
			};


			_mainContent = new ContentView { Content = new ScrollView { Content = new Label { Text = Description } } };
			rootGrid.AddChild (_mainContent, 0, 0);


			var buttons = new StackLayout { Orientation = StackOrientation.Horizontal };

			var button1A = new Button { Text = "View 1A" };
			button1A.Clicked += (sender, args) => ShowView (_view1A);
			buttons.Children.Add (button1A);

			var button1B = new Button { Text = "View 1B" };
			button1B.Clicked += (sender, args) => ShowView (_view1B);
			buttons.Children.Add (button1B);

			var button2 = new Button { Text = "View 2" };
			button2.Clicked += (sender, args) => ShowView (_view2);
			buttons.Children.Add (button2);

			rootGrid.AddChild (buttons, 0, 1);


			Content = rootGrid;
		}
Beispiel #21
0
		public Issue1742 ()
		{
			 var listView = new ListView
            {
                RowHeight = 40
            };
            var invisibleButton = new Button
            {
                IsVisible = false,
                Text = "INVISIBLE button"
            };
            var visibleButton = new Button
            {
                IsVisible = true,
                Text = "Visible button"
            };

            invisibleButton.Clicked += Button_Clicked;
            visibleButton.Clicked += Button_Clicked;
            listView.ItemTapped += ListView_ItemTapped;

            listView.ItemsSource = new string[] { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.FillAndExpand,
				Children = { listView, visibleButton, invisibleButton }
			};

		}
Beispiel #22
0
 protected override void Init()
 {
     var picker = new Picker
     {
         IsEnabled = false
     };
     picker.Items.Add("item");
     picker.Items.Add("item 2");
     
     Content = new StackLayout
     {
         Children =
         {
             picker,
             new Button
             {
                 Command = new Command(() =>
                 {
                     if (picker.IsEnabled)
                         picker.IsEnabled = false;
                     else
                         picker.IsEnabled = true;
                 }),
                 Text = "Enable/Disable Picker"
             }
         }
     };
 }
Beispiel #23
0
		protected override void Init ()
		{
			Content = new StackLayout {
				VerticalOptions = LayoutOptions.Center,
				Children = {
					new Label {
#pragma warning disable 618
						XAlign = TextAlignment.Center,
#pragma warning restore 618
						Text = "Welcome to Xamarin Forms!"
					},
					new Button {
						Text = "Without Params (Works)",
						AutomationId = "btnOpenUri1",
						Command = new Command (() => Device.OpenUri (new Uri ("http://www.bing.com")))
					},
					new Button {
						Text = "With encoded Params (Breaks)",
						AutomationId = "btnOpenUri2",
						Command = new Command (() => Device.OpenUri (new Uri ("http://www.bing.com/search?q=xamarin%20bombs%20on%20this")))
					},
					new Button {
						Text = "With decoded Params (Breaks)",
						AutomationId = "btnOpenUri3",
						Command = new Command (() => Device.OpenUri (new Uri ("http://www.bing.com/search?q=xamarin bombs on this")))
					}
				}
			};
		}
Beispiel #24
0
		protected override void Init ()
		{
			var listView = new ListView ();

			var selection = new Selection ();
			listView.SetBinding (ListView.ItemsSourceProperty, "Items");

			listView.ItemTemplate = new DataTemplate (() => {
				var cell = new SwitchCell ();
				cell.SetBinding (SwitchCell.TextProperty, "Name");
				cell.SetBinding (SwitchCell.OnProperty, "IsSelected", BindingMode.TwoWay);
				return cell;
			});

			var instructions = new Label {
				FontSize = 16,
				Text =
					"The label at the bottom should equal the number of switches which are in the 'on' position. Flip some of the switches. If the number at the bottom does not equal the number of 'on' switches, the test has failed."
			};

			var label = new Label { FontSize = 24 };
			label.SetBinding (Label.TextProperty, "SelectedCount");

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.Fill,
				Children = {
					instructions,
					listView,
					label
				}
			};

			BindingContext = selection;
		}
		protected override void Init()
		{
			var button = new Button
			{
				AutomationId = "crashButton",
				Text = "Start Test"
			};

			var success = new Label { Text = "Success", IsVisible = false, AutomationId = "successLabel" };

			var instructions = new Label { Text = "Click the Start Test button. " };

			Content = new StackLayout
			{
				HorizontalOptions = LayoutOptions.Fill,
				VerticalOptions = LayoutOptions.Fill,
				Children = { instructions, success, button }
			};

			button.Clicked += async (sender, args) =>
			{
				await Task.WhenAll(GenerateTasks());
				success.IsVisible = true;
			};
		}
Beispiel #26
0
		public MonoGameGuiManager CreateGui( )
		{
			
			var textureAtlas = new TextureAtlas("Atlas1");
            var upRegion = textureAtlas.AddRegion("cog", 48, 0, 47, 47);
            var cogRegion = textureAtlas.AddRegion("up", 0, 0, 47, 47);

			_gui = new MonoGameGuiManager(_game.GraphicsDevice, _game.Content);
            _gui.LoadContent(new GuiContent(textureAtlas, "ExampleFont.fnt", "ExampleFont_0"));
			
			var screen = new Screen(800, 480);
			var dockLayout = new DockLayout();
			var gridLayout = new GridLayout(1, 2);
			var leftStackLayout = new StackLayout() { Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Bottom };
			var loadRubeFileBtn = CreateButton(cogRegion);
			var dumpRubeFileBtn = CreateButton(upRegion);
						
			dockLayout.Items.Add(new DockItem(gridLayout, DockStyle.Bottom));

            dumpRubeFileBtn.Tag = "dump";
			loadRubeFileBtn.Tag = "load";
			leftStackLayout.Items.Add(loadRubeFileBtn);
			leftStackLayout.Items.Add(dumpRubeFileBtn);
			
			gridLayout.Items.Add(new GridItem(leftStackLayout, 0, 0));
			
			
			screen.Items.Add(dockLayout);
			_gui.Screen = screen;

			return _gui;
		}
Beispiel #27
0
		public Issue2292 ()
		{
			var datePicker = new DatePicker ();
			var datePickerBtn = new Button {
				Text = "Click me to call .Focus on DatePicker"
			};

			datePickerBtn.Clicked += (sender, args) => {
				datePicker.Focus ();
			};

			var datePickerBtn2 = new Button {
				Text = "Click me to call .Unfocus on DatePicker"
			};

			datePickerBtn2.Clicked += (sender, args) => {
				datePicker.Unfocus ();
			};

			Content = new StackLayout {
				Children = {
					datePickerBtn, 
					datePickerBtn2, 
					datePicker,
				}
			};
		}
Beispiel #28
0
		protected override void Init ()
		{
			CustomListView lv = new CustomListView () {
				ItemsSource = Enumerable.Range (0, 10)
			};
			Content = new StackLayout { Children = { new Label { Text = "If the ListView does not have green Cells, this test has failed." }, lv } };
		}
        public AutoCompleteView()
        {

            //InitializeComponent();
            stkBase = new StackLayout();
            var innerLayout = new StackLayout();
            entText = new Entry()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.Start
            };
            btnSearch = new Button()
            {
                VerticalOptions = LayoutOptions.Center,
                Text = "Search"
            };

            lstSugestions = new ListView()
            {
                HeightRequest = 250,
                HasUnevenRows = true
            };

            innerLayout.Children.Add(entText);
            innerLayout.Children.Add(btnSearch);
            stkBase.Children.Add(innerLayout);
            stkBase.Children.Add(lstSugestions);

            Content = stkBase;


            entText.TextChanged += (s, e) =>
            {
                Text = e.NewTextValue;
            };
            btnSearch.Clicked += (s, e) =>
            {
                if (SearchCommand != null && SearchCommand.CanExecute(Text))
                    SearchCommand.Execute(Text);
            };
            lstSugestions.ItemSelected += (s, e) =>
            {
                entText.Text = GetSearchString(e.SelectedItem);

                AvailableSugestions.Clear();
                ShowHideListbox(false);
                SelectedCommand.Execute(e);
                if (ExecuteOnSugestionClick
                   && SearchCommand != null && SearchCommand.CanExecute(Text))
                {
                    SearchCommand.Execute(e);
                }

            };
            AvailableSugestions = new ObservableCollection<object>();
            this.ShowHideListbox(false);
            lstSugestions.ItemsSource = this.AvailableSugestions;
            //lstSugestions.ItemTemplate = this.SugestionItemDataTemplate;
        }
Beispiel #30
0
		public ImageGallery ()
		{

			Padding = new Thickness (20);

			var normal = new Image { Source = ImageSource.FromFile ("cover1.jpg") };
			var disabled = new Image { Source = ImageSource.FromFile ("cover1.jpg") };
			var rotate = new Image { Source = ImageSource.FromFile ("cover1.jpg") };
			var transparent = new Image { Source = ImageSource.FromFile ("cover1.jpg") };
			var embedded = new Image { Source = ImageSource.FromResource ("Xamarin.Forms.Controls.ControlGalleryPages.crimson.jpg", typeof (ImageGallery)) };

			// let the stack shrink the images
			normal.MinimumHeightRequest = normal.MinimumHeightRequest = 10;
			disabled.MinimumHeightRequest = disabled.MinimumHeightRequest = 10;
			rotate.MinimumHeightRequest = rotate.MinimumHeightRequest = 10;
			transparent.MinimumHeightRequest = transparent.MinimumHeightRequest = 10;
			embedded.MinimumHeightRequest = 10;

			disabled.IsEnabled = false;
			rotate.GestureRecognizers.Add (new TapGestureRecognizer { Command = new Command (o => rotate.RelRotateTo (180))});
			transparent.Opacity = .5;

			Content = new StackLayout {
				Orientation = StackOrientation.Horizontal,
				Children = {
					new StackLayout {
						//MinimumWidthRequest = 20,
						HorizontalOptions = LayoutOptions.FillAndExpand,
						Children = {
							normal,
							disabled,
							transparent,
							rotate,
							embedded,
							new StackLayout {
								HeightRequest = 30,
								Orientation = StackOrientation.Horizontal,
								Children = {
									new Image {Source = "cover1.jpg"},
									new Image {Source = "cover1.jpg"},
									new Image {Source = "cover1.jpg"},
									new Image {Source = "cover1.jpg"}
								}
							}
						}
					},
					new StackLayout {
						WidthRequest = 30,
						Children = {
							new Image {Source = "cover1.jpg"},
							new Image {Source = "cover1.jpg"},
							new Image {Source = "cover1.jpg"},
							new Image {Source = "cover1.jpg"}
						}
					}

				}
			};
		}
Beispiel #31
0
        public CannotScrollRepro()
        {
            Title = "Nav Bar";

            var layout = new StackLayout {
                Padding         = new Thickness(20),
                BackgroundColor = Color.Gray
            };

            var button1 = new Button {
                Text = "Button 1"
            };
            var button2 = new Button {
                Text = "Button 2", IsEnabled = false
            };
            var button3 = new Button {
                Text = "Button 3", IsEnabled = false
            };
            var button4 = new Button {
                Text = "Button 4", IsEnabled = false
            };
            var button5 = new Button {
                Text = "Button 5", IsEnabled = false
            };
            var button6 = new Button {
                Text = "Button 6", IsEnabled = false
            };
            var button7 = new Button {
                Text = "Button 7", IsEnabled = false
            };
            var button8 = new Button {
                Text = "Button 8"
            };

            var label = new Label {
                Text = "Not Clicked"
            };

            var buttonStack = new StackLayout {
                Padding     = new Thickness(30, 0),
                Orientation = StackOrientation.Horizontal,
                Spacing     = 30,
                Children    =
                {
                    button1,
                    button2,
                    button3,
                    button4,
                    button5,
                    button6,
                    button7,
                    button8,
                }
            };

            button1.Clicked += (sender, args) => Navigation.PopModalAsync();

            int count = 0;

            button8.Clicked += (sender, e) => {
                if (count == 0)
                {
                    label.Text = "I was clicked once!";
                    count++;
                }
                else if (count == 1)
                {
                    label.Text = "I was clicked again!";
                    count++;
                }
                else if (count == 2)
                {
                    label.Text = "I was clicked again again!";
                }
            };

            layout.Children.Add(new BoxView {
                BackgroundColor   = Color.Red,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            });

            layout.Children.Add(label);

            layout.Children.Add(new ScrollView {
                BackgroundColor = Color.Aqua,
                Orientation     = ScrollOrientation.Horizontal,
                HeightRequest   = Device.RuntimePlatform == Device.UWP  ? 80 : 44,
                Content         = buttonStack
            });

            Content = layout;
        }
        // LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL

        #endregion


        public Entry100()
        {
            InitializeComponent();

            #region intro stuff
            this.Title      = "Near Hospitals, ER's";
            BackgroundColor = Color.Black; // WhiteSmoke;
            Opacity         = 0.9;
            //?//App.statusBaseLine.BackgroundColor = A_Util001.ColorInTraining();

            #endregion

            #region Toolbar 007
            //
            // .......................................................................
            // Tool Bar
            // .......................................................................
            ToolbarItems.Clear();
            // set originator, the returning address/name


            // How To Do
            ToolbarItem TBI_ToDo = new ToolbarItem
            {
                Icon    = "help.png",
                Order   = ToolbarItemOrder.Primary,
                Command = new Command(async() => await Navigation.PushAsync(new BaseGuide(1)))
            };
            ToolbarItems.Add(TBI_ToDo);

            // User Guide
            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "User Guide",
                Order   = ToolbarItemOrder.Secondary,
                Command = new Command(async() => await Navigation.PushAsync(new BaseGuide(1)))
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Share this app",
                Order   = ToolbarItemOrder.Secondary,
                Command = new Command(async() => await Navigation.PushAsync(new BaseShare()))
            });
            // Setup
            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Setup",
                Order   = ToolbarItemOrder.Secondary,
                Command = new Command(async() => await Navigation.PushAsync(new BaseSetup()))
            });
            // Legal Disclaimer
            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Legal Disclaimer",
                Order   = ToolbarItemOrder.Secondary,
                Command = new Command(async() => await Navigation.PushAsync(new BaseDisclaimer()))
            });
            // Privacy
            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Privacy",
                Order   = ToolbarItemOrder.Secondary,
                Command = new Command(async() => await Navigation.PushAsync(new BasePrivacy()))
            });
            // About
            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "About -- References",
                Order   = ToolbarItemOrder.Secondary,
                Command = new Command(async() => await Navigation.PushAsync(new StatAbout()))
            });
            // Contact Us
            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Contact Us",
                Order   = ToolbarItemOrder.Secondary,
                Command = new Command(async() => await Navigation.PushAsync(new BaseContactUs()))
            });
            // .......................................................................
            //

            #endregion


            #region Lines (lightgray)

            var boxViewbnew0 = new BoxView()
            {
                HeightRequest   = 1,
                WidthRequest    = 170,
                BackgroundColor = Color.Black
            };
            StackLayout n0_Underline = new StackLayout()
            {
                Margin          = new Thickness(2, 2, 0, 2),
                BackgroundColor = Color.LightGray,
                WidthRequest    = 170,
                HeightRequest   = 1,
                Children        = { boxViewbnew0 }
            };

            var boxViewbnew0444 = new BoxView()
            {
                HeightRequest   = 1,
                WidthRequest    = 170,
                BackgroundColor = Color.LightGray
            };
            var boxViewbnew02 = new BoxView()
            {
                HeightRequest   = 15,
                WidthRequest    = 28,
                BackgroundColor = Color.LightSkyBlue,
                Opacity         = 100
            };

            StackLayout n555_Underline = new StackLayout()
            {
                //Margin = new Thickness(0, 8, 0, 8),
                //BackgroundColor = Color.LightGray,
                //HeightRequest = 40,
                //WidthRequest=40,
                Children = { boxViewbnew02 }
            };
            #endregion

            #region Startup labels, background


            Label lb001 = new Label()
            {
                Text     = "Welcome\n\nList all Hospitals w/ EMS\nin 100 miles Surounding",
                Margin   = new Thickness(5, -125, 0, 0),
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                //FontAttributes = FontAttributes.Bold,
                Style   = Device.Styles.TitleStyle,
                Opacity = 0.5,
                HorizontalTextAlignment = TextAlignment.Center,
                BackgroundColor         = Color.White, //.LightYellow,
                TextColor = Color.Black,
                //WidthRequest = App.DisplayScaleMax,
                HeightRequest = 140
            };

            Label lb003b = new Label()
            {
                Text     = "Get Hospital Details, Get Driving Direction",
                Margin   = new Thickness(10, -5, 0, 0),
                FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)),
                HorizontalTextAlignment = TextAlignment.Center,
                //FontAttributes = FontAttributes.Bold,
                BackgroundColor = Color.White, //.LightYellow,
                TextColor       = Color.Blue,
                WidthRequest    = App.DisplayScaleMax,
                //HeightRequest = 60
            };

            var image001 = new Image
            {
                Source  = "Splash_121618002.jpg",
                Opacity = 0.2,
                Margin  = new Thickness(0, 0, 0, 0)
            };

            #endregion

            #region Start-It button

            btItemsAdult = new Button
            {
                Text         = "Hospitals",
                Image        = "techn.jpg",
                Margin       = new Thickness(0, 0, 0, 0),
                BorderWidth  = 2,
                CornerRadius = 10,
                BorderColor  = Color.White,
                FontSize     = Device.GetNamedSize(NamedSize.Small, typeof(Button)),
                //Style = Device.Styles.TitleStyle,
                FontAttributes    = FontAttributes.Italic,
                TextColor         = Color.White,
                BackgroundColor   = Color.DarkRed, //.DeepSkyBlue,
                HorizontalOptions = LayoutOptions.Center,
                HeightRequest     = 55,
                WidthRequest      = 160
            };
            btItemsAdult.Clicked += OnbtItemsAdultClickedAsync;


            btItemsHistory = new Button
            {
                Text         = "Plain List Only",
                Image        = "docitsmall.jpg",
                Margin       = new Thickness(0, 10, 0, 0),
                BorderWidth  = 2,
                CornerRadius = 10,
                BorderColor  = Color.White,
                FontSize     = Device.GetNamedSize(NamedSize.Small, typeof(Button)),
                //Style = Device.Styles.TitleStyle,
                FontAttributes    = FontAttributes.Italic,
                TextColor         = Color.Black,
                BackgroundColor   = Color.LightGray, //.DeepSkyBlue,
                HorizontalOptions = LayoutOptions.Center,
                HeightRequest     = 50,
                WidthRequest      = 200
            };
            btItemsHistory.Clicked += OnbtItemsHistoryClickedAsync;

            StackLayout stkSum2 = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                VerticalOptions   = LayoutOptions.EndAndExpand,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                //BackgroundColor = Color.White,
                Spacing      = 5,
                WidthRequest = App.DisplayScaleMax,
                Children     =
                {
                    btItemsAdult,
                    btItemsHistory,
                }
            };

            Frame startframe = new Frame()
            {
                Content           = stkSum2,
                BorderColor       = Color.Blue,
                CornerRadius      = 10,
                HasShadow         = true,
                Margin            = new Thickness(5, -10, 5, 5),
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.Center
            };


            #endregion

            #region Stack Layouts

            StackLayout selectionStack = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Margin            = new Thickness(0, 15, 0, 0),
                BackgroundColor   = Color.Snow, //.LightSlateGray, //.Silver, //.NavajoWhite,
                //WidthRequest = App.DisplayScreenHeight,
                WidthRequest = App.DisplayScaleMax,
                //Spacing = 8,
                Children =
                {
                    startframe,
                }
            };


            StackLayout leftStack = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Margin            = new Thickness(0, 0, 0, 0),
                BackgroundColor   = Color.White, //Color.LightSkyBlue,
                //WidthRequest = App.DisplayScreenHeight,
                Spacing  = 12,
                Children =
                {
                    image001,
                    lb001,
                    lb003b,
                    selectionStack,
                }
            };


            StackLayout centerStack = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                BackgroundColor   = Color.LightSkyBlue,
                WidthRequest      = App.DisplayScreenHeight,
                Spacing           = 12,
                Children          =
                {
                    leftStack,
                }
            };


            #endregion


            #region Advertisement on bottom
            //

            //  A. Ad-contract is renewable from month to month.
            //  B. An Ad-contract area size is a 'virtual' circle, with a center at Longitude / Latitude, and a radius of x miles
            //  C. Ad-contract areas do not overlap
            //
            // Upon the start of an app, the following steps are mtaken:
            //    1. establishes the devices geao location,
            //    2. get count of ad-contracts
            //
            //       loop on all contracts
            //				3. reads the ad-contract DB, keyed by location and distance, called contract-location, contract - distance
            //				4. if todays date is not past expiration date:
            //				5. calculate the distance between the device location and the contract - location, called device-distance
            //				6. if the device - distance is less than the contract-distance a hit is found,
            //					7. the texts from the hit record are read and displayed.
            //			end loop
            //


            try
            {
                //    1. establishes its own location, deviceLatitude. deviceLongitude
                Entry100.GetDevLocationAsync();
                //    2. get count of ad-contracts
                Entry100.azLoop = A_Advertisement.GetAzLoopCount();
                Entry100.azLoop = 1;
                //
                // loop on all Azure records
                //
                for (int iL = 0; iL < Entry100.azLoop; iL++)
                {
                    //	3. reads the ad-contract DB, keyed by location and distance, called contract-location, contract - distance
                    string aa = Entry100.readAd_Azure(iL);
                    //	4. if todays date is not past expiration date:

                    DateTime dt2 = DateTime.Now;;
                    DateTime dt1 = DateTime.Parse("07/12/2021");

                    if (dt1.Date > dt2.Date)
                    {
                        //	5. calculate the distance between the device location and the contract - location, called device-distance
                        int idistance = Entry100.adSpotsDistance_Azure(Entry100.deviceLatitude, Entry100.deviceLongitude, Entry100.aDspotLatitude, Entry100.aDspotLongitude);
                        //	6. if the device - distance is less than the contract-distance a hit is found,
                        if (idistance <= Entry100.aDspotMiles)
                        {
                            Entry100.adText = Entry100.adString;
                            break;
                        }
                    }
                    else
                    {
                        //It's an earlier or equal date
                    }
                }
                if (Entry100.adText.Length == 0)
                {
                    Entry100.adText = Entry100.adString;
                }
                this.addFooter.Text = "  " + Entry100.adText + "  ";
            }
            catch (Exception ex)
            {
                string aa = ex.ToString();
                //////ib = true;
            }

            A_Advertisement.Adv_Set1(addFooter, 0);
            stackAd = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                VerticalOptions   = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.Start,
                BackgroundColor   = Color.OldLace,
                //Spacing = 0,
                Children =
                {
                    addFooter
                }
            };

            #endregion


            #region Final Stacks

            StackLayout stackFinalHeader = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                VerticalOptions   = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.Start,
                BackgroundColor   = Color.Yellow, //.OldLace,
                //Spacing = 0,
                Children =
                {
                }
            };

            var stackFinalBody = new StackLayout()
            {
                Margin            = new Thickness(0, 0, 0, 0),
                Orientation       = StackOrientation.Vertical,
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                BackgroundColor   = Color.White, //.Green, //.Black,
                HeightRequest     = App.DisplayScaleMax,
                Children          =
                {
                    centerStack
                }
            };

            ScrollView FinalScrollView = new ScrollView()
            {
                VerticalOptions   = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Content           = stackFinalBody
            };


            // ------------------------------------------------------------------------
            // Page -------------------------------------------------------------------
            // ------------------------------------------------------------------------
            // Stacklayout
            // scroll Layout / View
            //   stack layout
            //
            // -------------------------------------------------------------------------
            App.CCMed FinalPageLayout = new App.CCMed();

            FinalPageLayout.TopStack.Children.Add(stackFinalHeader);
            //FinalPageLayout.TopStack.Children.Add(SPheader001);
            //FinalPageLayout.TopStack.Children.Add(FinalScrollView);
            FinalPageLayout.CenterStack.Children.Add(FinalScrollView);
            FinalPageLayout.BottomStack.Children.Add(stackAd); // TopScreen1.contentstatusBaseline);

            // Assign to the page
            this.Content = FinalPageLayout;

            #endregion

            //
            // Setting Startup Values
            //
            //////Accelerometer.Stop();
            //////Preferences.Set("MonitorOnOff", "0");
            //
            // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            // This will "blitz" through this page, and immidiately put up the next pag.
            // ... but if you pewaa <Return>, it will show this page for some advertisement
            // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            //
            try
            {
                var duration = TimeSpan.FromMilliseconds(1000);
                Vibration.Vibrate(duration);
            }
            catch (FeatureNotSupportedException ex)
            {
                string aa = ex.Message.ToString();
            }
            catch (Exception ex)
            {
                string aa = ex.Message.ToString();
            }
            bool noBlockChain = false;
            Navigation.PushAsync(new FindHospital(noBlockChain));
            //
        }
        /**
         *
         * **/
        public static StackLayout WaitingTemplate02(int ID, int AppointmentID, String PatientName, Status CurrentStatus, String BookingTime, String Description, ImageSource UserImageAddress, String PhoneNo)
        {
            Color StatusTextColor = (Color)App.Current.Resources["colorGreen"];

            switch (CurrentStatus)
            {
            case Status.Declined:
                StatusTextColor = (Color)App.Current.Resources["colorRed"];
                break;

            case Status.Waiting:
                StatusTextColor = (Color)App.Current.Resources["colorGold"];
                break;

            default:
                StatusTextColor = (Color)App.Current.Resources["colorGreen"];
                break;
            }

            Grid ParentGrid = new Grid {
                HeightRequest = 75, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(5, 0)
            };

            ParentGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(75)
            });
            ParentGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(.5, GridUnitType.Star)
            });
            ParentGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(.3, GridUnitType.Star)
            });

            TapGestureRecognizer ParentGridTapped = new TapGestureRecognizer();

            ParentGridTapped.Tapped += delegate
            {
                App.Current.MainPage.Navigation.PushAsync(new DetailedWaitingPatient(ID, AppointmentID, PatientName, BookingTime, Description, UserImageAddress, CurrentStatus, PhoneNo));
            };

            ParentGrid.GestureRecognizers.Add(ParentGridTapped);

            CircleImage UserImage = new CircleImage
            {
                //ImageSource.FromUri(new Uri(ImageAddress))
                //Utilities.Source("doc_anim.jpg", typeof(WaitingRoomTemplate))
                Source            = UserImageAddress,
                Aspect            = Aspect.AspectFill,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
            };

            Grid.SetColumn(UserImage, 0);


            Label PatientNameLabel = new Label
            {
                Text = PatientName,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Center,
                FontSize = 16,
            };

            Grid.SetColumn(PatientNameLabel, 1);


            Label StatusLabel = new Label
            {
                Text      = Enum.GetName(typeof(Status), CurrentStatus),
                TextColor = StatusTextColor,
                HorizontalTextAlignment = TextAlignment.End,
                VerticalTextAlignment   = TextAlignment.Center,
                FontSize = 14,
            };

            Grid.SetColumn(StatusLabel, 2);


            BoxView BottomLine = new BoxView
            {
                BackgroundColor   = (Color.White),
                HeightRequest     = 1,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.End
                                    //Style = App.Current.Resources["_BoxViewBottomLine"] as Style
            };

            ParentGrid.Children.Add(UserImage);
            ParentGrid.Children.Add(PatientNameLabel);
            ParentGrid.Children.Add(StatusLabel);

            StackLayout AllStack = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Spacing     = 0
            };

            AllStack.Children.Add(ParentGrid);
            AllStack.Children.Add(BottomLine);

            return(AllStack);
        }
Beispiel #34
0
        public UnitTestSection()
        {
            startButton = new Button {
                Text = "Start Tests", Size = new Size(200, 80)
            };
            useTestPlatform = new CheckBox {
                Text = "Use Test Platform"
            };
            var buttons = new StackLayout
            {
                Padding = new Padding(10),
                Spacing = 5,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                Items = { startButton, useTestPlatform }
            };

            if (Platform.Supports <TreeView>())
            {
                search = new SearchBox();
                search.Focus();
                search.KeyDown += (sender, e) =>
                {
                    if (e.KeyData == Keys.Enter)
                    {
                        startButton.PerformClick();
                        e.Handled = true;
                    }
                };

                var timer = new UITimer();
                timer.Interval = 0.5;
                timer.Elapsed += (sender, e) =>
                {
                    timer.Stop();
                    PopulateTree(search.Text);
                };
                search.TextChanged += (sender, e) => {
                    if (timer.Started)
                    {
                        timer.Stop();
                    }
                    timer.Start();
                };

                tree = new TreeView();

                tree.Activated += (sender, e) =>
                {
                    var item = (TreeItem)tree.SelectedItem;
                    if (item != null)
                    {
                        RunTests(item.Tag as CategoryFilter);
                    }
                };

                Content = new StackLayout
                {
                    Spacing = 5,
                    HorizontalContentAlignment = HorizontalAlignment.Stretch,
                    Items = { buttons, search, new StackLayoutItem(tree, expand: true) }
                };
            }
            else
            {
                Content = buttons;
            }

            startButton.Click += (s, e) => RunTests();
        }
Beispiel #35
0
        public CloseSwipeGallery()
        {
            Title = "Open/Close SwipeView Gallery";

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

            var openButton = new Button
            {
                Text = "Open SwipeView"
            };

            var closeButton = new Button
            {
                Text = "Close SwipeView"
            };

            swipeLayout.Children.Add(openButton);
            swipeLayout.Children.Add(closeButton);

            var swipeItem = new SwipeItem
            {
                BackgroundColor = Color.Red,
                IconImageSource = "calculator.png",
                Text            = "File"
            };

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

            var swipeItems = new SwipeItems {
                swipeItem
            };

            swipeItems.Mode = SwipeMode.Reveal;

            var swipeContent = new Grid
            {
                BackgroundColor = Color.Gray
            };

            var fileSwipeLabel = new Label
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Text = "Swipe to Right (File)"
            };

            swipeContent.Children.Add(fileSwipeLabel);

            var swipeView = new SwipeView
            {
                HeightRequest = 60,
                WidthRequest  = 300,
                LeftItems     = swipeItems,
                Content       = swipeContent
            };

            swipeLayout.Children.Add(swipeView);

            Content = swipeLayout;

            openButton.Clicked += (sender, e) =>
            {
                swipeView.Open(OpenSwipeItem.LeftItems);
            };

            closeButton.Clicked += (sender, e) =>
            {
                swipeView.Close();
            };
        }
Beispiel #36
0
        public FormsView(Syncfusion.SfDataGrid.XForms.SfDataGrid grid)
        {
            isSuspend = true;
            this.grid = grid;
            if (Device.RuntimePlatform != Device.UWP)
            {
                this.Visibility = false;
            }
            else
            {
                this.IsVisible = false;
            }
            this.Columns     = grid.Columns;
            Spacing          = 10;
            BackgroundColor  = Color.FromRgb(43, 43, 43);
            this.Orientation = StackOrientation.Vertical;
            this.Padding     = new Thickness(10);

            FormContentView = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal, Spacing = 20
            };
            if (Device.RuntimePlatform == Device.UWP || Device.RuntimePlatform == Device.macOS)
            {
                BackgroundColor = Color.Black;
                Footer          = new StackLayout()
                {
                    Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.CenterAndExpand, Spacing = 5
                };
                Save = new Button {
                    WidthRequest = 150, FontSize = 16, Text = "SAVE", HorizontalOptions = LayoutOptions.CenterAndExpand, BackgroundColor = Color.FromHex("#333333"), TextColor = Color.White
                };
                Cancel = new Button {
                    WidthRequest = 150, FontSize = 16, Text = "CANCEL", HorizontalOptions = LayoutOptions.CenterAndExpand, BackgroundColor = Color.FromHex("#333333"), TextColor = Color.White
                };
            }
            else
            {
                Footer = new StackLayout()
                {
                    Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.EndAndExpand
                };
                Save = new Button {
                    FontSize = 18, Text = "SAVE", HorizontalOptions = LayoutOptions.End, BackgroundColor = Color.Transparent, TextColor = Color.FromHex("#EC407A")
                };
                Cancel = new Button {
                    FontSize = 18, Text = "CANCEL", HorizontalOptions = LayoutOptions.End, BackgroundColor = Color.Transparent, TextColor = Color.FromHex("#EC407A")
                };
            }
            Save.Clicked   += Save_Clicked;
            Cancel.Clicked += Cancel_Clicked;
            Footer.Children.Add(new ContentView()
            {
                Content = Save
            });
            Footer.Children.Add(new ContentView()
            {
                Content = Cancel
            });
            Title = new Label {
                Text = "Edit Details", Margin = new Thickness(15, 15, 0, 0), FontSize = 20, HeightRequest = 30, TextColor = Color.White
            };
            HeaderView = new StackLayout()
            {
                Orientation = StackOrientation.Vertical, Spacing = 5, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand
            };
            EditorView = new StackLayout()
            {
                Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Spacing = 5
            };
            EditorView.BindingContextChanged += EditView_BindingContextChanged;
            isSuspend = false;
        }
Beispiel #37
0
        public ContentPage CreatePage(
            int teamNumber,
            string teamName,
            string teamScore,
            string matchNumber,
            int toteScore,
            int canScore,
            int noodleScore,
            int coopScore,
            string notes,
            bool brokeDown,
            string autoCapabilities,
            int currentPage,
            int pageNumber)
        {
            string      brokeDownText = (brokeDown) ? "broke down" : "didn\'t break down";
            StackLayout pageIndicator = new StackLayout {
                HorizontalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Horizontal
            };

            for (int x = 0; x < pageNumber; x++)
            {
                BoxView bv = new BoxView {
                    WidthRequest = 5, HeightRequest = 5, VerticalOptions = LayoutOptions.Center
                };
                if (currentPage == x)
                {
                    bv.BackgroundColor = Color.White;
                }
                else
                {
                    bv.BackgroundColor = Color.Black;
                }
                pageIndicator.Children.Add(bv);
            }

            var report = new ContentPage {
                BackgroundImage = "background.jpg",
                Content         = new ScrollView {
                    Content = new StackLayout {
                        //BackgroundColor = Color.Red,
                        Padding  = 5,
                        Children =
                        {
                            new Label {
                                Text = teamName + " " + teamNumber.ToString(), FontSize = 30, TextColor = Color.Black, FontAttributes = FontAttributes.Bold, XAlign = TextAlignment.Center
                            },
                            //new Image { Source=getPhoto(photo).Result},
                            new Label {
                                Text          = "",
                                HeightRequest = 12
                            },
                            new Label {
                                Text = "Match:", FontSize = 20, FontAttributes = FontAttributes.Bold, TextColor = Color.Black
                            },
                            new Label {
                                Text = "Alliance Score: " + teamScore, TextColor = Color.White,
                                //FontSize=25,
                                FontAttributes = FontAttributes.Bold
                            },
                            new Label {
                                Text = "Tote Score: " + toteScore, TextColor = Color.White,
                                //FontSize=25,
                                FontAttributes = FontAttributes.Bold
                            },
                            new Label {
                                Text = "Can Score: " + canScore, TextColor = Color.White,
                                //FontSize=25,
                                FontAttributes = FontAttributes.Bold
                            },
                            new Label {
                                Text = "Total Individual Score: " + (toteScore + canScore).ToString(), TextColor = Color.White,
                                //FontSize=25,
                                FontAttributes = FontAttributes.Bold
                            },

                            new Label {
                                Text = "Auto Capabilities: " + autoCapabilities,
                                //FontSize=25,
                                FontAttributes = FontAttributes.Bold, TextColor = Color.White
                            },
                            new Label {
                                Text = "Match Number: " + matchNumber,
                                //FontSize=25,
                                FontAttributes = FontAttributes.Bold, TextColor = Color.White
                            },
                            new Label {
                                Text = "Notes: " + notes,
                                //FontSize=25,
                                FontAttributes = FontAttributes.Bold, TextColor = Color.White
                            },

                            pageIndicator
                        }
                    }
                }
            };

            return(report);
        }
Beispiel #38
0
        protected override void Init()
        {
            var red = new BoxView
            {
                BackgroundColor = Color.Red,
                WidthRequest    = 50,
                HeightRequest   = 50,
                TranslationX    = 25
            };
            var green = new BoxView
            {
                BackgroundColor = Color.Green,
                WidthRequest    = 50,
                HeightRequest   = 50
            };
            var blue = new BoxView
            {
                BackgroundColor = Color.Blue,
                WidthRequest    = 50,
                HeightRequest   = 50,
                TranslationX    = -25
            };

            _boxStack = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                Spacing           = 0,
                Margin            = new Thickness(0, 50, 0, 0),
                HorizontalOptions = LayoutOptions.Center,
                Children          =
                {
                    red,
                    green,
                    blue
                }
            };
            _boxStack.ChildrenReordered += BoxStackOnChildrenReordered;

            var raiseButtons = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Center,
                Children          =
                {
                    new Button
                    {
                        Text         = "Raise Red",
                        WidthRequest = 110,
                        Command      = new Command(() => _boxStack.RaiseChild(red))
                    },
                    new Button
                    {
                        Text         = "Raise Green",
                        WidthRequest = 110,
                        Command      = new Command(() => _boxStack.RaiseChild(green))
                    },
                    new Button
                    {
                        Text         = "Raise Blue",
                        WidthRequest = 110,
                        Command      = new Command(() => _boxStack.RaiseChild(blue))
                    }
                }
            };
            var lowerButtons = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Center,
                Children          =
                {
                    new Button
                    {
                        Text         = "Lower Red",
                        WidthRequest = 110,
                        Command      = new Command(() => _boxStack.LowerChild(red))
                    },
                    new Button
                    {
                        Text         = "Lower Green",
                        WidthRequest = 110,
                        Command      = new Command(() => _boxStack.LowerChild(green))
                    },
                    new Button
                    {
                        Text         = "Lower Blue",
                        WidthRequest = 110,
                        Command      = new Command(() => _boxStack.LowerChild(blue))
                    }
                }
            };

            _colorsPositionLabel = new Label
            {
                FormattedText = new FormattedString()
            };
            FormatColorsChildrenPositionText();

            var colorsPositionStack = new StackLayout()
            {
                Margin   = new Thickness(0, 50, 0, 0),
                Children =
                {
                    new Label()
                    {
                        Text = "Colors collection order (i.e. z-index)"
                    },
                    _colorsPositionLabel
                }
            };

            var instructions = new StackLayout()
            {
                Margin            = new Thickness(0, 50, 0, 0),
                HorizontalOptions = LayoutOptions.Center,
                Children          =
                {
                    new Label()
                    {
                        Text     = "When LOWERING an item it's being moved to the START of the collection of children, therefore decreasing it's z-index",
                        FontSize = 15
                    },
                    new Label()
                    {
                        Text     = "When RAISING an item it's being moved to the END of the list of children, therefore increasing its z-index",
                        FontSize = 15
                    },
                    new Label()
                    {
                        Text   = "For instance, if you decide to press LOWER GREEN button, then the GREEN color should no longer be visible - it will become the first item in the list (lowest z-index) and therefore it will get covered by RED and BLUE.",
                        Margin = new Thickness(0, 10, 0, 0)
                    }
                }
            };

            Content = new StackLayout
            {
                Children =
                {
                    raiseButtons,
                    lowerButtons,
                    _boxStack,
                    colorsPositionStack,
                    instructions
                }
            };
        }
Beispiel #39
0
        void SetButtom()
        {
            entCount = new MyEntry {
                HorizontalTextAlignment = TextAlignment.Center,
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.CenterAndExpand,
                TextColor      = ApplicationStyle.GreenColor,
                FontAttributes = FontAttributes.Bold,
                FontSize       = Utils.GetSize(18),
                Keyboard       = Keyboard.Numeric
            };
            entCount.TextChanged += OnCountChange;

            btnPlus = new Button {
                HeightRequest   = Utils.GetSize(49),
                WidthRequest    = Utils.GetSize(49),
                BorderRadius    = 0,
                TextColor       = ApplicationStyle.GreenColor,
                BackgroundColor = ApplicationStyle.LineColor,
                Text            = "+"
            };
            btnPlus.Clicked += OnPlusClick;

            btnMinus = new Button {
                HeightRequest   = Utils.GetSize(49),
                WidthRequest    = Utils.GetSize(49),
                BorderRadius    = 0,
                TextColor       = ApplicationStyle.GreenColor,
                BackgroundColor = ApplicationStyle.LineColor,
                Text            = "-",
            };
            btnMinus.Clicked += OnMinusClick;

            StackLayout layoutButtomCount = new StackLayout {
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    btnPlus,
                    entCount,
                    btnMinus,
                }
            };
            Grid gridBottom = new Grid {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HeightRequest     = Utils.GetSize(49),
                ColumnSpacing     = 0,
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(50, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(50, GridUnitType.Star)
                    },
                },
                BackgroundColor = Color.White,
            };

            gridBottom.Children.Add(layoutButtomCount, 0, 0);
            gridBottom.Children.Add(btnOrder, 1, 0);

            layoutBottom = new StackLayout {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Spacing         = 0,
                Children        =
                {
                    new BoxView(),
                    gridBottom
                }
            };
        }
Beispiel #40
0
        void InitSizes()
        {
            layoutScrollSize = new StackLayout {
                Orientation       = StackOrientation.Horizontal,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };

            scrollSizes = new MyScrollView {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Orientation     = ScrollOrientation.Horizontal,
            };
            scrollSizes.Content = layoutScrollSize;

            relativeLayoutSize = new RelativeLayout()
            {
                HeightRequest = 43
            };

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

            relativeLayoutSize.Children.Add(
                new Image {
                HorizontalOptions = LayoutOptions.Start,
                Source            = Device.OnPlatform("Catalog/Sizesfon_left_", "Sizesfon_left_", "Sizesfon_left_"),
                HeightRequest     = Utils.GetSize(43)
            },
                Constraint.Constant(0),
                Constraint.Constant(0)
                );

            relativeLayoutSize.Children.Add(
                new Image {
                HorizontalOptions = LayoutOptions.EndAndExpand,
                Source            = Device.OnPlatform("Catalog/Sizesfon_right_", "Sizesfon_right_", "Sizesfon_right_"),
                HeightRequest     = Utils.GetSize(43)
            },
                Constraint.RelativeToParent((parent) => {
                return(parent.Width - 40);
            }),
                Constraint.Constant(0)
                );

            lblSize = new Label {
                HorizontalOptions     = LayoutOptions.CenterAndExpand,
                VerticalOptions       = LayoutOptions.FillAndExpand,
                VerticalTextAlignment = TextAlignment.Center,
                FontSize = 14,
                Text     = "Нет размеров",
            };

            layoutSize = new StackLayout {
                Padding       = new Thickness(0, 8, 0, 0),
                Spacing       = 0,
                HeightRequest = Utils.GetSize(45),
                Children      =
                {
                    new BoxView {
                        HeightRequest = 1.5
                    },
                    relativeLayoutSize,
                    //gridLayoutSize,
                    lblSize,
                    new BoxView {
                        HeightRequest = 1.5
                    },
                }
            };
        }
Beispiel #41
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var viewModel = new ListViewViewModel();

            var groupDisplayBindingContainer = new ViewContainer <ListView>(Test.ListView.GroupDisplayBinding, new ListView());

            InitializeElementListView(groupDisplayBindingContainer.View, 0);
            groupDisplayBindingContainer.View.ItemsSource         = viewModel.CategorizedEmployees;
            groupDisplayBindingContainer.View.IsGroupingEnabled   = true;
            groupDisplayBindingContainer.View.GroupDisplayBinding = new Binding("Key");


            var groupHeaderTemplateContainer = new ViewContainer <ListView>(Test.ListView.GroupHeaderTemplate, new ListView());

            InitializeElementListView(groupHeaderTemplateContainer.View, 0);
            groupHeaderTemplateContainer.View.ItemsSource         = viewModel.CategorizedEmployees;
            groupHeaderTemplateContainer.View.IsGroupingEnabled   = true;
            groupHeaderTemplateContainer.View.GroupHeaderTemplate = new DataTemplate(typeof(HeaderCell));

            var groupShortNameContainer = new ViewContainer <ListView>(Test.ListView.GroupShortNameBinding, new ListView());

            InitializeElementListView(groupShortNameContainer.View, 0);
            groupShortNameContainer.View.ItemsSource           = viewModel.CategorizedEmployees;
            groupShortNameContainer.View.IsGroupingEnabled     = true;
            groupShortNameContainer.View.GroupShortNameBinding = new Binding("Key");

            // TODO - not sure how to do this
            var hasUnevenRowsContainer = new ViewContainer <ListView>(Test.ListView.HasUnevenRows, new ListView());

            InitializeElement(hasUnevenRowsContainer.View);
            hasUnevenRowsContainer.View.HasUnevenRows = true;
            hasUnevenRowsContainer.View.ItemTemplate  = new DataTemplate(typeof(UnevenCell));

            var isGroupingEnabledContainer = new StateViewContainer <ListView>(Test.ListView.IsGroupingEnabled, new ListView());

            InitializeElement(isGroupingEnabledContainer.View);
            isGroupingEnabledContainer.View.ItemsSource           = viewModel.CategorizedEmployees;
            isGroupingEnabledContainer.View.IsGroupingEnabled     = true;
            isGroupingEnabledContainer.StateChangeButton.Clicked += (sender, args) => isGroupingEnabledContainer.View.IsGroupingEnabled = !isGroupingEnabledContainer.View.IsGroupingEnabled;


            var itemAppearingContainer = new EventViewContainer <ListView>(Test.ListView.ItemAppearing, new ListView());

            InitializeElement(itemAppearingContainer.View);
            itemAppearingContainer.View.ItemAppearing += (sender, args) => itemAppearingContainer.EventFired();

            var itemDisappearingContainer = new EventViewContainer <ListView>(Test.ListView.ItemDisappearing, new ListView());

            InitializeElement(itemDisappearingContainer.View);
            itemDisappearingContainer.View.ItemDisappearing += (sender, args) => itemDisappearingContainer.EventFired();

            var itemSelectedContainer = new EventViewContainer <ListView>(Test.ListView.ItemSelected, new ListView());

            InitializeElement(itemSelectedContainer.View);
            itemSelectedContainer.View.ItemSelected += (sender, args) => itemSelectedContainer.EventFired();

            var itemTappedContainer = new EventViewContainer <ListView>(Test.ListView.ItemTapped, new ListView());

            InitializeElement(itemTappedContainer.View);
            itemTappedContainer.View.ItemTapped += (sender, args) => itemTappedContainer.EventFired();

            // TODO
            var rowHeightContainer = new ViewContainer <ListView>(Test.ListView.RowHeight, new ListView());

            InitializeElement(rowHeightContainer.View);

            var selectedItemContainer = new ViewContainer <ListView>(Test.ListView.SelectedItem, new ListView());

            InitializeElement(selectedItemContainer.View);
            selectedItemContainer.View.SelectedItem = viewModel.Employees[2];

            var fastScrollItemContainer = new ViewContainer <ListView>(Test.ListView.FastScroll, new ListView());

            InitializeElement(fastScrollItemContainer.View);
            fastScrollItemContainer.View.On <Android>().SetIsFastScrollEnabled(true);
            fastScrollItemContainer.View.ItemsSource = viewModel.CategorizedEmployees;

            var scrolledItemContainer = new ViewContainer <ListView>(Test.ListView.Scrolled, new ListView());

            InitializeElement(scrolledItemContainer.View);
            scrolledItemContainer.View.ItemsSource = viewModel.Employees;
            var scrollTitle = scrolledItemContainer.TitleLabel.Text;

            scrolledItemContainer.View.Scrolled += (sender, args) =>
            {
                scrolledItemContainer.TitleLabel.Text = $"{scrollTitle}; X={args.ScrollX};Y={args.ScrollY}";
            };

            var refreshControlColorContainer = new ViewContainer <ListView>(Test.ListView.RefreshControlColor, new ListView());

            InitializeElement(refreshControlColorContainer.View);
            refreshControlColorContainer.View.RefreshControlColor    = Color.Red;
            refreshControlColorContainer.View.IsPullToRefreshEnabled = true;
            refreshControlColorContainer.View.Refreshing            += async(object sender, EventArgs e) =>
            {
                await Task.Delay(2000);

                refreshControlColorContainer.View.IsRefreshing = false;
            };
            refreshControlColorContainer.View.ItemsSource = viewModel.Employees;

            var scrollbarVisibilityContainer = new ViewContainer <ListView>(Test.ListView.ScrollBarVisibility, new ListView());

            InitializeElement(scrollbarVisibilityContainer.View);
            scrollbarVisibilityContainer.View.HorizontalScrollBarVisibility = ScrollBarVisibility.Never;
            scrollbarVisibilityContainer.View.VerticalScrollBarVisibility   = ScrollBarVisibility.Never;
            scrollbarVisibilityContainer.View.ItemsSource         = viewModel.CategorizedEmployees;
            scrollbarVisibilityContainer.View.IsGroupingEnabled   = true;
            scrollbarVisibilityContainer.View.GroupDisplayBinding = new Binding("Key");

            Add(groupDisplayBindingContainer);
            Add(groupHeaderTemplateContainer);
            Add(groupShortNameContainer);
            Add(hasUnevenRowsContainer);
            Add(isGroupingEnabledContainer);
            Add(itemAppearingContainer);
            Add(itemDisappearingContainer);
            Add(itemSelectedContainer);
            Add(itemTappedContainer);
            Add(rowHeightContainer);
            Add(selectedItemContainer);
            Add(fastScrollItemContainer);
            Add(scrolledItemContainer);
            Add(refreshControlColorContainer);
            Add(scrollbarVisibilityContainer);
        }
        void AddNativeControls(NestedNativeControlGalleryPage page)
        {
            if (page.NativeControlsAdded)
            {
                return;
            }

            StackLayout sl = page.Layout;

            // Create and add a native TextBlock
            var originalText = "I am a native TextBlock";
            var textBlock    = new TextBlock {
                Text       = originalText,
                FontSize   = 14,
                FontFamily = new FontFamily("HelveticaNeue")
            };

            sl?.Children.Add(textBlock);

            // Create and add a native Button
            var button = new Windows.UI.Xaml.Controls.Button {
                Content = "Toggle Font Size", Height = 80
            };

            button.Click += (sender, args) => { textBlock.FontSize = textBlock.FontSize == 14 ? 24 : 14; };

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

            // Create a control which we know doesn't behave correctly with regard to measurement
            var difficultControl = new BrokenNativeControl {
                Text = "Not Sized/Arranged Properly"
            };

            var difficultControl2 = new BrokenNativeControl {
                Text = "Fixed"
            };

            // Add the misbehaving controls, one with a custom delegate for ArrangeOverrideDelegate
            sl?.Children.Add(difficultControl);
            sl?.Children.Add(difficultControl2,
                             arrangeOverrideDelegate: (renderer, finalSize) => {
                if (finalSize.Width <= 0 || double.IsInfinity(finalSize.Width))
                {
                    return(null);
                }

                FrameworkElement frameworkElement = renderer.Control;

                frameworkElement.Measure(finalSize);

                // The broken control always tries to size itself to the screen width
                // So figure that out and we'll know how far off it's laying itself out
                Rect bounds        = ApplicationView.GetForCurrentView().VisibleBounds;
                double scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
                var screenWidth    = new Size(bounds.Width * scaleFactor, bounds.Height * scaleFactor);

                // We can re-center it by offsetting it during the Arrange call
                double diff = Math.Abs(screenWidth.Width - finalSize.Width) / -2;
                frameworkElement.Arrange(new Rect(diff, 0, finalSize.Width - diff, finalSize.Height));

                // Arranging the control to the left will make it show up past the edge of the stack layout
                // We can fix that by clipping it manually
                var clip = new RectangleGeometry {
                    Rect = new Rect(-diff, 0, finalSize.Width, finalSize.Height)
                };
                frameworkElement.Clip = clip;

                return(finalSize);
            }
                             );

            page.NativeControlsAdded = true;
        }
        protected async void InitializeControls()
        {
            Image imgMedia;
            Label lblDescription;
            Grid  gridTextLayout;
            Grid  gridToolBar;
            Grid  gridMedia;

            /////////////////////////////////////////////////////
            // Media Area show media wheather it's video or image
            /////////////////////////////////////////////////////
            string imageUri = postData.GetImageUri();

            imgMedia = new Image
            {
                Aspect            = Aspect.AspectFit,
                Source            = imageUri,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                BackgroundColor   = ZadSpecialDesigen.DefaultNoneImageColor,
            };

            // /*////////////////////////////////////////////////////////////////////////////////////////


            gridMedia = new Grid()
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                ColumnSpacing     = 0,
                RowSpacing        = 0,
                BackgroundColor   = Color.Black,
                RowDefinitions    =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        BindingContext = new GridLength(1, GridUnitType.Star)
                    }
                },
            };

            /// if media type is audio or video initialize webview with source
            if (postData.DataType == DataType.Video || postData.DataType == DataType.Audio)
            {
                if (webViewPlayer == null) //for first time
                {
                    webViewPlayer = new WebView
                    {
                        VerticalOptions   = LayoutOptions.FillAndExpand,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Source            = await GetHTMLWebViewSource(),
                    };
                }
                else
                {
                    webViewPlayer.Source = await GetHTMLWebViewSource();
                }

                var webStackLayout = new StackLayout
                {
                    BackgroundColor = Color.Black,
                    Children        = { webViewPlayer },
                };
                gridMedia.Children.Add(webStackLayout);
            }
            else
            {
                gridMedia.Children.Add(imgMedia);
            }

            /////////////////////////////////////////////////////
            // Text Area for title and description (Paragraph)
            /////////////////////////////////////////////////////

            lblDescription = new Label()
            {
                Text            = postData.Description,
                FontSize        = ZadSpecialDesigen.GetFontSizeOfDescription(),
                XAlign          = TextAlignment.End,
                YAlign          = TextAlignment.Start,
                TextColor       = Color.FromHex("#666666"),
                BackgroundColor = Color.White
            };
            StackLayout descriptionLayout = new StackLayout
            {
                Padding = ZadSpecialDesigen.GetPaddingOfDescription(),
            };

            descriptionLayout.Children.Add(lblDescription);

            gridTextLayout = new Grid()
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                RowSpacing        = 0,
                ColumnSpacing     = 0,
                RowDefinitions    =
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                },
                BackgroundColor = Color.White
            };

            gridTextLayout.Children.Add(
                new TitleIconStackLayout(postData.Title, this.TitleIconUri, Color.FromHex("#F0F4F5"), Color.FromHex("#19716B"))
                , 0, 0);
            gridTextLayout.Children.Add(descriptionLayout, 0, 1);

            /////////////////////////////////////////////////////
            // Footer ToolBar Area for shared and favorite
            /////////////////////////////////////////////////////
            var imgShare = new ClickableImage {
                Source = DEFAULT_ICON_SHARE,
            };

            imgFavorite = new ClickableImage {
                Source = Helper.GetUnFavoriteIconUri(),
            };

            imgShare.Clicked    += ImgShare_Clicked;
            imgFavorite.Clicked += ImgFavorite_Clicked;

            gridToolBar = new Grid()
            {
                RowSpacing      = 0,
                VerticalOptions = LayoutOptions.FillAndExpand,
                RowDefinitions  =
                {
                    new RowDefinition {
                        Height = new GridLength(.1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(.1, GridUnitType.Star)
                    },
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(30, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(20, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(20, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(30, GridUnitType.Star)
                    },
                },
                BackgroundColor = Color.FromHex("#199595"),
            };

            gridToolBar.Children.Add(imgFavorite, 1, 1);
            gridToolBar.Children.Add(imgShare, 2, 1);

            ////////////////////////////////////////////////////////////
            ///////////////////// Main grid //////////////////////////
            //////////////////////////////////////////////////////////
            var scrollview = new ScrollView
            {
                Content = gridTextLayout,
            };

            Grid MainGrid = new Grid()
            {
                Padding           = new Thickness(0, -6, 0, 0),
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                ColumnSpacing     = 0,
                RowSpacing        = 0,
                RowDefinitions    =
                {
                    new RowDefinition {
                        Height = new GridLength(0.46, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(0.46, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(0.08, GridUnitType.Star)
                    },
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

            MainGrid.Children.Add(gridMedia, 0, 0);
            MainGrid.Children.Add(scrollview, 0, 1);
            MainGrid.Children.Add(gridToolBar, 0, 2);

            base.MainBodyScrollView.IsVisible = false;
            base.MainForAdjDataView.Children.Add(MainGrid);
            base.MainForAdjDataView.Padding = 0;
            base.MainForAdjDataView.Spacing = 0;


            if (postData.Description == null || postData.Description == "") // no content
            {
                gridTextLayout.Children.Add(Helper.NoContentLable);
            }
        }
Beispiel #44
0
        public ProductView()
        {
            lblArticle = new Label {
                HeightRequest         = Utils.GetSize(23),
                FontSize              = Utils.GetSize(11),
                VerticalTextAlignment = TextAlignment.Center,
                Margin = new Thickness(8, 0)
            };

            BoxView artLine = new BoxView();

            img = new Image();
            if (Device.OS == TargetPlatform.Android)
            {
                img.HeightRequest = Utils.GetSize(300, 1);
            }
            else
            {
                img.HeightRequest = Utils.GetSize(300);
            }

            ImageClick = new TapGestureRecognizer();
            img.GestureRecognizers.Add(ImageClick);
            imgSklad = new Image {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.EndAndExpand,
                Source            = Device.OnPlatform("Catalog/sklad_", "Sklad", "Sklad"),
                HeightRequest     = Utils.GetSize(18, 1),
                IsVisible         = false
            };

            Grid imgGrid = new Grid {
                Padding = new Thickness(8, 0),
            };

            imgGrid.Children.Add(img, 0, 0);
            imgGrid.Children.Add(imgSklad, 0, 0);

            lblName = new Label {
                HorizontalOptions = LayoutOptions.CenterAndExpand, Margin = new Thickness(8, 8)
            };

            lblPriceOld = new MyLabel {
                FontSize          = Utils.GetSize(17),
                TextColor         = ApplicationStyle.LabelColor,
                HorizontalOptions = LayoutOptions.Center,
                IsVisible         = false,
                IsStrikeThrough   = true
            };
            lblPrice = new Label {
                FontSize          = Utils.GetSize(18),
                TextColor         = ApplicationStyle.GreenColor,
                HorizontalOptions = LayoutOptions.Center,
            };
            StackLayout layoutPrice = new StackLayout {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Center,
                Spacing           = Utils.GetSize(10),
                Children          =
                {
                    lblPriceOld,
                    lblPrice
                }
            };

            InitSizes();

            btnTableSize = new MyButton {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                BackgroundColor   = Color.Transparent,
                HeightRequest     = Utils.GetSize(25),
                Text        = "Таблица размеров",
                FontSize    = Utils.GetSize(9),
                TextColor   = ApplicationStyle.GreenColor,
                IsUnderline = true
            };
            btnTableSize.Clicked += (sender, e) => { EventTableSizeClick(sender, e); };

            lblDescription = new MyLabel {
                LineSpacing = 1.5f
            };

            btnOrder = new Button {
                Text              = "В корзину",
                FontSize          = Utils.GetSize(15),
                TextColor         = Color.White,
                BackgroundColor   = ApplicationStyle.RedColor,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BorderRadius      = 0,
            };
            btnOrder.Clicked += BasketButtonClick;

            SetButtom();

            StackLayout layoutBody = new StackLayout {
                Spacing  = 5,
                Padding  = new Thickness(8, 5),
                Children =
                {
                    btnTableSize,
                    lblDescription
                }
            };

            Image imgClock = new Image {
                Source        = Device.OnPlatform("Catalog/clock_", "clock", "clock"),
                HeightRequest = Utils.GetSize(18, 1),
            };
            MyLabel lblTitleTimer = new MyLabel {
                TextColor       = ApplicationStyle.GreenColor,
                Text            = "Расписание доступности товара:",
                VerticalOptions = LayoutOptions.CenterAndExpand,
                FontSize        = Utils.GetSize(14),
                IsUnderline     = true,
            };

            layoutTitleTimer = new StackLayout {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Orientation       = StackOrientation.Horizontal,
                Padding           = new Thickness(8, 0),
                Children          =
                {
                    imgClock,
                    lblTitleTimer
                }
            };
            TapGestureRecognizer tapLayoutTitle = new TapGestureRecognizer();

            tapLayoutTitle.Tapped += OnSelectTimer;
            layoutTitleTimer.GestureRecognizers.Add(tapLayoutTitle);

            gridTime = new Grid {
                Padding           = new Thickness(8, 0),
                ColumnSpacing     = Utils.GetSize(30),
                RowSpacing        = 0,
                IsVisible         = false,
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = GridLength.Auto
                    },
                    new ColumnDefinition {
                        Width = GridLength.Auto
                    },
                }
            };
            lblTime = new Label();

            layoutContent = new StackLayout {
                Padding         = new Thickness(0, 0, 0, 8),
                VerticalOptions = LayoutOptions.FillAndExpand,
                Spacing         = 0,
                Children        =
                {
                    lblArticle,
                    artLine,
                    imgGrid,
                    lblName,
                    layoutPrice,
                    layoutSize,
                    layoutBody,
                    layoutTitleTimer,
                    gridTime
                }
            };

            scrollView = new ScrollView {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Content         = layoutContent
            };

            mainGrid = new Grid {
                RowSpacing      = 0,
                VerticalOptions = LayoutOptions.FillAndExpand,
                RowDefinitions  =
                {
                    new RowDefinition {
                        Height = new GridLength(100, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = Utils.GetSize(50)
                    },
                }
            };
            mainGrid.Children.Add(scrollView, 0, 0);
            mainGrid.Children.Add(layoutBottom, 0, 1);

            Content = mainGrid;

            VerticalOptions = LayoutOptions.FillAndExpand;
        }
Beispiel #45
0
        public MainPage()
        {
            InitializeComponent();
            listViewModel = new ContactsViewModel();
            Grid mainGrid = new Grid()
            {
            };

            mainGrid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            mainGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });

            Grid pickerStack = new Grid()
            {
            };

            pickerStack.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            pickerStack.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            pickerStack.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            pickerStack.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(30)
            });
            pickerStack.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(40)
            });

            Label fromDateLabel = new Label()
            {
                Text = "From Date ", FontSize = 18
            };

            fromDatePicker = new DatePicker()
            {
            };
            fromDatePicker.MinimumDate = new DateTime(2018, 1, 1);
            fromDatePicker.MaximumDate = new DateTime(2022, 12, 31);
            fromDatePicker.Date        = new DateTime(2018, 1, 1);
            pickerStack.Children.Add(fromDateLabel, 0, 0);
            pickerStack.Children.Add(fromDatePicker, 0, 1);

            Label toDateLabel = new Label()
            {
                Text = "To Date ", FontSize = 18
            };

            toDatePicker = new DatePicker()
            {
            };
            toDatePicker.MinimumDate = new DateTime(2018, 1, 1);
            toDatePicker.MaximumDate = new DateTime(2022, 12, 31);
            toDatePicker.Date        = new DateTime(2018, 1, 1);
            pickerStack.Children.Add(toDateLabel, 1, 0);
            pickerStack.Children.Add(toDatePicker, 1, 1);

            Label doctorNameLabel = new Label()
            {
                Text = "Select Name", FontSize = 18
            };
            SfComboBox comboBox = new SfComboBox()
            {
                BorderColor = Color.Transparent, HeightRequest = 50, DisplayMemberPath = "DoctorName"
            };

            comboBox.DataSource = listViewModel.NameCollection;

            pickerStack.Children.Add(doctorNameLabel, 2, 0);
            pickerStack.Children.Add(comboBox, 2, 1);

            listview = new SfListView()
            {
                SelectionMode = SelectionMode.None, AutoFitMode = AutoFitMode.Height
            };
            listview.BindingContext = listViewModel;
            listview.ItemsSource    = listViewModel.ContactsInfo;
            listview.ItemTemplate   = new DataTemplate(() =>
            {
                Grid mainGridList = new Grid()
                {
                };
                mainGridList.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(80)
                });
                mainGridList.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(30)
                });
                mainGridList.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });

                Grid gridOne = new Grid();
                gridOne.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Auto
                });
                gridOne.Padding = new Thickness(0, 25, 0, 0);
                Label dateLabel = new Label()
                {
                    TextColor = Color.Teal,
                    FontSize  = 12,
                };
                Binding binding = new Binding("Date");
                dateLabel.SetBinding(Label.TextProperty, binding);
                gridOne.Children.Add(dateLabel);

                Grid gridTwo            = new Grid();
                gridTwo.VerticalOptions = LayoutOptions.StartAndExpand;
                BoxView box             = new BoxView()
                {
                    VerticalOptions   = LayoutOptions.CenterAndExpand,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    WidthRequest      = 2,
                    BackgroundColor   = Color.LightGray
                };
                if (Device.RuntimePlatform == Device.UWP)
                {
                    box.HeightRequest = 150;
                }
                else if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.iOS)
                {
                    box.HeightRequest = 160;
                }
                Grid childGrid = new Grid()
                {
                    VerticalOptions = LayoutOptions.Start
                };
                Image image = new Image()
                {
                    VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, WidthRequest = 95
                };
                if (Device.RuntimePlatform == Device.UWP)
                {
                    image.HeightRequest = 30;
                }
                else if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.iOS)
                {
                    image.HeightRequest = 35;
                }
                Binding bind = new Binding("ContactImage");
                image.SetBinding(Image.SourceProperty, bind);
                childGrid.Children.Add(image);
                gridTwo.Children.Add(box);
                gridTwo.Children.Add(childGrid);

                Grid gridThree = new Grid()
                {
                    Padding = new Thickness(5), ColumnSpacing = -20
                };
                gridOne.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
                gridTwo.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });

                Grid contentGrid = new Grid()
                {
                    Padding = 5, RowSpacing = 0, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand
                };
                contentGrid.BackgroundColor = Color.FromRgb(192, 238, 252);
                contentGrid.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });
                StackLayout stackContent = new StackLayout()
                {
                    Spacing = 5
                };
                Label detailsLabel = new Label()
                {
                    Text = "Details", FontSize = 15
                };
                stackContent.Children.Add(detailsLabel);
                StackLayout stacktwo = new StackLayout()
                {
                    Spacing = -2
                };
                Label contentLabel = new Label()
                {
                    Text = "Attended patient details of the ", FontSize = 12
                };
                Label monthLabel = new Label()
                {
                    FontSize = 12
                };
                monthLabel.SetBinding(Label.TextProperty, new Binding("Months"));
                stacktwo.Children.Add(contentLabel);
                stacktwo.Children.Add(monthLabel);
                stackContent.Children.Add(stacktwo);
                Grid DoctorPatientGrid = new Grid()
                {
                    HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center
                };
                DoctorPatientGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Auto
                });
                DoctorPatientGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
                DoctorPatientGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(20)
                });
                DoctorPatientGrid.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });
                Label doctor = new Label()
                {
                    Text = "Doctor Name", FontSize = 12
                };
                Label Patient = new Label()
                {
                    Text = "Patient Details", FontSize = 12
                };
                Label doctorName = new Label()
                {
                    FontSize = 12
                };
                doctorName.SetBinding(Label.TextProperty, new Binding("DoctorName"));
                Label PatienteName = new Label()
                {
                    FontSize = 12
                };
                PatienteName.SetBinding(Label.TextProperty, new Binding("PatientDetail"));
                DoctorPatientGrid.Children.Add(doctor, 0, 0);
                DoctorPatientGrid.Children.Add(Patient, 0, 1);
                DoctorPatientGrid.Children.Add(doctorName, 1, 0);
                DoctorPatientGrid.Children.Add(PatienteName, 1, 1);
                stackContent.Children.Add(DoctorPatientGrid);
                contentGrid.Children.Add(stackContent);
                gridThree.Children.Add(contentGrid, 0, 0);

                mainGridList.Children.Add(gridOne, 0, 0);
                mainGridList.Children.Add(gridTwo, 1, 0);
                mainGridList.Children.Add(gridThree, 2, 0);
                return(mainGridList);
            });

            mainGrid.Children.Add(pickerStack, 0, 0);
            mainGrid.Children.Add(listview, 0, 1);
            this.Content = mainGrid;

            listview.Loaded += ListView_Loaded;

            fromDatePicker.DateSelected      += FromPicker_DateSelected;
            toDatePicker.DateSelected        += ToPicker_DateSelected;
            comboBox.FilterCollectionChanged += NameComboBox_FilterCollectionChanged;
        }
        public Registro_Page(UsuarioRegistroViewModel usuarioRegistroViewModel)
        {
            this._usuarioRegistroViewModel = usuarioRegistroViewModel;

            #region Layout

            l_email = new Label()
            {
                Text = "E-mail", HorizontalOptions = LayoutOptions.Start
            };
            l_senha = new Label()
            {
                Text = "Senha", HorizontalOptions = LayoutOptions.Start
            };
            l_confirmacaoSenha = new Label()
            {
                Text = "Confirmação da Senha", HorizontalOptions = LayoutOptions.Start
            };
            l_nome = new Label()
            {
                Text = "Nome", HorizontalOptions = LayoutOptions.Start
            };
            l_sobrenome = new Label()
            {
                Text = "Sobrenome", HorizontalOptions = LayoutOptions.Start
            };
            l_razaosocial = new Label()
            {
                Text = "Razão Social", HorizontalOptions = LayoutOptions.Start
            };
            l_telefone1 = new Label()
            {
                Text = "Telefone Principal", HorizontalOptions = LayoutOptions.Start
            };
            l_telefone2 = new Label()
            {
                Text = "Telefone Opcional ", HorizontalOptions = LayoutOptions.Start
            };
            l_documento = new Label()
            {
                Text = "Documento(CPF ou CNPJ)", HorizontalOptions = LayoutOptions.Start
            };

            e_email = new Entry()
            {
                Keyboard = Keyboard.Email
            };
            e_senha = new Entry()
            {
                IsPassword = true
            };
            e_confirmacaoSenha = new Entry()
            {
                IsPassword = true
            };
            e_nome        = new Entry();;
            e_sobrenome   = new Entry();
            e_razaosocial = new Entry();
            e_telefone1   = new Entry()
            {
                Keyboard = Keyboard.Telephone
            };
            e_telefone2 = new Entry()
            {
                Keyboard = Keyboard.Telephone
            };
            e_documento = new Entry()
            {
            };

            b_registrar = new Button()
            {
                Text = "Registrar", VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.End
            };

            #endregion

            b_registrar.Clicked += B_registrar_Clicked;

            sl_principal = new StackLayout()
            {
                Padding  = Util.Constantes.PADDINGDEFAULT,
                Children =
                {
                    l_email
                    , e_email
                    , l_senha
                    , e_senha
                    , l_confirmacaoSenha
                    , e_confirmacaoSenha
                    , l_nome
                    , e_nome
                    , l_sobrenome
                    , e_sobrenome
                    , l_razaosocial
                    , e_razaosocial
                    , l_telefone1
                    , e_telefone1
                    , l_telefone2
                    , e_telefone2
                    , l_documento
                    , e_documento
                    , b_registrar
                }
            };

            this.Content = sl_principal;
        }
Beispiel #47
0
            public ModalActivityIndicator()
            {
                this.SetBinding(IsVisibleProperty, "IsBusy");
                this.SetBinding(IsEnabledProperty, "IsBusy");

                Children.Add(
                    view: new BoxView
                {
                    Opacity         = .4,
                    BackgroundColor = Color.FromHex("#ccc")
                },
                    widthConstraint: Microsoft.Maui.Controls.Constraint.RelativeToParent((parent) =>
                {
                    return(parent.Width);
                }),
                    heightConstraint: Microsoft.Maui.Controls.Constraint.RelativeToParent((parent) =>
                {
                    return(parent.Height);
                })
                    );

                var content = new StackLayout
                {
                    BackgroundColor = Color.White,
                    Spacing         = 10,
                    Padding         = new Thickness(
                        horizontalSize: 10,
                        verticalSize: 20
                        )
                };

                var activityIndicator = new ActivityIndicator {
                    IsRunning = true
                };

                activityIndicator.SetBinding(ActivityIndicator.ColorProperty, "Color");

                content.Children.Add(activityIndicator);
                var label = new Label {
                    HorizontalOptions = LayoutOptions.CenterAndExpand
                };

                label.SetBinding(Label.TextProperty, "BusyText");
                label.SetBinding(Label.TextColorProperty, "Color");

                content.Children.Add(label);

                Children.Add(
                    view: content,
                    widthConstraint: Microsoft.Maui.Controls.Constraint.RelativeToParent((parent) =>
                {
                    return(parent.Width / 2);
                }),
                    heightConstraint: Microsoft.Maui.Controls.Constraint.RelativeToParent((parent) =>
                {
                    return(parent.Width / 3);
                }),
                    xConstraint: Microsoft.Maui.Controls.Constraint.RelativeToParent((parent) =>
                {
                    return(parent.Width / 4);
                }),
                    yConstraint: Microsoft.Maui.Controls.Constraint.RelativeToParent((parent) =>
                {
                    return((parent.Height / 2) - (parent.Width / 6));
                })
                    );
            }
Beispiel #48
0
        public RegistrationPage(ViewModelBase viewModel) : base(viewModel)
        {
            var countryPicker = new BindablePicker();

            countryPicker.Title = "Country";
            countryPicker.SetBinding(BindablePicker.ItemsSourceProperty, new Binding("Countries"));
            countryPicker.SetBinding(BindablePicker.SelectedItemProperty, new Binding("SelectedCountry", BindingMode.TwoWay));

            var sexPicker = new BindablePicker();

            sexPicker.Title = "Sex";
            sexPicker.SetBinding(BindablePicker.ItemsSourceProperty, new Binding("Sexes"));
            sexPicker.SetBinding(BindablePicker.SelectedItemProperty, new Binding("SelectedSex", BindingMode.TwoWay));

            var agePicker = new BindablePicker();

            agePicker.Title = "Age";
            agePicker.SetBinding(BindablePicker.ItemsSourceProperty, new Binding("Ages"));
            agePicker.SetBinding(BindablePicker.SelectedItemProperty, new Binding("SelectedAge", BindingMode.TwoWay));

            var header = new Label
            {
                Text = "Registration",
                Font = Font.BoldSystemFontOfSize(36),
                HorizontalOptions = LayoutOptions.Center
            };

            var button = new Button();

            button.Text = "Register";
            button.SetBinding(IsEnabledProperty, new Binding("IsBusy", converter: new InverterConverter()));
            button.SetBinding(Button.CommandProperty, new Binding("RegisterCommand"));
            button.BackgroundColor = Color.Green;
            button.TextColor       = Color.White;

            var nameEntry = new Entry
            {
                Keyboard    = Keyboard.Text,
                Placeholder = "Nickname",
            };

            nameEntry.SetBinding(Entry.TextProperty, new Binding("Name", BindingMode.TwoWay));

            var passwordEntry = new Entry
            {
                Keyboard    = Keyboard.Text,
                IsPassword  = true,
                Placeholder = "Password",
            };

            passwordEntry.SetBinding(Entry.TextProperty, new Binding("Password", BindingMode.TwoWay));


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

            Content = new StackLayout
            {
                Children =
                {
                    header,
                    nameEntry,
                    passwordEntry,
                    countryPicker,
                    sexPicker,
                    agePicker,
                    button
                }
            };
        }
Beispiel #49
0
        public FormEntryCell(
            string labelText,
            Keyboard entryKeyboard     = null,
            bool isPassword            = false,
            VisualElement nextElement  = null,
            bool useLabelAsPlaceholder = false,
            string imageSource         = null,
            Thickness?containerPadding = null,
            bool useButton             = false)
        {
            _nextElement = nextElement;

            if (!useLabelAsPlaceholder)
            {
                Label = new Label
                {
                    Text              = labelText,
                    FontSize          = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                    Style             = (Style)Application.Current.Resources["text-muted"],
                    HorizontalOptions = LayoutOptions.FillAndExpand
                };
            }

            Entry = new ExtendedEntry
            {
                Keyboard          = entryKeyboard,
                HasBorder         = false,
                IsPassword        = isPassword,
                AllowClear        = true,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                WidthRequest      = 1,
                FontSize          = Device.GetNamedSize(NamedSize.Medium, typeof(Entry))
            };

            if (useLabelAsPlaceholder)
            {
                Entry.Placeholder = labelText;
            }

            if (nextElement != null)
            {
                Entry.ReturnType = Enums.ReturnType.Next;
            }

            var imageStackLayout = new StackLayout
            {
                Padding           = containerPadding ?? new Thickness(15, 10),
                Orientation       = StackOrientation.Horizontal,
                Spacing           = 10,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand
            };

            if (imageSource != null)
            {
                _tgr = new TapGestureRecognizer();

                var theImage = new CachedImage
                {
                    Source            = imageSource,
                    HorizontalOptions = LayoutOptions.Start,
                    VerticalOptions   = LayoutOptions.Center,
                    WidthRequest      = 18,
                    HeightRequest     = 18
                };
                theImage.GestureRecognizers.Add(_tgr);

                imageStackLayout.Children.Add(theImage);
            }

            var formStackLayout = new StackLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand
            };

            if (Device.RuntimePlatform == Device.Android)
            {
                var deviceInfo = Resolver.Resolve <IDeviceInfoService>();
                if (useLabelAsPlaceholder)
                {
                    if (deviceInfo.Version < 21)
                    {
                        Entry.Margin = new Thickness(-9, 1, -9, 0);
                    }
                    else if (deviceInfo.Version == 21)
                    {
                        Entry.Margin = new Thickness(0, 4, 0, -4);
                    }
                }
                else
                {
                    Entry.AdjustMarginsForDevice();
                }

                if (containerPadding == null)
                {
                    imageStackLayout.AdjustPaddingForDevice();
                }
            }

            if (!useLabelAsPlaceholder)
            {
                formStackLayout.Children.Add(Label);
            }

            formStackLayout.Children.Add(Entry);
            imageStackLayout.Children.Add(formStackLayout);

            if (useButton)
            {
                Button = new ExtendedButton();
                imageStackLayout.Children.Add(Button);

                if (Device.RuntimePlatform == Device.Android)
                {
                    Button.Padding         = new Thickness(0);
                    Button.BackgroundColor = Color.Transparent;
                }
            }

            View = imageStackLayout;
        }
Beispiel #50
0
        public IndicatorCodeGallery()
        {
            Title = "IndicatorView Gallery";

            On <iOS>().SetLargeTitleDisplay(LargeTitleDisplayMode.Never);

            var nItems = 10;

            var layout = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Star
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    }
                }
            };

            var itemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Horizontal)
            {
                SnapPointsType      = SnapPointsType.MandatorySingle,
                SnapPointsAlignment = SnapPointsAlignment.Center
            };

            var itemTemplate = ExampleTemplates.CarouselTemplate();

            var carouselView = new CarouselView
            {
                ItemsLayout     = itemsLayout,
                ItemTemplate    = itemTemplate,
                BackgroundColor = Color.LightGray,
                AutomationId    = "TheCarouselView"
            };

            layout.Children.Add(carouselView);

            var generator = new ItemsSourceGenerator(carouselView, nItems, ItemsSourceType.ObservableCollection, false);

            layout.Children.Add(generator);

            generator.GenerateItems();

            var indicatorView = new IndicatorView
            {
                HorizontalOptions      = LayoutOptions.Center,
                Margin                 = new Thickness(12, 6, 12, 24),
                IndicatorColor         = Color.Gray,
                SelectedIndicatorColor = Color.Black,
                IndicatorsShape        = IndicatorShape.Square,
                AutomationId           = "TheIndicatorView"
            };

            IndicatorView.SetItemsSourceBy(indicatorView, carouselView);

            layout.Children.Add(indicatorView);

            var stckMaxVisible = new StackLayout {
                Orientation = StackOrientation.Horizontal
            };

            stckMaxVisible.Children.Add(new Label {
                VerticalOptions = LayoutOptions.Center, Text = "MaximumVisible"
            });
            var maxVisibleSlider = new Slider
            {
                Maximum         = nItems,
                Minimum         = 0,
                Value           = nItems,
                WidthRequest    = 150,
                BackgroundColor = Color.Pink
            };

            stckMaxVisible.Children.Add(maxVisibleSlider);

            maxVisibleSlider.ValueChanged += (s, e) =>
            {
                var maximumVisible = (int)maxVisibleSlider.Value;
                indicatorView.MaximumVisible = maximumVisible;
            };

            layout.Children.Add(stckMaxVisible);

            var stckColors = new StackLayout {
                Orientation = StackOrientation.Horizontal
            };

            stckColors.Children.Add(new Label {
                VerticalOptions = LayoutOptions.Center, Text = "IndicatorColor"
            });

            var colors = new List <string>
            {
                "Black",
                "Blue",
                "Red"
            };

            var colorsPicker = new Picker
            {
                ItemsSource  = colors,
                WidthRequest = 150
            };

            colorsPicker.SelectedIndex = 0;

            colorsPicker.SelectedIndexChanged += (s, e) =>
            {
                var selectedIndex = colorsPicker.SelectedIndex;

                switch (selectedIndex)
                {
                case 0:
                    indicatorView.IndicatorColor = Color.Black;
                    break;

                case 1:
                    indicatorView.IndicatorColor = Color.Blue;
                    break;

                case 2:
                    indicatorView.IndicatorColor = Color.Red;
                    break;
                }
            };

            stckColors.Children.Add(colorsPicker);

            layout.Children.Add(stckColors);

            var stckTemplate = new StackLayout {
                Orientation = StackOrientation.Horizontal
            };

            stckTemplate.Children.Add(new Label {
                VerticalOptions = LayoutOptions.Center, Text = "IndicatorTemplate"
            });

            var templates = new List <string>
            {
                "Circle",
                "Square",
                "Template"
            };

            var templatePicker = new Picker
            {
                ItemsSource  = templates,
                WidthRequest = 150,
                TextColor    = Color.Black
            };

            templatePicker.SelectedIndexChanged += (s, e) =>
            {
                var selectedIndex = templatePicker.SelectedIndex;

                switch (selectedIndex)
                {
                case 0:
                    indicatorView.IndicatorTemplate = null;
                    indicatorView.IndicatorsShape   = IndicatorShape.Circle;
                    break;

                case 1:
                    indicatorView.IndicatorTemplate = null;
                    indicatorView.IndicatorsShape   = IndicatorShape.Square;
                    break;

                case 2:
                    indicatorView.IndicatorTemplate = ExampleTemplates.IndicatorTemplate();
                    break;
                }
            };

            templatePicker.SelectedIndex = 0;

            stckTemplate.Children.Add(templatePicker);

            layout.Children.Add(stckTemplate);

            Grid.SetRow(generator, 0);
            Grid.SetRow(stckMaxVisible, 1);
            Grid.SetRow(stckColors, 2);
            Grid.SetRow(stckTemplate, 3);
            Grid.SetRow(carouselView, 4);
            Grid.SetRow(indicatorView, 5);

            Content = layout;

            generator.CollectionChanged += (sender, e) =>
            {
                maxVisibleSlider.Maximum = generator.Count;
            };
        }
Beispiel #51
0
        public Styling()
        {
            normalGrid        = new GridLayout();
            normalGrid.width  = 950;
            normalGrid.height = 450;
            normalGrid.margin = new Thickness(0);

            textLayout            = new TextLayout();
            textLayout.fontFamily = new FontFamily("Cambria");

            imageLayout        = new ImageLayout();
            imageLayout.width  = 500;
            imageLayout.height = 250;
            imageLayout.margin = new Thickness(100, 50, 100, 50); //<----

            normalButton        = new ButtonLayout();
            normalButton.width  = 200;
            normalButton.height = 50;
            normalButton.margin = new Thickness(5); //<----

            menuButton        = new ButtonLayout();
            menuButton.width  = 250;
            menuButton.height = 50;
            menuButton.margin = new Thickness(0); //<----

            backButton        = new ButtonLayout();
            backButton.width  = 200;
            backButton.height = 50;
            backButton.margin = new Thickness(0); //<----

            textBoxLayout        = new TextBoxLayout();
            textBoxLayout.width  = 200;
            textBoxLayout.height = 25;
            textBoxLayout.margin = new Thickness(0); //<----

            normalLabel          = new LabelLayout();
            normalLabel.width    = 200;
            normalLabel.height   = 25;
            normalLabel.margin   = new Thickness(0); //<----
            normalLabel.fontSize = 12;

            titleLabel          = new LabelLayout();
            titleLabel.width    = 500;
            titleLabel.height   = 50;
            titleLabel.margin   = new Thickness(10);
            titleLabel.fontSize = 24;

            mainMenuStackPanel        = new StackLayout();
            mainMenuStackPanel.width  = 750;
            mainMenuStackPanel.height = 50;
            mainMenuStackPanel.margin = new Thickness(0, 37.5, 0, 37.5); //<----

            calculateStackPanel        = new StackLayout();
            calculateStackPanel.width  = 500;
            calculateStackPanel.height = 50;
            calculateStackPanel.margin = new Thickness(0, 0, 0, 0);

            inputFieldLayout        = new StackLayout();
            inputFieldLayout.width  = 50;
            inputFieldLayout.height = 200;
            inputFieldLayout.margin = new Thickness(0, 0, 0, 0);
        }
Beispiel #52
0
        public override View GetView(int index)
        {
            if (base.GetView(index) == null)
            {
                _selectedItems.Clear();
                _itemLabels.Clear();

                StackLayout itemLabelStack = new StackLayout
                {
                    Orientation       = StackOrientation.Vertical,
                    VerticalOptions   = LayoutOptions.Start,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Padding           = new Thickness(30, 10, 0, 10)
                };

                List <object> itemList = RandomizeItemOrder ? _items.OrderBy(item => Guid.NewGuid()).ToList() : _items;

                for (int i = 0; i < itemList.Count; ++i)
                {
                    object item = itemList[i];

                    Label itemLabel = new Label
                    {
                        FontSize          = 20,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        BindingContext    = item

                                            // set the style ID on the view so that we can retrieve it when unit testing
                        #if UNIT_TESTING
                        , StyleId = Name + " " + i
                        #endif
                    };

                    _itemLabels.Add(itemLabel);

                    itemLabel.SetBinding(Label.TextProperty, _textBindingPropertyPath, stringFormat: "{0}");

                    TapGestureRecognizer tapRecognizer = new TapGestureRecognizer
                    {
                        NumberOfTapsRequired = 1
                    };

                    Color defaultBackgroundColor = itemLabel.BackgroundColor;

                    tapRecognizer.Tapped += (o, e) =>
                    {
                        if (!itemLabel.IsEnabled)
                        {
                            return;
                        }

                        if (_selectedItems.Contains(item))
                        {
                            _selectedItems.Remove(item);
                        }
                        else
                        {
                            _selectedItems.Add(item);
                        }

                        if (!_multiselect)
                        {
                            _selectedItems.RemoveAll(selectedItem => selectedItem != item);
                        }

                        foreach (Label label in _itemLabels)
                        {
                            label.BackgroundColor = _selectedItems.Contains(label.BindingContext) ? Color.Accent : defaultBackgroundColor;
                        }

                        Complete = (Value as List <object>).Count > 0;
                    };

                    itemLabel.GestureRecognizers.Add(tapRecognizer);

                    // add invisible separator between items for fewer tapping errors
                    if (itemLabelStack.Children.Count > 0)
                    {
                        itemLabelStack.Children.Add(new BoxView {
                            Color = Color.Transparent, HeightRequest = 5
                        });
                    }

                    itemLabelStack.Children.Add(itemLabel);
                }

                _label = CreateLabel(index);

                base.SetView(new StackLayout
                {
                    Orientation     = StackOrientation.Vertical,
                    VerticalOptions = LayoutOptions.Start,
                    Children        = { _label, itemLabelStack }
                });
            }
            else
            {
                _label.Text = GetLabelText(index);  // if the view was already initialized, just update the label since the index might have changed.
            }
            return(base.GetView(index));
        }
Beispiel #53
0
        public Login()
        {
            switch_login = new Switch();
            //CREACION DE LOS EVENTOS ENTRE PAGINAS
            //  TapGestureRecognizer tapLogin = new TapGestureRecognizer();



            // 1. LAYOUT (VIEW DEL LOGIN)
            StackLayout viewLogin   = new StackLayout();
            ScrollView  scrollLogin = new ScrollView();

            // 2. CREACION DE CONTROLES
            Label labelTitle = new Label();

            entryUser = new Entry();
            entryPass = new Entry();
            Button btnLogin = new Button();

            labelRegistrarUsuario    = new Label();
            labelRecuperarContraseña = new Label();


            // 3. PROPIEDADES DE LOS CONTROLES
            scrollLogin.BackgroundColor = Color.FromHex("#FF007ACC");

            viewLogin.VerticalOptions   = LayoutOptions.CenterAndExpand;
            viewLogin.HorizontalOptions = LayoutOptions.CenterAndExpand;

            labelTitle.BackgroundColor         = Color.Black;
            labelTitle.TextColor               = Color.White;
            labelTitle.VerticalTextAlignment   = TextAlignment.Center;
            labelTitle.HorizontalTextAlignment = TextAlignment.Center;
            labelTitle.FontSize = 20;
            labelTitle.Text     = "**  LOGIN  **";


            entryUser.Placeholder       = "Usuario";
            entryUser.VerticalOptions   = LayoutOptions.CenterAndExpand;
            entryUser.HorizontalOptions = LayoutOptions.CenterAndExpand;
            entryUser.WidthRequest      = 355;
            entryUser.Text = "";

            entryPass.Placeholder       = "Contraseña";
            entryPass.IsPassword        = true;
            entryPass.VerticalOptions   = LayoutOptions.CenterAndExpand;
            entryPass.HorizontalOptions = LayoutOptions.CenterAndExpand;
            entryPass.WidthRequest      = 355;
            entryPass.Text = "";

            // activity.IsEnabled = false;
            activity.IsRunning = true;
            activity.IsVisible = false;


            btnLogin.Text            = "Ingresa";
            btnLogin.BackgroundColor = Color.LightGray;
            btnLogin.TextColor       = Color.Black;
            btnLogin.Clicked        += BtnLogin_Clicked1;



            labelRegistrarUsuario.FontSize                = 16;
            labelRegistrarUsuario.TextColor               = Color.White;
            labelRegistrarUsuario.VerticalTextAlignment   = TextAlignment.Center;
            labelRegistrarUsuario.HorizontalTextAlignment = TextAlignment.Center;
            labelRegistrarUsuario.Text = "Crear Cuenta";

            tapRegistrarUsuario.Tapped += TapRegistrarUsuario_Tapped;
            labelRegistrarUsuario.GestureRecognizers.Add(tapRegistrarUsuario);


            labelRecuperarContraseña.FontSize                = 16;
            labelRecuperarContraseña.TextColor               = Color.White;
            labelRecuperarContraseña.VerticalTextAlignment   = TextAlignment.Center;
            labelRecuperarContraseña.HorizontalTextAlignment = TextAlignment.Center;
            labelRecuperarContraseña.Text = "Recuperar Contraseña";

            tapRecuperarContraseña.Tapped += TapRecuperarContraseña_Tapped;
            labelRecuperarContraseña.GestureRecognizers.Add(tapRecuperarContraseña);



            // 4. SE AGREGA EL CONTENIDO O CONTROLES A LA VISTA/LAYOUT
            viewLogin.Children.Add(labelTitle);
            viewLogin.Children.Add(entryUser);
            viewLogin.Children.Add(entryPass);
            viewLogin.Children.Add(activity);
            viewLogin.Children.Add(switch_login);
            viewLogin.Children.Add(btnLogin);
            viewLogin.Children.Add(labelRegistrarUsuario);
            viewLogin.Children.Add(labelRecuperarContraseña);


            // 5. EL CONTENIDO ES VISUALIZADO EN EL STACKLAYOUT
            scrollLogin.Content = viewLogin;
            Content             = scrollLogin;
        }
Beispiel #54
0
        void CreateUI()
        {
            stack = new StackLayout
            {
                Orientation     = StackOrientation.Vertical,
                WidthRequest    = App.ScreenSize.Width,
                HeightRequest   = App.ScreenSize.Height - 48,
                VerticalOptions = LayoutOptions.StartAndExpand
            };

            innerStack = new StackLayout
            {
                VerticalOptions     = LayoutOptions.Start,
                HorizontalOptions   = LayoutOptions.Start,
                Orientation         = StackOrientation.Horizontal,
                MinimumWidthRequest = App.ScreenSize.Width,
                WidthRequest        = App.ScreenSize.Width,
                HeightRequest       = App.ScreenSize.Height - 48,
                InputTransparent    = true,
            };

            var topbar = new TopBar(true, "", this, 1, "burger_menu", "refresh_icon", innerStack).CreateTopBar();

            stack.HeightRequest = App.ScreenSize.Height - topbar.HeightRequest;

            var map = new CustomMap
            {
                WidthRequest    = App.ScreenSize.Width,
                HeightRequest   = App.ScreenSize.Height,
                VerticalOptions = LayoutOptions.FillAndExpand,
                MapType         = MapType.Hybrid,
            };

            map.RouteCoordinates = ViewModel.LocData;
            map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(ViewModel.SelectedJourney.GPSData[0].Latitude,
                                                                      ViewModel.SelectedJourney.GPSData[0].Longitude),
                                                         Distance.FromMiles(1)));

            map.RouteCoordinates = ViewModel.LocData;
            map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(ViewModel.JourneyData.GPSData[0].Latitude, ViewModel.JourneyData.GPSData[0].Longitude), Distance.FromMiles(1)));
            map.CustomPins = new List <CustomPin>();
            if (ViewModel.JourneyEvents != null)
            {
                if (ViewModel.JourneyEvents.Count != 0)
                {
                    foreach (var je in ViewModel.JourneyEvents)
                    {
                        var pin = new CustomPin
                        {
                            Pin = new Pin
                            {
                                Position = new Position(je.Latitude, je.Longitude),
                                Type     = PinType.Place,
                                Address  = je.Location.Replace('\n', ' '),
                                Label    = $"Speed {je.Speed} (Road speed {je.RoadSpeed})"
                            },
                            Id = je.Id.ToString()
                        };
                        map.CustomPins.Add(pin);
                        map.Pins.Add(pin.Pin);
                    }
                }
            }


            var alertEvent   = ViewModel.SelectedEvent;
            var alertJourney = ViewModel.SelectedJourney;

            alertView = new NotificationMapFrame().GenerateMapAlertFrame(alertEvent.Speed, alertEvent.RoadSpeed,
                                                                         alertEvent.Location, alertEvent.DateCreated.TimeOfDay.ToString(),
                                                                         alertEvent.DateCreated.ToString("ddd dd-MMM-yyyy"), ViewModel.EventType);

            var xpos      = App.ScreenSize.Width - (App.ScreenSize.Width * .9) / 2;
            var absLayout = new RelativeLayout();

            absLayout.Children.Add(map,
                                   Constraint.Constant(0),
                                   Constraint.Constant(0),
                                   Constraint.RelativeToParent((parent) => App.ScreenSize.Width),
                                   Constraint.RelativeToParent((parent) => App.ScreenSize.Height));
            absLayout.Children.Add(alertView,
                                   Constraint.Constant(0),
                                   Constraint.Constant(App.ScreenSize.Height * .1),
                                   Constraint.RelativeToParent((parent) => App.ScreenSize.Width),
                                   Constraint.RelativeToParent((parent) => App.ScreenSize.Height));

            stack.Children.Add(absLayout);
            innerStack.Children.Add(stack);
            innerStack.TranslationY = -6;

            var masterStack = new StackLayout
            {
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Start,
                Children          =
                {
                    new StackLayout
                    {
                        VerticalOptions   = LayoutOptions.Start,
                        HorizontalOptions = LayoutOptions.Start,
                        WidthRequest      = App.ScreenSize.Width,
                        Children          = { topbar }
                    },
                    innerStack
                }
            };

            Content = masterStack;
        }
Beispiel #55
0
        public HomePage()
        {
            try{
                Title = "REKENING STAND";

                #region filter
                txtAlamatStand = new cxEntry {
                    Placeholder          = "Cari stand",
                    PlaceholderTextColor = Color.White,
                    TextColor            = Color.White,
                    FontSize             = Shared.Settings.Styles.Sizes.Font.Base,
                    BackgroundColor      = Color.Transparent,
                    HorizontalOptions    = LayoutOptions.FillAndExpand,
                    VerticalOptions      = LayoutOptions.Center,
                    FontFamily           = Shared.Settings.Styles.Fonts.BaseLight
                };

                txtNmped = new cxEntry {
                    Placeholder          = "Cari pedagang",
                    PlaceholderTextColor = Color.White,
                    TextColor            = Color.White,
                    FontSize             = Shared.Settings.Styles.Sizes.Font.Base,
                    BackgroundColor      = Color.Transparent,
                    HorizontalOptions    = LayoutOptions.FillAndExpand,
                    VerticalOptions      = LayoutOptions.Center,
                    FontFamily           = Shared.Settings.Styles.Fonts.BaseLight
                };

                btnCariStand = new cxButton {
                    Text              = "Cari",
                    TextColor         = Color.White,
                    FontSize          = 14,
                    HorizontalOptions = LayoutOptions.EndAndExpand,
                    VerticalOptions   = LayoutOptions.Center,
                    BackgroundColor   = Color.FromHex("7fffffff"),
                    BorderColor       = Color.White,
                    Alignment         = TextAlignment.Center,
                };

                cariStandLayout = new StackLayout {
                    Spacing           = 0,
                    Padding           = new Thickness(20, 5, 20, 5),
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.Start,
                    BackgroundColor   = Shared.Settings.Styles.Colors.Background.LightBlue,
                    Children          =
                    {
                        txtAlamatStand,
                        txtNmped
                    }
                };
                #endregion

                filterLayout = new StackLayout {
                    Spacing           = 0,
                    Padding           = new Thickness(0, 0, 20, 0),
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.Start,
                    BackgroundColor   = Shared.Settings.Styles.Colors.Background.LightBlue,
                    Orientation       = StackOrientation.Horizontal,
                    Children          =
                    {
                        cariStandLayout,
                        btnCariStand
                    }
                };

                #region selected item
                txtSelectedItem = new cxLabel {
                    Text              = "0",
                    FontSize          = Shared.Settings.Styles.Sizes.Font.Base,
                    TextColor         = Color.Black,
                    FontFamily        = Shared.Settings.Styles.Fonts.BaseLight,
                    FontAttributes    = FontAttributes.Bold,
                    HorizontalOptions = LayoutOptions.Start,
                    VerticalOptions   = LayoutOptions.Center
                };

                txtSelectedItemDesc = new cxLabel {
                    Text              = " stand ditandai",
                    FontSize          = Shared.Settings.Styles.Sizes.Font.Base,
                    TextColor         = Color.Black,
                    FontFamily        = Shared.Settings.Styles.Fonts.BaseLight,
                    HorizontalOptions = LayoutOptions.Start,
                    VerticalOptions   = LayoutOptions.Center
                };

                selectedItemLayout = new StackLayout {
                    Spacing           = 0,
                    Padding           = new Thickness(0, 5, 0, 5),
                    BackgroundColor   = Color.White,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    VerticalOptions   = LayoutOptions.End,
                    Orientation       = StackOrientation.Horizontal,
                    Children          =
                    {
                        txtSelectedItem,
                        txtSelectedItemDesc
                    }
                };
                #endregion

                #region btnNextLayout
                btnLanjutLayout = new StackLayout {
                    Spacing           = 0,
                    Padding           = new Thickness(0, 5, 0, 5),
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.End,
                    HeightRequest     = 50,
                    BackgroundColor   = Shared.Settings.Styles.Colors.Background.LightBlue,
                    Children          =
                    {
                        new Label {
                            Text              = "Lanjut",
                            FontSize          = 20,
                            TextColor         = Color.White,
                            FontFamily        = Shared.Settings.Styles.Fonts.BaseLight,
                            HorizontalOptions = LayoutOptions.Center,
                            VerticalOptions   = LayoutOptions.Center
                        }
                    }
                };
                btnLanjutLayout.IsVisible = false;
                #endregion

                StandSearchResultLV = new Shared.Classes.Components.ListViews.SearchResult(typeof(Shared.Modules.DataTemplates.RekeningStand.StandSearchResult));
                StandSearchResultLV.IsPullToRefreshEnabled = false;

                allLayout = new StackLayout {
                    Spacing           = 0,
                    Padding           = new Thickness(0, 0, 0, 0),
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    BackgroundColor   = Color.White,
                    Children          =
                    {
                        filterLayout,
                        new StackLayout {
                            Spacing           = 0,
                            Padding           = new Thickness(20,       0, 20, 0),
                            VerticalOptions   = LayoutOptions.FillAndExpand,
                            HorizontalOptions = LayoutOptions.FillAndExpand,
                            BackgroundColor   = Color.White,
                            Children          =
                            {
                                StandSearchResultLV
                            }
                        },
                        selectedItemLayout,
                        btnLanjutLayout
                    }
                };

                Content = allLayout;

                var tool = Shared.Classes.Components.Toolbar.Toolbar.Secondary(
                    "Reset",
                    "",
                    new Command(() =>
                {
                    txtAlamatStand.Text = "";
                    txtNmped.Text       = "";
                })
                    );

                var tool1 = Shared.Classes.Components.Toolbar.Toolbar.Secondary(
                    "Hapus Semua Tanda",
                    "",
                    new Command(() =>
                {
                    contSelectedStand.Clear();
                    txtSelectedItem.Text         = contSelectedStand.Count.ToString();
                    selectedItemLayout.IsVisible = false;
                })
                    );

                ToolbarItems.Add(tool);
                ToolbarItems.Add(tool1);

                StandSearchResultLV.ItemSelected += (sender, e) => {
                    OnSelection(sender, e);
                };

                btnCariStand.Clicked += async(sender, e) => {
                    MessagingCenter.Send <ParamPasser> (new ParamPasser()
                    {
                        DateParameter = DateTime.Now
                    }, "Timer");
                    cachedAccessCredential = await Shared.Classes.Cache.cxCache.AccessCredential.Collect();

                    GetRekStand(cachedAccessCredential.Kdpasar, txtAlamatStand.Text, txtNmped.Text);
                };


                var btnLanjutTap = new TapGestureRecognizer();
                btnLanjutTap.NumberOfTapsRequired = 1;
                btnLanjutTap.Tapped += async(s, e) => {
                    MessagingCenter.Send <ParamPasser> (new ParamPasser()
                    {
                        DateParameter = DateTime.Now
                    }, "Timer");
                    if (contSelectedStand.Count >= 1)
                    {
                        cachedAccessCredential = await Shared.Classes.Cache.cxCache.AccessCredential.Collect();

                        await Navigation.PushAsync(new Shared.Modules.Pages.RekeningStand.StandReview(contSelectedStand, cachedAccessCredential.Kdpasar, "", ""), true);
                    }
                    else
                    {
                        Shared.Settings.Panels.Alert.Display("Mohon tandai setidaknya satu stand", "Gagal Melanjutkan Proses", "OK");
                    }
                };
                btnLanjutLayout.GestureRecognizers.Add(btnLanjutTap);
            }catch (Exception ex) {
                Shared.Services.Logs.Insights.Send("Layout", ex);
                throw ex;
            }
        }
Beispiel #56
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Mapsui.UI.Forms.MapView"/> class.
        /// </summary>
        public MapView()
        {
            MyLocationEnabled = false;
            MyLocationFollow  = false;

            IsClippedToBounds = true;

            _mapControl = new MapControl()
            {
                UseDoubleTap = false
            };
            _mapMyLocationLayer = new MyLocationLayer(this)
            {
                Enabled = true
            };
            _mapPinLayer = new Layer(PinLayerName)
            {
                IsMapInfoLayer = true
            };
            _mapDrawableLayer = new Layer(DrawableLayerName)
            {
                IsMapInfoLayer = true
            };

            // Get defaults from MapControl
            RotationLock = Lock.RotationLock;
            ZoomLock     = Lock.ZoomLock;
            PanLock      = Lock.PanLock;

            // Add some events to _mapControl
            _mapControl.Viewport.ViewportChanged += HandlerViewportChanged;
            _mapControl.ViewportInitialized      += HandlerViewportInitialized;
            _mapControl.Info            += HandlerInfo;
            _mapControl.PropertyChanged += HandlerMapControlPropertyChanged;
            _mapControl.SingleTap       += HandlerTap;
            _mapControl.DoubleTap       += HandlerTap;
            _mapControl.LongTap         += HandlerLongTap;
            _mapControl.Hovered         += HandlerHover;
            _mapControl.TouchMove       += (s, e) =>
            {
                Device.BeginInvokeOnMainThread(() => MyLocationFollow = false);
            };

            AbsoluteLayout.SetLayoutBounds(_mapControl, new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(_mapControl, AbsoluteLayoutFlags.All);

            _pictMyLocationNoCenter = (new SkiaSharp.Extended.Svg.SKSvg()).Load(Mapsui.Utilities.EmbeddedResourceLoader.Load("Images.LocationNoCenter.svg", typeof(MapView)));
            _pictMyLocationCenter   = (new SkiaSharp.Extended.Svg.SKSvg()).Load(Mapsui.Utilities.EmbeddedResourceLoader.Load("Images.LocationCenter.svg", typeof(MapView)));

            _mapZoomInButton = new SvgButton(Mapsui.Utilities.EmbeddedResourceLoader.Load("Images.ZoomIn.svg", typeof(MapView)))
            {
                BackgroundColor = Color.White,
                WidthRequest    = 40,
                HeightRequest   = 40,
                Command         = new Command((object obj) => { _mapControl.Navigator.ZoomIn(); Refresh(); }),
            };

            _mapZoomOutButton = new SvgButton(Mapsui.Utilities.EmbeddedResourceLoader.Load("Images.ZoomOut.svg", typeof(MapView)))
            {
                BackgroundColor = Color.White,
                WidthRequest    = 40,
                HeightRequest   = 40,
                Command         = new Command((object obj) => { _mapControl.Navigator.ZoomOut(); Refresh(); }),
            };

            _mapSpacingButton1 = new Image {
                BackgroundColor = Color.Transparent, WidthRequest = 40, HeightRequest = 8
            };

            _mapMyLocationButton = new SvgButton(_pictMyLocationNoCenter)
            {
                BackgroundColor = Color.White,
                WidthRequest    = 40,
                HeightRequest   = 40,
                Command         = new Command((object obj) => MyLocationFollow = !MyLocationFollow),
            };

            _mapSpacingButton2 = new Image {
                BackgroundColor = Color.Transparent, WidthRequest = 40, HeightRequest = 8
            };

            _mapNorthingButton = new SvgButton(Mapsui.Utilities.EmbeddedResourceLoader.Load("Images.RotationZero.svg", typeof(MapView)))
            {
                BackgroundColor = Color.White,
                WidthRequest    = 40,
                HeightRequest   = 40,
                Command         = new Command((object obj) => Device.BeginInvokeOnMainThread(() => _mapControl.Navigator.RotateTo(0))),
            };

            _mapButtons = new StackLayout {
                BackgroundColor = Color.Transparent, Opacity = 0.8, Spacing = 0, IsVisible = true
            };

            _mapButtons.Children.Add(_mapZoomInButton);
            _mapButtons.Children.Add(_mapZoomOutButton);
            _mapButtons.Children.Add(_mapSpacingButton1);
            _mapButtons.Children.Add(_mapMyLocationButton);
            _mapButtons.Children.Add(_mapSpacingButton2);
            _mapButtons.Children.Add(_mapNorthingButton);

            AbsoluteLayout.SetLayoutBounds(_mapButtons, new Rectangle(0.95, 0.03, 40, 176));
            AbsoluteLayout.SetLayoutFlags(_mapButtons, AbsoluteLayoutFlags.PositionProportional);

            Content = new AbsoluteLayout
            {
                Children =
                {
                    _mapControl,
                    _mapButtons,
                }
            };

            _pins.CollectionChanged     += HandlerPinsOnCollectionChanged;
            _drawable.CollectionChanged += HandlerDrawablesOnCollectionChanged;

            _mapPinLayer.DataSource = new ObservableCollectionProvider <Pin>(_pins);
            _mapPinLayer.Style      = null; // We don't want a global style for this layer

            _mapDrawableLayer.DataSource = new ObservableCollectionProvider <Drawable>(_drawable);
            _mapDrawableLayer.Style      = null; // We don't want a global style for this layer
        }
        public PicturePage()
        {
            BackgroundColor = MyColors.Black;

            var takePictureButton = new Button
            {
                Text              = "Take a picture",
                TextColor         = MyColors.White,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };

            var getPictureButton = new Button
            {
                Text              = "Get the picture",
                TextColor         = MyColors.White,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };

            var image = new Image
            {
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                HeightRequest     = 400,
                WidthRequest      = 400,
            };

            Device.BeginInvokeOnMainThread(async() =>
            {
                // Show latest picture when page loads
                var listOfFiles = await GetFilesListAsync(ContainerType.mycontainer);

                var max   = listOfFiles.Max(t => t.Item1);
                int index = listOfFiles.FindIndex(t => t.Item1 == max);

                image.Source = await GetImageAsync(ContainerType.mycontainer, listOfFiles[index].Item2);
            });

            getPictureButton.Clicked += async(sender, e) =>
            {
                // Get latest picture
                var listOfFiles = await GetFilesListAsync(ContainerType.mycontainer);

                var max   = listOfFiles.Max(t => t.Item1);
                int index = listOfFiles.FindIndex(t => t.Item1 == max);

                image.Source = await GetImageAsync(ContainerType.mycontainer, listOfFiles[index].Item2);
            };


            takePictureButton.Clicked += async(sender, e) =>
            {
                var request = WebRequest.Create(Constants.Constants.TakePictureURL);
                request.ContentType = "application/xml";
                request.Method      = "GET";

                using (HttpWebResponse response = await request.GetResponseAsync() as HttpWebResponse)
                {
                    if (response.StatusCode != HttpStatusCode.OK)
                    {
                        Debug.WriteLine("Error fetching data. Server returned status code: {0}", response.StatusCode);
                        return;
                    }
                    {
                        using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                        {
                            var content = reader.ReadToEnd();
                            if (string.IsNullOrWhiteSpace(content))
                            {
                                Debug.WriteLine("Response contained empty body...");
                            }
                            else
                            {
                                Debug.WriteLine("Response Body: \r\n {0}", content);
                            }
                        }
                    }
                }
            };

            Content = new StackLayout
            {
                Children =
                {
                    image,
                    takePictureButton,
                    getPictureButton
                }
            };
        }
Beispiel #58
0
        public static List <StackLayout> GetPropertyStacks(object o)
        {
            List <StackLayout> propertyStacks = new List <StackLayout>();

            List <Tuple <PropertyInfo, UiProperty> > propertyUiElements = o.GetType()
                                                                          .GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
                                                                          .Select(p => new Tuple <PropertyInfo, UiProperty>(p, Attribute.GetCustomAttribute(p, typeof(UiProperty), true) as UiProperty))
                                                                          .Where(pp => pp.Item2 != null)
                                                                          .OrderBy(pp => pp.Item2._order).ToList();

            foreach (Tuple <PropertyInfo, UiProperty> propertyUiElement in propertyUiElements)
            {
                UiProperty uiElement = propertyUiElement.Item2;

                Label parameterNameLabel = new Label
                {
                    Text = uiElement.LabelText,
                    HorizontalOptions = LayoutOptions.Start,
                    FontSize          = 20
                };

                bool addParameterValueLabel = false;

                View             view            = null;
                BindableProperty bindingProperty = null;
                IValueConverter  converter       = null;
                if (uiElement is OnOffUiProperty)
                {
                    view            = new Switch();
                    bindingProperty = Switch.IsToggledProperty;
                }
                else if (uiElement is DisplayYesNoUiProperty)
                {
                    view = new Label
                    {
                        FontSize = 20
                    };

                    bindingProperty    = Label.TextProperty;
                    converter          = new DisplayYesNoUiProperty.ValueConverter();
                    uiElement.Editable = true;  // just makes the label text non-dimmed. a label's text is never editable.
                }
                else if (uiElement is DisplayStringUiProperty)
                {
                    view = new Label
                    {
                        FontSize = 20
                    };

                    bindingProperty    = Label.TextProperty;
                    converter          = new DisplayStringUiProperty.ValueConverter();
                    uiElement.Editable = true;  // just makes the label text non-dimmed. a label's text is never editable.
                }
                else if (uiElement is EntryIntegerUiProperty)
                {
                    view = new Entry
                    {
                        Keyboard          = Keyboard.Numeric,
                        HorizontalOptions = LayoutOptions.FillAndExpand
                    };

                    bindingProperty = Entry.TextProperty;
                    converter       = new EntryIntegerUiProperty.ValueConverter();
                }
                else if (uiElement is IncrementalIntegerUiProperty)
                {
                    IncrementalIntegerUiProperty p = uiElement as IncrementalIntegerUiProperty;
                    view = new Stepper
                    {
                        Minimum   = p.Minimum,
                        Maximum   = p.Maximum,
                        Increment = p.Increment
                    };

                    bindingProperty        = Stepper.ValueProperty;
                    addParameterValueLabel = true;
                }
                else if (uiElement is EntryStringUiProperty)
                {
                    view = new Entry
                    {
                        Keyboard          = Keyboard.Default,
                        HorizontalOptions = LayoutOptions.FillAndExpand
                    };

                    bindingProperty = Entry.TextProperty;
                }
                else if (uiElement is ListUiProperty)
                {
                    Picker picker = new Picker
                    {
                        HorizontalOptions = LayoutOptions.FillAndExpand
                    };

                    List <object> items = (uiElement as ListUiProperty).Items.ToList();
                    foreach (object item in items)
                    {
                        picker.Items.Add(item.ToString());
                    }

                    picker.SelectedIndex = items.IndexOf(propertyUiElement.Item1.GetValue(o));

                    picker.SelectedIndexChanged += (oo, ee) =>
                    {
                        if (picker.SelectedIndex >= 0)
                        {
                            propertyUiElement.Item1.SetValue(o, items[picker.SelectedIndex]);
                        }
                    };

                    view = picker;
                }

                if (view != null)
                {
                    StackLayout stack = new StackLayout
                    {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.FillAndExpand
                    };

                    stack.Children.Add(parameterNameLabel);

                    if (addParameterValueLabel)
                    {
                        Label parameterValueLabel = new Label
                        {
                            HorizontalOptions = LayoutOptions.FillAndExpand,
                            FontSize          = 20
                        };
                        parameterValueLabel.BindingContext = o;
                        parameterValueLabel.SetBinding(Label.TextProperty, propertyUiElement.Item1.Name);

                        stack.Children.Add(parameterValueLabel);
                    }

                    view.IsEnabled = uiElement.Editable;

                    if (bindingProperty != null)
                    {
                        view.BindingContext = o;
                        view.SetBinding(bindingProperty, new Binding(propertyUiElement.Item1.Name, converter: converter));
                    }

                    stack.Children.Add(view);

                    propertyStacks.Add(stack);
                }
            }

            return(propertyStacks);
        }
Beispiel #59
0
        public TodoListPage()
        {
            Title = "Note+";

            NavigationPage.SetHasNavigationBar(this, true);
            NavigationPage.SetTitleIcon(this, "signature.png");

            listView = new ListView {
                RowHeight    = 60,
                ItemTemplate = new DataTemplate(typeof(TodoItemCell))
            };



            listView.ItemSelected += (sender, e) => {
                var todoItem = (TodoItem)e.SelectedItem;
                var todoPage = new TodoItemPage();
                todoPage.BindingContext = todoItem;
                Navigation.PushAsync(todoPage);
            };

            var layout = new StackLayout();

            if (Device.OS == TargetPlatform.WinPhone)               // WinPhone doesn't have the title showing
            {
                layout.Children.Add(new Label {
                    Text           = "Todo",
                    FontSize       = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                    FontAttributes = FontAttributes.Bold
                });
            }
            layout.Children.Add(listView);
            layout.VerticalOptions = LayoutOptions.FillAndExpand;
            Content = layout;


            ToolbarItem tbi = null;

            if (Device.OS == TargetPlatform.iOS)
            {
                tbi = new ToolbarItem("+", null, () => {
                    var todoItem            = new TodoItem();
                    var todoPage            = new TodoItemPage();
                    todoPage.BindingContext = todoItem;
                    Navigation.PushAsync(todoPage);
                }, 0, 0);
            }
            if (Device.OS == TargetPlatform.Android)               // BUG: Android doesn't support the icon being null
            {
                tbi = new ToolbarItem("+", "plus", () => {
                    var todoItem            = new TodoItem();
                    var todoPage            = new TodoItemPage();
                    todoPage.BindingContext = todoItem;
                    Navigation.PushAsync(todoPage);
                }, 0, 0);
            }

            if (Device.OS == TargetPlatform.WinPhone)
            {
                tbi = new ToolbarItem("Add", "add.png", () => {
                    var todoItem            = new TodoItem();
                    var todoPage            = new TodoItemPage();
                    todoPage.BindingContext = todoItem;
                    Navigation.PushAsync(todoPage);
                }, 0, 0);
            }

            ToolbarItems.Add(tbi);

            if (Device.OS == TargetPlatform.iOS)
            {
                var tbi2 = new ToolbarItem("?", null, () => {
                    var todos   = App.Database.GetItemsNotDone();
                    var tospeak = "";
                    foreach (var t in todos)
                    {
                        tospeak += t.Name + " ";
                    }
                    if (tospeak == "")
                    {
                        tospeak = "there are no tasks to do";
                    }

                    DependencyService.Get <ITextToSpeech> ().Speak(tospeak);
                }, 0, 0);
                ToolbarItems.Add(tbi2);
            }
        }
Beispiel #60
0
        public HeaderIconsControlPage(TabbedPage target)
        {
            _target = target;

            _toggleIconsButton          = new Button();
            _toggleIconsButton.Text     = "Show Header Icons";
            _toggleIconsButton.Clicked += (object sender, EventArgs e) =>
            {
                if (_target.On <WindowsOS>().IsHeaderIconsEnabled())
                {
                    _target.On <WindowsOS>().DisableHeaderIcons();
                    _toggleIconsButton.Text = "Show Header Icons";
                }
                else
                {
                    _target.On <WindowsOS>().EnableHeaderIcons();
                    _toggleIconsButton.Text = "Hide Header Icons";
                }
            };

            var iconWidthLabel = new Label {
                Text = "Head Icons Width:"
            };
            var iconHeightLabel = new Label {
                Text = "Head Icons Height:"
            };

            _iconWidthEntry = new Entry {
                Text = "16"
            };
            _iconHeightEntry = new Entry {
                Text = "16"
            };

            _changeIconsSizeButton          = new Button();
            _changeIconsSizeButton.Text     = "Change Header Icons Size";
            _changeIconsSizeButton.Clicked += (object sender, EventArgs e) =>
            {
                int width;
                int height;

                if (!Int32.TryParse(_iconWidthEntry.Text, out width))
                {
                    width = 16;
                }
                if (!Int32.TryParse(_iconHeightEntry.Text, out height))
                {
                    height = 16;
                }

                var currentSize = _target.On <WindowsOS>().GetHeaderIconsSize();
                if (currentSize.Width != width || currentSize.Height != height)
                {
                    _target.On <WindowsOS>().SetHeaderIconsSize(new Size(width, height));
                }
            };

            _getCurrentIconsSizeButton          = new Button();
            _getCurrentIconsSizeButton.Text     = "Load Current Header Icons Size";
            _getCurrentIconsSizeButton.Clicked += (object sender, EventArgs e) =>
            {
                var currentSize = _target.On <WindowsOS>().GetHeaderIconsSize();
                _iconWidthEntry.Text  = currentSize.Width.ToString();
                _iconHeightEntry.Text = currentSize.Height.ToString();
            };

            Content = new StackLayout
            {
                Padding  = new Thickness(0, 16),
                Children =
                {
                    new Label {
                        Text = "Control page for header icons on UWP.", FontAttributes = FontAttributes.Bold
                    },
                    _toggleIconsButton, iconWidthLabel, _iconWidthEntry, iconHeightLabel, _iconHeightEntry, _changeIconsSizeButton,
                    _getCurrentIconsSizeButton
                }
            };
        }