protected override void OnAttached()
        {
            if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.JellyBean)
            {
                _trueColor  = (Color)Element.GetValue(ChangeColorEffect.TrueColorProperty);
                _falseColor = (Color)Element.GetValue(ChangeColorEffect.FalseColorProperty);

                ((SwitchCompat)Control).CheckedChange += OnCheckedChange;

                //Supported formats for Parse are: #RRGGBB #AARRGGBB 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray'
                ((SwitchCompat)Control).ThumbDrawable.SetColorFilter(_falseColor.ToAndroid(), PorterDuff.Mode.Multiply);
            }

            //TODO: Glenn - From lollipop mr1 you can also use the TintList instead of working with events... not sure what the best approach is
            //if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.LollipopMr1)
            //{
            //    ColorStateList buttonStates = new ColorStateList(new int[][]
            //        {
            //            new int[] {Android.Resource.Attribute.StateChecked},
            //            new int[] {-Android.Resource.Attribute.StateEnabled},
            //            new int[] {}
            //        },
            //        new int[]
            //        {
            //            Android.Graphics.Color.Red,
            //            Android.Graphics.Color.Blue,
            //            Android.Graphics.Color.Green
            //        }
            //    );

            //    ((SwitchCompat)Control).ThumbDrawable.SetTintList(buttonStates);
            //}
        }
 public static Xamarin.Forms.Color MixOpacity(this Xamarin.Forms.Color color, float opacity)
 {
     return(new Xamarin.Forms.Color(
                color.R, color.G, color.B,
                Math.Min(color.A, opacity)
                ));
 }
Exemple #3
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string htmlColorCode = value.ToString();

            Xamarin.Forms.Color col = Xamarin.Forms.Color.FromHex(htmlColorCode);
            return(col);
        }
 private void BtnStop_OnClicked(object sender, EventArgs e)
 {
     _isTimerStart = false;
     Stop();
     BackgroundColor    = Color.FromHex((nColor[value].ToString()));
     rotatingLabel.Text = $"Belt Level: {Belts[value]}";
 }
        private void ProcessText()
        {
            if (Control == null || Element == null)
            {
                return;
            }

            Xamarin.Forms.Color linkColor = ((HtmlLabel)Element).LinkColor;
            if (!linkColor.IsDefault)
            {
                Control.SetLinkTextColor(linkColor.ToAndroid());
            }

            Control.SetIncludeFontPadding(false);
            var isRtl      = Device.FlowDirection == FlowDirection.RightToLeft;
            var styledHtml = new RendererHelper(Element, Control.Text, Device.RuntimePlatform, isRtl).ToString();

            /*
             * Android's TextView doesn't support lists.
             * List tags must be replaces with custom tags,
             * that it will be renderer by a custom tag handler.
             */
            styledHtml = styledHtml
                         ?.ReplaceTag(_tagUlRegex, ListTagHandler.TagUl)
                         ?.ReplaceTag(_tagOlRegex, ListTagHandler.TagOl)
                         ?.ReplaceTag(_tagLiRegex, ListTagHandler.TagLi);

            if (styledHtml != null)
            {
                SetText(Control, styledHtml);
            }
        }
Exemple #6
0
        public static UIColor ToUIColor(this Color color, UIColor defaultColor)
        {
            if (color.IsDefault)
                return defaultColor;

            return color.ToUIColor();
        }
Exemple #7
0
        public void ShortAlert(string message)
        {
            var toast = Android.Widget.Toast.MakeText(Android.App.Application.Context, message, ToastLength.Short);

            if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Q)
            {
                toast.View.Background.SetColorFilter(new BlendModeColorFilter(Color.FromHex(DefaultBackgroundColor).ToAndroid(), BlendMode.SrcIn));
            }
            else
            {
#pragma warning disable CS0618 // Type or member is obsolete
                toast.View.Background.SetColorFilter(Color.FromHex(DefaultBackgroundColor).ToAndroid(), Android.Graphics.PorterDuff.Mode.SrcIn);
#pragma warning restore CS0618 // Type or member is obsolete
            }

            var textView = toast.View.FindViewById <TextView>(Android.Resource.Id.Message);
            textView.SetTextColor(Color.White.ToAndroid());

            var deviceInfoService = DependencyService.Get <IDeviceInfoService>();
            var pixelDensity      = (int)deviceInfoService.PixelDensity;

            toast.SetGravity(Android.Views.GravityFlags.Bottom | Android.Views.GravityFlags.CenterHorizontal, 0, 100 * pixelDensity);

            toast.Show();
        }
