diff options
14 files changed, 289 insertions, 16 deletions
diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Help/proc-doc.chm b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Help/proc-doc.chm Binary files differindex a153e1469..24e7db2e2 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Help/proc-doc.chm +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Help/proc-doc.chm diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Help/proc-doc.chw b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Help/proc-doc.chw Binary files differindex f981812da..b5d8170cd 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Help/proc-doc.chw +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Help/proc-doc.chw diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Tango.FSE.Procedures.Documentation.shfbproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Tango.FSE.Procedures.Documentation.shfbproj index 9d86f76d3..78ae89b52 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Tango.FSE.Procedures.Documentation.shfbproj +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Tango.FSE.Procedures.Documentation.shfbproj @@ -45,7 +45,7 @@ <SaveComponentCacheCapacity>100</SaveComponentCacheCapacity> <HelpTitle>Tango FSE Procedures API</HelpTitle> <HelpFileVersion>1.0.0.0</HelpFileVersion> - <NamingMethod>Guid</NamingMethod> + <NamingMethod>MemberName</NamingMethod> <ContentPlacement>AboveNamespaces</ContentPlacement> <RootNamespaceContainer>False</RootNamespaceContainer> <NamespaceGrouping>False</NamespaceGrouping> @@ -71,7 +71,10 @@ <Filter entryType="Namespace" fullName="Tango.FSE.Common.Core" isExposed="False" /> <Filter entryType="Namespace" fullName="Tango.FSE.Common.DemoMode" isExposed="False" /> <Filter entryType="Namespace" fullName="Tango.FSE.Common.Diagnostics" isExposed="False"> - <Filter entryType="Class" fullName="Tango.FSE.Common.Diagnostics.DiagnosticsPackage" filterName="DiagnosticsPackage" isExposed="True" /> + <Filter entryType="Class" fullName="Tango.FSE.Common.Diagnostics.DiagnosticsPackage" filterName="DiagnosticsPackage" isExposed="True"> + <Filter entryType="Property" fullName="Tango.FSE.Common.Diagnostics.DiagnosticsPackage.Frame" filterName="Frame" isExposed="False" /> + <Filter entryType="Property" fullName="Tango.FSE.Common.Diagnostics.DiagnosticsPackage.MonitorsProperties" filterName="MonitorsProperties" isExposed="False" /> + </Filter> </Filter> <Filter entryType="Namespace" fullName="Tango.FSE.Common.Dialogs" isExposed="False" /> <Filter entryType="Namespace" fullName="Tango.FSE.Common.Events" isExposed="False" /> @@ -121,6 +124,8 @@ <Filter entryType="Namespace" fullName="Tango.FSE.Procedures.CSV" isExposed="False" /> <Filter entryType="Namespace" fullName="Tango.FSE.Procedures.Designer" isExposed="False" /> <Filter entryType="Namespace" fullName="Tango.FSE.Procedures.Dialogs" isExposed="False" /> +<Filter entryType="Namespace" fullName="Tango.FSE.Procedures.Examples.Another" isExposed="False" /> +<Filter entryType="Namespace" fullName="Tango.FSE.Procedures.Examples.Send" isExposed="False" /> <Filter entryType="Namespace" fullName="Tango.FSE.Procedures.Helpers" isExposed="False" /> <Filter entryType="Namespace" fullName="Tango.FSE.Procedures.Messages" isExposed="False" /> <Filter entryType="Namespace" fullName="Tango.FSE.Procedures.ViewModels" isExposed="False" /> @@ -130,7 +135,8 @@ <ProjectSummary>This is the global summery for the help file.</ProjectSummary> <NamespaceSummaries> <NamespaceSummaryItem name="(global)" isDocumented="True">This is the global summery for the help file.</NamespaceSummaryItem> -<NamespaceSummaryItem name="Tango.FSE.Procedures" isDocumented="True">Contains a collection of interfaces and classes for the main procedures API.</NamespaceSummaryItem></NamespaceSummaries> + <NamespaceSummaryItem name="Tango.FSE.Procedures" isDocumented="True">Contains a collection of interfaces and classes for the main procedures API.</NamespaceSummaryItem> + </NamespaceSummaries> <ComponentConfigurations /> <MissingTags>Summary, Parameter, Returns, AutoDocumentCtors, TypeParameter, AutoDocumentDispose</MissingTags> </PropertyGroup> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Contracts/IProcedureDesignerView.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Contracts/IProcedureDesignerView.cs index a16345f65..07899056c 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Contracts/IProcedureDesignerView.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Contracts/IProcedureDesignerView.cs @@ -29,5 +29,6 @@ namespace Tango.FSE.Procedures.Contracts List<ScriptBreakPoint> GetBreakPoints(); void HighlightBreakPointRequest(int lineNumber, List<ScriptBreakPointSymbol> symbols); void ResetBreakPointRequest(); + String GetCaretWord(); } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Examples/Send/Program.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Examples/Send/Program.cs new file mode 100644 index 000000000..bf7c38e13 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Examples/Send/Program.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Drawing; +using Google.Protobuf; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.PMR.Stubs; +using Tango.PMR.Diagnostics; +using Tango.FSE.Common.Connection; +using Tango.FSE.Common.Diagnostics; +using Tango.FSE.Procedures; + +namespace Tango.FSE.Procedures.Examples.Send +{ + #region Example + public class Program + { + public void OnExecute(IProcedureContext context) + { + //Sends a request by providing the request name and comma separated arguments. + CalculateResponse response1 = context.Send<CalculateResponse>("CalculateRequest", 10, 5); + + //Sends a request by providing the request short name and comma separated arguments. + CalculateResponse response2 = context.Send<CalculateResponse>("calculate", 10, 5); + + //Sends a request by providing the request short name, a timeout and comma separated arguments. + CalculateResponse response3 = context.Send<CalculateResponse>("calculate", TimeSpan.FromSeconds(5), 10, 5); + + //Sends a request by providing a request object. + CalculateRequest request = new CalculateRequest(); + request.A = 10; + request.B = 5; + + CalculateResponse response4 = context.Send<CalculateResponse>(request); + + //Sends a request by providing a request object and 5 seconds timeout. + CalculateResponse response5 = context.Send<CalculateResponse>(request, 5); + } + } + #endregion +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Examples/SendContinuous/Program.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Examples/SendContinuous/Program.cs new file mode 100644 index 000000000..2f8115642 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Examples/SendContinuous/Program.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Drawing; +using Google.Protobuf; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.PMR.Stubs; +using Tango.PMR.Diagnostics; +using Tango.FSE.Common.Connection; +using Tango.FSE.Common.Diagnostics; +using Tango.FSE.Procedures; + +namespace Tango.FSE.Procedures.Examples.SendContinuous +{ + #region Example + public class Program + { + private IProcedureContext _context; + + public void OnExecute(IProcedureContext context) + { + //Sends a continuous request by providing the request name, a callback method and comma separated arguments. + context.SendContinuous<ProgressResponse>("ProgressRequest", (response) => + { + //Each response will be provided here... + context.WriteLine(response); + }, 100, 10); + + + //Sends a continuous request by providing the request name, a callback method, a timeout, and comma separated arguments. + context.SendContinuous<ProgressResponse>("progress", (response) => + { + context.WriteLine(response); + }, TimeSpan.FromSeconds(5), 100, 10); + + + //Sends a continuous request by providing the request object, a callback method and a 5 seconds timeout. + ProgressRequest request = new ProgressRequest(); + request.Amount = 100; + request.Delay = 10; + + context.SendContinuous<ProgressResponse>(request, (response) => + { + context.WriteLine(response); + }, 5); + + + //Sends a continuous request by providing the request object, a defined callback method and a 5 seconds timeout. + //We need to store the context globally so the callback method will have access to it. + _context = context; + context.SendContinuous<ProgressResponse>(request, OnProgressResponse, 5); + } + + private void OnProgressResponse(ProgressResponse response) + { + _context.WriteLine(response); + } + } + #endregion +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/IProcedureContext.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/IProcedureContext.cs index 4c6f5cc6b..a72d26495 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/IProcedureContext.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/IProcedureContext.cs @@ -22,9 +22,6 @@ namespace Tango.FSE.Procedures /// <summary> /// Represents the main procedures API. /// </summary> - /// <example> - /// <code lang="C#" source="../Tango.FSE.Procedures/Resources/main_template.csx" title="Simple procedure" /> - /// </example> /// <seealso cref="Tango.Scripting.Basic.IContext" /> public interface IProcedureContext : IContext { @@ -107,12 +104,23 @@ namespace Tango.FSE.Procedures void ClearResults(); /// <summary> - /// Sends a request by name with optional comma separated arguments. + /// Sends a stub request by name, with optional comma separated arguments. /// </summary> + /// <remarks> + /// This Send override accepts only stub requests. + /// </remarks> /// <param name="messageName">Name of the message.</param> - /// <param name="timeout">The timeout in seconds.</param> - /// <param name="args">The arguments separated by commas.</param> - /// <returns></returns> + /// <param name="timeout">Request timeout in seconds. (leave null to get the default timeout)</param> + /// <param name="args">Request arguments separated by commas.</param> + /// <returns>Returns the response message.</returns> + /// <example> + /// <para> + /// <i> + /// The following example demonstrates how to send a request to the machine and get a response using the various different Send method overrides. + /// </i> + /// </para> + /// <code lang="C#" source="../Tango.FSE.Procedures/Examples/Send/Program.cs" title="Send a request" region="Example" /> + /// </example> IMessage Send(String messageName, TimeSpan? timeout = null, params Object[] args); /// <summary> @@ -121,6 +129,14 @@ namespace Tango.FSE.Procedures /// <param name="messageName">Name of the message.</param> /// <param name="args">The arguments separated by commas.</param> /// <returns></returns> + /// <example> + /// <para> + /// <i> + /// The following example demonstrates how to send a request to the machine and get a response using the various different Send method overrides. + /// </i> + /// </para> + /// <code lang="C#" source="../Tango.FSE.Procedures/Examples/Send/Program.cs" title="Send a request" region="Example" /> + /// </example> IMessage Send(String messageName, params Object[] args); /// <summary> @@ -131,6 +147,14 @@ namespace Tango.FSE.Procedures /// <param name="timeout">The timeout in seconds.</param> /// <param name="args">The arguments separated by commas.</param> /// <returns></returns> + /// <example> + /// <para> + /// <i> + /// The following example demonstrates how to send a request to the machine and get a response using the various different Send method overrides. + /// </i> + /// </para> + /// <code lang="C#" source="../Tango.FSE.Procedures/Examples/Send/Program.cs" title="Send a request" region="Example" /> + /// </example> T Send<T>(String messageName, TimeSpan? timeout = null, params Object[] args) where T : class, IMessage; /// <summary> @@ -140,6 +164,14 @@ namespace Tango.FSE.Procedures /// <param name="messageName">Name of the message.</param> /// <param name="args">The arguments separated by commas.</param> /// <returns></returns> + /// <example> + /// <para> + /// <i> + /// The following example demonstrates how to send a request to the machine and get a response using the various different Send method overrides. + /// </i> + /// </para> + /// <code lang="C#" source="../Tango.FSE.Procedures/Examples/Send/Program.cs" title="Send a request" region="Example" /> + /// </example> T Send<T>(String messageName, params Object[] args) where T : class, IMessage; /// <summary> @@ -148,6 +180,14 @@ namespace Tango.FSE.Procedures /// <param name="message">The message.</param> /// <param name="timeout">The timeout in seconds.</param> /// <returns></returns> + /// <example> + /// <para> + /// <i> + /// The following example demonstrates how to send a request to the machine and get a response using the various different Send method overrides. + /// </i> + /// </para> + /// <code lang="C#" source="../Tango.FSE.Procedures/Examples/Send/Program.cs" title="Send a request" region="Example" /> + /// </example> IMessage Send(IMessage message, int? timeout = null); /// <summary> @@ -157,6 +197,14 @@ namespace Tango.FSE.Procedures /// <param name="message">The message.</param> /// <param name="timeout">The timeout in seconds.</param> /// <returns></returns> + /// <example> + /// <para> + /// <i> + /// The following example demonstrates how to send a request to the machine and get a response using the various different Send method overrides. + /// </i> + /// </para> + /// <code lang="C#" source="../Tango.FSE.Procedures/Examples/Send/Program.cs" title="Send a request" region="Example" /> + /// </example> T Send<T>(IMessage message, int? timeout = null) where T : class, IMessage; /// <summary> @@ -166,6 +214,14 @@ namespace Tango.FSE.Procedures /// <param name="message">The message.</param> /// <param name="callback">Callback for continuous responses.</param> /// <param name="timeout">The timeout in seconds.</param> + /// <example> + /// <para> + /// <i> + /// The following example demonstrates how to send a continuous request to the machine and get a continuous response using the various different SendContinuous method overrides. + /// </i> + /// </para> + /// <code lang="C#" source="../Tango.FSE.Procedures/Examples/SendContinuous/Program.cs" title="Send a request" region="Example" /> + /// </example> void SendContinuous<T>(IMessage message, Action<T> callback, int? timeout) where T : class, IMessage; /// <summary> @@ -176,7 +232,7 @@ namespace Tango.FSE.Procedures /// <param name="callback">Callback for continuous responses.</param> /// <param name="timeout">The timeout in seconds.</param> /// <param name="args">The arguments.</param> - void SendContinuous<T>(String messageName, Action<T> callback, int? timeout, params Object[] args) where T : class, IMessage; + void SendContinuous<T>(String messageName, Action<T> callback, TimeSpan? timeout, params Object[] args) where T : class, IMessage; /// <summary> /// Sends a continuous message with optional comma separated arguments. diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/ProcedureContext.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/ProcedureContext.cs index 0f422c5f5..1676fb2ed 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/ProcedureContext.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/ProcedureContext.cs @@ -168,7 +168,7 @@ namespace Tango.FSE.Procedures return Send(messageName, timeout) as T; } - public void SendContinuous<T>(IMessage messageName, Action<T> callback, int? timeout = null) where T : class, IMessage + public void SendContinuous<T>(IMessage message, Action<T> callback, int? timeout = null) where T : class, IMessage { TaskCompletionSource<object> completion = new TaskCompletionSource<object>(); @@ -179,7 +179,7 @@ namespace Tango.FSE.Procedures timespan = TimeSpan.FromMilliseconds(timeout.Value); } - MachineProvider.MachineOperator.SendContinuousRequest(messageName, new Transport.TransportContinuousRequestConfig() + MachineProvider.MachineOperator.SendContinuousRequest(message, new Transport.TransportContinuousRequestConfig() { Timeout = timespan, ContinuousTimeout = timespan @@ -201,7 +201,7 @@ namespace Tango.FSE.Procedures completion.Task.GetAwaiter().GetResult(); } - public void SendContinuous<T>(string messageName, Action<T> callback, int? timeout = null, params object[] args) where T : class, IMessage + public void SendContinuous<T>(string messageName, Action<T> callback, TimeSpan? timeout = null, params object[] args) where T : class, IMessage { var stubType = MessageFactory.GetAvailableRequestStubs().SingleOrDefault(x => x.Name.ToLower() == messageName.ToLower() || x.Name.Replace("Request", "").ToLower() == messageName.ToLower()); if (stubType == null) @@ -242,7 +242,7 @@ namespace Tango.FSE.Procedures } } - SendContinuous<IMessage>(request, callback as Action<IMessage>, timeout); + SendContinuous<IMessage>(request, callback as Action<IMessage>, timeout != null ? (int?)timeout.Value.TotalSeconds : null); } public void SendContinuous<T>(string messageName, Action<T> callback, params object[] args) where T : class, IMessage diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Resources/main_template.csx b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Resources/main_template.csx index 8a2516cac..26e4fcb1c 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Resources/main_template.csx +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Resources/main_template.csx @@ -20,7 +20,6 @@ public class Program { public void OnExecute(IProcedureContext context) { - context.AddResult(ResultType.Passed, "My Value Name", "Test for this value has passed."); } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Tango.FSE.Procedures.csproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Tango.FSE.Procedures.csproj index a928bba75..266fc55aa 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Tango.FSE.Procedures.csproj +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Tango.FSE.Procedures.csproj @@ -150,6 +150,8 @@ <DependentUpon>UserInputDialogView.xaml</DependentUpon> </Compile> <Compile Include="Dialogs\UserInputDialogViewVM.cs" /> + <Compile Include="Examples\SendContinuous\Program.cs" /> + <Compile Include="Examples\Send\Program.cs" /> <Compile Include="Helpers\ProcedureExceptionHelper.cs" /> <Compile Include="IDialogController.cs" /> <Compile Include="IProcedureContext.cs" /> @@ -399,6 +401,7 @@ <ItemGroup> <Resource Include="Images\blend.png" /> </ItemGroup> + <ItemGroup /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="..\..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets" Condition="Exists('..\..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets')" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/ViewModels/ProcedureDesignerViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/ViewModels/ProcedureDesignerViewVM.cs index 3023d974b..fa649d1e0 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/ViewModels/ProcedureDesignerViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/ViewModels/ProcedureDesignerViewVM.cs @@ -1433,6 +1433,58 @@ namespace Tango.FSE.Procedures.ViewModels private void OpenHelpFile() { + String word = View.GetCaretWord(); + + if (word != null) + { + String memberSign = null; + String typeFullName = null; + + if (typeof(IProcedureContext).GetProperties(BindingFlags.Instance | BindingFlags.Public).Any(x => x.Name == word)) + { + memberSign = "P"; + } + + if (memberSign == null) + { + if (typeof(IProcedureContext).GetMethods(BindingFlags.Instance | BindingFlags.Public).Any(x => x.Name == word)) + { + memberSign = "M"; + } + } + + if (memberSign == null) + { + var type = typeof(IProcedureContext).Assembly.GetTypes().FirstOrDefault(x => x.Name == word); + if (type != null) + { + memberSign = "T"; + typeFullName = type.FullName.Replace(".", "_"); + } + } + + if (memberSign != null) + { + String url = String.Empty; + + if (memberSign == "T") + { + url = $"{typeFullName}.htm"; + } + else + { + url = $"Tango_FSE_Procedures_IProcedureContext_{word}.htm"; + } + + Process pp = new Process(); + pp.StartInfo.FileName = "hh.exe"; + pp.StartInfo.Arguments = $"ms-its:{Path.Combine(AssemblyHelper.GetCurrentAssemblyFolder(), "proc-doc.chm")}::/html/{memberSign}_{url}"; + pp.StartInfo.WindowStyle = ProcessWindowStyle.Maximized; + pp.Start(); + return; + } + } + Process p = new Process(); p.StartInfo.FileName = Path.Combine(AssemblyHelper.GetCurrentAssemblyFolder(), "proc-doc.chm"); p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized; diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Views/ProcedureDesignerView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Views/ProcedureDesignerView.xaml.cs index 0ee25b64d..e6857a87b 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Views/ProcedureDesignerView.xaml.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Views/ProcedureDesignerView.xaml.cs @@ -248,5 +248,10 @@ namespace Tango.FSE.Procedures.Views { runTimeBreakPointCanvas.Visibility = Visibility.Hidden; } + + public string GetCaretWord() + { + return GetCurrentEditor()?.GetCaretWord(); + } } } diff --git a/Software/Visual_Studio/Project Templates/Tango FSE Procedure Example.zip b/Software/Visual_Studio/Project Templates/Tango FSE Procedure Example.zip Binary files differnew file mode 100644 index 000000000..e220c4f8c --- /dev/null +++ b/Software/Visual_Studio/Project Templates/Tango FSE Procedure Example.zip diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/ScriptEditor.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/ScriptEditor.cs index b355ba818..6c248b63d 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/ScriptEditor.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/ScriptEditor.cs @@ -2750,6 +2750,44 @@ namespace Tango.Scripting.Editors } } + public String GetCaretWord() + { + try + { + var word_separators_plus = word_separators.ToList(); + word_separators_plus.Add(')'); + word_separators_plus.Add(';'); + + int wordStartOffset = CaretOffset; + int wordEndOffset = CaretOffset; + + while (wordStartOffset > 0) + { + if (word_separators_plus.Contains(Document.Text[wordStartOffset])) break; + wordStartOffset--; + } + + while (wordEndOffset < Document.Text.Length) + { + if (word_separators_plus.Contains(Document.Text[wordEndOffset])) break; + wordEndOffset++; + } + + if (wordStartOffset > 0) + { + wordStartOffset++; + } + + String word = Document.Text.Substring(wordStartOffset, wordEndOffset - wordStartOffset); + + return word; + } + catch + { + return null; + } + } + #endregion } } |
