// Update the ContentList list of files with all files and directories in the currently selected directory
        public void UpdateContentList()
        {
            if (SelectedDirectory != null)
            {
                FileFilter = string.Empty;
                ContentList.Clear();

                SelectedDirectory.UpdateFileList(ref _userMessage);
                SelectedDirectory.UpdateSubFolderList();

                foreach (UserDirectory folder in SelectedDirectory.Subfolders)
                {
                    ContentList.Add(folder);
                }

                foreach (UserFile file in SelectedDirectory.Files)
                {
                    //file.UpdateFileStatus();
                    ContentList.Add(file);
                    file.CheckFile(ref _userMessage);
                }

                SelectedDirectory.UpdatePerforceStatus();
                RaisePropertyChanged("UserMessage");
            }

            if (ContentList != null)
            {
                UserMessage = ContentList.Any(x => x.P4Success == false) ? P4ErrorMessage : UserMessage;
            }
        }
Exemple #2
0
        /// <summary>
        /// Processes and reroutes events when the list box selection changes.
        /// The three types of events are when selection count is 0, 1 or many.
        /// </summary>
        void listMain_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ignoreSelectionChanges.IsBlocked)
            {
                return;
            }

            foreach (ListPageItem added in e.AddedItems)
            {
                added.Selected = true;
            }

            foreach (ListPageItem added in e.RemovedItems)
            {
                added.Selected = false;
            }


            var count = listMain.SelectedItems.Count;

            if (count == 0)
            {
                SelectedNothing.Invoke(this, directory);
            }
            else if (count == 1)
            {
                var item = (ListPageItem)listMain.SelectedItem;

                if (item.Reference is File)
                {
                    SelectedFile.Invoke(this, directory, (File)item.Reference);
                }
                else if (item.Reference is Directory)
                {
                    SelectedDirectory.Invoke(this, directory, (Directory)item.Reference);
                }
                else if (item.Reference is Jump)
                {
                    SelectedJump.Invoke(this, directory, (Jump)item.Reference);
                }
                else if (item.Reference is Link)
                {
                    SelectedLink.Invoke(this, directory, (Link)item.Reference);
                }
            }
            else
            {
                var items = new List <FileSystemItem>();
                foreach (ListPageItem item in listMain.SelectedItems)
                {
                    items.Add(item.Reference);
                }

                SelectedMultiple.Invoke(this, directory, items.ToArray());
            }
        }
Exemple #3
0
        // 310 x 350
        protected virtual void RenderDirectoryPanel(Rectangle2D panel, int index, TreeGumpNode node)
        {
            var x = panel.X + 20;
            var y = panel.Y + 20;

            var w = panel.Width - 40;
            var h = panel.Height - 20;

            var xx = x;
            var yy = y;

            var subIndex = 0;

            var xMax = w / 65;
            var yMax = h / 110;

            var max = xMax * yMax;

            var range =
                Enumerable.Empty <FileSystemInfo>()
                .Union(SelectedDirectory.EnumerateDirectories().OrderByNatural(d => d.Name))
                .Union(SelectedDirectory.EnumerateFiles().OrderByNatural(f => f.Name));

            foreach (var info in range.Take(max))
            {
                // 65 x 110
                if (info is DirectoryInfo)
                {
                    var dir = (DirectoryInfo)info;

                    // 56 x 80
                    AddButton(xx, yy, 9810, 9810, b => SelectDirectory(dir));                     // 56 x 50
                    AddHtml(xx, yy + 50, 56, 40, info.Name.WrapUOHtmlCenter(), true, false);      // 56 x 40
                }
                else if (info is FileInfo)
                {
                    var file = (FileInfo)info;

                    // 56 x 80
                    AddButton(xx + 5, yy, 2234, 2234, b => SelectFile(file));                     // 46 x 50
                    AddHtml(xx, yy + 50, 56, 40, info.Name.WrapUOHtmlCenter(), true, false);      // 56 x 40
                }

                if (++subIndex % xMax == 0)
                {
                    xx  = x;
                    yy += 110;
                }
                else
                {
                    xx += 65;
                }
            }
        }
        private void OnNewFolder(object sender, RoutedEventArgs e)
        {
            const string newFolderName = "New Folder";

            SelectedDirectory.DirectoryInfo.CreateSubdirectory(newFolderName);
            SelectedDirectory.IsExpanded = true;
            SelectedDirectory.Refresh();

            var newDir = SelectedDirectory.Directories.First(d => d.Header == newFolderName);

            newDir.IsSelected = true;
            newDir.IsEditing  = true;
        }
        // Searches all files and directories in the directory tree starting at the selected directory for any that match
        // the FileFilter string
        public void GetFilteredFilesFromSelected()
        {
            ContentList.Clear();

            List <UserFile> FilteredFileList = SelectedDirectory.GetFilteredFiles(FileFilter);

            UpdatePerforceStatus(FilteredFileList);
            foreach (UserFile file in SelectedDirectory.GetFilteredFiles(FileFilter))
            {
                file.UpdateFileStatus();
                ContentList.Add(file);
                file.CheckFile(ref _userMessage);
                RaisePropertyChanged("UserMessage");
            }

            if (ContentList != null)
            {
                UserMessage = ContentList.Any(x => x.P4Success == false) ? P4ErrorMessage : UserMessage;
            }
        }
        /// <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); });
        }
