-
Notifications
You must be signed in to change notification settings - Fork 675
Expand file tree
/
Copy pathPreferenceSettings.cs
More file actions
1579 lines (1396 loc) · 56.7 KB
/
Copy pathPreferenceSettings.cs
File metadata and controls
1579 lines (1396 loc) · 56.7 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.IO;
using System.Linq;
using System.Reflection;
using System.Xml;
using System.Xml.Serialization;
using Autodesk.DesignScript.Runtime;
using Dynamo.Core;
using Dynamo.Graph.Connectors;
using Dynamo.Interfaces;
using Dynamo.Logging;
using Dynamo.Models;
using Dynamo.Utilities;
using DynamoUtilities;
namespace Dynamo.Configuration
{
static class ExtensionMethods
{
/// <summary>
/// Copy Properties from a PreferenceSettings instance to another iterating the Properties of the destination instance and populate them from their source counterparts, excluding the properties that are obsolete and only read.
/// </summary>
/// <param name="source"></param>
/// <param name="destination"></param>
internal static void CopyProperties(this PreferenceSettings source, PreferenceSettings destination)
{
var destinationProperties = destination.GetType().GetProperties();
foreach (var destinationPi in destinationProperties)
{
var sourcePi = source.GetType().GetProperty(destinationPi.Name);
if (destinationPi.GetCustomAttributes(typeof(System.ObsoleteAttribute), true).Length == 0 && destinationPi.CanWrite)
{
destinationPi.SetValue(destination, sourcePi.GetValue(source, null), null);
}
}
}
}
/// <summary>
/// PreferenceSettings is a class for GUI to persist certain settings.
/// Upon running of the GUI, those settings that are persistent will be loaded
/// from a XML file from DYNAMO_SETTINGS_FILE.
/// When GUI is closed, the settings are saved back into the XML file.
/// </summary>
public class PreferenceSettings : NotificationObject, IPreferences, IRenderPrecisionPreference, IDisablePackageLoadingPreferences, ILogSource, IHideAutocompleteMethodOptions
{
private readonly static Lazy<PreferenceSettings>
lazy = new Lazy<PreferenceSettings>
(() => PreferenceSettings.Load(PathManager.Instance.PreferenceFilePath));
/// <summary>
/// Return a PreferenceSetting object. The object returned is based on the following conditions:
/// 1) if DynamoModel present, the DynamoModel.PreferenceSettings object is returned,
/// 2) else, if a valid setting xml file exists, the PreferenceSettings object de-serialized from the xml file is returned,
/// 3) else, if no DynamoModel and no valid xml file exists, a new PreferenceSettings object returned
/// Note that Instance is a runtime object only. No changes to the PreferenceSettings will be persisted on disk with condition 2 or 3.
/// User of Instance must initiate save operations to insure persistence of modifications to the PreferenceSettings model.
/// In some cases even the save will not guarantee persistence of modifications depending on the startup of DynamoModel.
/// </summary>
[XmlIgnore]
internal static PreferenceSettings Instance { get; set; } = lazy.Value;
private string numberFormat;
private string lastUpdateDownloadPath;
private int maxNumRecentFiles;
private bool isBackgroundGridVisible;
private float gridScaleFactor;
private Configurations.Units currentHostUnits;
private double defaultScaleFactor;
private bool disableTrustWarnings = false;
private bool isNotificationCenterEnabled;
private bool isEnablePersistExtensionsEnabled;
private bool isAutoSyncDocumentBrowser = true;
private bool isStaticSplashScreenEnabled;
private bool isMcpServerEnabledOnStartup;
private bool isTimeStampIncludedInExportFilePath;
private bool isCreatedFromValidFile = true;
private string backupLocation;
private string templateFilePath;
private bool isMLAutocompleteTOUApproved;
private bool optionalInputsCollapsed;
private bool unconnectedOutputsCollapsed;
private bool collapseToMinSize;
#region Constants
/// <summary>
/// Indicates the maximum number of files shown in Recent Files
/// </summary>
internal const int DefaultMaxNumRecentFiles = 10;
/// <summary>
/// The default time interval between backup files. 5 minutes.
/// </summary>
internal const int DefaultBackupInterval = 300000;
/// <summary>
/// The old time interval between backup files. 1 minute.
/// </summary>
private const int OldDefaultBackupInterval = 60000;
/// <summary>
/// Indicates the default render precision, i.e. the maximum number of tessellation divisions
/// </summary>
internal const int DefaultRenderPrecision = 128;
/// <summary>
/// Temp PreferenceSetting Location for testing
/// </summary>
public static string DynamoTestPath = null;
/// <summary>
/// Default date format
/// </summary>
public const string DefaultDateFormat = "MMMM dd, yyyy h:mm tt";
/// <summary>
/// Default time
/// </summary>
public static readonly DateTime DynamoDefaultTime = new DateTime(1977, 4, 12, 12, 12, 0, 0);
internal static readonly IEnumerable<string> InitialExperimentalLib_Namespaces =
[
];
#endregion
// The following settings are persistent between Dynamo sessions and are user-controllable
#region Collect Information settings
/// <summary>
/// Indicates first run
/// </summary>
public bool IsFirstRun { get; set; }
/// <summary>
/// This defines if the user export file path would include timestamp
/// </summary>
public bool IsTimeStampIncludedInExportFilePath
{
get
{
return isTimeStampIncludedInExportFilePath;
}
set
{
isTimeStampIncludedInExportFilePath = value;
}
}
/// <summary>
/// Indicates whether ADP analytics reporting is approved or not.
/// Note that the getter will communicate to a analytics server which might be slow.
/// This API should only be used in UI scenarios (not in performance sensitive areas)
/// </summary>
[XmlIgnore]
[Obsolete("API obsolete - This is an internal API and should not be used.")]
public bool IsADPAnalyticsReportingApproved
{
get
{
return AnalyticsService.IsADPOptedIn;
}
set { throw new Exception("do not use"); }
}
#endregion
#region UI & Graphics settings
/// <summary>
/// The width of the library pane.
/// </summary>
public int LibraryWidth { get; set; }
/// <summary>
/// The locale of Dynamo UI, serialize locale instead of language name as ease of conversion back and forth
/// </summary>
public string Locale { get; set; }
/// <summary>
/// Contains the currently selected unit used for scaling the graphic helpers (grids, axes)
/// </summary>
public string GraphicScaleUnit { get; set; }
/// <summary>
/// The height of the console display.
/// </summary>
public int ConsoleHeight { get; set; }
/// <summary>
/// Indicates if preview bubbles should be displayed on nodes.
/// </summary>
public bool ShowPreviewBubbles { get; set; }
/// <summary>
/// Indicates if groups should display the default description.
/// </summary>
public bool ShowDefaultGroupDescription { get; set; }
/// <summary>
/// Indicates if the optional input ports are collapsed by default.
/// </summary>
public bool OptionalInPortsCollapsed
{
get => optionalInputsCollapsed;
set
{
if (optionalInputsCollapsed == value) return;
optionalInputsCollapsed = value;
RaisePropertyChanged(nameof(OptionalInPortsCollapsed));
}
}
/// <summary>
/// Indicates if the unconnected output ports are hidden by default.
/// </summary>
public bool UnconnectedOutPortsCollapsed
{
get => unconnectedOutputsCollapsed;
set
{
if (unconnectedOutputsCollapsed == value) return;
unconnectedOutputsCollapsed = value;
RaisePropertyChanged(nameof(UnconnectedOutPortsCollapsed));
}
}
/// <summary>
/// Indicates if the groups should be collapsed to minimal size by default.
/// </summary>
public bool CollapseToMinSize
{
get => collapseToMinSize;
set
{
if (collapseToMinSize == value) return;
collapseToMinSize = value;
RaisePropertyChanged(nameof(CollapseToMinSize));
}
}
/// <summary>
/// Indicates if Host units should be used for graphic helpers for Dynamo Revit
/// </summary>
public bool UseHostScaleUnits { get; set; }
/// <summary>
/// Indicates if code block node line numbers should be displayed.
/// </summary>
public bool ShowCodeBlockLineNumber { get; set; }
/// <summary>
/// Should connectors be visible?
/// </summary>
public bool ShowConnector { get; set; }
/// <summary>
/// Should connector tooltip be visible?
/// </summary>
public bool ShowConnectorToolTip { get; set; }
/// <summary>
/// Indicates the zoom scale of the library
/// </summary>
public int LibraryZoomScale { get; set; }
/// <summary>
/// Indicates the zoom scale of the Python editor
/// </summary>
public int PythonScriptZoomScale { get; set; }
/// <summary>
/// The types of connector: Bezier or Polyline.
/// </summary>
public ConnectorType ConnectorType { get; set; }
/// <summary>
/// Collection of pairs [BackgroundPreviewName;isActive]
/// </summary>
public List<BackgroundPreviewActiveState> BackgroundPreviews { get; set; }
/// <summary>
/// Returns active state of specified background preview
/// </summary>
/// <param name="name">Background preview name</param>
/// <returns>The active state</returns>
public bool GetIsBackgroundPreviewActive(string name)
{
var pair = GetBackgroundPreviewData(name);
return pair.IsActive;
}
/// <summary>
/// Sets active state of specified background preview
/// </summary>
/// <param name="name">Background preview name</param>
/// <param name="value">Active state</param>
public void SetIsBackgroundPreviewActive(string name, bool value)
{
var pair = GetBackgroundPreviewData(name);
pair.IsActive = value;
}
private BackgroundPreviewActiveState GetBackgroundPreviewData(string name)
{
// find or create BackgroundPreviewActiveState instance in list by name
var pair = BackgroundPreviews.FirstOrDefault(p => p.Name == name)
?? new BackgroundPreviewActiveState { Name = name };
if (!BackgroundPreviews.Contains(pair))
{
BackgroundPreviews.Add(pair);
}
return pair;
}
/// <summary>
/// Should the background grid be shown?
/// </summary>
public bool IsBackgroundGridVisible
{
get
{
return isBackgroundGridVisible;
}
set
{
if (value == isBackgroundGridVisible) return;
isBackgroundGridVisible = value;
RaisePropertyChanged(nameof(IsBackgroundGridVisible));
}
}
/// <summary>
/// Sets the background grid element scale
/// </summary>
public float GridScaleFactor
{
get
{
return gridScaleFactor;
}
set
{
if (value == gridScaleFactor) return;
gridScaleFactor = value;
RaisePropertyChanged(nameof(GridScaleFactor));
}
}
/// <summary>
/// The current Host document units. Will be updated the first time Dynamo is started
/// </summary>
internal Configurations.Units CurrentHostUnits
{
get
{
return currentHostUnits;
}
set
{
if (value == currentHostUnits) return;
currentHostUnits = value;
RaisePropertyChanged(nameof(CurrentHostUnits));
}
}
/// <summary>
/// Default geometry scale factor for a new workspace
/// </summary>
public double DefaultScaleFactor
{
get
{
return defaultScaleFactor;
}
set
{
if (value == defaultScaleFactor) return;
defaultScaleFactor = value;
RaisePropertyChanged(nameof(DefaultScaleFactor));
}
}
/// <summary>
/// Indicate which render precision will be used
/// </summary>
public int RenderPrecision { get; set; }
/// <summary>
/// Indicates whether surface and solid edges will
/// be rendered.
/// </summary>
public bool ShowEdges { get; set; }
/// <summary>
/// Indicates whether background preview use instancing when rendering geometry.
/// be rendered.
/// </summary>
public bool UseRenderInstancing { get; set; }
/// <summary>
/// Indicates whether show detailed or compact layout during search.
/// </summary>
public bool ShowDetailedLayout { get; set; }
/// <summary>
/// The last X coordinate of the Dynamo window.
/// </summary>
public double WindowX { get; set; }
/// <summary>
/// The last Y coordinate of the Dynamo window.
/// </summary>
public double WindowY { get; set; }
/// <summary>
/// The last width of the Dynamo window.
/// </summary>
public double WindowW { get; set; }
/// <summary>
/// The last height of the Dynamo window.
/// </summary>
public double WindowH { get; set; }
/// <summary>
/// Should Dynamo use hardware acceleration if it is supported?
/// </summary>
public bool UseHardwareAcceleration { get; set; }
/// <summary>
/// Persistence for Dynamo HomePage
/// </summary>
public List<string> HomePageSettings { get; set; }
#endregion
#region Dynamo application settings
/// <summary>
/// The decimal precision used to display numbers.
/// </summary>
public string NumberFormat
{
get { return numberFormat; }
set
{
numberFormat = value;
RaisePropertyChanged("NumberFormat");
}
}
/// <summary>
/// The maximum number of recent file paths to be saved.
/// </summary>
public int MaxNumRecentFiles
{
get { return maxNumRecentFiles; }
set
{
if (value > 0)
{
maxNumRecentFiles = value;
}
else
{
maxNumRecentFiles = DefaultMaxNumRecentFiles;
}
RaisePropertyChanged("MaxNumRecentFiles");
}
}
/// <summary>
/// A list of recently opened file paths.
/// </summary>
public List<string> RecentFiles { get; set; }
/// <summary>
/// Backup files path
/// </summary>
public string BackupLocation
{
get { return backupLocation; }
set
{
backupLocation = value;
RaisePropertyChanged(nameof(BackupLocation));
}
}
/// <summary>
/// Template path
/// </summary>
public string TemplateFilePath
{
get { return templateFilePath; }
set
{
templateFilePath = value;
RaisePropertyChanged(nameof(TemplateFilePath));
}
}
/// <summary>
/// A list of backup file paths.
/// </summary>
public List<string> BackupFiles { get; set; }
/// <summary>
/// A list of folders packages, custom nodes or direct paths to .dll and .ds files.
/// </summary>
public List<string> CustomPackageFolders { get; set; }
/// <summary>
/// If true, trust warnings for opening .dyn files from untrusted locations will not be shown.
/// Do not use this property setter, it does nothing. Exists only to support serialization.
/// </summary>
public bool DisableTrustWarnings
{
get => disableTrustWarnings;
//no-op
set { }
}
/// <summary>
/// This represents the user modifiable list of locations.
/// </summary>
private List<string> trustedLocations { get; set; } = new List<string>();
/// <summary>
/// Return a list of GraphChecksumItems
/// </summary>
[Obsolete("This property is not needed anymore in the preference settings and can be removed in a future version of Dynamo.")]
public List<GraphChecksumItem> GraphChecksumItemsList { get; set; }
// This function is used to deserialize the trusted locations manually
// so that the TrustedLocation propertie's setter does not need to be public.
private List<string> DeserializeTrustedLocations(XmlNode preferenceSettingsElement)
{
List<string> output = new List<string>();
try
{
var parentNode = preferenceSettingsElement.SelectSingleNode($@"//{nameof(TrustedLocations)}");
if (parentNode != null)
{
foreach (XmlNode value in parentNode.ChildNodes)
{
if (!string.IsNullOrEmpty(value?.InnerText))
{
output.Add(value.InnerText);
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return output;
}
private bool DeserializeDisableTrustWarnings(XmlNode preferenceSettingsElement)
{
try
{
return bool.Parse(preferenceSettingsElement.SelectSingleNode($@"//{nameof(DisableTrustWarnings)}").InnerText);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return false;
}
/// <summary>
/// Manually deserialize some preferences from the PreferencesSettings file.
/// This is done so that we can avoid exposing these property setters to the public API.
/// </summary>
/// <param name="prefsFilePath"></param>
private void DeserializeInternalPrefs(string prefsFilePath)
{
try
{
//manually load some xml we don't want to create public setters for.
var doc = new System.Xml.XmlDocument();
doc.Load(prefsFilePath);
var prefs = doc.SelectSingleNode($@"//{nameof(PreferenceSettings)}");
var deserializedLocations = DeserializeTrustedLocations(prefs);
SetTrustedLocations(deserializedLocations.Distinct());
var trustWarningsDisabled = DeserializeDisableTrustWarnings(prefs);
SetTrustWarningsDisabled(trustWarningsDisabled);
}
catch
{ }
}
/// <summary>
/// Manually deserialize some preferences from the PreferencesSettings file.
/// This is done so that we can avoid exposing these property setters to the public API.
/// </summary>
/// <param name="content">The content of the XML file</param>
private void DeserializeInternalPrefsContent(string content)
{
try
{
//manually load some xml we don't want to create public setters for.
var doc = new System.Xml.XmlDocument();
doc.LoadXml(content);
var prefs = doc.SelectSingleNode($@"//{nameof(PreferenceSettings)}");
var deserializedLocations = DeserializeTrustedLocations(prefs);
SetTrustedLocations(deserializedLocations.Distinct());
var trustWarningsDisabled = DeserializeDisableTrustWarnings(prefs);
SetTrustWarningsDisabled(trustWarningsDisabled);
}
catch
{ }
}
/// <summary>
/// Represents a copy of the list of trusted locations that the user added.
/// Do not use this list to check if a new path is trusted or not.
/// To check if a new path is trusted or not please use the IsTrustedLocation API (IsTrustedLocation supports locations)
/// </summary>
public List<string> TrustedLocations
{
get => trustedLocations.ToList(); //Copy of the internal list
}
/// <summary>
/// A list of packages used by the Package Manager to determine
/// which packages are marked for deletion.
/// </summary>
public List<string> PackageDirectoriesToUninstall { get; set; }
/// <summary>
/// Path to the Python (.py) file to use as a starting template when creating a new PythonScript Node.
/// </summary>
public string PythonTemplateFilePath
{
get { return pythonTemplateFilePath; }
set { pythonTemplateFilePath = value; }
}
/// <summary>
/// The backing store for the Python template file path. Required as static property cannot implement an interface member.
/// </summary>
private static string pythonTemplateFilePath = "";
/// <summary>
/// This defines how long (in milliseconds) will the graph be automatically saved.
/// </summary>
public int BackupInterval { get; set; }
/// <summary>
/// This defines how many files will be backed up.
/// </summary>
public int BackupFilesCount { get; set; }
/// <summary>
/// Indicates if the user has accepted the terms of
/// use for downloading packages from package manager.
/// </summary>
public bool PackageDownloadTouAccepted { get; set; }
/// <summary>
/// Indicates the default state of the "Open in Manual Mode"
/// checkbox in OpenFileDialog
/// </summary>
public bool OpenFileInManualExecutionMode { get; set; }
/// <summary>
/// This defines if user wants to see the Iron Python Extension Dialog box on every new session.
/// </summary>
[Obsolete("This property is deprecated and will be removed in a future version of Dynamo")]
public bool IsIronPythonDialogDisabled { get; set; }
/// <summary>
/// This defines if user wants to see the whitespaces and tabs in python script editor.
/// </summary>
public bool ShowTabsAndSpacesInScriptEditor { get; set; }
/// <summary>
/// Controls whether untrusted location notifications are shown in the notification center.
/// This value is set by the host during initialization and is not persisted to DynamoSettings.xml.
/// Default is true to maintain existing behavior.
/// Note: This does not affect the file trust warning popup.
/// </summary>
[XmlIgnore]
internal bool EnableUnTrustedLocationsNotifications { get; set; } = true;
/// <summary>
/// Controls whether Dynamo shows upgrade notifications for legacy CPython nodes
/// when opening a graph. These notices appear when a graph contains CPython-engine
/// Python nodes that are automatically upgraded to PythonNet3:
/// • save/close confirmation dialog
/// • banner inside the Python Script Editor
/// NOTE: This setting is not related to the historical IronPython2 → CPython3 migration.
/// </summary>
public bool ShowPythonAutoMigrationNotifications { get; set; } = true;
/// <summary>
/// This defines if user wants to see the enabled node Auto Complete feature for port interaction.
/// </summary>
public bool EnableNodeAutoComplete { get; set; }
/// <summary>
/// This allows the user to enable or disable the new node auto complete menu.
/// </summary>
public bool EnableNewNodeAutoCompleteUI { get; set; }
/// <summary>
/// PolyCurve normal and direction behavior has been made predictable in Dynamo 3.0 and has therefore changed.
/// This defines whether legacy (pre-3.0) PolyCurve behavior is selected by default.
/// This flag can be overridden by individual workspaces that have the EnableLegacyPolyCurveBehavior flag defined.
/// Note: For internal use only and will be removed in a future version of Dynamo.
/// </summary>
[IsObsolete("This property will be removed in a future version of Dynamo.")]
public bool DefaultEnableLegacyPolyCurveBehavior { get; set; }
/// <summary>
/// This defines if user wants to hide the nodes below a specific confidenc level.
/// </summary>
public bool HideNodesBelowSpecificConfidenceLevel { get; set; }
/// <summary>
/// This defines the level of confidence related to the ML recommendation.
/// </summary>
public int MLRecommendationConfidenceLevel { get; set; }
private int mLRecommendationNumberOfResults;
/// <summary>
/// This defines the number of results of the ML recommendation
/// </summary>
public int MLRecommendationNumberOfResults
{
get => mLRecommendationNumberOfResults;
set
{
if (mLRecommendationNumberOfResults != value)
{
mLRecommendationNumberOfResults = value;
AutocompletePreferencesChanged?.Invoke();
}
}
}
/// <summary>
/// If true, autocomplete method options are hidden from UI
/// </summary>
public bool HideAutocompleteMethodOptions { get; set; }
/// <summary>
/// This defines if user wants to see the enabled Dynamo Notification Center.
/// </summary>
public bool EnableNotificationCenter
{
get
{
return isNotificationCenterEnabled;
}
set
{
isNotificationCenterEnabled = value;
RaisePropertyChanged(nameof(EnableNotificationCenter));
}
}
/// <summary>
/// This defines if user wants the Extensions settings to persist across sessions.
/// </summary>
public bool EnablePersistExtensions
{
get
{
return isEnablePersistExtensionsEnabled;
}
set
{
isEnablePersistExtensionsEnabled = value;
RaisePropertyChanged(nameof(EnablePersistExtensions));
}
}
/// <summary>
/// This defines if user wants the Document Browser content to be automatically synced to the selected Node.
/// The default value is true.
/// </summary>
public bool IsAutoSyncDocumentBrowser
{
get
{
return isAutoSyncDocumentBrowser;
}
set
{
isAutoSyncDocumentBrowser = value;
RaisePropertyChanged(nameof(IsAutoSyncDocumentBrowser));
}
}
/// <summary>
/// This defines if the user wants to see the static splash screen again
/// </summary>
public bool EnableStaticSplashScreen
{
get
{
return isStaticSplashScreenEnabled;
}
set
{
isStaticSplashScreenEnabled = value;
}
}
/// <summary>
/// This defines whether the Dynamo MCP (Model Context Protocol) server starts
/// automatically when Dynamo launches. When false, the server stays off until the
/// user enables it from the MCP extension's Extensions-menu toggle (DYN-9355).
/// </summary>
public bool EnableMcpServerOnStartup
{
get
{
return isMcpServerEnabledOnStartup;
}
set
{
isMcpServerEnabledOnStartup = value;
RaisePropertyChanged(nameof(EnableMcpServerOnStartup));
}
}
/// <summary>
/// This defines if the user is agree to the ML Automcomplete Terms of Use
/// </summary>
public bool IsMLAutocompleteTOUApproved
{
get
{
return isMLAutocompleteTOUApproved;
}
set
{
isMLAutocompleteTOUApproved = value;
RaisePropertyChanged(nameof(IsMLAutocompleteTOUApproved));
// If user unchecks the agreement, automatically revert to ObjectType matching
if (!value && defaultNodeAutocompleteSuggestion == NodeAutocompleteSuggestion.MLRecommendation)
{
defaultNodeAutocompleteSuggestion = NodeAutocompleteSuggestion.ObjectType;
AutocompletePreferencesChanged?.Invoke();
}
}
}
/// <summary>
/// Engine used by default for new Python script and string nodes. If not empty, this takes precedence over any system settings.
/// </summary>
public string DefaultPythonEngine
{
get
{
return defaultPythonEngine;
}
set
{
defaultPythonEngine = value;
}
}
/// <summary>
/// Static field backing the DefaultPythonEngine setting property.
/// </summary>
private static string defaultPythonEngine;
internal event Func<string> RequestUserDataFolder;
internal string OnRequestUserDataFolder()
{
return RequestUserDataFolder?.Invoke();
}
private string selectedPackagePathForInstall;
// TODO: Add this to IPreferences in Dynamo 3.0
/// <summary>
/// Currently selected package path where all packages downloaded from the Package Manager
/// will be installed. The default package path for install is the user data directory
/// currently used by the Dynamo environment.
/// </summary>
public string SelectedPackagePathForInstall
{
get
{
if (string.IsNullOrEmpty(selectedPackagePathForInstall))
{
selectedPackagePathForInstall = OnRequestUserDataFolder();
}
return selectedPackagePathForInstall;
}
set
{
selectedPackagePathForInstall = value;
}
}
/// <summary>
/// Indicates (if any) which namespaces should not be displayed in the Dynamo node library.
/// String format: "[library name]:[fully qualified namespace]"
/// </summary>
public List<string> NamespacesToExcludeFromLibrary { get; set; }
/// <summary>
/// True if the NamespacesToExcludeFromLibrary element is found in DynamoSettings.xml.
/// </summary>
[XmlIgnore]
public bool NamespacesToExcludeFromLibrarySpecified { get; set; }
/// <summary>
/// Settings that apply to view extensions.
/// </summary>
public List<ViewExtensionSettings> ViewExtensionSettings { get; set; }
private bool disableBuiltinPackages;
/// <summary>
/// If enabled Dynamo Built-In Packages will not be loaded.
/// </summary>
public bool DisableBuiltinPackages
{
get { return disableBuiltinPackages; }
set
{
disableBuiltinPackages = value;
RaisePropertyChanged(nameof(DisableBuiltinPackages));
}
}
private bool disableCustomPackageLocations;
/// <summary>
/// If enabled user's custom package locations will not be loaded.
/// </summary>
public bool DisableCustomPackageLocations
{
get { return disableCustomPackageLocations; }
set
{
disableCustomPackageLocations = value;
RaisePropertyChanged(nameof(DisableCustomPackageLocations));
}
}
/// <summary>
/// Defines the default run type when opening a workspace
/// </summary>
public RunType DefaultRunType { get; set; }
private NodeAutocompleteSuggestion defaultNodeAutocompleteSuggestion;
/// <summary>
/// Defines the default method of the Node Autocomplete
/// </summary>
public NodeAutocompleteSuggestion DefaultNodeAutocompleteSuggestion
{
get => defaultNodeAutocompleteSuggestion;
set
{
if(defaultNodeAutocompleteSuggestion != value)
{
defaultNodeAutocompleteSuggestion = value;
AutocompletePreferencesChanged?.Invoke();
}
}
}
/// <summary>
/// Event that is fired when autocomplete-specific preferences are changed
/// </summary>
internal event Action AutocompletePreferencesChanged;
/// <summary>
/// Show Run Preview flag.
/// </summary>
public bool ShowRunPreview { get; set; }
/// <summary>
/// Stores the group styles added in the preference settings
/// </summary>
public List<GroupStyleItem> GroupStyleItemsList { get; set; }