예제 #1
0
        private void CefBrowser_FrameLoadEnd(object sender, CefSharp.FrameLoadEndEventArgs e)
        {
            var model = Dynamo.Applications.StartupUtils.MakeModel(false);

            dynamoViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                CommandFilePath  = "",
                DynamoModel      = model,
                Watch3DViewModel = HelixWatch3DViewModel.TryCreateHelixWatch3DViewModel(new Watch3DViewModelStartupParams(model), model.Logger),
                ShowLogin        = true
            });

            var pmExtension = dynamoViewModel.Model.GetPackageManagerExtension();
            var x           = new InstalledPackagesViewModel(dynamoViewModel, pmExtension.PackageLoader);

            //Get installed packages
            var packages = x.LocalPackages.Select(pkg => pkg.Model.Name).ToArray();

            if (e.Frame.IsMain)
            {
                var message = "'" + string.Join(",", packages) + "'";

                //Use previously registered object
                //message = "pkgMgrContext.message";

                e.Frame.ExecuteJavaScriptAsync("alert(" + message + ");");
            }
        }
        public void ComputeBoundsForSelectedNodeGeometry_PointNodeSelected_BoundingBoxIsAroundPoint()
        {
            var pointA = InitializePointWithId("A");
            var bounds = HelixWatch3DViewModel.ComputeBoundsForGeometry(new GeometryModel3D[] { pointA });

            Assert.AreEqual(bounds, pointA.Bounds());
        }
예제 #3
0
        public static DynamoRevitViewModel Start(StartConfiguration startConfiguration)
        {
            if (startConfiguration.DynamoModel == null)
            {
                startConfiguration.DynamoModel = RevitDynamoModel.Start();
            }
            else
            {
                if (startConfiguration.DynamoModel.GetType() != typeof(RevitDynamoModel))
                {
                    throw new Exception("An instance of RevitDynamoModel is required to construct a DynamoRevitViewModel.");
                }
            }

            if (startConfiguration.Watch3DViewModel == null)
            {
                startConfiguration.Watch3DViewModel =
                    HelixWatch3DViewModel.TryCreateHelixWatch3DViewModel(
                        null,
                        new Watch3DViewModelStartupParams(startConfiguration.DynamoModel),
                        startConfiguration.DynamoModel.Logger);
            }

            if (startConfiguration.WatchHandler == null)
            {
                startConfiguration.WatchHandler = new DefaultWatchHandler(startConfiguration.DynamoModel.PreferenceSettings);
            }

            return(new DynamoRevitViewModel(startConfiguration));
        }
예제 #4
0
        public void RunApplication(Application app)
        {
            try
            {
                DynamoModel.RequestMigrationStatusDialog += MigrationStatusDialogRequested;

                var model = Dynamo.Applications.StartupUtils.MakeModel(false);

                viewModel = DynamoViewModel.Start(
                    new DynamoViewModel.StartConfiguration()
                {
                    CommandFilePath  = commandFilePath,
                    DynamoModel      = model,
                    Watch3DViewModel = HelixWatch3DViewModel.TryCreateHelixWatch3DViewModel(new Watch3DViewModelStartupParams(model), model.Logger),
                    ShowLogin        = true
                });

                var view = new DynamoView(viewModel);
                view.Loaded += OnDynamoViewLoaded;

                app.Run(view);

                DynamoModel.RequestMigrationStatusDialog -= MigrationStatusDialogRequested;
            }

            catch (Exception e)
            {
                try
                {
#if DEBUG
                    // Display the recorded command XML when the crash happens,
                    // so that it maybe saved and re-run later
                    if (viewModel != null)
                    {
                        viewModel.SaveRecordedCommand.Execute(null);
                    }
#endif

                    DynamoModel.IsCrashing = true;
                    Dynamo.Logging.Analytics.TrackException(e, true);

                    if (viewModel != null)
                    {
                        // Show the unhandled exception dialog so user can copy the
                        // crash details and report the crash if she chooses to.
                        viewModel.Model.OnRequestsCrashPrompt(null,
                                                              new CrashPromptArgs(e.Message + "\n\n" + e.StackTrace));

                        // Give user a chance to save (but does not allow cancellation)
                        viewModel.Exit(allowCancel: false);
                    }
                }
                catch
                {
                }

                Debug.WriteLine(e.Message);
                Debug.WriteLine(e.StackTrace);
            }
        }
