public void InitializeAttributes(string database, string language, CSpecification spec, CObject obj) { this.btNew.BindingContext = this; midiacontrol = midiaControl; if (obj.ProjectUID == null) { obj.ProjectUID = spec.ProjectUID; } if (obj.OverlayUID == null) { obj.OverlayUID = spec.OverlayUID; } this.Icon = obj.Picture; this.Title = obj.Name; this.MainObject = obj; this.BindingContext = this; this.Database = database; this.Language = language; this.ButtonPlayPause.IsVisible = false; //this.ShowHome = true; //this.ShowAttributeView = true; this.CheckFavorite(); NavigationBarControl.OnSaved += NavigationBarControl_OnSaved; midiaControl.StartComponent(MainObject.UID, MainObject.Name); }
public PageAttributes(string database, string language, CSpecification spec, CObject obj) { InitializeComponent(); InitializeAttributes(database, language, spec, obj); this.btAddNewJDEMaterial.IsVisible = false; this.btTasks.IsVisible = false; this.isWorkpackage = false; this.isPEMActivity = false; Device.BeginInvokeOnMainThread(async() => { await UpdateAttributesUI(spec, obj, language); }); }
public async Task Init(string database, string language, CSpecification spec, CObject obj) { this.Icon = obj.Picture; this.Title = obj.Name; this.MainObject = obj; this.BindingContext = this; this.Database = database; this.Language = language; this.CheckFavorite(); NavigationBarControl.OnSaved += NavigationBarControl_OnSaved; await UpdateAttributesUI(spec, obj, language, false); }
public PageAttributes(string database, string language, CSpecification spec, CObject obj, string wp, string otNumber) { InitializeComponent(); InitializeAttributes(database, language, spec, obj); this.isWorkpackage = true; this.btTasks.IsVisible = true; this.isPEMActivity = false; Device.BeginInvokeOnMainThread(async() => { await UpdateAttributesUI(spec, obj, language); }); if (otNumber != "") { this.Title = otNumber; } }
public async Task UpdateAttributesUI(CSpecification spec, string objUID) { StackLayout stack = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Vertical, }; string html; try { html = await m_ComosWeb.GetObjectSpecificationAsHtml( this.ProjectData.SelectedDB.Key, spec.ProjectUID, spec.OverlayUID, ProjectData.SelectedLanguage.LCID, objUID, spec.Name); } catch (Exception ex) { await App.Current.MainPage.DisplayAlert("Error", "Error al cargar atributos: " + ex.Message, Services.TranslateExtension.TranslateText("OK")); return; } if (html == null) { return; } m_Attributes = CHtmlParser.ParseAttributesForUI(html); foreach (var attribute in m_Attributes) { var elm = await UpdateAttributesUI(attribute); if (elm == null) { continue; } stack.Children.Add(elm); } stack.Padding = new Thickness(0, 0, 0, 0); stack.HorizontalOptions = LayoutOptions.FillAndExpand; stack.VerticalOptions = LayoutOptions.FillAndExpand; this.m_Panel.Content = stack; }
public WorkPackageDetail(CSpecification spec, string objuid) { InitializeComponent(); this.BindingContext = this; SystemUID = objuid; /* * this.Icon = obj.Picture; * this.Title = obj.Name; * this.MainObject = obj; * this.BindingContext = this; * this.Database = database; * this.Language = language; * * this.ShowAttributeView = true; * this.CheckFavorite(); * NavigationBarControl.OnSaved += NavigationBarControl_OnSaved; * */ UpdateAttributesUI(spec, objuid); }
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(); } }
public async Task <List <CSpecification> > GetObjectSpecification(string database, string projectuid, string layer, string lcid, string target) { var content = await communicationManager.GetObjectSpecification(m_Url, database, projectuid, target, lcid, layer, m_Session.Id, serverName); if (content == null) { return(null); } JArray jarray = JArray.Parse(content); List <CSpecification> result = new List <CSpecification>(); if (jarray == null) { return(result); } foreach (var token in jarray) { CSpecification s = new CSpecification() { IsEditable = token.SelectToken("IsEditable").Value <bool>(), IsReauthenticationRequired = token.SelectToken("IsReauthenticationRequired").Value <bool>(), NestedName = token.SelectToken("NestedName").Value <string>(), ObjectUID = token.SelectToken("ObjectUID").Value <string>(), OverlayName = token.SelectToken("OverlayName").Value <string>(), ProjectName = token.SelectToken("ProjectName").Value <string>(), ClassType = token.SelectToken("ClassType").Value <string>(), Description = token.SelectToken("Description").Value <string>(), IsClientPicture = token.SelectToken("IsClientPicture").Value <bool>(), Name = token.SelectToken("Name").Value <string>(), OverlayUID = token.SelectToken("OverlayUID").Value <string>(), Picture = token.SelectToken("Picture").Value <string>(), ProjectUID = token.SelectToken("ProjectUID").Value <string>(), SystemFullName = token.SelectToken("SystemFullName").Value <string>(), UID = token.SelectToken("UID").Value <string>(), }; List <CSpecification> children = new List <CSpecification>(); var json_children = token.SelectToken("children"); if (json_children != null && json_children.HasValues) { foreach (var child in (JArray)json_children) { CSpecification v = new CSpecification() { ClassType = child.SelectToken("ClassType").Value <string>(), ProjectName = child.SelectToken("ProjectName").Value <string>(), OverlayName = child.SelectToken("OverlayName").Value <string>(), Description = child.SelectToken("Description").Value <string>(), IsClientPicture = child.SelectToken("IsClientPicture").Value <bool>(), IsEditable = child.SelectToken("IsEditable").Value <bool>(), IsReauthenticationRequired = child.SelectToken("IsReauthenticationRequired").Value <bool>(), Name = child.SelectToken("Name").Value <string>(), NestedName = child.SelectToken("NestedName").Value <string>(), ObjectUID = child.SelectToken("ObjectUID").Value <string>(), OverlayUID = child.SelectToken("OverlayUID").Value <string>(), Picture = child.SelectToken("Picture").Value <string>(), ProjectUID = child.SelectToken("ProjectUID").Value <string>(), SystemFullName = child.SelectToken("SystemFullName").Value <string>(), UID = child.SelectToken("UID").Value <string>(), children = null, }; v.CachedValue = ""; children.Add(v); } s.children = children; } result.Add(s); } return(result); }
public async Task <View> GetAttributesView(CSpecification spec, CObject obj, string language) { StackLayout layout = new StackLayout(); var html = await m_ComosWeb.GetObjectSpecificationAsHtml( m_Navigator, spec.ProjectUID, spec.OverlayUID, language, obj.UID, spec.Name); var attributes = CHtmlParser.ParseAttributes(html); foreach (var attribute in attributes.Items) { var lbl = new Label(); lbl.Text = attribute.Description + " = " + attribute.Value; if (attribute.HasUnits) { lbl.Text += " " + attribute.Unit; } layout.Children.Add(lbl); } return(layout); /* * StackLayout layout = new StackLayout(); * AbsoluteLayout stack = new AbsoluteLayout(); * var html = await m_ComosWeb.GetObjectSpecificationAsHtml( * m_Navigator.Database, spec.ProjectUID, spec.OverlayUID, language, obj.UID, spec.Name); * int maxheight = 0; * var attributes = CHtmlParser.ParseAttributes(html); * foreach (var attribute in attributes.Items) * { * if(attribute.Controls != null) * { * foreach (var ctrl in attribute.Controls) * { * System.Diagnostics.Debug.WriteLine( * string.Format("{0} {1} {2} {3}", * ctrl.X, ctrl.Y, ctrl.Width, ctrl.Height)); * if (maxheight < ctrl.Y) * maxheight = ctrl.Y; * switch (ctrl.UIType) * { * case UIType.SUICheckBox: * { * Switch c = new Switch() * { * IsToggled = bool.Parse(attribute.Value), * }; * AbsoluteLayout.SetLayoutBounds(c, new Rectangle( * ctrl.X, ctrl.Y, ctrl.Width, ctrl.Height)); * stack.Children.Add(c); * } * break; * case UIType.SUIText: * { * Label c = new Label() * { * Text = attribute.Description, * }; * AbsoluteLayout.SetLayoutBounds(c, new Rectangle( * ctrl.X, ctrl.Y, ctrl.Width, ctrl.Height)); * stack.Children.Add(c); * } * break; * case UIType.SUIOpenButton: * case UIType.SUITimeButton: * default: * break; * } * } * } * } * stack.MinimumHeightRequest = maxheight; * stack.HeightRequest = maxheight; * layout.Children.Add(stack); * return layout; */ }