private void SpecialColorButton_Click(object sender, RoutedEventArgs e)
        {
            WorkspaceViewModel workspaceView  = BeyondDynamo.Utils.DynamoVM.CurrentSpaceViewModel;
            string             configFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Dynamo\\BeyondDynamoSettings\\beyondDynamo2Config.json");
            BeyondDynamoConfig config         = new BeyondDynamoConfig(configFilePath);

            BeyondDynamoFunctions.ChangeGroupColor(workspaceView, config);
        }
 private async void EvaluateGraph(HomeWorkspaceModel model)
 {
     Application.Current.Dispatcher.Invoke(new Action(() =>
     {
         this.completedNodes = new List <NodeModel>();
         this.warningNodes   = new List <NodeModel>();
         this.errorNodes     = new List <NodeModel>();
         WarningStacker.Children.Clear();
         WorkspaceModel currentWorkSpace = BeyondDynamo.Utils.DynamoVM.CurrentSpace;
         foreach (NodeModel node in currentWorkSpace.Nodes)
         {
             if (node.State == ElementState.Active)
             {
                 completedNodes.Add(node);
             }
             else if (node.State == ElementState.Error)
             {
                 errorNodes.Add(node);
             }
             else if (node.State == ElementState.Warning || node.State == ElementState.PersistentWarning)
             {
                 warningNodes.Add(node);
                 string warningText   = BeyondDynamoFunctions.GetNodeViewModel(node).ErrorBubble.FullContent;
                 Button warningButton = new Button()
                 {
                     Style   = (Style)this.Resources["WarningButton"],
                     Content = warningText
                 };
                 warningButton.Click += WarningButton_Click;;
                 WarningStacker.Children.Add(warningButton);
             }
             else
             {
             }
         }
     }));
 }
 private void PythonRenameButton_Click(object sender, RoutedEventArgs e)
 {
     BeyondDynamoFunctions.RenamePythonInputs();
 }
        private void ImportDYNGraphButton_Click(object sender, RoutedEventArgs e)
        {
            DynamoViewModel viewmodel = BeyondDynamo.Utils.DynamoVM;

            BeyondDynamoFunctions.ImportFromScript(viewmodel);
        }