Exemple #8
0
 public MasterMenuItem(string Title, string IconSource, Color color, Type target)
 {
     this.Title           = Title;
     this.IconSource      = IconSource;
     this.BackgroundColor = color;
     this.TargetType      = target;
 }
 public static void UpdateFromFormsControl(this TextView textView, string text, Color formsColor, Font formsFont, TextAlignment textAlignment)
 {
     textView.Text = text;
     textView.SetTextColor(formsColor.ToAndroid(Color.Default));
     textView.UpdateFont(formsFont);
     textView.Gravity = textAlignment.ToNative();
 }
Exemple #10
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int parameterType = int.Parse(parameter.ToString());

            Xamarin.Forms.Color background = Color.Silver;
            var user     = (User)value;
            var userName = Settings.ChatID;

            if (user.UserId == userName)
            {
                background = Color.FromHex("#FFFFFF");
                if (parameterType == 0)
                {
                    background = Color.FromHex("#F1F0F0");
                }
            }
            else
            {
                background = Color.FromHex("#F1F0F0");
                if (parameterType == 0)
                {
                    background = Color.FromHex("#FF5252");
                }
            }

            return(background);
        }
 protected override void OnAttachedTo(ExtendedEntry bindable)
 {
     bindable.Unfocused += HandleTextUnfocused;
     control             = bindable;
     _placeHolder        = bindable.Placeholder;
     _placeHolderColor   = bindable.PlaceholderColor;
 }
Exemple #12
0
        /// <summary>
        /// Get image stream from points
        /// </summary>
        /// <param name="points">Drawing points</param>
        /// <param name="imageSize">Image size</param>
        /// <param name="lineWidth">Line Width</param>
        /// <param name="strokeColor">Line color</param>
        /// <param name="backgroundColor">Image background color</param>
        /// <returns>Image stream</returns>
        public static Stream GetImageStream(IList <Point>?points,
                                            Size imageSize,
                                            float lineWidth,
                                            Color strokeColor,
                                            Color backgroundColor)
        {
            if (points == null || points.Count < 2)
            {
                return(Stream.Null);
            }

            var image = GetImageInternal(points, lineWidth, strokeColor, backgroundColor);

            if (image == null)
            {
                return(Stream.Null);
            }

            using var resizedImage = MaxResizeImage(image, (float)imageSize.Width, (float)imageSize.Height);
            var stream         = new MemoryStream();
            var compressResult = resizedImage.Compress(Bitmap.CompressFormat.Jpeg, 100, stream);

            resizedImage.Recycle();

            if (!compressResult)
            {
                return(Stream.Null);
            }

            stream.Position = 0;
            return(stream);
        }
		public static void UpdateFromFormsControl (this UILabel uiLabel, string text, TextAlignment textAlignment, Color textColor, Font font)
		{
			uiLabel.Text = text;
			uiLabel.TextAlignment = textAlignment.ToUITextAlignment ();
			uiLabel.TextColor = textColor.ToUIColor ();
			uiLabel.Font = font.ToUIFont ();
		}
        async void OnColorButtonClicked(object sender, EventArgs e)
        {
            if (sender is XButton button)
            {
                string[] buttons =
                {
                    "Aqua",        "Azure",       "Beige",      "Bisque",       "Black",         "Blue",          "BlueViolet",    "Brown",      "Chocolate",
                    "Coral",       "Crimson",     "Cyan",       "DarkBlue",     "DarkCyan",      "DarkGoldenrod", "DarkGray",      "DarkGreen",  "DarkKhaki","DarkMagenta",   "DarkOliveGreen", "DarkOrange",
                    "DarkOrchid",  "DarkRed",     "DarkSalmon", "DarkSeaGreen", "DarkSlateBlue", "DarkSlateGray", "DarkTurquoise", "DarkViolet", "DeepPink", "DeepSkyBlue",
                    "FloralWhite", "Fuchsia",     "Gold",       "Gray",         "Green",         "GreenYellow",   "Honeydew",      "HotPink",    "IndianRed","Indigo",
                    "Ivory",       "Khaki",       "Lavender",   "LightBlue",    "LightCoral",    "LightPink",     "LightSkyBlue",  "Lime",       "Magenta",  "MidnightBlue",
                    "Navy",        "Olive",       "Orange",     "OrangeRed",    "Orchid",        "PaleGreen",     "Pink",          "Purple",     "Red",      "Silver",
                    "SkyBlue",     "Transparent", "Violet",     "Wheat",        "White",         "Yellow",        "YellowGreen"
                };
                string ret = await Application.Current.MainPage.DisplayActionSheet("Choose Color", "Cancel", "Default", buttons);

                XColor color = (XColor)(_converter.ConvertFromInvariantString(ret));
                if (color.IsDefault)
                {
                    ApplyDefaultColor(button);
                }
                else
                {
                    button.BackgroundColor = color;
                }
            }
        }
