Exemple #1
0
        public static View CreateMediaItemForAudio(string path, double width = 90, double height = 90)
        {
            var platform = Services.XServices.Instance.GetService <Services.IPlatformSystem>();

            //audios.Add(path);

            var viewcell = new CustomStackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Padding           = new Thickness(5, 5),
                IsAudio           = true,
                CustomData        = path,
                BackgroundColor   = Color.Transparent,
            };

            AFButton img = new AFButton
            {
                Text = "\uf028",
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                BackgroundColor   = (Color)Application.Current.Resources["UIFabButton"],
                TextColor         = (Color)Application.Current.Resources["UIFabButtonText"],
                WidthRequest      = width,
                HeightRequest     = height
            };


            viewcell.LongClick += Viewcell_LongClick;

            viewcell.Children.Add(img);

            //TapGestureRecognizer gesture = new TapGestureRecognizer();
            //gesture.Tapped += (object sender, EventArgs e) =>
            //{
            //    platform.PlayAudio(path);
            //};

            //viewcell.GestureRecognizers.Add(gesture);

            img.Clicked += (object sender, EventArgs e) =>
            {
                //AFButton bt = sender as AFButton;
                //if (!play)
                //{
                //bt.Text = "\uf04d";
                platform.PlayAudio(path);
                //    play = true;
                //}
                //else
                //{
                //    //bt.Text = "\uf028";
                //    platform.StopAudio();
                //    play = false;
                //}
            };

            return(viewcell);
        }
Exemple #2
0
        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);
        }