aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-01-08 19:00:50 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-01-08 19:00:50 +0200
commitdd4560b79e305772debf48cc76c9ba67af61f259 (patch)
tree9351aa19b976573c08cfcaafe6b976aaeda94fcf /Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs
parentce039a3181858a2b99bf58f43db90720e26089e1 (diff)
downloadTango-dd4560b79e305772debf48cc76c9ba67af61f259.tar.gz
Tango-dd4560b79e305772debf48cc76c9ba67af61f259.zip
Added code comments for:
SharedUI.
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs')
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs243
1 files changed, 172 insertions, 71 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs
index 7e643ef4b..1ad568aed 100644
--- a/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs
@@ -26,60 +26,107 @@ using Tango.SharedUI.Helpers;
namespace Tango.SharedUI.Controls
{
- #region Completion
-
- internal class CompletionData : ICompletionData
+ /// <summary>
+ /// Represents a C# script editor control.
+ /// </summary>
+ /// <seealso cref="System.Windows.Controls.UserControl" />
+ /// <seealso cref="System.Windows.Markup.IComponentConnector" />
+ public partial class ScriptEditorControl : UserControl
{
- private String _description;
-
- public BitmapSource Source { get; set; }
+ #region Completion
- public CompletionData(string text, String description)
+ /// <summary>
+ /// Represents an auto complete item.
+ /// </summary>
+ /// <seealso cref="ICSharpCode.AvalonEdit.CodeCompletion.ICompletionData" />
+ internal class CompletionData : ICompletionData
{
- this.Text = text;
- _description = description;
- }
+ private String _description;
- public System.Windows.Media.ImageSource Image
- {
- get { return Source; }
- }
+ /// <summary>
+ /// Gets or sets the icon source.
+ /// </summary>
+ public BitmapSource Source { get; set; }
- public string Text { get; private set; }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CompletionData"/> class.
+ /// </summary>
+ /// <param name="text">The text.</param>
+ /// <param name="description">The description.</param>
+ public CompletionData(string text, String description)
+ {
+ this.Text = text;
+ _description = description;
+ }
- // Use this property if you want to show a fancy UIElement in the drop down list.
- public object Content
- {
- get { return this.Text; }
- }
+ /// <summary>
+ /// Gets the image.
+ /// </summary>
+ public System.Windows.Media.ImageSource Image
+ {
+ get { return Source; }
+ }
- public object Description
- {
- get { return _description; }
- }
+ /// <summary>
+ /// Gets the text. This property is used to filter the list of visible elements.
+ /// </summary>
+ public string Text { get; private set; }
+
+ // Use this property if you want to show a fancy UIElement in the drop down list.
+ public object Content
+ {
+ get { return this.Text; }
+ }
- public double Priority { get { return 0; } }
+ /// <summary>
+ /// Gets the description.
+ /// </summary>
+ public object Description
+ {
+ get { return _description; }
+ }
- public void Complete(TextArea textArea, ISegment completionSegment, EventArgs insertionRequestEventArgs)
- {
- textArea.Document.Replace(completionSegment, this.Text);
- }
+ /// <summary>
+ /// Gets the priority. This property is used in the selection logic. You can use it to prefer selecting those items
+ /// which the user is accessing most frequently.
+ /// </summary>
+ public double Priority { get { return 0; } }
- public override string ToString()
- {
- return Text;
+ /// <summary>
+ /// Perform the completion.
+ /// </summary>
+ /// <param name="textArea">The text area on which completion is performed.</param>
+ /// <param name="completionSegment">The text segment that was used by the completion window if
+ /// the user types (segment between CompletionWindow.StartOffset and CompletionWindow.EndOffset).</param>
+ /// <param name="insertionRequestEventArgs">The EventArgs used for the insertion request.
+ /// These can be TextCompositionEventArgs, KeyEventArgs, MouseEventArgs, depending on how
+ /// the insertion was triggered.</param>
+ public void Complete(TextArea textArea, ISegment completionSegment, EventArgs insertionRequestEventArgs)
+ {
+ textArea.Document.Replace(completionSegment, this.Text);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String" /> that represents this instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String" /> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return Text;
+ }
}
- }
- #endregion
+ #endregion
- /// <summary>
- /// Interaction logic for ScriptEditorControl.xaml
- /// </summary>
- public partial class ScriptEditorControl : UserControl
- {
- private CompletionWindow completionWindow;
+ private CompletionWindow completionWindow; //Holds the auto-complete window instance.
+
+ #region Constructors
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ScriptEditorControl"/> class.
+ /// </summary>
public ScriptEditorControl()
{
InitializeComponent();
@@ -89,6 +136,15 @@ namespace Tango.SharedUI.Controls
textEditor.TextArea.TextEntered += textEditor_TextArea_TextEntered;
}
+ #endregion
+
+ #region Event Handlers
+
+ /// <summary>
+ /// Handles the TextEntered event of the textEditor_TextArea control.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="TextCompositionEventArgs"/> instance containing the event data.</param>
private void textEditor_TextArea_TextEntered(object sender, TextCompositionEventArgs e)
{
if (e.Text == ".")
@@ -146,6 +202,11 @@ namespace Tango.SharedUI.Controls
}
}
+ /// <summary>
+ /// Handles the TextEntering event of the textEditor_TextArea control.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="TextCompositionEventArgs"/> instance containing the event data.</param>
private void textEditor_TextArea_TextEntering(object sender, TextCompositionEventArgs e)
{
if (e.Text.Length > 0 && completionWindow != null)
@@ -159,6 +220,25 @@ namespace Tango.SharedUI.Controls
}
}
+ /// <summary>
+ /// Handles the TextChanged event of the textEditor control.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
+ private void textEditor_TextChanged(object sender, EventArgs e)
+ {
+ Text = textEditor.Text;
+ }
+
+ #endregion
+
+ #region Private Methods
+
+ /// <summary>
+ /// Fills the type.
+ /// </summary>
+ /// <param name="type">The type.</param>
+ /// <param name="data">The data.</param>
private void FillType(Type type, IList<ICompletionData> data)
{
List<CompletionData> items = new List<CompletionData>();
@@ -189,6 +269,11 @@ namespace Tango.SharedUI.Controls
}
}
+ /// <summary>
+ /// Fills the assembly.
+ /// </summary>
+ /// <param name="asm">The asm.</param>
+ /// <param name="data">The data.</param>
private void FillAssembly(Assembly asm, IList<ICompletionData> data)
{
var q = from t in asm.GetTypes()
@@ -201,10 +286,13 @@ namespace Tango.SharedUI.Controls
}
}
- #region Properties
-
+ #endregion
+ #region Properties
+ /// <summary>
+ /// Gets or sets the text.
+ /// </summary>
public String Text
{
get { return (String)GetValue(TextProperty); }
@@ -213,16 +301,9 @@ namespace Tango.SharedUI.Controls
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(String), typeof(ScriptEditorControl), new PropertyMetadata(null, (d, e) => (d as ScriptEditorControl).OnTextChanged()));
- private void OnTextChanged()
- {
- if (textEditor.Text != Text)
- {
- textEditor.Text = Text;
- }
- }
-
-
-
+ /// <summary>
+ /// Gets or sets the highlight types.
+ /// </summary>
public ObservableCollection<KeyValuePair<string, Type>> HighlightTypes
{
get { return (ObservableCollection<KeyValuePair<string, Type>>)GetValue(HighlightTypesProperty); }
@@ -231,12 +312,42 @@ namespace Tango.SharedUI.Controls
public static readonly DependencyProperty HighlightTypesProperty =
DependencyProperty.Register("HighlightTypes", typeof(ObservableCollection<KeyValuePair<string, Type>>), typeof(ScriptEditorControl), new PropertyMetadata(null));
+ #endregion
+
+ #region Virtual Methods
+ /// <summary>
+ /// Called when the text has changed.
+ /// </summary>
+ protected virtual void OnTextChanged()
+ {
+ if (textEditor.Text != Text)
+ {
+ textEditor.Text = Text;
+ }
+ }
+
+ /// <summary>
+ /// Called when the insert script command has changed.
+ /// </summary>
+ protected virtual void OnInsertScriptCommandChanged()
+ {
+ if (InsertSnippetCommand != null)
+ {
+ InsertSnippetCommand.Executed += (x, snippet) =>
+ {
+ textEditor.Document.Insert(textEditor.TextArea.Caret.Offset, snippet);
+ };
+ }
+ }
#endregion
#region Commands
+ /// <summary>
+ /// Gets or sets the run command.
+ /// </summary>
public RelayCommand RunCommand
{
get { return (RelayCommand)GetValue(RunCommandProperty); }
@@ -245,6 +356,9 @@ namespace Tango.SharedUI.Controls
public static readonly DependencyProperty RunCommandProperty =
DependencyProperty.Register("RunCommand", typeof(RelayCommand), typeof(ScriptEditorControl), new PropertyMetadata(null));
+ /// <summary>
+ /// Gets or sets the stop command.
+ /// </summary>
public RelayCommand StopCommand
{
get { return (RelayCommand)GetValue(StopCommandProperty); }
@@ -253,6 +367,9 @@ namespace Tango.SharedUI.Controls
public static readonly DependencyProperty StopCommandProperty =
DependencyProperty.Register("StopCommand", typeof(RelayCommand), typeof(ScriptEditorControl), new PropertyMetadata(null));
+ /// <summary>
+ /// Gets or sets the save command.
+ /// </summary>
public RelayCommand SaveCommand
{
get { return (RelayCommand)GetValue(SaveCommandProperty); }
@@ -261,8 +378,9 @@ namespace Tango.SharedUI.Controls
public static readonly DependencyProperty SaveCommandProperty =
DependencyProperty.Register("SaveCommand", typeof(RelayCommand), typeof(ScriptEditorControl), new PropertyMetadata(null));
-
-
+ /// <summary>
+ /// Gets or sets the insert snippet command.
+ /// </summary>
public RelayCommand<String> InsertSnippetCommand
{
get { return (RelayCommand<String>)GetValue(InsertSnippetCommandProperty); }
@@ -271,24 +389,7 @@ namespace Tango.SharedUI.Controls
public static readonly DependencyProperty InsertSnippetCommandProperty =
DependencyProperty.Register("InsertSnippetCommand", typeof(RelayCommand<String>), typeof(ScriptEditorControl), new PropertyMetadata(null,(d,e) => (d as ScriptEditorControl).OnInsertScriptCommandChanged()));
- private void OnInsertScriptCommandChanged()
- {
- if (InsertSnippetCommand != null)
- {
- InsertSnippetCommand.Executed += (x, snippet) =>
- {
- textEditor.Document.Insert(textEditor.TextArea.Caret.Offset, snippet);
- };
- }
- }
-
-
#endregion
-
- private void textEditor_TextChanged(object sender, EventArgs e)
- {
- Text = textEditor.Text;
- }
}
internal static class DocumentUtils