Пример #1
0
        public virtual void Start()
        {
            DynamoPathManager.Instance.InitializeCore(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            DynamoPathManager.PreloadAsmLibraries(DynamoPathManager.Instance);

            AppDomain.CurrentDomain.AssemblyResolve += AssemblyHelper.ResolveAssembly;
            CreateTemporaryFolder();

            // Setup Temp PreferenceSetting Location for testing
            PreferenceSettings.DynamoTestPath = Path.Combine(TempFolder, "UserPreferenceTest.xml");

            Model = DynamoModel.Start(
                new DynamoModel.StartConfiguration()
            {
                StartInTestMode = true
            });

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel = Model
            });

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

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
Пример #2
0
        private void RestartTestSetup()
        {
            // Shutdown Dynamo and restart it
            View.Close();
            View = null;

            if (ViewModel != null)
            {
                ViewModel.Model.ShutDown(false);
                ViewModel = null;
            }

            // Setup Temp PreferenceSetting Location for testing
            PreferenceSettings.DYNAMO_TEST_PATH = Path.Combine(TempFolder, "UserPreferenceTest.xml");

            Model = DynamoModel.Start(
                new DynamoModel.StartConfiguration()
            {
                StartInTestMode = true
            });

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel = Model
            });

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

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
Пример #3
0
        private void Init(IUpdateManager updateManager)
        {
            AppDomain.CurrentDomain.AssemblyResolve += AssemblyHelper.CurrentDomain_AssemblyResolve;

            Controller = new DynamoController("None", updateManager,
                                              new DefaultWatchHandler(), new PreferenceSettings());
            DynamoController.IsTestMode     = true;
            Controller.DynamoViewModel      = new DynamoViewModel(Controller, null);
            Controller.VisualizationManager = new VisualizationManager();

            //create the view
            Ui = new DynamoView {
                DataContext = Controller.DynamoViewModel
            };
            Vm = Controller.DynamoViewModel;
            Controller.UIDispatcher = Ui.Dispatcher;
            Ui.Show();

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());

            string tempPath = Path.GetTempPath();

            TempFolder = Path.Combine(tempPath, "dynamoTmp");

            if (!Directory.Exists(TempFolder))
            {
                Directory.CreateDirectory(TempFolder);
            }
            else
            {
                DynamoTestUI.EmptyTempFolder(TempFolder);
            }
        }
Пример #4
0
        private static void MakeStandaloneAndRun(string commandFilePath, out DynamoViewModel viewModel)
        {
            var geometryFactoryPath = string.Empty;
            var preloaderLocation   = string.Empty;

            PreloadShapeManager(ref geometryFactoryPath, ref preloaderLocation);

            DynamoModel.RequestMigrationStatusDialog += MigrationStatusDialogRequested;

            var model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                PathResolver        = new PathResolver(preloaderLocation),
                GeometryFactoryPath = geometryFactoryPath
            });

            viewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                CommandFilePath = commandFilePath,
                DynamoModel     = model
            });

            var view = new DynamoView(viewModel);

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

            var app = new Application();

            app.Run(view);

            DynamoModel.RequestMigrationStatusDialog -= MigrationStatusDialogRequested;
        }
Пример #5
0
        private void RestartTestSetup()
        {
            // Shutdown Dynamo and restart it
            Ui.Close();
            if (Controller != null)
            {
                Controller.ShutDown(false);
                Controller = null;
            }

            // Setup Temp PreferenceSetting Location for testing
            PreferenceSettings.DYNAMO_TEST_PATH = Path.Combine(TempFolder, "UserPreferenceTest.xml");

            Controller = DynamoController.MakeSandbox();
            DynamoController.IsTestMode = true;

            //create the view
            Ui                      = new DynamoView();
            Ui.DataContext          = Controller.DynamoViewModel;
            Vm                      = Controller.DynamoViewModel;
            Controller.UIDispatcher = Ui.Dispatcher;
            Ui.Show();

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
Пример #6
0
        private void Init()
        {
            AppDomain.CurrentDomain.AssemblyResolve += AssemblyHelper.ResolveAssembly;

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

            Model = DynamoModel.Start(
                new DynamoModel.StartConfiguration()
            {
                StartInTestMode = true,
                DynamoCorePath  = corePath
            });

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel = Model
            });

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

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
            CreateTemporaryFolder();
        }
