Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d99134f
added code regions and fixed annotations
radumg Jul 11, 2017
7eb91cc
added PythonTemplateFile setting
radumg Jul 11, 2017
8e9c755
added PythonTemplateFilePath to interfaces
radumg Jul 11, 2017
2d9f4e0
read template for Python nodes + documentation
radumg Jul 12, 2017
a12d5df
default Python template cleanup
radumg Jul 17, 2017
c13ef1c
add static backing store for PythonTemplateFIlePath
radumg Aug 17, 2017
ad36dae
moved hardcoded Python template to readonly prop
radumg Aug 18, 2017
bd658e4
add public static method to access private static prop
radumg Aug 18, 2017
773a416
fix Python template un-commented line
radumg Aug 18, 2017
2f234bb
replaced template get with static method call
radumg Aug 21, 2017
9308735
changed PathManager python template prop to static
radumg Aug 21, 2017
d221139
Update .gitignore
radumg Aug 22, 2017
5be6f8b
remove unnecessary reference
radumg Aug 24, 2017
6227c43
Merge branch 'python-template' of https://github.com/radumg/Dynamo in…
radumg Aug 24, 2017
2319431
add description for static method
radumg Aug 24, 2017
c4bff15
removed static PathManager props & added PyTemplate handling to Dynam…
radumg Aug 25, 2017
a99bde1
added PythonTemplate file test
radumg Aug 25, 2017
9ff3479
added settings files for tests
radumg Aug 27, 2017
bdb6c23
added unit test for CanUpdatePythonTemplateSettings
radumg Aug 27, 2017
5a73bf0
re-enable the temporarily disabled tests
radumg Aug 27, 2017
239fd8c
update Settings tests with Python test
radumg Aug 27, 2017
083fce5
ensure order of execution is right
radumg Aug 27, 2017
0ba2bc8
small consistency fixes to tests
radumg Aug 27, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/DynamoCore/Configuration/IPathResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ public interface IPathManager
/// </summary>
string PreferenceFilePath { get; }

/// <summary>
/// Full path to the python template py file. This setting file is specific
/// to the current user.
/// </summary>
string PythonTemplateFilePath { get; }

/// <summary>
/// Full path to the GalleryContent xml file. The file is located in
/// the AppData/Dynamo/[version]/gallery/
Expand Down
6 changes: 6 additions & 0 deletions src/DynamoCore/Configuration/IPreferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ public interface IPreferences
/// <returns>Returns true if the serialization is successful, or false
/// otherwise.</returns>
bool Save(string filePath);

/// <summary>
/// Return full path to the Python (.py) file to use as a starting template when creating a new PythonScript Node.
/// </summary>
string PythonTemplateFilePath { get; set; }

}

/// <summary>
Expand Down
8 changes: 8 additions & 0 deletions src/DynamoCore/Configuration/PathManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class PathManager : IPathManager
public const string GalleryDirectoryName = "gallery";
public const string BackupDirectoryName = "backup";
public const string PreferenceSettingsFileName = "DynamoSettings.xml";
public const string PythonTemplateFileName = "PythonTemplate.py";
public const string GalleryContentsFileName = "GalleryContents.xml";

private readonly int majorFileVersion;
Expand All @@ -75,6 +76,7 @@ class PathManager : IPathManager
private readonly string backupDirectory;
private readonly string preferenceFilePath;
private readonly string galleryFilePath;
private string pythonTemplateFilePath;

private readonly List<string> rootDirectories;
private readonly HashSet<string> nodeDirectories;
Expand Down Expand Up @@ -169,6 +171,11 @@ public string PreferenceFilePath
get { return preferenceFilePath; }
}

public string PythonTemplateFilePath
{
get { return pythonTemplateFilePath; }
}

public string GalleryFilePath
{
get { return galleryFilePath; }
Expand Down Expand Up @@ -329,6 +336,7 @@ internal PathManager(PathManagerParams pathManagerParams)
LogsDirectoryName);

preferenceFilePath = Path.Combine(userDataDir, PreferenceSettingsFileName);
pythonTemplateFilePath = Path.Combine(userDataDir, PythonTemplateFileName);
backupDirectory = Path.Combine(userDataDirNoVersion, BackupDirectoryName);

