示例#1
0
文件: Entry.cs 项目: dolani/CodeTorch
        public void Init()
        {
            ViewHelper.DefaultViewProperties(this);

            this.IsPassword = Me.IsPassword;

            Device.OnPlatform(
                Android: () =>
            {
                this.Text        = OnPlatformString.GetAndroidValue(Me.Text);
                this.Placeholder = OnPlatformString.GetAndroidValue(Me.Placeholder);

                if (!String.IsNullOrEmpty(OnPlatformString.GetAndroidValue(Me.TextColor)))
                {
                    this.TextColor = Color.FromHex(OnPlatformString.GetAndroidValue(Me.TextColor));
                }
            },
                iOS: () =>
            {
                this.Text        = OnPlatformString.GetiOSValue(Me.Text);
                this.Placeholder = OnPlatformString.GetiOSValue(Me.Placeholder);

                if (!String.IsNullOrEmpty(OnPlatformString.GetiOSValue(Me.TextColor)))
                {
                    this.TextColor = Color.FromHex(OnPlatformString.GetiOSValue(Me.TextColor));
                }
            },
                WinPhone: () =>
            {
                this.Text        = OnPlatformString.GetWinPhoneValue(Me.Text);
                this.Placeholder = OnPlatformString.GetWinPhoneValue(Me.Placeholder);

                if (!String.IsNullOrEmpty(OnPlatformString.GetWinPhoneValue(Me.TextColor)))
                {
                    this.TextColor = Color.FromHex(OnPlatformString.GetWinPhoneValue(Me.TextColor));
                }
            }
                );
        }
示例#2
0
 private IView GetView(Page page, MobileScreen screen, BaseControl control)
 {
     return(ViewHelper.GetView(page, screen, control));
 }
示例#3
0
        public void Init()
        {
            ViewHelper.DefaultViewProperties(this);

            Device.OnPlatform(
                Android: () =>
            {
                //this.BorderWidth = OnPlatformInt.GetAndroidValue(Me.BorderWidth);
                //this.BorderRadius = OnPlatformInt.GetAndroidValue(Me.BorderRadius);

                if (!String.IsNullOrEmpty(OnPlatformString.GetAndroidValue(Me.BorderColor)))
                {
                    this.BorderColor = Color.FromHex(OnPlatformString.GetAndroidValue(Me.BorderColor));
                }

                if (!String.IsNullOrEmpty(OnPlatformString.GetAndroidValue(Me.Image)))
                {
                    try
                    {
                        this.Image = ImageSource.FromFile(OnPlatformString.GetAndroidValue(Me.Image)) as FileImageSource;
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine("Error while trying to load button image {1}: {0} ", ex.Message, Me.Image);
                    }
                }


                this.Text = OnPlatformString.GetAndroidValue(Me.Text);

                if (!String.IsNullOrEmpty(OnPlatformString.GetAndroidValue(Me.TextColor)))
                {
                    this.TextColor = Color.FromHex(OnPlatformString.GetAndroidValue(Me.TextColor));
                }
            },
                iOS: () =>
            {
                if (!String.IsNullOrEmpty(OnPlatformString.GetiOSValue(Me.BorderColor)))
                {
                    this.BorderColor = Color.FromHex(OnPlatformString.GetiOSValue(Me.BorderColor));
                }

                if (!String.IsNullOrEmpty(OnPlatformString.GetiOSValue(Me.Image)))
                {
                    try
                    {
                        this.Image = ImageSource.FromFile(OnPlatformString.GetiOSValue(Me.Image)) as FileImageSource;
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine("Error while trying to load button image {1}: {0} ", ex.Message, Me.Image);
                    }
                }


                this.Text = OnPlatformString.GetiOSValue(Me.Text);

                if (!String.IsNullOrEmpty(OnPlatformString.GetiOSValue(Me.TextColor)))
                {
                    this.TextColor = Color.FromHex(OnPlatformString.GetiOSValue(Me.TextColor));
                }
            },
                WinPhone: () =>
            {
                if (!String.IsNullOrEmpty(OnPlatformString.GetWinPhoneValue(Me.BorderColor)))
                {
                    this.BorderColor = Color.FromHex(OnPlatformString.GetWinPhoneValue(Me.BorderColor));
                }

                if (!String.IsNullOrEmpty(OnPlatformString.GetWinPhoneValue(Me.Image)))
                {
                    try
                    {
                        this.Image = ImageSource.FromFile(OnPlatformString.GetWinPhoneValue(Me.Image)) as FileImageSource;
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine("Error while trying to load button image {1}: {0} ", ex.Message, Me.Image);
                    }
                }


                this.Text = OnPlatformString.GetWinPhoneValue(Me.Text);

                if (!String.IsNullOrEmpty(OnPlatformString.GetWinPhoneValue(Me.TextColor)))
                {
                    this.TextColor = Color.FromHex(OnPlatformString.GetWinPhoneValue(Me.TextColor));
                }
            }


                );

            this.Clicked += Button_Clicked;
        }