예제 #5
0
        private void ViewLoadedHandler(object sender, RoutedEventArgs e)
        {
            ViewModel = DataContext as HelixWatch3DViewModel;

            if (ViewModel == null)
            {
                return;
            }

            CompositionTarget.Rendering += CompositionTargetRenderingHandler;

            RegisterButtonHandlers();

            RegisterViewEventHandlers();

            ViewModel.RequestAttachToScene  += ViewModelRequestAttachToSceneHandler;
            ViewModel.RequestCreateModels   += RequestCreateModelsHandler;
            ViewModel.RequestRemoveModels   += RequestRemoveModelsHandler;
            ViewModel.RequestViewRefresh    += RequestViewRefreshHandler;
            ViewModel.RequestClickRay       += GetClickRay;
            ViewModel.RequestCameraPosition += GetCameraPosition;
            ViewModel.RequestZoomToFit      += ViewModel_RequestZoomToFit;

            ViewModel.UpdateUpstream();
            ViewModel.OnWatchExecution();
        }
예제 #6
0
        protected override void StartDynamo(TestSessionConfiguration testConfig)
        {
            // Add Dynamo Core location to the PATH system environment variable.
            // This is to make sure dependencies(e.g.Helix assemblies) can be located.
            var path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Process) + ";" + testConfig.DynamoCorePath;

            Environment.SetEnvironmentVariable("Path", path, EnvironmentVariableTarget.Process);

            var preloader = new Preloader(testConfig.DynamoCorePath, new[] { testConfig.RequestedLibraryVersion2 });

            preloader.Preload();

            var preloadedLibraries = new List <string>();

            GetLibrariesToPreload(preloadedLibraries);

            if (preloadedLibraries.Any())
            {
                if (pathResolver == null)
                {
                    pathResolver = new TestPathResolver();
                }

                var pr = pathResolver as TestPathResolver;
                foreach (var preloadedLibrary in preloadedLibraries.Distinct())
                {
                    pr.AddPreloadLibraryPath(preloadedLibrary);
                }
            }

            Model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                StartInTestMode     = true,
                PathResolver        = pathResolver,
                GeometryFactoryPath = preloader.GeometryFactoryPath,
                UpdateManager       = this.UpdateManager,
                ProcessMode         = TaskProcessMode.Synchronous
            });

            Model.EvaluationCompleted += Model_EvaluationCompleted;

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel      = Model,
                Watch3DViewModel =
                    HelixWatch3DViewModel.TryCreateHelixWatch3DViewModel(
                        null,
                        new Watch3DViewModelStartupParams(Model),
                        Model.Logger)
            });

            //create the view
            View = new DynamoView(ViewModel);
            View.Show();

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
        private void StartUI()
        {
            try
            {
                var nodeLibraryPath = @"C:\Users\pratapa.ADS\AppData\Roaming\Autodesk\Autodesk Fusion 360\API\AddIns\DynamoFusion\Debug\";

                //var customNodeLibraryPath = @"C:\Users\pratapa.ADS\AppData\Roaming\Autodesk\Autodesk Fusion 360\API\AddIns\DynamoFusion\Debug\";
                var customNodeLibraryPath = string.Empty;

                var model = MakeModel(nodeLibraryPath, customNodeLibraryPath);

                dynamoViewModel = DynamoViewModel.Start(
                    new DynamoViewModel.StartConfiguration()
                {
                    CommandFilePath  = string.Empty,
                    DynamoModel      = model,
                    Watch3DViewModel = HelixWatch3DViewModel.TryCreateHelixWatch3DViewModel(new Watch3DViewModelStartupParams(model), model.Logger),
                    ShowLogin        = true
                });

                var view = new DynamoView(dynamoViewModel);
                view.Show();
            }
            catch (Exception e)
            {
                try
                {
#if DEBUG
                    // Display the recorded command XML when the crash happens,
                    // so that it maybe saved and re-run later
                    if (dynamoViewModel != null)
                    {
                        dynamoViewModel.SaveRecordedCommand.Execute(null);
                    }
#endif

                    //DynamoModel.IsCrashing = true;
                    //InstrumentationLogger.LogException(e);
                    //StabilityTracking.GetInstance().NotifyCrash();

                    //if (viewModel != null)
                    //{
                    //    // Show the unhandled exception dialog so user can copy the
                    //    // crash details and report the crash if she chooses to.
                    //    viewModel.Model.OnRequestsCrashPrompt(null,
                    //        new CrashPromptArgs(e.Message + "\n\n" + e.StackTrace));

                    //    // Give user a chance to save (but does not allow cancellation)
                    //    viewModel.Exit(allowCancel: false);
                    //}
                }
                catch
                {
                }

                Debug.WriteLine(e.Message);
                Debug.WriteLine(e.StackTrace);
            }
        }
        public void ComputeBoundsForSelectedNodeGeometry_MultiplePointNodesSelected_BoundingBoxIsCorrect()
        {
            var pointA = InitializePointWithId("A");
            var pointB = InitializePointWithId("B", new Vector3(1000000, 1000000, 1000000));
            var bounds = HelixWatch3DViewModel.ComputeBoundsForGeometry(new GeometryModel3D[] { pointA, pointB });

            Assert.AreEqual(bounds.Minimum, pointA.Bounds().Minimum);
            Assert.AreEqual(bounds.Maximum, pointB.Bounds().Maximum);
        }
        public void ComputeClipPlaneDistances_ClosestObjectCoincidentWithCamera_NearClipDistance_IsDefault()
        {
            double near, far;
            var    planeOrigin = farPoint.Bounds().Minimum;
            var    planeNormal = new Vector3(1, 0, 0);
            var    geometry    = new GeometryModel3D[] { closePoint, farPoint, cube };

            HelixWatch3DViewModel.ComputeClipPlaneDistances(planeOrigin, planeNormal, geometry, 0.001, out near, out far,
                                                            HelixWatch3DViewModel.DefaultNearClipDistance, HelixWatch3DViewModel.DefaultFarClipDistance);
            Assert.AreEqual(near, HelixWatch3DViewModel.DefaultNearClipDistance);
        }
