private void SetPlaceholder(ExtendedLabel view) { if (view == null) { return; } if (view.FormattedText != null) { this.Control.AttributedText = view.FormattedText.ToAttributed(view.Font, view.TextColor); LayoutSubviews(); return; } if (!string.IsNullOrEmpty(view.Text)) { this.UpdateUi(view); LayoutSubviews(); return; } if (string.IsNullOrWhiteSpace(view.Placeholder) && view.FormattedPlaceholder == null) { return; } var formattedPlaceholder = view.FormattedPlaceholder ?? view.Placeholder; Control.AttributedText = formattedPlaceholder.ToAttributed(view.Font, view.TextColor); LayoutSubviews(); }
public ExtendedLabelPage() { InitializeComponent(); BindingContext = ViewModelLocator.Main; var label = new ExtendedLabel { Text = "From code, using Device.OnPlatform, Underlined", FontName = "Open 24 Display St.ttf", FriendlyFontName = Device.OnPlatform("", "", "Open 24 Display St"), IsUnderline = true, FontSize = 22, }; var label2 = new ExtendedLabel { Text = "From code, Strikethrough", FontName = "Open 24 Display St.ttf", FriendlyFontName = Device.OnPlatform("", "", "Open 24 Display St"), IsUnderline = false, IsStrikeThrough = true, FontSize = 22, }; var font = Font.OfSize("Open 24 Display St", 22); var label3 = new ExtendedLabel { Text = "From code, Strikethrough and using Font property", TextColor = Device.OnPlatform(Color.Black,Color.White, Color.White), IsUnderline = false, IsStrikeThrough = true }; var label4 = new ExtendedLabel { IsDropShadow = true, DropShadowColor = Color.Red, Text = "From code, Dropshadow with TextColor", TextColor = Color.Green }; var label5 = new Label { Text = "Standard Label created using code", }; label3.Font = font; stkRoot.Children.Add(label4); stkRoot.Children.Add(label3); stkRoot.Children.Add(label2); stkRoot.Children.Add(label); stkRoot.Children.Add(label5); }
static void UpdateUi(ExtendedLabel view, TextView control) { if (view.FontSize > 0) { control.TextSize = (float)view.FontSize; } if (view.IsUnderline) { control.PaintFlags = control.PaintFlags | PaintFlags.UnderlineText; } }
/// <summary> /// Updates the UI. /// </summary> /// <param name="view"> /// The view. /// </param> /// <param name="control"> /// The control. /// </param> private void UpdateUi(ExtendedLabel view, TextBlock control) { if (view == null || control == null) { return; } ////need to do this ahead of font change due to unexpected behaviour if done later. if (view.IsStrikeThrough) { //isn't perfect, but it's a start var border = new Border { Height = 2, Width = Control.ActualWidth, Background = control.Foreground, HorizontalAlignment = HorizontalAlignment.Center }; Canvas.SetTop(border, control.FontSize * .72); //Canvas.SetTop(border, (this.Control.ActualHeight / 2) - 0.5); this.Children.Add(border); //// STILL IN DEVELOPMENT === alternative and possibly more flexible grid method - Got stuck making this controls parent the grid below //var strikeThroughGrid = new System.Windows.Controls.Grid(); //strikeThroughGrid.VerticalAlignment = VerticalAlignment.Top; //strikeThroughGrid.HorizontalAlignment = HorizontalAlignment.Left; ////define rows //var colDef1 = new System.Windows.Controls.RowDefinition { Height = new System.Windows.GridLength(1, System.Windows.GridUnitType.Star) }; //var colDef2 = new System.Windows.Controls.RowDefinition { Height = new System.Windows.GridLength(1, System.Windows.GridUnitType.Star) }; //strikeThroughGrid.RowDefinitions.Add(colDef1); //strikeThroughGrid.RowDefinitions.Add(colDef2); ////add textblock //strikeThroughGrid.Children.Add(control); //System.Windows.Controls.Grid.SetRowSpan(control,2); ////add border //var strikethroughBorder = new Border{BorderThickness = new System.Windows.Thickness(0,0,0,2) , BorderBrush = control.Foreground , Padding = new System.Windows.Thickness(0,0,0,control.FontSize*0.3)}; //strikeThroughGrid.Children.Add(strikethroughBorder); } if (view.IsUnderline) { control.TextDecorations = TextDecorations.Underline; } if (view.IsDropShadow) { //TODO: Implement dropshadow } }
private static void UpdateUi(ExtendedLabel view, UILabel control) { var font = UIFont.SystemFontOfSize((view.FontSize > 0) ? (float)view.FontSize : 12.0f); // regular control.Font = font; var attrString = new NSMutableAttributedString(control.Text); if (view.IsUnderline) { attrString.AddAttribute(UIStringAttributeKey.UnderlineStyle, NSNumber.FromInt32((int)NSUnderlineStyle.Single), new NSRange(0, attrString.Length)); } control.AttributedText = attrString; }
/// <summary> /// Updates the UI. /// </summary> /// <param name="view"> /// The view. /// </param> /// <param name="control"> /// The control. /// </param> private void UpdateUi(ExtendedLabel view, UILabel control) { if (view == null || control == null) { return; } //Do not create attributed string if it is not necesarry if (!view.IsUnderline && !view.IsStrikeThrough && !view.IsDropShadow) { return; } var underline = view.IsUnderline ? NSUnderlineStyle.Single : NSUnderlineStyle.None; var strikethrough = view.IsStrikeThrough ? NSUnderlineStyle.Single : NSUnderlineStyle.None; NSShadow dropShadow = null; if (view.IsDropShadow) { dropShadow = new NSShadow { ShadowColor = UIColor.DarkGray, ShadowBlurRadius = 1.4f, ShadowOffset = new CoreGraphics.CGSize(new CoreGraphics.CGPoint(0.3f, 0.8f)) }; } // For some reason, if we try and convert Color.Default to a UIColor, the resulting color is // either white or transparent. The net result is the ExtendedLabel does not display. // Only setting the control's TextColor if is not Color.Default will prevent this issue. if (view.TextColor != Color.Default) { control.TextColor = view.TextColor.ToUIColor(); } control.AttributedText = new NSMutableAttributedString(control.Text, control.Font, underlineStyle: underline, strikethroughStyle: strikethrough, shadow: dropShadow); }
/// <summary> /// Updates the UI. /// </summary> /// <param name="view">The view.</param> /// <param name="control">The control.</param> void UpdateUi(ExtendedLabel view, TextView control) { if(!string.IsNullOrEmpty(view.FontName)) { string filename = view.FontName; //if no extension given then assume and add .ttf if(filename.LastIndexOf(".", System.StringComparison.Ordinal) != filename.Length - 4) { filename = string.Format("{0}.ttf", filename); } control.Typeface = TrySetFont(filename); } //======= This is for backward compatability with obsolete attrbute 'FontNameAndroid' ======== else if(!string.IsNullOrEmpty(view.FontNameAndroid)) { control.Typeface = TrySetFont(view.FontNameAndroid); } //====== End of obsolete section ========================================================== else if(view.Font != Font.Default) { control.Typeface = view.Font.ToExtendedTypeface(Context); } if(view.FontSize > 0) { control.TextSize = (float)view.FontSize; } if(view.IsUnderline) { control.PaintFlags = control.PaintFlags | PaintFlags.UnderlineText; } if(view.IsStrikeThrough) { control.PaintFlags = control.PaintFlags | PaintFlags.StrikeThruText; } }
/// <summary> /// Updates the UI. /// </summary> /// <param name="view">The view.</param> /// <param name="control">The control.</param> void UpdateUi(ExtendedLabel view, TextView control) { if (!string.IsNullOrEmpty(view.FontName)) { string filename = view.FontName; //if no extension given then assume and add .ttf if (filename.LastIndexOf(".", System.StringComparison.Ordinal) != filename.Length - 4) { filename = string.Format("{0}.ttf", filename); } control.Typeface = TrySetFont(filename); } //======= This is for backward compatability with obsolete attrbute 'FontNameAndroid' ======== else if (!string.IsNullOrEmpty(view.FontNameAndroid)) { control.Typeface = TrySetFont(view.FontNameAndroid); } //====== End of obsolete section ========================================================== else if (view.Font != Font.Default) { control.Typeface = view.Font.ToExtendedTypeface(Context); } if (view.FontSize > 0) { control.TextSize = (float)view.FontSize; } if (view.IsUnderline) { control.PaintFlags = control.PaintFlags | PaintFlags.UnderlineText; } if (view.IsStrikeThrough) { control.PaintFlags = control.PaintFlags | PaintFlags.StrikeThruText; } }
/// <summary> /// Updates the UI. /// </summary> /// <param name="view">The view.</param> /// <param name="control">The control.</param> void UpdateUi(ExtendedLabel view, TextView control) { if (view == null || control == null) { return; } if (view.IsUnderline) { control.PaintFlags = control.PaintFlags | PaintFlags.UnderlineText; } if (view.IsStrikeThrough) { control.PaintFlags = control.PaintFlags | PaintFlags.StrikeThruText; } if (view.IsDropShadow) { //TODO:: Needs implementation } }
/// <summary> /// Updates the UI. /// </summary> /// <param name="view"> /// The view. /// </param> /// <param name="control"> /// The control. /// </param> private void UpdateUi(ExtendedLabel view, TextBlock control) { if (view.FontSize > 0) { control.FontSize = (float)view.FontSize; } //control.FontSize = (view.FontSize > 0) ? (float)view.FontSize : 12.0f; ////need to do this ahead of font change due to unexpected behaviour if done later. if (view.IsStrikeThrough) { //isn't perfect, but it's a start var border = new Border { Height = 2, Width = Control.ActualWidth, Background = control.Foreground, HorizontalAlignment = HorizontalAlignment.Center }; Canvas.SetTop(border, control.FontSize * .72); //Canvas.SetTop(border, (this.Control.ActualHeight / 2) - 0.5); this.Children.Add(border); //// STILL IN DEVELOPMENT === alternative and possibly more flexible grid method - Got stuck making this controls parent the grid below //var strikeThroughGrid = new System.Windows.Controls.Grid(); //strikeThroughGrid.VerticalAlignment = VerticalAlignment.Top; //strikeThroughGrid.HorizontalAlignment = HorizontalAlignment.Left; ////define rows //var colDef1 = new System.Windows.Controls.RowDefinition { Height = new System.Windows.GridLength(1, System.Windows.GridUnitType.Star) }; //var colDef2 = new System.Windows.Controls.RowDefinition { Height = new System.Windows.GridLength(1, System.Windows.GridUnitType.Star) }; //strikeThroughGrid.RowDefinitions.Add(colDef1); //strikeThroughGrid.RowDefinitions.Add(colDef2); ////add textblock //strikeThroughGrid.Children.Add(control); //System.Windows.Controls.Grid.SetRowSpan(control,2); ////add border //var strikethroughBorder = new Border{BorderThickness = new System.Windows.Thickness(0,0,0,2) , BorderBrush = control.Foreground , Padding = new System.Windows.Thickness(0,0,0,control.FontSize*0.3)}; //strikeThroughGrid.Children.Add(strikethroughBorder); } if (!string.IsNullOrEmpty(view.FontName)) { string filename = view.FontName; //if no extension given then assume and add .ttf if (filename.LastIndexOf(".", StringComparison.Ordinal) != filename.Length - 4) { filename = string.Format("{0}.ttf", filename); } if (LocalFontFileExists(filename)) //only substitute custom font if exists { control.FontFamily = new FontFamily(string.Format(@"\Assets\Fonts\{0}#{1}", filename, string.IsNullOrEmpty(view.FriendlyFontName) ? filename.Substring(0, filename.Length - 4) : view.FriendlyFontName)); } } if (view.IsUnderline) { control.TextDecorations = TextDecorations.Underline; } }
/// <summary> /// Updates the UI. /// </summary> /// <param name="view"> /// The view. /// </param> private void UpdateUi(ExtendedLabel view) { // Prefer font set through Font property. if (view.Font == Font.Default) { if (view.FontSize > 0) { this.Control.Font = UIFont.FromName(this.Control.Font.Name, (float)view.FontSize); } if (!string.IsNullOrEmpty(view.FontName)) { var fontName = Path.GetFileNameWithoutExtension(view.FontName); var font = UIFont.FromName(fontName, this.Control.Font.PointSize); if (font != null) { this.Control.Font = font; } } #region ======= This is for backward compatability with obsolete attrbute 'FontNameIOS' ======== if (!string.IsNullOrEmpty(view.FontNameIOS)) { var font = UIFont.FromName(view.FontNameIOS, (view.FontSize > 0) ? (float)view.FontSize : 12.0f); if (font != null) { this.Control.Font = font; } } #endregion ====== End of obsolete section ========================================================== } //Do not create attributed string if it is not necesarry //if (!view.IsUnderline && !view.IsStrikeThrough && !view.IsDropShadow) //{ // return; //} var underline = view.IsUnderline ? NSUnderlineStyle.Single : NSUnderlineStyle.None; var strikethrough = view.IsStrikeThrough ? NSUnderlineStyle.Single : NSUnderlineStyle.None; NSShadow dropShadow = null; if (view.IsDropShadow) { dropShadow = new NSShadow { ShadowColor = UIColor.DarkGray, ShadowBlurRadius = 1.4f, ShadowOffset = new CoreGraphics.CGSize(new CoreGraphics.CGPoint(0.3f, 0.8f)) }; } // For some reason, if we try and convert Color.Default to a UIColor, the resulting color is // either white or transparent. The net result is the ExtendedLabel does not display. // Only setting the control's TextColor if is not Color.Default will prevent this issue. if (view.TextColor != Color.Default) { this.Control.TextColor = view.TextColor.ToUIColor(); } this.Control.AttributedText = new NSMutableAttributedString(view.Text, this.Control.Font, underlineStyle: underline, strikethroughStyle: strikethrough, shadow: dropShadow); ; }
/// <summary> /// Updates the UI. /// </summary> /// <param name="view"> /// The view. /// </param> /// <param name="control"> /// The control. /// </param> private void UpdateUi(ExtendedLabel view, TextBlock control) { if (view.FontSize > 0) control.FontSize = (float) view.FontSize; //control.FontSize = (view.FontSize > 0) ? (float)view.FontSize : 12.0f; ////need to do this ahead of font change due to unexpected behaviour if done later. if (view.IsStrikeThrough) { //isn't perfect, but it's a start var border = new Border { Height = 2, Width = Control.ActualWidth, Background = control.Foreground, HorizontalAlignment = HorizontalAlignment.Center }; Canvas.SetTop(border, control.FontSize*.72); //Canvas.SetTop(border, (this.Control.ActualHeight / 2) - 0.5); this.Children.Add(border); //// STILL IN DEVELOPMENT === alternative and possibly more flexible grid method - Got stuck making this controls parent the grid below //var strikeThroughGrid = new System.Windows.Controls.Grid(); //strikeThroughGrid.VerticalAlignment = VerticalAlignment.Top; //strikeThroughGrid.HorizontalAlignment = HorizontalAlignment.Left; ////define rows //var colDef1 = new System.Windows.Controls.RowDefinition { Height = new System.Windows.GridLength(1, System.Windows.GridUnitType.Star) }; //var colDef2 = new System.Windows.Controls.RowDefinition { Height = new System.Windows.GridLength(1, System.Windows.GridUnitType.Star) }; //strikeThroughGrid.RowDefinitions.Add(colDef1); //strikeThroughGrid.RowDefinitions.Add(colDef2); ////add textblock //strikeThroughGrid.Children.Add(control); //System.Windows.Controls.Grid.SetRowSpan(control,2); ////add border //var strikethroughBorder = new Border{BorderThickness = new System.Windows.Thickness(0,0,0,2) , BorderBrush = control.Foreground , Padding = new System.Windows.Thickness(0,0,0,control.FontSize*0.3)}; //strikeThroughGrid.Children.Add(strikethroughBorder); } if (!string.IsNullOrEmpty(view.FontName)) { string filename = view.FontName; //if no extension given then assume and add .ttf if (filename.LastIndexOf(".", StringComparison.Ordinal) != filename.Length - 4) { filename = string.Format("{0}.ttf", filename); } if (LocalFontFileExists(filename)) //only substitute custom font if exists { control.FontFamily = new FontFamily(string.Format(@"\Assets\Fonts\{0}#{1}", filename, string.IsNullOrEmpty(view.FriendlyFontName) ? filename.Substring(0, filename.Length - 4) : view.FriendlyFontName)); } } if (view.IsUnderline) control.TextDecorations = TextDecorations.Underline; }
public RelevantLinksScreen() { //creating layouts to store each of the images within the grid //without this the background of the grid is white when we want //it to be black #region imageIconLayouts StackLayout logoLayout = new StackLayout { BackgroundColor = App.QUTBlue, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(4, 0, 0, 0) }; #endregion //creating each of the image icons for //the grid with their tap commands to load //correct file #region imageIcons Image logo = new Image { Source = "QutLogoHeader.png", HeightRequest = (App.screenHeight / 10) - 4, HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; #endregion logoLayout.Children.Add(logo); //The Labels for all the Links within the Links section # region Links //Activity 1 text and links Label Activity1 = new Label { Text = "1. Old Government House", BackgroundColor = Color.Black, TextColor = Color.White, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link1a = new ExtendedLabel { Text = "• http://www.ogh.qut.edu.au/", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link1b = new ExtendedLabel { Text = "• http://www.govhouse.qld.gov.au/the-governor-of-queensland/about-the-governor.aspx", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link1c = new ExtendedLabel { Text = "• http://www.ogh.qut.edu.au/history/the_house/", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; Label link1d= new Label { Text = "• Michelle Sanson and Thalia Anthony, Connecting with Law (Oxford University Press, 3rd ed, 2014 382.", BackgroundColor = Color.Black, TextColor = App.appContentColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), HorizontalTextAlignment = TextAlignment.Start }; //End activity 1 text and links //Activity 2 Text and Links Label Activity2 = new Label { Text = "2. Parliament House", BackgroundColor = Color.Black, TextColor = Color.White, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link2a = new ExtendedLabel { Text = "• http://www.parliament.qld.gov.au/", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link2b = new ExtendedLabel { Text = "• http://www.ogh.qut.edu.au/about/history/political/keyevents.jsp", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link2c= new ExtendedLabel { Text = "• http://www.parliament.qld.gov.au/explore/education/factsheets/6", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link2d = new ExtendedLabel { Text = "• https://www.youtube.com/watch?v=IVUItgaQALM", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; Label link2e = new Label { Text = "• Michelle Sanson and Thalia Anthony, Connecting with Law (Oxford University Press 3rd ed, 2014 126.", BackgroundColor = Color.Black, TextColor = App.appContentColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), HorizontalTextAlignment = TextAlignment.Start }; //End activity 2 text and links //Activity 3 Text and Links Label Activity3 = new Label { Text = "3. Executive Building", BackgroundColor = Color.Black, TextColor = Color.White, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalTextAlignment = TextAlignment.Start }; Label link3a = new Label { Text = "• Michelle Sanson and Thalia Anthony, Connecting with Law (Oxford University Press 3rd ed, 2014 129-130.", BackgroundColor = Color.Black, TextColor = App.appContentColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), HorizontalTextAlignment = TextAlignment.Start }; //End activity 3 text and links //Activity 4 Text and Links Label Activity4 = new Label { Text = "4. Inns of Court", BackgroundColor = Color.Black, TextColor = Color.White, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link4a = new ExtendedLabel { Text = "• http://www.innsofcourt.com.au/", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link4b = new ExtendedLabel { Text = "• https://www.qldbar.asn.au/#/about-the-bar", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; //End activity 4 text and links //Activity 5 Text and Links Label Activity5 = new Label { Text = "5. Commonwealth Law Courts", BackgroundColor = Color.Black, TextColor = Color.White, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link5a = new ExtendedLabel { Text = "• http://www.hcourt.gov.au/", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link5b = new ExtendedLabel { Text = "• http://www.fedcourt.gov.au", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link5c = new ExtendedLabel { Text = "• http://www.familycourt.gov.au", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link5d = new ExtendedLabel { Text = "• http://www.hcourt.gov.au/registry/court-calendars", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link5e = new ExtendedLabel { Text = "• http://www.hcourt.gov.au/justices/about-the-justices", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link5f = new ExtendedLabel { Text = "• http://www5.austlii.edu.au/au/legis/cth/consol_act/hcoaa1979233/s7.html", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; //End activity 5 text and links //Activity 6 Text and Links Label Activity6 = new Label { Text = "6. Magistrates Court", BackgroundColor = Color.Black, TextColor = Color.White, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link6a = new ExtendedLabel { Text = "• http://www.courts.qld.gov.au/courts/magistrates-court", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link6b = new ExtendedLabel { Text = "• http://www.qld.gov.au/law/court/going-to-court/courtroom-rules/", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; Label link6c = new Label { Text = "• Michelle Sanson and Thalia Anthony, Connecting with Law (Oxford University Press, 3rd ed, 2014 132-139.", BackgroundColor = Color.Black, TextColor = App.appContentColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), HorizontalTextAlignment = TextAlignment.Start }; //End activity 6 text and links //Activity 7 Text and Links Label Activity7 = new Label { Text = "7. Queen Elizabeth II Courts Complex", BackgroundColor = Color.Black, TextColor = Color.White, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link7a = new ExtendedLabel { Text = "• http://archive.sclqld.org.au/judgepub/dj260401.pdf", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link7b = new ExtendedLabel { Text = "• http://www.courts.qld.gov.au/courts/district-court", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; ExtendedLabel link7c = new ExtendedLabel { Text = "• http://www.courts.qld.gov.au/courts/supreme-court", BackgroundColor = Color.Black, TextColor = App.linkTextColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), IsUnderline = true, HorizontalTextAlignment = TextAlignment.Start }; Label link7d = new Label { Text = "• Michelle Sanson and Thalia Anthony, Connecting with Law (Oxford University Press, 3rd ed, 2014 131-133.", BackgroundColor = Color.Black, TextColor = App.appContentColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), HorizontalTextAlignment = TextAlignment.Start }; //End activity 7 text and links //Error label Label error = new Label { Text = "Something went wrong while loading. Please try again by clicking back and reloading the page", BackgroundColor = Color.Black, TextColor = App.appContentColour, FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), HorizontalTextAlignment = TextAlignment.Start }; #endregion //Tap registers for all the Link labels # region LinkGestures link1a.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("http://www.ogh.qut.edu.au/"))) }); link1b.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("http://www.govhouse.qld.gov.au/the-governor-of-queensland/about-the-governor.aspx"))) }); link1c.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("http://www.ogh.qut.edu.au/history/the_house/"))) }); link2a.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("http://www.parliament.qld.gov.au/"))) }); link2b.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("http://www.ogh.qut.edu.au/about/history/political/keyevents.jsp"))) }); link2c.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("http://www.parliament.qld.gov.au/explore/education/factsheets/6"))) }); link2d.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("https://www.youtube.com/watch?v=IVUItgaQALM"))) }); link4a.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("http://www.innsofcourt.com.au/"))) }); link4b.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("https://www.qldbar.asn.au/#/about-the-bar"))) }); link5a.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("http://www.hcourt.gov.au/"))) }); link5b.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("www.fedcourt.gov.au"))) }); link5c.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("www.familycourt.gov.au"))) }); link5d.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("http://www.hcourt.gov.au/registry/court-calendars"))) }); link5e.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("http://www.hcourt.gov.au/justices/about-the-justices"))) }); link5f.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("http://www5.austlii.edu.au/au/legis/cth/consol_act/hcoaa1979233/s7.html"))) }); link6a.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("http://www.courts.qld.gov.au/courts/magistrates-court"))) }); link6b.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("http://www.qld.gov.au/law/court/going-to-court/courtroom-rules/"))) }); link7a.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("http://archive.sclqld.org.au/judgepub/dj260401.pdf"))) }); link7b.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("http://www.courts.qld.gov.au/courts/district-court"))) }); link7c.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Device.OpenUri(new Uri("http://www.courts.qld.gov.au/courts/supreme-court"))) }); #endregion //StackLayout for all the text of the links StackLayout LinksContent = new StackLayout { Padding = new Thickness(3, 0, 4, 0), BackgroundColor = Color.Black }; //Adds links depending on current task being conducted if (App.currentActivity == 1) { LinksContent.Children.Add(Activity1); LinksContent.Children.Add(link1a); LinksContent.Children.Add(link1b); LinksContent.Children.Add(link1c); LinksContent.Children.Add(link1d); } else if (App.currentActivity == 2) { LinksContent.Children.Add(Activity2); LinksContent.Children.Add(link2a); LinksContent.Children.Add(link2b); LinksContent.Children.Add(link2c); LinksContent.Children.Add(link2d); LinksContent.Children.Add(link2e); } else if (App.currentActivity == 3) { LinksContent.Children.Add(Activity3); LinksContent.Children.Add(link3a); } else if (App.currentActivity == 4) { LinksContent.Children.Add(Activity4); LinksContent.Children.Add(link4a); LinksContent.Children.Add(link4b); } else if (App.currentActivity == 5) { LinksContent.Children.Add(Activity5); LinksContent.Children.Add(link5a); LinksContent.Children.Add(link5b); LinksContent.Children.Add(link5c); LinksContent.Children.Add(link5d); LinksContent.Children.Add(link5e); LinksContent.Children.Add(link5f); } else if (App.currentActivity == 6) { LinksContent.Children.Add(Activity6); LinksContent.Children.Add(link6a); LinksContent.Children.Add(link6b); LinksContent.Children.Add(link6c); } else if (App.currentActivity == 7) { LinksContent.Children.Add(Activity7); LinksContent.Children.Add(link7a); LinksContent.Children.Add(link7b); LinksContent.Children.Add(link7c); LinksContent.Children.Add(link7d); } else { LinksContent.Children.Add(error); } Label backLbl = new Label { Text = "<", BackgroundColor = App.QUTBlue, TextColor = Color.White, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) + 4, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center }; backLbl.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => goBack()) }); Grid pageGrid = new Grid { VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand, BackgroundColor = Color.White, Opacity = 0.8, //row and column spacing creates a "bordered" //effect around each element RowSpacing = 2, ColumnSpacing = 2, IsClippedToBounds = true, Padding = new Thickness(.5, 1, .5, 0), //all row heights, and column widths are relative to //the devices screen size/resolution so they should //be an appropriate size on each type of device RowDefinitions = { new RowDefinition {Height = 0}, new RowDefinition {Height = App.screenHeight / 10}, new RowDefinition {Height = App.screenHeight / 1.213}, new RowDefinition {Height = 0} }, ColumnDefinitions = { new ColumnDefinition {Width = 0}, new ColumnDefinition {Width = App.screenWidth / 10}, new ColumnDefinition {Width = App.screenWidth / 5 - 32}, new ColumnDefinition {Width = App.screenWidth / 5}, new ColumnDefinition {Width = App.screenWidth / 5}, new ColumnDefinition {Width = App.screenWidth / 5}, new ColumnDefinition {Width = App.screenWidth / 10}, new ColumnDefinition {Width = 0} } }; //scrollview for the question editor ScrollView LinksText = new ScrollView { IsClippedToBounds = true, Content = LinksContent }; //adding each element to the grid pageGrid.Children.Add(backLbl, 1, 1); //back button pageGrid.Children.Add(logoLayout, 2, 7, 1, 2); //qut logo pageGrid.Children.Add(LinksText, 1, 7, 2, 3);//scrolling text StackLayout innerContent = new StackLayout { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, }; innerContent.Children.Add(pageGrid); //making the pages content the stacklayout with the grid this.Content = innerContent; //add padding to account for the iOS status bar this.Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0); this.BackgroundImage = "background.png"; }
/// <summary> /// Updates the UI. /// </summary> /// <param name="view"> /// The view. /// </param> private void UpdateUi(ExtendedLabel view) { // Prefer font set through Font property. if (view.Font == Font.Default) { if (view.FontSize > 0) { this.Control.Font = UIFont.FromName(this.Control.Font.Name, (float)view.FontSize); } if (!string.IsNullOrEmpty(view.FontName)) { var fontName = Path.GetFileNameWithoutExtension(view.FontName); var font = UIFont.FromName(fontName, this.Control.Font.PointSize); if (font != null) { this.Control.Font = font; } } #region ======= This is for backward compatability with obsolete attrbute 'FontNameIOS' ======== if (!string.IsNullOrEmpty(view.FontNameIOS)) { var font = UIFont.FromName(view.FontNameIOS, (view.FontSize > 0) ? (float)view.FontSize : 12.0f); if (font != null) { this.Control.Font = font; } } #endregion ====== End of obsolete section ========================================================== } //Do not create attributed string if it is not necesarry //if (!view.IsUnderline && !view.IsStrikeThrough && !view.IsDropShadow) //{ // return; //} var underline = view.IsUnderline ? NSUnderlineStyle.Single : NSUnderlineStyle.None; var strikethrough = view.IsStrikeThrough ? NSUnderlineStyle.Single : NSUnderlineStyle.None; NSShadow dropShadow = null; if (view.IsDropShadow) { dropShadow = new NSShadow { ShadowColor = view.DropShadowColor.ToUIColor(), ShadowBlurRadius = 1.4f, ShadowOffset = new CoreGraphics.CGSize(new CoreGraphics.CGPoint(0.3f, 0.8f)) }; } // For some reason, if we try and convert Color.Default to a UIColor, the resulting color is // either white or transparent. The net result is the ExtendedLabel does not display. // Only setting the control's TextColor if is not Color.Default will prevent this issue. if (view.TextColor != Color.Default) { this.Control.TextColor = view.TextColor.ToUIColor(); } this.Control.AttributedText = new NSMutableAttributedString(view.Text, this.Control.Font, underlineStyle: underline, strikethroughStyle: strikethrough, shadow: dropShadow);; }
public UserLoginView () { BindingContext = new UserViewModel(this.Navigation); var indicator = new ActivityIndicator { Color = Colors.DarkGray.ToFormsColor(), }; indicator.SetBinding (ActivityIndicator.IsRunningProperty, "IsLoading"); indicator.SetBinding (ActivityIndicator.IsVisibleProperty, "IsLoading"); img_Logo = new Image { HeightRequest = Width/4, WidthRequest = Width/4, HorizontalOptions = LayoutOptions.Center, Source="AppLogo.png", }; txt_Email = new EditText { WidthRequest = Width, HorizontalOptions = LayoutOptions.Center, Keyboard=Keyboard.Email, Placeholder="Email", TextColor=Colors.DarkGray.ToFormsColor(), BackgroundColor=Color.Transparent, HeightRequest=Width/10, Text="*****@*****.**" }; txt_Email.SetBinding(Entry.TextProperty, "Username"); txt_Password = new EditText { WidthRequest = Width, HorizontalOptions = LayoutOptions.Center, IsPassword=true, Placeholder="Password", TextColor=Colors.DarkGray.ToFormsColor(), BackgroundColor=Color.Transparent, HeightRequest=Width/10, Text="123" }; txt_Password.SetBinding(Entry.TextProperty, "Password"); btn_Login= new Button { WidthRequest = Width/2, HorizontalOptions = LayoutOptions.Center, HeightRequest=Width/8, Text="Login", FontSize=17, TextColor=Color.White, BackgroundColor=Colors.DarkGray.ToFormsColor(), CommandParameter=1, Command=ViewModel.LoginUser }; lbl_Registration = new ExtendedLabel { WidthRequest = Width, Text="Sing Up", HorizontalOptions = LayoutOptions.Start, TextColor=Colors.DarkGray.ToFormsColor(), BackgroundColor=Color.Transparent, FontSize=18, IsUnderline=true }; var Regtap = new TapGestureRecognizer(OnRegistrationTapped); Regtap.NumberOfTapsRequired = 1; lbl_Registration.IsEnabled = true; lbl_Registration.GestureRecognizers.Clear(); lbl_Registration.GestureRecognizers.Add(Regtap); lbl_Forgot = new ExtendedLabel { WidthRequest = Width, Text="Forgot Password ?", HorizontalOptions = LayoutOptions.End, TextColor=Colors.DarkGray.ToFormsColor(), BackgroundColor=Color.Transparent, FontSize=18, IsUnderline=true }; var Forgottap = new TapGestureRecognizer(OnForgotPasswordTapped); Forgottap.NumberOfTapsRequired = 1; lbl_Forgot.IsEnabled = true; lbl_Forgot.GestureRecognizers.Clear(); lbl_Forgot.GestureRecognizers.Add(Forgottap); stack_BottomView = new StackLayout { HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions=LayoutOptions.Fill, //BackgroundColor=Color.Aqua, Orientation=StackOrientation.Horizontal, Children= { lbl_Registration,lbl_Forgot } }; stack_MainLayout = new StackLayout { HorizontalOptions = LayoutOptions.Fill, VerticalOptions=LayoutOptions.Fill, BackgroundColor=Color.White, WidthRequest=Width, Padding=new Thickness(Width/10,Width/10,Width/10,Width/10), Spacing=Width/10, HeightRequest=Height, Children = { indicator,img_Logo,txt_Email,txt_Password,btn_Login,stack_BottomView } }; this.Content = stack_MainLayout; }