Exemple #15
0
 public Light(bool isOn, string name, Xamarin.Forms.Color color, string comment)
 {
     this.IsOn    = isOn;
     this.Name    = name;
     this.Color   = color;
     this.Comment = comment;
 }
Exemple #16
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int parameterType = int.Parse(parameter.ToString());

            Xamarin.Forms.Color background = Color.Silver;
            var user     = (User)value;
            var userName = Settings.UserId;

            if (user.UserId == userName)
            {
                background = Color.White;
                if (parameterType == 0)
                {
                    background = Color.Black;
                }
            }
            else
            {
                background = Color.Black;
                if (parameterType == 0)
                {
                    background = Color.White;
                }
            }

            return(background);
        }
        private void Button_Interest(object sender, EventArgs e)
        {
            var looper = gridInterest.Children.Where(x => x is Button);

            foreach (Button btn in looper)
            {
                btn.BackgroundColor = Color.Default;
                btn.BorderColor     = Color.Transparent;
                btn.BorderWidth     = 0;
            }
            Button btne = (Button)sender;

            btne.BackgroundColor = Color.Transparent;
            btne.BorderWidth     = 2;
            btne.BorderColor     = Color.FromHex("3cc5d5");
            if (btne == womenInterestButton)
            {
                interestIn = "0";
            }
            else if (btne == menInterestButton)
            {
                interestIn = "1";
            }
            else if (btne == everyoneInterestButton)
            {
                interestIn = "2";
            }
        }
Exemple #18
0
 public MarginFrame(int marginLeft, int marginTop, int marginRight, int marginBottom, Color backgroundColor)
 {
     Padding = new Thickness(marginLeft, marginTop, marginRight, marginBottom);
     OutlineColor = backgroundColor;
     BackgroundColor = backgroundColor;
     HasShadow = false;
 }
Exemple #19
0
 void SetWebViewBackgroundColor(Xamarin.Forms.Color backgroundColor)
 {
     if (Control != null)
     {
         Control.DefaultBackgroundColor = ToWindowsColor(backgroundColor);
     }
 }
        void ApplyBorder(int width, Color color, int cornerRadius)
        {
            var topLeftCorner     = Context.ToPixels(cornerRadius);
            var topRightCorner    = Context.ToPixels(cornerRadius);
            var bottomLeftCorner  = Context.ToPixels(cornerRadius);
            var bottomRightCorner = Context.ToPixels(cornerRadius);

            var cornerRadii = new[]
            {
                topLeftCorner,
                topLeftCorner,

                topRightCorner,
                topRightCorner,

                bottomRightCorner,
                bottomRightCorner,

                bottomLeftCorner,
                bottomLeftCorner,
            };



            GradientDrawable gd = new GradientDrawable();

            gd.SetCornerRadii(cornerRadii);
            //gd.SetCornerRadius(cornerRadius);
            gd.SetStroke(width, color.ToAndroid());
            this.Control.Background = gd;
        }
		public void SetColorTheme(ColorTheme appTheme)
		{
			_colorActive = appTheme.ColorPincodePageInputActive;
			_colorInactive = appTheme.ColorPincodePageInputInactive;
			_colorSet = appTheme.ColorPincodePageInputVisited;
			_colorText = appTheme.ColorPincodePageTextInput;
		}
        public void ShortAlert(string message)
        {
            var toast = Android.Widget.Toast.MakeText(Android.App.Application.Context, message, ToastLength.Short);

            // On API Level 30+ only simple toast messages can be displayed. No customizations to the toast background and view are permitted: https://developer.android.com/reference/android/widget/Toast#getView()
            if (Android.OS.Build.VERSION.SdkInt <= Android.OS.BuildVersionCodes.Q)
            {
                var backgroundColor = Xamarin.Forms.Application.Current.RequestedTheme == OSAppTheme.Dark
                  ? DefaultBackgroundColorDark
                  : DefaultBackgroundColorLight;
                if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Q)
                {
                    toast.View.Background.SetColorFilter(new BlendModeColorFilter(Color.FromHex(backgroundColor).ToAndroid(), BlendMode.SrcIn));
                }
                else
                {
#pragma warning disable CS0618 // Type or member is obsolete
                    toast.View.Background.SetColorFilter(Color.FromHex(backgroundColor).ToAndroid(), Android.Graphics.PorterDuff.Mode.SrcIn);
#pragma warning restore CS0618 // Type or member is obsolete
                }

                var textView = toast.View.FindViewById <TextView>(Android.Resource.Id.Message);
                textView.SetTextColor(Color.White.ToAndroid());
            }

            var deviceInfoService = DependencyService.Get <IDeviceInfoService>();
            var pixelDensity      = (int)deviceInfoService.PixelDensity;

            toast.SetGravity(Android.Views.GravityFlags.Bottom | Android.Views.GravityFlags.CenterHorizontal, 0, 100 * pixelDensity);

            toast.Show();
        }
        public void SetOrderStatusFrameColor(string OrderStatus)
        {
            OrderStatusColor = new Color();
            OrderStatusColor = Color.CadetBlue;
            UpdateBtnStatus  = true;

            if (OrderStatus.ToLower() == "delivered")
            {
                OrderStatusColor = Color.Green;
            }
            else if (OrderStatus.ToLower() == "cancelled")
            {
                OrderStatusColor = Color.DarkRed;
                UpdateBtnStatus  = false;
            }
            else if (OrderStatus.ToLower() == "completed")
            {
                OrderStatusColor = Color.Green;
                UpdateBtnStatus  = false;
            }
            else if (OrderStatus.ToLower() == "rejected")
            {
                OrderStatusColor = Color.DarkRed;
                UpdateBtnStatus  = false;
            }
        }
