Ejemplo n.º 1
0
        public HotelInfoViewModel(HotelInfo info)
        {
            Name             = info.HotelName;
            ID               = info.HotelID;
            Avatar           = new ImageViewModel(info.ImgUrl);
            ConditionPercent = (int)info.Condition;
            Condition        = (double)info.Condition;
            RoomsDescription = prepareRoomDescription(info.HotelRoomInfos);
            HotelRights      = info.HotelRights;
            RegionID         = info.RegionID;
            RegionName       = info.RegionName;
            CountryID        = info.CountryID;
            CountryName      = info.CountryName;
            OwnerID          = info.OwnerID;
            OwnerName        = info.OwnerName;


            Menu = prepareMenu();

            ConditionColor = ColorInterpolator
                             .Lerp(
                Condition / 100.0,
                Color.Red,
                Color.Orange,
                Color.Green).ToHex();

            if (HotelRights.AnyRights)
            {
                AvatarChange = new AvatarChangeViewModel(ID);
            }
        }
Ejemplo n.º 2
0
        public override void Draw(CGRect rect)
        {
            MyLabelRenderer myLabelRenderer = (MyLabelRenderer)Element;

            if (myLabelRenderer.IsGradient)
            {
                var gradientView = new UIView(Control.Frame);
                Control.BackgroundColor = UIColor.Clear;
                Color color = ColorInterpolator.InterpolateBetween(myLabelRenderer.StartColor,
                                                                   myLabelRenderer.EndColor,
                                                                   myLabelRenderer.NumToGradient);

                var gradientLayer = new CAGradientLayer
                {
                    Frame  = gradientView.Layer.Bounds,
                    Colors = new CGColor[] { myLabelRenderer.StartColor.ToCGColor(), color.ToCGColor() }
                };

                gradientView.Layer.AddSublayer(gradientLayer);
                gradientView.AddSubview(Control);

                var gradientLabel = new UILabel(Control.Frame);
                gradientLabel.AddSubview(gradientView);
                SetNativeControl(gradientLabel);

                gradientLayer.StartPoint = new CGPoint(0, 0.5);
                gradientLayer.EndPoint   = new CGPoint(1.0, 0.5);
            }
            else
            {
                Control.BackgroundColor = myLabelRenderer.StaticColor.ToUIColor();
            }
            base.Draw(rect);
        }
