Skip to content

Commit f3afd45

Browse files
committed
Added a way to auto import macros when installed from an extension...
1 parent 92beb1f commit f3afd45

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

External/Plugins/MacroManager/PluginMain.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,25 @@ public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
117117
if (e.Type == EventType.UIStarted)
118118
{
119119
String initScript = Path.Combine(PathHelper.BaseDir, "InitScript.cs");
120+
String autoImport = Path.Combine(PathHelper.BaseDir, "InitMacros.fdm");
120121
if (File.Exists(initScript))
121122
{
122123
String command = "Internal;" + initScript;
123124
PluginBase.MainForm.CallCommand("ExecuteScript", command);
124125
}
126+
if (File.Exists(autoImport))
127+
{
128+
List<Macro> macros = new List<Macro>();
129+
Object macrosObject = ObjectSerializer.Deserialize(autoImport, macros, false);
130+
macros = (List<Macro>)macrosObject;
131+
this.settingObject.UserMacros.AddRange(macros);
132+
try { File.Delete(autoImport); }
133+
catch (Exception ex)
134+
{
135+
ErrorManager.ShowError("Could not delete import file: " + autoImport, ex);
136+
}
137+
this.RefreshMacroMenuItems();
138+
}
125139
this.RunAutoRunMacros();
126140
}
127141
}

0 commit comments

Comments
 (0)