private void AddElement(Dictionary <string, string> template) { var keys = new List <string> { "Resource", "ActionType" }; var clonedAttributes = Attributes .Where(a => !keys.Contains(a.Key)) .ToDictionary(a => a.Key, a => a.Value); foreach (var item in template) { clonedAttributes[item.Key] = item.Value; } var element = new ListElement(); AttributeHelper.ApplyTranslation(element, clonedAttributes); foreach (var i in listViewComponent.ItemsSource) { if (!string.IsNullOrEmpty(i.Id) && i.Id == element.Id) { listViewComponent.ItemsSource.Remove(i); break; } } listViewComponent.ItemsSource.Add(element); }
public View Render() { StackLayout stackLayout = new StackLayout() { Margin = new Thickness(5) }; View = stackLayout; if (!string.IsNullOrWhiteSpace(Label)) { Label label = new Label { Text = Label, Margin = new Thickness(5, 0, 0, 0), FontAttributes = FontAttributes.Bold }; if (ElementTextColor != null) { label.TextColor = ElementTextColor; } stackLayout.Children.Add(label); } entry = new Entry() { Text = Value, Keyboard = (Keyboard) new KeyboardTypeConverter().ConvertFromInvariantString(Keyboard ?? "Default") }; if (Required) { entry.Placeholder = "(Required)"; } stackLayout.Children.Add(entry); if (ElementBackgroundColor != null) { entry.BackgroundColor = ElementBackgroundColor; } if (ElementTextColor != null) { entry.TextColor = ElementTextColor; } entry.TextChanged += (s, e) => { if (AutoPostBack) { PostBack?.Invoke(s, Key); } }; AttributeHelper.ApplyTranslation(entry, Attributes); return(View); }
private void PreConfigureStyles() { AttributeHelper.ApplyTranslation(listViewComponent, Attributes); if (Attributes.ContainsKey("Columns")) { Attributes.Remove("Columns"); } }
private void AddElement(ListElement element) { AttributeHelper.ApplyTranslation(element, Attributes); foreach (var i in listViewComponent.ItemsSource) { if (!string.IsNullOrEmpty(i.Id) && i.Id == element.Id) { listViewComponent.ItemsSource.Remove(i); break; } } listViewComponent.ItemsSource.Add(element); }
public MenuPage(MobilePage page) { InitializeComponent(); var layoutManager = new Utilities.LayoutManager(page.Layout); var layout = layoutManager.Content; //Modify the page with attributes AttributeHelper.ApplyTranslation(this, page.Attributes); //Put blocks into the layout foreach (var block in page.Blocks) { var blockType = Type.GetType(block.BlockType); if (blockType != null) { IRenderable mobileBlock = ( IRenderable )Activator.CreateInstance(blockType); mobileBlock.Attributes = block.Attributes; //Setup postback handler if required if (mobileBlock is IHasBlockMessenger) { var hasPostbackBlock = mobileBlock as IHasBlockMessenger; hasPostbackBlock.MessageHandler = new BlockMessenger(block.BlockId); } var zone = layoutManager.GetElement(block.Zone); if (zone != null) { try { var renderedBlock = mobileBlock.Render(); AttributeHelper.ApplyTranslation(renderedBlock, mobileBlock.Attributes); zone.Children.Add(renderedBlock); } catch (Exception e) { // } } } } MainStackLayout.Children.Add(layout); Menu = layout; }
public View Render() { StackLayout stackLayout = new StackLayout() { Margin = new Thickness(5) }; View = stackLayout; if (!string.IsNullOrWhiteSpace(Label)) { Label label = new Label { Text = Label, Margin = new Thickness(5, 0, 0, 0), FontAttributes = FontAttributes.Bold }; if (ElementTextColor != null) { label.TextColor = ElementTextColor; } stackLayout.Children.Add(label); } labelValue = new Label() { Text = Value, }; stackLayout.Children.Add(labelValue); if (ElementTextColor != null) { labelValue.TextColor = ElementTextColor; } AttributeHelper.ApplyTranslation(labelValue, Attributes); return(View); }
private void HandleResponse() { foreach (var block in notifyBlock) { block.OnDisappearing(); } notifyBlock.Clear(); mediaBlocks.Clear(); var page = observableResource.Resource as MobilePage; this.Title = page.Title; layoutManager = new Utilities.LayoutManager(page.Layout); var layout = layoutManager.Content; if (page.ShowTitle) { AddTitleBar(layout, page); } //Modify the page with attributes AttributeHelper.ApplyTranslation(this, page.Attributes); //Put blocks into the layout foreach (var block in page.Blocks) { var blockType = Type.GetType(block.BlockType); if (blockType != null) { IRenderable mobileBlock = ( IRenderable )Activator.CreateInstance(blockType); mobileBlock.Attributes = block.Attributes; //Setup postback handler if required if (mobileBlock is IHasBlockMessenger) { var hasPostbackBlock = mobileBlock as IHasBlockMessenger; hasPostbackBlock.MessageHandler = new BlockMessenger(block.BlockId); } var zone = layoutManager.GetElement(block.Zone); if (zone != null) { try { var renderedBlock = mobileBlock.Render(); AttributeHelper.ApplyTranslation(renderedBlock, mobileBlock.Attributes); zone.Children.Add(renderedBlock); //Get blocks that need notfication of appearing and disappearing if (renderedBlock is INotify) { notifyBlock.Add(( INotify )renderedBlock); } //Setup media if needed if (renderedBlock is IHasMedia) { var mediaBlock = ( IHasMedia )renderedBlock; mediaBlocks.Add(mediaBlock); mediaBlock.FullScreenChanged += MediaBlock_FullScreenChanged; } blocks.Add(renderedBlock); } catch (Exception e) { // } } } } if (ActivityIndicator.IsRunning == false) { layout.Opacity = 0; MainGrid.Children.Clear(); AddBackgroundImage(); MainGrid.Children.Add(layout); layout.FadeTo(1, 500, Easing.CubicInOut); } else { MainGrid.Children.Add(layout); ActivityIndicator.IsRunning = false; } btnBack.IsVisible = false; lTimeout.IsVisible = false; OnAppearing(); //iOS fires OnAppearing before the page can be rendered. }
private void HandleResponse() { var page = observableResource.Resource as MobilePage; this.Title = page.Title; var layoutType = Type.GetType("Avalanche.Layouts." + page.LayoutType.Replace(" ", "")); if (layoutType == null) { AvalancheNavigation.RemovePage(); return; } var layout = ( ContentView )Activator.CreateInstance(layoutType); if (page.ShowTitle) { AddTitleBar(layout, page); } //Modify the page with attributes AttributeHelper.ApplyTranslation(this, page.Attributes); //Put blocks into the layout foreach (var block in page.Blocks) { var blockType = Type.GetType(block.BlockType); if (blockType != null) { IRenderable mobileBlock = ( IRenderable )Activator.CreateInstance(blockType); mobileBlock.Attributes = block.Attributes; //Setup postback handler if required if (mobileBlock is IHasBlockMessenger) { var hasPostbackBlock = mobileBlock as IHasBlockMessenger; hasPostbackBlock.MessageHandler = new BlockMessenger(block.BlockId); } var zone = layout.FindByName <Layout <View> >(block.Zone); if (zone != null) { try { var renderedBlock = mobileBlock.Render(); AttributeHelper.ApplyTranslation(renderedBlock, mobileBlock.Attributes); zone.Children.Add(renderedBlock); } catch (Exception e) { // } } } } if (ActivityIndicator.IsRunning == false) { layout.Opacity = 0; MainGrid.Children.Clear(); AddBackgroundImage(); MainGrid.Children.Add(layout); layout.FadeTo(1, 500, Easing.CubicInOut); } else { MainGrid.Children.Add(layout); ActivityIndicator.IsRunning = false; } btnBack.IsVisible = false; lTimeout.IsVisible = false; }