/// <summary> /// The PreferencesViewModel constructor basically initialize all the ItemsSource for the corresponding ComboBox in the View (PreferencesView.xaml) /// </summary> public PreferencesViewModel(PreferenceSettings preferenceSettings, DynamoPythonScriptEditorTextOptions editTextOptions) { this.preferenceSettings = preferenceSettings; this.pythonScriptEditorTextOptions = editTextOptions; 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 = Wpf.Properties.Resources.DynamoViewSettingMenuNumber0000; //By Default the Default Run Settings radio button will be in Manual RunSettingsIsChecked = true; //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(); optionsGeometryScal.EnumProperty = GeometryScaleSize.Medium; 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)); }
/// <summary> /// This method will update the currently selected Radio Button in the Geometry Scaling section. /// </summary> /// <param name="scaleFactor"></param> private void UpdateGeoScaleRadioButtonSelected(int scaleFactor) { optionsGeometryScale.EnumProperty = (GeometryScaleSize)GeometryScalingOptions.ConvertScaleFactorToUI(scaleFactor); }
/// <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; }
/// <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; }