Esempio n. 1
0
        private void StartDynamo()
        {
            try
            {
                SIUnit.HostApplicationInternalAreaUnit = DynamoAreaUnit.SquareFoot;
                SIUnit.HostApplicationInternalLengthUnit = DynamoLengthUnit.DecimalFoot;
                SIUnit.HostApplicationInternalVolumeUnit = DynamoVolumeUnit.CubicFoot;

                var logger = new DynamoLogger();
                var updateManager = new UpdateManager.UpdateManager(logger);

                //create a new instance of the ViewModel
                Controller = new DynamoController(Context.NONE, updateManager, logger, 
                    new DefaultWatchHandler(), new PreferenceSettings());
                DynamoController.IsTestMode = true;
                Controller.DynamoViewModel = new DynamoViewModel(Controller, null);
                Controller.VisualizationManager = new VisualizationManager();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }

            //create the transaction manager object
            TransactionManager.SetupManager(new AutomaticTransactionStrategy());

            //tests do not run from idle thread
            TransactionManager.Instance.DoAssertInIdleThread = false;
        }
Esempio n. 2
0
        private void StartDynamo()
        {
            try
            {
                SIUnit.HostApplicationInternalAreaUnit   = DynamoAreaUnit.SquareFoot;
                SIUnit.HostApplicationInternalLengthUnit = DynamoLengthUnit.DecimalFoot;
                SIUnit.HostApplicationInternalVolumeUnit = DynamoVolumeUnit.CubicFoot;

                var logger        = new DynamoLogger();
                var updateManager = new UpdateManager.UpdateManager(logger);

                //create a new instance of the ViewModel
                Controller = new DynamoController(Context.NONE, updateManager, logger,
                                                  new DefaultWatchHandler(), new PreferenceSettings());
                DynamoController.IsTestMode     = true;
                Controller.DynamoViewModel      = new DynamoViewModel(Controller, null);
                Controller.VisualizationManager = new VisualizationManager();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }

            //create the transaction manager object
            TransactionManager.SetupManager(new AutomaticTransactionStrategy());

            //tests do not run from idle thread
            TransactionManager.Instance.DoAssertInIdleThread = false;
        }
Esempio n. 3
0
        public static DynamoController_Revit CreateDynamoRevitControllerAndViewModel(RevitServicesUpdater updater, DynamoLogger logger, string context)
        {
            BaseUnit.HostApplicationInternalAreaUnit   = DynamoAreaUnit.SquareFoot;
            BaseUnit.HostApplicationInternalLengthUnit = DynamoLengthUnit.DecimalFoot;
            BaseUnit.HostApplicationInternalVolumeUnit = DynamoVolumeUnit.CubicFoot;

            var updateManager    = new UpdateManager.UpdateManager(logger);
            var dynamoController = new DynamoController_Revit(updater, context, updateManager);

            // Generate a view model to be the data context for the view
            dynamoController.DynamoViewModel = new DynamoRevitViewModel(dynamoController, null);
            dynamoController.DynamoViewModel.RequestAuthentication +=
                ((DynamoController_Revit)dynamoController).RegisterSingleSignOn;
            dynamoController.DynamoViewModel.CurrentSpaceViewModel.CanFindNodesFromElements = true;
            dynamoController.DynamoViewModel.CurrentSpaceViewModel.FindNodesFromElements    =
                ((DynamoController_Revit)dynamoController).FindNodesFromSelection;

            // Register the view model to handle sign-on requests
            dynSettings.Controller.DynamoViewModel.RequestAuthentication +=
                ((DynamoController_Revit)dynamoController).RegisterSingleSignOn;

            dynamoController.VisualizationManager = new VisualizationManagerRevit();

            return(dynamoController);
        }