Ejemplo n.º 3
0
 void SetDrawable(MyButtonRenderer myButtonRenderer)
 {
     if (myButtonRenderer.IsGradient)
     {
         Color StartColor = ColorInterpolator.InterpolateBetween(myButtonRenderer.EndColor,
                                                                 myButtonRenderer.StartColor,
                                                                 myButtonRenderer.NumOfGradientStart);
         Color EndColor = ColorInterpolator.InterpolateBetween(myButtonRenderer.StartColor,
                                                               myButtonRenderer.EndColor,
                                                               myButtonRenderer.NumOfGradientEnd);
         var gradient = new CAGradientLayer();
         gradient.Colors = new CGColor[]
         {
             StartColor.ToCGColor(),
                 EndColor.ToCGColor()
         };
         gradient.StartPoint = new CGPoint(0, 0.5);
         gradient.EndPoint   = new CGPoint(1, 0.5);
         Control.Layer.InsertSublayer(gradient, 0);
     }
     else
     {
         Control.BackgroundColor = myButtonRenderer.StaticColor.ToUIColor();
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructs a <see cref="CycleColorAnimation"/> given a duration, framerate and base colour.
        /// </summary>
        public CycleColorAnimation(Action <Color> setColorFunction, Color baseColor, float duration, float frameRate) : base(duration, frameRate)
        {
            var lch = baseColor.ToLch();

            InterpolationMethod = time => ColorInterpolator.GetRainbowColor((float)lch.C, (float)lch.L, time).ToColor();
            ExecutionMethod     = setColorFunction;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Constructs a <see cref="CycleColorAnimation"/> given a duration, framerate and base colour.
        /// </summary>
        public LerpColorAnimation(Action <Color> setColorFunction, Color colorA, Color colorB, float duration, float frameRate) : base(duration, frameRate)
        {
            var lchSourceColor = colorA.ToLch();
            var lchTargetColor = colorB.ToLch();

            InterpolationMethod = time => ColorInterpolator.CalculateIntermediateColour(lchSourceColor, lchTargetColor, time).ToColor();
            ExecutionMethod     = setColorFunction;
        }
Ejemplo n.º 6
0
 public virtual System.Drawing.Bitmap GetAsBmp(float[] value)
 {
     System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(1, value.Length);
     for (int i = 0; i < size; i++)
     {
         bmp.SetPixel(0, i, ColorInterpolator.InterpolateBetween(System.Drawing.Color.Black, System.Drawing.Color.Lime, value[i]));
     }
     return(bmp);
 }
Ejemplo n.º 7
0
    protected override void Start()
    {
        base.Start();
        interpol = GetComponent <ColorInterpolator>();

        resourceStorage = GameController.instance.player.resources;
        if (!isCreated)
        {
            Expand(currentStorage);
            isCreated = true;
        }
        notification = GameController.instance.buttons.hint;
    }
Ejemplo n.º 8
0
        public System.Drawing.Bitmap GetFrequencyVisualization()
        {
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(width, height);

            //Build the bmp
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    System.Drawing.Color color = ColorInterpolator.InterpolateBetween(Color.Blue, Color.Yellow, Color.Red, neurons[x, y].GetSpikingFrequency());
                    bmp.SetPixel(x, y, color);
                }
            }
            //Console.WriteLine("Visualization computed in " + (time2 - time1).ToString());
            return(bmp);
        }
Ejemplo n.º 9
0
        void SetDrawable(MyLabelRenderer myLabelRenderer)
        {
            GradientDrawable gradientDrawable = new GradientDrawable();

            if (myLabelRenderer.IsGradient)
            {
                Color color = ColorInterpolator.InterpolateBetween(myLabelRenderer.StartColor,
                                                                   myLabelRenderer.EndColor,
                                                                   myLabelRenderer.NumToGradient);
                gradientDrawable = new GradientDrawable(
                    GradientDrawable.Orientation.LeftRight,
                    new int[] { myLabelRenderer.StartColor.ToAndroid(), color.ToAndroid() }
                    );
            }
            else
            {
                gradientDrawable.SetColor(myLabelRenderer.StaticColor.ToAndroid());
            }
            switch (myLabelRenderer.TypeBorder)
            {
            case TypeBorder.All:
                gradientDrawable.SetCornerRadii(new float[] { 80, 80, 80, 80,
                                                              80, 80, 80, 80 });
                break;

            case TypeBorder.Left:
                gradientDrawable.SetCornerRadii(new float[] { 80, 80, 0, 0,
                                                              0, 0, 80, 80 });
                break;

            case TypeBorder.Right:
                gradientDrawable.SetCornerRadii(new float[] { 0, 0, 80, 80,
                                                              80, 80, 0, 0 });
                break;

            case TypeBorder.Down:
                gradientDrawable.SetCornerRadii(new float[] { 0, 0, 0, 0,
                                                              80, 80, 80, 80 });
                break;

            case TypeBorder.Up:
                gradientDrawable.SetCornerRadii(new float[] { 80, 80, 80, 80,
                                                              0, 0, 0, 0 });
                break;
            }
            Control.SetBackground(gradientDrawable);
        }
Ejemplo n.º 10
0
        private void RenderBlip()
        {
            int x_off = 38;
            int y_off = 17;

            int blipMaxArea = 90;

            int blipUp   = 45;
            int blipDown = 57;

            if (blipTime * blipSpeed > blipMaxArea)
            {
                blipTime = 0;
            }

            var bs = (int)Math.Floor(blipTime * blipSpeed);

            Gorgon.CurrentRenderTarget.BlendingMode = BlendingModes.Modulated;
            for (int i = bs; i < (bs + blipWidth); i++)
            {
                float sweepPct = (float)i / (bs + blipWidth);

                float alpha =
                    Math.Min(Math.Max((1 - (Math.Abs((blipMaxArea / 2f) - i) / (blipMaxArea / 2f))) * (300f * sweepPct), 0f), 255f);
                _backgroundSprite.Color = Color.FromArgb((int)alpha,
                                                         ColorInterpolator.InterpolateBetween(Color.Orange,
                                                                                              Color.LawnGreen, healthPct));

                float blipHeightUp   = Math.Max(((blipUp - Math.Abs(blipUp - i)) / (float)blipUp) - 0.80f, 0f);
                float blipHeightDown = Math.Max(((blipDown - Math.Abs(blipDown - i)) / (float)blipDown) - 0.93f, 0f);

                if (i <= blipMaxArea)
                {
                    _backgroundSprite.Draw(new Rectangle(healthMeterInner.X + x_off + i,
                                                         healthMeterInner.Y + y_off -
                                                         (int)
                                                         ((blipHeightUp * 65) *
                                                          ((healthPct > 0f) ? Math.Max(healthPct, 0.30f) : 0)) +
                                                         (int)
                                                         ((blipHeightDown * 65) *
                                                          ((healthPct > 0f) ? Math.Max(healthPct, 0.45f) : 0)),
                                                         3, 3));
                }
            }
            Gorgon.CurrentRenderTarget.BlendingMode = BlendingModes.None;
        }
Ejemplo n.º 11
0
    protected override void Start()
    {
        base.Start();

        interpol        = GetComponent <ColorInterpolator>();
        resourceStorage = GameController.instance.player.resources;
        if (!isCreated)
        {
            currentCounter += startCounter;
            GameController.instance.player.skills.enhancementCounter += startCounter;
            isCreated = true;
            if (!GameController.instance.tutorialSettings.GetTutorialState("Engineering"))
            {
                tutorial.tPanel = GameController.instance.buttons.tPanel;
                tutorial.highlightedObjects.Add(GameController.instance.buttons.engineering.gameObject);
                tutorial.StartTutorial();
            }
        }
    }
Ejemplo n.º 12
0
        public Particle(Texture2D texture, ParticleConfig config)
        {
            Config = config;
            Texture = texture;
            OriginalColor = config.Color;
            OriginalScale = config.Scale;
            OriginalTimeToLive = config.TimeToLive;
            Alive = true;

            if (Config.VelocityInterpolate)
                (_velocity = new Vector2Interpolator()).Start(Config.Velocity, Config.TargetVelocity, Config.TimeToLive);
            if (Config.ScaleInterpolate)
                (_scale = new FloatInterpolator()).Start(Config.Scale, Config.TargetScale, Config.TimeToLive, true);
            if (Config.RotationVelocityInterpolate)
                (_rotation = new FloatInterpolator()).Start(Config.RotationVelocity, Config.TargetRotationVelocity, Config.TimeToLive);
            if (Config.ColorInterpolate)
                (_color = new ColorInterpolator()).Start(Config.Color, Config.TargetColor, Config.TimeToLive);
            if (OnParticleCreated != null) OnParticleCreated.Invoke(this, GameEventArgs.Empty);
        }
Ejemplo n.º 13
0
    protected override void Start()
    {
        base.Start();

        interpol        = GetComponent <ColorInterpolator>();
        resourceStorage = GameController.instance.player.resources;
        if (!isCreated)
        {
            currentEfficiency += startEfficiency;
            GameController.instance.player.skills.toxicityReducer += startEfficiency;
            isCreated = true;
            if (!GameController.instance.tutorialSettings.GetTutorialState("Laboratory"))
            {
                tutorial.tPanel = GameController.instance.buttons.tPanel;
                tutorial.highlightedObjects.Add(GameController.instance.buttons.laboratory.gameObject);
                tutorial.StartTutorial();
            }
        }
    }
Ejemplo n.º 14
0
        public static IEnumerable <Color> GetColorsBetween(Color start, Color end, int count, bool include_start = false, bool include_end = false)
        {
            //if (count <= 0 | count > 100) { throw new NotSupportedException(); }

            if (include_start)
            {
                yield return(start);
            }

            for (int i = 0; i < count; i++)
            {
                double lambda = (1.0 / (count + 1)) * (i + 1);

                yield return(ColorInterpolator.InterpolateBetween(start, end, lambda));
            }

            if (include_end)
            {
                yield return(end);
            }
        }
Ejemplo n.º 15
0
        public override void Update(float frameTime)
        {
            const int x_inner   = 4;
            const int y_inner   = 25;
            const int dec_inner = 7;

            panelBG.Position            = Position;
            healthMeterBg.Position      = new Vector2D(Position.X + x_inner, Position.Y + y_inner);
            healthMeterOverlay.Position = new Vector2D(Position.X + x_inner, Position.Y + y_inner);
            healthMeterGrid.Position    = new Vector2D(Position.X + x_inner, Position.Y + y_inner);

            ClientArea = Rectangle.Round(panelBG.AABB);

            healthMeterInner = new Rectangle(Position.X + x_inner + dec_inner, Position.Y + y_inner + dec_inner,
                                             (int)(healthMeterOverlay.Width - (2 * dec_inner)),
                                             (int)(healthMeterOverlay.Height - (2 * dec_inner)));
            healthPc.Position = new Point(healthMeterInner.X + 5,
                                          (int)
                                          (healthMeterInner.Y + (healthMeterInner.Height / 2f) -
                                           (healthPc.ClientArea.Height / 2f)) - 2);
            healthPc.Update(frameTime);

            Entity entity = _playerManager.ControlledEntity;

            if (entity != null && entity.HasComponent(ComponentFamily.Damageable))
            {
                var   comp    = (HealthComponent)entity.GetComponent(ComponentFamily.Damageable);
                float _health = comp.GetHealth();

                healthPct = comp.GetHealth() / comp.GetMaxHealth();
                if (float.IsNaN(healthPct))
                {
                    healthPct = 1;                         //This can happen when the components are not ready yet.
                }
                interpCol          = ColorInterpolator.InterpolateBetween(ColCritical, ColHealthy, healthPct);
                healthPc.Text.Text = Math.Round((healthPct * 100)).ToString() + "%";
            }

            blipTime += frameTime;
        }
Ejemplo n.º 16
0
        public HouseInfoViewModel(House house, HouseRights rights)
        {
            HouseRights = rights;

            var region = house.Region;

            HouseID     = house.ID;
            RegionName  = region.Name;
            RegionID    = region.ID;
            OwnerName   = house.Citizen.Entity.Name;
            CountryName = Persistent.Countries.GetById(region.CountryID.Value).Entity.Name;
            CountryID   = region.CountryID.Value;
            Avatar      = Images.HousePlaceholder.VM;

            foreach (var f in house.HouseFurnitures.ToList())
            {
                Furnitures.Add(new HouseFurnitureInfoViewModel(f));
            }

            ConditionPercent = (int)house.Condition;
            Condition        = (double)house.Condition;

            ConditionColor = ColorInterpolator
                             .Lerp(
                Condition / 100.0,
                Color.Red,
                Color.Orange,
                Color.Green).ToHex();

            if (house.SellHouse != null)
            {
                SellPrice   = house.SellHouse.Price;
                PriceSymbol = Persistent.Countries.GetCountryCurrency(house.Region.CountryID.Value).Symbol;
            }

            prepareMenu();
        }
Ejemplo n.º 17
0
        private BuiltInExpressionFfi()
        {
            _registry = new DelegateExpressionFfi
            {
                { "Abs", (float f) => Math.Abs(f) },
                { "Abs", (Vector2 v) => Vector2.Abs(v) },
                { "Abs", (Vector3 v) => Vector3.Abs(v) },
                { "Abs", (Vector4 v) => Vector4.Abs(v) },

                { "ACos", (float f) => (float)Math.Acos(f) },
                { "ASin", (float f) => (float)Math.Asin(f) },
                { "ATan", (float f) => (float)Math.Atan(f) },
                { "Ceil", (float f) => (float)Math.Ceiling(f) },

                { "Clamp", (float a1, float a2, float a3) => MathUtilities.Clamp(a1, a2, a3) },
                { "Clamp", (Vector2 a1, Vector2 a2, Vector2 a3) => Vector2.Clamp(a1, a2, a3) },
                { "Clamp", (Vector3 a1, Vector3 a2, Vector3 a3) => Vector3.Clamp(a1, a2, a3) },
                { "Clamp", (Vector4 a1, Vector4 a2, Vector4 a3) => Vector4.Clamp(a1, a2, a3) },

                { "Concatenate", (Quaternion a1, Quaternion a2) => Quaternion.Concatenate(a1, a2) },
                { "Cos", (float a) => (float)Math.Cos(a) },

                /*
                 * TODO:
                 *  ColorHsl(Float h, Float s, Float l)
                 *  ColorLerpHSL(Color colorTo, CompositionColorcolorFrom, Float progress)
                 */

                {
                    "ColorLerp", (Avalonia.Media.Color to, Avalonia.Media.Color from, float progress) =>
                    ColorInterpolator.LerpRGB(to, from, progress)
                },
                {
                    "ColorLerpRGB", (Avalonia.Media.Color to, Avalonia.Media.Color from, float progress) =>
                    ColorInterpolator.LerpRGB(to, from, progress)
                },
                {
                    "ColorRGB", (float a, float r, float g, float b) => Avalonia.Media.Color.FromArgb(
                        (byte)MathUtilities.Clamp(a, 0, 255),
                        (byte)MathUtilities.Clamp(r, 0, 255),
                        (byte)MathUtilities.Clamp(g, 0, 255),
                        (byte)MathUtilities.Clamp(b, 0, 255)
                        )
                },

                { "Distance", (Vector2 a1, Vector2 a2) => Vector2.Distance(a1, a2) },
                { "Distance", (Vector3 a1, Vector3 a2) => Vector3.Distance(a1, a2) },
                { "Distance", (Vector4 a1, Vector4 a2) => Vector4.Distance(a1, a2) },

                { "DistanceSquared", (Vector2 a1, Vector2 a2) => Vector2.DistanceSquared(a1, a2) },
                { "DistanceSquared", (Vector3 a1, Vector3 a2) => Vector3.DistanceSquared(a1, a2) },
                { "DistanceSquared", (Vector4 a1, Vector4 a2) => Vector4.DistanceSquared(a1, a2) },

                { "Floor", (float v) => (float)Math.Floor(v) },

                { "Inverse", (Matrix3x2 v) => Inverse(v) },
                { "Inverse", (Matrix4x4 v) => Inverse(v) },


                { "Length", (Vector2 a1) => a1.Length() },
                { "Length", (Vector3 a1) => a1.Length() },
                { "Length", (Vector4 a1) => a1.Length() },
                { "Length", (Quaternion a1) => a1.Length() },

                { "LengthSquared", (Vector2 a1) => a1.LengthSquared() },
                { "LengthSquared", (Vector3 a1) => a1.LengthSquared() },
                { "LengthSquared", (Vector4 a1) => a1.LengthSquared() },
                { "LengthSquared", (Quaternion a1) => a1.LengthSquared() },

                { "Lerp", (float a1, float a2, float a3) => Lerp(a1, a2, a3) },
                { "Lerp", (Vector2 a1, Vector2 a2, float a3) => Vector2.Lerp(a1, a2, a3) },
                { "Lerp", (Vector3 a1, Vector3 a2, float a3) => Vector3.Lerp(a1, a2, a3) },
                { "Lerp", (Vector4 a1, Vector4 a2, float a3) => Vector4.Lerp(a1, a2, a3) },


                { "Ln", (float f) => (float)Math.Log(f) },
                { "Log10", (float f) => (float)Math.Log10(f) },

                { "Matrix3x2.CreateFromScale", (Vector2 v) => Matrix3x2.CreateScale(v) },
                { "Matrix3x2.CreateFromTranslation", (Vector2 v) => Matrix3x2.CreateTranslation(v) },
                { "Matrix3x2.CreateRotation", (float v) => Matrix3x2.CreateRotation(v) },
                { "Matrix3x2.CreateScale", (Vector2 v) => Matrix3x2.CreateScale(v) },
                { "Matrix3x2.CreateSkew", (float a1, float a2, Vector2 a3) => Matrix3x2.CreateSkew(a1, a2, a3) },
                { "Matrix3x2.CreateTranslation", (Vector2 v) => Matrix3x2.CreateScale(v) },
                {
                    "Matrix3x2", (float m11, float m12, float m21, float m22, float m31, float m32) =>
                    new Matrix3x2(m11, m12, m21, m22, m31, m32)
                },
                { "Matrix4x4.CreateFromAxisAngle", (Vector3 v, float angle) => Matrix4x4.CreateFromAxisAngle(v, angle) },
                { "Matrix4x4.CreateFromScale", (Vector3 v) => Matrix4x4.CreateScale(v) },
                { "Matrix4x4.CreateFromTranslation", (Vector3 v) => Matrix4x4.CreateTranslation(v) },
                { "Matrix4x4.CreateScale", (Vector3 v) => Matrix4x4.CreateScale(v) },
                { "Matrix4x4.CreateTranslation", (Vector3 v) => Matrix4x4.CreateScale(v) },
                { "Matrix4x4", (Matrix3x2 m) => new Matrix4x4(m) },
                {
                    "Matrix4x4",
                    (float m11, float m12, float m13, float m14,
                     float m21, float m22, float m23, float m24,
                     float m31, float m32, float m33, float m34,
                     float m41, float m42, float m43, float m44) =>
                    new Matrix4x4(
                        m11, m12, m13, m14,
                        m21, m22, m23, m24,
                        m31, m32, m33, m34,
                        m41, m42, m43, m44)
                },


                { "Max", (float a1, float a2) => Math.Max(a1, a2) },
                { "Max", (Vector2 a1, Vector2 a2) => Vector2.Max(a1, a2) },
                { "Max", (Vector3 a1, Vector3 a2) => Vector3.Max(a1, a2) },
                { "Max", (Vector4 a1, Vector4 a2) => Vector4.Max(a1, a2) },


                { "Min", (float a1, float a2) => Math.Min(a1, a2) },
                { "Min", (Vector2 a1, Vector2 a2) => Vector2.Min(a1, a2) },
                { "Min", (Vector3 a1, Vector3 a2) => Vector3.Min(a1, a2) },
                { "Min", (Vector4 a1, Vector4 a2) => Vector4.Min(a1, a2) },

                { "Mod", (float a, float b) => a % b },

                { "Normalize", (Quaternion a) => Quaternion.Normalize(a) },
                { "Normalize", (Vector2 a) => Vector2.Normalize(a) },
                { "Normalize", (Vector3 a) => Vector3.Normalize(a) },
                { "Normalize", (Vector4 a) => Vector4.Normalize(a) },

                { "Pow", (float a, float b) => (float)Math.Pow(a, b) },
                { "Quaternion.CreateFromAxisAngle", (Vector3 a, float b) => Quaternion.CreateFromAxisAngle(a, b) },
                { "Quaternion", (float a, float b, float c, float d) => new Quaternion(a, b, c, d) },

                { "Round", (float a) => (float)Math.Round(a) },

                { "Scale", (Matrix3x2 a, float b) => a * b },
                { "Scale", (Matrix4x4 a, float b) => a * b },
                { "Scale", (Vector2 a, float b) => a * b },
                { "Scale", (Vector3 a, float b) => a * b },
                { "Scale", (Vector4 a, float b) => a * b },

                { "Sin", (float a) => (float)Math.Sin(a) },

                { "SmoothStep", (float a1, float a2, float a3) => SmoothStep(a1, a2, a3) },
                { "SmoothStep", (Vector2 a1, Vector2 a2, Vector2 a3) => SmoothStep(a1, a2, a3) },
                { "SmoothStep", (Vector3 a1, Vector3 a2, Vector3 a3) => SmoothStep(a1, a2, a3) },
                { "SmoothStep", (Vector4 a1, Vector4 a2, Vector4 a3) => SmoothStep(a1, a2, a3) },

                // I have no idea how to do a spherical interpolation for a scalar value, so we are doing a linear one
                { "Slerp", (float a1, float a2, float a3) => Lerp(a1, a2, a3) },
                { "Slerp", (Quaternion a1, Quaternion a2, float a3) => Quaternion.Slerp(a1, a2, a3) },

                { "Sqrt", (float a) => (float)Math.Sqrt(a) },
                { "Square", (float a) => a * a },
                { "Tan", (float a) => (float)Math.Tan(a) },

                { "ToRadians", (float a) => (float)(a * Math.PI / 180) },
                { "ToDegrees", (float a) => (float)(a * 180d / Math.PI) },

                { "Transform", (Vector2 a, Matrix3x2 b) => Vector2.Transform(a, b) },
                { "Transform", (Vector3 a, Matrix4x4 b) => Vector3.Transform(a, b) },

                { "Vector2", (float a, float b) => new Vector2(a, b) },
                { "Vector3", (float a, float b, float c) => new Vector3(a, b, c) },
                { "Vector3", (Vector2 v2, float z) => new Vector3(v2, z) },
                { "Vector4", (float a, float b, float c, float d) => new Vector4(a, b, c, d) },
                { "Vector4", (Vector2 v2, float z, float w) => new Vector4(v2, z, w) },
                { "Vector4", (Vector3 v3, float w) => new Vector4(v3, w) },
            };
        }
Ejemplo n.º 18
0
        protected override void OnElementChanged(ElementChangedEventArgs <Button> e)
        {
            base.OnElementChanged(e);

            if ((Control != null) && (e.OldElement == null))
            {
                MyButtonRenderer myButtonRenderer = (MyButtonRenderer)Element;
                GradientDrawable gradientDrawable = new GradientDrawable();
                if (myButtonRenderer.IsGradient)
                {
                    Color StartColor = ColorInterpolator.InterpolateBetween(myButtonRenderer.EndColor,
                                                                            myButtonRenderer.StartColor,
                                                                            myButtonRenderer.NumOfGradientStart);
                    Color EndColor = ColorInterpolator.InterpolateBetween(myButtonRenderer.StartColor,
                                                                          myButtonRenderer.EndColor,
                                                                          myButtonRenderer.NumOfGradientEnd);
                    if (!myButtonRenderer.IsEnabled)
                    {
                        StartColor = System.Drawing.Color.FromArgb(70, StartColor);
                        EndColor   = System.Drawing.Color.FromArgb(70, EndColor);
                    }
                    gradientDrawable = new GradientDrawable(
                        GradientDrawable.Orientation.LeftRight,
                        new int[] { StartColor.ToAndroid(),
                                    EndColor.ToAndroid() }
                        );
                }
                else
                {
                    Color staticColor = myButtonRenderer.StaticColor;
                    if (!myButtonRenderer.IsEnabled)
                    {
                        staticColor = System.Drawing.Color.FromArgb(70, myButtonRenderer.StaticColor);
                    }
                    gradientDrawable.SetColor(staticColor.ToAndroid());
                }
                switch (myButtonRenderer.TypeBorder)
                {
                case TypeBorder.All:
                    gradientDrawable.SetCornerRadii(new float[] { 80, 80, 80, 80,
                                                                  80, 80, 80, 80 });
                    break;

                case TypeBorder.Left:
                    gradientDrawable.SetCornerRadii(new float[] { 80, 80, 0, 0,
                                                                  0, 0, 80, 80 });
                    break;

                case TypeBorder.Right:
                    gradientDrawable.SetCornerRadii(new float[] { 0, 0, 80, 80,
                                                                  80, 80, 0, 0 });
                    break;

                case TypeBorder.Down:
                    gradientDrawable.SetCornerRadii(new float[] { 0, 0, 0, 0,
                                                                  80, 80, 80, 80 });
                    break;

                case TypeBorder.Up:
                    gradientDrawable.SetCornerRadii(new float[] { 80, 80, 80, 80,
                                                                  0, 0, 0, 0 });
                    break;
                }
                Control.StateListAnimator = new StateListAnimator();
                Control.SetBackground(gradientDrawable);
            }
        }
Ejemplo n.º 19
0
 private void Awake()
 {
     interpol = GetComponent <ColorInterpolator>();
     gameObject.SetActive(true);
 }
Ejemplo n.º 20
0
 private void Awake()
 {
     interpol = GetComponent <ColorInterpolator>();
 }
        protected override void OnBindingContextChanged()
        {
            if ((BindingContext != null) && (message == null))
            {
                message = (MessageElementModel)BindingContext;
                if (message != null)
                {
                    // Add Urgency element ?
                    if (message.Content.Urgency != UrgencyType.Std)
                    {
                        if (messageContentUrgency == null)
                        {
                            messageContentUrgency = new MessageContentUrgency();
                            messageContentUrgency.BindingContext = message;
                            ContentGrid.Children.Add(messageContentUrgency, 0, 0);
                            Grid.SetColumnSpan(messageContentUrgency, 2);
                        }
                    }

                    // Add forward header
                    if (message.IsForwarded)
                    {
                        if (messageContentForward == null)
                        {
                            messageContentForward = new MessageContentForward();
                            messageContentForward.BindingContext = message;
                            ContentGrid.Children.Add(messageContentForward, 0, 0);
                            Grid.SetColumnSpan(messageContentForward, 2);
                        }
                    }

                    // Add Reply element ?
                    if (message.Reply != null)
                    {
                        if (messageContentReply == null)
                        {
                            messageContentReply = new MessageContentReply();
                            messageContentReply.BindingContext = message;
                            ContentGrid.Children.Add(messageContentReply, 0, 1);
                            Grid.SetColumnSpan(messageContentReply, 2);
                        }
                    }

                    // Add Body element ?
                    if (!String.IsNullOrEmpty(message.Content?.Body))
                    {
                        if (message.Content.Body.StartsWith("/img", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (messageContentBodyWithImg == null)
                            {
                                messageContentBodyWithImg = new MessageContentBodyWithImg();
                                messageContentBodyWithImg.BindingContext = message;
                                ContentGrid.Children.Add(messageContentBodyWithImg, 0, 2);
                            }
                        }
                        else if (message.Content.Body.StartsWith("/code", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (messageContentBodyWithCode == null)
                            {
                                messageContentBodyWithCode = new MessageContentBodyWithCode();
                                messageContentBodyWithCode.BindingContext = message;
                                ContentGrid.Children.Add(messageContentBodyWithCode, 0, 2);
                            }
                        }
                        else if (messageContentBody == null)
                        {
                            messageContentBody = new MessageContentBody();
                            messageContentBody.BindingContext = message;
                            ContentGrid.Children.Add(messageContentBody, 0, 2);
                        }

                        BtnPosition = 2;
                    }
                    else if (message.Content.Type == "deletedMessage")
                    {
                        // We don't need action button in this case
                        needActionButton = false;

                        // Create MessageContentDeleted
                        messageContentDeleted = new MessageContentDeleted();
                        messageContentDeleted.BindingContext = message;
                        ContentGrid.Children.Add(messageContentDeleted, 0, 2);
                        Grid.SetColumnSpan(messageContentDeleted, 2);
                    }

                    // Add Attachment element ?
                    if (message.Content.Attachment != null)
                    {
                        if (messageContentAttachment == null)
                        {
                            messageContentAttachment = new MessageContentAttachment();
                            messageContentAttachment.BindingContext = message;
                            ContentGrid.Children.Add(messageContentAttachment, 0, 3);

                            if (BtnPosition == -1)
                            {
                                BtnPosition = 3;
                            }
                            else
                            {
                                Grid.SetColumnSpan(messageContentAttachment, 2);
                            }
                        }
                    }

                    // Are we managing a msg of the current user ?
                    if (message.Peer.Id == Helper.SdkWrapper.GetCurrentContactId())
                    {
                        color           = Helper.GetResourceDictionaryById <Color>("ColorConversationStreamMessageCurrentUserFont");
                        backgroundColor = Helper.GetResourceDictionaryById <Color>("ColorConversationStreamMessageCurrentUserBackGround");
                    }
                    else
                    {
                        color           = Helper.GetResourceDictionaryById <Color>("ColorConversationStreamMessageOtherUserFont");
                        backgroundColor = Helper.GetResourceDictionaryById <Color>("ColorConversationStreamMessageOtherUserBackGround");
                    }
                    interpolateColor = ColorInterpolator.InterpolateBetween(color, backgroundColor, 0.5);


                    Frame.BackgroundColor = backgroundColor;

                    // Add Btn Action in the correct place
                    if (needActionButton && (BtnPosition != -1))
                    {
                        CreateBtnAction();

                        BtnAction.ImageSourceId              = null;
                        BtnAction.BackgroundColor            = backgroundColor;
                        BtnAction.BackgroundColorOnMouseOver = interpolateColor;

                        ContentGrid.Children.Add(BtnAction, 1, BtnPosition);
                    }
                }
            }
        }
Ejemplo n.º 22
0
 public void SetInterpolator(ColorInterpolator p)
 {
     this._interpolator = p;
 }