Exemple #7
0
 private void _delete(object obj)
 {
     SelectedDirectory.Delete();
     Directories.Remove(SelectedDirectory);
     SelectedDirectory = null;
 }
        static void Main(string[] args)
        {
            int                   selected = 0;
            DirectoryInfo         Root     = new DirectoryInfo(Directory.GetCurrentDirectory() + "\\Home");
            DirectoryInfo         SelectedDirectory;
            List <FileSystemInfo> AvailableItems = new List <FileSystemInfo>();

            SelectedDirectory = Root;

NewDir:
            AvailableItems.Clear();
            AvailableItems.AddRange(SelectedDirectory.GetDirectories());
            AvailableItems.AddRange(SelectedDirectory.GetFiles());



Refresh:
            Console.Clear();
            Console.WriteLine($"Current directory: {SelectedDirectory.FullName}");
            var DefaultBC = Console.BackgroundColor;
            var DefaultFC = Console.ForegroundColor;

            for (var i = 0; i < AvailableItems.Count; i++)
            {
                if (i == selected)
                {
                    Console.BackgroundColor = ConsoleColor.Green;
                    Console.ForegroundColor = ConsoleColor.Black;
                }

                Console.WriteLine(AvailableItems[i].Name);

                Console.BackgroundColor = DefaultBC;
                Console.ForegroundColor = DefaultFC;
            }

ReadKey:

            switch (Console.ReadKey().Key)
            {
            case ConsoleKey.UpArrow: GoUp(); break;

            case ConsoleKey.DownArrow: Godown(); break;

            case ConsoleKey.RightArrow: GoToSelected(); goto NewDir;

            case ConsoleKey.LeftArrow: GoBack(); goto NewDir;

            case ConsoleKey.Enter: GoToSelected(); goto NewDir;

            case ConsoleKey.Backspace: GoBack(); goto NewDir;

            default: goto ReadKey; break;
            }

            goto Refresh;

            Console.ReadLine();

            void GoToSelected()
            {
                if (AvailableItems.Count != 0)
                {
                    SelectedDirectory = (DirectoryInfo)AvailableItems[selected];
                }
                selected = 0;
            }

            void GoBack()
            {
                if (SelectedDirectory.FullName != Root.FullName)
                {
                    SelectedDirectory = SelectedDirectory.Parent;
                }
                selected = 0;
            }

            void GoUp()
            {
                if (selected > 0)
                {
                    selected--;
                }
            }

            void Godown()
            {
                if (selected < AvailableItems.Count - 1)
                {
                    selected++;
                }
            }
        }
 private void OnRefreshFolder(object sender, RoutedEventArgs e)
 {
     SelectedDirectory.Refresh();
     OnRefreshResources(this, default(DependencyPropertyChangedEventArgs));
 }
 private void _sweepStaleMedia(object o)
 {
     SelectedDirectory.SweepStaleMedia();
 }
Exemple #11
0
 private void _addSub(object obj)
 {
     SelectedDirectory = SelectedDirectory.AddSubdirectory();
 }