Esempio n. 1
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 += (sender, args) => CloseMigrationWindow();

                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;
                    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);
            }
        }
Esempio n. 2
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);
        }
        public SearchView(SearchViewModel searchViewModel, DynamoViewModel dynamoViewModel)
        {
            viewModel = searchViewModel;
            this.dynamoViewModel = dynamoViewModel;

            DataContext = viewModel;
            InitializeComponent();
            Loaded += OnSearchViewLoaded;
            Unloaded += OnSearchViewUnloaded;

            SearchTextBox.IsVisibleChanged += delegate
            {
                if (SearchTextBox.IsVisible)
                {
                    this.viewModel.SearchCommand.Execute(null);
                    Keyboard.Focus(this.SearchTextBox);
                    var view = WpfUtilities.FindUpVisualTree<DynamoView>(this);
                    SearchTextBox.InputBindings.AddRange(view.InputBindings);
                    SearchTextBlock.Text = Properties.Resources.SearchTextBlockText;
                }
            };

            searchForegroundBrushNormal.Freeze();
            searchForegroundBrushHover.Freeze();
        }
 public InstalledPackagesViewModel(DynamoViewModel dynamoViewModel, PackageLoader model)
 {
     this.Model = model;
     this.dynamoViewModel = dynamoViewModel;
     
     InitializeLocalPackages();
 }
Esempio n. 5
0
 internal ViewLoadedParams(DynamoView dynamoV, DynamoViewModel dynamoVM) :
     base(dynamoVM.Model)
 {
     dynamoView = dynamoV;
     dynamoViewModel = dynamoVM;
     dynamoMenu = dynamoView.titleBar.ChildOfType<Menu>();
 }
Esempio n. 6
0
        internal ViewLoadedParams(DynamoView dynamoV, DynamoViewModel dynamoVM) :
            base(dynamoVM.Model)
        {
            dynamoView = dynamoV;
            dynamoViewModel = dynamoVM;
            dynamoMenu = dynamoView.titleBar.ChildOfType<Menu>();

            DynamoSelection.Instance.Selection.CollectionChanged += OnSelectionCollectionChanged;
        }
Esempio n. 7
0
        public DynamoView(DynamoViewModel dynamoViewModel)
        {
            // The user's choice to enable hardware acceleration is now saved in
            // the Dynamo preferences. It is set to true by default. 
            // When the view is constructed, we enable or disable hardware acceleration based on that preference. 
            //This preference is not exposed in the UI and can be used to debug hardware issues only
            // by modifying the preferences xml.
            RenderOptions.ProcessRenderMode = dynamoViewModel.Model.PreferenceSettings.UseHardwareAcceleration ? 
                RenderMode.Default : RenderMode.SoftwareOnly;
            
            this.dynamoViewModel = dynamoViewModel;
            this.dynamoViewModel.UIDispatcher = Dispatcher;            
            nodeViewCustomizationLibrary = new NodeViewCustomizationLibrary(this.dynamoViewModel.Model.Logger);

            DataContext = dynamoViewModel;
            Title = dynamoViewModel.BrandingResourceProvider.GetString(ResourceNames.MainWindow.Title);

            tabSlidingWindowStart = tabSlidingWindowEnd = 0;

            _timer = new Stopwatch();
            _timer.Start();

            InitializeComponent();

            ToggleIsUsageReportingApprovedCommand.ToolTip = string.Format(
                Wpf.Properties.Resources.DynamoViewSettingMenuEnableDataReportingTooltip,
                dynamoViewModel.BrandingResourceProvider.ProductName);

            Loaded += DynamoView_Loaded;
            Unloaded += DynamoView_Unloaded;

            SizeChanged += DynamoView_SizeChanged;
            LocationChanged += DynamoView_LocationChanged;

            // Check that preference bounds are actually within one
            // of the available monitors.
            if (CheckVirtualScreenSize())
            {
                Left = dynamoViewModel.Model.PreferenceSettings.WindowX;
                Top = dynamoViewModel.Model.PreferenceSettings.WindowY;
                Width = dynamoViewModel.Model.PreferenceSettings.WindowW;
                Height = dynamoViewModel.Model.PreferenceSettings.WindowH;
            }
            else
            {
                Left = 0;
                Top = 0;
                Width = 1024;
                Height = 768;
            }

            _workspaceResizeTimer.Tick += _resizeTimer_Tick;

            loginService = new LoginService(this, new System.Windows.Forms.WindowsFormsSynchronizationContext());
            if (dynamoViewModel.Model.AuthenticationManager.HasAuthProvider)
                dynamoViewModel.Model.AuthenticationManager.AuthProvider.RequestLogin += loginService.ShowLogin;
        }
Esempio n. 8
0
        public void Exit()
        {
            if (Ui.IsLoaded)
                Ui.Close();

            Controller.ShutDown(false);

            Controller = null;
            Vm = null;
            Ui = null;
            Model = null;

            GC.Collect();
        }
Esempio n. 9
0
        public override void SetupCustomUIElements(dynNodeView nodeUI)
        {
            this.dynamoViewModel = nodeUI.ViewModel.DynamoViewModel;

            //add a text box to the input grid of the control
            var rbTrue = new RadioButton();
            var rbFalse = new RadioButton();
            rbTrue.VerticalAlignment = VerticalAlignment.Center;
            rbFalse.VerticalAlignment = VerticalAlignment.Center;

            //use a unique name for the button group
            //so other instances of this element don't get confused
            string groupName = Guid.NewGuid().ToString();
            rbTrue.GroupName = groupName;
            rbFalse.GroupName = groupName;

            rbTrue.Content = "True";
            rbTrue.Padding = new Thickness(0,0,12,0);
            rbFalse.Content = "False";
            rbFalse.Padding = new Thickness(0);
            var wp = new WrapPanel()
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
                Margin = new Thickness(10,5,10,0),
                Orientation = Orientation.Horizontal
            };

            wp.Children.Add(rbTrue);
            wp.Children.Add(rbFalse);
            nodeUI.inputGrid.Children.Add(wp);

            //rbFalse.IsChecked = true;
            rbTrue.Checked += OnRadioButtonClicked;
            rbFalse.Checked += OnRadioButtonClicked;

            rbFalse.DataContext = this;
            rbTrue.DataContext = this;

            var rbTrueBinding = new Binding("Value") { Mode = BindingMode.TwoWay, };
            rbTrue.SetBinding(ToggleButton.IsCheckedProperty, rbTrueBinding);

            var rbFalseBinding = new Binding("Value")
            {
                Mode = BindingMode.TwoWay,
                Converter = new InverseBoolDisplay()
            };
            rbFalse.SetBinding(ToggleButton.IsCheckedProperty, rbFalseBinding);
        }
        /// <summary>
        /// Create CodeCOmpletionEditor with NodeViewModel
        /// </summary>
        /// <param name="nodeView"></param>
        public CodeCompletionEditor(NodeView nodeView)
        {
            InitializeComponent();

            nodeView.Unloaded += (obj, args) => IsDisposed = true;
            this.nodeViewModel = nodeView.ViewModel;
            this.dynamoViewModel = nodeViewModel.DynamoViewModel;
            this.DataContext = nodeViewModel.NodeModel;
            this.InnerTextEditor.TextChanged += OnTextChanged;
            this.InnerTextEditor.TextArea.LostFocus += OnTextAreaLostFocus;
            this.InnerTextEditor.TextArea.TextEntering += OnTextAreaTextEntering;
            this.InnerTextEditor.TextArea.TextEntered += OnTextAreaTextEntered;

            CodeHighlightingRuleFactory.CreateHighlightingRules(InnerTextEditor, dynamoViewModel.EngineController);
        }
Esempio n. 11
0
        public PackageViewModel(DynamoViewModel dynamoViewModel, Package model)
        {
            this.dynamoViewModel = dynamoViewModel;
            this.Model = model;

            ToggleTypesVisibleInManagerCommand = new DelegateCommand(ToggleTypesVisibleInManager, CanToggleTypesVisibleInManager);
            GetLatestVersionCommand = new DelegateCommand(GetLatestVersion, CanGetLatestVersion);
            PublishNewPackageVersionCommand = new DelegateCommand(PublishNewPackageVersion, CanPublishNewPackageVersion);
            PublishNewPackageCommand = new DelegateCommand(PublishNewPackage, CanPublishNewPackage);
            UninstallCommand = new DelegateCommand(Uninstall, CanUninstall);
            DeprecateCommand = new DelegateCommand(this.Deprecate, CanDeprecate);
            UndeprecateCommand = new DelegateCommand(this.Undeprecate, CanUndeprecate);

            this.dynamoViewModel.Model.NodeAdded += (node) => UninstallCommand.RaiseCanExecuteChanged();
            this.dynamoViewModel.Model.NodeDeleted += (node) => UninstallCommand.RaiseCanExecuteChanged();
            this.dynamoViewModel.Model.WorkspaceHidden += (ws) => UninstallCommand.RaiseCanExecuteChanged();
            this.dynamoViewModel.Model.Workspaces.CollectionChanged += (sender, args) => UninstallCommand.RaiseCanExecuteChanged();
        }
        public SearchView(SearchViewModel searchViewModel, DynamoViewModel dynamoViewModel)
        {
            viewModel = searchViewModel;
            this.dynamoViewModel = dynamoViewModel;

            DataContext = viewModel;
            InitializeComponent();
            Loaded += OnSearchViewLoaded;
            Unloaded += OnSearchViewUnloaded;

            SearchTextBox.IsVisibleChanged += delegate
            {
                if (!SearchTextBox.IsVisible) return;

                this.viewModel.SearchCommand.Execute(null);
                Keyboard.Focus(SearchTextBox);
                SearchTextBlock.Text = Properties.Resources.SearchTextBlockText;
            };
        }
