Inheritance: Dynamo.ViewModels.ViewModelBase, IWatchViewModel
Ejemplo n.º 1
0
 internal ViewStartupParams(DynamoViewModel dynamoVM) :
     base(dynamoVM.Model.AuthenticationManager.AuthProvider,
         dynamoVM.Model.PathManager,
         dynamoVM.Model.CustomNodeManager)
 {
     dynamoViewModel = dynamoVM;
 }
Ejemplo n.º 2
0
        public CodeBlockEditor(NodeViewModel nodeViewModel)
        {
            InitializeComponent();

            this.nodeViewModel = nodeViewModel;
            this.dynamoViewModel = nodeViewModel.DynamoViewModel;
            this.DataContext = nodeViewModel.NodeModel;
            this.nodeModel = nodeViewModel.NodeModel as CodeBlockNodeModel;

            // Register text editing events
            this.InnerTextEditor.TextChanged += InnerTextEditor_TextChanged;
            this.InnerTextEditor.TextArea.LostFocus += TextArea_LostFocus;

            // 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();
        }
Ejemplo n.º 3
0
 public virtual void OnRequestAboutWindow(DynamoViewModel vm)
 {
     if (RequestAboutWindow != null)
     {
         RequestAboutWindow(vm);
     }
 }
Ejemplo n.º 4
0
 public PackageDownloadHandle(DynamoViewModel dynamoViewModel, Greg.Responses.PackageHeader header, PackageVersion version)
 {
     this.dynamoViewModel = dynamoViewModel;
     this.Header = header;
     this.DownloadPath = "";
     this.VersionName = version.version;
 }
 public InstalledPackagesViewModel(DynamoViewModel dynamoViewModel, PackageLoader model)
 {
     this.Model = model;
     this.dynamoViewModel = dynamoViewModel;
     
     InitializeLocalPackages();
 }
Ejemplo n.º 6
0
        public CrashPrompt(CrashPromptArgs args, DynamoViewModel dynamoViewModel)
        {
            InitializeComponent();

            productName = dynamoViewModel.BrandingResourceProvider.ProductName;
            Title = string.Format(Wpf.Properties.Resources.CrashPromptDialogTitle, productName);
            txtOverridingText.Text = string.Format(Wpf.Properties.Resources.CrashPromptDialogCrashMessage, productName);

            if (args.HasDetails())
            {
                this.details = args.Details;
                this.CrashDetailsContent.Text = args.Details;
                this.btnDetails.Visibility = Visibility.Visible;
            }

            if (args.IsFilePath())
            {
                folderPath = Path.GetDirectoryName(args.FilePath);
                btnOpenFolder.Visibility = Visibility.Visible;
            }

            if (args.IsDefaultTextOverridden())
            {
                string overridingText = args.OverridingText;

                if (args.IsFilePath())
                    overridingText = overridingText.Replace("[FILEPATH]", args.FilePath);

                ConvertFormattedTextIntoTextblock(this.txtOverridingText, overridingText);
            }
        }
        public override void Cleanup()
        {
            try
            {
                preloader = null;
                DynamoSelection.Instance.ClearSelection();

                if (ViewModel == null)
                    return;

                var shutdownParams = new DynamoViewModel.ShutdownParams(
                    shutdownHost: false,
                    allowCancellation: false);

                ViewModel.PerformShutdownSequence(shutdownParams);
                ViewModel.RequestUserSaveWorkflow -= RequestUserSaveWorkflow;
                ViewModel = null;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }

            base.Cleanup();
        }
Ejemplo n.º 8
0
        public GalleryViewModel(DynamoViewModel dynamoViewModel)
        {
            dvm = dynamoViewModel;
            var pathManager = dynamoViewModel.Model.PathManager;
            var galleryFilePath = pathManager.GalleryFilePath;
            var galleryDirectory = Path.GetDirectoryName(galleryFilePath);

            var version = dynamoViewModel.Model.UpdateManager.ProductVersion;

            DynamoVersion = string.Format(Properties.Resources.GalleryDynamoVersion,
                            version.FileMajor, 
                            version.FileMinor, 
                            version.FileBuild);

            contents = GalleryContents.Load(galleryFilePath).GalleryUiContents;

            //Set image path relative to gallery Directory
            SetImagePath(galleryDirectory);

            currentContent = contents.FirstOrDefault();
            if (currentContent != null) //if contents is not empty
            {
                currentContent.IsCurrent = true;
            }


            MoveNextCommand = new DelegateCommand(p => MoveIndex(true), o => contents.Count > 1);
            MovePrevCommand = new DelegateCommand(p => MoveIndex(false), o => contents.Count > 1);
            CloseGalleryCommand = new DelegateCommand(p => dvm.CloseGalleryCommand.Execute(null), o => true);
        }
Ejemplo n.º 9
0
 protected AbstractMutator(Random rand)
 {
     this.Rand = rand;
     this.Controller = dynSettings.Controller;
     this.DynamoViewModel = Controller.DynamoViewModel;
     this.DynamoModel = Controller.DynamoModel;
 }
