Пример #1
0
        private void WalkDirectoryTree(System.IO.DirectoryInfo root, SampleFileProperty rootProperty)
        {
            try
            {
                // First try to get all the sub-directories before the files themselves.
                System.IO.DirectoryInfo[] directories = root.GetDirectories();
                if (null != directories && (directories.Length > 0))
                {
                    foreach (System.IO.DirectoryInfo directory in directories)
                    {
                        // Resursive call for each subdirectory.
                        SampleFileProperty subProperty = new SampleFileProperty(directory.Name, directory.FullName);
                        WalkDirectoryTree(directory, subProperty);
                        rootProperty.AddChildProperty(subProperty);
                    }
                }

                // Secondly, process all the files directly under this folder
                System.IO.FileInfo[] scriptFiles = null;
                scriptFiles = root.GetFiles("*.ds", System.IO.SearchOption.TopDirectoryOnly);

                if (null != scriptFiles && (scriptFiles.Length > 0))
                {
                    foreach (System.IO.FileInfo file in scriptFiles)
                    {
                        // Add each file under the root directory property list.
                        rootProperty.AddChildProperty(new SampleFileProperty(file.Name, file.FullName));
                    }
                }
            }
            catch (Exception)
            {
                // Perhaps some permission problems?
            }
        }
Пример #2
0
        public void AddChildProperty(SampleFileProperty childProperty)
        {
            if (null == childProperties)
                childProperties = new ObservableCollection<SampleFileProperty>();

            childProperties.Add(childProperty);
        }
Пример #3
0
        public void AddChildProperty(SampleFileProperty childProperty)
        {
            if (null == childProperties)
            {
                childProperties = new ObservableCollection <SampleFileProperty>();
            }

            childProperties.Add(childProperty);
        }
Пример #4
0
        public StartUpScreen()
        {
            InitializeComponent();
            recentFileList.AddRange(TextEditorControl.Instance.TextCore.Data.RecentFiles);
            recentFileList.Reverse();
            recentFileList.RemoveAll(item => !File.Exists(item.FilePath));
            lstRecentFiles.ItemsSource = recentFileList;
            lstRecentFiles.Items.Refresh();

            string executingAssemblyPathName = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string rootModuleDirectory       = System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(executingAssemblyPathName));
            string fullPathName = System.IO.Path.Combine(rootModuleDirectory, "Resources", "Samples");
            string root         = fullPathName;

            SampleFileProperty rootProperty = new SampleFileProperty("Samples", "Path");

            WalkDirectoryTree(new System.IO.DirectoryInfo(root), rootProperty);

            sampleFiles = new ObservableCollection <SampleFileProperty>();
            sampleFiles.Add(rootProperty);
            InternalTreeView.ItemsSource = sampleFiles;
            this.Focus();
        }
Пример #5
0
        public StartUpScreen()
        {
            InitializeComponent();
            recentFileList.AddRange(TextEditorControl.Instance.TextCore.Data.RecentFiles);
            recentFileList.Reverse();
            recentFileList.RemoveAll(item => !File.Exists(item.FilePath));
            lstRecentFiles.ItemsSource = recentFileList;
            lstRecentFiles.Items.Refresh();

            string executingAssemblyPathName = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string rootModuleDirectory = System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(executingAssemblyPathName));
            string fullPathName = System.IO.Path.Combine(rootModuleDirectory, "Resources", "Samples");
            string root = fullPathName;

            SampleFileProperty rootProperty = new SampleFileProperty("Samples", "Path");
            WalkDirectoryTree(new System.IO.DirectoryInfo(root), rootProperty);

            sampleFiles = new ObservableCollection<SampleFileProperty>();
            sampleFiles.Add(rootProperty);
            InternalTreeView.ItemsSource = sampleFiles;
            this.Focus();
        }
Пример #6
0
        private void WalkDirectoryTree(System.IO.DirectoryInfo root, SampleFileProperty rootProperty)
        {
            try
            {
                // First try to get all the sub-directories before the files themselves.
                System.IO.DirectoryInfo[] directories = root.GetDirectories();
                if (null != directories && (directories.Length > 0))
                {
                    foreach (System.IO.DirectoryInfo directory in directories)
                    {
                        // Resursive call for each subdirectory.
                        SampleFileProperty subProperty = new SampleFileProperty(directory.Name, directory.FullName);
                        WalkDirectoryTree(directory, subProperty);
                        rootProperty.AddChildProperty(subProperty);
                    }
                }

                // Secondly, process all the files directly under this folder
                System.IO.FileInfo[] scriptFiles = null;
                scriptFiles = root.GetFiles("*.ds", System.IO.SearchOption.TopDirectoryOnly);

                if (null != scriptFiles && (scriptFiles.Length > 0))
                {
                    foreach (System.IO.FileInfo file in scriptFiles)
                    {
                        // Add each file under the root directory property list.
                        rootProperty.AddChildProperty(new SampleFileProperty(file.Name, file.FullName));
                    }
                }
            }
            catch (Exception)
            {
                // Perhaps some permission problems?
            }
        }