private void dtStartdate_DrawItem(object sender, DevExpress.XtraEditors.Calendar.CustomDrawDayNumberCellEventArgs e)
        {
            MWDataManager.clsDataAccess _dbManCalType = new MWDataManager.clsDataAccess();
            _dbManCalType.ConnectionString = TConnections.GetConnectionString(resWPAS.systemDBTag, UserCurrentInfo.Connection);
            _dbManCalType.SqlStatement     = "select TOP 35 * from caltype where calendarcode='" + TheCalendarCode + "' and CalendarDate >= '" + String.Format("{0:yyyy-MM-dd}", dtStartdate.EditValue) + "' and workingday='Y'";

            _dbManCalType.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
            _dbManCalType.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _dbManCalType.ExecuteInstruction();


            dt = _dbManCalType.ResultsDataTable;
            foreach (DataRow dr in dt.Rows)
            {
                string abc = "";
                abc = String.Format("{0:yyyy-MM-dd}", e.Date);
                DateTime ABC = Convert.ToDateTime(abc);

                string bc = "";
                bc = String.Format("{0:yyyy-MM-dd}", dr["CalendarDate"]);
                DateTime BC = Convert.ToDateTime(bc);
                if (ABC.Date.Day == BC.Date.Day)
                {
                    e.Style.BackColor = Color.LightGray;
                }
            }
        }
