/// <summary>
        /// Refresh path information
        /// </summary>
        internal void RefreshPath()
        {
            VisualPathElements.Clear();

            // Get structure object
            var fileStructure = GetStructure();

            var currentItem = fileStructure.Directories.FirstOrDefault(x => x.Id == SelectedDirectory?.Model.Id);

            while (currentItem != null)
            {
                var type = directoryTypeService.Get(currentItem.DirectoryTypeId);

                var label = new System.Windows.Controls.Label();
                label.Content             = currentItem.Name;
                label.VerticalAlignment   = VerticalAlignment.Center;
                label.HorizontalAlignment = HorizontalAlignment.Center;

                VisualPathElements.Insert(0, label);

                var image = new Image();
                image.Width               = 16;
                image.Height              = 16;
                image.VerticalAlignment   = VerticalAlignment.Center;
                image.HorizontalAlignment = HorizontalAlignment.Center;
                image.Source              = iconService.GetByIdAsImage(type.IconId);

                VisualPathElements.Insert(0, image);

                if (currentItem.Parent != null)
                {
                    currentItem = currentItem.Parent;

                    // If a parent exists, we need an arrow in the left side
                    var arrow = new Image();
                    arrow.Width               = 16;
                    arrow.Height              = 16;
                    arrow.VerticalAlignment   = VerticalAlignment.Center;
                    arrow.HorizontalAlignment = HorizontalAlignment.Center;
                    arrow.Margin              = new Thickness(3, 0, 3, 0);
                    arrow.Source              = iconService.GetByNameAsImage("filestructure_separator_16x");

                    VisualPathElements.Insert(0, arrow);
                }
                else
                {
                    currentItem = null;
                    break;
                }
            }

            if (fileStructure.StackGuid != null && fileStructure.InstanceDataGuid != null)
            {
                var displayContent = stackService.GetInstanceDataContent((Guid)fileStructure.StackGuid, (Guid)fileStructure.InstanceDataGuid);

                if (VisualPathElements.Any())
                {
                    var arrow = new Image();
                    arrow.Width               = 16;
                    arrow.Height              = 16;
                    arrow.VerticalAlignment   = VerticalAlignment.Center;
                    arrow.HorizontalAlignment = HorizontalAlignment.Center;
                    arrow.Margin              = new Thickness(3, 0, 3, 0);
                    arrow.Source              = iconService.GetByNameAsImage("filestructure_separator_16x");

                    VisualPathElements.Insert(0, arrow);
                }

                var label = new System.Windows.Controls.Label();
                label.Content             = displayContent;
                label.VerticalAlignment   = VerticalAlignment.Center;
                label.HorizontalAlignment = HorizontalAlignment.Center;

                VisualPathElements.Insert(0, label);

                var image = new Image();
                image.Width               = 16;
                image.Height              = 16;
                image.VerticalAlignment   = VerticalAlignment.Center;
                image.HorizontalAlignment = HorizontalAlignment.Center;
                image.Source              = iconService.GetByNameAsImage("filestructure_root_16x");

                VisualPathElements.Insert(0, image);
            }

            if (expander.IsExpanded)
            {
                expander.Content = null;
                expander.Content = new DirectoryFieldControl();
                (expander.Content as DirectoryFieldControl).Initialize(SelectedDirectory.Model, GetStructure(), true);
            }
        }
        /// <summary>
        /// Create view model
        /// </summary>
        public FileStructureViewModel(RadTreeView directoryTreeView, Expander expander)
        {
            this.directoryTreeView = directoryTreeView;
            this.expander          = expander;

            localizationService               = CommonServiceLocator.ServiceLocator.Current.GetInstance <ILocalizationService>();
            directoryTypeService              = CommonServiceLocator.ServiceLocator.Current.GetInstance <IDirectoryTypeService>();
            iconService                       = CommonServiceLocator.ServiceLocator.Current.GetInstance <IIconService>();
            stackService                      = CommonServiceLocator.ServiceLocator.Current.GetInstance <IStackService>();
            fielStructureService              = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFileStructureService>();
            documentWorkflowContextService    = CommonServiceLocator.ServiceLocator.Current.GetInstance <IDocumentWorkflowConfigurationService>();
            documentWorkflowAssignmentService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IDocumentWorkflowAssignmentService>();



            directoryFieldService     = CommonServiceLocator.ServiceLocator.Current.GetInstance <IDirectoryFieldService>();
            directoryTypeFieldService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IDirectoryClassificationFieldService>();

            rootPath           = "";
            VisualPathElements = new ObservableCollection <FrameworkElement>();

            directoryCategoryMenuItems = new ObservableCollection <RadMenuItem>();

            foreach (var category in directoryTypeService.GetAll().OrderBy(d => d.Category).GroupBy(d => d.Category))
            {
                var categoryItem = new RadMenuItem
                {
                    Header = category.Key,
                    Tag    = category.Key,
                    Icon   = new Image
                    {
                        Source = iconService.GetByNameAsImage("directory_add_x16"),
                        Width  = 16,
                        Height = 16
                    }
                };

                foreach (var type in category)
                {
                    var menuItem = new RadMenuItem
                    {
                        Header = localizationService.Translate(type.Name),
                        Icon   = new Image
                        {
                            Source = iconService.GetByIdAsImage(type.IconId),
                            Width  = 16,
                            Height = 16
                        },
                        Tag = type
                    };
                    menuItem.Click += AddDirectoryItemClick;
                    categoryItem.Items.Add(menuItem);
                }

                directoryCategoryMenuItems.Add(categoryItem);
            }

            // Create remove directory command
            removeDirectoryCommand = new RelayCommand((e) =>
            {
                if (SelectedDirectory != null)
                {
                    if (fielStructureService.GetDocuments(model, selectedDirectory.Model, true).Any())
                    {
                        MessageBox.Show(localizationService.Translate("filestructure_delete_notallowed"), localizationService.Translate("filestructure_delete_notallowed_title"), MessageBoxButton.OK, MessageBoxImage.Information);
                        return;
                    }

                    SelectedDirectory.RemoveDirectory();

                    SelectedDirectory = null;

                    IsDirty = true;

                    RefreshPath();
                }
            }, (e) => { return(selectedDirectory != null); });

            // Create edit metadata command
            editMetaDataCommand = new RelayCommand((e) =>
            {
                if (SelectedDirectory != null)
                {
                    var directoryFieldWindow = new DirectoryFieldWindow();

                    directoryFieldWindow.Initialize(SelectedDirectory.Model, GetStructure());
                    directoryFieldWindow.WindowMode = Framework.UI.WindowMode.Edit;
                    directoryFieldWindow.ShowDialog();
                    return;
                }
            }, (e) => { return(selectedDirectory != null); });

            renameDirectoryCommand = new RelayCommand((e) =>
            {
                if (SelectedDirectory != null)
                {
                    directoryTreeView.ContainerFromItemRecursive(directoryTreeView.SelectedItem).BeginEdit();
                    return;
                }
            }, (e) => { return(selectedDirectory != null); });

            // Command to assign the workflow
            assignWorkflowCommand = new RelayCommand((e) =>
            {
                if (selectedDirectory.Model.WorkflowId.HasValue)
                {
                    MessageBox.Show(localizationService.Translate("filestructure_workflow_assign_already"),
                                    localizationService.Translate("filestructure_delete_notallowed_title"), MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }

                var box = ItemBoxManager.GetItemBoxFromDB("IB_Document_Workflow");
                box.ShowDialog();
                var result = box.GetSelectedItemCell("Guid");

                if (result is Guid guid)
                {
                    selectedDirectory.Model.WorkflowId = guid;
                    //Assign all parents and children the workflow
                    AssignedWorkflowToParentsAndChildren(guid);
                    Save();
                    RaisePropertyChanged(nameof(AssignedWorkflow));
                    RaisePropertyChanged(nameof(AssignedWorkflowVisibility));
                }
            });

            // Archive from clipboard click
            archiveFromClipboard = new RelayCommand((e) =>
            {
                // Save before archive
                if (IsDirty)
                {
                    Save();
                }

                if (IsWorkflowDirectory(selectedDirectory))
                {
                    return;
                }
                Helper.ArchiveHelper.ArchiveFromClipboard(model, selectedDirectory.Model);
            }, (e) => { return(selectedDirectory != null); });

            // Archive from scanner
            archiveFromScanner = new RelayCommand((e) =>
            {
                // Save before archive
                if (IsDirty)
                {
                    Save();
                }

                if (IsWorkflowDirectory(selectedDirectory))
                {
                    return;
                }

                Helper.ArchiveHelper.ArchiveFromScanClient(model, selectedDirectory.Model);
            }, (e) => { return(selectedDirectory != null); });

            setReturnDirectory = new RelayCommand((e) =>
            {
                var parentDirectory = selectedDirectory.StructureViewModel.Directories.FirstOrDefault(x =>
                {
                    return(x == selectedDirectory.Parent);
                });
                foreach (var directory in parentDirectory.Directories)
                {
                    directory.IsReturnDirectory = false;
                }
                selectedDirectory.IsReturnDirectory = true;
            }, (e) => { return(selectedDirectory != null); });
        }
        /// <summary>
        /// Refresh path information
        /// </summary>
        internal void RefreshPath()
        {
            Model.Path = "";
            VisualPathElements.Clear();
            var fileStructure = fileStructureService.Get(Model.FileStructureGuid);



            if (fileStructure != null)
            {
                var currentItem = fileStructure.Directories.FirstOrDefault(x => x.Id == path.DirectoryGuid);
                while (currentItem != null)
                {
                    var type = directoryTypeService.Get(currentItem.DirectoryTypeId);

                    var label = new Label();
                    label.Content             = currentItem.Name;
                    label.VerticalAlignment   = VerticalAlignment.Center;
                    label.HorizontalAlignment = HorizontalAlignment.Center;

                    VisualPathElements.Insert(0, label);

                    var image = new Image();
                    image.Width               = 16;
                    image.Height              = 16;
                    image.VerticalAlignment   = VerticalAlignment.Center;
                    image.HorizontalAlignment = HorizontalAlignment.Center;
                    image.Source              = iconService.GetByIdAsImage(type.IconId);

                    VisualPathElements.Insert(0, image);

                    if (currentItem.Parent != null)
                    {
                        currentItem = currentItem.Parent;

                        // If a parent exists, we need an arrow in the left side
                        var arrow = new Image();
                        arrow.Width               = 16;
                        arrow.Height              = 16;
                        arrow.VerticalAlignment   = VerticalAlignment.Center;
                        arrow.HorizontalAlignment = HorizontalAlignment.Center;
                        arrow.Margin              = new Thickness(3, 0, 3, 0);
                        arrow.Source              = iconService.GetByNameAsImage("filestructure_separator_16x");

                        VisualPathElements.Insert(0, arrow);
                    }
                    else
                    {
                        currentItem = null;
                        break;
                    }
                }

                if (fileStructure.StackGuid != null && fileStructure.InstanceDataGuid != null)
                {
                    var displayContent = stackService.GetInstanceDataContent((Guid)fileStructure.StackGuid, (Guid)fileStructure.InstanceDataGuid);

                    var arrow = new Image();
                    arrow.Width               = 16;
                    arrow.Height              = 16;
                    arrow.VerticalAlignment   = VerticalAlignment.Center;
                    arrow.HorizontalAlignment = HorizontalAlignment.Center;
                    arrow.Margin              = new Thickness(3, 0, 3, 0);
                    arrow.Source              = iconService.GetByNameAsImage("filestructure_separator_16x");

                    VisualPathElements.Insert(0, arrow);

                    var label = new Label();
                    label.Content             = displayContent;
                    label.VerticalAlignment   = VerticalAlignment.Center;
                    label.HorizontalAlignment = HorizontalAlignment.Center;

                    VisualPathElements.Insert(0, label);

                    var image = new Image();
                    image.Width               = 16;
                    image.Height              = 16;
                    image.VerticalAlignment   = VerticalAlignment.Center;
                    image.HorizontalAlignment = HorizontalAlignment.Center;
                    image.Source              = iconService.GetByNameAsImage("filestructure_root_16x");

                    VisualPathElements.Insert(0, image);
                }
            }
        }