Exemple #24
0
        protected override View GetCellCore(Cell item, View convertView, ViewGroup parent, Context context)
        {
            var cell = (LinearLayout)base.GetCellCore(item, convertView, parent, context);

            cell.SetPadding(20, 10, 0, 10);
            cell.DividerPadding = 50;

            var div = new ShapeDrawable();

            div.SetIntrinsicHeight(1);
            //div.Paint.Set(new Paint { Color = Color.FromHex("00FFFFFF").ToAndroid() });

            if (parent is ListView)
            {
                ((ListView)parent).Divider       = div;
                ((ListView)parent).DividerHeight = 1;
            }


            var label = (TextView)((LinearLayout)cell.GetChildAt(1)).GetChildAt(0);

            label.SetTextColor(Color.FromHex("000000").ToAndroid());
            label.TextSize = Font.SystemFontOfSize(NamedSize.Large).ToScaledPixel();

            var secondaryLabel = (TextView)((LinearLayout)cell.GetChildAt(1)).GetChildAt(1);

            secondaryLabel.SetTextColor(Color.FromHex("738182").ToAndroid());
            secondaryLabel.TextSize = Font.SystemFontOfSize(NamedSize.Medium).ToScaledPixel();


            return(cell);
        }
Exemple #25
0
 private UI.Color XamarinFormColorToWindowsColor(Color xamarinColor)
 {
     return(UI.Color.FromArgb((byte)(xamarinColor.A * 255),
                              (byte)(xamarinColor.R * 255),
                              (byte)(xamarinColor.G * 255),
                              (byte)(xamarinColor.B * 255)));
 }
 private string GetColorString(FormsColor c)
 {
     return($"{(byte)(c.A * byte.MaxValue):X}" +
            $"{(byte)(c.R * byte.MaxValue):X}" +
            $"{(byte)(c.G * byte.MaxValue):X}" +
            $"{(byte)(c.B * byte.MaxValue):X}");
 }
        public ProfileMaintenance(string _number, bool isSocialMediaRegistation = false, UserModel userModel = null)
        {
            NavigationPage.SetHasBackButton(this, false);
            InitializeComponent();
            _isSocialMediaRegistation = isSocialMediaRegistation;
            number = _number;
            ((NavigationPage)Application.Current.MainPage).BarBackgroundColor = Color.FromHex("890447");
            ((NavigationPage)Application.Current.MainPage).BarTextColor       = Color.White;
            BindingContext = new UserModelStorage();

            int      year     = DateTime.Now.Year;
            DateTime firstDay = new DateTime(year, 1, 1);

            birthdatePicker.SetValue(DatePicker.MaximumDateProperty, DateTime.Now.AddYears(-18));
            birthdatePicker.SetValue(DatePicker.MinimumDateProperty, firstDay.AddYears(-60));
            List <ContentPage> pageList = Children.ToList();

            if (isSocialMediaRegistation)
            {
                userModelMain            = userModel;
                chooseImageButton.Source = userModel.image;
                foreach (var child in Children.ToList())
                {
                    if (child == emailContent)
                    {
                        Children.Remove(child);
                    }
                }
            }
        }