Ejemplo n.º 10
0
 public AboutWindow(DynamoViewModel dynamoViewModel)
 {
     InitializeComponent();
     InstallNewUpdate = false;
     PreviewKeyDown += new KeyEventHandler(HandleEsc);
     DataContext = dynamoViewModel;
 }
        public UsageReportingAgreementPrompt(IBrandingResourceProvider resourceProvider, DynamoViewModel dynamoViewModel)
        {
            InitializeComponent();
            Title = resourceProvider.GetString(Wpf.Interfaces.ResourceNames.ConsentForm.Title);

            ConsentFormImageRectangle.Fill = new ImageBrush(
                resourceProvider.GetImageSource(Wpf.Interfaces.ResourceNames.ConsentForm.Image));

            viewModel = dynamoViewModel;

            var instrumentationFile = "InstrumentationConsent.rtf";

            if (viewModel.Model.PathManager.ResolveDocumentPath(ref instrumentationFile))
                InstrumentationContent.File = instrumentationFile;

            var googleAnalyticsFile = "GoogleAnalyticsConsent.rtf";

            if (viewModel.Model.PathManager.ResolveDocumentPath(ref googleAnalyticsFile))
                GoogleAnalyticsContent.File = googleAnalyticsFile;

            AcceptUsageReportingTextBlock.Text =
                string.Format(Wpf.Properties.Resources.ConsentFormInstrumentationCheckBoxContent,
                    dynamoViewModel.BrandingResourceProvider.ProductName);
            AcceptUsageReportingCheck.IsChecked = UsageReportingManager.Instance.IsUsageReportingApproved;
            AcceptAnalyticsReportingCheck.IsChecked = UsageReportingManager.Instance.IsAnalyticsReportingApproved;

        }
Ejemplo n.º 12
0
 public AboutWindow(DynamoLogger logger, DynamoViewModel model)
 {
     InitializeComponent();
     this.logger = logger;
     this.InstallNewUpdate = false;
     this.PreviewKeyDown += new KeyEventHandler(HandleEsc);
     this.DataContext = model;
 }
Ejemplo n.º 13
0
 public CrashPrompt(DynamoViewModel dynamoViewModel)
 {
     InitializeComponent();
     this.CrashDetailsContent.Text = "Unknown error";
     productName = dynamoViewModel.BrandingResourceProvider.ProductName;
     Title = string.Format(Wpf.Properties.Resources.CrashPromptDialogTitle, productName);
     txtOverridingText.Text = string.Format(Wpf.Properties.Resources.CrashPromptDialogCrashMessage, productName);
 }
 public PackageManagerClientViewModel(DynamoViewModel dynamoViewModel, PackageManagerClient packageManagerClient )
 {
     this.dynamoViewModel = dynamoViewModel;
     this.packageManagerClient = packageManagerClient;
     this.CachedPackageList = new List<PackageManagerSearchElement>();
     this.packageManagerClient.RequestAuthentication +=
         dynamoViewModel.OnRequestAuthentication;
 }
Ejemplo n.º 15
0
        internal ViewStartupParams(DynamoViewModel dynamoVM) :
            base(dynamoVM.Model.AuthenticationManager.AuthProvider,
                dynamoVM.Model.PathManager,
                new ExtensionLibraryLoader(dynamoVM.Model), 
				dynamoVM.Model.CustomNodeManager,
                dynamoVM.Model.GetType().Assembly.GetName().Version)
        {
            dynamoViewModel = dynamoVM;
        }
Ejemplo n.º 16
0
 public DynamoOpenFileDialog(DynamoViewModel model)
 {
     this.model = model;
     _dialog = new NativeFileOpenDialog();
     IFileDialogCustomize customize = (IFileDialogCustomize) _dialog;
     customize.AddCheckButton(RunManualCheckboxId, 
         Dynamo.Wpf.Properties.Resources.FileDialogManualMode,
         model.PreferenceSettings.OpenFileInManualExecutionMode);
 }
Ejemplo n.º 17
0
        public AboutWindow(DynamoViewModel dynamoViewModel)
        {
            InitializeComponent();
            InstallNewUpdate = false;
            PreviewKeyDown += new KeyEventHandler(HandleEsc);
            DataContext = dynamoViewModel;

            Title = string.Format(Dynamo.Wpf.Properties.Resources.AboutWindowTitle,dynamoViewModel.BrandingResourceProvider.ProductName);
            DynamoWebsiteButton.Content = string.Format(Dynamo.Wpf.Properties.Resources.AboutWindowDynamoWebsiteButton, dynamoViewModel.BrandingResourceProvider.ProductName);
        }
Ejemplo n.º 18
0
        public AboutWindow(ILogger logger, DynamoViewModel model)
        {
            InitializeComponent();
            this.logger = logger;
            InstallNewUpdate = false;
            PreviewKeyDown += new KeyEventHandler(HandleEsc);
            DataContext = model;

            Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
        }