Пример #7
0
        public static void Main(string[] args)
        {
            try
            {
                // Running Dynamo sandbox with a command file:
                // DynamoSandbox.exe /c "C:\file path\file.xml"
                //
                string commandFilePath = string.Empty;
                for (int i = 0; i < args.Length; ++i)
                {
                    // Looking for '/c'
                    string arg = args[i];
                    if (arg.Length != 2 || (arg[0] != '/'))
                    {
                        continue;
                    }

                    if (arg[1] == 'c' || (arg[1] == 'C'))
                    {
                        // If there's at least one more argument...
                        if (i < args.Length - 1)
                        {
                            commandFilePath = args[i + 1];
                        }
                    }
                }

                DynamoView.MakeSandboxAndRun(commandFilePath);
            }
            catch (Exception e)
            {
#if DEBUG
                // Display the recorded command XML when the crash happens, so that it maybe saved and re-run later
                dynSettings.Controller.DynamoViewModel.SaveRecordedCommand.Execute(null);
#endif

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

                    // Give user a chance to save (but does not allow cancellation)
                    bool allowCancellation = false;
                    dynSettings.Controller.DynamoViewModel.Exit(allowCancellation);
                }
                catch
                {
                }

                Debug.WriteLine(e.Message);
                Debug.WriteLine(e.StackTrace);
            }
            finally
            {
                ((DynamoLogger)dynSettings.DynamoLogger).Dispose();
            }
        }
Пример #8
0
        public virtual void Start()
        {
            var assemblyPath = Assembly.GetExecutingAssembly().Location;

            preloader = new Preloader(Path.GetDirectoryName(assemblyPath));
            preloader.Preload();
            CreateTemporaryFolder();

            // Setup Temp PreferenceSetting Location for testing
            PreferenceSettings.DynamoTestPath = Path.Combine(TempFolder, "UserPreferenceTest.xml");

            Model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                StartInTestMode     = true,
                GeometryFactoryPath = preloader.GeometryFactoryPath
            });

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel = Model
            });

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

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
Пример #9
0
        private void RestartTestSetupWithNewSettings(Dynamo.Models.DynamoModel.IStartConfiguration configuration, bool startInTestMode)
        {
            // Shutdown Dynamo and restart it
            View.Close();
            View = null;

            if (ViewModel != null)
            {
                var shutdownParams = new DynamoViewModel.ShutdownParams(
                    shutdownHost: false, allowCancellation: false);

                ViewModel.PerformShutdownSequence(shutdownParams);
                ViewModel = null;
            }

            Model = DynamoModel.Start(configuration);

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel = Model
            });

            var expectedState = startInTestMode
                ? DynamoModel.DynamoModelState.StartedUIless
                : DynamoModel.DynamoModelState.StartedUI;

            Assert.AreEqual(ViewModel.Model.State, expectedState);

            //create the view
            View = new DynamoView(ViewModel);
            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
Пример #10
0
        private static void MakeStandaloneAndRun(string commandFilePath, out DynamoViewModel viewModel)
        {
            var geometryFactoryPath = string.Empty;
            var preloaderLocation   = string.Empty;

            PreloadShapeManager(ref geometryFactoryPath, ref preloaderLocation);

            // TODO(PATHMANAGER): Do we really libg_xxx folder on resolution path?
            // If not, PathResolver will be completely redundant so please remove it.
            var pathResolver = new PathResolver(preloaderLocation);

            var model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                PathResolver        = pathResolver,
                GeometryFactoryPath = geometryFactoryPath
            });

            viewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                CommandFilePath = commandFilePath,
                DynamoModel     = model
            });

            var view = new DynamoView(viewModel);

            var app = new Application();

            app.Run(view);
        }