// Common directories.
Expand Down
131 changes: 84 additions & 47 deletions src/DynamoCore/Configuration/PreferenceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ namespace Dynamo.Configuration
/// 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 into the XML file.
/// When GUI is closed, the settings are saved back into the XML file.
/// </summary>
public class PreferenceSettings : NotificationObject, IPreferences, IPreviewBubblePreference, IBackgroundPreviewPreference
{
private string numberFormat;
private string lastUpdateDownloadPath;
private int maxNumRecentFiles;

#region Constants
/// <summary>
/// Indicates the maximum number of files shown in Recent Files
/// </summary>
Expand All @@ -43,9 +44,10 @@ public class PreferenceSettings : NotificationObject, IPreferences, IPreviewBubb
/// </summary>
public static readonly System.DateTime DynamoDefaultTime = new System.DateTime(1977, 4, 12, 12, 12, 0, 0);

// Variables of the settings that will be persistent
#endregion

#region Collect Information Settings
/// The following settings are persistent between Dynamo sessions and are user-controllable
#region Collect Information settings

/// <summary>
/// Indicates first run
Expand All @@ -63,6 +65,8 @@ public class PreferenceSettings : NotificationObject, IPreferences, IPreviewBubb
public bool IsAnalyticsReportingApproved { get; set; }
#endregion

#region UI & Graphics settings

/// <summary>
/// The width of the library pane.
/// </summary>
Expand Down Expand Up @@ -94,10 +98,10 @@ public class PreferenceSettings : NotificationObject, IPreferences, IPreviewBubb
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>
/// 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);
Expand Down Expand Up @@ -139,7 +143,9 @@ private BackgroundPreviewActiveState GetBackgroundPreviewData(string name)
/// Indicates whether background preview is active or not.
/// </summary>
[Obsolete("Property will be deprecated in Dynamo 2.0, please use BackgroundPreviews")]
public bool IsBackgroundPreviewActive { get
public bool IsBackgroundPreviewActive
{
get
{
return GetIsBackgroundPreviewActive("IsBackgroundPreviewActive");
}
Expand All @@ -149,6 +155,47 @@ public bool IsBackgroundPreviewActive { get
}
}

/// <summary>
/// Indicates whether surface and solid edges will
/// be rendered.
/// </summary>
public bool ShowEdges { 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; }

#endregion

#region Dynamo application settings

/// <summary>
/// The decimal precision used to display numbers.
/// </summary>
Expand Down Expand Up @@ -195,7 +242,7 @@ public int MaxNumRecentFiles
/// <summary>
/// A list of folders containing zero-touch nodes and custom nodes.
/// </summary>
public List<string> CustomPackageFolders { get; set; }
public List<string> CustomPackageFolders { get; set; }

/// <summary>
/// A list of packages used by the Package Manager to determine
Expand All @@ -204,29 +251,18 @@ public int MaxNumRecentFiles
public List<string> PackageDirectoriesToUninstall { 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.
/// Path to the Python (.py) file to use as a starting template when creating a new PythonScript Node.
/// </summary>
public double WindowW { get; set; }
public string PythonTemplateFilePath
{
get { return pythonTemplateFilePath; }
set { pythonTemplateFilePath = value; }
}

/// <summary>
/// The last height of the Dynamo window.
/// The backing store for the Python template file path. Required as static property cannot implement an interface member.
/// </summary>
public double WindowH { get; set; }

/// <summary>
/// Should Dynamo use hardware acceleration if it is supported?
/// </summary>
public bool UseHardwareAcceleration { get; set; }
private static string pythonTemplateFilePath = "";

/// <summary>
/// This defines how long (in milliseconds) will the graph be automatically saved.
Expand All @@ -244,17 +280,6 @@ public int MaxNumRecentFiles
/// </summary>
public bool PackageDownloadTouAccepted { get; set; }

/// <summary>
/// Indicates whether surface and solid edges will
/// be rendered.
/// </summary>
public bool ShowEdges { get; set; }

/// <summary>
/// Indicates whether show detailed or compact layout during search.
/// </summary>
public bool ShowDetailedLayout { get; set; }

/// <summary>
/// Indicates the default state of the "Open in Manual Mode"
/// checkbox in OpenFileDialog
Expand All @@ -273,6 +298,8 @@ public int MaxNumRecentFiles
[XmlIgnore]
public bool NamespacesToExcludeFromLibrarySpecified { get; set; }

#endregion

/// <summary>
/// Initializes a new instance of the <see cref="PreferenceSettings"/> class.
/// </summary>
Expand Down Expand Up @@ -309,14 +336,14 @@ public PreferenceSettings()
BackupFiles = new List<string>();

CustomPackageFolders = new List<string>();
PythonTemplateFilePath = "";
}

/// <summary>
/// Saves PreferenceSettings in XML File Path if possible,
/// else return false
/// Saves PreferenceSettings to XML, given a file path.
/// </summary>
/// <param name="filePath">Path of the XML File</param>
/// <returns>Whether file is saved or error occurred.</returns>
/// <param name="filePath">Path of the XML File to save to.</param>
/// <returns>True if file is saved successfully, false if an error occurred.</returns>
public bool Save(string filePath)
{
try
Expand Down Expand Up @@ -345,7 +372,7 @@ public bool Save(string filePath)
/// <param name="preferenceFilePath">The file path to save preference
/// settings to. If this parameter is null or empty string, preference
/// settings will be saved to the default path.</param>
/// <returns>Whether file is saved or error occurred.</returns>
/// <returns>True if file is saved successfully, false if an error occurred.</returns>
public bool SaveInternal(string preferenceFilePath)
{
if (!String.IsNullOrEmpty(DynamoTestPath))
Expand All @@ -357,8 +384,8 @@ public bool SaveInternal(string preferenceFilePath)
}

/// <summary>
/// Returns PreferenceSettings from XML path if possible,
/// else return PreferenceSettings with default values
/// Loads PreferenceSettings from specified XML file if possible,
/// else initialises PreferenceSettings with default values.
/// </summary>
/// <param name="filePath">Path of the XML File</param>
/// <returns>
Expand Down Expand Up @@ -386,7 +413,17 @@ public static PreferenceSettings Load(string filePath)
settings.CustomPackageFolders = settings.CustomPackageFolders.Distinct().ToList();

return settings;
}
}

/// <summary>
/// Returns the static Python template file path.
/// When the file exists and is not empty, its contents are used to populate new Python Script nodes added to the Dynamo workspace.
/// </summary>
/// <returns></returns>
public static string GetPythonTemplateFilePath()
{
return pythonTemplateFilePath;
}

internal void InitializeNamespacesToExcludeFromLibrary()
{
Expand Down
Loading