public void DrawScopeOfUnknownLength(Scope scope, bool isActive, Graphics g) { if (scope.IsRoot) { return; } DrawingParameters borderParameters = new DrawingParameters(Color.Empty, g, implicitScopeBorderColor, scopeOpacity, nonActiveScopeBorderWidth); DrawingParameters fillParameters = new DrawingParameters(activeScopeFillColor, g, scopeOpacity); borderParameters.IsActive = isActive; fillParameters.IsActive = isActive; int startPos = scope.StartPosInRootScope; int length = scope.Length; if (scope.IsImplicit && scope.IsFlat) { borderParameters.BorderColor = implicitScopeBorderColor; borderParameters.BorderWidth = nonActiveScopeBorderWidth; rtb.DrawBorder(startPos, length, borderParameters); } if (!isActive && !scope.IsImplicit && scope.IsFlat) { borderParameters.BorderColor = nonActiveScopeBorderColor; rtb.DrawBorder(startPos, length, borderParameters); fillParameters.FillColor = nonActiveScopeFillColor; fillParameters.Opacity = 25; fillParameters.BorderWidth = nonActiveScopeBorderWidth; rtb.DrawFill(startPos, length, fillParameters); } if (isActive && !scope.IsImplicit && scope.IsFlat) { borderParameters.BorderColor = activeScopeBorderColor; borderParameters.BorderWidth = activeScopeBorderWidth; rtb.DrawBorder(startPos, length, borderParameters); fillParameters.FillColor = activeScopeFillColor; fillParameters.BorderWidth = activeScopeBorderWidth; rtb.DrawFill(startPos, length, fillParameters); } }
protected virtual void HighlightText(Color fillColor, int fillOpacity, Color borderColor, int borderOpacity, int borderWidth, bool shouldDrawFill, bool shouldDrawBorder) { DrawingParameters fillData = new DrawingParameters(fillColor, txt.CreateGraphics(), fillColor, fillOpacity, borderWidth); DrawingParameters borderData = new DrawingParameters(borderColor, txt.CreateGraphics(), borderColor, borderOpacity, borderWidth); int lastSelectionStart = txt.SelectionStart; int lastSelectionLength = txt.SelectionLength; if (root != null) { lastSelectionStart = root.StartPosInRootScope; lastSelectionLength = root.Length; } if (shouldDrawFill) { txt.DrawFill(lastSelectionStart, lastSelectionLength, fillData); } if (shouldDrawBorder) { txt.DrawBorder(lastSelectionStart, lastSelectionLength, borderData); } }