public EventCellView() { var layoutIntero = new Grid { HeightRequest = 300, BackgroundColor = Color.Transparent, RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength(0.70, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(0.30, GridUnitType.Star) } }, RowSpacing = 0, Padding = new Thickness(5), }; var grigliaTesto = new Grid { BackgroundColor = Color.White, RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto } }, ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition { Width = 50 }, new ColumnDefinition { Width = GridLength.Star } }, Padding = new Thickness(5, 0, 5, 0) }; var title = new Label { TextColor = Color.Black, FontSize = DefaultTema.FontMedium, FontAttributes = FontAttributes.Bold, HorizontalTextAlignment = TextAlignment.Start, HorizontalOptions = LayoutOptions.Start, }; title.SetBinding(Label.TextProperty, nameof(EventCellVM.Title)); var data = new Label { TextColor = Color.White, FontSize = DefaultTema.FontSmall }; data.SetBinding(Label.TextProperty, nameof(EventCellVM.DataInizio)); var luogoLabel = new Label { TextColor = Color.White }; luogoLabel.SetBinding(Label.TextProperty, nameof(EventCellVM.Luogo)); var prezzoLabel = new Label { TextColor = Color.White }; prezzoLabel.SetBinding(Label.TextProperty, nameof(EventCellVM.Prezzo)); var startLabel = new Label { }; startLabel.SetBinding(Label.FormattedTextProperty, nameof(EventCellVM.DataFormatted)); #if __DROID__ var img = new FFImageLoading.Forms.CachedImage() { Aspect = Aspect.AspectFill, LoadingPriority = FFImageLoading.Work.LoadingPriority.Low, CacheDuration = TimeSpan.FromDays(360), ErrorPlaceholder = Globals.DefaultThumb, LoadingPlaceholder = Globals.DefaultThumb, }; img.SetBinding(SpeedImage.SourceProperty, nameof(EventCellVM.Copertina)); #else var img = new Image() { Aspect = Aspect.AspectFill, }; img.SetBinding(Image.SourceProperty, nameof(EventCellVM.Copertina)); #endif //var img = new Image() { Aspect = Aspect.AspectFill,}; //img.Bind(nameof(EventCellVM.Copertina)); var layoutDataLuogo = new StackLayout { Orientation = StackOrientation.Horizontal, Spacing = 5, Children = { new Label { Text = "@", TextColor = Color.Pink }, luogoLabel, data } }; var boxView = new BoxView { Color = Color.Black, Opacity = 0.5 }; //prima era 0.8 grigliaTesto.AddChild(startLabel, 0, 0, 2, 1); grigliaTesto.AddChild(title, 0, 1, 1, 1); layoutIntero.AddChild(img, 0, 0, 1, 1); layoutIntero.AddChild(grigliaTesto, 1, 0, 1, 1); layoutIntero.Margin = new Thickness(5); View = layoutIntero; }
private DataTemplate CreateTemplateForRow(CColumn[] columns, ListView listQuery, string language) { DataTemplate template = new DataTemplate(() => { var layout = new StackLayout() { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.StartAndExpand }; var headerlayout = new StackLayout() { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; Label lblHeader = new Label(); lblHeader.VerticalOptions = LayoutOptions.FillAndExpand; lblHeader.HorizontalOptions = LayoutOptions.FillAndExpand; lblHeader.SetBinding(Label.TextProperty, "Items[ " + pickerIndex + "].Text"); lblHeader.FontAttributes = FontAttributes.Bold; FFImageLoading.Forms.CachedImage img = new FFImageLoading.Forms.CachedImage(); Binding binding = new Binding("Items[ " + pickerIndex + "].Picture"); binding.Converter = converter; img.SetBinding(FFImageLoading.Forms.CachedImage.SourceProperty, binding); img.HeightRequest = 20; img.WidthRequest = 20; // document download /* * * AFButton btdoc = new AFButton(); * Binding bindinguid = new Binding("Items[ " + pickerIndex + "].UID"); * bindinguid.Converter = docconverter; * btdoc.SetBinding(AFButton.IsVisibleProperty, bindinguid); * btdoc.Text = "\uf019"; * btdoc.HorizontalOptions = LayoutOptions.EndAndExpand; * btdoc.BackgroundColor = Color.Transparent; * btdoc.BorderColor = Color.Transparent; * btdoc.Clicked += (object sender, EventArgs e) => * { * AFButton af = (AFButton)sender; * Services.ComosDocumentHandler.DownloadDocument(m_ProjectData, ""); * }; * */ // incident creation /* * AFButton btdev = new AFButton(); * Binding bindinguiddev = new Binding("Items[ " + pickerIndex + "].UID"); * bindinguiddev.Converter = devconverter; * btdev.SetBinding(AFButton.IsVisibleProperty, bindinguiddev); * btdev.Text = "\uf071"; * btdev.HorizontalOptions = LayoutOptions.EndAndExpand; * btdev.BackgroundColor = Color.Transparent; * btdev.BorderColor = Color.Transparent; * btdev.Clicked += async (object sender, EventArgs e) => * { * AFButton af = (AFButton)sender; * CRow cell = (CRow)af.BindingContext; * string uid = cell.Items[pickerIndex].UID; * string pic = cell.Items[pickerIndex].Picture; * string ownername = cell.Items[pickerIndex].Text; * * var db = Services.XServices.Instance.GetService<Services.XDatabase>(); * ComosWebSDK.UI.UICachedScreen screen = db.GetCachedScreen(comos.Constants.IncidentCDevUID); * await this.Navigation.PushAsync(new PageNewDevice(screen, uid, pic, ownername)); * * }; */ var contentlayout = new StackLayout() { Orientation = StackOrientation.Vertical, IsVisible = false, }; contentlayout.FadeTo(0, 300, Easing.Linear); int colid = 0; foreach (CColumn column in columns) { AFButton bt = new AFButton(); Label lbl = new Label(); Label lblvalue = new Label(); StackLayout stackRow = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Spacing = 5 }; lbl.VerticalOptions = LayoutOptions.Center; lbl.HorizontalOptions = LayoutOptions.Start; lbl.FontAttributes = FontAttributes.Bold; lbl.Text = column.DisplayDescription; FFImageLoading.Forms.CachedImage imginterior = new FFImageLoading.Forms.CachedImage(); Binding bindinginterior = new Binding("Items[ " + colid.ToString() + "].Picture"); bindinginterior.Converter = converter; imginterior.SetBinding(FFImageLoading.Forms.CachedImage.SourceProperty, bindinginterior); imginterior.HeightRequest = 15; imginterior.WidthRequest = 15; lblvalue.VerticalOptions = LayoutOptions.Center; lblvalue.HorizontalOptions = LayoutOptions.End; lblvalue.SetBinding(Label.TextProperty, "Items[ " + colid.ToString() + "].Text"); colid = colid + 1; bt.Text = "\uf054"; bt.HorizontalOptions = LayoutOptions.EndAndExpand; bt.BackgroundColor = Color.Transparent; bt.BorderColor = Color.Transparent; bt.StyleId = colid.ToString(); //stackRow.Children.Add(imginterior); stackRow.Children.Add(lbl); stackRow.Children.Add(lblvalue); //stackRow.Children.Add(bt); // store index to click contentlayout.Children.Add(stackRow); #region "Old arrow for each column stuff" //stackRow.StyleId = colid.ToString(); //TapGestureRecognizer tap = new TapGestureRecognizer(); //tap.Tapped += async (object sender, EventArgs e) => //{ // AFButton item = (AFButton)sender; // CRow qcell = (CRow)item.BindingContext; // //CSystemObject sysobj = await m_ComosWeb.GetObject(m_Layer, qcell.Items[int.Parse(item.StyleId)].UID, language); // //aways the first object to avoid arrows at all lines? // CSystemObject sysobj = await m_ComosWeb.GetObject(m_Layer, qcell.Items[0].UID, language); // CObject o = new CObject() // { // ClassType = sysobj.SystemType, // Description = sysobj.Description, // IsClientPicture = sysobj.IsClientPicture, // Name = sysobj.Name, // UID = sysobj.UID, // OverlayUID = m_ProjectData.SelectedLayer.UID, // Picture = sysobj.Picture, // ProjectUID = m_ProjectData.SelectedProject.ProjectUID, // SystemFullName = sysobj.Name, // }; // PageSpecifications page = new PageSpecifications(m_Navigator, o, language); // await this.Navigation.PushAsync(page); //}; //contentlayout.GestureRecognizers.Add(tap); //stackRow.GestureRecognizers.Add(tap); //bt.GestureRecognizers.Add(tap); #endregion } TapGestureRecognizer tap = new TapGestureRecognizer(); tap.Tapped += async(object sender, EventArgs e) => { if (OnCellTaped == null) { StackLayout item = (StackLayout)sender; CRow qcell = (CRow)item.BindingContext; //aways the first object to avoid arrows at all lines? CSystemObject sysobj; try { sysobj = await m_ComosWeb.GetObject(m_Layer, qcell.Items[0].UID, language); } catch (Exception ex) { await App.Current.MainPage.DisplayAlert("Error", "Error al cargar objetos de Comos Web: " + ex.Message, Services.TranslateExtension.TranslateText("OK")); return; } if (sysobj == null) { return; } CObject o = new CObject() { ClassType = sysobj.SystemType, Description = sysobj.Description, IsClientPicture = sysobj.IsClientPicture, Name = sysobj.Name, UID = sysobj.UID, OverlayUID = m_ProjectData.SelectedLayer.UID, Picture = sysobj.Picture, ProjectUID = m_ProjectData.SelectedProject.ProjectUID, SystemFullName = sysobj.Name, }; PageSpecifications page = new PageSpecifications(m_Navigator, o, language); await this.Navigation.PushAsync(page); } else { CellTaped(sender, e); } }; contentlayout.GestureRecognizers.Add(tap); headerlayout.Children.Add(img); headerlayout.Children.Add(lblHeader); //headerlayout.Children.Add(btdoc); //headerlayout.Children.Add(btdev); layout.Children.Add(headerlayout); layout.Children.Add(contentlayout); TapGestureRecognizer headertap = new TapGestureRecognizer(); headertap.Tapped += async(object sender, EventArgs e) => { if (expandable) { contentlayout.IsVisible = !contentlayout.IsVisible; if (contentlayout.IsVisible) { contentlayout.FadeTo(1, 750, Easing.Linear); } else { await contentlayout.FadeTo(0, 300, Easing.Linear); } OnPropertyChanged("IsVisible"); } }; Frame frm = new Frame() { OutlineColor = (Color)Application.Current.Resources["ComosColorNavBarButton"], HasShadow = true, BackgroundColor = (Color)Application.Current.Resources["ComosColorModuleCard"], Margin = new Thickness(0, 0, 0, 5) }; frm.Content = layout; frm.GestureRecognizers.Add(headertap); return(new ViewCell { View = frm }); }); return(template); }