Example #1
0
        public ActionResult Edit([Bind(Include = "Id,Name")] EditLayerViewModel model)
        {
            try
            {
                logger.InfoFormat("UserId={0}", User.Identity.GetUser().Id);

                if (ModelState.IsValid)
                {
                    using (var access = new DataAccess())
                    {
                        var layer = access.Layers.GetByID(model.Id);
                        if (layer == null)
                        {
                            logger.ErrorFormat("NOT_FOUND -- Layer with id={0} not found.", model.Id);

                            ModelState.AddModelError("", Error.NOT_FOUND);
                        }
                        else if (layer.Map.User.Id != User.Identity.GetUser().Id)
                        {
                            logger.ErrorFormat("FORBIDDEN -- User with id={0} cannot access layer with id={1}.",
                                               User.Identity.GetUser().Id, model.Id);

                            ModelState.AddModelError("", Error.FORBIDDEN);
                        }
                        else
                        {
                            var sameNameLayer = access.Layers.Get(l => l.Name.Equals(model.Name) && l.Map.Id == layer.Map.Id).SingleOrDefault();
                            if (sameNameLayer != null && !sameNameLayer.Id.Equals(layer.Id))
                            {
                                logger.ErrorFormat("UserId={0} -- Duplicate layer name", User.Identity.GetUser().Id);

                                ModelState.AddModelError("", string.Format("Layer with name '{0}' already exists.", layer.Name));
                            }
                            else
                            {
                                layer.Name = model.Name;
                                access.Layers.Update(layer);
                                access.Save();
                                return(PartialView("Details", new DetailsLayerViewModel(layer)));
                            }
                        }
                    }
                }
                else
                {
                    logger.ErrorFormat("UserId={0} -- Model state is invalid", User.Identity.GetUser().Id);
                }
            }
            catch (Exception ex)
            {
                logger.Fatal("", ex);
                ModelState.AddModelError("", Error.ERROR);
            }
            return(PartialView(model));
        }
Example #2
0
        public override IDock CreateLayout()
        {
            var documentViewModel = new SceneControlDocumentViewModel()
            {
                Id    = "Viewport",
                Title = "Viewport"
            };

            documentViewModel.SceneControlViewModel.Document = m_ViewModel.Document;

            var layersToolViewModel = new LayersViewModel()
            {
                Id    = "Layers",
                Title = "Layers"
            };

            layersToolViewModel.SceneViewModel.Scene = documentViewModel.SceneControlViewModel;

            var editLayerToolViewModel = new EditLayerViewModel()
            {
                Id    = "GroupAndLayerSettings",
                Title = "Group and Layer Settings"
            };

            editLayerToolViewModel.SceneViewModel.Scene = documentViewModel.SceneControlViewModel;

            var addGeometryViewModel = new AddGeometryViewModel()
            {
                Id    = "AddGeometry",
                Title = "Add Geometry"
            };

            addGeometryViewModel.SceneViewModel.Scene = documentViewModel.SceneControlViewModel;

            var mainLayout = new ProportionalDock
            {
                Id               = "MainLayout",
                Title            = "MainLayout",
                Proportion       = double.NaN,
                Orientation      = Orientation.Horizontal,
                ActiveDockable   = null,
                VisibleDockables = CreateList <IDockable>
                                   (
                    new ProportionalDock
                {
                    Id               = "LeftPane",
                    Title            = "LeftPane",
                    Proportion       = .2,
                    Orientation      = Orientation.Vertical,
                    ActiveDockable   = null,
                    VisibleDockables = CreateList <IDockable>
                                       (
                        new ToolDock
                    {
                        Id               = "LeftPaneTop",
                        Title            = "LeftPaneTop",
                        Proportion       = double.NaN,
                        ActiveDockable   = layersToolViewModel,
                        VisibleDockables = CreateList <IDockable>
                                           (
                            layersToolViewModel
                                           )
                    },
                        new SplitterDock()
                    {
                        Id    = "LeftPaneTopSplitter",
                        Title = "LeftPaneTopSplitter"
                    },
                        new ToolDock
                    {
                        Id               = "LeftPaneBottom",
                        Title            = "LeftPaneBottom",
                        Proportion       = double.NaN,
                        ActiveDockable   = editLayerToolViewModel,
                        VisibleDockables = CreateList <IDockable>
                                           (
                            editLayerToolViewModel
                                           )
                    }
                                       )
                },
                    new SplitterDock()
                {
                    Id    = "LeftSplitter",
                    Title = "LeftSplitter"
                },
                    new ProportionalDock
                {
                    Id               = "CenterPane",
                    Title            = "CenterPane",
                    Proportion       = double.NaN,
                    Orientation      = Orientation.Vertical,
                    ActiveDockable   = null,
                    VisibleDockables = CreateList <IDockable>
                                       (
                        new DocumentDock
                    {
                        Id               = "DocumentsPane",
                        Title            = "DocumentsPane",
                        Proportion       = .8,
                        ActiveDockable   = documentViewModel,
                        VisibleDockables = CreateList <IDockable>
                                           (
                            documentViewModel
                                           )
                    },
                        new SplitterDock()
                    {
                        Id    = "CenterPaneSplitter",
                        Title = "CenterPaneSplitter"
                    },
                        new ToolDock
                    {
                        Id               = "CenterPaneBottom",
                        Title            = "CenterPaneBottom",
                        Proportion       = double.NaN,
                        ActiveDockable   = addGeometryViewModel,
                        VisibleDockables = CreateList <IDockable>
                                           (
                            addGeometryViewModel
                                           )
                    }
                                       )
                }
                                   )
            };

            var mainView = new MainViewModel
            {
                Id               = "Main",
                Title            = "Main",
                ActiveDockable   = mainLayout,
                VisibleDockables = CreateList <IDockable>(mainLayout)
            };

            var root = CreateRootDock();

            root.Id               = "Root";
            root.Title            = "Root";
            root.ActiveDockable   = mainView;
            root.DefaultDockable  = mainView;
            root.VisibleDockables = CreateList <IDockable>(mainView);

            return(root);
        }
