コード例 #1
0
        // This Action may cost much time. TODO: improve it
        public override ActionResult LayerPanel([FromBody] LayerPanelRequest request)
        {
            string name = JsonHelper.CastTo <string>(request.name);

            var layers = new List <PanelViewModel>();
            // gets the action with the same name as the argument
            var action = _codecAction.SubActions.SingleOrDefault(c => c.Name.Equals(name));

            if (action == null || action.Result == null)
            {
                return(PartialView("_Layers", layers));
            }

            layers = GenerateLayers(name, action.Result, false);
            // add UseDifferenceTile
            ICodecAction subbandDiffingAction = _codecAction.SubActions.SingleOrDefault(c => c.Name.Equals(Constants.PDECODE_NAME_SUBBANDDIFFING));

            if (subbandDiffingAction != null)
            {
                var parameters  = new Dictionary <string, string>();
                var use_diffing = "False";
                if (action.Parameters.ContainsKey(Constants.PARAM_NAME_USE_DIFFERENCE_TILE) &&
                    action.Parameters[Constants.PARAM_NAME_USE_DIFFERENCE_TILE] is UseDifferenceTile &&
                    ((UseDifferenceTile)action.Parameters[Constants.PARAM_NAME_USE_DIFFERENCE_TILE]).Enabled)
                {
                    use_diffing = "True";
                }
                parameters.Add("use-diffing", use_diffing);
                ViewBag.Parameters = parameters;
            }

            return(PartialView("_Layers", layers));
        }
コード例 #2
0
        public override ActionResult LayerPanel([FromBody] LayerPanelRequest request)
        {
            var layersGroup = new List <PanelViewModel>();

            try
            {
                var CodecActionDic = this.HttpContext.Session.Get <Dictionary <int, ICodecAction> >(ConstantCodecActionDic);
                _codecAction = CodecActionDic == null ? null : (CodecActionDic.ContainsKey(request.layer) ? CodecActionDic[request.layer] : null);

                if (_codecAction == null)
                {
                    return(PartialView("_Layers", layersGroup));
                }

                if (request.name.Equals(Constants.DECODE_NAME_RECONSTRUCTEDFRAME))
                {
                    return(DecodedImage(request.layer));
                }

                // gets the action with the same name as the argument
                var action = _codecAction.SubActions.SingleOrDefault(c => c.Name.Equals(request.name));
                if (action == null || action.Result == null)
                {
                    return(PartialView("_Layers", layersGroup));
                }

                // create layers accroding to the given layer.
                // This is different with others
                string           idPrefix   = request.name.Replace(' ', '-').Replace('/', '-') + "-input-layer-" + request.layer;
                var              layerPanel = new PanelViewModel(idPrefix, "Layer " + request.layer);
                Tile             result     = action.Result.FirstOrDefault();
                Triplet <string> triplet    = result.GetStrings(TileSerializerFactory.GetDefaultSerizlizer());
                var              tabx       = new TabViewModel {
                    Id = idPrefix + "-Y", Title = "Y", Content = triplet.X, Editable = false
                };
                var taby = new TabViewModel {
                    Id = idPrefix + "-Cb", Title = "Cb", Content = triplet.Y, Editable = false
                };
                var tabz = new TabViewModel {
                    Id = idPrefix + "-Cr", Title = "Cr", Content = triplet.Z, Editable = false
                };
                layerPanel.Tabs = new List <TabViewModel> {
                    tabx, taby, tabz
                };
                layersGroup.Add(layerPanel);
            }
            catch (Exception ex)
            {
                return(Json(ReturnResult <string> .Fail(ex.Message)));
            }

            return(PartialView("_Layers", layersGroup));
        }
コード例 #3
0
        public override ActionResult InputPanel([FromBody] LayerPanelRequest request)
        {
            string name = JsonHelper.CastTo <string>(request.name);

            // gets the action with the same name as the argument
            var layers = new List <PanelViewModel>();
            var action = _codecAction.SubActions.SingleOrDefault(c => c.Name.Equals(name));

            if (action == null || action.Result == null)
            {
                return(PartialView("_Layers", layers));
            }

            layers = GenerateLayers(name, action.Input, true);

            return(PartialView("_Layers", layers));
        }
コード例 #4
0
        public virtual ActionResult LayerPanel([FromBody] LayerPanelRequest request)
        {
            if (request.name.Equals(Constants.DECODE_NAME_RECONSTRUCTEDFRAME))
            {
                return(DecodedImage());
            }

            var layers = new List <PanelViewModel>();

            try
            {
                var action = _codecAction.SubActions.FirstOrDefault(c => c.Name.Equals(request.name));
                if (action == null || action.Result == null)
                {
                    return(PartialView("_Layers", layers));
                }

                for (int index = 0; index < action.Result.Length; index++)
                {
                    string           idPrefix = request.name.Replace(' ', '-') + "-layer-" + index;
                    var              layer    = new PanelViewModel(idPrefix, "Layer " + index);
                    Tile             result   = action.Result[index];
                    Triplet <string> triplet  = result.GetStrings(TileSerializerFactory.GetDefaultSerizlizer());
                    var              tabx     = new TabViewModel {
                        Id = idPrefix + "-Y", Title = "Y", Content = triplet.X, Editable = false
                    };
                    var taby = new TabViewModel {
                        Id = idPrefix + "-Cb", Title = "Cb", Content = triplet.Y, Editable = false
                    };
                    var tabz = new TabViewModel {
                        Id = idPrefix + "-Cr", Title = "Cr", Content = triplet.Z, Editable = false
                    };
                    layer.Tabs = new List <TabViewModel> {
                        tabx, taby, tabz
                    };
                    layers.Add(layer);
                }
            }
            catch (Exception ex)
            {
                return(Json(ReturnResult <string> .Fail(ex.Message)));
            }

            return(PartialView("_Layers", layers));
        }
