Esempio n. 1
0
        private void bandedGridView1_CustomDrawFooter(object sender, DevExpress.XtraGrid.Views.Base.RowObjectCustomDrawEventArgs e)
        {
            int offset = 5;

            e.DefaultDraw();
            Color     color = highPriority;
            Rectangle markRectangle;
            string    priorityText = " - High level";

            for (int i = 0; i < 3; i++)
            {
                if (i == 1)
                {
                    color        = normalPriority;
                    priorityText = " - Normal level";
                }
                else if (i == 2)
                {
                    color        = lowPriority;
                    priorityText = " - Low level";
                }
                markRectangle = new Rectangle(e.Bounds.X + offset, e.Bounds.Y + offset + (markWidth + offset) * i, markWidth, markWidth);
                e.Cache.FillEllipse(markRectangle.X, markRectangle.Y, markRectangle.Width, markRectangle.Height, color);
                e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near;
                e.Appearance.Options.UseTextOptions = true;
                e.Appearance.DrawString(e.Cache, priorityText, new Rectangle(markRectangle.Right + offset, markRectangle.Y, e.Bounds.Width, markRectangle.Height));
            }
        }
        private void gvBOSExternalEntity_CustomDrawRowPreview(object sender, DevExpress.XtraGrid.Views.Base.RowObjectCustomDrawEventArgs e)
        {
            try
            {
                if (e.RowHandle > -1)
                {
                    if (ActiveViewOption != null)
                    {
                        if (sender is GridView view)
                        {
                            if (view.IsRowSelected(e.RowHandle))
                            {
                                return;
                            }


                            //DataTable table1 = TempDataTableCreator.CreateDataTableFromEntity(gvExample.GetRow(e.RowHandle));
                            //to represent the entity as the one on the scheduler, see if it is already an appointment, so check the scheduler
                            DataTable table     = new DataTable();
                            var       recInGrid = view.GetRow(e.RowHandle) as BOSEntity;

                            //look for the appointments with the ext ref as subject, and then extract the entity within the appointment with that reference
                            var appts = schedulerDataStorage.Appointments.Items.FindAll(a => (a.CustomFields["ENTITY"] is BOSEntity bosEnt) && bosEnt.ExtRefId == recInGrid.ExtRefId);
                            if (appts.Any())
                            {
                                Appointment appt = appts.FirstOrDefault(a => a.Start.Date == dateNavigator.SelectionStart.Date);
                                if (appt == null)
                                {
                                    appt = appts.FirstOrDefault();
                                }
                                //recInGrid.PopulateWith((BOSEntity)appt.CustomFields["ENTITY"]);<-- this causes issues
                                table = appt.CustomFields["ENTITY"].ConvertToDataTable();
                            }
                            else //there is no appointment on the scheduler that represents this external entity, so fake send a BosEntity
                            {
                                table = recInGrid.ConvertToDataTable();
                            }

                            ApptLabel label = ActiveViewOption.GetApptLabel(table);
                            if (label != null)
                            {
                                e.Appearance.BackColor = Color.FromArgb(label.ColourRGB);
                                e.Appearance.ForeColor = Color.FromArgb(label.ForeColourRGB);
                                //e.Handled = true;
                            }
                            else
                            {
                                e.DefaultDraw();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
#if DEBUG
                throw ex;
#endif
            }
        }