Example #3
0
        public override IDock CreateLayout()
        {
            SpatialDocument document = new SpatialDocument();
            ILayer          layer    = document.AddItemsLayer();

            document.SelectedNode = layer;
            layer.Name            = "WKT Geometries";

            var documentViewModel = new SceneControlDocumentViewModel()
            {
                Id    = "Document1",
                Title = "Document 1"
            };

            documentViewModel.SceneControlViewModel.Document = document;

            var layersToolViewModel = new LayersViewModel()
            {
                Id    = "Layers",
                Title = "Layers"
            };

            layersToolViewModel.SceneViewModel.Scene = documentViewModel.SceneControlViewModel;

            var editLayerToolViewModel = new EditLayerViewModel()
            {
                Id    = "GroupAndLayerSettings",
                Title = "Group and Layer Settings"
            };

            editLayerToolViewModel.SceneViewModel.Scene = documentViewModel.SceneControlViewModel;

            var addGeometryViewModel = new AddGeometryViewModel()
            {
                Id    = "AddGeometry",
                Title = "Add Geometry"
            };

            addGeometryViewModel.SceneViewModel.Scene = documentViewModel.SceneControlViewModel;

            var mainLayout = new ProportionalDock
            {
                Id               = "MainLayout",
                Title            = "MainLayout",
                Proportion       = double.NaN,
                Orientation      = Orientation.Horizontal,
                ActiveDockable   = null,
                VisibleDockables = CreateList <IDockable>
                                   (
                    new ProportionalDock
                {
                    Id               = "LeftPane",
                    Title            = "LeftPane",
                    Proportion       = .2,
                    Orientation      = Orientation.Vertical,
                    ActiveDockable   = null,
                    VisibleDockables = CreateList <IDockable>
                                       (
                        new ToolDock
                    {
                        Id               = "LeftPaneTop",
                        Title            = "LeftPaneTop",
                        Proportion       = double.NaN,
                        ActiveDockable   = layersToolViewModel,
                        VisibleDockables = CreateList <IDockable>
                                           (
                            layersToolViewModel
                                           )
                    },
                        new SplitterDock()
                    {
                        Id    = "LeftPaneTopSplitter",
                        Title = "LeftPaneTopSplitter"
                    },
                        new ToolDock
                    {
                        Id               = "LeftPaneBottom",
                        Title            = "LeftPaneBottom",
                        Proportion       = double.NaN,
                        ActiveDockable   = editLayerToolViewModel,
                        VisibleDockables = CreateList <IDockable>
                                           (
                            editLayerToolViewModel
                                           )
                    }
                                       )
                },
                    new SplitterDock()
                {
                    Id    = "LeftSplitter",
                    Title = "LeftSplitter"
                },
                    new ProportionalDock
                {
                    Id               = "CenterPane",
                    Title            = "CenterPane",
                    Proportion       = double.NaN,
                    Orientation      = Orientation.Vertical,
                    ActiveDockable   = null,
                    VisibleDockables = CreateList <IDockable>
                                       (
                        new DocumentDock
                    {
                        Id               = "DocumentsPane",
                        Title            = "DocumentsPane",
                        Proportion       = .8,
                        ActiveDockable   = documentViewModel,
                        VisibleDockables = CreateList <IDockable>
                                           (
                            documentViewModel
                                           )
                    },
                        new SplitterDock()
                    {
                        Id    = "CenterPaneSplitter",
                        Title = "CenterPaneSplitter"
                    },
                        new ToolDock
                    {
                        Id               = "CenterPaneBottom",
                        Title            = "CenterPaneBottom",
                        Proportion       = double.NaN,
                        ActiveDockable   = addGeometryViewModel,
                        VisibleDockables = CreateList <IDockable>
                                           (
                            addGeometryViewModel
                                           )
                    }
                                       )
                }
                                   )
            };

            var mainView = new MainViewModel
            {
                Id               = "Main",
                Title            = "Main",
                ActiveDockable   = mainLayout,
                VisibleDockables = CreateList <IDockable>(mainLayout)
            };

            var root = CreateRootDock();

            root.Id               = "Root";
            root.Title            = "Root";
            root.ActiveDockable   = mainView;
            root.DefaultDockable  = mainView;
            root.VisibleDockables = CreateList <IDockable>(mainView);
            root.Top              = CreatePinDock();
            root.Top.Alignment    = Alignment.Top;
            root.Bottom           = CreatePinDock();
            root.Bottom.Alignment = Alignment.Bottom;
            root.Left             = CreatePinDock();
            root.Left.Alignment   = Alignment.Left;
            root.Right            = CreatePinDock();
            root.Right.Alignment  = Alignment.Right;

            return(root);
        }