//public DynamoController(SplashScreen splash) public DynamoController() { Bench = new dynBench(this); homeSpace = CurrentSpace = new HomeWorkspace(); Bench.CurrentX = dynBench.CANVAS_OFFSET_X; Bench.CurrentY = dynBench.CANVAS_OFFSET_Y; Bench.InitializeComponent(); Bench.Log(String.Format( "Dynamo -- Build {0}.", Assembly.GetExecutingAssembly().GetName().Version.ToString())); dynSettings.Bench = Bench; dynSettings.Controller = this; dynSettings.Workbench = Bench.WorkBench; if (DynamoCommands.ShowSplashScreenCmd.CanExecute(null)) { DynamoCommands.ShowSplashScreenCmd.Execute(null); } //WTF Bench.settings_curves.IsChecked = true; Bench.settings_curves.IsChecked = false; Bench.LockUI(); //run tests if (FScheme.RunTests(Bench.Log)) Bench.Log("All Tests Passed. Core library loaded OK."); FSchemeEnvironment = new ExecutionEnvironment(); LoadBuiltinTypes(); PopulateSamplesMenu(); Bench.Activated += Bench_Activated; //Dispatcher.CurrentDispatcher.Hooks.DispatcherInactive += new EventHandler(Hooks_DispatcherInactive); }
/// <summary> /// Load Custom Nodes from the default directory - the "definitions" /// directory where the executing assembly is located.. /// </summary> /// <param name="bench">The logger is needed in order to tell how long it took.</param> public static void LoadCustomNodes(dynBench bench, CustomNodeLoader customNodeLoader, SearchViewModel searchViewModel) { // custom node loader var sw = new Stopwatch(); sw.Start(); customNodeLoader.UpdateSearchPath(); var nn = customNodeLoader.GetNodeNameCategoryAndGuidList(); // add nodes to search foreach (var pair in nn) { searchViewModel.Add(pair.Item1, pair.Item2, pair.Item3); } sw.Stop(); bench.Log(string.Format("{0} ellapsed for loading definitions.", sw.Elapsed)); // update search view searchViewModel.SearchAndUpdateResultsSync(searchViewModel.SearchText); }
public DynamoController(SplashScreen splash) { Bench = new dynBench(this); splashScreen = splash; homeSpace = CurrentSpace = new HomeWorkspace(); Bench.CurrentX = dynBench.CANVAS_OFFSET_X; Bench.CurrentY = dynBench.CANVAS_OFFSET_Y; Bench.InitializeComponent(); Bench.Log(String.Format( "Dynamo -- Build {0}.", Assembly.GetExecutingAssembly().GetName().Version.ToString())); //WTF Bench.settings_curves.IsChecked = true; Bench.settings_curves.IsChecked = false; dynSettings.Bench = Bench; dynSettings.Controller = this; dynSettings.Workbench = Bench.WorkBench; Bench.LockUI(); //run tests if (FScheme.RunTests(Bench.Log)) Bench.Log("All Tests Passed. Core library loaded OK."); FSchemeEnvironment = new ExecutionEnvironment(); LoadBuiltinTypes(); PopulateSamplesMenu(); Bench.Activated += Bench_Activated; }
/// <summary> /// Class constructor /// </summary> public DynamoController(ExecutionEnvironment env) { dynSettings.Controller = this; this.RunEnabled = true; this.CanRunDynamically = true; Bench = new dynBench(this); dynSettings.Bench = Bench; // custom node loader string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string pluginsPath = Path.Combine(directory, "definitions"); CustomNodeLoader = new CustomNodeLoader(pluginsPath); SearchViewModel = new SearchViewModel(); PackageManagerClient = new PackageManagerClient(this); PackageManagerLoginViewModel = new PackageManagerLoginViewModel(PackageManagerClient); PackageManagerPublishViewModel = new PackageManagerPublishViewModel(PackageManagerClient); FSchemeEnvironment = env; HomeSpace = CurrentSpace = new HomeWorkspace(); Bench.CurrentOffset = new Point(dynBench.CANVAS_OFFSET_X, dynBench.CANVAS_OFFSET_Y); Bench.InitializeComponent(); Bench.Log(String.Format( "Dynamo -- Build {0}.", Assembly.GetExecutingAssembly().GetName().Version)); DynamoLoader.LoadBuiltinTypes(SearchViewModel, this, Bench); DynamoLoader.LoadSamplesMenu(Bench); Bench.settings_curves.IsChecked = true; Bench.settings_curves.IsChecked = false; Bench.LockUI(); Bench.Activated += OnBenchActivated; dynSettings.Workbench = Bench.WorkBench; //run tests if (FScheme.RunTests(Bench.Log)) { if (Bench != null) Bench.Log("All Tests Passed. Core library loaded OK."); } }
/// <summary> /// Enumerate the types in an assembly and add them to DynamoController's /// dictionaries and the search view model. Internally catches exceptions and sends the error /// to the console. /// </summary> /// <param name="searchViewModel">The searchViewModel to which the nodes will be added</param> /// <param name="controller">The DynamoController, whose dictionaries will be modified</param> /// <param name="bench">The bench where logging errors will be sent</param> private static void LoadNodesFromAssembly(Assembly assembly, SearchViewModel searchViewModel, DynamoController controller, dynBench bench ) { try { Type[] loadedTypes = assembly.GetTypes(); foreach (Type t in loadedTypes) { //only load types that are in the right namespace, are not abstract //and have the elementname attribute object[] attribs = t.GetCustomAttributes(typeof(NodeNameAttribute), false); if (IsNodeSubType(t) && attribs.Length > 0) { searchViewModel.Add(t); string typeName = (attribs[0] as NodeNameAttribute).Name; var data = new TypeLoadData(assembly, t); controller.builtinTypesByNickname.Add(typeName, data); controller.builtinTypesByTypeName.Add(t.FullName, data); } } } catch (Exception e) { bench.Log("Could not load types."); bench.Log(e); if (e is ReflectionTypeLoadException) { var typeLoadException = e as ReflectionTypeLoadException; Exception[] loaderExceptions = typeLoadException.LoaderExceptions; bench.Log("Dll Load Exception: " + loaderExceptions[0]); bench.Log(loaderExceptions[0].ToString()); if (loaderExceptions.Count() > 1) { bench.Log("Dll Load Exception: " + loaderExceptions[1]); bench.Log(loaderExceptions[1].ToString()); } } } }