Ejemplo n.º 19
0
        public AboutWindow(DynamoViewModel dynamoViewModel)
        {
            InitializeComponent();
            InstallNewUpdate = false;
            PreviewKeyDown += new KeyEventHandler(HandleEsc);
            DataContext = dynamoViewModel;

#if ENABLE_DYNAMO_SCHEDULER
            // SCHEDULER: Temporary way to tell that scheduler is enabled.
            VersionNumber.Foreground = new SolidColorBrush(Colors.Yellow);
#endif
        }
Ejemplo n.º 20
0
 public Watch3DViewModelStartupParams(DynamoModel model, DynamoViewModel viewModel, string name)
 {
     Model = model;
     Scheduler = model.Scheduler;
     Logger = model.Logger;
     Preferences = model.PreferenceSettings;
     EngineControllerManager = model;
     RenderPackageFactory = viewModel.RenderPackageFactoryViewModel.Factory;
     ViewModel = viewModel;
     RenderPackageFactoryViewModel = viewModel.RenderPackageFactoryViewModel;
     Name = name;
 }
Ejemplo n.º 21
0
        public ParameterEditor(NodeViewModel nodeViewModel)
        {
            InitializeComponent();

            this.nodeViewModel = nodeViewModel;
            this.dynamoViewModel = nodeViewModel.DynamoViewModel;
            this.DataContext = nodeViewModel.NodeModel;
            this.InnerTextEditor.TextArea.LostFocus += OnTextAreaLostFocus;
            this.InnerTextEditor.TextArea.TextEntering += OnTextAreaTextEntering;
            this.InnerTextEditor.TextArea.TextEntered += OnTextAreaTextEntered;

            InitializeSyntaxHighlighter();
        }
Ejemplo n.º 22
0
        public CodeBlockEditor(NodeViewModel nodeViewModel)
        {
            InitializeComponent();

            this.nodeViewModel = nodeViewModel;
            this.dynamoViewModel = nodeViewModel.DynamoViewModel;
            this.DataContext = nodeViewModel.NodeModel;

            // Register text editing events
            this.InnerTextEditor.TextChanged += InnerTextEditor_TextChanged;
            this.InnerTextEditor.TextArea.LostFocus += TextArea_LostFocus;
            this.Loaded += (obj, args) => this.InnerTextEditor.TextArea.Focus();

            InitializeSyntaxHighlighter();
        }
Ejemplo n.º 23
0
        public void Regressions(RegressionTestData testData)
        {
            Exception exception = null;

            try
            {
                var dynamoFilePath = testData.Arguments[0].ToString();
                var revitFilePath = testData.Arguments[1].ToString();

                Setup();

                //ensure that the incoming arguments are not empty or null
                //if a dyn file is found in the regression tests directory
                //and there is no corresponding rfa or rvt, then an empty string
                //or a null will be passed into here.
                Assert.IsNotNullOrEmpty(dynamoFilePath, "Dynamo file path is invalid or missing.");
                Assert.IsNotNullOrEmpty(revitFilePath, "Revit file path is invalid or missing.");

                //open the revit model
                SwapCurrentModel(revitFilePath);

                //open the dyn file
                ViewModel.OpenCommand.Execute(dynamoFilePath);

                //run the expression and assert that it does not
                //throw an error
                Assert.DoesNotThrow(() => ViewModel.Model.RunExpression());
                var errorNodes =
                    ViewModel.Model.Nodes.Where(
                        x => x.State == ElementState.Error || x.State == ElementState.Warning);
                Assert.AreEqual(0, errorNodes.Count());
            }
            catch (Exception ex)
            {
                exception = ex;
            }
            finally
            {
                ViewModel.Model.ShutDown(false);
                ViewModel = null;
                Teardown();
            }

            if (exception != null)
            {
                Assert.Fail(exception.Message);
            }
        }
Ejemplo n.º 24
0
        public override void Cleanup()
        {
            try
            {
                ViewModel.Model.ShutDown(false, null);
                ViewModel = null;
                DynamoSelection.Instance.ClearSelection();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }

            base.Cleanup();

            GC.Collect();
        }
Ejemplo n.º 25
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();
        }
Ejemplo n.º 26
0
        public HomeWorkspaceViewModel(HomeWorkspaceModel model, DynamoViewModel dynamoViewModel)
            : base(model, dynamoViewModel)
        {
            RunSettingsViewModel = new RunSettingsViewModel(((HomeWorkspaceModel)model).RunSettings, this, dynamoViewModel);
            RunSettingsViewModel.PropertyChanged += RunSettingsViewModel_PropertyChanged;

            StartPeriodicTimerCommand = new DelegateCommand(StartPeriodicTimer, CanStartPeriodicTimer);
            StopPeriodicTimerCommand = new DelegateCommand(StopPeriodicTimer, CanStopPeriodicTimer);

            CheckAndSetPeriodicRunCapability();

            var hwm = (HomeWorkspaceModel)Model;
            hwm.EvaluationStarted += hwm_EvaluationStarted;
            hwm.EvaluationCompleted += hwm_EvaluationCompleted;
            hwm.SetNodeDeltaState +=hwm_SetNodeDeltaState;

            dynamoViewModel.Model.ShutdownStarted += Model_ShutdownStarted;
        }