예제 #10
0
        private void ViewLoadedHandler(object sender, RoutedEventArgs e)
        {
            ViewModel = DataContext as HelixWatch3DViewModel;

            if (ViewModel == null)
            {
                return;
            }

            RegisterEventHandlers();
        }
        public void ComputeClipPlaneDistances_AllObjectsBehind__ClipDistances_AreDefault()
        {
            double near, far;
            var    planeOrigin = new Vector3(50000, 0, 0);
            var    planeNormal = new Vector3(1, 0, 0);
            var    geometry    = new GeometryModel3D[] { closePoint, farPoint, cube };

            HelixWatch3DViewModel.ComputeClipPlaneDistances(planeOrigin, planeNormal, geometry, 0.001, out near, out far,
                                                            HelixWatch3DViewModel.DefaultNearClipDistance, HelixWatch3DViewModel.DefaultFarClipDistance);
            Assert.AreEqual(near, HelixWatch3DViewModel.DefaultNearClipDistance);
            Assert.AreEqual(far, HelixWatch3DViewModel.DefaultFarClipDistance);
        }
예제 #12
0
        public void RunApp(IntPtr windowHandle)
        {
            try
            {
                DynamoModel model;
                StartupUtils.ASMPreloadFailure += ASMPreloadFailureHandler;

                if (!String.IsNullOrEmpty(ASMPath))
                {
                    model = StartupUtils.MakeModel(false, ASMPath);
                }
                else
                {
                    model = StartupUtils.MakeModel(false);
                }

                ViewModel = DynamoViewModel.Start(
                    new DynamoViewModel.StartConfiguration()
                {
                    DynamoModel      = model,
                    Watch3DViewModel = HelixWatch3DViewModel.TryCreateHelixWatch3DViewModel
                                       (
                        null,
                        new Watch3DViewModelStartupParams(model),
                        model.Logger
                                       ),
                    ShowLogin = true
                });

                var view = new DynamoView(ViewModel);
                view.Loaded += OnDynamoViewLoaded;

                var windowHelper = new WindowInteropHelper(view);
                windowHelper.Owner = windowHandle;

                var app = Application.Current;
                if (app != null)
                {
                    app.Run(view);
                }
                else
                {
                    //view.Owner
                    view.Show();
                }

                StartupUtils.ASMPreloadFailure -= ASMPreloadFailureHandler;
            }
            catch (Exception ex)
            {
                //throw;
            }
        }
        public void ComputeClipPlaneDistances_ObjectsInFrontAndBehind_ClipDistance_IsCorrect()
        {
            double near, far;
            var    planeOrigin = new Vector3(-10, 0, 0);
            var    planeNormal = new Vector3(1, 0, 0);
            var    geometry    = new GeometryModel3D[] { closePoint, farPoint, cube };

            HelixWatch3DViewModel.ComputeClipPlaneDistances(planeOrigin, planeNormal, geometry, 0.001, out near, out far,
                                                            HelixWatch3DViewModel.DefaultNearClipDistance, HelixWatch3DViewModel.DefaultFarClipDistance);
            Assert.Less(near, closePoint.Bounds().GetCorners().Min(c => c.DistanceToPlane(planeOrigin, planeNormal)));
            Assert.Greater(far, farPoint.Bounds().GetCorners().Max(c => c.DistanceToPlane(planeOrigin, planeNormal)));
        }
