Beispiel #1
0
 private void RecurseLoadTemplate(DbSet<SigNode> nodeSet, TemplateViewModel template, ObservableCollection<TemplateNodeViewModel> nodes, Int64  parentId,List<TemplateNodeLayerViewModel> layersNodes)
 {
     List<SigNode> levelNodes = (from n in nodeSet where n.SigTemplateId == template.Id && n.ParentId == parentId orderby n.Order select n).ToList();
     foreach (SigNode levelNode in levelNodes)
     {
         if (levelNode.SigCodeNode.Code.Equals("Folder"))
         {
             TemplateNodeFolderViewModel vm = new TemplateNodeFolderViewModel(levelNode);
             nodes.Add(vm);
             this.RecurseLoadTemplate(nodeSet, template, vm.Nodes, levelNode.Id, layersNodes);
         }
         else if (levelNode.SigCodeNode.Code.Equals("Layer"))
         {
             TemplateNodeLayerViewModel vm = new TemplateNodeLayerViewModel(levelNode);
             nodes.Add(vm);
             layersNodes.Add(vm);
         }
     }
 }
Beispiel #2
0
        private void RemoveLayerMetier(TemplateViewModel templateViewModel, TemplateNodeLayerViewModel templateNodeLayerViewModel)
        {
            DbSet<SigNode> nodes = this.DataService.GetDbSet<SigNode>();
            DbSet<SigLayer> layers = this.DataService.GetDbSet<SigLayer>();

            TemplateNodeFolderViewModel parentFolder = this.GetParentFolder(templateViewModel, templateViewModel.Nodes, templateNodeLayerViewModel);
            if (parentFolder != null)
            {parentFolder.Nodes.Remove(templateNodeLayerViewModel);}
            else
            {templateViewModel.Nodes.Remove(templateNodeLayerViewModel);}
            nodes.Remove(templateNodeLayerViewModel.Model);
            this.DataService.DataContext.Entry(templateNodeLayerViewModel.Model).Reload();
            if (templateNodeLayerViewModel.Model.SigLayerId.HasValue)
            {
                SigLayer layerToRemove = (from l in layers where l.Id == templateNodeLayerViewModel.Model.SigLayerId.Value select l).FirstOrDefault();
                if (layerToRemove != null)
                { layers.Remove(layerToRemove); }
            }
            
          
            this.DataService.DataContext.SaveChanges();


            List<SigNode> nodeMaps = (from n in nodes where n.SigTemplateId == templateViewModel.Id && n.SigLayer != null orderby n.SigLayer.MapOrder select n).ToList();
            int mapOrder = 0;
            foreach (SigNode nodeMap in nodeMaps)
            {
                nodeMap.SigLayer.MapOrder = mapOrder;
                mapOrder++;
            }
            this.DataService.DataContext.SaveChanges();

            int nodeOrder = 0;
            if (parentFolder != null)
            {
                foreach (TemplateNodeViewModel child in parentFolder.Nodes)
                {
                    child.Model.Order = nodeOrder;
                    nodeOrder++;
                }
            }
            else
            {
                foreach (TemplateNodeViewModel child in templateViewModel.Nodes)
                {
                    child.Model.Order = nodeOrder;
                    nodeOrder++;
                }
            }
            
            this.DataService.DataContext.SaveChanges();
            foreach (IMapLayer layer in templateNodeLayerViewModel.Layers)
            {this.Map.Layers.Remove(layer);}
        }
Beispiel #3
0
        private void AddLayerMetier(TemplateViewModel templateViewModel, TemplateNodeFolderViewModel parentFolder, EntityTableInfo tableInfo)
        {
            long nextMapOrder = this.GetNextMapOrder();
            DbSet<SigNode> nodes = this.DataService.GetDbSet<SigNode>();
            DbSet<SigLayer> layers = this.DataService.GetDbSet<SigLayer>();


            DbSet<SigCodeNode> codeNodes = this.DataService.GetDbSet<SigCodeNode>();
            DbSet<SigCodeLayer> codeLayers = this.DataService.GetDbSet<SigCodeLayer>();
           
            SigNode nodeLayerMetier = new SigNode();
            nodeLayerMetier.SigTemplateId = templateViewModel.Id;
            if (parentFolder != null)
            {
                nodeLayerMetier.ParentId = parentFolder.Model.Id;
                nodeLayerMetier.Order = parentFolder.Nodes.Count;
            }
            else
            {
                nodeLayerMetier.ParentId = -1;
                nodeLayerMetier.Order = templateViewModel.Nodes.Count;
            }
            nodeLayerMetier.SigCodeNode = (from c in codeNodes where c.Code.Equals("Layer") select c).FirstOrDefault();
            nodeLayerMetier.Libelle = tableInfo.DisplayName;
            SigLayer layer = new SigLayer();
            layer.Libelle = tableInfo.DisplayName;
            layer.MapOrder = nextMapOrder;
            layer.EntityName = tableInfo.EntityType.Name;
            layer.SigCodeLayer = (from c in codeLayers where c.Code.Equals("Geocodage") select c).FirstOrDefault();
            layers.Add(layer);           
            this.DataService.DataContext.SaveChanges();
            nodeLayerMetier.SigLayer = layer;
            nodes.Add(nodeLayerMetier);
            this.DataService.DataContext.SaveChanges();
            nodeLayerMetier.SigLayer = layer;
            nodeLayerMetier.SigLayerId = layer.Id;
            TemplateNodeLayerViewModel vm = new TemplateNodeLayerViewModel(nodeLayerMetier);
            if (parentFolder == null)
            { templateViewModel.Nodes.Add(vm); }
            else
            { parentFolder.Nodes.Add(vm); }
            vm.CreateLayers();
            foreach (IMapLayer mapLayer in vm.Layers)
            {this.Map.Layers.Add(mapLayer);}
        }
Beispiel #4
0
        private void CreateStyle(TemplateNodeLayerViewModel templateNodeLayerViewModel)
        {
            StyleViewModel vm = new StyleViewModel();
            vm.DisplayName = "Nouveau style";
            IDialogService dialogService = ServiceLocator.Current.GetInstance<IDialogService>();
            Window window =  dialogService.CreateDialog("CartoStyleRegion", "Création d'un style");
            window.DataContext = vm;
            Nullable<Boolean> result = window.ShowDialog();

        }