public GreetPage() { InitializeComponent(); slider.Value = 0.5; var x = new OnPlatform <Thickness> { Android = new Thickness(0), iOS = new Thickness(0, 20, 0, 0) }; Padding = x; }
public void WinPhoneColor() { MockForms.Init(Device.WinPhone); var platformColor = new OnPlatform <Color>(); platformColor.Platforms.Add(new On { Value = Color.Red, Platform = new[] { Device.WinPhone } }); Assert.AreEqual(Color.Red, (Color)platformColor); }
public void DefaultColor() { MockForms.Init(); var platformColor = new OnPlatform <Color>(); platformColor.Platforms.Add(new On { Value = Color.Red, Platform = new[] { Device.RuntimePlatform } }); Assert.AreEqual(Color.Red, (Color)platformColor); }
public TimeCollectionView() : base() { this.Title = this.ViewModel.Title; OnPlatform <Thickness> op = (OnPlatform <Thickness>)Application.Current.Resources["PagePadding"]; this.Padding = Device.OnPlatform(op.iOS, op.Android, op.WinPhone); // Call MessagingCenter.Send<Page>(Page, Message.RefreshMainPage) from any Page to refresh this page MessagingCenter.Subscribe <Page>(this, Message.RefreshMainPage, async(sender) => { await this.Refresh(); }); }
public void DefaultString() { MockForms.Init(); var platformString = new OnPlatform <string>(); platformString.Platforms.Add(new On { Value = "Chuck", Platform = new[] { Device.RuntimePlatform } }); Assert.AreEqual("Chuck", (string)platformString); }
public ExpenseCollectionView() : base() { this.Title = this.ViewModel.Title; // This is needed to prevent the toolbar from overlapping on the controls in the page. OnPlatform <Thickness> op = (OnPlatform <Thickness>)Application.Current.Resources["PagePadding"]; this.Padding = Device.OnPlatform(op.iOS, op.Android, op.WinPhone); // Call MessagingCenter.Send<Page>(Page, Message.RefreshMainPage) from any Page to refresh this page MessagingCenter.Subscribe <Page>(this, Message.RefreshMainPage, async(sender) => { await this.Refresh(); }); }
public MainPage() { NavigationPage.SetHasNavigationBar(this, false); Padding = new OnPlatform<Thickness> { iOS = new Thickness(0,20,0,0), Android = new Thickness(0), WinPhone = new Thickness(0) }; Label lblStatus = new Label(); lblStatus.Text = ""; Button btnLeagueStats = new Button(); btnLeagueStats.Text = "Search Summoner"; btnLeagueStats.HorizontalOptions = LayoutOptions.Center; btnLeagueStats.Clicked += async (s, e) => { await Navigation.PushAsync(new FcpSummoner() ); }; Button btnChampions = new Button(); //btnChampions.Image = (FileImageSource)ImageSource.FromResource("LeagueStatsMobile.Resources.ChampionProfile.Jax.png"); btnChampions.Text = "Search Champions"; btnChampions.HorizontalOptions = LayoutOptions.Center; btnChampions.Clicked += async (s, e) => { lblStatus.Text = "Loading"; await Navigation.PushAsync(new FcpChampions()); }; this.Content = new StackLayout { Padding = new Thickness(14, 20, 14, 20), VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Black, Children = { new Label { Text = "Main Page", HorizontalOptions = LayoutOptions.Center, XAlign = TextAlignment.Center }, new Label { Text = "Testing grounds", XAlign = TextAlignment.Start }, btnLeagueStats, btnChampions, lblStatus } }; }
public void macOSColor() { MockForms.Init(Device.macOS); var platformColor = new OnPlatform <Color> { Default = Color.Blue }; platformColor.Platforms.Add(new On { Value = Color.Red, Platform = new[] { Device.macOS } }); Assert.AreNotEqual(Color.Blue, (Color)platformColor); Assert.AreEqual(Color.Red, (Color)platformColor); }
public static T Resolve <T>(this OnPlatform <T> value) { if (value == null) { return(default(T)); } switch (Device.RuntimePlatform) { case Device.Android: return(value.Android); case Device.iOS: return(value.iOS); case Device.UWP: return(value.WinPhone); default: return(value.Default); } }
public GreetPage() { InitializeComponent(); slider.Value = 0.5; var x = new OnPlatform <Thickness>() { Android = new Thickness(0), iOS = new Thickness(0, 20, 0, 0) }; Padding = x; //if (Device.OS == TargetPlatform.iOS) // Padding = new Thickness(0, 20, 0, 0); //else if (Device.OS == TargetPlatform.Android) // Padding = new Thickness(10, 20, 0, 0); //else if (Device.OS == TargetPlatform.WinPhone) // Padding = new Thickness(30, 20, 0, 0); //Padding = Device.OnPlatform(iOS: new Thickness(0, 20, 0, 0), // Android: new Thickness(10, 20, 0, 0), // WinPhone: new Thickness(30, 20, 0, 0)); //Device.OnPlatform(iOS: () => //{ // Padding = new Thickness(0, 20, 0, 0); //}, //Android: () => //{ // //.. //}); //Content = new Label() //{ // HorizontalOptions = LayoutOptions.Center, // VerticalOptions = LayoutOptions.Center, // Text = "Hello World" //}; }
public FramedTextPage() { Padding = new Thickness(20); //Padding = new Thickness(5, Device.OnPlatform(20, 5, 5), 5, 5); Padding = new OnPlatform <Thickness> { iOS = new Thickness(0, 20, 0, 0), Android = new Thickness(5), WinPhone = new Thickness(5) }; Content = new Frame { //OutlineColor = Color.Accent, OutlineColor = Color.Default, Content = new Label { Text = "I've been framed!", FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center } }; }
public CodeContentPage() { OnPlatform <string> FontDictionary = Application.Current.Resources["FontAwesomeRegular"] as OnPlatform <string>; string CharValueAsString = ParseHexValueToString("f58b"); string Font = FontDictionary; Debug.WriteLine(string.Format("{0}:{1}", "Font", Font)); Content = new StackLayout { Children = { new Label { Text = ParseHexValueToString("f58b"), VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand, FontSize = 36, FontFamily = Font } } }; }
public void OnPlatformConstructor() { tlog.Debug(tag, $"OnPlatformConstructor START"); var testingTarget = new OnPlatform <string>(); Assert.IsNotNull(testingTarget, "Can't create success object OnPlatform."); Assert.IsInstanceOf <OnPlatform <string> >(testingTarget, "Should return OnPlatform instance."); testingTarget.Android = "Android"; Assert.AreEqual("Android", testingTarget.Android, "Should be equal"); testingTarget.iOS = "iOS"; Assert.AreEqual("iOS", testingTarget.iOS, "Should be equal"); testingTarget.WinPhone = "WinPhone"; Assert.AreEqual("WinPhone", testingTarget.WinPhone, "Should be equal"); testingTarget.Default = "Default"; Assert.AreEqual("Default", testingTarget.Default, "Should be equal"); Assert.IsNotNull(testingTarget.Platforms, "Should not be null."); tlog.Debug(tag, $"OnPlatformConstructor END"); }
public static string TextFontFamily(bool bold = false, bool italic = false, bool standart = false) { string font = String.Empty; if (standart || (Game.Data.Constants == null) || String.IsNullOrEmpty(Game.Data.Constants.GetFont())) { font = (bold ? "YanoneFontBold" : "YanoneFont"); } else { font = String.Format("{0}{1}", Game.Data.Constants.GetFont(), (bold ? "Bold" : String.Empty)); } if (italic) { font = "RobotoFontItalic"; } OnPlatform <string> OnPlatformDic = (OnPlatform <string>)App.Current.Resources[font]; var fontFamily = OnPlatformDic.Platforms.FirstOrDefault((arg) => arg.Platform.FirstOrDefault() == Device.RuntimePlatform).Value; return(fontFamily.ToString()); }
/// <summary> /// Creates a new instance of the <see cref="MainTabBarView"/> class. /// </summary> public MainTabBarView() { this.logService = DependencyService.Resolve <ILogService>(); // Set default values here. OnPlatform <string> fontFamily = (OnPlatform <string>)Application.Current.Resources["FontAwesomeSolid"]; this.Button1FontFamily = fontFamily; this.Button2FontFamily = fontFamily; this.Button3FontFamily = fontFamily; InitializeComponent(); Button1.SetBinding(Button.CommandProperty, new Binding(nameof(Button1Command), source: this)); Button2.SetBinding(Button.CommandProperty, new Binding(nameof(Button2Command), source: this)); Button3.SetBinding(Button.CommandProperty, new Binding(nameof(Button3Command), source: this)); Button1.SetBinding(Button.FontFamilyProperty, new Binding(nameof(Button1FontFamily), source: this)); Button2.SetBinding(Button.FontFamilyProperty, new Binding(nameof(Button2FontFamily), source: this)); Button3.SetBinding(Button.FontFamilyProperty, new Binding(nameof(Button3FontFamily), source: this)); Button1.SetBinding(Button.TextProperty, new Binding(nameof(Button1Text), source: this)); Button2.SetBinding(Button.TextProperty, new Binding(nameof(Button2Text), source: this)); Button3.SetBinding(Button.TextProperty, new Binding(nameof(Button3Text), source: this)); }
private void InitializeComponent() { if (ResourceLoader.CanProvideContentFor(new ResourceLoader.ResourceLoadingQuery { AssemblyName = typeof(App).GetTypeInfo().Assembly.GetName(), ResourcePath = "App.xaml", Instance = this })) { __InitComponentRuntime(); return; } if (XamlLoader.XamlFileProvider != null && XamlLoader.XamlFileProvider(GetType()) != null) { __InitComponentRuntime(); return; } On on = new On(); On on2 = new On(); OnPlatform <string> onPlatform = new OnPlatform <string>(); On on3 = new On(); On on4 = new On(); OnPlatform <string> onPlatform2 = new OnPlatform <string>(); On on5 = new On(); On on6 = new On(); OnPlatform <string> onPlatform3 = new OnPlatform <string>(); Color color = new Color(0.18823529779911041, 0.18823529779911041, 0.18431372940540314, 1.0); Color color2 = new Color(0.49019607901573181, 0.48627451062202454, 0.48627451062202454, 1.0); Color color3 = new Color(0.72156864404678345, 0.72156864404678345, 0.72156864404678345, 1.0); Color color4 = new Color(0.97254902124404907, 0.96078431606292725, 0.9686274528503418, 1.0); Color color5 = new Color(0.886274516582489, 0.0235294122248888, 0.074509806931018829, 1.0); ResourceDictionary resourceDictionary = new ResourceDictionary(); App app; NameScope value = (NameScope)(NameScope.GetNameScope(app = this) ?? new NameScope()); NameScope.SetNameScope(app, value); app.Resources = resourceDictionary; VisualDiagnostics.RegisterSourceInfo(resourceDictionary, new Uri("App.xaml", UriKind.RelativeOrAbsolute), 8, 10); on.Platform = new List <string>(1) { "Android" }; on.Value = "Fonts/TCL-Light_0.otf#TCL"; onPlatform.Platforms.Add(on); VisualDiagnostics.RegisterSourceInfo(on, new Uri("App.xaml", UriKind.RelativeOrAbsolute), 10, 18); on2.Platform = new List <string>(1) { "iOS" }; on2.Value = "TCL-Light"; onPlatform.Platforms.Add(on2); VisualDiagnostics.RegisterSourceInfo(on2, new Uri("App.xaml", UriKind.RelativeOrAbsolute), 11, 18); resourceDictionary.Add("TCLLight", onPlatform); on3.Platform = new List <string>(1) { "Android" }; on3.Value = "Fonts/TCL-Regular_0.otf#TCL"; onPlatform2.Platforms.Add(on3); VisualDiagnostics.RegisterSourceInfo(on3, new Uri("App.xaml", UriKind.RelativeOrAbsolute), 14, 18); on4.Platform = new List <string>(1) { "iOS" }; on4.Value = "TCL-Regular"; onPlatform2.Platforms.Add(on4); VisualDiagnostics.RegisterSourceInfo(on4, new Uri("App.xaml", UriKind.RelativeOrAbsolute), 15, 18); resourceDictionary.Add("TCLRegular", onPlatform2); on5.Platform = new List <string>(1) { "Android" }; on5.Value = "Fonts/TCL-Bold_0.otf#TCL"; onPlatform3.Platforms.Add(on5); VisualDiagnostics.RegisterSourceInfo(on5, new Uri("App.xaml", UriKind.RelativeOrAbsolute), 18, 18); on6.Platform = new List <string>(1) { "iOS" }; on6.Value = "TCL-Bold"; onPlatform3.Platforms.Add(on6); VisualDiagnostics.RegisterSourceInfo(on6, new Uri("App.xaml", UriKind.RelativeOrAbsolute), 19, 18); resourceDictionary.Add("TCLBold", onPlatform3); resourceDictionary.Add("DarkGrayColor", color); resourceDictionary.Add("MediumGrayColor", color2); resourceDictionary.Add("DisabledGrayColor", color3); resourceDictionary.Add("LightGrayColor", color4); resourceDictionary.Add("TCLRed", color5); app.Resources = resourceDictionary; VisualDiagnostics.RegisterSourceInfo(resourceDictionary, new Uri("App.xaml", UriKind.RelativeOrAbsolute), 8, 10); VisualDiagnostics.RegisterSourceInfo(app, new Uri("App.xaml", UriKind.RelativeOrAbsolute), 2, 2); }
public static On GetPlatFormValue <T>(this OnPlatform <T> onPlatform, string platform) { return(onPlatform?.Platforms.FirstOrDefault(p => p.Platform.Contains(platform))); }
protected override void Init() { if (Application.Current.Resources == null) { Application.Current.Resources = new ResourceDictionary(); } if (!Application.Current.Resources.ContainsKey("SomeSmallImage")) { var smallImage = new OnPlatform <ImageSource> { Android = ImageSource.FromFile("coffee.png"), WinPhone = ImageSource.FromFile("bank.png"), iOS = ImageSource.FromFile("coffee.png") }; Application.Current.Resources.Add("SomeSmallImage", smallImage); } const string instructions1 = @"Tap the Start button and follow the instructions on the next page."; string instructions2 = $"When you return to this page, tap the Collect button. The message \n'{Bugzilla42069_Page.DestructorMessage}'\n should appear at least once in the debug output."; var label1 = new Label { Text = instructions1 }; var label2 = new Label { Text = instructions2, HorizontalTextAlignment = TextAlignment.Center }; var startButton = new Button { Text = "Start" }; startButton.Clicked += (sender, args) => { // We have to do the push-pop-push dance because NavigationPage // holds a reference to its last page for unrelated reasons; our concern // here is that the first Bugzilla42069_Page that we pushed gets collected PushAsync(new Bugzilla42069_Page(), false); PopAsync(false); PushAsync(new Bugzilla42069_Page(), false); }; var collectButton = new Button { Text = "Collect" }; collectButton.Clicked += (sender, args) => { GC.Collect(); GC.Collect(); GC.Collect(); }; var startPage = new ContentPage { Content = new StackLayout { Children = { label1, startButton, label2, collectButton } } }; PushAsync(startPage); }