Exemple #28
0
        protected override void OnElementChanged(ElementChangedEventArgs <global::Skor.Controls.GradientTextButton> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement == null)
            {
                return;
            }

            this.button                 = e.NewElement as global::Skor.Controls.GradientTextButton;
            this.backgroundColor        = this.button.BackgroundColor;
            this.button.BackgroundColor = Xamarin.Forms.Color.Transparent;
            this.button.HeightRequest   = this.button.HeightRequest >= DEFAULT_HEIGHT_BUTTON ? this.button.HeightRequest : DEFAULT_HEIGHT_BUTTON;
            InitControls();
            RenderText();
            InitStyleButton();
            nButton.Click += (s, ev) =>
            {
                button.SendClicked();
            };
            nButton.LongClick += (s, ev) =>
            {
                button.SendLongClick();
            };
            frame.AddView(nButton);
            SetNativeControl(this.frame);
        }
Exemple #29
0
 public static UIKit.UIColor ToPlatformColor(this Xamarin.Forms.Color color)
 {
     return(UIKit.UIColor.FromRGB(
                (int)(color.R * 255),
                (int)(color.G * 255),
                (int)(color.B * 255)));
 }
        protected override void OnElementChanged(ElementChangedEventArgs <ContentView> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                return;
            }

            var element = (RoundedContentView)Element;

            //if (element.HasShadow)
            //{
            //	this.Elevation = element.ShadowElevation;
            //	this.TranslationZ = element.ShadowTranslationZ;
            //}

            _startColor            = element.GradientStartColor;
            _endColor              = element.GradientEndColor;
            _hasBackgroundGradient = element.HasBackgroundGradient;

            _cornerRadius        = TypedValue.ApplyDimension(ComplexUnitType.Dip, element.CornerRadius, Context.Resources.DisplayMetrics);
            this.OutlineProvider = new RoundedCornerOutlineProvider(_cornerRadius);
            this.ClipToOutline   = true;
        }
Exemple #31
0
 public MarginFrame(int margin, Color backgroundColor)
 {
     Padding = new Thickness(margin);
     OutlineColor = backgroundColor;
     BackgroundColor = backgroundColor;
     HasShadow = false;
 }
Exemple #32
0
        protected override void OnElementChanged(ElementChangedEventArgs <ContentView> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                return;
            }

            var element = (RoundedContentView)Element;


            _borderThickness = element.BorderThickness * 4;
            _borderColor     = element.BorderColor;
            _backgroundColor = element.BackgroundColor;
            _borderIsDashed  = element.BorderIsDashed;

            _startColor            = element.GradientStartColor;
            _endColor              = element.GradientEndColor;
            _hasBackgroundGradient = element.HasBackgroundGradient;

            _cornerRadius        = TypedValue.ApplyDimension(ComplexUnitType.Dip, element.CornerRadius, Context.Resources.DisplayMetrics);
            this.OutlineProvider = new RoundedCornerOutlineProvider(_cornerRadius, _borderThickness);
            this.ClipToOutline   = true;
        }
 /// <summary>
 /// Converts a Xamarin Forms Color to a Windows UI Color
 /// </summary>
 /// <param name="color">The Xamarin Forms Color to convert</param>
 /// <returns>Windows.UI.Color</returns>
 private Windows.UI.Color XamarinColorToUwp(Xamarin.Forms.Color color)
 {
     return(Windows.UI.Color.FromArgb((byte)(color.A * 255),
                                      (byte)(color.R * 255),
                                      (byte)(color.G * 255),
                                      (byte)(color.B * 255)));
 }
Exemple #34
0
        private async void Button_ClickedAsync(object sender, EventArgs e)
        {
            var configuration = new MqttConfiguration
            {
                BufferSize                   = 128 * 1024,
                Port                         = 1883,
                KeepAliveSecs                = 10,
                WaitTimeoutSecs              = 2,
                MaximumQualityOfService      = MqttQualityOfService.AtMostOnce,
                AllowWildcardsInTopicFilters = true
            };

            Botao1.IsEnabled = false;
            client           = await MqttClient.CreateAsync(BrokerURL, BrokerPort);

            sessionState = await client.ConnectAsync(new MqttClientCredentials(clientId : MQTTClientID));

            if (client.IsConnected)
            {
                await DisplayAlert("Conexão", "Estado: Conectado", "Ok");
            }

            Botao1.IsEnabled = false;
            Botao1.Text      = "Conectado";
            Xamarin.Forms.Color xfColor = Xamarin.Forms.Color.FromRgb(0, 255, 0);
            Botao1.BackgroundColor = xfColor;
        }
