public TreeViewController(TreeViewContext context)
        {
            _context = context;

            if (_context.TreeNodes.Count() == 0)
            {
                _context.TreeNodes.AddRange(defaultTreeViewState);
                _context.SaveChanges();
            }
        }
Example #2
0
        /// <summary>
        /// Sets the root resource folder, registers events and refreshes controls</summary>
        /// <param name="rootFolder">Resource folder</param>
        public void SetRootFolder(IResourceFolder rootFolder)
        {
            if (m_watcher == null)
            {
                m_uiThreadContext               = SynchronizationContext.Current;
                m_watcher                       = new FileSystemWatcher();
                m_watcher.SynchronizingObject   = m_mainForm;
                m_watcher.IncludeSubdirectories = true;
                m_watcher.EnableRaisingEvents   = false;
                m_watcher.Created              += Watcher_FileChanged;
                m_watcher.Deleted              += Watcher_FileChanged;
                m_watcher.Renamed              += Watcher_Renamed;

                // We need to shut down the watcher before the dispose phase begins
                // this is because file events can occur while disposing other MEF objects
                // (eg, flushing out a cached file). When this happens, we can get a
                // callback that can end up accessing MEF objects that have already
                // been disposed.
                Application.ApplicationExit += ShutdownWatcher;
            }

            IFileSystemResourceFolder rootDirectory = rootFolder as IFileSystemResourceFolder;

            if (rootDirectory != null)
            {
                m_watcher.Path = rootDirectory.FullPath;
                m_watcher.EnableRaisingEvents = true;
            }
            else
            {
                m_watcher.Path = null;
                m_watcher.EnableRaisingEvents = false;
            }

            if (m_treeContext != null)
            {
                m_treeContext.SelectionChanged -= TreeSelectionChanged;
            }

            m_treeContext = new TreeViewContext(rootFolder);
            m_treeContext.SelectionChanged += TreeSelectionChanged;
            m_treeControlAdapter.TreeView   = m_treeContext;

            if (m_listContext != null)
            {
                m_listContext.SelectionChanged -= listSelectionContext_SelectionChanged;
            }

            m_listContext = new ListViewContext();
            m_listContext.SelectionChanged += listSelectionContext_SelectionChanged;
            m_listViewAdapter.ListView      = m_listContext;

            m_treeControlAdapter.Refresh(rootFolder);
        }
Example #3
0
        /// <summary>
        /// Sets the root resource folder, registers events and refreshes controls</summary>
        /// <param name="rootFolder">Resource folder</param>
        public void SetRootFolder(IResourceFolder rootFolder)
        {
            m_treeContext          = new TreeViewContext(rootFolder);
            m_treeSelectionContext = m_treeContext.As <ISelectionContext>();
            m_treeSelectionContext.SelectionChanged += TreeSelectionChanged;
            m_treeControlAdapter.TreeView            = m_treeContext;

            m_listContext = new ListViewContext();
            m_listViewAdapter.ListView = m_listContext;

            m_treeControlAdapter.Refresh(rootFolder);
        }
Example #4
0
        /// <summary>
        /// Sets the root resource folder, registers events and refreshes controls</summary>
        /// <param name="rootFolder">Resource folder</param>
        public void SetRootFolder(IResourceFolder rootFolder)
        {
            if (m_watcher == null)
            {
                m_watcher = new FileSystemWatcher();
                m_watcher.SynchronizingObject   = m_mainForm;
                m_watcher.IncludeSubdirectories = true;
                m_watcher.EnableRaisingEvents   = false;
                m_watcher.Created += Watcher_FileChanged;
                m_watcher.Deleted += Watcher_FileChanged;
                m_watcher.Renamed += Watcher_Renamed;
            }

            IFileSystemResourceFolder rootDirectory = rootFolder as IFileSystemResourceFolder;

            if (rootDirectory != null)
            {
                m_watcher.Path = rootDirectory.FullPath;
                m_watcher.EnableRaisingEvents = true;
            }
            else
            {
                m_watcher.Path = null;
                m_watcher.EnableRaisingEvents = false;
            }

            if (m_treeContext != null)
            {
                m_treeContext.SelectionChanged -= TreeSelectionChanged;
            }

            m_treeContext = new TreeViewContext(rootFolder);
            m_treeContext.SelectionChanged += TreeSelectionChanged;
            m_treeControlAdapter.TreeView   = m_treeContext;

            if (m_listContext != null)
            {
                m_listContext.SelectionChanged -= listSelectionContext_SelectionChanged;
            }

            m_listContext = new ListViewContext();
            m_listContext.SelectionChanged += listSelectionContext_SelectionChanged;
            m_listViewAdapter.ListView      = m_listContext;

            m_treeControlAdapter.Refresh(rootFolder);
        }
Example #5
0
        public async Task <ActionResult <List <TreeViewMenuItem> > > GetTreeViewMenuItems(TreeViewContext context)
        {
            if (context.Node is null)
            {
                ModelState.AddModelError(nameof(TreeViewContext.Node), $"The {nameof(TreeViewContext.Node)} field is required.");
            }
            if (ModelState.ErrorCount != 0)
            {
                return(BadRequest(new ValidationProblemDetails(ModelState)
                {
                    Status = StatusCodes.Status400BadRequest,
                }));
            }

            return(Ok(await context.Server.GetDatabaseSystem().LoadTreeViewMenuItems(context.Node !, context.Database, context.Server.Id !.Value)));
        }
Example #6
0
 public async Task <ActionResult <IEnumerable <TreeViewNode> > > GetTreeViewNodes(TreeViewContext context)
 {
     return(Ok(await context.Server.GetDatabaseSystem().LoadTreeViewNodes(context.Database, context.Node)));
 }