예제 #2
0
 void OnCustomDrawDayNumberCell(object sender, DevExpress.XtraEditors.Calendar.CustomDrawDayNumberCellEventArgs e)
 {
     if (IsExistingDate(e.Date))
     {
         e.Style.ForeColor = Color.BlueViolet;
     }
 }
 private void DateNavigator_CustomDrawDayNumberCell(object sender, DevExpress.XtraEditors.Calendar.CustomDrawDayNumberCellEventArgs e)
 {
     try
     {
         if (_AvailableTimeIntervals != null && selectedExternalEntity is IEntityWithDuration durationEnt)
         {
             TimeInterval timeInt = _AvailableTimeIntervals.FirstOrDefault(d => d.Start.Date == e.Date && d.Duration >= TimeSpan.FromHours(durationEnt.Duration));
             if (timeInt != null)
             {
                 RectangleF rect = new RectangleF(e.Bounds.Location, e.Bounds.Size);
                 e.Style.ForeColor = (Color)PluginSettings[TEXT_COLOUR];
                 Color backColor = (Color)(PluginSettings[FRAME_COLOUR]);
                 rect.Inflate(-2, -2);
                 e.Graphics.DrawRectangles(new Pen(backColor)
                 {
                     Width = 3
                 }, new[] { rect });
                 e.Graphics.DrawString(e.Date.Day.ToString(), new Font(e.Style.Font, FontStyle.Bold), new SolidBrush(e.Style.ForeColor), rect, e.Style.GetStringFormat());
                 e.Handled = true;
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private void dnMain_CustomDrawDayNumberCell(object sender, DevExpress.XtraEditors.Calendar.CustomDrawDayNumberCellEventArgs e)
        {
            AppointmentBaseCollection appList = ssWorkingDays.GetAppointments(e.Date, e.Date.AddHours(0.7));
            Rectangle rec = new Rectangle(e.Bounds.Location, e.Bounds.Size);

            System.Drawing.Pen myPen;


            if (appList.Count == 1)
            {
                switch (appList[0].LabelId)
                {
                case NonWorking:
                    System.Drawing.SolidBrush nwBrush = new System.Drawing.SolidBrush(colNonWorking);
                    e.Graphics.FillRectangle(nwBrush, rec);
                    break;

                case Working:

                    System.Drawing.SolidBrush wBrush = new System.Drawing.SolidBrush(colWorking);


                    e.Graphics.FillRectangle(wBrush, rec);
                    break;
                }
            }
        }
예제 #5
0
파일: Form1.cs 프로젝트: esafb52/ClassSRM
        //Draw Persian Holiday to Calendar
        private void pCalendar_CustomDrawDayNumberCell(object sender, DevExpress.XtraEditors.Calendar.CustomDrawDayNumberCellEventArgs e)
        {
            if (e.View != DevExpress.XtraEditors.Controls.DateEditCalendarViewType.MonthInfo)
            {
                return;
            }
            //return if a given date is not a holiday
            //in this case the default drawing will be performed (e.Handled is false)
            if (!Config.IsHoliday(e.Date))
            {
                return;
            }
            //highlight the selected date
            if (e.Selected)
            {
                e.Graphics.FillRectangle(e.Style.GetBackBrush(e.Cache), e.Bounds);
            }
            //the brush for painting days
            Brush brush = (e.Inactive ? Brushes.LightPink : Brushes.OrangeRed);
            //specify formatting attributes for drawing text
            StringFormat strFormat = new StringFormat();

            strFormat.Alignment     = StringAlignment.Center;
            strFormat.LineAlignment = StringAlignment.Center;
            //draw the day number

            DateTime dt  = e.Date;
            var      day = Config.PersianDate(dt).Substring(8, 2);

            e.Graphics.DrawString(day, e.Style.Font, brush, e.Bounds, strFormat);
            e.Handled = true;
        }
예제 #6
0
        private void dateNavigator1_CustomDrawDayNumberCell(object sender, DevExpress.XtraEditors.Calendar.CustomDrawDayNumberCellEventArgs e)
        {
            if (e.Date == ConvertHelper.ToDateTime("2020-04-16", DateTime.MinValue))
            {
                e.Graphics.FillRectangle(Brushes.Red, e.Bounds);

                e.Graphics.DrawString(e.Date.Day.ToString(), e.Style.Font, Brushes.White, e.Bounds);

                e.Handled = true;
            }
        }
예제 #7
0
 private void calendarControl1_CustomDrawDayNumberCell(object sender,
                                                       DevExpress.XtraEditors.Calendar.CustomDrawDayNumberCellEventArgs e)
 {
     if (e.Date.DayOfYear % 12 == 0)
     {
         Pen       p = e.Cache.GetPen(Color.Violet);
         Rectangle r = e.Bounds;
         r.Inflate(-2, 0);
         r.Offset(3, 0);
         e.Cache.DrawRectangle(p, r);
     }
 }
예제 #8
0
 private void MainDateNavigator_CustomDrawDayNumberCell(object sender, DevExpress.XtraEditors.Calendar.CustomDrawDayNumberCellEventArgs e)
 {
 }
예제 #9
0
        private void dateNavigatorAperture_CustomDrawDayNumberCell(object sender, DevExpress.XtraEditors.Calendar.CustomDrawDayNumberCellEventArgs e)
        {
            if (_Postazione == null)
            {
                e.Handled = false;
            }
            else
            {
                // Q343046

                var painter       = sender as DevExpress.XtraScheduler.Drawing.DateNavigatorPainter;
                var selectedDates = painter.Calendar.Selection;

                if (_Aperture.Contiene(_Postazione.Oid, e.Date))
                {
                    //if (e.BackgroundElementInfo == null)
                    //    e.Cache.FillRectangle(e.Cache.GetSolidBrush(LookAndFeelHelper.GetSystemColor(LookAndFeel, SystemColors.Highlight)), e.Bounds);
                    //else
                    //    ObjectPainter.DrawObject(e.Cache, SkinElementPainter.Default, e.BackgroundElementInfo);

                    if (selectedDates.Contains(e.Date))
                    {
                        Color fillColor = Color.FromArgb(60, Color.DarkSeaGreen.R, Color.DarkSeaGreen.G, Color.DarkSeaGreen.B);
                        Brush fillBrush = new SolidBrush(fillColor);

                        Pen rectPen = new Pen(new SolidBrush(Color.DarkSeaGreen), 1);

                        e.Graphics.FillRectangle(fillBrush, e.Bounds);
                        e.Graphics.DrawRectangle(rectPen, e.Bounds);
                    }
                    else
                    {
                        Color fillColor = Color.FromArgb(60, Color.Goldenrod.R, Color.Goldenrod.G, Color.Goldenrod.B);
                        Brush fillBrush = new SolidBrush(fillColor);

                        Pen rectPen = new Pen(new SolidBrush(Color.Goldenrod), 1);

                        e.Graphics.FillRectangle(fillBrush, e.Bounds);
                        e.Graphics.DrawRectangle(rectPen, e.Bounds);
                    }

                    //specify formatting attributes for drawing text
                    var strFormat = new StringFormat();
                    strFormat.Alignment     = StringAlignment.Center;
                    strFormat.LineAlignment = StringAlignment.Far;

                    //draw the day number
                    var fontBold = new Font(e.Style.Font, FontStyle.Bold);
                    if (e.Date.DayOfWeek == DayOfWeek.Sunday || e.Date.DayOfWeek == DayOfWeek.Saturday)
                    {
                        e.Graphics.DrawString(e.Date.Day.ToString(), fontBold, Brushes.Red, e.Bounds, strFormat);
                    }
                    else
                    {
                        e.Graphics.DrawString(e.Date.Day.ToString(), fontBold, Brushes.Black, e.Bounds, strFormat);
                    }

                    //no default drawing is required
                    e.Handled = true;
                }
                else if (selectedDates.Contains(e.Date))
                {
                    Color fillColor = Color.FromArgb(60, Color.PaleGreen.R, Color.PaleGreen.G, Color.PaleGreen.B);
                    Brush fillBrush = new SolidBrush(fillColor);

                    Pen rectPen = new Pen(new SolidBrush(Color.PaleGreen), 1);

                    e.Graphics.FillRectangle(fillBrush, e.Bounds);
                    e.Graphics.DrawRectangle(rectPen, e.Bounds);

                    //Pen p = e.Cache.GetPen(Color.Violet);

                    //if (e.BackgroundElementInfo == null)
                    //    e.Cache.FillRectangle(e.Cache.GetSolidBrush(LookAndFeelHelper.GetSystemColor(LookAndFeel, SystemColors.Highlight)), e.Bounds);
                    //else
                    //    ObjectPainter.DrawObject(e.Cache, SkinElementPainter.Default, e.BackgroundElementInfo);

                    //Pen violet = e.Cache.GetPen(Color.Violet);
                    //e.Graphics.DrawRectangle(violet, e.Bounds);

                    //specify formatting attributes for drawing text
                    var strFormat = new StringFormat();
                    strFormat.Alignment     = StringAlignment.Center;
                    strFormat.LineAlignment = StringAlignment.Far;

                    //draw the day number
                    var fontBold = new Font(e.Style.Font, FontStyle.Bold);
                    if (e.Date.DayOfWeek == DayOfWeek.Sunday || e.Date.DayOfWeek == DayOfWeek.Saturday)
                    {
                        e.Graphics.DrawString(e.Date.Day.ToString(), fontBold, Brushes.Red, e.Bounds, strFormat);
                    }
                    else
                    {
                        e.Graphics.DrawString(e.Date.Day.ToString(), fontBold, Brushes.Black, e.Bounds, strFormat);
                    }

                    e.Handled = true;
                }
                else
                {
                    e.Handled = false;
                }


                //if (_Aperture.Contiene(_Ingresso, e.Date))
                //{
                //    Pen p = e.Cache.GetPen(Color.Violet);
                //    Rectangle r = e.Bounds;
                //    r.Inflate(-2, 0);
                //    r.Offset(3, 0);
                //    e.Cache.DrawRectangle(p, r);
                //}
            }
        }
예제 #10
0
        private void DateNavigator_CustomDrawDayNumberCell(object sender, DevExpress.XtraEditors.Calendar.CustomDrawDayNumberCellEventArgs e)
        {
            //draw a rectangle around the date where a match is found
            if (selectedExternalEntity is IEntityWithLocation entityWithLocation)
            {
                var visibleResources = schedulerDataStorage.Resources.Items.Where(r => r.Visible == true);
                var ApptList         = schedulerDataStorage.Appointments.Items.Where(a => (a.CustomFields["ENTITY"] is IEntityWithLocation apptEntity) &&
                                                                                     apptEntity.Location != null &&
                                                                                     apptEntity.LocationCode != null &&
                                                                                     visibleResources.FirstOrDefault(res => $"{res.Id}" == $"{a.ResourceId}" &&
                                                                                                                     a.Start.Date == e.Date) != null);

                if (ApptList.Count() > 0)
                {
                    int   lvl1Cut  = (int)PluginSettings[LEVEL1_MATCH_LENGTH];
                    Color lvl1Col  = (Color)PluginSettings[LEVEL1_MATCH_COLOUR];
                    bool  lvl1Enbl = (bool)PluginSettings[LEVEL1_MATCH_ENABLED];
                    int   lvl2Cut  = (int)PluginSettings[LEVEL2_MATCH_LENGTH];
                    Color lvl2Col  = (Color)PluginSettings[LEVEL2_MATCH_COLOUR];
                    bool  lvl2Enbl = (bool)PluginSettings[LEVEL2_MATCH_ENABLED];
                    int   lvl3Cut  = (int)PluginSettings[LEVEL3_MATCH_LENGTH];
                    Color lvl3Col  = (Color)PluginSettings[LEVEL3_MATCH_COLOUR];
                    bool  lvl3Enbl = (bool)PluginSettings[LEVEL3_MATCH_ENABLED];
                    int   lvl4Cut  = (int)PluginSettings[LEVEL4_MATCH_LENGTH];
                    Color lvl4Col  = (Color)PluginSettings[LEVEL4_MATCH_COLOUR];
                    bool  lvl4Enbl = (bool)PluginSettings[LEVEL4_MATCH_ENABLED];
                    //match on level 1

                    if (entityWithLocation.LocationCode == null || entityWithLocation.LocationCode == string.Empty)
                    {
                        e.Handled = true;
                        return;
                    }

                    if (lvl1Enbl)
                    {
                        if (ApptList.FirstOrDefault(a => (a.CustomFields["ENTITY"] as IEntityWithLocation).LocationCode.StartsWith(entityWithLocation.LocationCode.Substring(0, lvl1Cut))) != null)
                        {
                            RectangleF rect = new RectangleF(e.Bounds.Location, e.Bounds.Size);
                            e.Style.ForeColor = Color.DarkSlateGray;
                            Color backColor = lvl1Col;
                            rect.Inflate(-4, -4);
                            e.Graphics.FillRectangle(new SolidBrush(backColor), rect);
                            e.Graphics.DrawString(e.Date.Day.ToString(), new Font(e.Style.Font, FontStyle.Bold), new SolidBrush(e.Style.ForeColor), rect, e.Style.GetStringFormat());
                            e.Handled = true;
                        }
                    }

                    if (lvl2Enbl)
                    {
                        if (ApptList.FirstOrDefault(a => (a.CustomFields["ENTITY"] as IEntityWithLocation).LocationCode.StartsWith(entityWithLocation.LocationCode.Substring(0, lvl2Cut))) != null)
                        {
                            RectangleF rect = new RectangleF(e.Bounds.Location, e.Bounds.Size);
                            e.Style.ForeColor = Color.DarkSlateGray;
                            Color backColor = lvl2Col;
                            rect.Inflate(-4, -4);
                            e.Graphics.FillRectangle(new SolidBrush(backColor), rect);
                            e.Graphics.DrawString(e.Date.Day.ToString(), new Font(e.Style.Font, FontStyle.Bold), new SolidBrush(e.Style.ForeColor), rect, e.Style.GetStringFormat());
                            e.Handled = true;
                        }
                    }

                    if (lvl3Enbl)
                    {
                        if (ApptList.FirstOrDefault(a => (a.CustomFields["ENTITY"] as IEntityWithLocation).LocationCode.StartsWith(entityWithLocation.LocationCode.Substring(0, lvl3Cut))) != null)
                        {
                            RectangleF rect = new RectangleF(e.Bounds.Location, e.Bounds.Size);
                            e.Style.ForeColor = Color.DarkSlateGray;
                            Color backColor = lvl3Col;
                            rect.Inflate(-4, -4);
                            e.Graphics.FillRectangle(new SolidBrush(backColor), rect);
                            e.Graphics.DrawString(e.Date.Day.ToString(), new Font(e.Style.Font, FontStyle.Bold), new SolidBrush(e.Style.ForeColor), rect, e.Style.GetStringFormat());
                            e.Handled = true;
                        }
                    }
                    if (lvl4Enbl)
                    {
                        if (ApptList.FirstOrDefault(a => (a.CustomFields["ENTITY"] as IEntityWithLocation).LocationCode.StartsWith(entityWithLocation.LocationCode.Substring(0, lvl4Cut))) != null)
                        {
                            RectangleF rect = new RectangleF(e.Bounds.Location, e.Bounds.Size);
                            e.Style.ForeColor = Color.DarkSlateGray;
                            Color backColor = lvl4Col;
                            rect.Inflate(-4, -4);
                            e.Graphics.FillRectangle(new SolidBrush(backColor), rect);
                            e.Graphics.DrawString(e.Date.Day.ToString(), new Font(e.Style.Font, FontStyle.Bold), new SolidBrush(e.Style.ForeColor), rect, e.Style.GetStringFormat());
                            e.Handled = true;
                        }
                    }
                }
            }
        }