Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReportPage"/> class with default settings.
 /// </summary>
 public ReportPage()
 {
     paperWidth   = 210;
     paperHeight  = 297;
     leftMargin   = 10;
     topMargin    = 10;
     rightMargin  = 10;
     bottomMargin = 10;
     InitPreview();
     bands                = new BandCollection(this);
     guides               = new FloatCollection();
     columns              = new PageColumns(this);
     border               = new Border();
     fill                 = new SolidFill(SystemColors.Window);
     watermark            = new Watermark();
     titleBeforeHeader    = true;
     startPageEvent       = "";
     finishPageEvent      = "";
     manualBuildEvent     = "";
     BaseName             = "Page";
     unlimitedHeight      = false;
     printOnRollPaper     = false;
     unlimitedWidth       = false;
     unlimitedHeightValue = MAX_PAPER_SIZE_MM * Units.Millimeters;
     unlimitedWidthValue  = MAX_PAPER_SIZE_MM * Units.Millimeters;
 }
Example #2
0
 internal void Serialize(FRWriter writer, PageColumns c)
 {
     if (Count != c.Count)
     {
         writer.WriteInt("Columns.Count", Count);
     }
     if (Count > 1)
     {
         writer.WriteFloat("Columns.Width", Width);
         Positions = Positions; // avoid bug when number of positions is not equal number of columns
         writer.WriteValue("Columns.Positions", Positions);
     }
 }
Example #3
0
        private void DrawGuides(Graphics g)
        {
            FloatCollection guides = Workspace.Page.Guides;

            if (guides == null)
            {
                return;
            }
            for (int i = 0; i < guides.Count; i++)
            {
                Bitmap b = Res.GetImage(i == FActiveGuide ? 174 : 74);
                g.DrawImage(b, (int)Math.Round(Offset + guides[i] * ReportWorkspace.Scale - 4), 16);
            }
        }
Example #4
0
        private void DrawGuides(Graphics g, BandBase band)
        {
            FloatCollection guides = band.Guides;

            if (guides == null)
            {
                return;
            }
            for (int i = 0; i < guides.Count; i++)
            {
                Bitmap b = Res.GetImage(band == FActiveBand && i == FActiveGuide ? 173 : 73);
                g.DrawImage(b, 16, (int)Math.Round(Offset + (band.Top + guides[i]) * ReportWorkspace.Scale - 4));
            }
        }
Example #5
0
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (value is string)
     {
         FloatCollection result = new FloatCollection();
         string[]        values = (value as string).Split(new char[] { ',' });
         foreach (string s in values)
         {
             result.Add((float)Converter.FromString(typeof(float), s));
         }
         return(result);
     }
     return(base.ConvertFrom(context, culture, value));
 }
Example #6
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (Workspace.Locked)
            {
                return;
            }

            float scale = ReportWorkspace.Scale;

            if (e.Button == MouseButtons.None)
            {
                // find guide
                FloatCollection guides = Workspace.Page.Guides;
                if (guides == null)
                {
                    return;
                }
                FActiveGuide = -1;
                for (int i = 0; i < guides.Count; i++)
                {
                    if ((e.X - Offset) / scale > guides[i] - 5 && (e.X - Offset) / scale < guides[i] + 5)
                    {
                        FActiveGuide = i;
                        break;
                    }
                }
                Refresh();
            }
            else if (e.Button == MouseButtons.Left)
            {
                if (FActiveGuide == -1)
                {
                    return;
                }
                float kx = e.X / scale - FLastMousePoint.X;
                float ky = e.Y / scale - FLastMousePoint.Y;
                if (!CheckGridStep(ref kx, ref ky))
                {
                    return;
                }
                FMouseMoved = true;
                MoveGuide(kx);
                FLastMousePoint.X += kx;
                FLastMousePoint.Y += ky;
            }
        }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BandBase"/> class with default settings.
 /// </summary>
 public BandBase()
 {
     objects           = new ReportComponentCollection(this);
     guides            = new FloatCollection();
     beforeLayoutEvent = "";
     afterLayoutEvent  = "";
     outlineExpression = "";
     CanBreak          = false;
     ShiftMode         = ShiftMode.Never;
     if (BaseName.EndsWith("Band"))
     {
         BaseName = ClassName.Remove(ClassName.IndexOf("Band"));
     }
     SetFlags(Flags.CanMove | Flags.CanChangeOrder | Flags.CanChangeParent | Flags.CanCopy | Flags.CanGroup, false);
     FlagUseStartNewPage = true;
     FlagCheckFreeSpace  = true;
 }
