/// <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> /// 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); } } }