Ejemplo n.º 1
0
        private SchedulerDragData GetDragData(GridView view)
        {
            int rowHandle = view.FocusedRowHandle;

            if (!view.IsDataRow(rowHandle))
            {
                return(null);
            }

            var         row = view.GetRow(rowHandle) as Deal;
            Appointment apt = storageMain.CreateAppointment(AppointmentType.Normal);

            apt.Subject            = row.Route;
            apt.Start              = row.DateStart.Value;
            apt.End                = row.DateEnd.Value;
            apt.Description        = row.Description;
            apt.CustomFields["Id"] = row.Id;

            AppointmentBaseCollection appointments = new AppointmentBaseCollection();

            appointments.Add(apt);
            var result = new SchedulerDragData(appointments, 0);

            return(result);
        }
Ejemplo n.º 2
0
        private DataRow ObtainDataRowFromSchedulerData(SchedulerDragData schedulerData)
        {
            Appointment apt       = schedulerData.PrimaryAppointment;
            DataTable   dataTable = (DataTable)gridControl1.ItemsSource;
            DataRow     dataRow   = dataTable.NewRow();

            dataRow["Subject"]     = apt.Subject;
            dataRow["Severity"]    = apt.LabelKey;
            dataRow["Priority"]    = apt.StatusKey;
            dataRow["Duration"]    = (int)apt.Duration.TotalMinutes;
            dataRow["Description"] = apt.Description;

            return(dataRow);
        }
        void OnSchedulerControlPrepareDragData(object sender, PrepareDragDataEventArgs e)
        {
            object data = e.DataObject.GetData(DataFormats.Serializable);
            AppointmentBaseCollection appointments = new AppointmentBaseCollection();

            foreach (AppointmentExchangeData item in (IList)data)
            {
                var apt = this.schedulerStorage.CreateAppointment(AppointmentType.Normal);
                apt.Subject     = item.Subject;
                apt.Description = item.Description;
                apt.Start       = item.Start;
                apt.Duration    = item.Duration;
                apt.LabelKey    = item.LabelKey;
                apt.StatusKey   = item.StatusKey;
                appointments.Add(apt);
            }
            SchedulerDragData schedulerDragData = new SchedulerDragData(appointments);

            e.DragData = schedulerDragData;
        }
Ejemplo n.º 4
0
        void tableView1_PreviewDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(SchedulerDragData)))
            {
                SchedulerDragData schedulerData = ((SchedulerDragData)e.Data.GetData(typeof(SchedulerDragData)));
                DataRow           dataRow       = ObtainDataRowFromSchedulerData(schedulerData);
                DataTable         dataTable     = (DataTable)gridControl1.ItemsSource;
                TableViewHitInfo  hitInfo       = tableView1.CalcHitInfo(e.OriginalSource as DependencyObject);
                int rowIndex = dataTable.Rows.Count;

                if (hitInfo.RowHandle != GridControl.InvalidRowHandle)
                {
                    rowIndex = gridControl1.GetListIndexByRowHandle(hitInfo.RowHandle);
                }

                if (this.dragFromGrid)
                {
                    tableView1.DeleteRow(currentRowHandle);
                }

                dataTable.Rows.InsertAt(dataRow, rowIndex);
                schedulerData.PrimaryAppointment.Delete();
            }
        }