Esempio n. 13
0
        public SearchView(SearchViewModel searchViewModel, DynamoViewModel dynamoViewModel)
        {
            this.viewModel = searchViewModel;
            this.dynamoViewModel = dynamoViewModel;

            InitializeComponent();
            Loaded += OnSearchViewLoaded;
            Unloaded += OnSearchViewUnloaded;

            SearchTextBox.IsVisibleChanged += delegate
            {
                if (SearchTextBox.IsVisible)
                {
                    this.viewModel.SearchCommand.Execute(null);
                    Keyboard.Focus(this.SearchTextBox);
                    var view = WPF.FindUpVisualTree<DynamoView>(this);
                    SearchTextBox.InputBindings.AddRange(view.InputBindings);
                }
            };
        }
Esempio n. 14
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
                });

            var view = new DynamoView(viewModel);
            view.Loaded += (sender, args) => CloseMigrationWindow();

            var app = new Application();
            app.Run(view);

            DynamoModel.RequestMigrationStatusDialog -= MigrationStatusDialogRequested;
        }
Esempio n. 15
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            HandleDebug(commandData);
            
            InitializeCore(commandData);

            try
            {
                IdlePromise.ExecuteOnIdleAsync(
                    delegate
                    {
                        // create core data models
                        revitDynamoModel = InitializeCoreModel(commandData);
                        dynamoViewModel = InitializeCoreViewModel(revitDynamoModel);

                        // show the window
                        InitializeCoreView().Show();

                        TryOpenWorkspaceInCommandData(commandData);
                        SubscribeViewActivating(commandData);
                    });

                // Disable the Dynamo button to prevent a re-run
                DynamoRevitApp.DynamoButton.Enabled = false;
            }
            catch (Exception ex)
            {
                // notify instrumentation
                InstrumentationLogger.LogException(ex);
                StabilityTracking.GetInstance().NotifyCrash();

                MessageBox.Show(ex.ToString());

                DynamoRevitApp.DynamoButton.Enabled = true;

                return Result.Failed;
            }

            return Result.Succeeded;
        }
Esempio n. 16
0
        public DynamoView(DynamoViewModel dynamoViewModel)
        {
            this.dynamoViewModel = dynamoViewModel;
            this.dynamoViewModel.UIDispatcher = this.Dispatcher;

            this.DataContext = dynamoViewModel;

            tabSlidingWindowStart = tabSlidingWindowEnd = 0;            

            _timer = new Stopwatch();
            _timer.Start();

            InitializeComponent();

            this.Loaded += DynamoView_Loaded;
            this.Unloaded += DynamoView_Unloaded;

            this.SizeChanged += DynamoView_SizeChanged;
            this.LocationChanged += DynamoView_LocationChanged;

            // Check that preference bounds are actually within one
            // of the available monitors.
            if (CheckVirtualScreenSize())
            {
                Left = dynamoViewModel.Model.PreferenceSettings.WindowX;
                Top = dynamoViewModel.Model.PreferenceSettings.WindowY;
                Width = dynamoViewModel.Model.PreferenceSettings.WindowW;
                Height = dynamoViewModel.Model.PreferenceSettings.WindowH;
            }
            else
            {
                Left = 0;
                Top = 0;
                Width = 1024;
                Height = 768;
            }

            _workspaceResizeTimer.Tick += _resizeTimer_Tick;
        }
Esempio n. 17
0
        public EditWindow(DynamoViewModel dynamoViewModel,
            bool updateSourceOnTextChange = false)
        {
            InitializeComponent();
            this.dynamoViewModel = dynamoViewModel;

            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            this.editText.Focus();

            // do not accept value if user closes 
            this.Closing += (sender, args) => this.DialogResult = false;

            if (false != updateSourceOnTextChange)
            {
                this.editText.TextChanged += delegate
                {
                    var expr = editText.GetBindingExpression(TextBox.TextProperty);
                    if (expr != null)
                        expr.UpdateSource();
                };
            }
        }
Esempio n. 18
0
        public CodeBlockEditor(NodeView nodeView): this()
        {
           
            this.nodeViewModel = nodeView.ViewModel;
            this.dynamoViewModel = nodeViewModel.DynamoViewModel;
            this.DataContext = nodeViewModel.NodeModel;
            this.nodeModel = nodeViewModel.NodeModel as CodeBlockNodeModel;
            
            if (nodeModel == null)
            {
                throw new InvalidOperationException(
                    "Should not be used for nodes other than code block");
            }

            // Determines if this editor is created for a new code block node.
            // In cases like an undo/redo operation, the editor is created for 
            // an existing code block node.
            createdForNewCodeBlock = string.IsNullOrEmpty(nodeModel.Code);

            // Register text editing events            
            this.InnerTextEditor.TextChanged += InnerTextEditor_TextChanged;
            this.InnerTextEditor.TextArea.LostFocus += TextArea_LostFocus;
            nodeView.Unloaded += (obj, args) => isDisposed = true;

            // the code block should not be in focus upon undo/redo actions on node
            if (this.nodeModel.ShouldFocus)
            {
                this.Loaded += (obj, args) => this.InnerTextEditor.TextArea.Focus();
            }

            // Register auto-completion callbacks
            this.InnerTextEditor.TextArea.TextEntering += OnTextAreaTextEntering;
            this.InnerTextEditor.TextArea.TextEntered += OnTextAreaTextEntered;

            InitializeSyntaxHighlighter();
        }
Esempio n. 19
0
 public MutatorDriver(DynamoViewModel dynamoViewModel)
 {
     this.dynamoViewModel = dynamoViewModel;
 }
Esempio n. 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);
            }
        }
Esempio n. 21
0
        public override bool RunTest(NodeModel node, EngineController engine, StreamWriter writer)
        {
            bool pass = false;

            writer.WriteLine("### - Beginning readout");

            var valueMap = new Dictionary <Guid, String>();

            if (node.OutPorts.Count > 0)
            {
                Guid   guid = node.GUID;
                Object data = node.GetValue(0, engine).Data;
                String val  = data != null?data.ToString() : "null";

                valueMap.Add(guid, val);
                writer.WriteLine(guid + " :: " + val);
                writer.Flush();
            }

            writer.WriteLine("### - Readout complete");
            writer.Flush();

            writer.WriteLine("### - Beginning delete");
            writer.WriteLine("### - Deletion target: " + node.GUID);

            int numberOfUndosNeeded = Mutate(node);

            Thread.Sleep(100);

            writer.WriteLine("### - delete complete");
            writer.Flush();

            writer.WriteLine("### - Beginning re-exec");

            DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
            {
                DynamoModel.RunCancelCommand runCancel =
                    new DynamoModel.RunCancelCommand(false, false);

                DynamoViewModel.ExecuteCommand(runCancel);
            }));
            Thread.Sleep(100);

            writer.WriteLine("### - re-exec complete");
            writer.Flush();

            writer.WriteLine("### - Beginning undo");

            for (int iUndo = 0; iUndo < numberOfUndosNeeded; iUndo++)
            {
                DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
                {
                    DynamoModel.UndoRedoCommand undoCommand =
                        new DynamoModel.UndoRedoCommand(
                            DynamoModel.UndoRedoCommand.Operation.Undo);

                    DynamoViewModel.ExecuteCommand(undoCommand);
                }));
            }
            Thread.Sleep(100);

            writer.WriteLine("### - undo complete");
            writer.Flush();

            writer.WriteLine("### - Beginning re-exec");

            DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
            {
                DynamoModel.RunCancelCommand runCancel =
                    new DynamoModel.RunCancelCommand(false, false);

                DynamoViewModel.ExecuteCommand(runCancel);
            }));
            Thread.Sleep(10);
            while (!DynamoViewModel.HomeSpace.RunEnabled)
            {
                Thread.Sleep(10);
            }

            writer.WriteLine("### - re-exec complete");
            writer.Flush();

            writer.WriteLine("### - Beginning readback");

            if (node.OutPorts.Count > 0)
            {
                try
                {
                    String valmap  = valueMap[node.GUID].ToString();
                    Object data    = node.GetValue(0, engine).Data;
                    String nodeVal = data != null?data.ToString() : "null";

                    if (valmap != nodeVal)
                    {
                        writer.WriteLine("!!!!!!!!!!! Read-back failed");
                        writer.WriteLine(node.GUID);

                        writer.WriteLine("Was: " + nodeVal);
                        writer.WriteLine("Should have been: " + valmap);
                        writer.Flush();
                        return(pass);
                    }
                }
                catch (Exception)
                {
                    writer.WriteLine("!!!!!!!!!!! Read-back failed");
                    writer.Flush();
                    return(pass);
                }
            }

            return(pass = true);
        }