Ejemplo n.º 27
0
        protected void StartDynamo()
        {
            DynamoPathManager.Instance.InitializeCore(
               Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            DynamoPathManager.PreloadAsmLibraries(DynamoPathManager.Instance);
            
            var model = DynamoModel.Start(
                new DynamoModel.StartConfiguration()
                {
                    StartInTestMode = true
                });

            this.ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
                {
                    DynamoModel = model
                });
        }
Ejemplo n.º 28
0
        internal AutomationSettings(DynamoViewModel vm, string commandFilePath)
        {
            this.CommandInterval = 20; // 20ms between two consecutive commands.
            this.PauseAfterPlayback = 10; // 10ms after playback is done.
            this.ExitAfterPlayback = true; // Exit Dynamo after playback.

            this.CurrentMode = Mode.None;
            if (LoadCommandFromFile(commandFilePath))
                this.CurrentMode = Mode.Playback;
            else
            {
                this.CurrentMode = Mode.Recording;
                recordedCommands = new List<DynCmd.RecordableCommand>();
            }

            this.owningViewModel = vm;
            if (null == this.owningViewModel)
                throw new ArgumentNullException("vm");
        }
Ejemplo n.º 29
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();
                };
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// The class constructor. </summary>
        /// <param name="header">The PackageHeader object describing the element</param>
        public PackageManagerSearchElement(DynamoViewModel dynamoViewModel, Greg.Responses.PackageHeader header)
        {
            this.dynamoViewModel = dynamoViewModel;

            this.Header = header;
            this.Weight = header.deprecated ? 0.1 : 1;

            if (header.keywords != null && header.keywords.Count > 0)
            {
                this.Keywords = String.Join(" ", header.keywords);
            } 
            else
            {
                this.Keywords = "";
            }
            this.Votes = header.votes;
            this.IsExpanded = false;
            this.DownloadLatest = new DelegateCommand((Action) Execute);
            this.UpvoteCommand = new DelegateCommand((Action) Upvote, CanUpvote);
            this.DownvoteCommand = new DelegateCommand((Action) Downvote, CanDownvote);
        }
Ejemplo n.º 31
0
 protected override void ExecuteCore(DynamoViewModel dynamoViewModel)
 {
     dynamoViewModel.UndoRedoImpl(this);
 }
