Project class.
Contains a Project instance, represented by a path, a name and several applied methods
Наследование: FileObject
Пример #1
0
        public static Boolean DeleteProject(Project project)
        {
            if (project != null)
            {
                string serializeFolderPath = Session.CurrentSession.ApplicationFolder + "\\" + Session.CurrentSession.Workspace.Name + "\\" + Session.CurrentSession.CurrentProject.Name;

                Directory.Delete(project.ParentPath, true);
                Session.CurrentSession.Workspace.Projects.Remove(project);

                if (Directory.Exists(serializeFolderPath))
                    Directory.Delete(serializeFolderPath, true);

                if (Session.CurrentSession.CurrentProject.Name == project.Name)
                {
                    Session.CurrentSession.ModelVisual.Children.Clear();
                    Session.CurrentSession.ModelVisual.Content = null;
                }

                //TODO: Check Remove project from current project
                Session.CurrentSession.Workspace.CurrentProject = null;
                Session.CurrentSession.CurrentProject = null;

                return true;
            }
            return false;
        }
Пример #2
0
        public static Project CreateProject(string path, string name)
        {
            if (!CheckPathIntegrity(path))
            {
                throw new DirectoryNotFoundException("Project path doesn't exist");
            }

            if (name == "")
            {
                throw new ArgumentException("Please enter a name for your project");
            }

            if (!FolderIsAvailable(Path.Combine(path, name)))
            {
                throw new ArgumentException("Project already exists");
            } 

            if (!CreateProjectWorkspace(path, name))
            {
                throw new ArgumentException("Project workspace already exists");
            }

            if (!WriteProjectConfigurationFile(path, name))
            {
                throw new ArgumentException("Project configuration file couldn't be created");
            }

            Project project = new Project(Path.Combine(path, name, name + ".mckp"));

            return project;
        }
Пример #3
0
        private Session()
        {
            applicationFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), SessionConstants.ApplicationFolderName);
            if (!Directory.Exists(applicationFolder))
                CreateApplicationFolder();

            systemPreferences = new SystemPreferences(Path.Combine(applicationFolder, SessionConstants.SystemPreferencesFolderName));
            applicationFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            LoadSystemPreferences();
            workspace = new Workspace(systemPreferences.GetSettingValue("Software", "Workspace path"));
            currentProject = null;
            capture = new Capture();
            viewport = null;
        }
        public ProjectPreferencesGridViewModel()
        {
            Session session = Session.CurrentSession;

            if (session.IsProjectInitialized() && session.CurrentProject.HasPreferences())
            {
                selectedProject = session.CurrentProject;
                Preferences preferences = selectedProject.Preferences;

                if (preferences != null && preferences.Settings == null || preferences.Settings.Count == 0)
                    preferences.LoadDefaultPreferences();
                selectedSettings = preferences.Settings[0];
            }
            else if (session.IsWorkspaceInitialized() && session.Workspace.IsWorkspaceValid() && session.Workspace.HasProjects())
                selectedProject = session.Workspace.Projects[0];
        }
Пример #5
0
        public Workspace(String path)
            : base(path)
        {
            if (!IsInitialized)
            {
                CreateDefaultWorkspace();
                currentProject = null;
                IsInitialized = true;

                // The Workspace couldn't be created after the initialization : the application is shut down.
                if (!IsWorkspaceValid())
                    Session.SessionFatalError(Session.ResourceManager.GetString("WorkspaceCreationFailure"), new ArgumentNullException());
            }
            else
            {
                try
                {
                    workspaceProjectsPath = System.IO.Path.Combine(Path, WorkspaceConstants.ProjectsFolderName);
                    workspaceConfigurationFilePath = System.IO.Path.Combine(Path, WorkspaceConstants.ConfigurationFileName);
                }
                catch (IOException e)
                {
                    Session.SessionFatalError(Session.ResourceManager.GetString("WorkspaceCreationFailure"), e);
                }
                catch (ArgumentException e)
                {
                    Session.SessionFatalError(Session.ResourceManager.GetString("WorkspaceCreationFailure"), e);
                }

                if (!IsWorkspaceValid())
                {
                    System.Windows.MessageBox.Show("Workspace at " + Path + " is not valid.\nCreating default Workspace at " + FallbackPath);
                    CreateDefaultWorkspace();
                }
                else
                    projects = new ObservableCollection<Project>();

                LoadProjects();
                currentProject = GetLastProject();
            }
        }
Пример #6
0
 public void AddProject(Project project)
 {
     if (project != null)
     {
         if (Projects == null)
             Projects = new ObservableCollection<Project>();
         Projects.Add(project);
     }
 }
Пример #7
0
 public void LoadProject(Project project)
 {
     if (project != null && project.IsInitialized)
         CurrentProject = project;
 }