Exemple #35
0
        void SetOverlay(Xamarin.Forms.Color color)
        {
            var formsImage = (Xamarin.Forms.Image)Element;

            if (formsImage?.Source == null)
            {
                return;
            }

            try
            {
                var drawable = ((ImageView)Control).Drawable.Mutate();
                drawable.SetColorFilter(color.ToAndroid(), PorterDuff.Mode.SrcAtop);
                drawable.Alpha = color.ToAndroid().A;

                ((ImageView)Control).SetImageDrawable(drawable);
                ((IVisualElementController)Element).NativeSizeChanged();
            }
            catch (NullReferenceException)
            {
                return;
            }
            catch (ObjectDisposedException)
            {
                return;
            }
        }
		public MainPageHubItem(string text, Color boxColor, ICommand navigationCommand, Color textColor)
		{
			_text = text;
			_boxColor = boxColor;
			_navigationCommand = navigationCommand;
			_textColor = textColor;
			CreateUI();
		}
 public override void Preparing(View content, PopupPage page)
 {
     if (HasBackgroundAnimation && page.BackgroundImage == null)
     {
         _backgroundColor = page.BackgroundColor;
         page.BackgroundColor = GetColor(0);
     }
 }
Exemple #38
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TreeWatch.FieldMap"/> class.
        /// </summary>
        /// <param name="region">The actual position inside the map.</param>
        public FieldMap(MapSpan region)
            : base(region)
        {
            this.Fields = new ObservableCollection<Field>();
            this.overlayColor = Color.Transparent;
            this.boundaryColor = Color.FromHex("#ff8400");

            this.StyleId = "FieldMapView";
        }
    public static void UpdateBorder(this View nativeControl, Color color, int thickness)
    {
      var backgroundGradient = nativeControl.Background as GradientDrawable;

      if (backgroundGradient != null)
      {
        var relativeBorderThickness = thickness*3;
        backgroundGradient.SetStroke(relativeBorderThickness, color.ToAndroid());
      }
    }
Exemple #40
0
 private static void SetLightTheme()
 {
     _currentTheme = AppTheme.Light;
     _useLightIcons = false;
     _backgroundColor = Color.FromHex("EEFCED");
     _navBackgroundColor = Color.FromHex("C0D1CF");
     _textColor = Color.FromHex("686963");
     _headerColor = Color.FromHex("809DB5");
     _linkColor = Color.FromHex("DB5461");
     _frameColor = Color.FromHex("C0D1CF");
     _frameBorderColor = Color.FromHex("809DB5");
     _buttonBackgroundColor = Color.FromHex("C0D1CF");
     _buttonTextColor = Color.FromHex("DB5461");
 }
Exemple #41
0
 public LabelStyles(Color firstColor, Color secondColor)
 {
     display4 = CreateStyle (firstColor, 76, StyleKit.LightFont);
     display3 = CreateStyle (firstColor, 50, StyleKit.RegularFont);
     display2 = CreateStyle (firstColor, 42, StyleKit.RegularFont);
     display = CreateStyle (firstColor, 30, StyleKit.RegularFont);
     headline = CreateStyle (secondColor, 20, StyleKit.RegularFont, LineBreakMode.WordWrap);
     title = CreateStyle (firstColor, 16, StyleKit.MediumFont);
     subhead = CreateStyle (secondColor, 14, StyleKit.RegularFont, LineBreakMode.WordWrap);
     body2 = CreateStyle (firstColor, 12, StyleKit.MediumFont, LineBreakMode.WordWrap);
     body = CreateStyle (firstColor, 12, StyleKit.RegularFont, LineBreakMode.WordWrap);
     caption = CreateStyle (secondColor, 9, StyleKit.RegularFont, LineBreakMode.WordWrap);
     action = CreateStyle (firstColor, 16, StyleKit.LightFont, LineBreakMode.WordWrap);
 }
