示例#1
0
        private async void listQuery_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            CRow tapped = (CRow)e.Item;

            if (tapped.Items[0].UID != "")
            {
                CSystemObject sysobj;
                try
                {
                    sysobj = await m_ComosWeb.GetObject(m_Layer, tapped.Items[0].UID, m_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_Mainobject.OverlayUID,
                    Picture         = sysobj.Picture,
                    ProjectUID      = m_Mainobject.ProjectUID,
                    SystemFullName  = sysobj.Name,
                };

                PageSpecifications page = new PageSpecifications(m_Navigator, o, m_Language);
                this.Navigation.PushAsync(page);
            }
        }
示例#2
0
        private async void m_List_ItemTapped(object sender, EventArgs e)
        {
            StackLayout viewcell = (StackLayout)sender;
            ResultItem  item     = (ResultItem)viewcell.BindingContext;

            await viewcell.ScaleTo(1.2, 50, Easing.Linear);

            await viewcell.ScaleTo(1, 50, Easing.Linear);


            if ((bool)docconverter.Convert(item.UID, null, null, null))
            {
                if (plataform.IsOnline)
                {
                    plataform.ShowProgressMessage(Services.TranslateExtension.TranslateText("downloading_documents"), true);
                    CheckAndDownloadAditionalContent downloader = new CheckAndDownloadAditionalContent();
                    CDocument filename_andtype = await downloader.DownloadDocument(item.UID, true);

                    if (filename_andtype != null && filename_andtype.FileName != "")
                    {
                        cachedb.CacheDocumentFilePath(filename_andtype.FileName, filename_andtype.MimeType, item.UID, m_ProjectData.SelectedProject.UID, m_ProjectData.SelectedLayer.UID, filename_andtype.Name, filename_andtype.Description, filename_andtype.Picture);
                    }
                    if (filename_andtype == null)
                    {
                        plataform.ShowToast(Services.TranslateExtension.TranslateText("document_not_found"));
                    }

                    plataform.HideProgressMessage();
                }
            }
            else if ((bool)devconverter.Convert(item.UID, null, null, null))
            {
                CSystemObject sysobj;
                try
                {
                    sysobj = await m_ComosWeb.GetObject(m_ProjectData.SelectedLayer, item.UID, m_ProjectData.SelectedLanguage.LCID);
                }
                catch (Exception ex)
                {
                    await App.Current.MainPage.DisplayAlert("Error", "Error al buscar: " + 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_ProjectData.SelectedDB.Key, o, m_ProjectData.SelectedLanguage.LCID);
                await this.Navigation.PushAsync(page);
            }
        }
示例#3
0
        private async void ViewCell_DocumentTapped(object sender, EventArgs e)
        {
            var viewcell = sender as StackLayout;
            var row      = viewcell.BindingContext as CRow;

            await viewcell.ScaleTo(1.2, 50, Easing.Linear);

            await viewcell.ScaleTo(1, 50, Easing.Linear);

            if ((bool)docconverter.Convert(row.Items[0].UID, null, null, null))
            {
                if (plataform.IsOnline)
                {
                    plataform.ShowProgressMessage(Services.TranslateExtension.TranslateText("downloading_documents"), true);
                    //string[] filename_andtype = await DownloadDocument(row.Items[0].UID);
                    CDocument filename_andtype = await DownloadDocument(row.Items[0].UID);

                    if (filename_andtype != null && !string.IsNullOrEmpty(filename_andtype.FileName))
                    {
                        cachedb.CacheDocumentFilePath(filename_andtype.FileName, filename_andtype.MimeType, row.Items[0].UID, ProjectData.SelectedProject.UID, ProjectData.SelectedLayer.UID, filename_andtype.Name, filename_andtype.Description, filename_andtype.Picture);
                    }
                    if (filename_andtype == null)
                    {
                        plataform.ShowToast(Services.TranslateExtension.TranslateText("document_not_found"));
                    }
                    if (string.IsNullOrEmpty(filename_andtype.FileName))
                    {
                        // Can happen in emulator. When folder /SDCard/Storage/Download not exists.
                        plataform.ShowToast(Services.TranslateExtension.TranslateText("save_not_possible"));
                    }

                    plataform.HideProgressMessage();
                }
                else
                {
                    string[] path = cachedb.GetDocumentFilePath(row.Items[0].UID, ProjectData.SelectedProject.UID, ProjectData.SelectedLayer.UID);
                    if (path != null && path[0] != "")
                    {
                        bool result = await plataform.OpenFile(path[0], path[1]);
                    }
                    //else doc not found in cache
                }
            }
            else if ((bool)devconverter.Convert(row.Items[0].UID, null, null, null))
            {
                // open device properties

                if (m_Page != null)
                {
                    CSystemObject sysobj;
                    try
                    {
                        sysobj = await m_ComosWeb.GetObject(ProjectData.SelectedLayer, row.Items[0].UID, ProjectData.SelectedLanguage.LCID);
                    }
                    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)
                    {
                        CObject o = new CObject()
                        {
                            ClassType       = sysobj.SystemType,
                            Description     = sysobj.Description,
                            IsClientPicture = sysobj.IsClientPicture,
                            Name            = sysobj.Name,
                            UID             = sysobj.UID,
                            OverlayUID      = ProjectData.SelectedLayer.UID,
                            Picture         = sysobj.Picture,
                            ProjectUID      = ProjectData.SelectedProject.ProjectUID,
                            SystemFullName  = sysobj.Name,
                        };
                        PageSpecifications page = new PageSpecifications(ProjectData.SelectedDB.Key, o, ProjectData.SelectedLanguage.LCID);

                        await m_Page.Navigation.PushAsync(page);
                    }
                }
            }
        }
