Beispiel #1
0
        ColorTranslation createDefaultColorTranslation(double lineHeight)
        {
            var ct = new ColorTranslation();

            ct.LineHeight = lineHeight;
            return(ct);
        }
        public Color(string name, DefaultContext context, ColorTranslation.Languages lang = ColorTranslation.Languages.Eng)
        {
            if (context == null)
            {
                throw new Exception("DefaultContext is null");
            }
            ColorTranslation translation = null;

            switch (lang)
            {
            case ColorTranslation.Languages.Rus:
                translation = context.ColorTranslations.Where(c => c.Rus.Trim().ToLower() == name.Trim().ToLower()).FirstOrDefault();
                break;

            default:
                translation = context.ColorTranslations.Where(c => c.Eng.Trim().ToLower() == name.Trim().ToLower()).FirstOrDefault();
                break;
            }
            if (translation != null)
            {
                var color = context.Colors.Where(c => c.Id == translation.ColorId).First();
                r  = color.r;
                g  = color.g;
                b  = color.b;
                a  = color.a;
                Id = color.Id;
            }
            else
            {
                Id = -1;
                a  = 1;
            }
        }
Beispiel #3
0
 public void Setup()
 {
     this.polygon          = this.createDefaultPolygon();
     this.triangle         = this.createTriangle();
     this.inverseTriangle  = this.createInverseTriangle();
     this.colorTranslation = this.createDefaultColorTranslation(0.1);
 }
Beispiel #4
0
        public async Task ModifyTranslation(ColorTranslation translation)
        {
            Validate(translation);

            if (State.Value == null)
            {
                throw new ColorsException("Translation does not exists");
            }

            var modified = false;

            foreach (ColorTranslation item in State.Value.Translations)
            {
                if (item.Language == translation.Language)
                {
                    item.Translation = translation.Translation;
                    modified         = true;
                }
            }
            if (modified == false)
            {
                throw new ColorsException("Translation does not exists");
            }

            await WriteStateAsync();
        }
Beispiel #5
0
 private void Validate(ColorTranslation translation)
 {
     if (!IsValidTranslation(translation))
     {
         throw new ColorsException("Invallid values");
     }
 }
        public async Task <IHttpActionResult> PostColorTranslation(ColorTranslation ColorTranslation)
        {
            if (ColorTranslation == null)
            {
                return(BadRequest("Отсутствует тело элемента"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            _db.ColorTranslations.Add(ColorTranslation);

            try
            {
                await _db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ColorTranslationExists(ColorTranslation.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }
            return(CreatedAtRoute("DefaultApi", new { id = ColorTranslation.Id }, ColorTranslation));
        }
        public void StartColorTranslation(ColorTranslation ct)
        {
            if (CurrentColorTranslation != null)
            {
                StopColorTranslation(false);
            }

            CameraSupervisor.MainCamera.DOColor(ct.DestanationColor, ct.Time)
            .SetId(MakeUniqueId(ColorTranslationTweenId))
            .SetEase(ct.Ease)
            .OnComplete(OnColorTranslationComplete)
            .SetDelay(ct.Delay);
        }
        public async Task <IHttpActionResult> GetColorTranslation(int?id)
        {
            if (!id.HasValue)
            {
                return(BadRequest("Не указан Id"));
            }
            ColorTranslation ColorTranslation = await _db.ColorTranslations.Where(t => t.Id == id).SingleOrDefaultAsync();

            if (ColorTranslation == null)
            {
                return(NotFound());
            }
            return(Ok(ColorTranslation));
        }
        public void StopColorTranslation(bool shouldCompleteTranslation = true)
        {
            if (CurrentColorTranslation == null)
            {
                return;
            }

            DOTween.Kill(MakeUniqueId(ColorTranslationTweenId), shouldCompleteTranslation);
            if (!shouldCompleteTranslation)
            {
                OnColorTranslationInterrupted();
            }
            CurrentColorTranslation = null;
        }
Beispiel #10
0
        public void Angle0IsIdenticalWithHorizontal()
        {
            var ct = new ColorTranslation();

            ct.LineHeight = 0.234;

            Polygon           p  = this.createDefaultPolygon();
            HorizontalStepper hs = new HorizontalStepper(p, ct);
            AngleStepper      a  = new AngleStepper(p, ct);


            List <Step> stepsHorizontal = hs.CalculateFillSteps();
            List <Step> stepsAngle      = a.CalculateFillSteps();

            CollectionAssert.AreEqual(stepsHorizontal, stepsAngle);
        }
        public async Task <IActionResult> Post(string id, [FromBody] ColorTranslation value)
        {
            var rgb = id.ToUpper();

            try
            {
                var grain = _client.GetGrain <IColorGrain>(rgb);
                await grain.AddTranslation(value);

                return(Ok(new { Message = "Translation added" }));
            }
            catch (ColorsException e)
            {
                return(BadRequest(new { Message = e.Message }));
            }
        }
        public async Task <IHttpActionResult> PutColorTranslation(int?id, ColorTranslation ColorTranslation)
        {
            if (!id.HasValue)
            {
                return(BadRequest("Не указан Id"));
            }
            if (ColorTranslation == null)
            {
                return(BadRequest("Отсутствует тело элемента"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != ColorTranslation.Id)
            {
                return(BadRequest());
            }

            _db.Entry(ColorTranslation).State = EntityState.Modified;

            try
            {
                await _db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ColorTranslationExists(id.Value))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #13
0
        public async Task AddTranslation(ColorTranslation translation)
        {
            Validate(translation);

            if (State.Value == null)
            {
                // Un color que no existeix, cal crear l'estat
                State = new ColorState
                {
                    Value = new Color
                    {
                        Id           = this.GetPrimaryKeyString(),
                        Translations = new List <ColorTranslation>()
                    }
                };
            }

            if (State.Value.Translations.Count(it => it.Language == translation.Language) != 0)
            {
                throw new ColorsException("Translation already exists");
            }
            State.Value.Translations.Add(translation);
            await WriteStateAsync();
        }
Beispiel #14
0
 private bool IsValidTranslation(ColorTranslation c) => c.Language != null && c.Translation != null;
Beispiel #15
0
 private void OnColorTranslationComplete()
 {
     CurrentColorTranslation = null;
     StartNewColorTranslation();
 }
Beispiel #16
0
 public static Color GetColor(this Spell.SpellBase spell)
 {
     return(ColorTranslation.ContainsKey(spell.Slot) ? ColorTranslation[spell.Slot] : Color.Wheat);
 }
Beispiel #17
0
        static IEnumerable <Step> CreatePatch(double patchSize, double xPosition, double yPosition, ColorTranslation ct)
        {
            var points = new Point[] { new Point(xPosition, yPosition),
                                       new Point(xPosition + patchSize, yPosition),
                                       new Point(xPosition + patchSize, yPosition + patchSize),
                                       new Point(xPosition, yPosition + patchSize) };

            Polygon p = new Polygon(points);

            var s = new AngleStepper(p, ct);

            return(s.CalculateFillSteps());
        }