Example #8
0
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == typeof(string))
     {
         if (value == null)
         {
             return("");
         }
         FastString      builder = new FastString();
         FloatCollection list    = value as FloatCollection;
         foreach (float f in list)
         {
             builder.Append(Converter.ToString(f)).Append(",");
         }
         if (builder.Length > 0)
         {
             builder.Remove(builder.Length - 1, 1);
         }
         return(builder.ToString());
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == typeof(string))
     {
         if (value == null)
         {
             return("");
         }
         string          result = "";
         FloatCollection list   = value as FloatCollection;
         foreach (float f in list)
         {
             result += Converter.ToString(f) + ",";
         }
         if (result.Length > 0)
         {
             result = result.Remove(result.Length - 1);
         }
         return(result);
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
Example #10
0
        private void DrawGuides(Graphics g, object obj)
        {
            FloatCollection guides   = null;
            bool            vertical = false;
            float           offs     = 0;

            if (obj is ReportPage)
            {
                guides   = (obj as ReportPage).Guides;
                vertical = true;
            }
            else if (obj is BandBase)
            {
                guides = (obj as BandBase).Guides;
                offs   = (obj as BandBase).Top;
            }
            if (guides != null)
            {
                Pen pen = new Pen(Color.CornflowerBlue);
                pen.DashStyle = DashStyle.Dot;
                foreach (float f in guides)
                {
                    float scale = ReportWorkspace.Scale;
                    if (vertical)
                    {
                        g.DrawLine(pen, f * scale, 0, f * scale, Workspace.Height);
                    }
                    else
                    {
                        if (f > 0 && f < (obj as BandBase).Height)
                        {
                            g.DrawLine(pen, 0, (f + offs) * scale, Workspace.Width, (f + offs) * scale);
                        }
                    }
                }
                pen.Dispose();
            }
        }
Example #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReportPage"/> class with default settings.
 /// </summary>
 public ReportPage()
 {
     FPaperWidth        = 210;
     FPaperHeight       = 297;
     FLeftMargin        = 10;
     FTopMargin         = 10;
     FRightMargin       = 10;
     FBottomMargin      = 10;
     FFirstPageSource   = 7;
     FOtherPagesSource  = 7;
     FDuplex            = Duplex.Default;
     FBands             = new BandCollection(this);
     FGuides            = new FloatCollection();
     FColumns           = new PageColumns(this);
     FBorder            = new Border();
     FFill              = new SolidFill(SystemColors.Window);
     FWatermark         = new Watermark();
     FTitleBeforeHeader = true;
     FStartPageEvent    = "";
     FFinishPageEvent   = "";
     FManualBuildEvent  = "";
     BaseName           = "Page";
 }
Example #12
0
        /// <summary>
        /// Gets a string format with specified settings.
        /// </summary>
        /// <param name="align">Text alignment information on the vertical plane.</param>
        /// <param name="lineAlign">Line alignment on the horizontal plane.</param>
        /// <param name="trimming"><b>StringTrimming</b> enumeration.</param>
        /// <param name="flags"><b>StringFormatFlags</b> enumeration that contains formatting information.</param>
        /// <param name="firstTab">The number of spaces between the beginning of a line of text and the first tab stop.</param>
        /// <param name="tabWidth">Distance between tab stops.</param>
        /// <param name="defaultTab">Default distance between default tabs stops.</param>
        /// <returns>The <b>StringFormat</b> object.</returns>
        public StringFormat GetStringFormat(StringAlignment align, StringAlignment lineAlign,
                                            StringTrimming trimming, StringFormatFlags flags, float firstTab, FloatCollection tabWidth,
                                            float defaultTab)
        {
            int hash = align.GetHashCode() ^ (lineAlign.GetHashCode() << 2) ^ (trimming.GetHashCode() << 5) ^
                       (flags.GetHashCode() << 16) ^ (100 - firstTab).GetHashCode() ^ tabWidth.GetHashCode();
            StringFormat result = stringFormats[hash] as StringFormat;

            if (result == null)
            {
                result               = new StringFormat();
                result.Alignment     = align;
                result.LineAlignment = lineAlign;
                result.Trimming      = trimming;
                result.FormatFlags   = flags;
                float[] tabStops = new float[64];
                // fixed issue 2823
                tabStops[0] = firstTab;
                for (int i = 1; i < 64; i++)
                {
                    if (i > tabWidth.Count)
                    {
                        tabStops[i] = defaultTab;
                        continue;
                    }
                    tabStops[i] = tabWidth[i - 1];
                }
                result.SetTabStops(0, tabStops);
                stringFormats[hash] = result;
            }
            return(result);
        }
Example #13
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (Workspace.Locked)
            {
                return;
            }

            float scale = ReportWorkspace.Scale;

            if (e.Button == MouseButtons.None)
            {
                // find band
                Cursor       = Cursors.Default;
                FResizing    = false;
                FActiveGuide = -1;
                FActiveBand  = BandAt(e.Y / scale - Offset);
                if (FActiveBand != null)
                {
                    // check band resize
                    if (e.Y / scale - Offset > FActiveBand.Bottom - 1 &&
                        e.Y / scale - Offset < FActiveBand.Bottom + (ReportWorkspace.ClassicView ? BandBase.HeaderSize : 4))
                    {
                        FResizing = true;
                        Cursor    = Cursors.HSplit;
                    }
                    else
                    {
                        // check guides
                        FloatCollection guides = FActiveBand.Guides;
                        if (guides != null)
                        {
                            for (int i = 0; i < guides.Count; i++)
                            {
                                if (e.Y / scale - Offset > FActiveBand.Top + guides[i] - 5 &&
                                    e.Y / scale - Offset < FActiveBand.Top + guides[i] + 5)
                                {
                                    FActiveGuide = i;
                                    break;
                                }
                            }
                        }
                    }
                }
                Refresh();
            }
            else if (e.Button == MouseButtons.Left)
            {
                float kx = e.X / scale - FLastMousePoint.X;
                float ky = e.Y / scale - FLastMousePoint.Y;
                if (!CheckGridStep(ref kx, ref ky))
                {
                    return;
                }

                if (FActiveBand != null)
                {
                    if (FResizing)
                    {
                        FMouseMoved = true;
                        ResizeBand(ky);
                    }
                    else if (FActiveGuide != -1)
                    {
                        FMouseMoved = true;
                        MoveGuide(ky);
                    }
                }
                FLastMousePoint.X += kx;
                FLastMousePoint.Y += ky;
            }
        }
        /// <summary>
        /// Reads a float array from the stream.
        /// </summary>
        public FloatCollection ReadFloatArray(string fieldName)
        {
            var values = new FloatCollection();

            List<object> token = null;

            if (!ReadArrayField(fieldName, out token))
            {
                return values;
            }

            for (int ii = 0; ii < token.Count; ii++)
            {
                try
                {
                    m_stack.Push(token[ii]);
                    values.Add(ReadFloat(null));
                }
                finally
                {
                    m_stack.Pop();
                }
            }

            return values;
        }
