예제 #1
0
        private void Options_Load(object sender, EventArgs e)
        {
            HeaderText  = Configuration.GetSetting(Constants.Application.Header.Text) ?? string.Empty;
            EncodedLogo = Configuration.GetSetting(Constants.Application.Logo.Image) ?? string.Empty;
            LogoHeight  = Configuration.GetSettingOrDefault(Constants.Application.Logo.Height, int.TryParse, 0);
            Unit        = Configuration.GetSetting(Constants.Document.MeasurementUnit) ?? Constants.Document.Defaults.MeasurementUnitDefault;

            // draw grid on export
            Configuration.GetSettingOrDefault(Constants.Document.DrawGridOnExport, bool.TryParse, true);

            // Header Text
            _backColor = Color.FromArgb(Configuration.GetSettingOrDefault <int>(Constants.Application.Header.TextColor, int.TryParse, Constants.Measurement.Defaults.Black));

            HeaderFont        = FontHelpers.GetHeaderFont();
            lblFont.Font      = HeaderFont;
            lblFont.ForeColor = _backColor;
            //lblFont.Text = string.Format("{0}, {1} {2}", HeaderFont.Name, HeaderFont.Size, HeaderFont.Style);

            txtHeaderText.DataBindings.Add("Text", this, "HeaderText");
            nupLogoHeight.DataBindings.Add("Value", this, "LogoHeight");
            txtUnit.DataBindings.Add("Text", this, "Unit");

            if (!string.IsNullOrEmpty(EncodedLogo))
            {
                LoadImageFromEncodedString(Convert.FromBase64String(EncodedLogo));
            }
        }
예제 #2
0
        private void AddLogoShapesToDocument(int LogoHeight, string LogoEncodedImage, int headerHeight, System.Drawing.Rectangle saveRectangle, Drawing translatedDrawing, Graphics g)
        {
            // add a line between the header and the actual drawing.
            translatedDrawing.AddShape(new Line(new Entry(0, headerHeight), new Entry(saveRectangle.Width / gridSize, headerHeight), Color.DarkGray, 2));

            if (!string.IsNullOrEmpty(LogoEncodedImage))
            {
                translatedDrawing.AddShape(new Image(new Entry(1, 1), new Entry(1, 1 + LogoHeight), LogoEncodedImage));
            }

            string headerText = Configuration.GetSetting(Constants.Application.Header.Text) ?? string.Empty;

            if (!string.IsNullOrEmpty(headerText))
            {
                Font  headerFont = FontHelpers.GetHeaderFont();
                Color color      = Color.FromArgb(Configuration.GetSettingOrDefault <int>(Constants.Application.Header.TextColor, int.TryParse, Constants.Measurement.Defaults.Black));
                //sadly, we need to create the image here as well, to see how big it is...
                // consider moving this in the logoimage

                int newWidth = GetLogoWidth(LogoHeight, LogoEncodedImage);

                // the size of the remaining space is:
                int remainingWidth = saveRectangle.Width - newWidth;

                var stringSize = g.MeasureString(headerText, headerFont);

                //compute the top corner for the text.
                float x = ((newWidth / gridSize) * gridSize) + (remainingWidth - stringSize.Width) / 2;
                float y = ((headerHeight * gridSize) - stringSize.Height) / 2;

                var top    = new Point((int)x, (int)y).ToEntry(gridSize);
                var bottom = new Entry(top.X + (int)(stringSize.Width / gridSize), top.Y + (int)(stringSize.Height / gridSize));

                translatedDrawing.AddShape(new Text(top, bottom, headerText, headerFont.Size, headerFont.FontFamily.Name, headerFont.Style, color));
            }
        }