Example #1
0
        public override void Draw(GraphicsCache cache, Font font, Color foreColor, StringFormat format)
        {
            if (IsBreak)
            {
                return;
            }
            if (LabelInfoHelper.IsActionElement(this.InfoText.Text))
            {
                DrawButton(cache);
                return;
            }
            if (LabelInfoHelper.EditorItem(this))
            {
                DrawTestEditor(cache, this.InfoText.Text);
                return;
            }
            Font         activeFont = IsActive ? new Font(font, font.Style | FontStyle.Underline) : null;
            StringFormat sformat    = format == null?CreateStringFormat() : format;

            for (int i = 0; i < Count; i++)
            {
                Rectangle bounds = this[i].Bounds;
                bounds.Y = bounds.Y - ScrollTop;
                cache.DrawString(this[i].Text, IsActive ? activeFont : font, cache.GetSolidBrush(foreColor), bounds, sformat);
            }
            if (format == null)
            {
                sformat.Dispose();
            }
            if (activeFont != null)
            {
                activeFont.Dispose();
            }
        }
Example #2
0
        protected override void Draw(OverlayWindowCustomDrawContext context)
        {
            //The Handled event parameter should be set to true.
            //to disable the default drawing algorithm.
            context.Handled = true;
            //Provides access to the drawing surface.
            GraphicsCache cache = context.DrawArgs.Cache;

            //Adjust the TextRenderingHint option
            //to improve the image quality.
            cache.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            //Overlapped control bounds.
            Rectangle bounds = context.DrawArgs.Bounds;

            //Draws the default background.
            context.DrawBackground();
            //Specify the string that will be drawn on the Overlay Form instead of the wait indicator.
            //string drawString = "You must have webMAN installed to use this feature.";
            //Get the system's black brush.
            Brush drawBrush = Brushes.Gainsboro;
            //Calculate the size of the message string.
            SizeF textSize = cache.CalcTextSize(messageString, drawFont);
            //A point that specifies the upper-left corner of the rectangle where the string will be drawn.
            PointF drawPoint = new(bounds.Left + (bounds.Width / 2) - (textSize.Width / 2),
                                   bounds.Top + (bounds.Height / 2) - (textSize.Height / 2));

            //Draw the string on the screen.
            cache.DrawString(messageString, drawFont, drawBrush, drawPoint);
        }
Example #3
0
        void DrawLink(CustomDrawCellEventArgs e, GraphicsCache cache, string text)
        {
            e.DrawDefault();
            e.Handled = true;
            var        brush      = cache.GetSolidBrush(Color.FromArgb(5, 111, 206));
            var        font       = cache.GetFont(e.Font, FontStyle.Underline);
            SizeF      size       = cache.CalcTextSize(text, font, StringFormat.GenericDefault, 0);
            float      height     = (float)e.Bounds.Height - size.Height;
            RectangleF textBounds = new RectangleF(e.Bounds.Left + 8, e.Bounds.Top + height / 2, size.Width + 4, size.Height);

            cache.DrawString(text, font, brush, Rectangle.Round(textBounds), StringFormat.GenericDefault);
        }
Example #4
0
        void CustomDrawAppointmentFlyoutSubject(Appointment appointment, AppointmentBandDrawerViewInfoBase viewInfo)
        {
            GraphicsCache cache        = viewInfo.Cache;
            StringFormat  stringFormat = new StringFormat(viewInfo.View.Appearance.GetStringFormat());

            stringFormat.Alignment = stringFormat.LineAlignment = StringAlignment.Center;
            try {
                // Draw status
                Rectangle statusRect = GetStatusBounds(viewInfo);
                cache.FillRectangle(viewInfo.View.Status.GetBrush(), statusRect);

                if (viewInfo.View.Status.Type == AppointmentStatusType.Free)
                {
                    // Draw a warning
                    cache.DrawImage(GetWarningIcon(new Size(statusRect.Height, statusRect.Height)), statusRect.Location);
                    cache.DrawString("Status is unacceptable", fontStorage.StatusFont, Brushes.Red, statusRect, stringFormat);
                }
                // Draw subject
                cache.DrawString(appointment.Subject, fontStorage.SubjectFont, Brushes.Black, GetSubjectBounds(viewInfo), stringFormat);
            }
            finally {
                stringFormat.Dispose();
            }
        }
        protected override void DrawCore(OverlayWindowCustomDrawContext context)
        {
            GraphicsCache     cache = context.DrawArgs.Cache;
            TextRenderingHint prev  = cache.TextRenderingHint;

            cache.TextRenderingHint = TextRenderingHint.AntiAlias;
            try
            {
                cache.DrawString(Text, font, cache.GetSolidBrush(Color), textPos);
            }
            finally
            {
                cache.TextRenderingHint = prev;
            }
        }
Example #6
0
        protected override void DrawText(GraphicsCache cache)
        {
            string text = Text;

            if (text == null || text.Length == 0 || TextBounds.IsEmpty)
            {
                return;
            }
            AppearanceObject appearance = new AppearanceObject(GetDefaultAppearance());

            appearance.Font = Owner.Font;
            appearance.TextOptions.Trimming = Trimming.EllipsisCharacter;
            Rectangle r = RectangleHelper.GetCenterBounds(TextBounds, new Size(TextBounds.Width, appearance.CalcDefaultTextSize(cache.Graphics).Height));

            DrawTextShadow(cache, appearance, r);
            cache.DrawString(text, appearance.Font, appearance.GetForeBrush(cache), r, appearance.GetStringFormat());
        }
