static View CreateTopRow () { var profile = new StackLayout { Orientation = StackOrientation.Horizontal, Spacing = 18, HeightRequest = 50, Padding = new Thickness (20, 40, 10, 10), //BackgroundColor = Color.Green, Children = { CreateQRBox (), CreateNameStack () } }; profile.SetBinding(StackLayout.IsVisibleProperty, "HasProfile"); var profileTapGesture = new TapGestureRecognizer(); profileTapGesture.SetBinding (TapGestureRecognizer.CommandProperty, "AddContactCommand"); profile.GestureRecognizers.Add (profileTapGesture); var noProfile = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.CenterAndExpand, Spacing = 18, HeightRequest = 50, Padding = new Thickness (20, 40, 10, 10), //BackgroundColor = Color.Red, Children = { CreateNoProfileView () } }; noProfile.SetBinding(StackLayout.IsVisibleProperty, "HasProfile", converter: new NegateValueConverter()); var noProfileTapGesture = new TapGestureRecognizer(); noProfileTapGesture.SetBinding<MenuViewModel> (TapGestureRecognizer.CommandProperty, vm => vm.CreateProfileCommand); noProfile.GestureRecognizers.Add (noProfileTapGesture); var grid = new Grid { Children = { profile, noProfile } }; return grid; }
public MatrixView (MatrixMainPageView mainView) { InitializeComponent (); Title = "Матрица"; if (Device.OS == TargetPlatform.iOS) { Icon = "matrixTabIcon.png"; { var btn = new Button() {Text = "Фильтры"}; btn.Clicked += (s, e) => { mainView.IsPresented = !mainView.IsPresented; }; Grid.SetRow(btn, 2); grdRoot.Children.Add(btn); } } grdRoot.Padding = Device.OnPlatform (10, 8, 10); grdHeaderContent.ColumnSpacing = Device.OnPlatform (25, 50, 0); cnvHeader.HeightRequest = Device.OnPlatform (80, 110, 0); cnvInfo.HeightRequest = Device.OnPlatform (80, 110, 0); lblInfo.FontSize = Device.OnPlatform (11, 14, 0); lblHeader1.FontSize = Device.OnPlatform (11, 14, 0); lblHeaderContent1.FontSize = Device.OnPlatform (11, 14, 0); lblHeader2.FontSize = Device.OnPlatform (11, 14, 0); lblHeaderContent2.FontSize = Device.OnPlatform (11, 14, 0); lblZ.FontSize = Device.OnPlatform (11, 14, 0); lblZ1.FontSize = Device.OnPlatform (11, 14, 0); lblZ2.FontSize = Device.OnPlatform (11, 14, 0); lblZ3.FontSize = Device.OnPlatform (11, 14, 0); lblZ4.FontSize = Device.OnPlatform (11, 14, 0); lblZ5.FontSize = Device.OnPlatform (11, 14, 0); lblZ6.FontSize = Device.OnPlatform (11, 14, 0); lblD.FontSize = Device.OnPlatform (11, 14, 0); lblD1.FontSize = Device.OnPlatform (11, 14, 0); lblD2.FontSize = Device.OnPlatform (11, 14, 0); lblD3.FontSize = Device.OnPlatform (11, 14, 0); lblD4.FontSize = Device.OnPlatform (11, 14, 0); lblD5.FontSize = Device.OnPlatform (11, 14, 0); lblD6.FontSize = Device.OnPlatform (11, 14, 0); lblStatus.FontSize = Device.OnPlatform (11, 14, 0); stkChart.Spacing = Device.OnPlatform(5, 3, 0); { var gesture=new TapGestureRecognizer(); gesture.SetBinding(TapGestureRecognizer.CommandProperty,new Binding("GoToChartCommand")); stkChart.GestureRecognizers.Add(gesture); } _mainView = mainView; InitToolbar (); _repository = ContainerService.Instance.Container.Resolve<IMatrixCacheRepository> (); }
TapGestureRecognizer CreateTapGestureRecognizer () { var tapGestureRecognizer = new TapGestureRecognizer (); tapGestureRecognizer.SetBinding (TapGestureRecognizer.CommandProperty, "LaunchCamera"); return tapGestureRecognizer; }
IGestureRecognizer CreateTapGestureRecognizer () { var recognizer = new TapGestureRecognizer (); recognizer.SetBinding (TapGestureRecognizer.CommandProperty, "ItemTapped"); return recognizer; }
/// <summary> /// Lay out the grid, calendar cells, days of the week. Everything but the events themselves. /// </summary> private void BuildCalendarGrid() { var startDate = Start.Date; var endDate = End.Date; var days = (endDate - startDate).Days; _cols = Math.Min(days, _daysInWeek); _rows = (int)Math.Ceiling((double)days / _daysInWeek); // Clear any existing events, just in case ClearEvents(); _grid = new Grid(); _grid.ColumnSpacing = 0; _grid.RowSpacing = 0; // Header _grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); // Configure columns and place headers labels (days of the week) // for (int i = 0; i < _cols; i++) { // Note that the drag/drop logic has hardcoded assumptions about this configuration, so simply // tweaking column definitions here (e.g. to give weekends different width or just make everything // a fixed-width) without updating that logic would break things. // _grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); var label = new Label(); label.Text = startDate.AddDays(i).DayOfWeek.ToString(); label.XAlign = TextAlignment.Center; label.LineBreakMode = LineBreakMode.TailTruncation; label.FontSize = Device.GetNamedSize(NamedSize.Small, label); _grid.Children.Add(label, i, 0); } // Configure rows // for (int i = 0; i < _rows; i++) { // RowDefinition doesn't support MinHeight property yet... // (the MinHeight property is there, just marked internal...) // var height = (_rows <= 3) ? new GridLength(1, GridUnitType.Star) : new GridLength(_minRowHeight, GridUnitType.Absolute); _grid.RowDefinitions.Add(new RowDefinition { Height = height }); } // Add calendar cells for each day // var day = startDate; for (int row = 0; row < _rows; row++) { for (int col = 0; col < _cols; col++) { var calendarCell = new CalendarCellView { BindingContext = day.Date }; var tapGesture = new TapGestureRecognizer(); // Bind to the "parent" context (i.e., ours, as opposed to the cell's) tapGesture.BindingContext = this; tapGesture.SetBinding(TapGestureRecognizer.CommandProperty, "AddEventCommand"); tapGesture.CommandParameter = day.Date; calendarCell.GestureRecognizers.Add(tapGesture); _grid.Children.Add(calendarCell, col, row + 1); day = day.AddDays(1); } } // Create one AutoStackGrid for each row in the main grid // for (int row = 0; row < _rows; row++) { var container = new AutoStackGrid(); //container.IsEnabled = false; //container.InputTransparent = true; // Extra padding on top to accomodate the date display // container.Padding = new Thickness(0, 20, 0, 5); Grid.SetRow(container, row + 1); Grid.SetColumn(container, 0); Grid.SetColumnSpan(container, _cols); container.Columns = _cols; _grid.Children.Add(container); _labelContainers.Add(container); } Content = new ScrollView { Content = _grid }; }
IGestureRecognizer CreateTapGestureRecognizer () { var tapGestureRecognizer = new TapGestureRecognizer (); tapGestureRecognizer.SetBinding (TapGestureRecognizer.CommandProperty, "ToggleSelection"); return tapGestureRecognizer; }