Esempio n. 4
0
        private void StartDynamo()
        {
            try
            {
                var updater = new RevitServicesUpdater(DynamoRevitApp.ControlledApplication, DynamoRevitApp.Updaters);
                updater.ElementAddedForID += ElementMappingCache.GetInstance().WatcherMethodForAdd;
                updater.ElementsDeleted   += ElementMappingCache.GetInstance().WatcherMethodForDelete;

                SIUnit.HostApplicationInternalAreaUnit   = DynamoAreaUnit.SquareFoot;
                SIUnit.HostApplicationInternalLengthUnit = DynamoLengthUnit.DecimalFoot;
                SIUnit.HostApplicationInternalVolumeUnit = DynamoVolumeUnit.CubicFoot;

                var logger = new DynamoLogger();
                dynSettings.DynamoLogger = logger;
                var updateManager = new UpdateManager.UpdateManager(logger);

                Controller = DynamoRevit.CreateDynamoRevitControllerAndViewModel(updater, logger, Context.NONE);
                DynamoController.IsTestMode = true;

                // create the transaction manager object
                TransactionManager.SetupManager(new AutomaticTransactionStrategy());

                // Because the test framework does not work in the idle thread.
                // We need to trick Dynamo into believing that it's in the idle
                // thread already.
                IdlePromise.InIdleThread = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
Esempio n. 5
0
        protected void StartDynamo()
        {
            var logger = new DynamoLogger();
            var updateManager = new UpdateManager.UpdateManager(logger);

            ////create a new instance of the ViewModel
            Controller = new DynamoController(Context.NONE, updateManager, logger,
                new DefaultWatchHandler(), new PreferenceSettings());
            DynamoController.IsTestMode = true;
            Controller.DynamoViewModel = new DynamoViewModel(Controller, null);
            Controller.VisualizationManager = new VisualizationManager();   
        }
Esempio n. 6
0
        protected void StartDynamo()
        {
            var logger        = new DynamoLogger();
            var updateManager = new UpdateManager.UpdateManager(logger);

            ////create a new instance of the ViewModel
            Controller = new DynamoController(Context.NONE, updateManager, logger,
                                              new DefaultWatchHandler(), new PreferenceSettings());
            DynamoController.IsTestMode     = true;
            Controller.DynamoViewModel      = new DynamoViewModel(Controller, null);
            Controller.VisualizationManager = new VisualizationManager();
        }
        /// <summary>
        /// Open App Target Dialog
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Update_Click(object sender, RoutedEventArgs e)
        {
            this.Cursor = System.Windows.Input.Cursors.Wait;

            UpdateManager.UpdateManager updateManager = UpdateManager.UpdateManager.create();

            _data.RefreshScreen();
            NDKEntry.ItemsSource = null;
            NDKEntry.ItemsSource = _data.NDKEntries;

            this.Cursor = System.Windows.Input.Cursors.Hand;
        }
Esempio n. 8
0
        protected void StartDynamo()
        {
            var corePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            DynamoPathManager.Instance.InitializeCore(corePath);

            var logger = new DynamoLogger(DynamoPathManager.Instance.Logs);
            dynSettings.DynamoLogger = logger;

            var updateManager = new UpdateManager.UpdateManager(logger);

            ////create a new instance of the ViewModel
            Controller = new DynamoController(Context.NONE, updateManager,
                new DefaultWatchHandler(), new PreferenceSettings(), corePath);
            DynamoController.IsTestMode = true;
            Controller.DynamoViewModel = new DynamoViewModel(Controller, null);
            Controller.VisualizationManager = new VisualizationManager();   
        }
Esempio n. 9
0
        protected void StartDynamo()
        {
            var logger = new DynamoLogger();

            dynSettings.DynamoLogger = logger;

            var updateManager = new UpdateManager.UpdateManager(logger);

            var corePath =
                Path.GetFullPath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            ////create a new instance of the ViewModel
            Controller = new DynamoController(Context.NONE, updateManager,
                                              new DefaultWatchHandler(), new PreferenceSettings(), corePath);
            DynamoController.IsTestMode     = true;
            Controller.DynamoViewModel      = new DynamoViewModel(Controller, null);
            Controller.VisualizationManager = new VisualizationManager();
        }
Esempio n. 10
0
        /// <summary>
        /// Generate a new FrmMain form.
        /// </summary>
        /// <param name="args">A collection of arguments.</param>
        public FrmMain(string[] args)
        {
            InitializeComponent();
            LoadTheme();

            LanguageManager = new LanguageManager();
            _updateManager  = new UpdateManager.UpdateManager(Assembly.GetExecutingAssembly().GetName().Version, "http://codedead.com/Software/DeadLock/update.xml", "DeadLock");

            try
            {
                LanguageSwitch();

                nfiTray.Visible = Properties.Settings.Default.ShowNotifyIcon;
                if (Properties.Settings.Default.RememberFormSize)
                {
                    Size = Properties.Settings.Default.FormSize;
                }
            }
            catch (Exception ex)
            {
                MessageBoxAdv.Show(ex.Message, "DeadLock", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            _args = args;
        }
Esempio n. 11
0
        public static DynamoController_Revit CreateDynamoRevitControllerAndViewModel(
            RevitServicesUpdater updater, DynamoLogger logger, string context)
        {
            BaseUnit.HostApplicationInternalAreaUnit = DynamoAreaUnit.SquareFoot;
            BaseUnit.HostApplicationInternalLengthUnit = DynamoLengthUnit.DecimalFoot;
            BaseUnit.HostApplicationInternalVolumeUnit = DynamoVolumeUnit.CubicFoot;

            var updateManager = new UpdateManager.UpdateManager(logger);

            string corePath =
                Path.GetFullPath(
                    Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\..\");
            var dynamoController = new DynamoController_Revit(
                updater,
                context,
                updateManager,
                corePath);

            // Generate a view model to be the data context for the view
            dynamoController.DynamoViewModel = new DynamoRevitViewModel(dynamoController, null);
            dynamoController.DynamoViewModel.RequestAuthentication +=
                dynamoController.RegisterSingleSignOn;
            dynamoController.DynamoViewModel.CurrentSpaceViewModel.CanFindNodesFromElements = true;
            dynamoController.DynamoViewModel.CurrentSpaceViewModel.FindNodesFromElements =
                dynamoController.FindNodesFromSelection;

            // Register the view model to handle sign-on requests
            dynSettings.Controller.DynamoViewModel.RequestAuthentication +=
                dynamoController.RegisterSingleSignOn;

            dynamoController.VisualizationManager = new VisualizationManagerRevit();

            return dynamoController;
        }
Esempio n. 12
0
        private void StartDynamo()
        {
            try
            {
                var updater = new RevitServicesUpdater(DynamoRevitApp.ControlledApplication, DynamoRevitApp.Updaters);
                updater.ElementAddedForID += ElementMappingCache.GetInstance().WatcherMethodForAdd;
                updater.ElementsDeleted += ElementMappingCache.GetInstance().WatcherMethodForDelete;

                SIUnit.HostApplicationInternalAreaUnit = DynamoAreaUnit.SquareFoot;
                SIUnit.HostApplicationInternalLengthUnit = DynamoLengthUnit.DecimalFoot;
                SIUnit.HostApplicationInternalVolumeUnit = DynamoVolumeUnit.CubicFoot;

                var logger = new DynamoLogger(DynamoPathManager.Instance.Logs);
                dynSettings.DynamoLogger = logger;
                var updateManager = new UpdateManager.UpdateManager(logger);

                Controller = DynamoRevit.CreateDynamoRevitControllerAndViewModel(updater, logger, Context.NONE);
                DynamoController.IsTestMode = true;

                // create the transaction manager object
                TransactionManager.SetupManager(new AutomaticTransactionStrategy());

                // Because the test framework does not work in the idle thread. 
                // We need to trick Dynamo into believing that it's in the idle
                // thread already.
                IdlePromise.InIdleThread = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
Esempio n. 13
0
        public Result Execute(ExternalCommandData revit, ref string message, ElementSet elements)
        {
            AppDomain.CurrentDomain.AssemblyResolve += AssemblyHelper.CurrentDomain_AssemblyResolve;
            AppDomain.CurrentDomain.AssemblyResolve += DynamoRaaS.AssemblyHelper.ResolveAssemblies;

            //Add an assembly load step for the System.Windows.Interactivity assembly
            //Revit owns a version of this as well. Adding our step here prevents a duplicative
            //load of the dll at a later time.
            var assLoc = Assembly.GetExecutingAssembly().Location;
            var interactivityPath = Path.Combine(Path.GetDirectoryName(assLoc), "System.Windows.Interactivity.dll");
            var interactivityAss = Assembly.LoadFrom(interactivityPath);

            //When a user double-clicks the Dynamo icon, we need to make
            //sure that we don't create another instance of Dynamo.
            if (isRunning)
            {
                Debug.WriteLine("Dynamo is already running.");
                if (dynamoView != null)
                {
                    dynamoView.Focus();
                }
                return Result.Succeeded;
            }

            isRunning = true;

            try
            {
                #region default level

                var fecLevel = new FilteredElementCollector(revit.Application.ActiveUIDocument.Document);
                fecLevel.OfClass(typeof(Level));
                var defaultLevel = fecLevel.ToElements()[0] as Level;

                #endregion

                if (DocumentManager.Instance.CurrentUIApplication == null)
                    DocumentManager.Instance.CurrentUIApplication = revit.Application;

                DocumentManager.OnLogError += dynSettings.Controller.DynamoLogger.Log;

                dynRevitSettings.DefaultLevel = defaultLevel;

                //TODO: has to be changed when we handle multiple docs
                Updater = new RevitServicesUpdater(DynamoRevitApp.ControlledApplication, DynamoRevitApp.Updaters);
                Updater.ElementAddedForID += ElementMappingCache.GetInstance().WatcherMethodForAdd;
                Updater.ElementsDeleted += ElementMappingCache.GetInstance().WatcherMethodForDelete;

                RevThread.IdlePromise.ExecuteOnIdleAsync(
                    delegate
                    {
                        //get window handle
                        IntPtr mwHandle = Process.GetCurrentProcess().MainWindowHandle;

                        var r = new Regex(@"\b(Autodesk |Structure |MEP |Architecture )\b");
                        string context = r.Replace(revit.Application.Application.VersionName, "");

                        //they changed the application version name conventions for vasari
                        //it no longer has a version year so we can't compare it to other versions
                        //TODO:come up with a more stable way to test for Vasari beta 3
                        if (context == "Vasari")
                            context = "Vasari 2014";

                        BaseUnit.HostApplicationInternalAreaUnit = DynamoAreaUnit.SquareFoot;
                        BaseUnit.HostApplicationInternalLengthUnit = DynamoLengthUnit.DecimalFoot;
                        BaseUnit.HostApplicationInternalVolumeUnit = DynamoVolumeUnit.CubicFoot;

                        var logger = new DynamoLogger();
                        var updateManager = new UpdateManager.UpdateManager(logger);
                        dynamoController = new DynamoController_Revit(Updater, context, updateManager,logger);

                        // Generate a view model to be the data context for the view
                        dynamoController.DynamoViewModel = new DynamoRevitViewModel(dynamoController, null);
                        dynamoController.DynamoViewModel.RequestAuthentication += ((DynamoController_Revit)dynamoController).RegisterSingleSignOn;
                        dynamoController.DynamoViewModel.CurrentSpaceViewModel.CanFindNodesFromElements = true;
                        dynamoController.DynamoViewModel.CurrentSpaceViewModel.FindNodesFromElements = ((DynamoController_Revit)dynamoController).FindNodesFromSelection;
                        
                        // Register the view model to handle sign-on requests
                        dynSettings.Controller.DynamoViewModel.RequestAuthentication += ((DynamoController_Revit)dynamoController).RegisterSingleSignOn;

                        dynamoController.VisualizationManager = new VisualizationManagerRevit();
                        
                        dynamoView = new DynamoView { DataContext = dynamoController.DynamoViewModel };
                        dynamoController.UIDispatcher = dynamoView.Dispatcher;

                        //set window handle and show dynamo
                        new WindowInteropHelper(dynamoView).Owner = mwHandle;

                        handledCrash = false;

                        dynamoView.WindowStartupLocation = WindowStartupLocation.Manual;

                        Rectangle bounds = Screen.PrimaryScreen.Bounds;
                        dynamoView.Left = DynamoViewX ?? bounds.X;
                        dynamoView.Top = DynamoViewY ?? bounds.Y;
                        dynamoView.Width = DynamoViewWidth ?? 1000.0;
                        dynamoView.Height = DynamoViewHeight ?? 800.0;

                        dynamoView.Show();

                        dynamoView.Dispatcher.UnhandledException += DispatcherOnUnhandledException; 
                        dynamoView.Closing += dynamoView_Closing;
                        dynamoView.Closed += dynamoView_Closed;

                        revit.Application.ViewActivating += Application_ViewActivating;
                    });
            }
            catch (Exception ex)
            {
                isRunning = false;
                MessageBox.Show(ex.ToString());

                dynSettings.Controller.DynamoLogger.LogError(ex.Message);
                dynSettings.Controller.DynamoLogger.LogError(ex.StackTrace);
                dynSettings.Controller.DynamoLogger.LogError("Dynamo log ended " + DateTime.Now);

                return Result.Failed;
            }

            return Result.Succeeded;
        }
Esempio n. 14
0
        public Result Execute(ExternalCommandData revit, ref string message, ElementSet elements)
        {
            AppDomain.CurrentDomain.AssemblyResolve += AssemblyHelper.CurrentDomain_AssemblyResolve;
            AppDomain.CurrentDomain.AssemblyResolve += DynamoRaaS.AssemblyHelper.ResolveAssemblies;

            //Add an assembly load step for the System.Windows.Interactivity assembly
            //Revit owns a version of this as well. Adding our step here prevents a duplicative
            //load of the dll at a later time.
            var assLoc            = Assembly.GetExecutingAssembly().Location;
            var interactivityPath = Path.Combine(Path.GetDirectoryName(assLoc), "System.Windows.Interactivity.dll");
            var interactivityAss  = Assembly.LoadFrom(interactivityPath);

            //When a user double-clicks the Dynamo icon, we need to make
            //sure that we don't create another instance of Dynamo.
            if (isRunning)
            {
                Debug.WriteLine("Dynamo is already running.");
                if (dynamoView != null)
                {
                    dynamoView.Focus();
                }
                return(Result.Succeeded);
            }

            isRunning = true;

            try
            {
                #region default level

                var fecLevel = new FilteredElementCollector(revit.Application.ActiveUIDocument.Document);
                fecLevel.OfClass(typeof(Level));
                var defaultLevel = fecLevel.ToElements()[0] as Level;

                #endregion

                if (DocumentManager.Instance.CurrentUIApplication == null)
                {
                    DocumentManager.Instance.CurrentUIApplication = revit.Application;
                }

                DocumentManager.OnLogError += dynSettings.Controller.DynamoLogger.Log;

                dynRevitSettings.DefaultLevel = defaultLevel;

                //TODO: has to be changed when we handle multiple docs
                Updater = new RevitServicesUpdater(DynamoRevitApp.ControlledApplication, DynamoRevitApp.Updaters);
                Updater.ElementAddedForID += ElementMappingCache.GetInstance().WatcherMethodForAdd;
                Updater.ElementsDeleted   += ElementMappingCache.GetInstance().WatcherMethodForDelete;

                RevThread.IdlePromise.ExecuteOnIdleAsync(
                    delegate
                {
                    //get window handle
                    IntPtr mwHandle = Process.GetCurrentProcess().MainWindowHandle;

                    var r          = new Regex(@"\b(Autodesk |Structure |MEP |Architecture )\b");
                    string context = r.Replace(revit.Application.Application.VersionName, "");

                    //they changed the application version name conventions for vasari
                    //it no longer has a version year so we can't compare it to other versions
                    //TODO:come up with a more stable way to test for Vasari beta 3
                    if (context == "Vasari")
                    {
                        context = "Vasari 2014";
                    }

                    BaseUnit.HostApplicationInternalAreaUnit   = DynamoAreaUnit.SquareFoot;
                    BaseUnit.HostApplicationInternalLengthUnit = DynamoLengthUnit.DecimalFoot;
                    BaseUnit.HostApplicationInternalVolumeUnit = DynamoVolumeUnit.CubicFoot;

                    var logger        = new DynamoLogger();
                    var updateManager = new UpdateManager.UpdateManager(logger);
                    dynamoController  = new DynamoController_Revit(Updater, context, updateManager, logger);

                    // Generate a view model to be the data context for the view
                    dynamoController.DynamoViewModel = new DynamoRevitViewModel(dynamoController, null);
                    dynamoController.DynamoViewModel.RequestAuthentication += ((DynamoController_Revit)dynamoController).RegisterSingleSignOn;
                    dynamoController.DynamoViewModel.CurrentSpaceViewModel.CanFindNodesFromElements = true;
                    dynamoController.DynamoViewModel.CurrentSpaceViewModel.FindNodesFromElements    = ((DynamoController_Revit)dynamoController).FindNodesFromSelection;

                    // Register the view model to handle sign-on requests
                    dynSettings.Controller.DynamoViewModel.RequestAuthentication += ((DynamoController_Revit)dynamoController).RegisterSingleSignOn;

                    dynamoController.VisualizationManager = new VisualizationManagerRevit();

                    dynamoView = new DynamoView {
                        DataContext = dynamoController.DynamoViewModel
                    };
                    dynamoController.UIDispatcher = dynamoView.Dispatcher;

                    //set window handle and show dynamo
                    new WindowInteropHelper(dynamoView).Owner = mwHandle;

                    handledCrash = false;

                    dynamoView.WindowStartupLocation = WindowStartupLocation.Manual;

                    Rectangle bounds  = Screen.PrimaryScreen.Bounds;
                    dynamoView.Left   = DynamoViewX ?? bounds.X;
                    dynamoView.Top    = DynamoViewY ?? bounds.Y;
                    dynamoView.Width  = DynamoViewWidth ?? 1000.0;
                    dynamoView.Height = DynamoViewHeight ?? 800.0;

                    dynamoView.Show();

                    dynamoView.Dispatcher.UnhandledException += DispatcherOnUnhandledException;
                    dynamoView.Closing += dynamoView_Closing;
                    dynamoView.Closed  += dynamoView_Closed;

                    revit.Application.ViewActivating += Application_ViewActivating;
                });
            }
            catch (Exception ex)
            {
                isRunning = false;
                MessageBox.Show(ex.ToString());

                dynSettings.Controller.DynamoLogger.LogError(ex.Message);
                dynSettings.Controller.DynamoLogger.LogError(ex.StackTrace);
                dynSettings.Controller.DynamoLogger.LogError("Dynamo log ended " + DateTime.Now);

                return(Result.Failed);
            }

            return(Result.Succeeded);
        }