Exemple #42
0
 static AppColors()
 {
     Device.OnPlatform(
         Android: () =>{
             PositiveBalance = PositiveBalance.AddLuminosity(0.3);
             NegativeBalance = NegativeBalance.AddLuminosity(0.3);
             SubTitle = Color.FromRgb(115, 129, 130);
         },
         WinPhone: () =>{
             PositiveBalance = PositiveBalance.AddLuminosity(0.3);
             NegativeBalance = NegativeBalance.AddLuminosity(0.3);
         }
     );
 }
		/// <summary>
		/// Adds the text.
		/// </summary>
		/// <param name="source">The source.</param>
		/// <param name="text">The text.</param>
		/// <param name="point">The point.</param>
		/// <param name="font">The font.</param>
		/// <param name="color">The color.</param>
		/// <returns>Task&lt;ImageSource&gt;.</returns>
		public static async Task<ImageSource> AddText(
			this StreamImageSource source,
			string text,
			CGPoint point,
			Font font,
			Color color)
		{
			var token = new CancellationTokenSource();
			var stream = await source.Stream(token.Token);
			var image = UIImage.LoadFromData(NSData.FromStream(stream));

			var bytes = image.AddText(text, point, font.ToUIFont(), color.ToUIColor()).AsPNG().ToArray();

			return ImageSource.FromStream(() => new MemoryStream(bytes));
		}
Exemple #44
0
		public HomePage ()
		{
			BackgroundColor = Color.XamarinLightGray.ToFormsColor ();
			Title = "MobileFirst Sample";

			var activityIndicatorColor = new Xamarin.Forms.Color (Color.XamarinGray.R, Color.XamarinGray.G, Color.XamarinGray.B, .4);

			activityIndicator = new ActivityIndicator{
				Color = Xamarin.Forms.Color.Black,
				BackgroundColor = new Xamarin.Forms.Color (0, 0, 0, 0),
				IsRunning = false,
				IsVisible = true
			};

			listView = new ListView {
				RowHeight = 40,
				BackgroundColor = Xamarin.Forms.Color.White,
				VerticalOptions = LayoutOptions.Start
			};

			listView.ItemsSource = new [] {
				new CommandItem { Command = "Connect", Image = "connect.png", ItemSelected = OnConnect },
				new CommandItem { Command = "Invoke Procedure", Image = "invoke.png", ItemSelected = OnInvokeProcedure },
				new CommandItem { Command = "Subscribe to Push", Image = "subscribe.png", ItemSelected = OnSubscribe },
				new CommandItem { Command = "Unsubscribe from Push", Image = "unsubscribe.png", ItemSelected = OnUnSubscribe },
				new CommandItem { Command = "Is Push Subscribed?", Image = "issubscribed.png", ItemSelected = OnIsSubscribed },
				new CommandItem { Command = "Is Push Supported?", Image = "issubscribed.png", ItemSelected = OnIsPushEnabled },
				new CommandItem { Command = "Log Activity", Image = "logactivity.png", ItemSelected = OnSendActivity },
				new CommandItem { Command = "JSONStore destroy", Image = "logactivity.png", ItemSelected = OnDestroyJSONStore },
				new CommandItem { Command = "Open JSONStore Collection", Image = "logactivity.png", ItemSelected = OnJSONStoreOpenCollection },
				new CommandItem { Command = "Add Data to JSONStore", Image = "logactivity.png", ItemSelected = OnAddDataToJSONStore },
				new CommandItem { Command = "Retrieve all Data", Image = "logactivity.png", ItemSelected = OnRetrieveAllDataFromJSONStore },
				new CommandItem { Command = "Retrieve Filtered Data", Image = "logactivity.png", ItemSelected = OnRetrieveFilteredDataFromJSONStore },
				new CommandItem { Command = "Invoke REST via OAuth", Image = "oauth.png", ItemSelected = OnRestInvoke },
			};

			listView.ItemTemplate = new DataTemplate (typeof(CommandCell));

			listView.ItemSelected += (sender, e) => {
				if (e.SelectedItem == null) return;

				(e.SelectedItem as CommandItem).ItemSelected ();
				listView.SelectedItem = null; 
			};

			Content = CreateLayout (activityIndicatorColor);
		}
		public static void UpdateFromFormsControl (this UILabel uiLabel, string text, Xamarin.Forms.TextAlignment textAlignment, Color textColor, Font font)
		{
			uiLabel.Text = text;

			switch (textAlignment) {
			case TextAlignment.Start:
				uiLabel.TextAlignment = UITextAlignment.Left;
				break;
			case TextAlignment.Center: 
				uiLabel.TextAlignment = UITextAlignment.Center;
				break;
			case TextAlignment.End: 
				uiLabel.TextAlignment = UITextAlignment.Right;
				break;
			}

			uiLabel.TextColor = textColor.ToUIColor ();
			uiLabel.Font = font.ToUIFont ();
		}
        public override Task Disappearing(View content, PopupPage page)
        {
            if (HasBackgroundAnimation && page.BackgroundImage == null)
            {
                TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();

                _backgroundColor = page.BackgroundColor;

                page.Animate("backgroundFade", d =>
                {
                    page.BackgroundColor = GetColor(d);
                }, _backgroundColor.A, 0, length: DurationOut, finished: (d, b) =>
                {
                    task.SetResult(true);
                });

                return task.Task;
            }

            return Task.FromResult(0);
        }
        public MatrixCellControlPrototype(string cellTitle, Color cellColor, TreeMapItem item)
        {
            InitializeComponent ();

            //			CommandsInit ();
            //
            //			_singleTapAction = singleTapAction;
            //			_doubleTapAction = doubleTapAction;

            lblTitle.Text = cellTitle;
            BackgroundColor = cellColor;
            cnvColor.BackgroundColor = cellColor;

            _cellColor = cellColor;

            InnerItem = item;

            cnvBorder.Padding = Device.OnPlatform (2,new Thickness(1,1,2,2),2);

            //			gestSingle.GestureCommand = SingleTapCommand;
            //			gestDouble.GestureCommand = DoubleTapCommand;

            //cnvGesture.GestureRecognized += OnCellGesture;
        }
			public ModalActivityIndicatorModel ()
			{
				_color = Color.Default;
			}
 private void ChangeStringCommandAction()
 {
     StringImage = "Hello Trung DZ";
     StringColor = Color.Red;            
 }
 public static void UpdateBorderColor(this Border nativeControl, Color backgroundColor)
 {
   nativeControl.Background = backgroundColor.ToBrush();
 }
 public NamedColor(string name, Color color)
 {
     Color = color;
     Name = name;
 }
 public static void UpdateBackgroundColor(this Rectangle nativeControl, Color backgroundColor)
 {
   nativeControl.Fill = backgroundColor.ToBrush();
 }