Пример #11
0
        protected virtual void StartDynamo(TestSessionConfiguration testConfig)
        {
            preloader = new Preloader(testConfig.DynamoCorePath, testConfig.RequestedLibraryVersion);
            preloader.Preload();

            Model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                StartInTestMode     = true,
                PathResolver        = pathResolver,
                GeometryFactoryPath = preloader.GeometryFactoryPath
            });

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel = Model
            });

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

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
Пример #12
0
        public static void Main(string[] args)
        {
            try
            {
                // Running Dynamo sandbox with a command file:
                // DynamoSandbox.exe /c "C:\file path\file.xml"
                //
                string commandFilePath = string.Empty;
                for (int i = 0; i < args.Length; ++i)
                {
                    // Looking for '/c'
                    string arg = args[i];
                    if (arg.Length != 2 || (arg[0] != '/'))
                    {
                        continue;
                    }

                    if (arg[1] == 'c' || (arg[1] == 'C'))
                    {
                        // If there's at least one more argument...
                        if (i < args.Length - 1)
                        {
                            commandFilePath = args[i + 1];
                        }
                    }
                }

                DynamoView.MakeSandboxAndRun(commandFilePath);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                Debug.WriteLine(e.StackTrace);
            }
        }
Пример #13
0
        public override void doIt(MArgList argl)
        {
            SubscribeAssemblyResolvingEvent();


            if (!String.IsNullOrEmpty(wpfTitle))
            {
                // Check the existence of the window
                int wndExist = int.Parse(MGlobal.executeCommandStringResult($@"format -stringArg `control -q -ex ""{wpfTitle}""` ""^1s"""));
                if (wndExist > 0)
                {
                    MGlobal.executeCommand($@"catch (`workspaceControl -e -visible true ""{hostTitle}""`);");
                    return;
                }
            }

            if (dynStartUp != null)
            {
                if (dynStartUp.DynView != null)
                {
                    if (dynStartUp.DynView.IsVisible)
                    {
                        MGlobal.displayWarning("Dynamo is already open");
                        return;
                    }
                    else
                    {
                        dynWnd.Show();
                    }
                }
            }
            else
            {
                newDmStartup();
                dynWnd = dynStartUp.DynView;
                // Create the window to dock
                dynWnd.Show();
                // Extract the window handle of the window we want to dock
                IntPtr mWindowHandle = new System.Windows.Interop.WindowInteropHelper(dynWnd).Handle;

                int width  = (int)dynWnd.Width;
                int height = (int)dynWnd.Height;

                var title = dynWnd.Title;
                wpfTitle  = title + " Internal";
                hostTitle = title;

                dynWnd.Title = wpfTitle;

                mayaWnd = new MForeignWindowWrapper(mWindowHandle, true);


                uint flagIdx = argl.flagIndex(flagName);
                if (flagIdx == MArgList.kInvalidArgIndex)
                {
                    // Create a workspace-control to wrap the native window wrapper, and use it as the parent of this WPF window
                    CreateWorkspaceControl(wpfTitle, hostTitle, width, height, false);
                }
            }
        }
Пример #14
0
 internal ViewLoadedParams(DynamoView dynamoV, DynamoViewModel dynamoVM) :
     base(dynamoVM.Model)
 {
     dynamoView      = dynamoV;
     dynamoViewModel = dynamoVM;
     dynamoMenu      = dynamoView.titleBar.ChildOfType <Menu>();
 }
Пример #15
0
        public void LibraryViewCustomizationServiceLoaded()
        {
            var model = GetModel();
            var vm    = DynamoViewModel.Start(new DynamoViewModel.StartConfiguration()
            {
                DynamoModel = model
            });
            var view = new DynamoView(vm);

            var customization = model.ExtensionManager.Service <ILibraryViewCustomization>();

            Assert.IsNotNull(customization);
            var eventanme  = "SpecChanged";
            var controller = new Mock <IEventController>();

            customization.SpecificationUpdated += (o, e) => controller.Object.RaiseEvent(eventanme);

            var sectiontext = "Y";

            customization.AddSections(new[] { "X", "Y", "Z" }.Select(s => new LayoutSection(s)));

            var spec = customization.GetSpecification();

            Assert.AreEqual(3, spec.sections.Count);

            LibraryViewCustomizationTests.VerifyAddElements(customization, sectiontext, 3);

            LibraryViewCustomizationTests.VerifyAddIncludeInfo(customization, "X", 3);

            controller.Verify(c => c.RaiseEvent(eventanme), Times.Exactly(3)); //Only notified twice
        }
