123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412 |
- using System;
- using System.ComponentModel;
- using System.Drawing;
- using System.Drawing.Design;
- using CustomControls.Pattern.DataModels;
- using DevExpress.Utils.Serializing;
- using DevExpress.XtraPrinting;
- using DevExpress.XtraReports;
- using DevExpress.XtraReports.Expressions;
- using DevExpress.XtraReports.UI;
- using DevExpress.XtraReports.UserDesigner;
- namespace CustomControls.Pattern
- {
- /// <summary>
- /// 控件
- /// </summary>
- [ToolboxItem(true)]
- [XRDesigner("CustomControls.Design.XRPatternDesigner,CustomControls.Design")]
- [Designer("CustomControls.Design._XRPatternDesigner,CustomControls.Design")]
- [XRToolboxSubcategory(0, 7)]
- [DefaultBindableProperty(nameof(StringData))]
- public class XRPattern : XRControl
- {
- PatternDataItem patternDataItem = new PatternDataItem();
- #region 隐藏属性
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override string Text
- {
- get => base.Text;
- set => base.Text = value;
- }
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override string TextFormatString
- {
- get => base.TextFormatString;
- set => base.TextFormatString = value;
- }
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override string XlsxFormatString
- {
- get => base.XlsxFormatString;
- set => base.XlsxFormatString = value;
- }
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override bool WordWrap
- {
- get => base.WordWrap;
- set => base.WordWrap = value;
- }
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override bool KeepTogether
- {
- get => base.KeepTogether;
- set => base.KeepTogether = value;
- }
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override HorizontalAnchorStyles AnchorHorizontal
- {
- get => base.AnchorHorizontal;
- set => base.AnchorHorizontal = value;
- }
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override VerticalAnchorStyles AnchorVertical
- {
- get => base.AnchorVertical;
- set => base.AnchorVertical = value;
- }
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override bool CanPublish
- {
- get => base.CanPublish;
- set => base.CanPublish = value;
- }
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override Color BackColor
- {
- get => base.BackColor;
- set => base.BackColor = value;
- }
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override Color BorderColor
- {
- get => base.BorderColor;
- set => base.BorderColor = value;
- }
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override BorderDashStyle BorderDashStyle
- {
- get => base.BorderDashStyle;
- set => base.BorderDashStyle = value;
- }
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override float BorderWidth
- {
- get => base.BorderWidth;
- set => base.BorderWidth = value;
- }
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override BorderSide Borders
- {
- get => base.Borders;
- set => base.Borders = value;
- }
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override Font Font
- {
- get => base.Font;
- set => base.Font = value;
- }
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override Color ForeColor
- {
- get => base.ForeColor;
- set => base.ForeColor = value;
- }
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override PaddingInfo Padding
- {
- get => base.Padding;
- set => base.Padding = value;
- }
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override StylePriority StylePriority => base.StylePriority;
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override XRControlStyles Styles => base.Styles;
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override TextAlignment TextAlignment
- {
- get => base.TextAlignment;
- set => base.TextAlignment = value;
- }
- [Bindable(false), EditorBrowsable(EditorBrowsableState.Never)]
- public override event BindingEventHandler EvaluateBinding
- {
- add { }
- remove { }
- }
- [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
- public override event PrintOnPageEventHandler PrintOnPage
- {
- add { }
- remove { }
- }
- [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
- public override event PreviewMouseEventHandler PreviewMouseMove
- {
- add { }
- remove { }
- }
- [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
- public override event PreviewMouseEventHandler PreviewMouseDown
- {
- add { }
- remove { }
- }
- [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
- public override event PreviewMouseEventHandler PreviewMouseUp
- {
- add { }
- remove { }
- }
- [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
- public override event PreviewMouseEventHandler PreviewClick
- {
- add { }
- remove { }
- }
- [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
- public override event PreviewMouseEventHandler PreviewDoubleClick
- {
- add { }
- remove { }
- }
- [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
- public override event DrawEventHandler Draw
- {
- add { }
- remove { }
- }
- [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
- public override event HtmlEventHandler HtmlItemCreated
- {
- add { }
- remove { }
- }
- [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
- public override event EventHandler TextChanged
- {
- add { }
- remove { }
- }
- [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
- public override event DevExpress.XtraReports.UI.ChangeEventHandler SizeChanged
- {
- add { }
- remove { }
- }
- #endregion
- #region 属性和方法
- public new XRPatternScripts Scripts => (XRPatternScripts)fEventScripts;
- [DisplayName("String Data")]
- [Description("String Data description")]
- [Category("Data")]
- [XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
- [RefreshProperties(RefreshProperties.All)]
- public string StringData
- {
- get => patternDataItem.PatternData;
- set => patternDataItem.PatternData = value;
- }
- bool ShouldSerializeStringData() => false;
- [DisplayName("Row Space")]
- [Description("Row Space description")]
- [Category("Data")]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
- [XtraSerializableProperty(XtraSerializationVisibility.Content)]
- public int RowSpace
- {
- get => patternDataItem.RowSpace;
- set => patternDataItem.RowSpace = value;
- }
- [DisplayName("Column Space")]
- [Description("Column Space description")]
- [Category("Data")]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
- [XtraSerializableProperty(XtraSerializationVisibility.Content)]
- public int ColumnSpace
- {
- get => patternDataItem.ColumnSpace;
- set => patternDataItem.ColumnSpace = value;
- }
- [DisplayName("Is Draw Horizontal Line")]
- [Description("Is Draw Horizontal Line description")]
- [Category("Data")]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
- [XtraSerializableProperty(XtraSerializationVisibility.Content)]
- public bool IsDrawHorizontalLine
- {
- get => patternDataItem.IsDrawHorizontalLine;
- set => patternDataItem.IsDrawHorizontalLine = value;
- }
- [DisplayName("Code Options")]
- [Description("Code Options description")]
- [Category("Data")]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- [XtraSerializableProperty(XtraSerializationVisibility.Content)]
- public CodeOptions CodeOptions { get; } = new CodeOptions();
- #endregion
- #region 构造函数
- static XRPattern()
- {
- ExpressionBindingDescriptor.SetPropertyDescription(typeof(XRPattern), nameof(StringData), new ExpressionBindingDescription(new string[] { "BeforePrint" }, 1000, new string[0]));
- }
- public XRPattern()
- {
- }
- #endregion
- #region 重写属性和方法
- /// <summary>
- /// 固定模块大小
- /// </summary>
- //public override RectangleF BoundsF
- //{
- // get => AdaptBounds(base.BoundsF);
- // set => base.BoundsF = value;
- //}
- RectangleF AdaptBounds(RectangleF rect)
- {
- if (RootReport != null)
- {
- rect.Size = GraphicsUnitConverter.Convert(GetActualSize(), GraphicsDpi.Millimeter, Dpi);
- }
- return rect;
- }
- SizeF GetActualSize() => Constants.Bounds.Size;
- protected override XRControlScripts CreateScripts() => new XRPatternScripts(this);
- protected override int DefaultHeight =>
- ConvertFromMMToDpi(Constants.Bounds.Height, GraphicsDpi.HundredthsOfAnInch);
- protected override int DefaultWidth =>
- ConvertFromMMToDpi(Constants.Bounds.Width, GraphicsDpi.HundredthsOfAnInch);
- int ConvertFromMMToDpi(float mmValue, float targetDpi) => (int)GraphicsUnitConverter.Convert(mmValue, GraphicsDpi.Millimeter, targetDpi);
- protected override VisualBrick CreateBrick(VisualBrick[] childrenBricks) => new PatternBrick(this);
- protected override void PutStateToBrick(VisualBrick brick, PrintingSystemBase ps)
- {
- base.PutStateToBrick(brick, ps);
- if (!(brick is PatternBrick patternBrick)) return;
- patternBrick.CodeOptions.Assign(CodeOptions);
- patternBrick.GenerateContent(patternDataItem);
- }
- protected override void GetStateFromBrick(VisualBrick brick) => base.GetStateFromBrick(brick);
- #endregion
- }
- }
|