Exemple #53
0
 private static void SetNightTheme()
 {
     _currentTheme = AppTheme.Night;
     _useLightIcons = false;
     _backgroundColor = Color.FromHex("2A0000");
     _navBackgroundColor = Color.FromHex("360000");
     _textColor = Color.FromHex("730000");
     _headerColor = Color.FromHex("A80000");
     _linkColor = Color.FromHex("6B2B2B");
     _frameColor = Color.FromHex("460303");
     _frameBorderColor = Color.FromHex("A80000");
     _buttonBackgroundColor = Color.FromHex("460303");
     _buttonTextColor = Color.FromHex("6B2B2B");
 }
Exemple #54
0
 private static void SetDarkTheme()
 {
     _currentTheme = AppTheme.Dark;
     _useLightIcons = true;
     _backgroundColor = Color.FromHex("21252B");
     _navBackgroundColor = Color.FromHex("282C34");
     _textColor = Color.FromHex("9EA6B5");
     _headerColor = Color.FromHex("BFC8D7");
     _linkColor = Color.FromHex("548AF7");
     _frameColor = Color.FromHex("282C34");
     _frameBorderColor = Color.FromHex("9EA6B5");
     _buttonBackgroundColor = Color.FromHex("282C34");
     _buttonTextColor = Color.FromHex("548AF7");
 }
 public static void SetColor(BindableObject view, Color value)
 {
     view.SetValue (ColorProperty, value);
 }
	    private static void OnTextColorChanged(BindableObject bindable, Color oldvalue, Color newvalue)
	    {
            var control = bindable as TextOnImage;
            if (control == null) return;
            control.LabelImage.TextColor = newvalue;
        }
 private void SetTextColor( Color color )
 {
     dayLabel.TextColor = color;
     dayOfWeekLabel.TextColor = color;
 }
		public MainPageHubItem(string text, Color boxColor, ICommand navigationCommand) 
			: this(text, boxColor, navigationCommand, Device.OnPlatform(Color.White, Color.White, Color.White)) {}
Exemple #59
0
 private static void SetContrastTheme()
 {
     _currentTheme = AppTheme.Contrast;
     _useLightIcons = true;
     _backgroundColor = Color.Black;
     _navBackgroundColor = Color.Black;
     _textColor = Color.Yellow;
     _headerColor = Color.Lime;
     _linkColor = Color.Red;
     _frameColor = Color.Black;
     _frameBorderColor = Color.Silver;
     _buttonBackgroundColor = Color.Yellow;
     _buttonTextColor = Color.Red;
 }
 public static void UpdateBorder(this UIView nativeControl, Color color, int thickness)
 {
   nativeControl.Layer.BorderColor = color.ToCGColor();
   nativeControl.Layer.BorderWidth = thickness;
 }