Ejemplo n.º 1
0
        private void recursiveLearnFromFile(FileSystemObjectInfo info, bool recurse = false)
        {
            if ((info.FileSystemInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
            {
                var files = Directory.EnumerateFiles(info.FileSystemInfo.FullName, "*.*", SearchOption.TopDirectoryOnly)
                            .Where(s => s.EndsWith(".txt", StringComparison.OrdinalIgnoreCase));

                foreach (string path in files)
                {
                    FileInfo             fi   = new FileInfo(path);
                    FileSystemObjectInfo fsoi = new FileSystemObjectInfo(fi);
                    recursiveLearnFromFile(fsoi);
                }
            }
            else
            {
                try
                {
                    using (StreamReader sr = new StreamReader(info.FileSystemInfo.FullName))
                    {
                        string line = sr.ReadToEnd();
                        Markov.Train(Context, line);
                        Log("Batched file training complete");
                    }
                }
                catch (IOException ex)
                {
                    Log("Error: The file could not be read:\n" + ex.Message);
                }
            }
        }
Ejemplo n.º 2
0
        public MainViewModel()
        {
            Message         = "Program has been started.";
            CanStartProject = true;
            FileExtension   = ".wtf";
            OperandLenght   = 9;
            OperationLenght = 5;
            using (File.Open(Directory.GetCurrentDirectory() + "\\Project.wtf", FileMode.OpenOrCreate))


                CurrentFileInfo = new FileInfo(Directory.GetCurrentDirectory() + "\\Project.wtf");
            Commands = new ObservableCollection <Command>(ReadFromBinaryFile(CurrentFileInfo.FullName));
            if (Commands.Count > 0)
            {
                CurrentCommand = Commands.First();
            }
            BreakPoints = new ObservableCollection <int>();

            var curDir = new FileSystemObjectInfo(new DirectoryInfo(Directory.GetCurrentDirectory()));

            CurrentDirectories = new ObservableCollection <FileSystemObjectInfo>()
            {
                curDir
            };

            RaisePropertyChanged("Commands");
        }
Ejemplo n.º 3
0
        public void updateFolder(ObservableCollection <FileSystemObjectInfo> WorkFolder)
        {
            WorkFolder.Clear();
            DirectoryInfo drives = new DirectoryInfo(OpenedFolder);
            var           newDir = new FileSystemObjectInfo(drives);

            WorkFolder.Insert(WorkFolder.Count, newDir);
        }
Ejemplo n.º 4
0
        public void newFolder(ObservableCollection <FileSystemObjectInfo> WorkFolder, string path)
        {
            WorkFolder.Clear();
            OpenedFolder = path;
            DirectoryInfo drives = new DirectoryInfo(path);
            var           newDir = new FileSystemObjectInfo(drives);

            WorkFolder.Insert(WorkFolder.Count, newDir);
        }
Ejemplo n.º 5
0
 private void btnSearchSong_Click(object sender, RoutedEventArgs e)
 {
     if (!(TreeViewNavigate.SelectedItem is null))
     {
         FileSystemObjectInfo path     = (FileSystemObjectInfo)TreeViewNavigate.SelectedItem;
         ListView             allFiles = new ListView();
         allFiles = listAllFiles(allFiles, path.FileSystemInfo.FullName, "mp3", true);
         ListViewMusic.ItemsSource = allFiles.Items;
     }
 }
Ejemplo n.º 6
0
        private void TreeViewNavigate_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            FileSystemObjectInfo item = (FileSystemObjectInfo)TreeViewNavigate.SelectedItem;

            if ((item != null))
            {
                string path = item.FileSystemInfo.FullName;
                LoadMusic(path);
            }
        }
Ejemplo n.º 7
0
        public int loadXmlPre(FileSystemObjectInfo TreeItem, ObservableCollection <EditableFile> Items)
        {
            //var TreeItem = obj as FileSystemObjectInfo;
            // EditableFile loadXml = new EditableFile();

            string file = TreeItem.FileSystemInfo.FullName;

            return(LoadFilePreview(file, Items));
            //Transform();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Работа с проводником
        /// </summary>
        #region folder

        private void LoadFolder(string file, ObservableCollection <FileSystemObjectInfo> WorkFolder)
        {
            WorkFolder.Clear();
            OpenedFolder = file;
            DirectoryInfo drives = new DirectoryInfo(file);
            var           newDir = new FileSystemObjectInfo(drives);

            WorkFolder.Insert(WorkFolder.Count, newDir);
            // WorkspaceVisible = true;
            // TreeVisible = true;
        }
Ejemplo n.º 9
0
        public void InitializeFileSystemObjects()
        {
            var drives = DriveInfo.GetDrives();

            DriveInfo.GetDrives().ToList().ForEach(drive =>
            {
                var fileSystemObject            = new FileSystemObjectInfo(drive);
                fileSystemObject.BeforeExplore += FileSystemObject_BeforeExplore;
                fileSystemObject.AfterExplore  += FileSystemObject_AfterExplore;
                TreeViewNavigate.Items.Add(fileSystemObject);
            });
        }
Ejemplo n.º 10
0
        private void InitializeFileSystemObjects()
        {
            var drives = DriveInfo.GetDrives();

            DriveInfo.GetDrives().Where(drive => drive.IsReady == true).ToList().ForEach(drive =>
            {
                var fileSystemObject            = new FileSystemObjectInfo(drive);
                fileSystemObject.BeforeExplore += FileSystemObject_BeforeExplore;
                fileSystemObject.AfterExplore  += FileSystemObject_AfterExplore;

                treeView.Items.Add(fileSystemObject);
            });
        }
Ejemplo n.º 11
0
        private void BuildRootPath()
        {
            if (!Directory.Exists(GlobalData.Instance.LuaRootPath))
            {
                return;
            }
            tvLua.Items.Clear();
            var fileSystemObject = new FileSystemObjectInfo(new DirectoryInfo(GlobalData.Instance.LuaRootPath));

            fileSystemObject.BeforeExplore += FileSystemObject_BeforeExplore;
            fileSystemObject.AfterExplore  += FileSystemObject_AfterExplore;
            tvLua.Items.Add(fileSystemObject);
            fileSystemObject.IsExpanded = true;
        }
Ejemplo n.º 12
0
    protected void Page_Init(object sender, EventArgs e)
    {
        IEnumerable <FileSystemObjectInfo> foldersToShow = new FileSystemObjectInfo[] {
            new FileSystemObjectInfo()
            {
                PrivateName = "Folder 1", PublicName = "First Folder"
            },
            new FileSystemObjectInfo()
            {
                PrivateName = "Folder 3", PublicName = "Third Folder"
            },
            new FileSystemObjectInfo()
            {
                PrivateName = "Folder 1\\Subfolder 1-1", PublicName = "First Folder\\First Sub"
            },
        };
        IEnumerable <FileSystemObjectInfo> filesToShow = new FileSystemObjectInfo[] {
            new FileSystemObjectInfo()
            {
                PrivateName = "Folder 1\\File 1.txt", PublicName = "First Folder\\First File.txt"
            },
            new FileSystemObjectInfo()
            {
                PrivateName = "Folder 1\\File 2.txt", PublicName = "First Folder\\Second File.txt"
            },
            new FileSystemObjectInfo()
            {
                PrivateName = "Folder 1\\File 3.txt", PublicName = "First Folder\\Third File.txt"
            },
            new FileSystemObjectInfo()
            {
                PrivateName = "Folder 1\\Subfolder 1-1\\Doc 1.txt", PublicName = "First Folder\\First Sub\\First Doc.txt"
            },
            new FileSystemObjectInfo()
            {
                PrivateName = "Folder 3\\Article 1.txt", PublicName = "Third Folder\\First Article.txt"
            },
            new FileSystemObjectInfo()
            {
                PrivateName = "Folder 3\\Article 2.txt", PublicName = "Third Folder\\Second Article.txt"
            },
            new FileSystemObjectInfo()
            {
                PrivateName = "Folder 3\\Article 3.txt", PublicName = "Third Folder\\Third Article.txt"
            },
        };

        FileManager.CustomFileSystemProvider = new CustomPhysicalFileSystemProvider("~/Files/Root", foldersToShow, filesToShow);
    }
Ejemplo n.º 13
0
        private void InitializeFileSystemObjects()
        {
            var drives = DriveInfo.GetDrives();

            drives.ToList().ForEach(drive =>
            {
                var fileSystemObject            = new FileSystemObjectInfo(drive);
                fileSystemObject.BeforeExplore += FileSystemObject_BeforeExplore;
                fileSystemObject.AfterExplore  += FileSystemObject_AfterExplore;
                FilesSource.Add(fileSystemObject);
            });

            PreSelect(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
            //SelectedFileObject =
        }
Ejemplo n.º 14
0
        private void InitializeFileSystemObjects()
        {
            var drives = DriveInfo.GetDrives();

            DriveInfo
            .GetDrives()
            .ToList()
            .ForEach(drive =>
            {
                var fileSystemObject            = new FileSystemObjectInfo(drive, ref filelist);
                fileSystemObject.BeforeExplore += FileSystemObject_BeforeExplore;
                fileSystemObject.AfterExplore  += FileSystemObject_AfterExplore;
                treeView.Items.Add(fileSystemObject);
            });
            PreSelect(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// init for the treeview file explorer control
        /// </summary>
        private void InitializeFileSystemObjects()
        {
            treeView.SelectedItemChanged         += TreeView_SelectedItemChanged;
            BatchListBox.SelectionChanged        += BatchListBox_SelectedItemChanged;
            Context.BatchFiles.CollectionChanged += BatchFiles_CollectionChanged;

            var drives = DriveInfo.GetDrives();

            DriveInfo.GetDrives().ToList().ForEach(drive =>
            {
                var fileSystemObject            = new FileSystemObjectInfo(drive);
                fileSystemObject.BeforeExplore += FileSystemObject_BeforeExplore;
                fileSystemObject.AfterExplore  += FileSystemObject_AfterExplore;
                treeView.Items.Add(fileSystemObject);
            });
        }
Ejemplo n.º 16
0
        public void newFolder(ObservableCollection <FileSystemObjectInfo> WorkFolder)
        {
            var openFolder = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog();

            if (openFolder.ShowDialog().GetValueOrDefault())
            {
                WorkFolder.Clear();
                OpenedFolder = openFolder.SelectedPath;
                DirectoryInfo drives = new DirectoryInfo(openFolder.SelectedPath);
                var           newDir = new FileSystemObjectInfo(drives);
                WorkFolder.Insert(WorkFolder.Count, newDir);

                //WorkspaceVisible = true;
                //TreeVisible = true;
            }
        }
Ejemplo n.º 17
0
 private void InitialiseTreeFileExplorer()
 {
     try
     {
         DriveInfo[] drives = DriveInfo.GetDrives();
         DriveInfo.GetDrives().ToList().ForEach(drive =>
         {
             FileSystemObjectInfo fileSystemObject = new FileSystemObjectInfo(drive);
             fileSystemObject.BeforeExplore       += FileSystemObject_BeforeExplore;
             fileSystemObject.AfterExplore        += FileSystemObject_AfterExplore;
             treeView.Items.Add(fileSystemObject);
         });
     }
     catch (Exception e)
     {
         MessageBox.Show($"Failed to initialise File Explorer. Error: {e.Message}");
     }
 }
Ejemplo n.º 18
0
        // File tree methods (and cursor type methods)
        private void InitializeFileSystemObjects()
        {
            // Get path to default folder (set to documents by default)
            var docspath = defaultFolder;
            // Get folder info for default folder
            var docsfolderinfo = new DirectoryInfo(docspath);

            // Create file system object with default folder info (have to feed file system object into items.add)
            var fileSystemObject = new FileSystemObjectInfo(docsfolderinfo);


            // Changing cursor to indicate loading (Seen mostly when opening additional files)
            fileSystemObject.BeforeExplore += FileSystemObject_BeforeExplore;
            fileSystemObject.AfterExplore  += FileSystemObject_AfterExplore;

            // After loading, add file system to tree view
            treeView.Items.Add(fileSystemObject);
        }
Ejemplo n.º 19
0
 private void PreSelect(FileSystemObjectInfo fileSystemObjectInfo,
                        string path)
 {
     foreach (var childFileSystemObjectInfo in fileSystemObjectInfo.Children)
     {
         var isParentPath = IsParentPath(path, childFileSystemObjectInfo.FileSystemInfo.FullName);
         if (isParentPath)
         {
             if (string.Equals(childFileSystemObjectInfo.FileSystemInfo.FullName, path))
             {
                 /* We found the item for pre-selection */
             }
             else
             {
                 childFileSystemObjectInfo.IsExpanded = true;
                 PreSelect(childFileSystemObjectInfo, path);
             }
         }
     }
 }
Ejemplo n.º 20
0
        private void InitializeFileSystemObjects()
        {
            DriveInfo
            .GetDrives()
            .ToList()
            .ForEach(drive =>
            {
                var fileSystemObject = new FileSystemObjectInfo(drive);

                fileSystemObject.BeforeExplore += FileSystemObject_BeforeExplore;
                fileSystemObject.AfterExplore  += FileSystemObject_AfterExplore;

                _ = FoldersControl.Items.Add(fileSystemObject);
            });

            //PreSelect(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
            if (!string.IsNullOrEmpty(_preSelectPath))
            {
                ViewManager.PreSelect(FoldersControl, _preSelectPath);
            }
        }
Ejemplo n.º 21
0
        public MainWindow()
        {
            InitializeComponent();

            // Get all drives
            var drives = DriveInfo.GetDrives();

            // Iterate each drive
            foreach (var drive in drives)
            {
                // Create an FSO
                var fileSystemObject = new FileSystemObjectInfo(drive);

                // Handle the events
                fileSystemObject.BeforeExplore += FileSystemObject_BeforeExplore;
                fileSystemObject.AfterExplore  += FileSystemObject_AfterExplore;

                // Add the item
                this.treeView.Items.Add(fileSystemObject);
            }
        }
Ejemplo n.º 22
0
        public static void PreSelect(FileSystemObjectInfo info, string path)
        {
            foreach (var childInfo in info.Children)
            {
                if (path.StartsWith(childInfo.FileSystemInfo.FullName))
                {
                    if (childInfo.FileSystemInfo.FullName.Equals(path))
                    {
                        _found = true;
                        return; /* We found the item for pre-selection */
                    }

                    childInfo.IsExpanded = true;
                    PreSelect(childInfo, path);

                    if (_found)
                    {
                        return;
                    }
                }
            }
        }
Ejemplo n.º 23
0
 private void PreSelect(FileSystemObjectInfo fileSystemObjectInfo,
                        string path)
 {
     foreach (var childFileSystemObjectInfo in fileSystemObjectInfo.Children)
     {
         var isParentPath = IsParentPath(path, childFileSystemObjectInfo.FileSystemInfo.FullName);
         if (isParentPath)
         {
             if (string.Equals(childFileSystemObjectInfo.FileSystemInfo.FullName, path))
             {
                 childFileSystemObjectInfo.IsSelected = true;
                 selectedFileObject = childFileSystemObjectInfo;
                 UpdateDetailFiles();
             }
             else
             {
                 childFileSystemObjectInfo.IsExpanded = true;
                 PreSelect(childFileSystemObjectInfo, path);
             }
         }
     }
 }
Ejemplo n.º 24
0
        private void InitializeFileSystemObjects()
        {
            var drives = DriveInfo.GetDrives();

            DriveInfo
            .GetDrives()
            .ToList()
            .ForEach(drive =>
            {
                var fileSystemObject            = new FileSystemObjectInfo(drive);
                fileSystemObject.BeforeExplore += FileSystemObject_BeforeExplore;
                fileSystemObject.AfterExplore  += FileSystemObject_AfterExplore;
                //fileSystemObject.DeleteEvent += FileSystemObject_Delete;
                treeView.Items.Add(fileSystemObject);
            });

            foreach (var drive in drives)
            {
                if (drive.DriveType != DriveType.Fixed)
                {
                    continue;
                }
#if false
                FileSystemWatcher fsWatcher = new FileSystemWatcher
                {
                    Path         = drive.RootDirectory.FullName,
                    Filter       = "*.*",
                    NotifyFilter = NotifyFilters.FileName |
                                   NotifyFilters.DirectoryName,
                    IncludeSubdirectories = true
                };
                fsWatcher.Created            += new FileSystemEventHandler(OnChanged);
                fsWatcher.Deleted            += new FileSystemEventHandler(OnChanged);
                fsWatcher.EnableRaisingEvents = true;
                _fsWatchers.Add(fsWatcher);
#endif
            }
        }
Ejemplo n.º 25
0
        // Triggers from xaml right click context menu on file tree -> when user selects "open new project folder"
        private void Pfolder_open(object sender, RoutedEventArgs e)
        {
            swf.FolderBrowserDialog dlg    = new swf.FolderBrowserDialog();
            swf.DialogResult        result = dlg.ShowDialog();
            dlg.RootFolder = Environment.SpecialFolder.MyDocuments;

            if (result == swf.DialogResult.OK)             // Only try to add project folder if user hit ok and not cancel
            {
                var pfolderpath = dlg.SelectedPath;        // Store file path for folder user selected

                // Take given file path and get folder info to be added to file tree
                var pfolderinfo = new DirectoryInfo(pfolderpath);

                // Create file system object with the directory info
                var fileSystemObject = new FileSystemObjectInfo(pfolderinfo);

                // Changing cursor to indicate loading (Seen mostly when opening additional files)
                fileSystemObject.BeforeExplore += FileSystemObject_BeforeExplore;
                fileSystemObject.AfterExplore  += FileSystemObject_AfterExplore;

                // After loading, add file system to tree view
                treeView.Items.Add(fileSystemObject);
            }
        }
Ejemplo n.º 26
0
 private void MyTreeView_SelectedItemChanged(Object sender, RoutedPropertyChangedEventArgs <Object> e)
 {
     this.SelectedItem = base.SelectedItem as FileSystemObjectInfo;
 }
Ejemplo n.º 27
0
 private void OnTreeItemSelectedChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
 {
     _selectedNode = (sender as TreeView).SelectedItem as FileSystemObjectInfo;
     CurrentPath   = _selectedNode.FileSystemInfo.FullName;
 }
Ejemplo n.º 28
0
        private void ActivateSearch(string searchtxt)
        {
            Cursor = Cursors.Wait;             // Set loading cursor before everything begins

            searchView.Items.Clear();          // Clear search in case you didnt empty the text box (which clears) before searching again (?)

            foreach (MyTabItem t in tabItems)
            {
                t.Content.dehighlightSections();
            }
            treeView.Visibility   = Visibility.Hidden;                  // Hide project folders
            searchView.Visibility = Visibility.Visible;                 // Show search files
            Image i = new Image();

            i.Source              = new BitmapImage(new Uri(@"close2.png", UriKind.Relative));
            i.Name                = "img2";
            i.Height              = 15;
            i.Width               = 15;
            i.Margin              = new Thickness(0);
            i.MouseUp            += I_MouseUp;
            i.HorizontalAlignment = HorizontalAlignment.Right;
            i.Visibility          = Visibility.Visible;
            txtSearchBG.Children.Add(i);



            // Set variables for priority search list. Priority is given to titles matching search text then number of times file content has a match with the search text
            bool matchfound = false;
            //SortedDictionary<int, string> filemap = new SortedDictionary<int, string>(); // Create map-like object to track list order of files
            //List<Tuple<int, string>> filemap = new List<Tuple<int, string>>();

            var filemap = new List <Tuple <int, string> >();

            foreach (FileSystemObjectInfo Pdirectory in treeView.Items)             // For every project folder added to tree view
            {
                // Debug.WriteLine(Pdirectory.FileSystemInfo.ToString()); // Console printing of directories (paths) in treeview, delete later

                string[] files = System.IO.Directory.GetFiles(Pdirectory.FileSystemInfo.ToString(), "*.noto");

                foreach (string notofile in files)                 // for each located noto file (notofile = file path string)
                {
                    string nototext = LoadSearchFiles(notofile);   // Load the file (XamlPackage) to get its text

                    // Get file name by finding text after the last '\'
                    string[] splitnotopath = notofile.Split('\\');                      // Split file path by '\'
                    string   notofilename  = (splitnotopath[splitnotopath.Length - 1]); // Filename is everything after the last '\' (last element of new array)
                    notofilename = notofilename.Substring(0, notofilename.Length - 5);  // Remove the file extension (i.e. remove last 5 characters: '.noto')

                    if (notofilename.Contains(searchtxt))                               // If file name (TITLE) contains searched text (prioritises matched titles)
                    {
                        matchfound = true;

                        filemap.Add(new Tuple <int, string>(99999, notofile));
                    }
                    else if (nototext.Contains(searchtxt))                     // If the text in a file contains the user searched text
                    {
                        matchfound  = true;
                        matchedText = searchtxt;

                        int matchcount = Regex.Matches(nototext, searchtxt).Count;

                        filemap.Add(new Tuple <int, string>(matchcount, notofile));                        // Give content matched files priority equal to number of matches found
                    }
                }

                if (matchfound)
                {
                    // Sort filemap by key (Chronologically)
                    var orderedmap = filemap.OrderByDescending(t => t.Item1).ToList();

                    foreach (var orderedfile in orderedmap)
                    {
                        // Get file info
                        var notofileinfo = new FileInfo(orderedfile.Item2);

                        // Create file system object with file info (have to feed file system object into items.add)
                        var fileSystemObject = new FileSystemObjectInfo(notofileinfo);

                        // Add file system object to the search results tree view
                        searchView.Items.Add(fileSystemObject);
                    }
                }
            }
            highlightText();
            Cursor = Cursors.Arrow;             // Set normal cursor once files loaded and finished
        }