Ejemplo n.º 32
0
        /// <summary>
        /// The PreferencesViewModel constructor basically initialize all the ItemsSource for the corresponding ComboBox in the View (PreferencesView.xaml)
        /// </summary>
        public PreferencesViewModel(DynamoViewModel dynamoViewModel)
        {
            this.preferenceSettings            = dynamoViewModel.PreferenceSettings;
            this.pythonScriptEditorTextOptions = dynamoViewModel.PythonScriptEditorTextOptions;
            this.runPreviewEnabled             = dynamoViewModel.HomeSpaceViewModel.RunSettingsViewModel.RunButtonEnabled;
            this.homeSpace                  = dynamoViewModel.HomeSpace;
            this.dynamoViewModel            = dynamoViewModel;
            this.installedPackagesViewModel = new InstalledPackagesViewModel(dynamoViewModel,
                                                                             dynamoViewModel.PackageManagerClientViewModel.PackageManagerExtension.PackageLoader);

            // Scan for engines
            AddPythonEnginesOptions();

            PythonEngineManager.Instance.AvailableEngines.CollectionChanged += PythonEnginesChanged;

            //Sets SelectedPythonEngine.
            //If the setting is empty it corresponds to the default python engine
            var engine = PythonEnginesList.FirstOrDefault(x => x.Equals(preferenceSettings.DefaultPythonEngine));

            SelectedPythonEngine = string.IsNullOrEmpty(engine) ? Res.DefaultPythonEngineNone : preferenceSettings.DefaultPythonEngine;

            string languages = Wpf.Properties.Resources.PreferencesWindowLanguages;

            LanguagesList    = new ObservableCollection <string>(languages.Split(','));
            SelectedLanguage = languages.Split(',').First();

            FontSizeList = new ObservableCollection <string>();
            FontSizeList.Add(Wpf.Properties.Resources.ScalingSmallButton);
            FontSizeList.Add(Wpf.Properties.Resources.ScalingMediumButton);
            FontSizeList.Add(Wpf.Properties.Resources.ScalingLargeButton);
            FontSizeList.Add(Wpf.Properties.Resources.ScalingExtraLargeButton);
            SelectedFontSize = Wpf.Properties.Resources.ScalingMediumButton;

            NumberFormatList = new ObservableCollection <string>();
            NumberFormatList.Add(Wpf.Properties.Resources.DynamoViewSettingMenuNumber0);
            NumberFormatList.Add(Wpf.Properties.Resources.DynamoViewSettingMenuNumber00);
            NumberFormatList.Add(Wpf.Properties.Resources.DynamoViewSettingMenuNumber000);
            NumberFormatList.Add(Wpf.Properties.Resources.DynamoViewSettingMenuNumber0000);
            NumberFormatList.Add(Wpf.Properties.Resources.DynamoViewSettingMenuNumber00000);
            SelectedNumberFormat = preferenceSettings.NumberFormat;

            runSettingsIsChecked = preferenceSettings.DefaultRunType;
            RunPreviewIsChecked  = preferenceSettings.ShowRunPreview;

            //By Default the warning state of the Visual Settings tab (Group Styles section) will be disabled
            isWarningEnabled = false;

            StyleItemsList = LoadStyles(preferenceSettings.GroupStyleItemsList);

            //When pressing the "Add Style" button some controls will be shown with some values by default so later they can be populated by the user
            AddStyleControl = new StyleItem()
            {
                GroupName = "", HexColorString = "#" + GetRandomHexStringColor()
            };

            //This piece of code will populate all the description text for the RadioButtons in the Geometry Scaling section.
            optionsGeometryScale = new GeometryScalingOptions();

            UpdateGeoScaleRadioButtonSelected(dynamoViewModel.ScaleFactorLog);

            optionsGeometryScale.DescriptionScaleRange = new ObservableCollection <string>();
            optionsGeometryScale.DescriptionScaleRange.Add(string.Format(Res.ChangeScaleFactorPromptDescriptionContent, scaleRanges[GeometryScaleSize.Small].Item2,
                                                                         scaleRanges[GeometryScaleSize.Small].Item3));
            optionsGeometryScale.DescriptionScaleRange.Add(string.Format(Res.ChangeScaleFactorPromptDescriptionContent, scaleRanges[GeometryScaleSize.Medium].Item2,
                                                                         scaleRanges[GeometryScaleSize.Medium].Item3));
            optionsGeometryScale.DescriptionScaleRange.Add(string.Format(Res.ChangeScaleFactorPromptDescriptionContent, scaleRanges[GeometryScaleSize.Large].Item2,
                                                                         scaleRanges[GeometryScaleSize.Large].Item3));
            optionsGeometryScale.DescriptionScaleRange.Add(string.Format(Res.ChangeScaleFactorPromptDescriptionContent, scaleRanges[GeometryScaleSize.ExtraLarge].Item2,
                                                                         scaleRanges[GeometryScaleSize.ExtraLarge].Item3));

            SavedChangesLabel   = string.Empty;
            SavedChangesTooltip = string.Empty;

            preferencesTabs = new Dictionary <string, TabSettings>();
            preferencesTabs.Add("General", new TabSettings()
            {
                Name = "General", ExpanderActive = string.Empty
            });
            preferencesTabs.Add("Features", new TabSettings()
            {
                Name = "Features", ExpanderActive = string.Empty
            });
            preferencesTabs.Add("VisualSettings", new TabSettings()
            {
                Name = "VisualSettings", ExpanderActive = string.Empty
            });
            preferencesTabs.Add("Package Manager", new TabSettings()
            {
                Name = "Package Manager", ExpanderActive = string.Empty
            });

            //create a packagePathsViewModel we'll use to interact with the package search paths list.
            var loadPackagesParams = new LoadPackageParams
            {
                Preferences = preferenceSettings
            };
            var customNodeManager = dynamoViewModel.Model.CustomNodeManager;
            var packageLoader     = dynamoViewModel.Model.GetPackageManagerExtension()?.PackageLoader;

            PackagePathsViewModel = new PackagePathViewModel(packageLoader, loadPackagesParams, customNodeManager);

            WorkspaceEvents.WorkspaceSettingsChanged += PreferencesViewModel_WorkspaceSettingsChanged;

            PropertyChanged += Model_PropertyChanged;
        }
Ejemplo n.º 33
0
 protected override void ExecuteCore(DynamoViewModel dynamoViewModel)
 {
     dynamoViewModel.DeleteModelImpl(this);
 }