예제 #5
0
        /// <summary>
        /// Function Which gets Called on Loading the Plug-In
        /// </summary>
        /// <param name="p">Parameters</param>
        public void Loaded(ViewLoadedParams p)
        {
            BDmenuItem = new MenuItem {
                Header = "Beyond Dynamo"
            };
            DynamoViewModel VM = p.DynamoWindow.DataContext as DynamoViewModel;

            BeyondDynamo.Utils.DynamoWindow = p.DynamoWindow;

            Utils.DynamoVM = VM;
            Utils.LogMessage("Loading Menu Items Started...");

            Utils.LogMessage("Loading Menu Items: Latest Version Started...");
            LatestVersion = new MenuItem {
                Header = "New version available! Download now!"
            };
            LatestVersion.Click += (sender, args) =>
            {
                System.Diagnostics.Process.Start("www.github.com/JoelvanHerwaarden/BeyondDynamo2.X/releases");
            };
            if (this.currentVersion < this.latestVersion)
            {
                BDmenuItem.Items.Add(LatestVersion);
            }
            else
            {
                Utils.LogMessage("Loading Menu Items: Latest Version is installed");
            }

            Utils.LogMessage("Loading Menu Items: Latest Version Completed");

            #region THIS CAN BE RUN ANYTIME

            Utils.LogMessage("Loading Menu Items: Chang Node Colors Started...");
            ChangeNodeColors = new MenuItem {
                Header = "Change Node Color"
            };
            ChangeNodeColors.Click += (sender, args) =>
            {
                //Get the current Node Color Template
                System.Windows.ResourceDictionary dynamoUI = Dynamo.UI.SharedDictionaryManager.DynamoColorsAndBrushesDictionary;

                //Initiate a new Change Node Color Window
                ChangeNodeColorsWindow colorWindow = new ChangeNodeColorsWindow(dynamoUI, config)
                {
                    // Set the owner of the window to the Dynamo window.
                    Owner = BeyondDynamo.Utils.DynamoWindow
                };
                colorWindow.Left = colorWindow.Owner.Left + 400;
                colorWindow.Top  = colorWindow.Owner.Top + 200;

                //Show the Color window
                colorWindow.Show();
            };
            ChangeNodeColors.ToolTip = new ToolTip()
            {
                Content = "This lets you change the Node Color Settings in your Dynamo nodes in In-Active, Active, Warning and Error state"
            };

            Utils.LogMessage("Loading Menu Items: Batch Remove Trace Data Started...");
            BatchRemoveTraceData = new MenuItem {
                Header = "Remove Session Trace Data from Dynamo Graphs"
            };
            BatchRemoveTraceData.Click += (sender, args) =>
            {
                //Make a ViewModel for the Remove Trace Data window

                //Initiate a new Remove Trace Data window
                RemoveTraceDataWindow window = new RemoveTraceDataWindow()
                {
                    Owner     = p.DynamoWindow,
                    viewModel = VM
                };
                window.Left = window.Owner.Left + 400;
                window.Top  = window.Owner.Top + 200;

                //Show the window
                window.Show();
            };
            BatchRemoveTraceData.ToolTip = new ToolTip()
            {
                Content = "Removes the Session Trace Data / Bindings from muliple Dynamo scripts in a given Directory" +
                          "\n" +
                          "\nSession Trace Data / Bindings is the trace data binding with the current Revit model and elements." +
                          "\nIt can slow your scripts down if you run them because it first tries the regain the last session in which it was used."
            };

            Utils.LogMessage("Loading Menu Items: Order Player Nodes Started...");
            OrderPlayerInput = new MenuItem {
                Header = "Order Input/Output Nodes"
            };
            OrderPlayerInput.Click += (sender, args) =>
            {
                //Open a FileBrowser Dialog so the user can select a Dynamo Graph
                System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog();
                fileDialog.Filter = "Dynamo Files (*.dyn)|*.dyn";
                if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    if (BeyondDynamoFunctions.IsFileOpen(VM, fileDialog.FileName))
                    {
                        Forms.MessageBox.Show("Please close the file before using this command", "Order Input/Output Nodes");
                        return;
                    }
                    //Get the selected filePath
                    string DynamoFilepath = fileDialog.FileName;
                    string DynamoString   = File.ReadAllText(DynamoFilepath);
                    if (DynamoString.StartsWith("<"))
                    {
                        //Call the SortInputNodes Function
                        BeyondDynamoFunctions.SortInputOutputNodesXML(fileDialog.FileName);
                    }
                    else if (DynamoString.StartsWith("{"))
                    {
                        //Call the SortInputNodes Function
                        BeyondDynamoFunctions.SortInputOutputNodesJson(fileDialog.FileName);
                    }
                    else
                    {
                        return;
                    }
                }
            };
            OrderPlayerInput.ToolTip = new ToolTip()
            {
                Content = "Select a Dynamo file and it will let you sort the Nodes marked as 'Input'' & Output'" +
                          "\n" +
                          "\n Only Watch nodes which are marked as Output are displayed in the Dynamo Player. " +
                          "\nOther nodes will show up in Refinery"
            };

            Utils.LogMessage("Loading Menu Items: Player Scripts Started...");
            PlayerScripts = new MenuItem {
                Header = "Player Graphs"
            };
            OpenPlayerPath = new MenuItem {
                Header = "Open Player Path"
            };
            OpenPlayerPath.Click += (sender, args) =>
            {
                System.Diagnostics.Process.Start(this.config.playerPath);
            };

            SetPlayerPath = new MenuItem {
                Header = "Set Player Path"
            };
            List <MenuItem> extraMenuItems = new List <MenuItem> {
                SetPlayerPath, OpenPlayerPath
            };
            SetPlayerPath.Click += (sender, args) =>
            {
                Forms.FolderBrowserDialog browserDialog = new Forms.FolderBrowserDialog();
                if (this.config.playerPath != null)
                {
                    browserDialog.SelectedPath = this.config.playerPath;
                }
                if (browserDialog.ShowDialog() == Forms.DialogResult.OK)
                {
                    if (browserDialog.SelectedPath != null)
                    {
                        PlayerScripts.Items.Clear();
                        BeyondDynamoFunctions.RetrievePlayerFiles(PlayerScripts, VM, browserDialog.SelectedPath, extraMenuItems);
                        this.config.playerPath = browserDialog.SelectedPath;
                    }
                }
            };
            Utils.LogMessage("Playerpath = " + this.config.playerPath);
            if (this.config.playerPath != null | this.config.playerPath != string.Empty)
            {
                try
                {
                    if (Directory.Exists(Path.GetDirectoryName(this.config.playerPath)))
                    {
                        BeyondDynamoFunctions.RetrievePlayerFiles(PlayerScripts, VM, this.config.playerPath, extraMenuItems);
                    }
                }
                catch (Exception e)
                {
                    Utils.LogMessage("Loading Player Path Warning: " + e.Message);
                    PlayerScripts.Items.Add(SetPlayerPath);
                }
            }
            else
            {
                PlayerScripts.Items.Add(SetPlayerPath);
            }

            //BDmenuItem.Items.Add(ChangeNodeColors);
            //Utils.LogMessage("Loading Menu Items: Chang Node Colors Completed");
            //BDmenuItem.Items.Add(BatchRemoveTraceData);
            //Utils.LogMessage("Loading Menu Items: Batch Remove Trace Data Completed");
            BDmenuItem.Items.Add(OrderPlayerInput);
            Utils.LogMessage("Loading Menu Items: Order Player Nodes Completed");
            BDmenuItem.Items.Add(PlayerScripts);
            Utils.LogMessage("Loading Menu Items: Player Scripts Completed");

            BDmenuItem.Items.Add(new Separator());
            BDmenuItem.Items.Add(new Separator());
            #endregion

            # region THESE FUNCTION ONLY WORK INSIDE A SCRIPT