Example #7
0
        protected void DrawClear(bool isHot, AppearanceObject app, GraphicsCache cache, Rectangle rect)
        {
            if (rect.IsEmpty)
            {
                return;
            }
            Brush br = app.GetForeBrush(cache);

            if (isHot)
            {
                SkinElementInfo skin = new SkinElementInfo(CommonSkins.GetSkin(DevExpress.LookAndFeel.UserLookAndFeel.Default.ActiveLookAndFeel)[CommonSkins.SkinHighlightedItem], rect);
                br = new SolidBrush(DevExpress.LookAndFeel.LookAndFeelHelper.GetSystemColor(
                                        DevExpress.LookAndFeel.UserLookAndFeel.Default.ActiveLookAndFeel,
                                        SystemColors.HotTrack));
                ObjectPainter.DrawObject(cache, SkinElementPainter.Default, skin);
            }
            StringFormat format = new StringFormat();

            format.Alignment = StringAlignment.Center;
            cache.DrawString("Clear", app.Font, br, rect, format);
        }
Example #8
0
        public static void DrawWeekDayContent(StoreDay storeday, EmployeeDay epd, GraphicsCache cache, Rectangle rect, IRecordingContext context)
        {
            Font cellfont = _cellFont;
            Rectangle cellBound = Rectangle.Inflate(rect, -1, -1);
            Brush cellbrush = Brushes.Black ;
            StringFormat sformat = null;
            if (epd.HasLongAbsence)
            {
                string s = context.LongAbsences.GetAbbreviation(epd.LongAbsenceId);
                if (String.IsNullOrEmpty(s)) return;
                sformat = new StringFormat ();
                sformat.Alignment = StringAlignment.Center;
                sformat.LineAlignment = StringAlignment.Center;
                cache.DrawString(s, cellfont, cellbrush, cellBound, sformat);
            }
            else
            {
                List<string> lstValues = new List<string>();

                List<EmployeeTimeRange> lst = epd.TimeList;

                if (lst != null && lst.Count > 0)
                {
                    sformat = new StringFormat(StringFormatFlags.MeasureTrailingSpaces |
                                            StringFormatFlags.NoWrap);
                    //sformat.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces |
                    //                        StringFormatFlags.NoWrap;

                    //cellbrush = Brushes.Black ;
                    Brush absenceBrush = null;
                    string str = String.Empty;
                    int heightCell = (int)(cellBound.Height);// / 2);
                    foreach (EmployeeTimeRange range in lst)
                    {
                        str = range.ToString();//TextParser.EmployeeTimeToString(range);

                        Size sf = cache.CalcTextSize(str, cellfont, sformat, 10000).ToSize ();

                        if (range.Absence == null)
                        {
                            cache.DrawString(str, cellfont, cellbrush, cellBound, sformat);
                        }
                        else
                        {
                            absenceBrush = cache.GetSolidBrush(Color.FromArgb(range.Absence.Color));
                            cache.DrawString(str, cellfont, absenceBrush, cellBound, sformat);

                        }

                        cellBound.Y += sf.Height + 2;
                        heightCell -= (sf.Height + 2);
                        if ((heightCell < 0)) break;//  - (sf.Height + 2)) < 0) break;
                        //if ((cellBound.Y + sf.Height) > (rect.Y + rect.Width)) break;
                    }

                }
            }
        }
Example #9
0
        public static void DrawWeekDayContent(StoreDay storeday, EmployeeDay epd, GraphicsCache cache, Rectangle rect, IRecordingContext context)
        {
            Font         cellfont  = _cellFont;
            Rectangle    cellBound = Rectangle.Inflate(rect, -1, -1);
            Brush        cellbrush = Brushes.Black;
            StringFormat sformat   = null;

            if (epd.HasLongAbsence)
            {
                string s = context.LongAbsences.GetAbbreviation(epd.LongAbsenceId);
                if (String.IsNullOrEmpty(s))
                {
                    return;
                }
                sformat               = new StringFormat();
                sformat.Alignment     = StringAlignment.Center;
                sformat.LineAlignment = StringAlignment.Center;
                cache.DrawString(s, cellfont, cellbrush, cellBound, sformat);
            }
            else
            {
                List <string> lstValues = new List <string>();

                List <EmployeeTimeRange> lst = epd.TimeList;

                if (lst != null && lst.Count > 0)
                {
                    sformat = new StringFormat(StringFormatFlags.MeasureTrailingSpaces |
                                               StringFormatFlags.NoWrap);
                    //sformat.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces |
                    //                        StringFormatFlags.NoWrap;

                    //cellbrush = Brushes.Black ;
                    Brush  absenceBrush = null;
                    string str          = String.Empty;
                    int    heightCell   = (int)(cellBound.Height);// / 2);
                    foreach (EmployeeTimeRange range in lst)
                    {
                        str = range.ToString();//TextParser.EmployeeTimeToString(range);

                        Size sf = cache.CalcTextSize(str, cellfont, sformat, 10000).ToSize();

                        if (range.Absence == null)
                        {
                            cache.DrawString(str, cellfont, cellbrush, cellBound, sformat);
                        }
                        else
                        {
                            absenceBrush = cache.GetSolidBrush(Color.FromArgb(range.Absence.Color));
                            cache.DrawString(str, cellfont, absenceBrush, cellBound, sformat);
                        }

                        cellBound.Y += sf.Height + 2;
                        heightCell  -= (sf.Height + 2);
                        if ((heightCell < 0))
                        {
                            break;                  //  - (sf.Height + 2)) < 0) break;
                        }
                        //if ((cellBound.Y + sf.Height) > (rect.Y + rect.Width)) break;
                    }
                }
            }
        }