public virtual void ReplaceExpressionMarker(EditorControl editor) { QuickletMarker newExpression = new QuickletMarker(Begin.Offset + 1, End.Offset - (Begin.Offset + 1), MarkerType, markerColor, MainForm.rm.GetString("expressionTooltip")); RemoveExpressionFromEditor(editor); Expression = newExpression; AddExpressionToEditor(editor); }
public ExpressionMarker(int beginOffset, int length, string varName) { expression = new QuickletMarker(beginOffset, length, MarkerType, markerColor, MainForm.rm.GetString("expressionTooltip")); begin = new QuickletMarker(beginOffset - 1, 1, TextMarkerType.Invisible, System.Drawing.Color.Blue, ""); end = new QuickletMarker(beginOffset + length, 1, TextMarkerType.Invisible, System.Drawing.Color.Blue, ""); VariableName = varName; }
public CopyMarker(int beginOffset, int length, ExpressionMarker parent) { markerColor = Color.Black; base.MarkerType = TextMarkerType.CopyMarker; Expression = new QuickletMarker(beginOffset, length, MarkerType, markerColor); Begin = new QuickletMarker(beginOffset - 1, 1, TextMarkerType.Invisible, System.Drawing.Color.Aqua); End = new QuickletMarker(beginOffset + length, 1, TextMarkerType.Invisible, System.Drawing.Color.Aqua); VariableName = ""; Parent = parent; }
public void InsertString(string text, int offset, EditorControl editor) { if (mouseEndPosition != null) { removeMouseEndPosition(editor); } int indexOfEndMarker = text.IndexOf("$end$"); if (indexOfEndMarker > -1) { text = text.Replace("$end$", ""); TextLocation tl = editor.Document.OffsetToPosition(offset); tl.Column += indexOfEndMarker; editor.Document.Insert(offset, text); mouseEndPosition = new QuickletMarker(editor.Document.PositionToOffset(tl), 1, TextMarkerType.QuickMark, Color.Red, MainForm.rm.GetString("EndMarkerToolTip")); editor.Document.MarkerStrategy.AddMarker(mouseEndPosition); } }
private void GenerateExpressions(string formattedTemplate, int shortcutBeginOffset) { cleanTemplate = formattedTemplate; list.Clear(); int pos = 0; for (int i = 0; i < variablesInTemplate + 1; i++) { int begin = cleanTemplate.IndexOf("$", pos); int end = cleanTemplate.IndexOf("$", begin + 1); end += 1; string varName = cleanTemplate.Substring(begin, end - begin); if (varName == "$end$") { EndMarker = new QuickletMarker(begin + shortcutBeginOffset, 1, TextMarkerType.QuickMark, Color.Red); cleanTemplate = cleanTemplate.Remove(begin, "$end$".Length); } else { Variable var = getVariableByName(varName); if (var.Name != "") { cleanTemplate = cleanTemplate.Remove(begin, var.Name.Length); cleanTemplate = cleanTemplate.Insert(begin, var.Value); pos = begin + var.Value.Length; ExpressionMarker parent = getParentMarker(var.Name); if (parent == null) { list.Add(new ExpressionMarker(begin + shortcutBeginOffset, var.Value.Length, var.Name)); } else { list.Add(new CopyMarker(begin + shortcutBeginOffset, var.Value.Length, parent)); } } } } }
private void removeMouseEndPosition(EditorControl editor) { editor.Document.MarkerStrategy.RemoveMarker(mouseEndPosition); mouseEndPosition = null; editor.Refresh(); }