예제 #14
0
        protected override void StartDynamo(TestSessionConfiguration testConfig)
        {
            var preloader = new Preloader(testConfig.DynamoCorePath, testConfig.RequestedLibraryVersion);

            preloader.Preload();

            var preloadedLibraries = new List <string>();

            GetLibrariesToPreload(preloadedLibraries);

            if (preloadedLibraries.Any())
            {
                if (pathResolver == null)
                {
                    pathResolver = new TestPathResolver();
                }

                var pr = pathResolver as TestPathResolver;
                foreach (var preloadedLibrary in preloadedLibraries.Distinct())
                {
                    pr.AddPreloadLibraryPath(preloadedLibrary);
                }
            }

            Model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                StartInTestMode     = true,
                PathResolver        = pathResolver,
                GeometryFactoryPath = preloader.GeometryFactoryPath,
                UpdateManager       = this.UpdateManager,
                ProcessMode         = TaskProcessMode.Synchronous
            });

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel      = Model,
                Watch3DViewModel =
                    HelixWatch3DViewModel.TryCreateHelixWatch3DViewModel(
                        null,
                        new Watch3DViewModelStartupParams(Model),
                        Model.Logger)
            });

            //create the view
            View = new DynamoView(ViewModel);
            View.Show();

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
        public void Loaded(ViewLoadedParams parameters)
        {
            Parameters   = parameters;
            DynamoWindow = parameters.DynamoWindow;
            ViewModel    = parameters.BackgroundPreviewViewModel as HelixWatch3DViewModel;
            if (ViewModel == null)
            {
                throw new Exception("Could not obtain HelixWatch3DViewModel. Sad!");
            }

            ViewModel.ViewCameraChanged  += ViewModelViewCameraChangedHandler;
            ViewModel.ViewMouseDown      += ViewModelViewMouseDownHandler;
            ViewModel.ViewMouseMove      += ViewModelViewMouseMoveHandler;
            ViewModel.RequestViewRefresh += ViewModelRequestViewRefreshHandler;
        }
예제 #16
0
        private void ViewLoadedHandler(object sender, RoutedEventArgs e)
        {
            ViewModel = DataContext as HelixWatch3DViewModel;

            if (ViewModel == null)
            {
                return;
            }

            var grid             = ViewModel.Element3DDictionary[HelixWatch3DViewModel.DefaultGridName];
            var axes             = ViewModel.Element3DDictionary[HelixWatch3DViewModel.DefaultAxesName];
            var directionalLight = ViewModel.Element3DDictionary[HelixWatch3DViewModel.DefaultLightName];
            var headlight        = ViewModel.Element3DDictionary[HelixWatch3DViewModel.HeadLightName];

            RegisterEventHandlers();
        }
예제 #17
0
        private void ViewLoadedHandler(object sender, RoutedEventArgs e)
        {
            viewModel = DataContext as HelixWatch3DViewModel;

            CompositionTarget.Rendering += CompositionTargetRenderingHandler;

            RegisterButtonHandlers();

            if (viewModel == null)
            {
                return;
            }

            viewModel.RequestAttachToScene += ViewModelRequestAttachToSceneHandler;
            viewModel.RequestCreateModels  += RequestCreateModelsHandler;
            viewModel.RequestViewRefresh   += RequestViewRefreshHandler;
        }
        public void ComputeBoundsForSelectedNodeGeometry_OnePointOneCubeSelected_BoundingBoxIsCorrect()
        {
            var pointA = InitializePointWithId("A");

            var builder = new MeshBuilder();

            builder.AddBox(new Vector3(1000000, 1000000, 1000000), 5, 5, 5, BoxFaces.All);
            var boxGeom = builder.ToMeshGeometry3D();
            var boxB    = new MeshGeometryModel3D()
            {
                Geometry = boxGeom,
                Name     = "B"
            };

            var bounds = HelixWatch3DViewModel.ComputeBoundsForGeometry(new GeometryModel3D[] { pointA, boxB });

            Assert.AreEqual(bounds.Minimum, pointA.Bounds().Minimum);
            Assert.AreEqual(bounds.Maximum, boxB.Bounds().Maximum);
        }
