コード例 #1
0
        private void FindRecentProjectFiles()
        {
            this.RecentProjectFiles.Clear();

            List <string> existingRecentFiles = new List <string>();

            foreach (string recentFile in HydroDesktop.Configuration.Settings.Instance.RecentProjectFiles)
            {
                if (File.Exists(recentFile))
                {
                    if (!existingRecentFiles.Contains(recentFile)) //add to list only if not exists
                    {
                        existingRecentFiles.Add(recentFile);
                    }
                }
            }

            HydroDesktop.Configuration.Settings.Instance.RecentProjectFiles.Clear();
            foreach (string recentFile in existingRecentFiles)
            {
                HydroDesktop.Configuration.Settings.Instance.RecentProjectFiles.Add(recentFile);
                RecentProjectFiles.Add(new ProjectFileInfo(recentFile));
            }

            bsRecentFiles.ResetBindings(false);
        }
コード例 #2
0
ファイル: WelcomeScreen.cs プロジェクト: wz2cool/HydroDesktop
        private void FindRecentProjectFiles()
        {
            this.RecentProjectFiles.Clear();

            List <string> existingRecentFiles = new List <string>();

            foreach (string recentFile in Settings.Instance.RecentProjectFiles)
            {
                if (File.Exists(recentFile))
                {
                    if (!existingRecentFiles.Contains(recentFile)) //add to list only if not exists
                    {
                        existingRecentFiles.Add(recentFile);
                    }
                }
            }

            Settings.Instance.RecentProjectFiles.Clear();
            foreach (string recentFile in existingRecentFiles)
            {
                Settings.Instance.RecentProjectFiles.Add(recentFile);
                RecentProjectFiles.Add(new ProjectFileInfo(recentFile));
            }

            SetupSampleProjects();

            bsRecentFiles.ResetBindings(false);
            lstRecentProjects.SelectedIndex = -1;
        }
コード例 #3
0
ファイル: WelcomeScreen.cs プロジェクト: wz2cool/HydroDesktop
        private void SetupSampleProjects()
        {
            //string[] predefinedSampleProjects = new string[] { "elbe.dspx", "jacobs_well_spring.dspx" };

            string userProjDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "HydroDesktop");

            if (!Directory.Exists(userProjDir))
            {
                try
                {
                    Directory.CreateDirectory(userProjDir);
                }
                catch (Exception ex)
                {
                    Trace.Write("error creating directory " + userProjDir + " " + ex.Message);
                }
            }
            if (!Directory.Exists(userProjDir))
            {
                try
                {
                    userProjDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "HydroDesktop");
                    Directory.CreateDirectory(userProjDir);
                }
                catch (Exception ex)
                {
                    Trace.Write("error creating directory " + userProjDir + " " + ex.Message);
                }
            }
            if (!Directory.Exists(userProjDir))
            {
                try
                {
                    userProjDir = Path.Combine(Path.GetTempPath(), "HydroDesktop");
                    Directory.CreateDirectory(userProjDir);
                }
                catch { }
            }

            if (Directory.Exists(userProjDir))
            {
                //also add the project files from hd_sample_projects folder
                string projDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SampleProjectsDirectory);

                string userSampleProjectDir = Path.Combine(userProjDir, "hydroDesktop_sample_projects");
                if (!Directory.Exists(userSampleProjectDir))
                {
                    foreach (string dirPath in Directory.GetDirectories(projDir, "*", SearchOption.AllDirectories))
                    {
                        Directory.CreateDirectory(dirPath.Replace(projDir, userSampleProjectDir));
                    }

                    //Copy all the files
                    foreach (string newPath in Directory.GetFiles(projDir, "*.*",
                                                                  SearchOption.AllDirectories))
                    {
                        File.Copy(newPath, newPath.Replace(projDir, userSampleProjectDir));
                    }
                }
                if (Directory.Exists(userSampleProjectDir))
                {
                    string[] projFiles = Directory.GetFiles(userSampleProjectDir, "*.dspx", SearchOption.AllDirectories);
                    foreach (string projFile in projFiles)
                    {
                        ProjectFileInfo projFileInfo = new ProjectFileInfo(projFile);
                        if (!Settings.Instance.RecentProjectFiles.Contains(projFile))
                        {
                            Settings.Instance.RecentProjectFiles.Add(projFile);
                            RecentProjectFiles.Add(projFileInfo);
                        }
                    }
                }
            }
        }