コード例 #5
0
        public virtual ActionResult InputPanel([FromBody] LayerPanelRequest request)
        {
            var layers = new List <PanelViewModel>();

            try
            {
                // gets the action with the same name as the argument
                var action = _codecAction.SubActions.FirstOrDefault(c => c.Name.Equals(request.name));
                if (action == null || action.Input == null)
                {
                    return(PartialView("_Layers", layers));
                }

                for (int index = 0; index < action.Input.Length; index++)
                {
                    string           idPrefix = request.name.Replace(' ', '-').Replace('/', '-') + "-input-layer-" + index;
                    var              layer    = new PanelViewModel(idPrefix, "Layer " + index);
                    Tile             result   = action.Input[index];
                    Triplet <string> triplet  = result.GetStrings(TileSerializerFactory.GetDefaultSerizlizer());
                    var              tabx     = new TabViewModel {
                        Id = idPrefix + "-Y", Title = "Y", Content = triplet.X, Editable = true
                    };
                    var taby = new TabViewModel {
                        Id = idPrefix + "-Cb", Title = "Cb", Content = triplet.Y, Editable = true
                    };
                    var tabz = new TabViewModel {
                        Id = idPrefix + "-Cr", Title = "Cr", Content = triplet.Z, Editable = true
                    };
                    layer.Tabs = new List <TabViewModel> {
                        tabx, taby, tabz
                    };
                    layers.Add(layer);
                }
            }
            catch (Exception ex)
            {
                return(Json(ReturnResult <string> .Fail(ex.Message)));
            }

            return(PartialView("_Layers", layers));
        }
コード例 #6
0
        public override ActionResult InputPanel([FromBody] LayerPanelRequest request)
        {
            // TODO: Extract Common with function Panel
            var layersGroup = new List <PanelViewModel>();

            try
            {
                var CodecActionDic = this.HttpContext.Session.Get <Dictionary <int, ICodecAction> >(ConstantCodecActionDic);
                _codecAction = CodecActionDic == null ? null : (CodecActionDic.ContainsKey(request.layer) ? CodecActionDic[request.layer] : null);

                if (_codecAction == null)
                {
                    return(PartialView("_Layers", layersGroup));
                }

                // gets the action with the same name as the argument
                var action = _codecAction.SubActions.SingleOrDefault(c => c.Name.Equals(request.name));
                if (action == null || action.Input == null)
                {
                    return(PartialView("_Layers", layersGroup));
                }

                // create layers accroding to the given layer.
                // This is different with others
                string idPrefix   = request.name.Replace(' ', '-').Replace('/', '-') + "-output-layer-" + request.layer;
                var    layerPanel = new PanelViewModel(idPrefix, "Layer " + request.layer);
                if (action.Input.Length > 1 && request.layer > 0)
                {
                    Tile             input      = action.Input[0];
                    Tile             rawInput   = action.Input[1];
                    Triplet <string> triplet    = input.GetStrings(TileSerializerFactory.GetDefaultSerizlizer());
                    Triplet <string> rawTriplet = rawInput.GetStrings(TileSerializerFactory.GetDefaultSerizlizer());
                    var tabx = new TabViewModel {
                        Id = idPrefix + "-Y", Title = "Y", Content = triplet.X, Editable = true
                    };
                    var tabrawx = new TabViewModel {
                        Id = idPrefix + "-YRaw", Title = "Y Raw Data", Content = rawTriplet.X, Editable = true
                    };
                    var taby = new TabViewModel {
                        Id = idPrefix + "-Cb", Title = "Cb", Content = triplet.Y, Editable = true
                    };
                    var tabrawy = new TabViewModel {
                        Id = idPrefix + "-CbRaw", Title = "Cb Raw Data", Content = rawTriplet.Y, Editable = true
                    };
                    var tabz = new TabViewModel {
                        Id = idPrefix + "-Cr", Title = "Cr", Content = triplet.Z, Editable = true
                    };
                    var tabrawz = new TabViewModel {
                        Id = idPrefix + "-CrRaw", Title = "Cr Raw Data", Content = rawTriplet.Z, Editable = true
                    };

                    layerPanel.Tabs = new List <TabViewModel> {
                        tabx, tabrawx, taby, tabrawy, tabz, tabrawz
                    };
                    layersGroup.Add(layerPanel);
                }
                else
                {
                    Tile             input   = action.Input.FirstOrDefault();
                    Triplet <string> triplet = input.GetStrings(TileSerializerFactory.GetDefaultSerizlizer());
                    var tabx = new TabViewModel {
                        Id = idPrefix + "-Y", Title = "Y", Content = triplet.X, Editable = true
                    };
                    var taby = new TabViewModel {
                        Id = idPrefix + "-Cb", Title = "Cb", Content = triplet.Y, Editable = true
                    };
                    var tabz = new TabViewModel {
                        Id = idPrefix + "-Cr", Title = "Cr", Content = triplet.Z, Editable = true
                    };
                    layerPanel.Tabs = new List <TabViewModel> {
                        tabx, taby, tabz
                    };
                    layersGroup.Add(layerPanel);
                }
            }
            catch (Exception ex)
            {
                return(Json(ReturnResult <string> .Fail(ex.Message)));
            }

            return(PartialView("_Layers", layersGroup));
        }