Ejemplo n.º 34
0
            internal bool HandleMouseMove(object sender, Point mouseCursor)
            {
                if (this.currentState == State.Connection)
                {
                    // If we are currently connecting and there is an active
                    // connector, redraw it to match the new mouse coordinates.

                    owningWorkspace.UpdateActiveConnector(mouseCursor);
                }
                else if (this.currentState == State.WindowSelection)
                {
                    // When the mouse is held down, reposition the drag selection box.
                    double x      = Math.Min(mouseDownPos.X, mouseCursor.X);
                    double y      = Math.Min(mouseDownPos.Y, mouseCursor.Y);
                    double width  = Math.Abs(mouseDownPos.X - mouseCursor.X);
                    double height = Math.Abs(mouseCursor.Y - mouseDownPos.Y);

                    // We perform cross selection (i.e. select a node whenever
                    // it touches the selection box as opposed to only select
                    // it when it is entirely within the selection box) when
                    // mouse moves in the opposite direction (i.e. the current
                    // mouse position is smaller than the point mouse-down
                    // happened).
                    //
                    bool isCrossSelection = mouseCursor.X < mouseDownPos.X;

                    SelectionBoxUpdateArgs args = null;
                    args = new SelectionBoxUpdateArgs(x, y, width, height);
                    args.SetSelectionMode(isCrossSelection);
                    this.owningWorkspace.RequestSelectionBoxUpdate(this, args);

                    var rect = new Rect(x, y, width, height);

                    var             command         = new DynCmd.SelectInRegionCommand(rect, isCrossSelection);
                    DynamoViewModel dynamoViewModel = dynSettings.Controller.DynamoViewModel;
                    dynamoViewModel.ExecuteCommand(command);
                }
                else if (this.currentState == State.DragSetup)
                {
                    // There are something in the selection, but none is ILocatable.
                    if (!DynamoSelection.Instance.Selection.Any((x) => (x is ILocatable)))
                    {
                        SetCurrentState(State.None);
                        return(false);
                    }

                    // Record and begin the drag operation for selected nodes.
                    var             operation       = DynCmd.DragSelectionCommand.Operation.BeginDrag;
                    var             command         = new DynCmd.DragSelectionCommand(mouseCursor, operation);
                    DynamoViewModel dynamoViewModel = dynSettings.Controller.DynamoViewModel;
                    dynamoViewModel.ExecuteCommand(command);

                    SetCurrentState(State.NodeReposition);
                    return(true);
                }
                else if (this.currentState == State.NodeReposition)
                {
                    // Update the dragged nodes (note: this isn't recorded).
                    owningWorkspace.UpdateDraggedSelection(mouseCursor);
                }

                return(false); // Mouse event not handled.
            }
        private static bool CustomNodeHasCollisons(string nodeName, string packageName, DynamoViewModel viewModel)
        {
            var pmExtension = viewModel.Model.GetPackageManagerExtension();

            if (pmExtension is null)
            {
                return(false);
            }

            var package = pmExtension.PackageLoader.LocalPackages
                          .Where(x => x.Name == packageName)
                          .FirstOrDefault();

            if (package is null)
            {
                return(false);
            }

            var loadedNodesWithSameName = package.LoadedCustomNodes
                                          .Where(x => x.Name == nodeName)
                                          .ToList();

            if (loadedNodesWithSameName.Count == 1)
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 36
0
 private void DoGraphAutoLayout(object o)
 {
     Model.DoGraphAutoLayout();
     DynamoViewModel.RaiseCanExecuteUndoRedo();
 }
 internal NodeAutoCompleteSearchViewModel(DynamoViewModel dynamoViewModel) : base(dynamoViewModel)
 {
     // Do nothing for now, but we may off load some time consuming operation here later
 }
Ejemplo n.º 38
0
 protected override void ExecuteCore(DynamoViewModel dynamoViewModel)
 {
     dynamoViewModel.OpenFileImpl(this);
 }
Ejemplo n.º 39
0
 protected override void ExecuteCore(DynamoViewModel dynamoViewModel)
 {
     dynamoViewModel.ForceRunCancelImpl(this);
 }
Ejemplo n.º 40
0
 /// <summary>
 /// Derived classes must implement this method to perform the actual
 /// command execution. A typical implementation of this method involves
 /// calling a corresponding method on DynamoViewModel by passing itself
 /// as the only argument.
 /// </summary>
 /// <param name="dynamoViewModel">The DynamoViewModel object on which
 /// this command should be executed.</param>
 ///
 protected abstract void ExecuteCore(DynamoViewModel dynamoViewModel);
Ejemplo n.º 41
0
 protected override void ExecuteCore(DynamoViewModel dynamoViewModel)
 {
     // A PausePlaybackCommand should never be executed.
     throw new NotImplementedException();
 }
Ejemplo n.º 42
0
 protected override void ExecuteCore(DynamoViewModel dynamoViewModel)
 {
     dynamoViewModel.SwitchTabImpl(this);
 }
Ejemplo n.º 43
0
 protected override void ExecuteCore(DynamoViewModel dynamoViewModel)
 {
     dynamoViewModel.ConvertNodesToCodeImpl(this);
 }
Ejemplo n.º 44
0
 protected override void ExecuteCore(DynamoViewModel dynamoViewModel)
 {
     dynamoViewModel.UpdateModelValueImpl(this);
 }
Ejemplo n.º 45
0
 protected override void ExecuteCore(DynamoViewModel dynamoViewModel)
 {
     dynamoViewModel.SendModelEventImpl(this);
 }
Ejemplo n.º 46
0
 protected override void ExecuteCore(DynamoViewModel dynamoViewModel)
 {
     dynamoViewModel.MutateTestImpl();
 }
Ejemplo n.º 47
0
 private void Paste(object param)
 {
     var point = InCanvasSearchViewModel.InCanvasSearchPosition;
     DynamoViewModel.Model.Paste(new Point2D(point.X, point.Y), false);
     DynamoViewModel.RaiseCanExecuteUndoRedo();
 }
Ejemplo n.º 48
0
 protected override void ExecuteCore(DynamoViewModel dynamoViewModel)
 {
     dynamoViewModel.CreateNoteImpl(this);
 }
Ejemplo n.º 49
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);

            var annotationsColl = new CollectionContainer {
                Collection = Annotations
            };

            _workspaceElements.Add(annotationsColl);

            //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.NodeAdded    += Model_NodeAdded;
            Model.NodeRemoved  += Model_NodeRemoved;
            Model.NodesCleared += Model_NodesCleared;

            Model.NoteAdded    += Model_NoteAdded;
            Model.NoteRemoved  += Model_NoteRemoved;
            Model.NotesCleared += Model_NotesCleared;

            Model.AnnotationAdded    += Model_AnnotationAdded;
            Model.AnnotationRemoved  += Model_AnnotationRemoved;
            Model.AnnotationsCleared += Model_AnnotationsCleared;

            Model.ConnectorAdded   += Connectors_ConnectorAdded;
            Model.ConnectorDeleted += Connectors_ConnectorDeleted;
            Model.PropertyChanged  += ModelPropertyChanged;

            DynamoSelection.Instance.Selection.CollectionChanged += RefreshViewOnSelectionChange;

            DynamoViewModel.CopyCommand.CanExecuteChanged  += CopyPasteChanged;
            DynamoViewModel.PasteCommand.CanExecuteChanged += CopyPasteChanged;

            // sync collections

            foreach (NodeModel node in Model.Nodes)
            {
                Model_NodeAdded(node);
            }
            foreach (NoteModel note in Model.Notes)
            {
                Model_NoteAdded(note);
            }
            foreach (AnnotationModel annotation in Model.Annotations)
            {
                Model_AnnotationAdded(annotation);
            }
            foreach (ConnectorModel connector in Model.Connectors)
            {
                Connectors_ConnectorAdded(connector);
            }

            InCanvasSearchViewModel         = new SearchViewModel(DynamoViewModel);
            InCanvasSearchViewModel.Visible = true;
        }
