示例#1
0
        public async Task UpdateAttributesUI(string html)
        {
            var         rejectionFrame     = "Rechazo";
            var         UltimoUsuarioFrame = "Última modificación";
            StackLayout stack = new StackLayout()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Orientation       = StackOrientation.Vertical,
            };

            var attributes = CHtmlParser.ParseAttributesForUI(html);
            var uiParser   = new UI.HTMLToUIParser();

            uiParser.MainObject   = this.MainObject;
            uiParser.CachedDevice = this.cacheddevice;

            foreach (var attribute in attributes)
            {
                if ((attribute.Text != rejectionFrame) && ((attribute.Text != UltimoUsuarioFrame)))
                {
                    var elm = uiParser.UpdateAttributesUI(attribute);
                    if (elm != null)
                    {
                        elm.IsEnabled = true;
                        stack.Children.Add(elm);
                        //this.MobileTabFrame.Content = ((Frame)elm).Content;
                    }
                }
            }

            stack.Padding           = new Thickness(0, 0, 0, 0);
            stack.HorizontalOptions = LayoutOptions.FillAndExpand;
            stack.VerticalOptions   = LayoutOptions.FillAndExpand;

            this.Values          = uiParser.Values;
            this.m_Panel.Content = stack;

            addEquipmentButton();
        }
示例#2
0
        public async Task UpdateAttributesUI(CSpecification spec, CObject obj, string language, bool render = true)
        {
            try
            {
                if (render)
                {
                    ShowSpinner(Services.TranslateExtension.TranslateText("loading"));
                }
                //ShowStickSpinner("Loading values...");

                StackLayout stack = new StackLayout()
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    Orientation       = StackOrientation.Vertical,
                };

                string html;
                try
                {
                    html = await m_ComosWeb.GetObjectSpecificationAsHtml(
                        this.Database, spec.ProjectUID, spec.OverlayUID, language, obj.UID, spec.Name);
                }
                catch (TaskCanceledException) { return; } // If there is a Logout Request
                catch (Exception ex)
                {
                    await App.Current.MainPage.DisplayAlert("Error", "Error al cargar atributos: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));

                    return;
                }

                if (html == null)
                {
                    ShowToast("Error al cargar la información. Intente nuevamente.");
                    this.HideSpinner();
                    return;
                }


                m_UIAttributes = CHtmlParser.ParseAttributesForUI(html);
                await ExecuteQueriesInAttributes(m_UIAttributes);

                //just download the jsons
                if (!render)
                {
                    ShowToast("Error al cargar la información. Intente nuevamente.");
                    this.HideSpinner();
                    return;
                }

                var uiParser = new UI.HTMLToUIParser(this);
                uiParser.MainObject = this.MainObject;

                foreach (var attribute in m_UIAttributes)
                {
                    var elm = uiParser.UpdateAttributesUI(attribute);      //convert attribute to xamarin element
                    processDisplayElement(attribute);                      //parse xamarin element to extract info in selected attributes
                    if (elm != null && isAttributeVisible(attribute))      //if elm is not null and is a visible attribute, then add to display stack
                    {
                        View myNewElement = postProcessDisplayElement(elm, attribute);

                        if (isALoogBook)
                        {
                            Frame       myNewElementFrame       = (Frame)myNewElement;
                            StackLayout myNewElementStackLayout = (StackLayout)myNewElementFrame.Children[0];

                            for (int i = 0; i < myNewElementStackLayout.Children.Count; i++)
                            {
                                var element = myNewElementStackLayout.Children[i];
                                if (element.GetType() == typeof(StackLayout))
                                {
                                    StackLayout elementStackLayout = (StackLayout)element;
                                    foreach (var elementChild in elementStackLayout.Children)
                                    {
                                        VisualElement visualElement = (VisualElement)elementChild;
                                        visualElement.IsEnabled = false;
                                    }
                                }
                            }
                        }

                        stack.Children.Add(myNewElement);
                    }
                }

                stack.Padding           = new Thickness(0, 0, 0, 0);
                stack.HorizontalOptions = LayoutOptions.FillAndExpand;
                stack.VerticalOptions   = LayoutOptions.FillAndExpand;

                stack.Children.Add(new StackLayout()
                {
                    HeightRequest = 65
                });

                if (isALoogBook)
                {
                    this.ViewSave          = false;
                    floatingMenu.IsVisible = false;
                }
                else
                {
                    this.ViewSave          = (uiParser.EditableValues.Count > 0);
                    floatingMenu.IsVisible = (uiParser.EditableValues.Count > 0);
                }

                this.Values          = uiParser.Values;
                this.m_Panel.Content = stack;

                //if (this.IsActivity){//this.SetupForActivity();}

                if (this.AllowPictures)
                {
                    this.SetupForPictures();
                }

                this.HideSpinner();
                //this.HideStickSpinner();
                addEquipmentButton();

                if (belongsToAnEquipment)
                {
                    equipmentVerified.Text            = Constants.OkIcon;
                    equipmentVerified.BackgroundColor = Color.Green;
                }
                else if (equipmentVerified != null)
                {
                    equipmentVerified.Text            = Constants.CancelIcon;
                    equipmentVerified.BackgroundColor = Color.Red;
                }
            }
            catch (Exception ex)
            {
                ShowToast($"Error al cargar atributos: {ex.Message}");
            }

            finally
            {
                this.HideSpinner();
            }
        }