Пример #16
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);
            }
        }
Пример #17
0
        public virtual void Start()
        {
            AppDomain.CurrentDomain.AssemblyResolve += AssemblyHelper.ResolveAssembly;

            string tempPath = Path.GetTempPath();

            TempFolder = Path.Combine(tempPath, "dynamoTmp");

            if (!Directory.Exists(TempFolder))
            {
                Directory.CreateDirectory(TempFolder);
            }
            else
            {
                EmptyTempFolder(TempFolder);
            }

            // Setup Temp PreferenceSetting Location for testing
            PreferenceSettings.DYNAMO_TEST_PATH = Path.Combine(TempFolder, "UserPreferenceTest.xml");

            Controller = DynamoController.MakeSandbox();
            DynamoController.IsTestMode = true;

            //create the view
            Ui                      = new DynamoView();
            Ui.DataContext          = Controller.DynamoViewModel;
            Vm                      = Controller.DynamoViewModel;
            Model                   = Controller.DynamoModel;
            Controller.UIDispatcher = Ui.Dispatcher;
            Ui.Show();

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
Пример #18
0
        private static void MakeStandaloneAndRun(string commandFilePath, ref DynamoViewModel viewModel)
        {
            DynamoPathManager.Instance.InitializeCore(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            DynamoPathManager.PreloadAsmLibraries(DynamoPathManager.Instance);

            var model = DynamoModel.Start(
                new DynamoModel.StartConfiguration()
            {
                Preferences = PreferenceSettings.Load()
            });

            viewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                CommandFilePath = commandFilePath,
                DynamoModel     = model
            });

            var view = new DynamoView(viewModel);

            var app = new Application();

            app.Run(view);
        }
Пример #19
0
        public void Start()
        {
            AppDomain.CurrentDomain.AssemblyResolve += AssemblyHelper.CurrentDomain_AssemblyResolve;

            Controller = DynamoController.MakeSandbox();

            //create the view
            Ui                      = new DynamoView();
            Ui.DataContext          = Controller.DynamoViewModel;
            Vm                      = Controller.DynamoViewModel;
            Model                   = Controller.DynamoModel;
            Controller.UIDispatcher = Ui.Dispatcher;
            Ui.Show();

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());

            string tempPath = Path.GetTempPath();

            TempFolder = Path.Combine(tempPath, "dynamoTmp");

            if (!Directory.Exists(TempFolder))
            {
                Directory.CreateDirectory(TempFolder);
            }
            else
            {
                EmptyTempFolder();
            }
        }
        public void Loaded(ViewLoadedParams p)
        {
            // Save a reference to your loaded parameters.
            // You'll need these later when you want to use
            // the supplied workspaces
            view       = p.DynamoWindow as DynamoView;
            ksMenuItem = new MenuItem {
                Header = "Keyboard Shortcuts"
            };



            #region Shortcuts

            ksMenuItem.Click += (sender, args) =>
            {
                var viewModel = new NodeShortcutsViewModel(p);
                var window    = new NodeShortcutsWindow()
                {
                    // Set the data context for the main grid in the window.
                    sp = { DataContext = viewModel },

                    // Set the owner of the window to the Dynamo window.
                    Owner = p.DynamoWindow
                };

                window.Left = window.Owner.Left + 400;
                window.Top  = window.Owner.Top + 200;

                // Show a modeless window.
                window.Show();
            };
            p.dynamoMenu.Items.Add(ksMenuItem);
            #endregion
        }
Пример #21
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);
            }
        }
Пример #23
0
        //todo delete me
        //public void SaveAllShortcuts()
        //{
        //    List<Shortcut> assignedShortcuts = NodeShortcuts.Where(s => String.IsNullOrEmpty(s.Keys)).ToList();

        //}

        public void Loaded(ViewLoadedParams p)
        {
            view          = p.DynamoWindow as DynamoView;
            view.KeyDown += View_KeyDown;
            view.KeyUp   += View_KeyUp;

            InitialSetOfAllNodeShortcuts();
            ReadFile();
        }