Ejemplo n.º 50
0
 /// <summary>
 /// Call this method to execute a RecordableCommand. A RecordableCommand
 /// must be executed in the context of an existing DynamoViewModel.
 /// </summary>
 /// <param name="dynamoViewModel">The DynamoViewModel object this
 /// RecordableCommand is targeting.</param>
 ///
 internal void Execute(DynamoViewModel dynamoViewModel)
 {
     ExecuteCore(dynamoViewModel);
 }
Ejemplo n.º 51
0
 public PackageManagerClientViewModel(DynamoViewModel dynamoViewModel, PackageManagerClient model)
 {
     this.dynamoViewModel   = dynamoViewModel;
     this.Model             = model;
     this.CachedPackageList = new List <PackageManagerSearchElement>();
 }
Ejemplo n.º 52
0
 protected override void ExecuteCore(DynamoViewModel dynamoViewModel)
 {
     dynamoViewModel.DragSelectionImpl(this);
 }
Ejemplo n.º 53
0
        /// <summary>
        /// The PreferencesViewModel constructor basically initialize all the ItemsSource for the corresponding ComboBox in the View (PreferencesView.xaml)
        /// </summary>
        public PreferencesViewModel(DynamoViewModel dynamoViewModel)
        {
            this.preferenceSettings            = dynamoViewModel.PreferenceSettings;
            this.pythonScriptEditorTextOptions = dynamoViewModel.PythonScriptEditorTextOptions;
            this.runPreviewEnabled             = dynamoViewModel.HomeSpaceViewModel.RunSettingsViewModel.RunButtonEnabled;
            this.homeSpace       = dynamoViewModel.HomeSpace;
            this.dynamoViewModel = dynamoViewModel;

            PythonEnginesList = new ObservableCollection <string>();
            PythonEnginesList.Add(Wpf.Properties.Resources.DefaultPythonEngineNone);
            AddPythonEnginesOptions();
            SelectedPythonEngine = preferenceSettings.DefaultPythonEngine;

            string languages = Wpf.Properties.Resources.PreferencesWindowLanguages;

            LanguagesList    = new ObservableCollection <string>(languages.Split(','));
            SelectedLanguage = languages.Split(',').First();

            FontSizeList = new ObservableCollection <string>();
            FontSizeList.Add(Wpf.Properties.Resources.ScalingSmallButton);
            FontSizeList.Add(Wpf.Properties.Resources.ScalingMediumButton);
            FontSizeList.Add(Wpf.Properties.Resources.ScalingLargeButton);
            FontSizeList.Add(Wpf.Properties.Resources.ScalingExtraLargeButton);
            SelectedFontSize = Wpf.Properties.Resources.ScalingMediumButton;

            NumberFormatList = new ObservableCollection <string>();
            NumberFormatList.Add(Wpf.Properties.Resources.DynamoViewSettingMenuNumber0);
            NumberFormatList.Add(Wpf.Properties.Resources.DynamoViewSettingMenuNumber00);
            NumberFormatList.Add(Wpf.Properties.Resources.DynamoViewSettingMenuNumber000);
            NumberFormatList.Add(Wpf.Properties.Resources.DynamoViewSettingMenuNumber0000);
            NumberFormatList.Add(Wpf.Properties.Resources.DynamoViewSettingMenuNumber00000);
            SelectedNumberFormat = preferenceSettings.NumberFormat;

            runSettingsIsChecked = preferenceSettings.DefaultRunType;

            //By Default the warning state of the Visual Settings tab (Group Styles section) will be disabled
            isWarningEnabled = false;

            StyleItemsList = new ObservableCollection <StyleItem>();

            //When pressing the "Add Style" button some controls will be shown with some values by default so later they can be populated by the user
            AddStyleControl = new StyleItem()
            {
                GroupName = "", HexColorString = "#" + GetRandomHexStringColor()
            };

            //This piece of code will populate all the description text for the RadioButtons in the Geometry Scaling section.
            optionsGeometryScal = new GeometryScalingOptions();

            //This will set the default option for the Geometry Scaling Radio Buttons, the value is comming from the DynamoViewModel
            optionsGeometryScal.EnumProperty = (GeometryScaleSize)GeometryScalingOptions.ConvertScaleFactorToUI(dynamoViewModel.ScaleFactorLog);

            optionsGeometryScal.DescriptionScaleRange = new ObservableCollection <string>();
            optionsGeometryScal.DescriptionScaleRange.Add(string.Format(Res.ChangeScaleFactorPromptDescriptionContent, scaleRanges[GeometryScaleSize.Small].Item2,
                                                                        scaleRanges[GeometryScaleSize.Small].Item3));
            optionsGeometryScal.DescriptionScaleRange.Add(string.Format(Res.ChangeScaleFactorPromptDescriptionContent, scaleRanges[GeometryScaleSize.Medium].Item2,
                                                                        scaleRanges[GeometryScaleSize.Medium].Item3));
            optionsGeometryScal.DescriptionScaleRange.Add(string.Format(Res.ChangeScaleFactorPromptDescriptionContent, scaleRanges[GeometryScaleSize.Large].Item2,
                                                                        scaleRanges[GeometryScaleSize.Large].Item3));
            optionsGeometryScal.DescriptionScaleRange.Add(string.Format(Res.ChangeScaleFactorPromptDescriptionContent, scaleRanges[GeometryScaleSize.ExtraLarge].Item2,
                                                                        scaleRanges[GeometryScaleSize.ExtraLarge].Item3));

            SavedChangesLabel   = string.Empty;
            SavedChangesTooltip = string.Empty;

            this.PropertyChanged += model_PropertyChanged;
        }
