コード例 #1
0
 /// <summary>
 /// Loads the project file for use by ProjectManager event listeners
 /// </summary>
 /// <param name="sProjectFile"></param>
 /// <returns></returns>
 public void OpenProject(string sProjectFile)
 {
     LoadedProject = LoadProject(sProjectFile);
     UpdateSettings();
     SetLoadedProjectFile(sProjectFile);
     ProjectOpened?.Invoke(this, new ProjectEventArgs(LoadedProject, ProjectFilePath));
 }
コード例 #2
0
ファイル: ProjectServiceBase.cs プロジェクト: olesar/Altaxo
        /// <summary>
        /// Fires the <see cref="ProjectChanged" /> event. This occurs <b>after</b> the events <see cref="ProjectOpened" />,
        /// <see cref="ProjectClosed" />, <see cref="ProjectRenamed" />, and <see cref="ProjectDirtyChanged" /> event. Usefull if
        /// you not want to subscribe to the above mentioned single events.
        /// </summary>
        protected virtual void OnProjectChanged(ProjectEventArgs e)
        {
            switch (e.ProjectEventKind)
            {
            case ProjectEventKind.ProjectOpening:
                break;

            case ProjectEventKind.ProjectOpened:
                ProjectOpened?.Invoke(this, e);
                break;

            case ProjectEventKind.ProjectClosing:
                break;

            case ProjectEventKind.ProjectClosed:
                ProjectClosed?.Invoke(this, e);
                break;

            case ProjectEventKind.ProjectRenamed:
                ProjectRenamed?.Invoke(this, (ProjectRenamedEventArgs)e);
                break;

            case ProjectEventKind.ProjectDirtyChanged:
                ProjectDirtyChanged?.Invoke(this, e);
                break;

            default:
                break;
            }

            ProjectChanged?.Invoke(this, e);
        }
コード例 #3
0
        public bool OpenProject([Required] string projectName)
        {
            bool result = false;

            try
            {
                if (_uri != null)
                {
                    var project = _availableProjects?
                                  .FirstOrDefault(x => string.CompareOrdinal(projectName, x.Key) == 0);

                    if (project.HasValue)
                    {
                        Project    = project.Value.Key;
                        _projectId = project.Value.Value;

                        ProjectOpened?.Invoke(this, projectName);

                        result = true;
                    }
                }
            }
            catch
            {
                Project    = null;
                _projectId = Guid.Empty;
            }

            return(result);
        }
コード例 #4
0
 internal static void OnProjectOpened(ProjectViewModel project)
 {
     ProjectOpened?.Invoke(typeof(ProjectPadApplication), new ProjectOpenedEventArgs()
     {
         Project = project
     });
 }
コード例 #5
0
        /// <inheritdoc/>
        public ProjectModel CreateNewProject()
        {
            if (Project != null)
            {
                CloseProject();
            }

            Project = new ProjectModel();

            ProjectOpened?.Invoke(this, new EventArgs());

            return(Project);
        }
コード例 #6
0
ファイル: Project.cs プロジェクト: testpulse/Pickle-Studio
        public void Open(string filePath)
        {
            var isFeature = filePath.IsFeature();

            if (isFeature)
            {
                var feature = new Feature(filePath, OnFeatureContentChanged, OnFeatureSaved);
                if (Name == NoProjectName)
                {
                    var existingFeatureIndex = Features.FindIndex(f => f.FilePath == filePath);
                    if (existingFeatureIndex >= 0)
                    {
                        Features[existingFeatureIndex] = feature;
                    }
                    else
                    {
                        Features.Add(feature);
                    }
                    FeatureOpened.Raise(this, this, feature);
                    return;
                }
                else
                {
                    Name     = NoProjectName;
                    FilePath = string.Empty;
                    Features = new List <Feature> {
                        feature
                    };
                }
            }
            else
            {
                Name     = Path.GetFileNameWithoutExtension(filePath);
                FilePath = filePath;
                var project = GetProject(filePath);
                Features = project.Items
                           .Where(i => i.EvaluatedInclude.IsFeature())
                           .Select(i => new Feature(Path.Combine(project.DirectoryPath, i.EvaluatedInclude), OnFeatureContentChanged, OnFeatureSaved))
                           .ToList();
            }
            Command.TestRun.SetEnabled(Name != NoProjectName);
            ProjectOpened.Raise(this, this);
        }
コード例 #7
0
        public void LoadProjectFromDisk(string projectFilePath)
        {
            _projectFilePath = projectFilePath;

            System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(typeof(Project));

            using (StreamReader sr = new StreamReader(_projectFilePath))
            {
                _project = (Project)ser.Deserialize(sr);
            }

            UserDataManager.Instance.AddUsedProject(_project.Id, _projectFilePath, _project.Name);

            ProjectOpened?.Invoke(_project);

            _cmdProcessor = new CommandProcessor();

            _outputService.PushInfo($"Project '{_project.Name}' loaded from:");
            _outputService.PushInfo(_projectFilePath);
        }
コード例 #8
0
        /// <inheritdoc/>
        public ProjectModel OpenProject(string filePath)
        {
            if (Project != null)
            {
                CloseProject();
            }

            using (FileStream fs = new FileStream(filePath, FileMode.Open))
            {
                using XmlDictionaryReader xmlReader = XmlDictionaryReader.CreateTextReader(fs, new XmlDictionaryReaderQuotas());
                DataContractSerializer serializer = new DataContractSerializer(typeof(ProjectModel));
                Project = (ProjectModel)serializer.ReadObject(xmlReader, true);

                // The absolute path of the file opened in the FileStream.
                Project.ProjectFilePath = fs.Name;
            }

            Project.IsNew      = false;
            Project.HasChanges = false;

            if (Project.VideoProcessingOptions == null)
            {
                Project.VideoProcessingOptions = new VideoProcessingOptionsModel();
            }

            if (Project.Cropping == null)
            {
                Project.Cropping = new CroppingSubProjectModel();
            }

            if (Project.Masking == null)
            {
                Project.Masking = new MaskingSubProjectModel();
            }

            ProjectOpened?.Invoke(this, new EventArgs());

            return(Project);
        }
コード例 #9
0
ファイル: ProjectService.cs プロジェクト: megahirt/cog
 private void OnProjectOpened(EventArgs e)
 {
     ProjectOpened?.Invoke(this, e);
 }