Esempio n. 22
0
        public static PublishPackageViewModel FromLocalPackage(DynamoViewModel dynamoViewModel, Package l)
        {
            var defs = new List <CustomNodeDefinition>();

            foreach (var x in l.LoadedCustomNodes)
            {
                CustomNodeDefinition def;
                if (dynamoViewModel.Model.CustomNodeManager.TryGetFunctionDefinition(
                        x.FunctionId,
                        DynamoModel.IsTestMode,
                        out def))
                {
                    defs.Add(def);
                }
            }

            var vm = new PublishPackageViewModel(dynamoViewModel)
            {
                Group       = l.Group,
                Description = l.Description,
                Keywords    = l.Keywords != null?String.Join(" ", l.Keywords) : "",
                                  CustomNodeDefinitions = defs,
                                  Name          = l.Name,
                                  RepositoryUrl = l.RepositoryUrl ?? "",
                                  SiteUrl       = l.SiteUrl ?? "",
                                  Package       = l,
                                  License       = l.License
            };

            // add additional files
            l.EnumerateAdditionalFiles();
            foreach (var file in l.AdditionalFiles)
            {
                vm.AdditionalFiles.Add(file.Model.FullName);
            }

            var nodeLibraryNames = l.Header.node_libraries;

            // load assemblies into reflection only context
            foreach (var file in l.EnumerateAssemblyFilesInBinDirectory())
            {
                Assembly assem;
                var      result = PackageLoader.TryReflectionOnlyLoadFrom(file, out assem);

                if (result)
                {
                    var isNodeLibrary = nodeLibraryNames == null || nodeLibraryNames.Contains(assem.FullName);
                    vm.Assemblies.Add(new  PackageAssembly()
                    {
                        IsNodeLibrary = isNodeLibrary,
                        Assembly      = assem
                    });
                }
                else
                {
                    // if it's not a .NET assembly, we load it as an additional file
                    vm.AdditionalFiles.Add(file);
                }
            }

            if (l.VersionName == null)
            {
                return(vm);
            }

            var parts = l.VersionName.Split('.');

            if (parts.Count() != 3)
            {
                return(vm);
            }

            vm.MajorVersion = parts[0];
            vm.MinorVersion = parts[1];
            vm.BuildVersion = parts[2];
            return(vm);
        }
Esempio n. 23
0
        public override bool RunTest(NodeModel node, EngineController engine, StreamWriter writer)
        {
            bool pass = false;

            var nodes = DynamoViewModel.Model.CurrentWorkspace.Nodes;

            if (nodes.Count() == 0)
            {
                return(true);
            }

            int nodesCountBeforeDelete = nodes.Count();

            writer.WriteLine("### - Beginning readout");

            writer.WriteLine("### - Beginning delete");
            writer.WriteLine("### - Deletion target: " + node.GUID);

            int numberOfUndosNeeded = Mutate(node);

            Thread.Sleep(0);

            writer.WriteLine("### - delete complete");
            writer.Flush();

            writer.WriteLine("### - Beginning re-exec");

            DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
            {
                DynamoModel.RunCancelCommand runCancel =
                    new DynamoModel.RunCancelCommand(false, false);

                DynamoViewModel.ExecuteCommand(runCancel);
            }));
            Thread.Sleep(0);

            writer.WriteLine("### - re-exec complete");
            writer.Flush();

            writer.WriteLine("### - Beginning undo");

            int nodesCountAfterDelete = DynamoViewModel.Model.CurrentWorkspace.Nodes.Count();

            if (nodesCountBeforeDelete > nodesCountAfterDelete)
            {
                for (int iUndo = 0; iUndo < numberOfUndosNeeded; iUndo++)
                {
                    DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
                    {
                        DynamoModel.UndoRedoCommand undoCommand =
                            new DynamoModel.UndoRedoCommand(
                                DynamoModel.UndoRedoCommand.Operation.Undo);

                        DynamoViewModel.ExecuteCommand(undoCommand);
                    }));
                    Thread.Sleep(0);
                }
                writer.WriteLine("### - undo complete");
                writer.Flush();

                writer.WriteLine("### - Beginning re-exec");

                ExecuteAndWait();
                writer.WriteLine("### - re-exec complete");
                writer.Flush();

                int nodesCountAfterUbdo = DynamoViewModel.Model.CurrentWorkspace.Nodes.Count();
                if (nodesCountBeforeDelete == nodesCountAfterUbdo)
                {
                    writer.WriteLine("### - Node was restored");
                }
                else
                {
                    writer.WriteLine("### - Node wasn't restored");
                    return(pass);
                }
                writer.Flush();
            }
            else
            {
                writer.WriteLine("### - Error removing a node");
                writer.Flush();
                return(pass);
            }
            return(pass = true);
        }
Esempio n. 24
0
 public StringInputMutator(DynamoViewModel viewModel)
     : base(viewModel)
 {
 }
Esempio n. 25
0
        private void DynamoView_Loaded(object sender, EventArgs e)
        {
            // Do an initial load of the cursor collection
            CursorLibrary.GetCursor(CursorSet.ArcSelect);

            //Backing up IsFirstRun to determine whether to show Gallery
            var isFirstRun = dynamoViewModel.Model.PreferenceSettings.IsFirstRun;
            // If first run, Collect Info Prompt will appear
            UsageReportingManager.Instance.CheckIsFirstRun(this, dynamoViewModel.BrandingResourceProvider);

            WorkspaceTabs.SelectedIndex = 0;
            dynamoViewModel = (DataContext as DynamoViewModel);
            dynamoViewModel.Model.RequestLayoutUpdate += vm_RequestLayoutUpdate;
            dynamoViewModel.RequestViewOperation += DynamoViewModelRequestViewOperation;
            dynamoViewModel.PostUiActivationCommand.Execute(null);

            _timer.Stop();
            dynamoViewModel.Model.Logger.Log(String.Format(Wpf.Properties.Resources.MessageLoadingTime,
                                                                     _timer.Elapsed, dynamoViewModel.BrandingResourceProvider.ProductName));
            InitializeLogin();
            InitializeShortcutBar();
            InitializeStartPage(isFirstRun);

#if !__NO_SAMPLES_MENU
            LoadSamplesMenu();
#endif
            #region Search initialization

            var search = new SearchView(
                dynamoViewModel.SearchViewModel,
                dynamoViewModel);
            sidebarGrid.Children.Add(search);
            dynamoViewModel.SearchViewModel.Visible = true;

            #endregion

            #region Package manager

            dynamoViewModel.RequestPackagePublishDialog += DynamoViewModelRequestRequestPackageManagerPublish;
            dynamoViewModel.RequestManagePackagesDialog += DynamoViewModelRequestShowInstalledPackages;
            dynamoViewModel.RequestPackageManagerSearchDialog += DynamoViewModelRequestShowPackageManagerSearch;
            dynamoViewModel.RequestPackagePathsDialog += DynamoViewModelRequestPackagePaths;

            #endregion

            #region Node view injection

            // scan for node view overrides



            #endregion

            //FUNCTION NAME PROMPT
            dynamoViewModel.Model.RequestsFunctionNamePrompt += DynamoViewModelRequestsFunctionNamePrompt;

            //Preset Name Prompt
            dynamoViewModel.Model.RequestPresetsNamePrompt += DynamoViewModelRequestPresetNamePrompt;
            dynamoViewModel.RequestPresetsWarningPrompt += DynamoViewModelRequestPresetWarningPrompt;

            dynamoViewModel.RequestClose += DynamoViewModelRequestClose;
            dynamoViewModel.RequestSaveImage += DynamoViewModelRequestSaveImage;
            dynamoViewModel.SidebarClosed += DynamoViewModelSidebarClosed;

            dynamoViewModel.Model.RequestsCrashPrompt += Controller_RequestsCrashPrompt;
            dynamoViewModel.Model.RequestTaskDialog += Controller_RequestTaskDialog;

            DynamoSelection.Instance.Selection.CollectionChanged += Selection_CollectionChanged;

            dynamoViewModel.RequestUserSaveWorkflow += DynamoViewModelRequestUserSaveWorkflow;

            dynamoViewModel.Model.ClipBoard.CollectionChanged += ClipBoard_CollectionChanged;

            //ABOUT WINDOW
            dynamoViewModel.RequestAboutWindow += DynamoViewModelRequestAboutWindow;

            //SHOW or HIDE GALLERY
            dynamoViewModel.RequestShowHideGallery += DynamoViewModelRequestShowHideGallery;

            LoadNodeViewCustomizations();
            SubscribeNodeViewCustomizationEvents();

            // Kick start the automation run, if possible.
            dynamoViewModel.BeginCommandPlayback(this);

            var loadedParams = new ViewLoadedParams(this, dynamoViewModel);

            foreach (var ext in viewExtensionManager.ViewExtensions)
            {
                try
                {
                    ext.Loaded(loadedParams);
                }
                catch (Exception exc)
                {
                    Log(ext.Name + ": " + exc.Message);
                }
            }

            BackgroundPreview = new Watch3DView {Name = BackgroundPreviewName};
            background_grid.Children.Add(BackgroundPreview);
            BackgroundPreview.DataContext = dynamoViewModel.BackgroundPreviewViewModel;
            BackgroundPreview.Margin = new System.Windows.Thickness(0,20,0,0);
            var vizBinding = new Binding
            {
                Source = dynamoViewModel.BackgroundPreviewViewModel,
                Path = new PropertyPath("Active"),
                Mode = BindingMode.TwoWay,
                Converter = new BooleanToVisibilityConverter()
            };
            BackgroundPreview.SetBinding(VisibilityProperty, vizBinding);
        }
