/// <summary>Draws the specified sub-image of image strip.</summary> /// <param name="g">The graphic representing drawing surface.</param> /// <param name="subImageNumber">Part number.</param> /// <param name="destinationRectangle">Destination rectangle.</param> /// <param name="borderThickness">The part border thickness.</param> /// <exception cref="T:System.ArgumentNullException">g is null.</exception> /// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="subImageNumber" /> is less than zero or isn't less than number of sub-images. /// -- or -- /// <paramref name="borderThickness" /> is less than zero.</exception> /// <exception cref="T:System.ObjectDisposedException">Thrown when image strip is disposed.</exception> public void DrawSubImage(Graphics g, int subImageNumber, Rectangle destinationRectangle, int borderThickness) { if (disposed) { throw new ObjectDisposedException(GetType().FullName); } if (g == null) { throw new ArgumentNullException("g"); } if (subImageNumber < 0 || subImageNumber >= SubImagesCount) { throw new ArgumentOutOfRangeException(); } if (borderThickness < 0) { throw new ArgumentOutOfRangeException(); } DrawingParameters dp = new DrawingParameters(); dp.BorderThickness = borderThickness; dp.Size = destinationRectangle.Size; dp.SubImage = subImageNumber; if (!bitmapDictionary.ContainsKey(dp)) { Bitmap b = new Bitmap(destinationRectangle.Width, destinationRectangle.Height); using (Graphics gb = Graphics.FromImage(b)) { gb.Clear(Color.Transparent); switch (Orientation) { case ImageStripOrientation.Horizontal: DrawSubImage(gb, ImageStripBitmap, new Rectangle(new Point(SubImageSize.Width * subImageNumber, 0), SubImageSize), destinationRectangle, borderThickness); break; case ImageStripOrientation.Vertical: DrawSubImage(gb, ImageStripBitmap, new Rectangle(new Point(0, SubImageSize.Height * subImageNumber), SubImageSize), destinationRectangle, borderThickness); break; } } Pair pair = new Pair(); pair.DrawingParameters = dp; pair.Bitmap = b; bitmapList.Add(pair); bitmapDictionary[dp] = b; if (bitmapList.Count > bitmapListMaximumSize) { Pair pairToDel = bitmapList[0]; bitmapList.RemoveAt(0); bitmapDictionary.Remove(pairToDel.DrawingParameters); } } g.DrawImage(bitmapDictionary[dp], destinationRectangle); }
protected internal override void DrawCustomForSingleSurroundingRect(Rectangle rect, Scope scopeToDraw) { DrawingParameters borderParameters = new DrawingParameters(Color.Empty, graphics, RTB.ImplicitScopeBorderColor, 35, RTB.NonActiveScopeBorderWidth); DrawingParameters fillParameters = new DrawingParameters(RTB.ActiveScopeFillColor, graphics, 35); fillParameters.IsActive = IsActive; borderParameters.IsActive = IsActive; borderParameters.BorderColor = RTB.ActiveScopeBorderColor; borderParameters.BorderWidth = RTB.ActiveScopeBorderWidth; fillParameters.FillColor = RTB.ActiveScopeFillColor; fillParameters.BorderWidth = RTB.ActiveScopeBorderWidth; visible = true; Rectangle finalRect = rect; fillParameters.Rect = finalRect; borderParameters.Rect = finalRect; DrawBorder(borderParameters); DrawFill(fillParameters); return; }
protected override void HighlightText(Color fillColor, int fillOpacity, Color borderColor, int borderOpacity, int borderWidth, bool shouldDrawFill, bool shouldDrawBorder) { txt.SelectionLength = 0; DrawingParameters fillData = new DrawingParameters(fillColor, txt.CreateGraphics(), fillColor, fillOpacity, borderWidth); DrawingParameters borderData = new DrawingParameters(borderColor, txt.CreateGraphics(), borderColor, borderOpacity, borderWidth); if (shouldDrawFill) { txt.DrawFill(selStart, selLength, fillData); } if (shouldDrawBorder) { txt.DrawBorder(selStart, selLength, borderData); } }
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 internal override void DrawCustomForSingleSurroundingRect(Rectangle rect, Scope scopeToDraw) { DrawingParameters borderParameters = new DrawingParameters(Color.Empty, graphics, Color.Empty, 65, RTB.NonActiveScopeBorderWidth); DrawingParameters fillParameters = new DrawingParameters(Color.Empty, graphics, 35); fillParameters.IsActive = IsActive; borderParameters.IsActive = IsActive; borderParameters.BorderColor = Color.Silver; borderParameters.BorderWidth = RTB.NonActiveScopeBorderWidth; fillParameters.FillColor = Color.Silver; visible = true; fillParameters.Rect = rect; borderParameters.Rect = rect; DrawBorder(borderParameters); // DrawFill(fillParameters); }
protected internal override void DrawCustomForSingleSurroundingRect(Rectangle rect, Scope scopeToDraw) { DrawingParameters borderParameters = new DrawingParameters(Color.Empty, graphics, RTB.ImplicitScopeBorderColor, 35, RTB.NonActiveScopeBorderWidth); DrawingParameters fillParameters = new DrawingParameters(Color.Empty, graphics, 35); fillParameters.IsActive = IsActive; borderParameters.IsActive = IsActive; borderParameters.BorderColor = Color.Black; borderParameters.Opacity = 255; borderParameters.BorderWidth = 2; fillParameters.FillColor = Color.LightYellow; fillParameters.Opacity = 200; Rectangle biggerRect = GetHigherRect(rect); fillParameters.Rect = biggerRect; borderParameters.Rect = biggerRect; DrawBorder(borderParameters); DrawFill(fillParameters); if (scopeToDraw.Name == string.Empty) { return; } Font italicFont = new Font(txt.Font.FontFamily, txt.Font.Size - 2, FontStyle.Italic); SizeF nameWidth = graphics.MeasureString(scopeToDraw.Name, italicFont); if (nameWidth.Width > rect.Width) { return; } graphics.DrawString(scopeToDraw.Suggestions[0].Description, italicFont, new SolidBrush(Color.Black), GetMiddleRect(biggerRect)); }
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); } }
/// <summary> /// /// </summary> /// <param name="shapeTypeEnum"></param> /// <param name="stroke"></param> /// <returns></returns> public TrackableShape CreateShape(ShapeType shapeTypeEnum, object drawingParameters) { DrawingParameters shapeDrawingParameters = drawingParameters as DrawingParameters; TrackableShape createdShape = new TrackableShape(); switch (shapeTypeEnum) { case (ShapeType.Line): createdShape.TwoDShape = new Line() { Stroke = shapeDrawingParameters.Stroke, StrokeThickness = shapeDrawingParameters.StrokeThickness }; createdShape.SetAddInitialPointMethod(new AddInitialPointToLine()); createdShape.SetAddEndPointMethod(new AddEndPointToLine()); break; case (ShapeType.Ellipse): createdShape.TwoDShape = new Ellipse() { Stroke = shapeDrawingParameters.Stroke, Fill = shapeDrawingParameters.Fill, StrokeThickness = shapeDrawingParameters.StrokeThickness }; createdShape.SetAddInitialPointMethod(new AddInitialPointToEllipse()); createdShape.SetAddEndPointMethod(new AddEndPointToEllipse()); break; case (ShapeType.Rectangle): createdShape.TwoDShape = new Rectangle() { Stroke = shapeDrawingParameters.Stroke, Fill = shapeDrawingParameters.Fill, StrokeThickness = shapeDrawingParameters.StrokeThickness }; createdShape.SetAddInitialPointMethod(new AddInitialPointToRectangle()); createdShape.SetAddEndPointMethod(new AddEndPointToRectangle()); break; case (ShapeType.Pencil): createdShape.TwoDShape = new Polyline() { Stroke = shapeDrawingParameters.Stroke, StrokeThickness = shapeDrawingParameters.StrokeThickness }; createdShape.SetAddInitialPointMethod(new AddInitialPointToPolyline()); createdShape.SetAddEndPointMethod(new AddEndPointToPolyline()); break; case (ShapeType.Polygon): createdShape.TwoDShape = new Polygon() { Stroke = shapeDrawingParameters.Stroke, StrokeThickness = shapeDrawingParameters.StrokeThickness, Fill = shapeDrawingParameters.Fill }; createdShape.SetAddInitialPointMethod(new AddInitialPointToPolygon()); createdShape.SetAddEndPointMethod(new AddEndPointToPolygon()); break; case (ShapeType.Polyline): createdShape.TwoDShape = new Polyline() { Stroke = shapeDrawingParameters.Stroke, StrokeThickness = shapeDrawingParameters.StrokeThickness }; createdShape.SetAddInitialPointMethod(new AddInitialPointToPolyline()); createdShape.SetAddEndPointMethod(new AddEndPointToPolyline()); break; } return(createdShape); }