示例#1
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));
            }
        }
示例#2
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));
        }