Пример #24
0
        private static DynamoView InitializeCoreView()
        {
            DynamoView dynamoView = new DynamoView(Model.ViewModel);

            dynamoView.Closed += OnDynamoViewClosed;
            dynamoView.Loaded += (o, e) => UpdateLibraryLayoutSpec();

            return(dynamoView);
        }
Пример #25
0
        internal ViewLoadedParams(DynamoView dynamoV, DynamoViewModel dynamoVM) :
            base(dynamoVM.Model)
        {
            dynamoView      = dynamoV;
            dynamoViewModel = dynamoVM;
            dynamoMenu      = dynamoView.titleBar.ChildOfType <Menu>();

            DynamoSelection.Instance.Selection.CollectionChanged += OnSelectionCollectionChanged;
        }
Пример #26
0
        /// <summary>
        ///     Setup the "Samples" sub-menu with contents of samples directory.
        /// </summary>
        /// <param name="bench">The bench where the UI will be loaded</param>
        public static void LoadSamplesMenu(DynamoView bench)
        {
            string directory   = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string samplesPath = Path.Combine(directory, "samples");

            if (Directory.Exists(samplesPath))
            {
                string[] dirPaths  = Directory.GetDirectories(samplesPath);
                string[] filePaths = Directory.GetFiles(samplesPath, "*.dyn");

                // handle top-level files
                if (filePaths.Any())
                {
                    foreach (string path in filePaths)
                    {
                        var item = new MenuItem
                        {
                            Header = Path.GetFileNameWithoutExtension(path),
                            Tag    = path
                        };
                        item.Click += OpenSample_Click;
                        bench.SamplesMenu.Items.Add(item);
                    }
                }

                // handle top-level dirs, TODO - factor out to a seperate function, make recusive
                if (dirPaths.Any())
                {
                    foreach (string dirPath in dirPaths)
                    {
                        var dirItem = new MenuItem
                        {
                            Header = Path.GetFileName(dirPath),
                            Tag    = Path.GetFileName(dirPath)
                        };

                        filePaths = Directory.GetFiles(dirPath, "*.dyn");
                        if (filePaths.Any())
                        {
                            foreach (string path in filePaths)
                            {
                                var item = new MenuItem
                                {
                                    Header = Path.GetFileNameWithoutExtension(path),
                                    Tag    = path
                                };
                                item.Click += OpenSample_Click;
                                dirItem.Items.Add(item);
                            }
                        }
                        bench.SamplesMenu.Items.Add(dirItem);
                    }
                    return;
                }
            }
            //this.fileMenu.Items.Remove(this.samplesMenu);
        }
        private static DynamoView InitializeCoreView()
        {
            IntPtr     mwHandle   = Autodesk.AdvanceSteel.CADAccess.CADUtilities.GetCADWindowHandle();
            DynamoView dynamoView = new DynamoView(dynamoViewModel);

            dynamoView.Loaded += (o, e) => UpdateLibraryLayoutSpec();


            return(dynamoView);
        }
Пример #28
0
        protected override void StartDynamo(TestSessionConfiguration testConfig)
        {
            base.StartDynamo(testConfig);

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

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
Пример #29
0
        /// <summary>
        /// Removes our custom events from Dynamo.
        /// </summary>
        public static void UnregisterEventHandlers()
        {
            DynamoView view = DynamoReadyParams.DynamoWindow as DynamoView;

            view.KeyDown -= RapidFireInstance.View_KeyDown;
            view.KeyUp   -= RapidFireInstance.View_KeyUp;

            DynamoReadyParams.CurrentWorkspaceChanged           -= OnCurrentWorkspaceChanged;
            DynamoReadyParams.CurrentWorkspaceModel.NodeAdded   -= OnNodeAdded;
            DynamoReadyParams.CurrentWorkspaceModel.NodeRemoved -= OnNodeRemoved;
        }
Пример #30
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;
            }
        }