Example #15
0
 internal PageColumns(ReportPage page)
 {
     FPage      = page;
     FPositions = new FloatCollection();
     Count      = 1;
 }
Example #16
0
        /// <summary>
        /// Reads a float array from the stream.
        /// </summary>
        public FloatCollection ReadFloatArray(string fieldName)
        {
            bool isNil = false;

            FloatCollection values = new FloatCollection();
                                    
            if (BeginField(fieldName, true, out isNil))
            {                                
                PushNamespace(Namespaces.OpcUaXsd);
                
                while (MoveToElement("Float"))
                {
                    values.Add(ReadFloat("Float"));
                }

                // check the length.
                if (m_context.MaxArrayLength > 0 && m_context.MaxArrayLength < values.Count)
                {
                    throw new ServiceResultException(StatusCodes.BadEncodingLimitsExceeded);
                }

                PopNamespace();

                EndField(fieldName);
                return values;
            }

            if (isNil)
            {
                return null;
            }

            return values;
        }
Example #17
0
        /// <summary>
        /// Reads a float array from the stream.
        /// </summary>
        public FloatCollection ReadFloatArray(string fieldName)
        {
            int length = ReadArrayLength();

            if (length == -1)
            {
                return null;
            }

            FloatCollection values = new FloatCollection(length);

            for (int ii = 0; ii < length; ii++)
            {
                values.Add(ReadFloat(null));
            }

            return values;
        }