示例#4
0
        public async Task ShowTableQuery()
        {
            /*
             * Device.BeginInvokeOnMainThread(() =>
             * {
             *              //this.ShowSpinner("FetchingQuery Result ...");
             * });
             *
             * this.Query = await m_ComosWeb.GetqueriesResult(
             *              m_Navigator, obj.ProjectUID, obj.OverlayUID, language, obj.UID, null);
             */

            if (this.Query == null)
            {
                //this.HideSpinner();
                string text = Services.TranslateExtension.TranslateText("query_not_found");
                text = text.Replace("@", m_Mainobject.SystemFullName);
                await App.Current.MainPage.DisplayAlert("", text, "OK");

                return;
            }

            Device.BeginInvokeOnMainThread(() =>
            {
                Grid grid = new Grid();

                // Create the page content in code.
                for (int j = 0; j < m_Query.Columns.Length; j++)
                {
                    ColumnDefinition def = new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Auto)
                    };
                    var column = m_Query.Columns[j];
                    grid.ColumnDefinitions.Add(def);
                }

                grid.RowDefinitions.Add(
                    new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Auto)
                }
                    );
                for (int i = 0; i < m_Query.Columns.Length; i++)
                {
                    var column = m_Query.Columns[i];

                    grid.Children.Add(
                        new ContentView()
                    {
                        Content = new Label()
                        {
                            Text           = column.DisplayDescription,
                            FontAttributes = FontAttributes.Bold,
                        },
                        Padding = new Thickness(10, 10, 10, 10),
                        Margin  = new Thickness(1, 1, 0, 0),
                    }, i, 0);
                }

                //mainList.Clear();

                for (int i = 0; i < m_Query.Rows.Length; i++)
                {
                    var row = m_Query.Rows[i];
                    //mainList.Add(new QCell { Cells = row.Items, UID = row.UID });

                    grid.RowDefinitions.Add(
                        new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto),
                    });
                }
                for (int rowid = 0; rowid < m_Query.Rows.Length; rowid++)
                {
                    var row = m_Query.Rows[rowid];
                    for (int colid = 0; colid < m_Query.Columns.Length; colid++)
                    {
                        var cell = row.Items[colid];
                        ContentView cellcontent = new ContentView();

                        cellcontent.Content = new Label()
                        {
                            Text = cell.Text,
                        };
                        cellcontent.Margin          = new Thickness(1, 1, 0, 0);
                        cellcontent.Padding         = new Thickness(10, 10, 10, 10);
                        cellcontent.BackgroundColor = Color.White;

                        TapGestureRecognizer tap = new TapGestureRecognizer();

                        tap.Tapped += async(object sender, EventArgs e) =>
                        {
                            CSystemObject sysobj;
                            try
                            {
                                sysobj = await m_ComosWeb.GetObject(m_Layer, cell.UID, m_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.UID,
                                SystemFullName  = sysobj.Name,
                            };

                            PageSpecifications page = new PageSpecifications(m_Navigator, o, m_Language);
                            this.Navigation.PushAsync(page);
                        };
                        cellcontent.GestureRecognizers.Add(tap);
                        grid.Children.Add(cellcontent, colid, rowid + 1);
                    }
                }
                grid.ColumnSpacing     = 1;
                grid.RowSpacing        = 1;
                grid.BackgroundColor   = Color.FromRgb(190, 205, 215);
                grid.Padding           = new Thickness(0, 0, 0, 0);
                grid.HorizontalOptions = LayoutOptions.StartAndExpand;
                grid.VerticalOptions   = LayoutOptions.StartAndExpand;

                queryGrid.Children.Clear();
                queryGrid.Children.Add(grid);

                //  this.HideSpinner();
            });
        }
示例#5
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);
        }