예제 #19
0
        private static void MakeStandaloneAndRun(string commandFilePath, out DynamoViewModel viewModel)
        {
            var model = Dynamo.Applications.StartupUtils.MakeModel(false);

            DynamoModel.RequestMigrationStatusDialog += MigrationStatusDialogRequested;

            viewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                CommandFilePath  = commandFilePath,
                DynamoModel      = model,
                Watch3DViewModel = HelixWatch3DViewModel.TryCreateHelixWatch3DViewModel(new Watch3DViewModelStartupParams(model), model.Logger)
            });

            var view = new DynamoView(viewModel);

            view.Loaded += (sender, args) => CloseMigrationWindow();

            var app = new Application();

            app.Run(view);

            DynamoModel.RequestMigrationStatusDialog -= MigrationStatusDialogRequested;
        }
예제 #20
0
        public void RunApplication(Application app)
        {
            try
            {
                DynamoModel.RequestMigrationStatusDialog += MigrationStatusDialogRequested;
                DynamoModel model;
                Dynamo.Applications.StartupUtils.ASMPreloadFailure += ASMPreloadFailureHandler;
                if (!String.IsNullOrEmpty(ASMPath))
                {
                    model = Dynamo.Applications.StartupUtils.MakeModel(false, ASMPath);
                }
                else
                {
                    model = Dynamo.Applications.StartupUtils.MakeModel(false);
                }

                viewModel = DynamoViewModel.Start(
                    new DynamoViewModel.StartConfiguration()
                {
                    CommandFilePath  = commandFilePath,
                    DynamoModel      = model,
                    Watch3DViewModel =
                        HelixWatch3DViewModel.TryCreateHelixWatch3DViewModel(
                            null,
                            new Watch3DViewModelStartupParams(model),
                            model.Logger),
                    ShowLogin = true
                });

                var view = new DynamoView(viewModel);
                view.Loaded += OnDynamoViewLoaded;

                app.Run(view);

                DynamoModel.RequestMigrationStatusDialog           -= MigrationStatusDialogRequested;
                Dynamo.Applications.StartupUtils.ASMPreloadFailure -= ASMPreloadFailureHandler;
            }

            catch (Exception e)
            {
                try
                {
#if DEBUG
                    // Display the recorded command XML when the crash happens,
                    // so that it maybe saved and re-run later
                    if (viewModel != null)
                    {
                        viewModel.SaveRecordedCommand.Execute(null);
                    }
#endif

                    DynamoModel.IsCrashing = true;
                    Dynamo.Logging.Analytics.TrackException(e, true);

                    if (viewModel != null)
                    {
                        // Show the unhandled exception dialog so user can copy the
                        // crash details and report the crash if she chooses to.
                        viewModel.Model.OnRequestsCrashPrompt(null,
                                                              new CrashPromptArgs(e.Message + "\n\n" + e.StackTrace));

                        // Give user a chance to save (but does not allow cancellation)
                        viewModel.Exit(allowCancel: false);
                    }
                    else
                    {
                        //show a message dialog box with the exception so the user
                        //can effectively report the issue.
                        var shortStackTrace = String.Join(Environment.NewLine, e.StackTrace.Split(Environment.NewLine.ToCharArray()).Take(10));

                        var result = MessageBox.Show($"{Resources.SandboxCrashMessage} {Environment.NewLine} {e.Message}" +
                                                     $"  {Environment.NewLine} {e.InnerException?.Message} {Environment.NewLine} {shortStackTrace} {Environment.NewLine} " +
                                                     Environment.NewLine + string.Format(Resources.SandboxBuildsPageDialogMessage, sandboxWikiPage),

                                                     "DynamoSandbox",
                                                     MessageBoxButton.YesNo, MessageBoxImage.Error);

                        if (result == MessageBoxResult.Yes)
                        {
                            System.Diagnostics.Process.Start(sandboxWikiPage);
                        }
                    }
                }
                catch
                {
                }

                Debug.WriteLine(e.Message);
                Debug.WriteLine(e.StackTrace);
            }
        }
        public void ComputeBoundsForSelectedNodeGeometry_NothingSelected_BoundingBoxAroundAllGeometry()
        {
            var bounds = HelixWatch3DViewModel.ComputeBoundsForGeometry(new GeometryModel3D[] { });

            Assert.AreEqual(bounds, HelixWatch3DViewModel.DefaultBounds);
        }