Exemplo n.º 1
0
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        private void _ChangeLayer(ActiveBoard b, Change change)
        {
            /*verificam ce s-a schimbat */
            var             jss = new JavaScriptSerializer();
            ChangeDataLayer cd  = jss.Deserialize <ChangeDataLayer>(change.ChangeString);

            /*cautam activelayer-ul corespunzator*/
            if (!b.Layers.ContainsKey(cd.Id))
            {
                throw new Exception("Changed layer id not found");
            }

            ActiveLayer l = b.Layers[cd.Id];

            /*modificam campurile*/
            l.Name             = cd.Name;
            l.LayerEntity.Name = cd.Name;

            /*  daca e schimbat orderul, trebuie refacut stack-ul */
            if (cd.Order != l.LayerEntity.Order)
            {
                l.LayerEntity.Order = cd.Order;
                /*il stergem din pozitia existenta*/
                b.LayerStack.Remove(l);
                /*il reinseram*/
                b.LayerStack.Insert(cd.Order, l);
            }
        }
Exemplo n.º 2
0
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        private void _AddLayer(ActiveBoard b, Change change)
        {
            ActiveLayer     newActiveLayer = new ActiveLayer();
            var             jss            = new JavaScriptSerializer();
            ChangeDataLayer cd             = jss.Deserialize <ChangeDataLayer>(change.ChangeString);

            newActiveLayer.Id   = cd.Id;
            newActiveLayer.Name = cd.Name;

            /*creem si o entitate in bd*/
            Layer newLayer = new Layer();

            newActiveLayer.LayerEntity = newLayer;
            newLayer.LayerId           = cd.Id;
            newLayer.Order             = cd.Order;
            newLayer.BoardId           = b.BoardEntity.Id;
            newLayer.Name = cd.Name;

            /*inseram in stackul de layere din board*/
            lock (b.Layers) {
                b.Layers.Add(cd.Id, newActiveLayer);
            }
            lock (b.LayerStack) {
                b.LayerStack.Insert(cd.Order, newActiveLayer);
            }

            this._em.AddToLayers(newLayer);
        }