Ejemplo n.º 54
0
 protected override void ExecuteCore(DynamoViewModel dynamoViewModel)
 {
     dynamoViewModel.MakeConnectionImpl(this);
 }
Ejemplo n.º 55
0
        public WorkspaceViewModel(WorkspaceModel model, DynamoViewModel dynamoViewModel)
        {
            this.DynamoViewModel = dynamoViewModel;
            this.DynamoViewModel.PropertyChanged += DynamoViewModel_PropertyChanged;

            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);

            var annotationsColl = new CollectionContainer {
                Collection = Annotations
            };

            _workspaceElements.Add(annotationsColl);

            //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.NodeAdded    += Model_NodeAdded;
            Model.NodeRemoved  += Model_NodeRemoved;
            Model.NodesCleared += Model_NodesCleared;

            Model.Notes.CollectionChanged       += Notes_CollectionChanged;
            Model.Annotations.CollectionChanged += Annotations_CollectionChanged;
            Model.ConnectorAdded   += Connectors_ConnectorAdded;
            Model.ConnectorDeleted += Connectors_ConnectorDeleted;
            Model.PropertyChanged  += ModelPropertyChanged;

            DynamoSelection.Instance.Selection.CollectionChanged +=
                (sender, e) => RefreshViewOnSelectionChange();

            // sync collections


            foreach (NodeModel node in Model.Nodes)
            {
                Model_NodeAdded(node);
            }
            Notes_CollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Model.Notes));
            Annotations_CollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Model.Annotations));
            foreach (var c in Model.Connectors)
            {
                Connectors_ConnectorAdded(c);
            }

            InCanvasSearchViewModel         = new SearchViewModel(DynamoViewModel);
            InCanvasSearchViewModel.Visible = true;
        }
Ejemplo n.º 56
0
 internal NodeAutoCompleteSearchViewModel(DynamoViewModel dynamoViewModel) : base(dynamoViewModel)
 {
     // Off load some time consuming operation here
     InitializeDefaultAutoCompleteCandidates();
 }