-
Notifications
You must be signed in to change notification settings - Fork 675
Expand file tree
/
Copy pathPreferencesViewModel.cs
More file actions
2231 lines (2038 loc) · 85.1 KB
/
Copy pathPreferencesViewModel.cs
File metadata and controls
2231 lines (2038 loc) · 85.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows;
using Dynamo.Configuration;
using Dynamo.Core;
using Dynamo.Logging;
using Dynamo.Models;
using Dynamo.PackageManager;
using Dynamo.PythonServices;
using Dynamo.UI.Commands;
using Dynamo.Utilities;
using Dynamo.Wpf.ViewModels.Core.Converters;
using DynamoUtilities;
using ViewModels.Core;
using Res = Dynamo.Wpf.Properties.Resources;
namespace Dynamo.ViewModels
{
/// <summary>
/// The next enum will contain the possible values for Scaling (Visual Settings -> Geometry Scaling section)
/// </summary>
public enum GeometryScaleSize
{
Small,
Medium,
Large,
ExtraLarge
}
/// <summary>
/// Preferences data context
/// </summary>
public class PreferencesViewModel : ViewModelBase, INotifyPropertyChanged
{
#region Private Properties
private string savedChangesLabel;
private string savedChangesTooltip;
private string currentWarningMessage;
private string selectedPackagePathForInstall;
private string selectedLanguage;
private string selectedUnits;
private string selectedNumberFormat;
private string selectedPythonEngine;
private ObservableCollection<string> languagesList;
private ObservableCollection<string> unitList;
private ObservableCollection<string> packagePathsForInstall;
private ObservableCollection<string> fontSizeList;
private ObservableCollection<int> groupStyleFontSizeList;
private ObservableCollection<string> numberFormatList;
private StyleItem addStyleControl;
private ObservableCollection<string> pythonEngineList;
private RunType runSettingsIsChecked;
private NodeAutocompleteSuggestion nodeAutocompleteSuggestion;
private Dictionary<string, TabSettings> preferencesTabs;
private readonly PreferenceSettings preferenceSettings;
private readonly DynamoPythonScriptEditorTextOptions pythonScriptEditorTextOptions;
private readonly DynamoViewModel dynamoViewModel;
private readonly InstalledPackagesViewModel installedPackagesViewModel;
private bool isWarningEnabled;
private bool isSaveButtonEnabled = true;
private bool isVisibleAddStyleBorder;
private bool isEnabledAddStyleButton;
private GeometryScalingOptions optionsGeometryScale = null;
private GeometryScaleSize defaultGeometryScaling = GeometryScaleSize.Medium;
private bool canResetBackupLocation = false;
private bool canResetTemplateLocation = false;
#endregion Private Properties
public GeometryScaleSize DefaultGeometryScaling
{
get
{
return defaultGeometryScaling;
}
set
{
if(defaultGeometryScaling != value)
{
defaultGeometryScaling = value;
SelectedDefaultScaleFactor = GeometryScalingOptions.ConvertUIToScaleFactor((int)defaultGeometryScaling);
RaisePropertyChanged(nameof(DefaultGeometryScaling));
}
}
}
/// <summary>
/// This property will be used by the Preferences screen to store and retrieve all the settings from the expanders
/// </summary>
public Dictionary<string, TabSettings> PreferencesTabs
{
get
{
return preferencesTabs;
}
set
{
preferencesTabs = value;
RaisePropertyChanged(nameof(PreferencesTabs));
}
}
/// <summary>
/// Controls what the SavedChanges label will display
/// </summary>
public string SavedChangesLabel
{
get
{
return savedChangesLabel;
}
set
{
savedChangesLabel = value;
RaisePropertyChanged(nameof(SavedChangesLabel));
}
}
/// <summary>
/// Controls what SavedChanges label's tooltip will display
/// </summary>
public string SavedChangesTooltip
{
get
{
return savedChangesTooltip;
}
set
{
savedChangesTooltip = value;
RaisePropertyChanged(nameof(SavedChangesTooltip));
}
}
/// <summary>
/// Returns all installed packages
/// </summary>
public ObservableCollection<PackageViewModel> LocalPackages => installedPackagesViewModel.LocalPackages;
/// <summary>
/// Returns all available filters
/// </summary>
public ObservableCollection<PackageFilter> Filters => installedPackagesViewModel.Filters;
//This includes all the properties that can be set on the General tab
#region General Properties
/// <summary>
/// Controls the Selected option in Language ComboBox
/// </summary>
public string SelectedLanguage
{
get
{
return selectedLanguage;
}
set
{
if (selectedLanguage != value)
{
selectedLanguage = value;
RaisePropertyChanged(nameof(SelectedLanguage));
if (Configurations.SupportedLocaleDic.TryGetValue(selectedLanguage, out string locale))
{
preferenceSettings.Locale = locale;
dynamoViewModel.ToastManager?.CreateRealTimeInfoWindow(Res.PreferencesViewLanguageSwitchHelp, true);
}
}
}
}
/// <summary>
/// Contains the currently selected scaling unit used for grahic helpers (grids, axes)
/// </summary>
public string SelectedUnits
{
get
{
return selectedUnits;
}
set
{
if (selectedUnits != value)
{
selectedUnits = value;
RaisePropertyChanged(nameof(SelectedUnits));
if (UseHostScaleUnits && IsDynamoRevit) return;
var enUnit = LocalizedUnitsMap.FirstOrDefault(x => x.Key == selectedUnits).Value;
var result = Enum.TryParse(enUnit, out Configurations.Units currentUnit);
if (!result) return;
if (Configurations.SupportedUnits.TryGetValue(currentUnit, out double units))
{
// Update preferences setting and update the grapic helpers
preferenceSettings.GraphicScaleUnit = currentUnit.ToString();
preferenceSettings.GridScaleFactor = (float)units;
dynamoViewModel.UpdateGraphicHelpersScaleCommand.Execute(null);
// We have turn the grid visilibilty on
// Check the current visibility settings, and turn it back off
if (!preferenceSettings.IsBackgroundGridVisible)
{
dynamoViewModel.ToggleBackgroundGridVisibilityCommand.Execute(null); // switch 'on'
dynamoViewModel.ToggleBackgroundGridVisibilityCommand.Execute(null); // switch 'off'
}
}
}
}
}
/// <summary>
/// Controls the Selected option in Number Format ComboBox
/// </summary>
public string SelectedNumberFormat
{
get
{
return preferenceSettings.NumberFormat;
}
set
{
selectedNumberFormat = value;
preferenceSettings.NumberFormat = value;
RaisePropertyChanged(nameof(SelectedNumberFormat));
}
}
/// <summary>
/// This property holds the Geometry Scale factor selected in the Preferences panel (when a new workspace is created this will be the Geometry Scale used)
/// </summary>
public double SelectedDefaultScaleFactor
{
get
{
return preferenceSettings.DefaultScaleFactor;
}
set
{
preferenceSettings.DefaultScaleFactor = value;
RaisePropertyChanged(nameof(SelectedDefaultScaleFactor));
}
}
/// <summary>
/// Time Interval for backup files in minutes
/// Serialized as milliseconds in preferences setting.
/// </summary>
public int BackupIntervalInMinutes
{
get
{
return preferenceSettings.BackupInterval/60000;
}
set
{
preferenceSettings.BackupInterval = value * 60000;
RaisePropertyChanged(nameof(BackupIntervalInMinutes));
}
}
/// <summary>
/// Backup files path
/// </summary>
public string BackupLocation
{
get
{
return preferenceSettings.BackupLocation;
}
set
{
preferenceSettings.BackupLocation = value;
RaisePropertyChanged(nameof(BackupLocation));
RaisePropertyChanged(nameof(CanResetBackupLocation));
}
}
/// <summary>
/// Indicates if the user can reset the Backup Location to the default value
/// </summary>
public bool CanResetBackupLocation
{
get
{
return !dynamoViewModel.Model.IsDefaultPreferenceItemLocation(PathManager.PreferenceItem.Backup);
}
}
/// <summary>
/// Backup files path
/// </summary>
public string TemplateLocation
{
get
{
return preferenceSettings.TemplateFilePath;
}
set
{
preferenceSettings.TemplateFilePath = value;
RaisePropertyChanged(nameof(TemplateLocation));
RaisePropertyChanged(nameof(CanResetTemplateLocation));
}
}
/// <summary>
/// Indicates if the user can reset the Backup Location to the default value
/// </summary>
public bool CanResetTemplateLocation
{
get
{
return !dynamoViewModel.Model.IsDefaultPreferenceItemLocation(PathManager.PreferenceItem.Templates);
}
}
/// <summary>
/// Maximum number of recent files on startup page.
/// </summary>
public int MaxNumRecentFiles
{
get
{
return preferenceSettings.MaxNumRecentFiles;
}
set
{
preferenceSettings.MaxNumRecentFiles = value;
RaisePropertyChanged(nameof(MaxNumRecentFiles));
}
}
/// <summary>
/// Controls the IsChecked property in the RunSettings radio button
/// </summary>
public bool RunSettingsIsChecked
{
get
{
return runSettingsIsChecked == RunType.Manual;
}
set
{
if (value)
{
preferenceSettings.DefaultRunType = RunType.Manual;
runSettingsIsChecked = RunType.Manual;
}
else
{
preferenceSettings.DefaultRunType = RunType.Automatic;
runSettingsIsChecked = RunType.Automatic;
}
RaisePropertyChanged(nameof(RunSettingsIsChecked));
}
}
/// <summary>
/// Controls the IsChecked property in the Show Run Preview toggle button
/// </summary>
public bool RunPreviewIsChecked
{
get
{
return preferenceSettings.ShowRunPreview;
}
set
{
preferenceSettings.ShowRunPreview = value;
dynamoViewModel.ShowRunPreview = value;
RaisePropertyChanged(nameof(RunPreviewIsChecked));
}
}
/// <summary>
/// Controls the IsChecked property in the Show Static Splash Screen toggle button
/// </summary>
public bool StaticSplashScreenEnabled
{
get
{
return preferenceSettings.EnableStaticSplashScreen;
}
set
{
preferenceSettings.EnableStaticSplashScreen = value;
RaisePropertyChanged(nameof(StaticSplashScreenEnabled));
}
}
/// <summary>
/// Controls the IsChecked property in the "start MCP server on launch" toggle button.
/// When enabled, the Dynamo MCP server starts automatically with Dynamo; otherwise it
/// stays off until enabled from the MCP extension's Extensions-menu toggle (DYN-9355).
/// </summary>
public bool McpServerEnabledOnStartup
{
get
{
return preferenceSettings.EnableMcpServerOnStartup;
}
set
{
preferenceSettings.EnableMcpServerOnStartup = value;
RaisePropertyChanged(nameof(McpServerEnabledOnStartup));
}
}
/// <summary>
/// Controls the IsChecked property in the selecting to include timestamp for export path section
/// </summary>
public bool IsTimeStampIncludedInExportFilePath
{
get
{
return preferenceSettings.IsTimeStampIncludedInExportFilePath;
}
set
{
preferenceSettings.IsTimeStampIncludedInExportFilePath = value;
RaisePropertyChanged(nameof(IsTimeStampIncludedInExportFilePath));
}
}
/// <summary>
/// Controls the Enabled property in the Show Run Preview toggle button
/// </summary>
public bool RunPreviewEnabled
{
get
{
return dynamoViewModel.HomeSpaceViewModel.RunSettingsViewModel.RunButtonEnabled;
}
}
/// <summary>
/// LanguagesList property contains the list of all the languages listed in: https://wiki.autodesk.com/display/LOCGD/Dynamo+Languages
/// </summary>
public ObservableCollection<string> LanguagesList
{
get
{
return languagesList;
}
set
{
languagesList = value;
RaisePropertyChanged(nameof(LanguagesList));
}
}
/// <summary>
/// Supported units in Host (Revit), used in scaling of grapic helpers (grid, axes)
/// </summary>
public ObservableCollection<string> UnitList
{
get
{
return unitList;
}
set
{
unitList = value;
RaisePropertyChanged(nameof(UnitList));
}
}
/// <summary>
/// PackagePathsForInstall contains the list of all package paths where
/// packages can be installed.
/// </summary>
public ObservableCollection<string> PackagePathsForInstall
{
get
{
var allowedFileExtensions = new string[] { ".dll", ".ds" };
if (packagePathsForInstall == null || !packagePathsForInstall.Any())
{
var programDataPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
// Filter Builtin Packages and ProgramData paths from list of paths for download
var customPaths = preferenceSettings.CustomPackageFolders.Where(
x => x != DynamoModel.BuiltInPackagesToken && !x.StartsWith(programDataPath));
//filter out paths that have extensions ending in .dll or .ds
var directoryPaths = customPaths.Where(path => !(Path.HasExtension(path) && allowedFileExtensions.Contains(Path.GetExtension(path).ToLower())));
packagePathsForInstall = new ObservableCollection<string>();
foreach (var path in directoryPaths)
{
packagePathsForInstall.Add(path);
}
}
return packagePathsForInstall;
}
set
{
packagePathsForInstall = value;
RaisePropertyChanged(nameof(PackagePathsForInstall));
}
}
/// <summary>
/// Currently selected package path where new packages will be downloaded.
/// </summary>
public string SelectedPackagePathForInstall
{
get
{
return selectedPackagePathForInstall;
}
set
{
if (selectedPackagePathForInstall != value)
{
selectedPackagePathForInstall = value;
RaisePropertyChanged(nameof(SelectedPackagePathForInstall));
}
}
}
/// <summary>
/// Flag specifying whether loading built-in packages
/// is disabled, if true, or enabled, if false.
/// </summary>
public bool DisableBuiltInPackages
{
get
{
return preferenceSettings.DisableBuiltinPackages;
}
set
{
preferenceSettings.DisableBuiltinPackages = value;
PackagePathsViewModel.SetPackagesScheduledState(PathManager.BuiltinPackagesDirectory, value);
RaisePropertyChanged(nameof(DisableBuiltInPackages));
}
}
/// <summary>
/// Flag specifying whether loading custom packages
/// is disabled, if true, or enabled, if false.
/// </summary>
public bool DisableCustomPackages
{
get
{
return preferenceSettings.DisableCustomPackageLocations;
}
set
{
preferenceSettings.DisableCustomPackageLocations = value;
foreach(var path in preferenceSettings.CustomPackageFolders.Where(x => x != DynamoModel.BuiltInPackagesToken))
{
PackagePathsViewModel.SetPackagesScheduledState(path, value);
}
RaisePropertyChanged(nameof(DisableCustomPackages));
}
}
/// <summary>
/// Flag specifying whether trust warnings should be shown
/// when opening .dyn files from unstrusted locations.
/// </summary>
public bool DisableTrustWarnings
{
get
{
return preferenceSettings.DisableTrustWarnings;
}
// We keep this setter private to avoid view extensions calling it directly.
// Access modifiers are not intended for security, but it's simple enough to hook a toggle to the UI
// without binding, and this makes it clear it's not an API.
internal set
{
preferenceSettings.SetTrustWarningsDisabled(value);
}
}
/// <summary>
/// GroupStyleFontSizeList contains the list of sizes for defined fonts to be applied to a GroupStyle
/// </summary>
public ObservableCollection<int> GroupStyleFontSizeList
{
get
{
return groupStyleFontSizeList;
}
set
{
groupStyleFontSizeList = value;
RaisePropertyChanged(nameof(GroupStyleFontSizeList));
}
}
/// <summary>
/// NumberFormatList contains the list of the format for numbers, right now in Dynamo has the next formats: 0, 0.0, 0.00, 0.000, 0.0000
/// </summary>
public ObservableCollection<string> NumberFormatList
{
get
{
return numberFormatList;
}
set
{
numberFormatList = value;
RaisePropertyChanged(nameof(NumberFormatList));
}
}
#endregion
//This includes all the properties that can be set on the Visual Settings tab
#region VisualSettings Properties
/// <summary>
/// This will contain a list of all the Styles created by the user in the Styles list ( Visual Settings -> Group Styles section)
/// </summary>
public ObservableCollection<GroupStyleItem> StyleItemsList
{
get { return preferenceSettings.GroupStyleItemsList.ToObservableCollection(); }
set
{
preferenceSettings.GroupStyleItemsList = value.ToList<GroupStyleItem>();
RaisePropertyChanged(nameof(StyleItemsList));
RaisePropertyChanged(nameof(CanResetGroupStyles));
}
}
/// <summary>
/// Returns whether the current group styles differ from the default set and therefore can be reset.
/// </summary>
public bool CanResetGroupStyles
{
get { return !MatchesDefaultGroupStyles(preferenceSettings.GroupStyleItemsList); }
}
/// <summary>
/// Used to add styles to the StyleItemsListe while also update the saved changes label
/// </summary>
/// <param name="style">style to be added</param>
public void AddStyle(StyleItem style)
{
preferenceSettings.GroupStyleItemsList.Add(new GroupStyleItem {
HexColorString = style.HexColorString,
Name = style.Name,
FontSize = style.FontSize,
GroupStyleId = style.GroupStyleId,
IsDefault = style.IsDefault
});
RaisePropertyChanged(nameof(StyleItemsList));
RaisePropertyChanged(nameof(CanResetGroupStyles));
}
/// <summary>
/// This flag will be in true when the Style that user is trying to add already exists (otherwise will be false - Default)
/// </summary>
public bool IsWarningEnabled
{
get
{
return isWarningEnabled;
}
set
{
isWarningEnabled = value;
RaisePropertyChanged(nameof(IsWarningEnabled));
}
}
/// <summary>
/// This property will hold the warning message that has to be shown in the warning icon next to the TextBox
/// </summary>
public string CurrentWarningMessage
{
get
{
return currentWarningMessage;
}
set
{
currentWarningMessage = value;
RaisePropertyChanged(nameof(CurrentWarningMessage));
}
}
/// <summary>
/// This property describes if the SaveButton will be enabled or not (when trying to save a new Style).
/// </summary>
public bool IsSaveButtonEnabled
{
get
{
return isSaveButtonEnabled;
}
set
{
isSaveButtonEnabled = value;
RaisePropertyChanged(nameof(IsSaveButtonEnabled));
}
}
/// <summary>
/// This property was created just a container for default information when the user is adding a new Style
/// When users press the Add Style button some controls are shown so the user can populate them, this property will contain default values shown
/// </summary>
public StyleItem AddStyleControl
{
get
{
return addStyleControl;
}
set
{
addStyleControl = value;
RaisePropertyChanged(nameof(AddStyleControl));
}
}
/// <summary>
/// This property is used as a container for the description text (GeometryScalingOptions.DescriptionScaleRange) for each radio button (Visual Settings -> Geometry Scaling section)
/// </summary>
public GeometryScalingOptions OptionsGeometryScale
{
get
{
return optionsGeometryScale;
}
set
{
optionsGeometryScale = value;
RaisePropertyChanged(nameof(OptionsGeometryScale));
}
}
/// <summary>
/// Controls the binding for the ShowEdges toggle in the Preferences->Visual Settings->Display Settings section
/// </summary>
public bool ShowEdges
{
get
{
return dynamoViewModel.RenderPackageFactoryViewModel.ShowEdges;
}
set
{
dynamoViewModel.RenderPackageFactoryViewModel.ShowEdges = value;
RaisePropertyChanged(nameof(ShowEdges));
}
}
/// <summary>
/// Controls the binding for the UseRenderInstancing toggle in the Preferences->Visual Settings->Display Settings section
/// </summary>
public bool UseRenderInstancing
{
get
{
return dynamoViewModel.RenderPackageFactoryViewModel.UseRenderInstancing;
}
set
{
dynamoViewModel.RenderPackageFactoryViewModel.UseRenderInstancing = value;
RaisePropertyChanged(nameof(UseRenderInstancing));
}
}
/// <summary>
/// Control to use hardware acceleration
/// </summary>
public bool UseHardwareAcceleration
{
get
{
return dynamoViewModel.Model.PreferenceSettings.UseHardwareAcceleration;
}
set
{
dynamoViewModel.Model.PreferenceSettings.UseHardwareAcceleration = value;
RaisePropertyChanged(nameof(UseHardwareAcceleration));
}
}
/// <summary>
/// Controls the binding for the IsolateSelectedGeometry toggle in the Preferences->Visual Settings->Display Settings section
/// </summary>
public bool IsolateSelectedGeometry
{
get
{
return dynamoViewModel.BackgroundPreviewViewModel.IsolationMode;
}
set
{
dynamoViewModel.BackgroundPreviewViewModel.IsolationMode = value;
RaisePropertyChanged(nameof(IsolateSelectedGeometry));
}
}
/// <summary>
/// This property is bind to the Render Precision Slider and control the amount of tessellation applied to objects in background preview
/// </summary>
public int TessellationDivisions
{
get
{
return dynamoViewModel.RenderPackageFactoryViewModel.MaxTessellationDivisions;
}
set
{
dynamoViewModel.RenderPackageFactoryViewModel.MaxTessellationDivisions = value;
RaisePropertyChanged(nameof(TessellationDivisions));
}
}
/// <summary>
/// Indicates if preview bubbles should be displayed on nodes.
/// </summary>
public bool ShowPreviewBubbles
{
get
{
return preferenceSettings.ShowPreviewBubbles;
}
set
{
preferenceSettings.ShowPreviewBubbles = value;
RaisePropertyChanged(nameof(ShowPreviewBubbles));
}
}
/// <summary>
/// Indicates if groups should display the default description.
/// </summary>
public bool ShowDefaultGroupDescription
{
get
{
return preferenceSettings.ShowDefaultGroupDescription;
}
set
{
preferenceSettings.ShowDefaultGroupDescription = value;
RaisePropertyChanged(nameof(ShowDefaultGroupDescription));
dynamoViewModel.RefreshAnnotationDescriptions();
}
}
/// <summary>
/// Indicates if the optional input ports are collapsed by default.
/// </summary>
public bool OptionalInputsCollapsed
{
get => preferenceSettings.OptionalInPortsCollapsed;
set
{
preferenceSettings.OptionalInPortsCollapsed = value;
RaisePropertyChanged(nameof(OptionalInputsCollapsed));
}
}
/// <summary>
/// Indicates if the unconnected output ports are hidden by default.
/// </summary>
public bool UnconnectedOutputsCollapsed
{
get => preferenceSettings.UnconnectedOutPortsCollapsed;
set
{
preferenceSettings.UnconnectedOutPortsCollapsed = value;
RaisePropertyChanged(nameof(UnconnectedOutputsCollapsed));
}
}
/// <summary>
/// Indicates if the groups should be collapsed to minimal size by default.
/// </summary>
public bool CollapseToMinSize
{
get => preferenceSettings.CollapseToMinSize;
set
{
preferenceSettings.CollapseToMinSize = value;
RaisePropertyChanged(nameof(CollapseToMinSize));
}
}
/// <summary>
/// Indicates if Host units should be used for graphic helpers for Dynamo Revit
/// Also toggles between Host and Dynamo units
/// </summary>
public bool UseHostScaleUnits
{
get
{
return preferenceSettings.UseHostScaleUnits;
}
set
{
preferenceSettings.UseHostScaleUnits = value;
RaisePropertyChanged(nameof(EnableManualScaleOverrides));
RaisePropertyChanged(nameof(UseHostScaleUnits));
RaisePropertyChanged(nameof(HostGenericScaleUnits));
var hostUnits = preferenceSettings.CurrentHostUnits;
var result = Enum.TryParse(preferenceSettings.GraphicScaleUnit, out Configurations.Units dynamoUnits);
if (!result) return;
var unitsToUse = value ? GetTransformedHostUnits(hostUnits) : dynamoUnits;
if (Configurations.SupportedUnits.TryGetValue(unitsToUse, out double units))
{
preferenceSettings.GridScaleFactor = (float)units;
dynamoViewModel.UpdateGraphicHelpersScaleCommand.Execute(null);
}
}
}
// Perform unit reverse conversion to create a uniform grid for any Host units
internal Configurations.Units GetTransformedHostUnits(Configurations.Units hostUnits)
{
if(hostUnits == Configurations.Units.Millimeters)
{
return Configurations.Units.Meters;
}
else if(hostUnits == Configurations.Units.Centimeters)
{
return Configurations.Units.Centimeters;
}
else if (hostUnits == Configurations.Units.Meters)
{
return Configurations.Units.Millimeters;
}
else
{
return hostUnits;
}
}
public string HostGenericScaleUnits
{
get
{
if (preferenceSettings.CurrentHostUnits == Configurations.Units.Feet
|| preferenceSettings.CurrentHostUnits == Configurations.Units.Inches
|| preferenceSettings.CurrentHostUnits == Configurations.Units.Miles)
{
return Res.PreferencesHostGenericScaleImperialUnits;
}
else
{
return Res.PreferencesHostGenericScaleMetricUnits;
}
}
}
/// <summary>
/// If not in DynamoRevit, then enable this option
/// Else, control via the Revit-specific toggle
/// </summary>
public bool EnableManualScaleOverrides
{
get
{
if (!IsDynamoRevit) return true;
return !UseHostScaleUnits;
}
}
/// <summary>
/// Indicates if line numbers should be displayed on code block nodes.
/// </summary>
public bool ShowCodeBlockLineNumber
{
get
{
return preferenceSettings.ShowCodeBlockLineNumber;
}
set
{
preferenceSettings.ShowCodeBlockLineNumber = value;
RaisePropertyChanged(nameof(ShowCodeBlockLineNumber));
}
}
/// <summary>
/// This property will make Visible or Collapse the AddStyle Border defined in the GroupStyles section
/// </summary>
public bool IsVisibleAddStyleBorder