public void ForceFieldTransform(ReportField field)
        {
            if (field == null)
            {
                throw new ArgumentNullException(nameof(field));
            }

            if (FieldType != ReportFieldType.Value)
            {
                field.Transform = ReportFieldTransform.None;
            }
            else if (field.Transform == ReportFieldTransform.None)
            {
                var dataType = (field.Fields.Tail as EntityTypedField)?.DataType;

                switch (dataType.GetValueOrDefault(EntityDataType.String))
                {
                case EntityDataType.Decimal:
                case EntityDataType.Long:
                case EntityDataType.Int:
                    field.Transform = ReportFieldTransform.Sum;
                    break;

                default:
                    field.Transform = ReportFieldTransform.Count;
                    break;
                }
            }
        }
        protected override void OnDragLeave(EventArgs e)
        {
            base.OnDragLeave(e);

            if (_draggingField != null)
            {
                Items.Remove(_draggingField);
                _draggingField.Transform = _draggingOldTransform;
                _draggingField           = null;
            }
        }
        private void SetDraggingField(ReportField field)
        {
            if (_draggingField != null)
            {
                Items.Remove(_draggingField);
            }

            if (_draggingField == field)
            {
                return;
            }

            _draggingField        = field;
            _draggingOldTransform = _draggingField.Transform;

            ForceFieldTransform(_draggingField);
        }
Пример #4
0
        private void ShowFieldMenu(ReportFieldListBox sender, ReportField reportField)
        {
            _moveToColumnLabelsMenuItem.Enabled = sender.FieldType != ReportFieldType.Column;
            _moveToRowLabelsMenuItem.Enabled    = sender.FieldType != ReportFieldType.Row;
            _moveToValuesMenuItem.Enabled       = sender.FieldType != ReportFieldType.Value;
            _aggregateMenuItem.Enabled          = sender.FieldType == ReportFieldType.Value;

            int index = sender.Items.IndexOf(reportField);

            _moveUpMenuItem.Enabled          = index > 0;
            _moveToBeginningMenuItem.Enabled = index > 0;
            _moveDownMenuItem.Enabled        = index < sender.Items.Count - 1;
            _moveToEndMenuItem.Enabled       = index < sender.Items.Count - 1;

            foreach (ToolStripMenuItem menuItem in _aggregateMenuItem.DropDownItems)
            {
                menuItem.Checked = (ReportFieldTransform)menuItem.Tag == reportField.Transform;
            }

            var bounds = sender.GetItemRectangle(index);

            _selectedField = new SelectedField(sender, reportField);
            _fieldContextMenu.Show(sender, bounds.Left, bounds.Bottom + 1);
        }
        protected override void OnDragDrop(DragEventArgs e)
        {
            base.OnDragDrop(e);

            _draggingField = null;
        }
Пример #6
0
 public SelectedField(ReportFieldListBox listBox, ReportField field)
 {
     ListBox = listBox;
     Field   = field;
 }