Esempio n. 26
0
 public DoubleSliderMutator(DynamoViewModel viewModel)
     : base(viewModel)
 {
 }
Esempio n. 27
0
        internal StartPageViewModel(DynamoViewModel dynamoViewModel)
        {
            this.DynamoViewModel = dynamoViewModel;

            this.recentFiles = new ObservableCollection <StartPageListItem>();
            sampleFiles      = new ObservableCollection <SampleFileEntry>();


            #region File Operations

            fileOperations.Add(new StartPageListItem(Resources.StartPageNewFile, "icon-new.png")
            {
                ContextData = ButtonNames.NewWorkspace,
                ClickAction = StartPageListItem.Action.RegularCommand
            });

            fileOperations.Add(new StartPageListItem(Resources.StartPageNewCustomNode, "icon-customnode.png")
            {
                ContextData = ButtonNames.NewCustomNodeWorkspace,
                ClickAction = StartPageListItem.Action.RegularCommand
            });

            fileOperations.Add(new StartPageListItem(Resources.StartPageOpenFile, "icon-open.png")
            {
                ContextData = ButtonNames.OpenWorkspace,
                ClickAction = StartPageListItem.Action.RegularCommand
            });

            #endregion

            #region Community Links

            communityLinks.Add(new StartPageListItem(Resources.StartPageDiscussionForum, "icon-discussion.png")
            {
                ContextData = Configurations.DynamoBimForum,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            communityLinks.Add(new StartPageListItem(Resources.StartPageVisitDynamoBim, "icon-dynamobim.png")
            {
                ContextData = Configurations.DynamoSiteLink,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            #endregion

            #region Reference List

            references.Add(new StartPageListItem(Resources.StartPageAdvancedTutorials, "icon-reference.png")
            {
                ContextData = Configurations.DynamoAdvancedTutorials,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            references.Add(new StartPageListItem(Resources.StartPageVideoTutorials, "icon-video.png")
            {
                ContextData = Configurations.DynamoVideoTutorials,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            references.Add(new StartPageListItem(Resources.StartPageMoreSamples, "icons-more-samples.png")
            {
                ContextData = Configurations.DynamoMoreSamples,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            #endregion

            #region Contribution Links

            contributeLinks.Add(new StartPageListItem(Resources.StartPageGithubRepository, "icon-github.png")
            {
                ContextData = Configurations.GitHubDynamoLink,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            contributeLinks.Add(new StartPageListItem(Resources.StartPageSendIssues, "icon-issues.png")
            {
                ContextData = Configurations.GitHubBugReportingLink,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            #endregion

            var dvm = this.DynamoViewModel;
            RefreshRecentFileList(dvm.RecentFiles);
            dvm.RecentFiles.CollectionChanged += OnRecentFilesChanged;
        }
Esempio n. 28
0
        public static void Main(string[] args)
        {
            DynamoViewModel viewModel = null;

            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];
                        }
                    }
                }

                MakeStandaloneAndRun(commandFilePath, ref viewModel);
            }
            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;
                    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);
            }
        }
Esempio n. 29
0
        internal StartPageViewModel(DynamoViewModel dynamoViewModel)
        {
            this.DynamoViewModel = dynamoViewModel;

            this.recentFiles = new ObservableCollection <StartPageListItem>();
            sampleFiles      = new ObservableCollection <SampleFileEntry>();


            #region File Operations

            fileOperations.Add(new StartPageListItem("New", "icon-new.png")
            {
                ContextData = ButtonNames.NewWorkspace,
                ClickAction = StartPageListItem.Action.RegularCommand
            });

            fileOperations.Add(new StartPageListItem("Open", "icon-open.png")
            {
                ContextData = ButtonNames.OpenWorkspace,
                ClickAction = StartPageListItem.Action.RegularCommand
            });

            #endregion

            #region Community Links

            communityLinks.Add(new StartPageListItem("Discussion forum", "icon-discussion.png")
            {
                ContextData = Configurations.DynamoBimForum,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            communityLinks.Add(new StartPageListItem("Visit www.dynamobim.org", "icon-dynamobim.png")
            {
                ContextData = Configurations.DynamoSiteLink,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            #endregion

            #region Reference List

            references.Add(new StartPageListItem("Written Tutorials", "icon-reference.png")
            {
                ContextData = Configurations.DynamoWrittenTutorials,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            references.Add(new StartPageListItem("Video Tutorials", "icon-video.png")
            {
                ContextData = Configurations.DynamoVideoTutorials,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            references.Add(new StartPageListItem("More Samples", "icons-more-samples.png")
            {
                ContextData = Configurations.DynamoMoreSamples,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            #endregion

            #region Contribution Links

            contributeLinks.Add(new StartPageListItem("Github repository", "icon-github.png")
            {
                ContextData = Configurations.GitHubDynamoLink,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            contributeLinks.Add(new StartPageListItem("Send issues", "icon-issues.png")
            {
                ContextData = Configurations.GitHubBugReportingLink,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            #endregion

            var dvm = this.DynamoViewModel;
            RefreshRecentFileList(dvm.RecentFiles);
            dvm.RecentFiles.CollectionChanged += OnRecentFilesChanged;
        }
Esempio n. 30
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 umConfig = UpdateManagerConfiguration.GetSettings(new SandboxLookUp());
            Debug.Assert(umConfig.DynamoLookUp != null);

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

            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;
        }
Esempio n. 31
0
 public ListMutator(DynamoViewModel viewModel)
     : base(viewModel)
 {
 }
Esempio n. 32
0
 public CopyNodeMutator(DynamoViewModel viewModel)
     : base(viewModel)
 {
 }
Esempio n. 33
0
 public static void DestroyInstance()
 {
     instance        = null;
     dynamoViewModel = null;
 }
Esempio n. 34
0
        public override bool RunTest(NodeModel node, EngineController engine, StreamWriter writer)
        {
            const bool pass = false;

            var nodes = DynamoViewModel.Model.CurrentWorkspace.Nodes;

            if (nodes.Count() == 0)
            {
                return(pass);
            }

            int nodesCountBeforeCopying = nodes.Count();

            int numberOfUndosNeeded = this.Mutate(node);

            Thread.Sleep(10);

            writer.WriteLine("### - Beginning undo");
            for (int iUndo = 0; iUndo < numberOfUndosNeeded; iUndo++)
            {
                DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
                {
                    DynamoModel.UndoRedoCommand undoCommand =
                        new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);
                    DynamoViewModel.ExecuteCommand(undoCommand);
                }));
                Thread.Sleep(0);
            }
            writer.WriteLine("### - undo complete");
            writer.Flush();

            ExecuteAndWait();

            writer.WriteLine("### - Beginning test of CopyNode");
            if (node.OutPorts.Count > 0)
            {
                try
                {
                    int nodesCountAfterCopying = DynamoViewModel.Model.CurrentWorkspace.Nodes.Count();

                    if (nodesCountBeforeCopying != nodesCountAfterCopying)
                    {
                        writer.WriteLine("!!!!!!!!!!! - test of CopyNode is failed");
                        writer.WriteLine(node.GUID);

                        writer.WriteLine("Was: " + nodesCountAfterCopying);
                        writer.WriteLine("Should have been: " + nodesCountBeforeCopying);
                        writer.Flush();
                        return(pass);
                    }
                    else
                    {
                        writer.WriteLine("### - test of CopyNode is passed");
                        writer.Flush();
                    }
                }
                catch (Exception)
                {
                    writer.WriteLine("!!!!!!!!!!! - test of CopyNode is failed");
                    writer.Flush();
                    return(pass);
                }
            }
            writer.WriteLine("### - test of CopyNode complete");
            writer.Flush();

            return(true);
        }
Esempio n. 35
0
        public DynamoView(DynamoViewModel dynamoViewModel)
        {
            // The user's choice to enable hardware acceleration is now saved in
            // the Dynamo preferences. It is set to true by default. 
            // When the view is constructed, we enable or disable hardware acceleration based on that preference. 
            //This preference is not exposed in the UI and can be used to debug hardware issues only
            // by modifying the preferences xml.
            RenderOptions.ProcessRenderMode = dynamoViewModel.Model.PreferenceSettings.UseHardwareAcceleration ? 
                RenderMode.Default : RenderMode.SoftwareOnly;
            
            this.dynamoViewModel = dynamoViewModel;
            this.dynamoViewModel.UIDispatcher = Dispatcher;            
            nodeViewCustomizationLibrary = new NodeViewCustomizationLibrary(this.dynamoViewModel.Model.Logger);

            DataContext = dynamoViewModel;
            Title = dynamoViewModel.BrandingResourceProvider.GetString(ResourceNames.MainWindow.Title);

            tabSlidingWindowStart = tabSlidingWindowEnd = 0;

            _timer = new Stopwatch();
            _timer.Start();

            InitializeComponent();

            ToggleIsUsageReportingApprovedCommand.ToolTip = string.Format(
                Wpf.Properties.Resources.DynamoViewSettingMenuEnableDataReportingTooltip,
                dynamoViewModel.BrandingResourceProvider.ProductName);

            Loaded += DynamoView_Loaded;
            Unloaded += DynamoView_Unloaded;

            SizeChanged += DynamoView_SizeChanged;
            LocationChanged += DynamoView_LocationChanged;

            // Check that preference bounds are actually within one
            // of the available monitors.
            if (CheckVirtualScreenSize())
            {
                Left = dynamoViewModel.Model.PreferenceSettings.WindowX;
                Top = dynamoViewModel.Model.PreferenceSettings.WindowY;
                Width = dynamoViewModel.Model.PreferenceSettings.WindowW;
                Height = dynamoViewModel.Model.PreferenceSettings.WindowH;
            }
            else
            {
                Left = 0;
                Top = 0;
                Width = 1024;
                Height = 768;
            }

            _workspaceResizeTimer.Tick += _resizeTimer_Tick;

            if (dynamoViewModel.Model.AuthenticationManager.HasAuthProvider)
            {
                loginService = new LoginService(this, new System.Windows.Forms.WindowsFormsSynchronizationContext());
                dynamoViewModel.Model.AuthenticationManager.AuthProvider.RequestLogin += loginService.ShowLogin;
            }

            var viewExtensions = viewExtensionManager.ExtensionLoader.LoadDirectory(dynamoViewModel.Model.PathManager.ViewExtensionsDirectory);
            viewExtensionManager.MessageLogged += Log;

            var startupParams = new ViewStartupParams(dynamoViewModel);

            foreach (var ext in viewExtensions)
            {
                try
                {
                    var logSource = ext as ILogSource;
                    if (logSource != null)
                        logSource.MessageLogged += Log;

                    ext.Startup(startupParams);
                    viewExtensionManager.Add(ext);
                }
                catch (Exception exc)
                {
                    Log(ext.Name + ": " + exc.Message);
                }
            }

            this.dynamoViewModel.RequestPaste += OnRequestPaste;
            this.dynamoViewModel.RequestReturnFocusToView += OnRequestReturnFocusToView;
            FocusableGrid.InputBindings.Clear();
        }
Esempio n. 36
0
        /// <summary>
        /// This method (Application.Idling event handler) is called exactly once
        /// during the creation of Dynamo Revit plug-in. It is in this call both 
        /// DynamoScheduler and its RevitSchedulerThread objects are created. All 
        /// other AsyncTask beyond this point are scheduled through the scheduler.
        /// </summary>
        /// 
        private static void OnRevitIdleOnce(object sender, IdlingEventArgs e)
        {
            // We only need to initialize this once, unregister.
            extCommandData.Application.Idling -= OnRevitIdleOnce;

            // create core data models
            revitDynamoModel = InitializeCoreModel(extCommandData);
            dynamoViewModel = InitializeCoreViewModel(revitDynamoModel);

            // show the window
            InitializeCoreView().Show();

            TryOpenWorkspaceInCommandData(extCommandData);
            SubscribeViewActivating(extCommandData);
        }
Esempio n. 37
0
        public override void SetupCustomUIElements(dynNodeView view)
        {
            this.dynamoViewModel = view.ViewModel.DynamoViewModel;

            base.SetupCustomUIElements(view);

            var editWindowItem = new MenuItem { Header = "Edit...", IsCheckable = false };
            view.MainContextMenu.Items.Add(editWindowItem);
            editWindowItem.Click += delegate { EditScriptContent(); };
            view.UpdateLayout();

            view.MouseDown += view_MouseDown;
        }
Esempio n. 38
0
        public Result ExecuteCommand(DynamoRevitCommandData commandData)
        {
            var startupTimer = Stopwatch.StartNew();

            if (ModelState == RevitDynamoModelState.StartedUIless)
            {
                if (CheckJournalForKey(commandData, JournalKeys.ShowUiKey, true) ||
                    CheckJournalForKey(commandData, JournalKeys.ModelShutDownKey))
                {
                    //When we move from UIless to UI we prefer to start with a fresh revitDynamoModel
                    //in order to benefit from a startup sequence similar to Dynamo Revit UI launch.
                    //Also there might be other situations which demand a new revitDynamoModel.
                    //In order to be able to address them we process ModelShutDownKey.
                    //An example of this situation is when you have a revitDynamoModel already started and you switch
                    //the document in Revit. Since revitDynamoModel is well connected to the previous document we need to
                    //shut it down and start a new one in order to able to run a graph in the new document.
                    revitDynamoModel.ShutDown(false);
                    ModelState = RevitDynamoModelState.NotStarted;
                }
                else
                {
                    TryOpenAndExecuteWorkspaceInCommandData(commandData);
                    return(Result.Succeeded);
                }
            }

            if (ModelState == RevitDynamoModelState.StartedUI)
            {
                TryOpenAndExecuteWorkspaceInCommandData(commandData);
                return(Result.Succeeded);
            }

            HandleDebug(commandData);

            InitializeCore(commandData);
            //subscribe to the assembly load
            AppDomain.CurrentDomain.AssemblyLoad += AssemblyLoad;

            try
            {
                extCommandData = commandData;

                UpdateSystemPathForProcess();

                // create core data models
                revitDynamoModel = InitializeCoreModel(extCommandData);
                revitDynamoModel.UpdateManager.RegisterExternalApplicationProcessId(Process.GetCurrentProcess().Id);
                revitDynamoModel.Logger.Log("SYSTEM", string.Format("Environment Path:{0}", Environment.GetEnvironmentVariable("PATH")));

                // handle initialization steps after RevitDynamoModel is created.
                revitDynamoModel.HandlePostInitialization();
                ModelState = RevitDynamoModelState.StartedUIless;

                // show the window
                if (CheckJournalForKey(extCommandData, JournalKeys.ShowUiKey, true))
                {
                    dynamoViewModel = InitializeCoreViewModel(revitDynamoModel);

                    // Let the host (e.g. Revit) control the rendering mode
                    var save = RenderOptions.ProcessRenderMode;
                    InitializeCoreView().Show();
                    RenderOptions.ProcessRenderMode = save;
                    revitDynamoModel.Logger.Log(Dynamo.Applications.Properties.Resources.WPFRenderMode + RenderOptions.ProcessRenderMode.ToString());

                    ModelState = RevitDynamoModelState.StartedUI;
                    // Disable the Dynamo button to prevent a re-run
                    DynamoRevitApp.DynamoButtonEnabled = false;
                }

                //foreach preloaded exception send a notification to the Dynamo Logger
                //these are messages we want the user to notice.
                preLoadExceptions.ForEach(x => revitDynamoModel.Logger.LogNotification
                                              (revitDynamoModel.GetType().ToString(),
                                              x.GetType().ToString(),
                                              DynamoApplications.Properties.Resources.MismatchedAssemblyVersionShortMessage,
                                              x.Message));

                TryOpenAndExecuteWorkspaceInCommandData(extCommandData);

                //unsubscribe to the assembly load
                AppDomain.CurrentDomain.AssemblyLoad -= AssemblyLoad;
                Analytics.TrackStartupTime("DynamoRevit", startupTimer.Elapsed, ModelState.ToString());
            }
            catch (Exception ex)
            {
                // notify instrumentation
                Analytics.TrackException(ex, true);

                MessageBox.Show(ex.ToString());

                DynamoRevitApp.DynamoButtonEnabled = true;

                //If for some reason Dynamo has crashed while startup make sure the Dynamo Model is properly shutdown.
                if (revitDynamoModel != null)
                {
                    revitDynamoModel.ShutDown(false);
                    revitDynamoModel = null;
                }

                return(Result.Failed);
            }

            return(Result.Succeeded);
        }
Esempio n. 39
0
 public FilePathMutator(DynamoViewModel viewModel)
     : base(viewModel)
 {
 }
Esempio n. 40
0
        public RunSettingsViewModel(RunSettings settings, HomeWorkspaceViewModel workspaceViewModel, DynamoViewModel dynamoViewModel)
        {
            Model = settings;
            Model.PropertyChanged += Model_PropertyChanged;

            this.workspaceViewModel = workspaceViewModel;
            this.dynamoViewModel = dynamoViewModel;

            CancelRunCommand = new DelegateCommand(CancelRun, CanCancelRun);
            RunExpressionCommand = new DelegateCommand(RunExpression, CanRunExpression);

            RunTypeItems = new ObservableCollection<RunTypeItem>();
            foreach (RunType val in Enum.GetValues(typeof(RunType)))
            {
                RunTypeItems.Add(new RunTypeItem(val));
            }
            ToggleRunTypeEnabled(RunType.Periodic, false);
        }
Esempio n. 41
0
 public CodeBlockNodeMutator(DynamoViewModel viewModel)
     : base(viewModel)
 {
 }
Esempio n. 42
0
        public void Loaded(ViewLoadedParams loaded)
        {
            DynamoViewModel dynamoViewModel = loaded.DynamoWindow.DataContext as DynamoViewModel;

            #region QuasarMainMenu
            // Quasar Main Menu
            Quasar = new MenuItem {
                Header = "Quasar"
            };
            Quasar.ToolTip = new ToolTip {
                Content = "Quasar View Extension"
            };
            #endregion QuasarMainMenu

            #region Label

            #region LabelMenuItem
            Label = new MenuItem {
                Header = "Label Selection"
            };
            Label.ToolTip = new ToolTip {
                Content = " Add description label to selected nodes"
            };
            #endregion LabelMenuItem

            Label.Click += (sender, args) =>
            {
                var viewModel = new QuasarLabel(loaded, dynamoViewModel);
            };

            #endregion Label

            #region NodeInGraph

            #region NodeInGraphMenuItem

            /*
             * // NodesInGraph MenuItem
             * NodesInGraph = new MenuItem { Header = "Nodes In Graph" };
             * NodesInGraph.ToolTip = new ToolTip { Content = "Nodes info in this graph" };
             */
            #endregion NodeInGraphMenuItem
            #region NodeInGraphClickEvent

            /*
             * // ~ NodesInGraph Click Event ~
             * NodesInGraph.Click += (sender, args) =>
             * {
             *  var viewModel = new QuasarNodeInGraph(loaded);
             *  var window = new QuasarWindow
             *  {
             *      MainGrid = { DataContext = viewModel },
             *      Owner = loaded.DynamoWindow
             *  };
             *  window.Left = window.Owner.Left + 300;
             *  window.Top = window.Owner.Top + 250;
             *  window.Show();
             * };
             */
            #endregion NodeInGraphClickEvent

            #endregion NodeInGraph

            #region About

            #region AboutMenuItem
            About = new MenuItem {
                Header = "About"
            };
            About.ToolTip = new ToolTip {
                Content = "About Quasar Extension"
            };
            #endregion AboutMenuItem
            About.Click += (sender, args) =>
            {
                var viewModel = new QuasarAbout(loaded);
                var window    = new QuasarAboutWindow
                {
                    MainGrid = { DataContext = viewModel },
                    Owner    = loaded.DynamoWindow
                };
                window.Left = window.Owner.Left + 200;
                window.Top  = window.Owner.Top + 100;
                window.Show();
            };

            #endregion About

            #region Freeze

            #region FreezeMenuItem
            // Freeze MenuItem
            Freeze = new MenuItem {
                Header = "Freeze Selection"
            };
            Freeze.ToolTip = new ToolTip {
                Content = "Freeze current selected nodes"
            };
            #endregion FreezeMenuItem
            Freeze.Click += (sender, args) =>
            {
                var viewModel = new QuasarFreeze(loaded);
            };


            #endregion Freeze

            #region Unfreeze

            #region UnfreezeMenuItem
            Unfreeze = new MenuItem {
                Header = "Unfreeze Selection"
            };
            Unfreeze.ToolTip = new ToolTip {
                Content = "Unfreeze current selected nodes"
            };
            #endregion UnfreezeMenuItem
            Unfreeze.Click += (sender, args) =>
            {
                var viewModel = new QuasarUnfreeze(loaded);
            };

            #endregion Unfreeze

            #region Sample

            #region SamplesMenuItems
            SampleFileMenu = new MenuItem {
                Header = "Quasar Samples"
            };
            SampleFileMenu.ToolTip = new ToolTip {
                Content = " Sample files for node usage"
            };

            var appdata     = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            var path        = Path.Combine(appdata, "Dynamo\\Dynamo Revit\\2.0\\packages\\Quasar\\extra\\samples");
            var SubMenuItem = Directory.GetDirectories(path);

            foreach (string sub in SubMenuItem)
            {
                MenuItem subMenu = new MenuItem {
                    Header = sub.Split('\\').Last()
                };
                //subMenu.ToolTip = new ToolTip { Content = sub.Split('\\').Last()};
                //SampleFileMenu.Items.Add(subMenu);
                MenuItem subMenuItems = SampleFiles(sub, subMenu, dynamoViewModel);
                SampleFileMenu.Items.Add(subMenuItems);
            }

            #endregion SampleMenuItems

            SampleFileMenu.Click += (sender, args) =>
            {
                var viewModel = new QuasarSampleFile(loaded, dynamoViewModel);
            };

            #endregion Sample

            #region FunctionTest

            /*
             * // FunctionTest MenuItem
             * FunctionTest = new MenuItem { Header = "Function Test" };
             * FunctionTest.ToolTip = new ToolTip { Content = "Testing Dynamo API Methods" };
             */
            #endregion FunctionTest


            #region AddAllMenuItems

            Quasar.Items.Add(Label);
            Quasar.Items.Add(Freeze);
            Quasar.Items.Add(Unfreeze);
            Quasar.Items.Add(new Separator());
            Quasar.Items.Add(SampleFileMenu);
            Quasar.Items.Add(new Separator());
            Quasar.Items.Add(About);

            // load to dynamo menu
            loaded.dynamoMenu.Items.Add(Quasar);

            #endregion AddAllMenuItems
        }
Esempio n. 43
0
        private void dynBench_Activated(object sender, EventArgs e)
        {
            this.WorkspaceTabs.SelectedIndex = 0;
            _vm = (DataContext as DynamoViewModel);
            _vm.Model.RequestLayoutUpdate += vm_RequestLayoutUpdate;
            _vm.PostUiActivationCommand.Execute(null);

            _timer.Stop();
            DynamoLogger.Instance.Log(String.Format("{0} elapsed for loading Dynamo main window.",
                                                                     _timer.Elapsed));
            LoadSamplesMenu();

            #region Search initialization

            var search = new SearchView { DataContext = dynSettings.Controller.SearchViewModel };
            sidebarGrid.Children.Add(search);
            dynSettings.Controller.SearchViewModel.Visible = true;

            #endregion

            //PACKAGE MANAGER
            _vm.RequestPackagePublishDialog += _vm_RequestRequestPackageManagerPublish;
            _vm.RequestManagePackagesDialog += new EventHandler(_vm_RequestShowInstalledPackages);
            _vm.RequestPackageManagerSearchDialog += new EventHandler(_vm_RequestShowPackageManagerSearch);

            //FUNCTION NAME PROMPT
            _vm.Model.RequestsFunctionNamePrompt += _vm_RequestsFunctionNamePrompt;

            _vm.SidebarClosed += new EventHandler(_vm_SidebarClosed);
            _vm.RequestClose += new EventHandler(_vm_RequestClose);
            _vm.RequestSaveImage += new ImageSaveEventHandler(_vm_RequestSaveImage);

            dynSettings.Controller.RequestsCrashPrompt += new DynamoController.CrashPromptHandler(Controller_RequestsCrashPrompt);

            DynamoSelection.Instance.Selection.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Selection_CollectionChanged);

            _vm.RequestUserSaveWorkflow += new WorkspaceSaveEventHandler(_vm_RequestUserSaveWorkflow);

            dynSettings.Controller.ClipBoard.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(ClipBoard_CollectionChanged);

            // Kick start the automation run, if possible.
            _vm.BeginCommandPlayback(this);
        }
Esempio n. 44
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(
                            null,
                            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);
            }
        }
Esempio n. 45
0
 public NumberSequenceMutator(DynamoViewModel viewModel)
     : base(viewModel)
 {
 }
Esempio n. 46
0
        private void dynBench_Activated(object sender, EventArgs e)
        {
            // If first run, Collect Info Prompt will appear
            UsageReportingManager.Instance.CheckIsFirstRun();

            this.WorkspaceTabs.SelectedIndex = 0;
            _vm = (DataContext as DynamoViewModel);
            _vm.Model.RequestLayoutUpdate += vm_RequestLayoutUpdate;
            _vm.PostUiActivationCommand.Execute(null);

            _timer.Stop();
            dynSettings.Controller.DynamoLogger.Log(String.Format("{0} elapsed for loading Dynamo main window.",
                                                                     _timer.Elapsed));
            InitializeShortcutBar();

#if !__NO_SAMPLES_MENU
            LoadSamplesMenu();
#endif
            #region Search initialization

            var search = new SearchView { DataContext = dynSettings.Controller.SearchViewModel };
            sidebarGrid.Children.Add(search);
            dynSettings.Controller.SearchViewModel.Visible = true;

            #endregion

            //PACKAGE MANAGER
            _vm.RequestPackagePublishDialog += _vm_RequestRequestPackageManagerPublish;
            _vm.RequestManagePackagesDialog += _vm_RequestShowInstalledPackages;
            _vm.RequestPackageManagerSearchDialog += _vm_RequestShowPackageManagerSearch;

            //FUNCTION NAME PROMPT
            _vm.RequestsFunctionNamePrompt += _vm_RequestsFunctionNamePrompt;

            _vm.RequestClose += _vm_RequestClose;
            _vm.RequestSaveImage += _vm_RequestSaveImage;
            _vm.SidebarClosed += _vm_SidebarClosed;

            dynSettings.Controller.RequestsCrashPrompt += Controller_RequestsCrashPrompt;
            dynSettings.Controller.RequestTaskDialog += Controller_RequestTaskDialog;

            DynamoSelection.Instance.Selection.CollectionChanged += Selection_CollectionChanged;

            _vm.RequestUserSaveWorkflow += _vm_RequestUserSaveWorkflow;

            dynSettings.Controller.ClipBoard.CollectionChanged += ClipBoard_CollectionChanged;

            //ABOUT WINDOW
            _vm.RequestAboutWindow += _vm_RequestAboutWindow;

            //ABOUT WINDOW
            _vm.RequestAboutWindow += _vm_RequestAboutWindow;

            // Kick start the automation run, if possible.
            _vm.BeginCommandPlayback(this);
        }
        public RunSettingsViewModel(RunSettings settings, HomeWorkspaceViewModel workspaceViewModel, DynamoViewModel dynamoViewModel)
        {
            Model = settings;
            Model.PropertyChanged += Model_PropertyChanged;

            this.workspaceViewModel = workspaceViewModel;
            this.dynamoViewModel    = dynamoViewModel;

            CancelRunCommand     = new DelegateCommand(CancelRun, CanCancelRun);
            RunExpressionCommand = new DelegateCommand(RunExpression, CanRunExpression);

            RunTypeItems = new ObservableCollection <RunTypeItem>();
            foreach (RunType val in Enum.GetValues(typeof(RunType)))
            {
                RunTypeItems.Add(new RunTypeItem(val));
            }
            ToggleRunTypeEnabled(RunType.Periodic, false);
        }
Esempio n. 48
0
        void _vm_RequestAboutWindow(DynamoViewModel model)
        {
            if (_aboutWindow == null)
            {
                _aboutWindow = new AboutWindow(DynamoLogger.Instance, model);
                _aboutWindow.Closed += (sender, args) => _aboutWindow = null;
                _aboutWindow.Show();

                if (_aboutWindow.IsLoaded && this.IsLoaded) _aboutWindow.Owner = this;
            }

            _aboutWindow.Focus();
        }
Esempio n. 49
0
        public static void Main(string[] args)
        {
            DynamoViewModel viewModel = null;

            try
            {
                var cmdLineArgs     = CommandLineArguments.FromArguments(args);
                var supportedLocale = new HashSet <string>(new[]
                {
                    "cs-CZ", "de-DE", "en-US", "es-ES", "fr-FR", "it-IT",
                    "ja-JP", "ko-KR", "pl-PL", "pt-BR", "ru-RU", "zh-CN", "zh-TW"
                });
                string libgLocale;

                if (!string.IsNullOrEmpty(cmdLineArgs.Locale))
                {
                    // Change the application locale, if a locale information is supplied.
                    Thread.CurrentThread.CurrentUICulture = new CultureInfo(cmdLineArgs.Locale);
                    Thread.CurrentThread.CurrentCulture   = new CultureInfo(cmdLineArgs.Locale);
                    libgLocale = cmdLineArgs.Locale;
                }
                else
                {
                    // In case no language is specified, libG's locale should be that of the OS.
                    // There is no need to set Dynamo's locale in this case.
                    libgLocale = CultureInfo.InstalledUICulture.ToString();
                }

                // If locale is not supported by Dynamo, default to en-US.
                if (!supportedLocale.Any(s => s.Equals(libgLocale, StringComparison.InvariantCultureIgnoreCase)))
                {
                    libgLocale = "en-US";
                }

                // Change the locale that LibG depends on.
                StringBuilder sb = new StringBuilder("LANGUAGE=");
                sb.Append(libgLocale.Replace("-", "_"));
                _putenv(sb.ToString());

                MakeStandaloneAndRun(cmdLineArgs.CommandFilePath, out viewModel);
            }
            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;
                    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);
            }
        }
Esempio n. 50
0
 public CommandLineRunnerWPF(DynamoViewModel viewModel) : base(viewModel.Model)
 {
     this.viewModel = viewModel;
 }
Esempio n. 51
0
        public override bool RunTest(NodeModel node, EngineController engine, StreamWriter writer)
        {
            bool pass = false;

            var firstNodeConnectors = node.AllConnectors.ToList();

            var valueMap = new Dictionary <Guid, String>();

            if (node.OutPorts.Count > 0)
            {
                foreach (ConnectorModel connector in firstNodeConnectors)
                {
                    if (connector.Start.Owner.GUID != node.GUID &&
                        !valueMap.ContainsKey(connector.Start.Owner.GUID))
                    {
                        Guid   guid = connector.Start.Owner.GUID;
                        Object data = connector.Start.Owner.GetValue(0, engine).Data;
                        String val  = data != null?data.ToString() : "null";

                        valueMap.Add(guid, val);
                        writer.WriteLine(guid + " :: " + val);
                        writer.Flush();
                    }
                }
            }

            int numberOfUndosNeeded = Mutate(node);

            Thread.Sleep(10);

            writer.WriteLine("### - Beginning undo");
            for (int iUndo = 0; iUndo < numberOfUndosNeeded; iUndo++)
            {
                DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
                {
                    DynamoModel.UndoRedoCommand undoCommand =
                        new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);

                    DynamoViewModel.ExecuteCommand(undoCommand);
                }));
                Thread.Sleep(100);
            }
            writer.WriteLine("### - undo complete");
            writer.Flush();

            ExecuteAndWait();

            writer.WriteLine("### - Beginning test of List");
            if (node.OutPorts.Count > 0)
            {
                try
                {
                    foreach (ConnectorModel connector in firstNodeConnectors)
                    {
                        if (connector.Start.Owner.GUID != node.GUID)
                        {
                            String valmap  = valueMap[connector.Start.Owner.GUID].ToString();
                            Object data    = connector.Start.Owner.GetValue(0, engine).Data;
                            String nodeVal = data != null?data.ToString() : "null";

                            if (valmap != nodeVal)
                            {
                                writer.WriteLine("!!!!!!!!!!! - test of List is failed");
                                writer.WriteLine(node.GUID);

                                writer.WriteLine("Was: " + nodeVal);
                                writer.WriteLine("Should have been: " + valmap);
                                writer.Flush();
                                return(pass);
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    writer.WriteLine("!!!!!!!!!!! - test of List is failed");
                    writer.Flush();
                    return(pass);
                }
            }
            writer.WriteLine("### - test of List complete");
            writer.Flush();

            return(pass = true);
        }
Esempio n. 52
0
 public ConnectorMutator(DynamoViewModel viewModel)
     : base(viewModel)
 {
 }
Esempio n. 53
0
        internal StartPageViewModel(DynamoViewModel dynamoViewModel, bool isFirstRun)
        {
            this.DynamoViewModel = dynamoViewModel;
            this.isFirstRun      = isFirstRun;

            this.recentFiles = new ObservableCollection <StartPageListItem>();
            sampleFiles      = new ObservableCollection <SampleFileEntry>();
            backupFiles      = new ObservableCollection <StartPageListItem>();


            #region File Operations

            fileOperations.Add(new StartPageListItem(Resources.StartPageNewFile, "icon-new.png")
            {
                ContextData = ButtonNames.NewWorkspace,
                ClickAction = StartPageListItem.Action.RegularCommand
            });

            fileOperations.Add(new StartPageListItem(Resources.StartPageNewCustomNode, "icon-customnode.png")
            {
                ContextData = ButtonNames.NewCustomNodeWorkspace,
                ClickAction = StartPageListItem.Action.RegularCommand
            });

            fileOperations.Add(new StartPageListItem(Resources.StartPageOpenFile, "icon-open.png")
            {
                ContextData = ButtonNames.OpenWorkspace,
                ClickAction = StartPageListItem.Action.RegularCommand
            });

            #endregion

            #region Community Links

            communityLinks.Add(new StartPageListItem(Resources.StartPageDiscussionForum, "icon-discussion.png")
            {
                ContextData = Configurations.DynamoBimForum,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            communityLinks.Add(new StartPageListItem(
                                   string.Format(Resources.StartPageVisitWebsite, dynamoViewModel.BrandingResourceProvider.ProductName),
                                   "icon-dynamobim.png")
            {
                ContextData = Configurations.DynamoSiteLink,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            #endregion

            #region Reference List

            references.Add(new StartPageListItem(Resources.StartPageWhatsNew, "icon-whats-new.png")
            {
                ContextData = ButtonNames.ShowGallery,
                ClickAction = StartPageListItem.Action.RegularCommand
            });

            references.Add(new StartPageListItem(Resources.StartPageDynamoPrimer, "icon-reference.png")
            {
                ContextData = Configurations.DynamoPrimer,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            references.Add(new StartPageListItem(Resources.StartPageVideoTutorials, "icon-video.png")
            {
                ContextData = Configurations.DynamoVideoTutorials,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            #endregion

            #region Contribution Links

            contributeLinks.Add(new StartPageListItem(Resources.StartPageGithubRepository, "icon-github.png")
            {
                ContextData = Configurations.GitHubDynamoLink,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            contributeLinks.Add(new StartPageListItem(Resources.StartPageSendIssues, "icon-issues.png")
            {
                ContextData = Configurations.GitHubBugReportingLink,
                ClickAction = StartPageListItem.Action.ExternalUrl
            });

            #endregion

            var dvm = this.DynamoViewModel;
            RefreshRecentFileList(dvm.RecentFiles);
            RefreshBackupFileList(dvm.Model.PreferenceSettings.BackupFiles);
            dvm.RecentFiles.CollectionChanged += OnRecentFilesChanged;
        }
Esempio n. 54
0
        public override bool RunTest(NodeModel node, EngineController engine, StreamWriter writer)
        {
            bool pass = false;

            List <ConnectorModel> firstNodeConnectors = node.AllConnectors.ToList();

            Dictionary <Guid, String> valueMap = new Dictionary <Guid, String>();

            foreach (ConnectorModel connector in firstNodeConnectors)
            {
                if (connector.Start.Owner.GUID != node.GUID)
                {
                    Guid guid = connector.Start.Owner.GUID;
                    if (!valueMap.ContainsKey(guid))
                    {
                        String val = connector.Start.Owner.NickName;
                        valueMap.Add(guid, val);
                        writer.WriteLine(guid + " :: " + val);
                        writer.Flush();
                    }
                }
                else if (connector.End.Owner.GUID != node.GUID)
                {
                    Guid guid = connector.End.Owner.GUID;
                    if (!valueMap.ContainsKey(guid))
                    {
                        String val = connector.End.Owner.NickName;
                        valueMap.Add(guid, val);
                        writer.WriteLine(guid + " :: " + val);
                        writer.Flush();
                    }
                }
            }

            int numberOfUndosNeeded = Mutate(node);

            Thread.Sleep(100);

            IEnumerable <NodeModel> nodesAfterMutate = DynamoViewModel.Model.CurrentWorkspace.Nodes;

            if (nodesAfterMutate.Contains(node))
            {
                writer.WriteLine("### - Connector wasn't deleted");
                writer.Flush();
                return(pass);
            }
            else
            {
                writer.WriteLine("### - Connector was deleted");
            }

            for (int iUndo = 0; iUndo < numberOfUndosNeeded; iUndo++)
            {
                DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
                {
                    DynamoModel.UndoRedoCommand undoCommand =
                        new DynamoModel.UndoRedoCommand(
                            DynamoModel.UndoRedoCommand.Operation.Undo);

                    DynamoViewModel.ExecuteCommand(undoCommand);
                }));
            }
            Thread.Sleep(100);

            IEnumerable <NodeModel> nodesAfterUndo = DynamoViewModel.Model.CurrentWorkspace.Nodes;

            NodeModel nodeAfterUndo = nodesAfterUndo.FirstOrDefault(t => t.GUID.Equals(node.GUID));

            List <ConnectorModel> firstNodeConnectorsAfterUndo = nodeAfterUndo.AllConnectors.ToList();

            foreach (ConnectorModel connector in firstNodeConnectorsAfterUndo)
            {
                if (connector.Start.Owner.GUID != node.GUID)
                {
                    Guid guid = connector.Start.Owner.GUID;

                    if (!valueMap.ContainsKey(guid))
                    {
                        writer.WriteLine("### - ### - Connector wasn't recreated");
                        writer.Flush();
                        return(pass);
                    }
                    else
                    {
                        writer.WriteLine("### - Connector was recreated");
                        writer.Flush();
                    }
                }
                else if (connector.End.Owner.GUID != node.GUID)
                {
                    Guid guid = connector.End.Owner.GUID;

                    if (!valueMap.ContainsKey(guid))
                    {
                        writer.WriteLine("### - ### - Connector wasn't recreated");
                        writer.Flush();
                        return(pass);
                    }
                    else
                    {
                        writer.WriteLine("### - Connector was recreated");
                        writer.Flush();
                    }
                }
            }
            return(pass = true);
        }
Esempio n. 55
0
 void DynamoViewModelRequestAboutWindow(DynamoViewModel model)
 {
     var aboutWindow = model.BrandingResourceProvider.CreateAboutBox(model);
     aboutWindow.Owner = this;
     aboutWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
     aboutWindow.ShowDialog();
 }
Esempio n. 56
0
 public NumberRangeMutator(DynamoViewModel viewModel)
     : base(viewModel)
 {
 }
Esempio n. 57
0
 /// <summary>
 /// The class constructor. </summary>
 public PublishPackageViewModel(DynamoViewModel dynamoViewModel) : this()
 {
     this.dynamoViewModel = dynamoViewModel;
 }
Esempio n. 58
0
        public WorkspaceViewModel(WorkspaceModel model, DynamoViewModel dynamoViewModel)
        {
            this.DynamoViewModel = dynamoViewModel;

            Model = model;
            stateMachine = new StateMachine(this);

            var nodesColl = new CollectionContainer { Collection = Nodes };
            _workspaceElements.Add(nodesColl);

            var connColl = new CollectionContainer { Collection = Connectors };
            _workspaceElements.Add(connColl);

            var notesColl = new CollectionContainer { Collection = Notes };
            _workspaceElements.Add(notesColl);

            var errorsColl = new CollectionContainer { Collection = Errors };
            _workspaceElements.Add(errorsColl);

            // Add EndlessGrid
            var endlessGrid = new EndlessGridViewModel(this);
            _workspaceElements.Add(endlessGrid);

            //respond to collection changes on the model by creating new view models
            //currently, view models are added for notes and nodes
            //connector view models are added during connection
            Model.Nodes.CollectionChanged += Nodes_CollectionChanged;
            Model.Notes.CollectionChanged += Notes_CollectionChanged;
            Model.Connectors.CollectionChanged += Connectors_CollectionChanged;
            Model.PropertyChanged += ModelPropertyChanged;

            DynamoSelection.Instance.Selection.CollectionChanged += this.AlignSelectionCanExecuteChanged;

            // sync collections
            Nodes_CollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Model.Nodes));
            Connectors_CollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Model.Connectors));
            Notes_CollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Model.Notes));
        }
Esempio n. 59
0
        public WorkspaceViewModel(WorkspaceModel model, DynamoViewModel vm)
        {
            _model = model;
            stateMachine = new StateMachine(this);

            //setup the composite collection
            var previewsColl = new CollectionContainer { Collection = Previews };
            _workspaceElements.Add(previewsColl);

            var nodesColl = new CollectionContainer { Collection = Nodes };
            _workspaceElements.Add(nodesColl);

            var connColl = new CollectionContainer { Collection = Connectors };
            _workspaceElements.Add(connColl);

            var notesColl = new CollectionContainer { Collection = Notes };
            _workspaceElements.Add(notesColl);

            var errorsColl = new CollectionContainer { Collection = Errors };
            _workspaceElements.Add(errorsColl);

            // Add EndlessGrid
            var endlessGrid = new EndlessGridViewModel(this);
            _workspaceElements.Add(endlessGrid);

            //respond to collection changes on the model by creating new view models
            //currently, view models are added for notes and nodes
            //connector view models are added during connection
            _model.Nodes.CollectionChanged += Nodes_CollectionChanged;
            _model.Notes.CollectionChanged += Notes_CollectionChanged;
            _model.Connectors.CollectionChanged += Connectors_CollectionChanged;
            _model.PropertyChanged += ModelPropertyChanged;

            // sync collections
            Nodes_CollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, _model.Nodes));
            Connectors_CollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, _model.Connectors));
            Notes_CollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, _model.Notes));
            Dispatcher = System.Windows.Threading.Dispatcher.CurrentDispatcher;
        }
Esempio n. 60
0
 public DeleteNodeMutator(DynamoViewModel viewModel)
     : base(viewModel)
 {
 }