public JsonResult GetConfig(string name)
        {
            IExpress express = ServiceHelper.Create <IExpressService>().GetExpress(name);
            ExpressTemplateConfig expressTemplateConfig = new ExpressTemplateConfig()
            {
                width  = express.Width,
                height = express.Height,
                data   = (
                    from item in ExpressPrintElement.AllPrintElements
                    select new Element()
                {
                    key = item.Key.ToString(),
                    @value = item.Value
                }).ToArray()
            };
            ExpressTemplateConfig expressTemplateConfig1 = expressTemplateConfig;

            if (express.Elements != null)
            {
                int num = 0;
                foreach (ExpressPrintElement element in express.Elements)
                {
                    Element element1 = ((IEnumerable <Element>)expressTemplateConfig1.data).FirstOrDefault((Element t) => t.key == element.PrintElementIndex.ToString());
                    int[]   x        = new int[] { element.LeftTopPoint.X, element.LeftTopPoint.Y };
                    element1.a = x;
                    int[] numArray = new int[] { element.RightBottomPoint.X, element.RightBottomPoint.Y };
                    element1.b        = numArray;
                    element1.selected = true;
                    num++;
                }
                expressTemplateConfig1.selectedCount = num;
            }
            return(Json(expressTemplateConfig1, JsonRequestBehavior.AllowGet));
        }
        public JsonResult GetConfig(string name)
        {
            var template = _iExpressService.GetExpress(name);
            ExpressTemplateConfig config = new ExpressTemplateConfig()
            {
                width = template.Width,
                height = template.Height,

                data = ExpressPrintElement.AllPrintElements.Select(item => new Element()
                {
                    key = item.Key.ToString(),
                    value = item.Value,
                }).ToArray()
            };
            if (template.Elements != null)
            {
                int i = 0;
                foreach (var element in template.Elements)
                {
                    var item = config.data.FirstOrDefault(t => t.key == element.PrintElementIndex.ToString());
                    item.a = new int[] { element.LeftTopPoint.X, element.LeftTopPoint.Y };
                    item.b = new int[] { element.RightBottomPoint.X, element.RightBottomPoint.Y };
                    item.selected = true;
                    i++;
                }
                config.selectedCount = i;
            }
            return Json(config, JsonRequestBehavior.AllowGet);
        }
Example #3
0
        public JsonResult GetConfig(string name)
        {
            var template     = ExpressApplication.GetExpress(name);
            var elementTypes = Enum.GetValues(typeof(ExpressElementType));
            var allElements  = new List <Element>();

            foreach (var item in elementTypes)
            {
                Element el = new Element()
                {
                    key   = ((int)item).ToString(),
                    value = ((ExpressElementType)item).ToDescription()
                };
                allElements.Add(el);
            }
            ExpressTemplateConfig config = new ExpressTemplateConfig()
            {
                width  = template.Width,
                height = template.Height,
                data   = allElements.ToArray(),
            };

            if (template.Elements != null)
            {
                int i = 0;
                foreach (var element in template.Elements)
                {
                    var item = config.data.FirstOrDefault(t => t.key == ((int)element.ElementType).ToString());
                    item.a        = element.a;
                    item.b        = element.b;
                    item.selected = true;
                    i++;
                }
                config.selectedCount = i;
            }
            return(Json(config));
        }