Exemple #1
0
        /// <summary>
        ///     Get a guid from a specific path, internally this first calls GetDefinitionFromPath
        /// </summary>
        /// <param name="path">The path from which to get the guid</param>
        /// <returns>The custom node info object - null if we failed</returns>
        public static CustomNodeInfo GetHeaderFromPath(string path)
        {
            string name, category, description;
            Guid   id;

            if (CustomNodeManager.GetHeaderFromPath(path, out id, out name, out category, out description))
            {
                return(new CustomNodeInfo(id, Path.GetFileNameWithoutExtension(path), category, description, path));
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
        /// <summary>
        ///     Class constructor
        /// </summary>
        public DynamoController(ExecutionEnvironment env, Type viewModelType, string context)
        {
            dynSettings.Controller = this;

            this.Context = context;

            //create the view model to which the main window will bind
            //the DynamoModel is created therein
            this.DynamoViewModel = (DynamoViewModel)Activator.CreateInstance(viewModelType,new object[]{this});

            // custom node loader
            string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string pluginsPath = Path.Combine(directory, "definitions");

            CustomNodeManager = new CustomNodeManager(pluginsPath);

            SearchViewModel = new SearchViewModel();
            PackageManagerClient = new PackageManagerClient();
            dynSettings.PackageManagerClient = PackageManagerClient;
            PublishPackageViewModel = new PublishPackageViewModel(PackageManagerClient);

            dynSettings.PackageLoader = new PackageLoader();

            dynSettings.PackageLoader.DoCachedPackageUninstalls();
            dynSettings.PackageLoader.LoadPackages();

            FSchemeEnvironment = env;

            DynamoViewModel.Model.CurrentSpace.X = DynamoView.CANVAS_OFFSET_X;
            DynamoViewModel.Model.CurrentSpace.Y = DynamoView.CANVAS_OFFSET_Y;

            dynSettings.Controller.DynamoViewModel.Log(String.Format(
                "Dynamo -- Build {0}",
                Assembly.GetExecutingAssembly().GetName().Version));

            DynamoLoader.ClearCachedAssemblies();
            DynamoLoader.LoadBuiltinTypes();

            //run tests
            if (FScheme.RunTests(dynSettings.Controller.DynamoViewModel.Log))
            {
                dynSettings.Controller.DynamoViewModel.Log("All Tests Passed. Core library loaded OK.");
            }

            NodeSubmittedForRendering += new EventHandler(Controller_NodeSubmittedForRendering);
            NodeRemovedFromRendering += new EventHandler(Controller_NodeRemovedFromRendering);
        }
 public void UpdateCustomNodeManager(CustomNodeManager customNodeManager)
 {
     customNodeManager.SetNodeInfo(new CustomNodeInfo(   FunctionId,
                                                         WorkspaceModel.Name,
                                                         WorkspaceModel.Category,
                                                         WorkspaceModel.Description,
                                                         WorkspaceModel.FileName));
 }
        private static void RemapCustomNodeFilePaths( CustomNodeManager customNodeManager, IEnumerable<string> filePaths, string dyfRoot )
        {

            var defList= filePaths
                .Where(x => x.EndsWith(".dyf"))
                .Select(customNodeManager.GuidFromPath)
                .Select(customNodeManager.GetFunctionDefinition)
                .ToList();
                
            defList.ForEach( func =>
                    {
                        var newPath = Path.Combine(dyfRoot, Path.GetFileName(func.WorkspaceModel.FileName));
                        func.WorkspaceModel.FileName = newPath;
                        customNodeManager.SetNodePath(func.FunctionId, newPath);
                    });
        }
        /// <summary>
        ///     Class constructor
        /// </summary>
        public DynamoController(ExecutionEnvironment env,
            Type viewModelType, string context, string commandFilePath)
        {
            DynamoLogger.Instance.StartLogging();

            dynSettings.Controller = this;

            this.Context = context;

            //Start heartbeat reporting
            Services.InstrumentationLogger.Start();

            //create the view model to which the main window will bind
            //the DynamoModel is created therein
            this.DynamoViewModel = (DynamoViewModel)Activator.CreateInstance(
                viewModelType, new object[] { this, commandFilePath });

            // custom node loader
            string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string pluginsPath = Path.Combine(directory, "definitions");

            CustomNodeManager = new CustomNodeManager(pluginsPath);

            SearchViewModel = new SearchViewModel();

            dynSettings.PackageLoader = new PackageLoader();

            dynSettings.PackageLoader.DoCachedPackageUninstalls();
            dynSettings.PackageLoader.LoadPackages();

            FSchemeEnvironment = env;

            DynamoViewModel.Model.CurrentWorkspace.X = 0;
            DynamoViewModel.Model.CurrentWorkspace.Y = 0;

            DynamoLogger.Instance.Log(String.Format(
                "Dynamo -- Build {0}",
                Assembly.GetExecutingAssembly().GetName().Version));

            DynamoLoader.ClearCachedAssemblies();
            DynamoLoader.LoadBuiltinTypes();

            //run tests
            if (FScheme.RunTests(DynamoLogger.Instance.Log))
            {
                DynamoLogger.Instance.Log("All Tests Passed. Core library loaded OK.");
            }

            this.InfoBubbleViewModel = new InfoBubbleViewModel();

            AddPythonBindings();

            MigrationManager.Instance.MigrationTargets.Add(typeof(WorkspaceMigrations));

            var updateManager = UpdateManager.UpdateManager.Instance;
            updateManager.UpdateDownloaded += updateManager_UpdateDownloaded;
            updateManager.ShutdownRequested += updateManager_ShutdownRequested;
            updateManager.CheckForProductUpdate();
        }
Exemple #6
0
 internal void RefreshCustomNodesFromDirectory(CustomNodeManager customNodeManager)
 {
     this.LoadedCustomNodes.Clear();
     customNodeManager
                 .GetInfosFromFolder(this.CustomNodeDirectory)
                 .ToList()
                 .ForEach(x => this.LoadedCustomNodes.Add(x));
 }
Exemple #7
0
        internal void UninstallCore( CustomNodeManager customNodeManager, PackageLoader packageLoader, IPreferences prefs, ILogger logger )
        {
            if (this.LoadedAssemblies.Any())
            {
                this.MarkForUninstall(prefs);
                return;
            }

            try
            {
                LoadedCustomNodes.ToList().ForEach(x => customNodeManager.RemoveFromDynamo(x.Guid));
                packageLoader.LocalPackages.Remove(this);
                Directory.Delete(this.RootDirectory, true);
            }
            catch (Exception e)
            {
                logger.Log("Exception when attempting to uninstall the package " + this.Name + " from " + this.RootDirectory);
                logger.Log(e.GetType() + ": " + e.Message);
                throw e;
            }
        }
        /// <summary>
        ///     Class constructor
        /// </summary>
        public DynamoController(Type viewModelType, string context, string commandFilePath, IUpdateManager updateManager, IWatchHandler watchHandler, IPreferences preferences)
        {
            DynamoLogger.Instance.StartLogging();

            dynSettings.Controller = this;

            Context = context;

            //Start heartbeat reporting
            InstrumentationLogger.Start();

            PreferenceSettings = preferences;
            ((PreferenceSettings) PreferenceSettings).PropertyChanged += PreferenceSettings_PropertyChanged;

            SIUnit.LengthUnit = PreferenceSettings.LengthUnit;
            SIUnit.AreaUnit = PreferenceSettings.AreaUnit;
            SIUnit.VolumeUnit = PreferenceSettings.VolumeUnit;
            SIUnit.NumberFormat = PreferenceSettings.NumberFormat;

            UpdateManager = updateManager;
            UpdateManager.UpdateDownloaded += updateManager_UpdateDownloaded;
            UpdateManager.ShutdownRequested += updateManager_ShutdownRequested;
            UpdateManager.CheckForProductUpdate(new UpdateRequest(new Uri(Configurations.UpdateDownloadLocation),DynamoLogger.Instance, UpdateManager.UpdateDataAvailable));

            WatchHandler = watchHandler;

            //create the view model to which the main window will bind
            //the DynamoModel is created therein
            DynamoViewModel = (DynamoViewModel)Activator.CreateInstance(
                viewModelType, new object[] { this, commandFilePath });

            // custom node loader
            string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string pluginsPath = Path.Combine(directory, "definitions");

            CustomNodeManager = new CustomNodeManager(pluginsPath);

            SearchViewModel = new SearchViewModel();

            dynSettings.PackageLoader = new PackageLoader();

            dynSettings.PackageLoader.DoCachedPackageUninstalls();
            dynSettings.PackageLoader.LoadPackages();

            DynamoViewModel.Model.CurrentWorkspace.X = 0;
            DynamoViewModel.Model.CurrentWorkspace.Y = 0;

            DisposeLogic.IsShuttingDown = false;
            EngineController = new EngineController(this, false);
            //This is necessary to avoid a race condition by causing a thread join
            //inside the vm exec
            //TODO(Luke): Push this into a resync call with the engine controller
            ResetEngine();

            DynamoLogger.Instance.Log(String.Format(
                "Dynamo -- Build {0}",
                Assembly.GetExecutingAssembly().GetName().Version));

            DynamoLoader.ClearCachedAssemblies();
            DynamoLoader.LoadNodeModels();

            //run tests
            if (FScheme.RunTests(DynamoLogger.Instance.Log))
            {
                DynamoLogger.Instance.Log("All Tests Passed. Core library loaded OK.");
            }

            InfoBubbleViewModel = new InfoBubbleViewModel();

            AddPythonBindings();

            MigrationManager.Instance.MigrationTargets.Add(typeof(WorkspaceMigrations));
        }
        /// <summary>
        ///     Class constructor
        /// </summary>
        public DynamoController(string context, IUpdateManager updateManager, ILogger logger,
            IWatchHandler watchHandler, IPreferences preferences)
        {
            IsCrashing = false;

            DynamoLogger = logger;

            dynSettings.Controller = this;

            Context = context;

            //Start heartbeat reporting
            InstrumentationLogger.Start();

            PreferenceSettings = preferences;
            ((PreferenceSettings) PreferenceSettings).PropertyChanged += PreferenceSettings_PropertyChanged;

            BaseUnit.LengthUnit = PreferenceSettings.LengthUnit;
            BaseUnit.AreaUnit = PreferenceSettings.AreaUnit;
            BaseUnit.VolumeUnit = PreferenceSettings.VolumeUnit;
            BaseUnit.NumberFormat = PreferenceSettings.NumberFormat;

            UpdateManager = updateManager;
            UpdateManager.UpdateDownloaded += updateManager_UpdateDownloaded;
            UpdateManager.ShutdownRequested += updateManager_ShutdownRequested;
            UpdateManager.CheckForProductUpdate(new UpdateRequest(new Uri(Configurations.UpdateDownloadLocation),dynSettings.Controller.DynamoLogger, UpdateManager.UpdateDataAvailable));

            WatchHandler = watchHandler;

            //create the model
            DynamoModel = new DynamoModel ();
            DynamoModel.AddHomeWorkspace();
            DynamoModel.CurrentWorkspace = DynamoModel.HomeSpace;
            DynamoModel.CurrentWorkspace.X = 0;
            DynamoModel.CurrentWorkspace.Y = 0;

            // custom node loader
            string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string pluginsPath = Path.Combine(directory, "definitions");

            CustomNodeManager = new CustomNodeManager(pluginsPath);
            
            SearchViewModel = new SearchViewModel();

            dynSettings.PackageLoader = new PackageLoader();

            dynSettings.PackageLoader.DoCachedPackageUninstalls();
            dynSettings.PackageLoader.LoadPackages();

            DisposeLogic.IsShuttingDown = false;

            //This is necessary to avoid a race condition by causing a thread join
            //inside the vm exec
            //TODO(Luke): Push this into a resync call with the engine controller
            ResetEngine();

            dynSettings.Controller.DynamoLogger.Log(String.Format(
                "Dynamo -- Build {0}",
                Assembly.GetExecutingAssembly().GetName().Version));

            DynamoLoader.ClearCachedAssemblies();
            DynamoLoader.LoadNodeModels();
            
            InfoBubbleViewModel = new InfoBubbleViewModel();

            MigrationManager.Instance.MigrationTargets.Add(typeof(WorkspaceMigrations));

            evaluationWorker.DoWork += RunThread;
        }