/// <summary></summary>
		public GlobalRenderingSettingData(GlobalRenderingSettingData previous)
			{
			BackgroundColor = new ColorEx( previous.BackgroundColor );
			SelectedObjectBorder = new PenEx( previous.SelectedObjectBorder );
			SelectedObjectFill = new HatchBrushEx( previous.SelectedObjectFill );
			InvalidObjectBorder = new PenEx( previous.InvalidObjectBorder );
			InvalidObjectFill = new HatchBrushEx( previous.InvalidObjectFill );
			DisabledObjectBorder = new PenEx( previous.DisabledObjectBorder );
			DisabledObjectFill = new HatchBrushEx( previous.DisabledObjectFill );
			}
 /// <summary></summary>
 public GlobalRenderingSettingData(GlobalRenderingSettingData previous)
 {
     BackgroundColor      = new ColorEx(previous.BackgroundColor);
     SelectedObjectBorder = new PenEx(previous.SelectedObjectBorder);
     SelectedObjectFill   = new HatchBrushEx(previous.SelectedObjectFill);
     InvalidObjectBorder  = new PenEx(previous.InvalidObjectBorder);
     InvalidObjectFill    = new HatchBrushEx(previous.InvalidObjectFill);
     DisabledObjectBorder = new PenEx(previous.DisabledObjectBorder);
     DisabledObjectFill   = new HatchBrushEx(previous.DisabledObjectFill);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Draws the rectangle by the pen on the canvas.
 /// </summary>
 private static void DrawRectangle(IDrawingCanvas canvas, PenEx pen, float x, float y, float width, float height)
 {
     PointF[] polygon = new[]
     {
         new PointF(x, y),
         new PointF(x + width, y),
         new PointF(x + width, y + height),
         new PointF(x, y + height),
         new PointF(x, y),
     };
     canvas.DrawPolygon(pen, polygon);
 }
Exemplo n.º 4
0
        void IDrawingCanvas.DrawAndFillPath(PenEx pen, BrushEx brush, PathEx path)
        {
            var pdfPath = GetPath(path);

            if (brush != null)
            {
                _graphics.DrawPath((BrushBase)brush, pdfPath);
            }
            if (pen != null)
            {
                _graphics.DrawPath((Pen)pen, pdfPath);
            }
        }
Exemplo n.º 5
0
        public void PenExCTorNegativeWidthTest()
        {
            ArgumentOutOfRangeException expected = null;

            try
            {
                PenEx pen = new PenEx(Color.Black, -1);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                expected = ex;
            }

            Assert.IsNotNull(expected);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Draws the month header row.
        /// </summary>
        private void DrawMonthTitle(MonthInfo month, ref float topOffset)
        {
            // calcs the rect to draw the month title row
            SizeF      monthTitleRowSize = CalendarData.GetMonthTitleRowSize(MonthAreaSize);
            RectangleF monthRowRect      = new RectangleF(
                CalendarArea.X, CalendarArea.Y + topOffset,
                monthTitleRowSize.Width, monthTitleRowSize.Height);
            float borderWidth = CalendarData.MonthTitleBorderStyle.LineWidth.ToTwips() / 2;

            // get month name to draw
            string monthTitle = string.Format(CalendarData.Culture,
                                              CalendarData.FormatString(new DateTime(month.Year, month.Month, 1), CalendarData.MonthTitleFormat));

            // fill the area
            using (BrushEx brush = Canvas.CreateSolidBrush(CalendarData.MonthTitleBackcolor))
                Canvas.FillRectangle(brush, monthRowRect);
            // draw month title string
            var font = CalendarData.MonthTitleFontStyle.CreateFontInfo();

            using (BrushEx brush = Canvas.CreateSolidBrush(CalendarData.MonthTitleFontStyle.FontColor))
            {
                RectangleF titleRect = new RectangleF(
                    monthRowRect.X + borderWidth, monthRowRect.Y + borderWidth,
                    monthRowRect.Width - 2 * borderWidth, monthRowRect.Height - 2 * borderWidth);

                // HACK: we should consider the issue with drawing string later. the issue comes about in the designer when caledar has small width to fit titles. --SergeyP
                Canvas.PushState();
                Canvas.DrawString(monthTitle, font, brush, titleRect, ToEx(CalendarData.MonthTitleStringFormat));
                Canvas.PopState();
            }
            // draw the borders
            using (PenEx pen = LineStyle.CreatePen(Canvas, CalendarData.MonthTitleBorderStyle))
            {
                pen.Alignment = PenAlignment.Center;
                DrawRectangle(Canvas, pen, monthRowRect.X, monthRowRect.Y,
                              monthRowRect.Width, monthRowRect.Height - borderWidth);           // shift the bottom border to avoid overlapping
            }

            // set offset
            topOffset += monthTitleRowSize.Height;
        }
		internal LayerSettingDialog(LayerData layer)
			{
			InitializeComponent();
			DialogResult = DialogResult.Cancel;

			Layer = layer;
			LayerProfile = Layer.Profile;
			textBoxLayerName.Text = Layer.Name;
			Border = new PenEx( LayerProfile.RenderSetting.Border );
			Fill = new HatchBrushEx( LayerProfile.RenderSetting.Fill );

			Text = Language.LayerSettingDialog.Text;
			labelName.Text = Language.LayerSettingDialog.LabelLayerName;
			groupBoxMaterial.Text = Language.LayerSettingDialog.GroupBoxMaterial;
			buttonMaterial.Text = Language.LayerSettingDialog.ButtonMaterial;
			groupBoxRenderingStyle.Text = Language.LayerSettingDialog.GroupBoxRenderingStyle;
			buttonBorderColor.Text = Language.LayerSettingDialog.ButtonBorderColor;
			buttonFillColor.Text = Language.LayerSettingDialog.ButtonFillColor;
			buttonFillStyle.Text = Language.LayerSettingDialog.ButtonFillStyle;
			buttonOK.Text = Language.DialogGeneral.ButtonOK;
			buttonCancel.Text = Language.DialogGeneral.ButtonCancel;
			}
Exemplo n.º 8
0
        /// <summary>
        /// Draws all months of the current calendar.
        /// </summary>
        private void DrawMonths(IEnumerable <MonthInfo> months)
        {
            try
            {
                try
                {
                    Canvas.PushState();

                    // draw the months of the calendar
                    float topOffset = 0;
                    foreach (MonthInfo month in months)
                    {
                        DrawMonth(month, ref topOffset);
                        topOffset += CalendarData.MonthsSpace;
                    }
                }
                finally
                {
                    Canvas.PopState();
                }
            }
            catch (Exception ex)
            {
                using (BrushEx brush = Canvas.CreateSolidBrush(Color.FromArgb(255, 255, 255, 255)))
                    Canvas.FillRectangle(brush, CalendarArea);
                using (PenEx pen = Canvas.CreatePen(Color.FromArgb(255, 255, 0, 0)))
                    Canvas.DrawPolygon(pen, new PointF[]
                    {
                        new PointF(CalendarArea.X, CalendarArea.Y),
                        new PointF(CalendarArea.X + CalendarArea.Width, CalendarArea.Y),
                        new PointF(CalendarArea.X + CalendarArea.Width, CalendarArea.Y + CalendarArea.Height),
                        new PointF(CalendarArea.X, CalendarArea.Y + CalendarArea.Height),
                        new PointF(CalendarArea.X, CalendarArea.Y),
                    });
                var font = new FontInfo(SystemFonts.DefaultFont.Name, SystemFonts.DefaultFont.SizeInPoints);
                using (BrushEx brush = Canvas.CreateSolidBrush(Color.FromArgb(255, 0, 0, 0)))
                    Canvas.DrawString(ex.ToString(), font, brush, CalendarArea, StringFormatEx.GetGenericDefault);
            }
        }
        internal LayerSettingDialog(LayerData layer)
        {
            InitializeComponent();
            DialogResult = DialogResult.Cancel;

            Layer                 = layer;
            LayerProfile          = Layer.Profile;
            textBoxLayerName.Text = Layer.Name;
            Border                = new PenEx(LayerProfile.RenderSetting.Border);
            Fill = new HatchBrushEx(LayerProfile.RenderSetting.Fill);

            Text                        = Language.LayerSettingDialog.Text;
            labelName.Text              = Language.LayerSettingDialog.LabelLayerName;
            groupBoxMaterial.Text       = Language.LayerSettingDialog.GroupBoxMaterial;
            buttonMaterial.Text         = Language.LayerSettingDialog.ButtonMaterial;
            groupBoxRenderingStyle.Text = Language.LayerSettingDialog.GroupBoxRenderingStyle;
            buttonBorderColor.Text      = Language.LayerSettingDialog.ButtonBorderColor;
            buttonFillColor.Text        = Language.LayerSettingDialog.ButtonFillColor;
            buttonFillStyle.Text        = Language.LayerSettingDialog.ButtonFillStyle;
            buttonOK.Text               = Language.DialogGeneral.ButtonOK;
            buttonCancel.Text           = Language.DialogGeneral.ButtonCancel;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Creates the pen to draw by specifed line style.
        /// </summary>
        public static PenEx CreatePen(IDrawingCanvas canvas, LineStyle style)
        {
            PenEx pen = canvas.CreatePen(style.LineColor, style.LineWidth.ToTwips());

            switch (style.DashStyle)
            {
            case BorderStyle.None:
                pen.Color = Color.FromArgb(0, 0, 0, 0);                         // Transparent color
                break;

            case BorderStyle.Dotted:
                pen.DashStyle = PenStyleEx.Dot;
                pen.StartCap  = LineCap.Round;
                pen.EndCap    = LineCap.Round;
                break;

            case BorderStyle.Dashed:
                pen.DashStyle = PenStyleEx.Dash;
                break;
            }
            return(pen);
        }
Exemplo n.º 11
0
 void IDrawingCanvas.DrawLine(PenEx pen, PointF from, PointF to)
 {
     _graphics.DrawLine((Pen)pen, PdfConverter.Convert(from), PdfConverter.Convert(to));
 }
Exemplo n.º 12
0
 public void DrawEllipse(PenEx pen, RectangleF rect)
 {
 }
Exemplo n.º 13
0
 void IDrawingCanvas.DrawLines(PenEx pen, PointF[] polyLine)
 {
     _graphics.DrawLines((Pen)pen, polyLine.Select(p => PdfConverter.Convert(p)).ToArray());
 }
Exemplo n.º 14
0
 void IDrawingCanvas.DrawPolygon(PenEx pen, PointF[] points)
 {
     _graphics.DrawPolygon((Pen)pen, points.Select(p => PdfConverter.Convert(p)).ToArray());
 }
Exemplo n.º 15
0
 void IDrawingCanvas.DrawEllipse(PenEx pen, RectangleF rect)
 {
     _graphics.DrawEllipse((Pen)pen, PdfConverter.Convert(rect));
 }
Exemplo n.º 16
0
 public void DrawPolygon(PenEx pen, PointF[] polygon)
 {
 }
		/// <summary>コピーコンストラクタ。</summary>
		/// <param name="previous"></param>
		public LayerRenderSettingData(LayerRenderSettingData previous)
			{
			Visible = previous.Visible;
			Border = new PenEx( previous.Border );
			Fill = new HatchBrushEx( previous.Fill );
			}
Exemplo n.º 18
0
 public void DrawLines(PenEx pen, PointF[] polyLine)
 {
 }
Exemplo n.º 19
0
        /// <summary>
        /// Draws the appointments of a specified week.
        /// </summary>
        private void RenderAppointments(MonthInfo month, IEnumerable <DayInfo> days, SizeF dayCellSize)
        {
            const float ImagePadding = 0.02f;

            for (int week = 0; week < CalendarData.WeeksInMonth; week++)
            {
                DateTime weekStartDate = month.GetDateOfDay(week, CalendarData.FirstDayOfWeek, CalendarData.FirstDayOfWeek);
                DateTime weekEndDate   = month.GetDateOfDay(week, CalendarData.LastDayOfWeek, CalendarData.FirstDayOfWeek, true);

                CalendarData.AppointmentLayoutHelper layoutHelper = new CalendarData.AppointmentLayoutHelper(CalendarData.FirstDayOfWeek, CalendarData.AppointmentGap);
                foreach (Appointment appointment in CalendarData.GetAppointmentsInWeek(month, week))
                {
                    int apptWeekDaysCount = appointment.GetDurationInPeriod(weekStartDate, weekEndDate);
                    Debug.Assert(apptWeekDaysCount > 0, "The appointment should belong to the rendering week.");

                    DateTime appStartDate    = appointment.ArrangeStartDate(weekStartDate);
                    DayInfo  appStartDayInfo = DayInfo.FindDayInfo(days, appStartDate);
                    Debug.Assert(appStartDayInfo != null, "Day have to be found in the collection.");

                    SizeF      appSize   = CalendarData.MeasureAppointment(appointment, weekStartDate, weekEndDate, dayCellSize);
                    float      appOffset = layoutHelper.Add(appStartDate, appStartDate.AddDays(apptWeekDaysCount - 1), appSize.Height);
                    RectangleF appointmentRect;
                    if (!_rightToLeft)
                    {
                        appointmentRect = new RectangleF(
                            appStartDayInfo.Bounds.X,
                            appStartDayInfo.Bounds.Y + appStartDayInfo.HeaderSize.Height + appOffset,
                            apptWeekDaysCount * dayCellSize.Width,
                            appSize.Height);
                    }
                    else
                    {
                        appointmentRect = new RectangleF(
                            appStartDayInfo.Bounds.X - ((apptWeekDaysCount - 1) * dayCellSize.Width),
                            appStartDayInfo.Bounds.Y + appStartDayInfo.HeaderSize.Height + appOffset,
                            apptWeekDaysCount * dayCellSize.Width,
                            appSize.Height);
                    }

                    AddActionToInteractivityMap(appointment, appointmentRect);

                    using (BrushEx backcolorBrush = Canvas.CreateSolidBrush(appointment.Backcolor))
                    {
                        Canvas.FillRectangle(backcolorBrush, appointmentRect);
                    }
                    // draw image!
                    Image      img         = CalendarData.GetAppointmentImage(appointment);
                    RectangleF appTextRect = new RectangleF(appointmentRect.X, appointmentRect.Y, appointmentRect.Width, appointmentRect.Height);
                    bool       drawImage   = appointment.StartDate >= weekStartDate && appointment.StartDate <= weekEndDate;
                    if (img != null && drawImage)
                    {
                        var imageStream = new MemoryStream();
                        img.Save(imageStream, ImageFormat.Png);
                        imageStream.Position = 0;
                        using (ImageEx image = Canvas.CreateImage(new ImageInfo(imageStream, "image/png")))
                        {
                            float imgHeight = Math.Min(CalendarData.GetAppointmentImageSize(appointment), appointmentRect.Width);
                            float imgWidth  = imgHeight;
                            float imgLeft;
                            if (!_rightToLeft)
                            {
                                imgLeft = appointmentRect.X;
                            }
                            else
                            {
                                imgLeft = appointmentRect.Right - imgWidth;
                            }
                            float imgTop = appointmentRect.Y + ImagePadding;
                            //Fix for case 44294
                            Canvas.PushState();
                            Canvas.IntersectClip(new RectangleF(imgLeft, imgTop, imgWidth, imgHeight));
                            SizeF imgSz = CalendarData.GetAppointmentImageRealSize(appointment);
                            Canvas.DrawImage(image, imgLeft, imgTop, imgSz.Width, imgSz.Height);
                            Canvas.PopState();
                            if (imgHeight == appointmentRect.Width)
                            {
                                appTextRect.Y      += imgHeight;
                                appTextRect.Height -= imgHeight;
                            }
                            else
                            {
                                if (!_rightToLeft)
                                {
                                    appTextRect.X = appointmentRect.X + imgWidth;
                                }
                                appTextRect.Width = appointmentRect.Width - imgWidth;
                            }
                        }
                    }
                    // HACK: we should consider the issue with drawing string later. the issue comes about in the designer when caledar has small width to fit titles. --SergeyP
                    using (StringFormat sf = Components.Calendar.CalendarData.GetAppointmentFormat(appointment, _rightToLeft))
                    {
                        TextStyle fontStyle = new TextStyle(appointment.FontFamily, appointment.FontSize,
                                                            appointment.FontStyle, appointment.FontWeight, appointment.FontDecoration,
                                                            appointment.FontColor);
                        Canvas.PushState();
                        var font = fontStyle.CreateFontInfo();
                        using (BrushEx forecolorBrush = Canvas.CreateSolidBrush(fontStyle.FontColor))
                        {
                            string value = CalendarData.FormatString(appointment.Value, appointment.Format);
                            Canvas.DrawString(value, font, forecolorBrush, appTextRect, ToEx(sf));
                        }
                        Canvas.PopState();
                    }
                    LineStyle borderStyle = new LineStyle(appointment.BorderColor);
                    using (PenEx pen = LineStyle.CreatePen(Canvas, borderStyle))
                    {
                        pen.Width = 1;                         // HACK: temporary hack because the width is turned off for appointments
                        DrawRectangle(Canvas, pen,
                                      appointmentRect.X, appointmentRect.Y, appointmentRect.Width, appointmentRect.Height);
                    }

                    RenderAction(appointment, Canvas, appointmentRect);
                }
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Draws the days.
        /// </summary>
        /// <param name="days">a sorted list of days to draw</param>
        private void RenderDays(IEnumerable <DayInfo> days)
        {
            foreach (DayInfo day in days)
            {
                RectangleF dayRect = day.Bounds;

                var headerBorderPath = new PathEx();
                var borderPath       = new PathEx();
                {
                    // create day-box area
                    borderPath.AddLines(
                        new PointF[]
                    {
                        new PointF(dayRect.X, dayRect.Y),
                        new PointF(dayRect.X + dayRect.Width, dayRect.Y),
                        new PointF(dayRect.X + dayRect.Width, dayRect.Y + dayRect.Height),
                        new PointF(dayRect.X, dayRect.Y + dayRect.Height),
                    });
                    borderPath.CloseAllFigures();

                    //Fix for case 44962
                    headerBorderPath.AddLines(
                        new PointF[]
                    {
                        new PointF(dayRect.X, dayRect.Y),
                        new PointF(dayRect.X + dayRect.Width, dayRect.Y),
                        new PointF(dayRect.X + dayRect.Width, dayRect.Y + day.HeaderSize.Height),
                        new PointF(dayRect.X, dayRect.Y + day.HeaderSize.Height),
                    });
                    headerBorderPath.CloseAllFigures();

                    // fill day-box area
                    using (BrushEx brush = Canvas.CreateSolidBrush(CalendarData.GetDayBackcolor(day.DayKind)))
                    {
                        Canvas.DrawAndFillPath(null, brush, borderPath);
                        Canvas.DrawAndFillPath(null, brush, headerBorderPath);
                    }
                    // draw the day label
                    TextStyle fontStyle = CalendarData.GetDayFontStyle(day.DayKind);
                    var       font      = fontStyle.CreateFontInfo();
                    using (BrushEx brush = Canvas.CreateSolidBrush(fontStyle.FontColor))
                    {
                        float      borderWidth  = CalendarData.GetDayBorderStyle(day.DayKind).LineWidth.ToTwips() / 2;
                        RectangleF dayLabelRect = new RectangleF(
                            dayRect.X + borderWidth, dayRect.Top + borderWidth,
                            day.Bounds.Width - 2 * borderWidth, day.HeaderSize.Height - 2 * borderWidth);

                        // HACK: we should consider the issue with drawing string later. the issue comes about in the designer when caledar has small width to fit titles. --SergeyP
                        Canvas.PushState();
                        Canvas.DrawString(day.Label, font, brush, dayLabelRect, ToEx(CalendarData.GetDayStringFormat(day.DayKind)));
                        Canvas.PopState();
                    }
                    // draw borders
                    using (PenEx pen = LineStyle.CreatePen(Canvas, CalendarData.GetDayBorderStyle(day.DayKind)))
                    {
                        Canvas.DrawAndFillPath(pen, null, borderPath);
                        Canvas.DrawAndFillPath(pen, null, headerBorderPath);
                    }
                }
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Draws the week day names.
        /// </summary>
        private void DrawWeekDays(ref float topOffset)
        {
            // calc the rect of the week day names row
            SizeF      weekDaysRowSize = CalendarData.GetDaysOfWeekRowSize(MonthAreaSize);
            RectangleF weekDaysRowRect = new RectangleF(
                CalendarArea.X, CalendarArea.Y + topOffset,
                weekDaysRowSize.Width, weekDaysRowSize.Height);

            SizeF dayCellSize = CalendarData.GetDayCellSize(weekDaysRowSize);

            using (BrushEx brush = Canvas.CreateSolidBrush(CalendarData.DayHeadersBackcolor))
                Canvas.FillRectangle(brush, weekDaysRowRect);

            // draw the week days how they represented in month
            var font = CalendarData.DayHeadersFontStyle.CreateFontInfo();

            using (BrushEx brush = Canvas.CreateSolidBrush(CalendarData.DayHeadersFontStyle.FontColor))
                using (PenEx pen = LineStyle.CreatePen(Canvas, CalendarData.DayHeadersBorderStyle))
                {
                    for (int i = 0; i < CalendarData.DaysInWeek; i++)
                    {
                        RectangleF dayCellRect;
                        if (!_rightToLeft)
                        {
                            dayCellRect = new RectangleF(
                                weekDaysRowRect.X + (i * dayCellSize.Width),
                                weekDaysRowRect.Y,
                                dayCellSize.Width,
                                dayCellSize.Height);
                        }
                        else
                        {
                            dayCellRect = new RectangleF(
                                (weekDaysRowRect.X + weekDaysRowRect.Width) - ((i + 1) * dayCellSize.Width),
                                weekDaysRowRect.Y,
                                dayCellSize.Width,
                                dayCellSize.Height);
                        }
                        var borderPath = new PathEx();
                        {
                            // create day-box area
                            borderPath.AddLines(
                                new PointF[]
                            {
                                new PointF(dayCellRect.X, dayCellRect.Y),
                                new PointF(dayCellRect.X + dayCellRect.Width, dayCellRect.Y),
                                new PointF(dayCellRect.X + dayCellRect.Width, dayCellRect.Y + dayCellRect.Height),
                                new PointF(dayCellRect.X, dayCellRect.Y + dayCellRect.Height),
                            });
                            borderPath.CloseAllFigures();

                            // the day name to draw
                            string weekDayName = CalendarData.Culture.DateTimeFormat.GetDayName(CalendarData.WeekDays[i]);
                            // HACK: we should consider the issue with drawing string later. the issue comes about in the designer when caledar has small width to fit titles. --SergeyP
                            {
                                Canvas.PushState();
                                Canvas.DrawString(weekDayName, font, brush, dayCellRect, ToEx(CalendarData.DayHeadersFormat));
                                Canvas.PopState();
                            }
                            Canvas.DrawAndFillPath(pen, null, borderPath);
                            //RenderUtils.DrawRectangle(Canvas, pen, dayCellRect.X, dayCellRect.Y, dayCellRect.Width, dayCellRect.Height);
                        }
                    }
                }

            // set offset
            topOffset += weekDaysRowSize.Height;
        }
Exemplo n.º 22
0
 public void DrawAndFillPath(PenEx pen, BrushEx brush, PathEx path)
 {
 }
Exemplo n.º 23
0
 public void DrawRectangle(PenEx pen, RectangleF rect)
 {
 }
Exemplo n.º 24
0
 public void DrawLine(PenEx pen, PointF @from, PointF to)
 {
 }
Exemplo n.º 25
0
 /// <summary>コピーコンストラクタ。</summary>
 /// <param name="previous"></param>
 public LayerRenderSettingData(LayerRenderSettingData previous)
 {
     Visible = previous.Visible;
     Border  = new PenEx(previous.Border);
     Fill    = new HatchBrushEx(previous.Fill);
 }