Esempio n. 1
0
        public void Load(string FilePath, IProgressEx Progress = null)
        {
            _hasChanges = false;

            _projectFilePath = FilePath;

            ProjectBasePath = Path.GetDirectoryName(_projectFilePath);

            MainLogger.Log(String.Format("Loading Project File '{0}'...", Path.GetFileName(_projectFilePath)), 0,
                           LogMessageType.Information, LogReceiver.Console | LogReceiver.StatusBar);

            XDocument xDoc = XDocument.Load(FilePath);

            // Deserializing the project from XML document
            this.Xml = xDoc.Element("Project");

            // Base directory where the components are stored
            ComponentSet.BaseDir = Path.Combine(ApplicationBasePath, _COMPONENTS_DIR);

            // Optional project directory where the components are stored
            ComponentSet.ProjectDir = Path.Combine(ProjectBasePath, _COMPONENTS_DIR);

            ComponentSet.VerboseLoad = IsVerboseLoad();

            // Loading components
            ComponentSet.Load(Progress);

            CheckComponents();

            // If views are defined, load them
            if (ViewSet != null)
            {
                ViewSet.VerboseLoad    = ComponentSet.VerboseLoad;
                ViewSet.Components     = ComponentSet;
                ViewSet.BaseDir        = Path.Combine(ApplicationBasePath, _VIEWS_DIR);
                ViewSet.ProjectBaseDir = Path.Combine(ProjectBasePath, _VIEWS_DIR);
                ViewSet.Load(Progress);
            }

            if (ComponentSet.HasExceptions || ViewSet.HasExceptions)
            {
                MainLogger.Log(string.Format("Project '{0}' has loaded with problems!", Properties["Title"]), 0,
                               LogMessageType.Exclamation, LogReceiver.Console | LogReceiver.StatusBar | LogReceiver.MessageBox);
            }
            else
            {
                MainLogger.Log(string.Format("Project '{0}' loaded successfully!", Properties["Title"]), 0,
                               LogMessageType.Success, LogReceiver.Console | LogReceiver.StatusBar);
            }

            _target = (ITarget)ComponentSet["Target"].Plugin;

            _loaded = true;
        }