Ejemplo n.º 1
0
        public JsonResult AddCharacter(string questionId, double x, double y, double width, double height)
        {
            UpdateList();
            AnimateViewModel a = new AnimateViewModel();

            a = GetAnimatesType((listImageType.Where(z => z.Type == "Character")).FirstOrDefault().Id, new Guid(questionId));
            if (a != null)
            {
                //var cek = listImage.Where(im => im.Name == imageName).FirstOrDefault().Id;

                if (height != 0)
                {
                    a.Height = height;
                }
                if (width != 0)
                {
                    a.Width = width;
                }
                a.PosX = x;
                a.PosY = y;
                a.UpdateAnimate();
                return(Json(a, JsonRequestBehavior.AllowGet));
            }
            return(Json(a, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public JsonResult AddAnimates(string imageType, string imageName, string questionId, double x, double y, double width, double height)
        {
            var c = imageName;

            UpdateList();
            AnimateViewModel a = new AnimateViewModel();

            a = GetAnimatesType(new Guid(imageType), new Guid(questionId));
            if (a != null)
            {
                //var cek = listImage.Where(im => im.Name == imageName).FirstOrDefault().Id;
                a.ImageId = new Guid(imageName);

                if (height != 0)
                {
                    a.Height = height;
                }
                if (width != 0)
                {
                    a.Width = width;
                }
                a.PosX = x;
                a.PosY = y;
                a.UpdateAnimate();
                return(Json(a, JsonRequestBehavior.AllowGet));
            }
            else
            {
                a            = new AnimateViewModel();
                a.Id         = Guid.NewGuid();
                a.ImageId    = new Guid(imageName);
                a.QuestionId = new Guid(questionId);
                a.Height     = i.GetType((Guid)a.ImageId).Height;
                a.Width      = i.GetType((Guid)a.ImageId).Width;
                a.PosX       = 0;
                a.PosY       = 0;

                //brutal
                if (imageType == "Background")
                {
                    a.Depth = 0;
                }
                else if (imageType == "Dialog")
                {
                    a.Depth = 1;
                }
                else if (imageType == "Character")
                {
                    a.Depth = 2;
                }
                a.AddAnimate();
                return(Json(a, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 3
0
        public JsonResult GetAnimates(string questionId)
        {
            var temp = db.Animates.Where(x => x.IsDeleted == false && x.QuestionId == new Guid(questionId));
            AnimatesController      ac = new AnimatesController();
            List <AnimateViewModel> a  = new List <AnimateViewModel>();

            foreach (var item in temp)
            {
                AnimateViewModel animate = new AnimateViewModel(item);
                string[]         s       = i.GetImageType((Guid)item.ImageId).Split(' ');
                animate.imageType = s[0];
                animate.Location  = db.Images.Where(x => x.Id == (Guid)item.ImageId).FirstOrDefault().Location;
                a.Add(animate);
            }
            a.OrderBy(x => x.imageType);
            return(Json(a, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        //------end color

        //---------------------------apply to all

        public JsonResult ApplyAll(string questionId, string color, int size)
        {
            if (AccountController.CheckSurveyId())
            {
                AnimateViewModel a;
                UpdateList();
                var id       = new Guid(questionId);
                var surveyId = AccountController.GetSurveyId();
                var q        = listQuestion.Where(x => x.SurveyId == surveyId);
                var animates = listAnimate.Where(x => x.QuestionId == id);
                if (animates != null)
                {
                    foreach (var item in q)
                    {
                        if (item.Id != id)
                        {
                            item.FontColor = color;
                            item.FontSize  = size;
                            item.UpdateQuestion(item);
                            var animates2 = listAnimate.Where(x => x.QuestionId == item.Id);

                            foreach (var i in animates)
                            {
                                var check = animates2.Where(x => x.imageType == i.imageType).FirstOrDefault();
                                if (check == null)
                                {
                                    a = new AnimateViewModel
                                    {
                                        Id         = Guid.NewGuid(),
                                        QuestionId = item.Id,
                                        ImageId    = i.ImageId,
                                        Height     = i.Height,
                                        Width      = i.Width,
                                        PosX       = i.PosX,
                                        PosY       = i.PosY,
                                        Depth      = i.Depth
                                    };
                                    a.AddAnimate();
                                }
                                else
                                {
                                    check.ImageId = i.ImageId;
                                    check.Height  = i.Height;
                                    check.Width   = i.Width;
                                    check.PosX    = i.PosX;
                                    check.PosY    = i.PosY;
                                    check.Depth   = i.Depth;
                                    check.UpdateAnimate();
                                }
                            }
                            if (animates.Count() < animates2.Count())
                            {
                                foreach (var i in animates)
                                {
                                    var check = animates2.Where(x => x.imageType != i.imageType);
                                    if (check != null)
                                    {
                                        foreach (var j in check)
                                        {
                                            j.DeleteAnimate();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(Json(questionId, JsonRequestBehavior.AllowGet));
        }