1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using PaintDotNet.Measurement.Enum;
- using System;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- namespace PaintDotNet.Measurement.ObjInfo
- {
- /// <summary>
- /// Carries information about the subset of Brush configuration details that we support.
- /// Does not carry color information.
- /// </summary>
- [Serializable]
- public class BrushInfo : ICloneable
- {
- private BrushType brushType;
- private HatchStyle hatchStyle;
- public BrushType BrushType
- {
- get
- {
- return brushType;
- }
- set
- {
- brushType = value;
- }
- }
- /// <summary>
- /// If BrushType is equal to BrushType.Hatch, then this info is pertinent.
- /// </summary>
- public HatchStyle HatchStyle
- {
- get
- {
- return hatchStyle;
- }
- set
- {
- hatchStyle = value;
- }
- }
- public Brush CreateBrush(Color foreColor, Color backColor)
- {
- if (brushType == BrushType.Solid)
- {
- return new SolidBrush(foreColor);
- }
- else if (brushType == BrushType.Hatch)
- {
- return new HatchBrush(hatchStyle, foreColor, backColor);
- }
- throw new InvalidOperationException("BrushType is invalid");
- }
- public BrushInfo(BrushType brushType, HatchStyle hatchStyle)
- {
- this.brushType = brushType;
- this.hatchStyle = hatchStyle;
- }
- public BrushInfo Clone()
- {
- return new BrushInfo(this.brushType, this.hatchStyle);
- }
- object ICloneable.Clone()
- {
- return Clone();
- }
- }
- }
|