Esempio n. 1
0
        public Result OnStartup(UIControlledApplication application)
        {
            try
            {
                // The executing assembly will be in Revit_20xx, so
                // we have to walk up one level. Unfortunately, we
                // can't use DynamoPaths here because those are not
                // initialized until the controller is constructed.
                var assDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                DynamoPaths.SetupDynamoPaths(Path.GetFullPath(assDir + @"\.."));

                //add an additional node processing folder
                DynamoPaths.Nodes.Add(Path.Combine(assDir, "nodes"));

                AppDomain.CurrentDomain.AssemblyResolve += AssemblyHelper.ResolveAssembly;

                ControlledApplication = application.ControlledApplication;

                RevThread.IdlePromise.RegisterIdle(application);
                TransactionManager.SetupManager(new AutomaticTransactionStrategy());
                ElementBinder.IsEnabled = true;

                //TAF load english_us TODO add a way to localize
                res = Resource_en_us.ResourceManager;
                // Create new ribbon panel
                RibbonPanel ribbonPanel = application.CreateRibbonPanel(res.GetString("App_Description"));

                dynamoButton =
                    (PushButton)ribbonPanel.AddItem(
                        new PushButtonData(
                            "Dynamo 0.7 Alpha",
                            res.GetString("App_Name"),
                            assemblyName,
                            "Dynamo.Applications.DynamoRevit"));


                Bitmap dynamoIcon = Resources.logo_square_32x32;

                BitmapSource bitmapSource = Imaging.CreateBitmapSourceFromHBitmap(
                    dynamoIcon.GetHbitmap(),
                    IntPtr.Zero,
                    Int32Rect.Empty,
                    BitmapSizeOptions.FromEmptyOptions());

                dynamoButton.LargeImage = bitmapSource;
                dynamoButton.Image      = bitmapSource;

                RegisterAdditionalUpdaters(application);

                return(Result.Succeeded);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(Result.Failed);
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Class constructor
        /// </summary>
        public DynamoController(string context, IUpdateManager updateManager,
                                IWatchHandler watchHandler, IPreferences preferences, string corePath)
        {
            DynamoPaths.SetupDynamoPaths(corePath);

            DebugSettings = new DebugSettings();

            IsCrashing = false;

            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), dynSettings.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;

            // Set the DynamoCore path

            // 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;

            EngineController = new EngineController(this);

            //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.DynamoLogger.Log(String.Format(
                                             "Dynamo -- Build {0}",
                                             Assembly.GetExecutingAssembly().GetName().Version));

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

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

            Runner = new DynamoRunner();
        }