Beispiel #1
0
/// <summary>
/// Calculate group value from incoming data value
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        private void Grid_CustomGroupInterval(object sender, PivotCustomGroupIntervalEventArgs e)
        {
            PivotGridFieldContext fc = GetPivotGridFieldContext(e.Field);
            PivotGridFieldMx      f  = fc.F;
            AggregationDef        ad = f.Aggregation;

            if (e.Field.Area != PivotArea.ColumnArea && e.Field.Area != PivotArea.RowArea)
            {
                return;                 // not sure why this is happening but ignore if so
            }
            if (!ad.IsGroupingType)     // must check this since when moving a field to a grouping area in the PivotGridDialog, this event fires before the FieldAreaChanged event (true?)
            {
                return;                 // throw new Exception("Expected Group Role");
            }
            AggregationTypeDetail td = ad.TypeDetail;

            if (td.GroupingMethod == null)
            {
                return;
            }

            QueryColumn qc = fc.Qc;
            object      vo = e.Value;        // value to apply group function to

            object groupValue = td.GroupingMethod(qc, ad, vo);

            e.GroupValue = groupValue;
        }
Beispiel #2
0
        /// <summary>
        /// Summary type selected
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void AggregationTypeMenuItem_Click(object sender, EventArgs e)
        {
            PivotGridFieldMx f = PivotGridField;

            DXMenuItem mi       = sender as DXMenuItem;
            string     typeName = mi.Tag.ToString();         // tag is enum member name

            AggregationTypeDetail atd = AggregationTypeDetail.GetByTypeName(typeName, true);

            if (atd.IsGroupingType && atd.GroupingType == GroupingTypeEnum.NumericInterval)
            {
                DialogResult dr = NumericIntervalDialog.ShowDialog(f.Aggregation, UIMisc.MousePosition);
                //if (dr == DialogResult.Cancel) return;
            }

            f.Aggregation.SetFromTypeName(typeName);
            f.SyncDxAreaToMxRole();             // sync Dx area
            PivotGrid.RefreshData();

            if (UpdateViewWhenGridControlChanges)
            {
                View.UpdateViewFieldsFromGridFields();
            }

            return;
        }
Beispiel #3
0
/// <summary>
/// SetFieldGridDataRow
/// </summary>
/// <param name="dr"></param>
/// <param name="f"></param>

        void SetFieldGridDataRow(DataRow dr, PivotGridFieldMx f)
        {
            string label, txt;

            ResultsField  rfld = f.ResultsField as ResultsField;
            ResultsTable  rt   = rfld.ResultsTable;
            ResultsFormat rf   = rt.ResultsFormat;
            MetaColumn    mc   = rfld.MetaColumn;
            QueryColumn   qc   = rfld.QueryColumn;
            QueryTable    qt   = qc.QueryTable;
            Query         q    = qt.Query;

            dr["ColTypeImageCol"] = QueryTableControl.GetMetaColumnDataTypeImage(mc);
            dr["PivotFieldCol"]   = f;           // store reference to pivot field
            dr["FieldNameCol"]    = f.Caption;

            dr["AggRoleCol"] = f.Aggregation.RoleLabel;

            dr["AggTypeCol"] = f.Aggregation.TypeLabel;

            //			txt = GroupingTypeLabel(f);
            //			dr["HeaderBinningCol"] = txt;

            dr["SourceColumnCol"] = PivotGridControlMx.BuildFieldCaption(f);

            label = qt.ActiveLabel;
            if (rf.Tables.Count > 1)
            {
                label = "T" + (rt.Position + 1) + " - " + label;
            }
            dr["SourceTableCol"] = label;

            return;
        }
Beispiel #4
0
        public static string BuildFieldCaption(
            PivotGridFieldMx f)
        {
            ResultsField rfld = f.ResultsField as ResultsField;

            if (rfld == null)
            {
                return("Unknown");
            }
            QueryColumn    qc = rfld.QueryColumn;
            ResultsTable   rt = rfld.ResultsTable;
            ResultsFormat  rf = rt.ResultsFormat;
            AggregationDef ad = f.Aggregation;

            string caption = qc.GetActiveLabel(includeAggregationType: false);

            if (rf.Tables.Count > 1)
            {
                caption = "T" + (rt.Position + 1) + "." + caption;
            }

            if (f.Role == AggregationRole.DataSummary)
            {
                if (!ad.IsGroupingType)
                {
                    caption += " " + ad.TypeLabel;
                }
            }

            f.Caption = caption;

            return(caption);
        }
Beispiel #5
0
/// <summary>
/// Set field caption
/// </summary>
/// <param name="f"></param>

        public static void SetFieldCaption(
            PivotGridFieldMx f)
        {
            string caption = BuildFieldCaption(f);

            f.Caption = caption;
        }
Beispiel #6
0
/// <summary>
/// Set default summary type
/// </summary>
/// <param name="f"></param>

        internal static void SetDefaultFieldSummaryType(
            PivotGridFieldMx f)
        {
            ResultsField rfld = f.ResultsField as ResultsField;

            if (rfld == null)
            {
                return;
            }
            MetaColumn mc = rfld.MetaColumn;

            if (mc.IsNumeric)
            {
                f.SummaryTypeMx = SummaryTypeEnum.ArithmeticMean;
            }

            else if (mc.DataType == MetaColumnType.Date)
            {
                f.SummaryTypeMx = SummaryTypeEnum.Count;
            }

            else
            {
                f.SummaryTypeMx = SummaryTypeEnum.Count;
            }
        }
Beispiel #7
0
        /// <summary>
        /// Duplicate an existing field
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void DuplicatePivotField_Click(object sender, EventArgs e)
        {
            int[] rows = FieldGridView.GetSelectedRows();
            if (rows.Length == 0)
            {
                return;
            }

            PivotGrid.BeginUpdate();
            object ds = PivotGrid.DataSource;

            PivotGrid.DataSource = null;

            PivotGridFieldMx f = PivotGrid.Fields[rows[0]] as PivotGridFieldMx;

            if (f == null)
            {
                return;
            }

            PivotGridFieldMx f2 = new PivotGridFieldMx();

            f.CopyField(f2);
            PivotGrid.Fields.Add(f2);

            PivotGrid.DataSource = ds;
            PivotGrid.EndUpdate();

            FillFieldDetailsGrid();
            return;
        }
Beispiel #8
0
/// <summary>
/// Show the panel
/// </summary>
/// <param name="f"></param>
/// <param name="location"></param>

        public void Show(
            PivotGridFieldMx f,
            Point location,
            PivotGridDialog dialog)
        {
            string txt;

            Field     = f;
            FieldCopy = new PivotGridFieldMx();
            f.CopyField(FieldCopy);
            PgDlg = dialog;

            Control c = NoInterval;

            IntervalBinCount.Text          =
                FixedIntervalSize.Text     =
                    VariableIntervals.Text = "";

            //if (f.GroupIntervalMx == GroupBinType.FixedIntervalCount)
            //{
            //	//FixedIntervalCountOption.Checked = true;
            //	//txt = f.GroupIntervalCount.ToString();
            //	//if (f.GroupIntervalCount <= 0) txt = "3";
            //	//IntervalBinCount.Text = txt;
            //	//c = IntervalBinCount;
            //}

            //else if (f.GroupIntervalMx == GroupBinType.FixedIntervalSize)
            //{
            //	//FixedIntervalSizeOption.Checked = true;

            //	//txt = f.GroupIntervalSize.ToString();
            //	//if (f.GroupIntervalCount <= 0) txt = "100";
            //	//FixedIntervalSize.Text = txt;
            //	//c = FixedIntervalSize;
            //}

            //else if (f.GroupIntervalMx == GroupBinType.VariableIntervals)
            //{
            //	//VariableIntervalsOption.Checked = true;
            //	//VariableIntervals.Text = f.GroupVariableIntervals;
            //	//c = VariableIntervals;
            //}

            //else
            //{
            //	NoInterval.Checked = true;
            //	c = NoInterval;
            //}

            Location = location;
            Show();
            c.Focus();
            return;
        }
Beispiel #9
0
/// <summary>
/// GetPivotGridFieldContext
/// </summary>
/// <param name="f"></param>
/// <returns>PivotGridFieldContext</returns>

        public static PivotGridFieldContext GetPivotGridFieldContext(
            PivotGridFieldBase fb,
            bool throwException = false)
        {
            AggregationDef a;

            PivotGridFieldContext fc = new PivotGridFieldContext();

            PivotGridFieldMx f = fb as PivotGridFieldMx;

            if (f == null)
            {
                if (throwException)
                {
                    throw new Exception("PivotGridFieldMx is null");
                }
                else
                {
                    return(null);
                }
            }

            fc.F            = f;
            fc.ResultsField = f.ResultsField as ResultsField;
            if (fc.ResultsField == null)
            {
                if (throwException)
                {
                    throw new Exception("ResultsField is null");
                }
                else
                {
                    return(null);
                }
            }

            fc.Qc = fc.ResultsField.QueryColumn;
            fc.Mc = fc.Qc.MetaColumn;

            fc.Q  = fc.Qc.QueryTable.Query;
            fc.Qm = fc.Q.QueryManager as QueryManager;
            if (fc.Qm != null)
            {
                fc.Qe = fc.Qm.QueryEngine;
            }

            a = fc.Aggregation = f.Aggregation;
            if (a != null && a.Role != PivotGridFieldMx.DxAreaToMxRole(f))             // be sure Mx role is in synch with Dx FieldArea which may change before FieldAreaChanged event fires
            {
                a.Role = PivotGridFieldMx.DxAreaToMxRole(f);
                a.SetDefaultTypeIfUndefined(fc.Mc);                 // also set type if not defined yet
            }

            return(fc);
        }
Beispiel #10
0
        /// <summary>
/// User has changed the value of a cell
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        private void FieldGridView_CellValueChanged(object sender, CellValueChangedEventArgs e)
        {
            int ri = e.RowHandle;

            if (ri < 0)
            {
                return;
            }

            GridColumn gc = e.Column;

            if (gc == null)
            {
                return;
            }
            int gci = gc.AbsoluteIndex;

            PivotGridFieldMx f    = PivotGrid.Fields[ri] as PivotGridFieldMx;
            ResultsField     rfld = f.ResultsField as ResultsField;

            Mobius.Data.QueryColumn qc = rfld.QueryColumn;
            MetaColumn mc = qc.MetaColumn;

            if (gc.FieldName == "FieldNameCol")
            {
                f.Caption = e.Value.ToString();
            }

            else if (gc.FieldName == "AggRoleCol")
            {
                return;                 // handled in CellValueChanging
            }

            else if (gc.FieldName == "AggTypeCol")
            {
                return;
            }

            //else if (gc.FieldName == "HeaderBinningCol")
            //{
            //	return;
            //}

            else if (gc.FieldName == "SourceColumnCol" || gc.FieldName == "SourceTableCol")
            {
                return;
            }

            else
            {
                return;              // something else
            }
        }
Beispiel #11
0
/// <summary>
/// Configure the binding for a pivot grid field
/// </summary>
/// <param name="field"></param>

        internal void ConfigurePivotGridControlField(PivotGridFieldMx field)
        {
            ResultsField rfld = field.ResultsField as ResultsField;
            MetaColumn   mc   = rfld.MetaColumn;

            if (mc.DataType == MetaColumnType.CompoundId)
            {
                if (mc.IsNumeric)
                {
                    field.UnboundType = UnboundColumnType.Integer;
                }
                else
                {
                    field.UnboundType = field.UnboundType = UnboundColumnType.String;
                }
            }

            else if (mc.DataType == MetaColumnType.Integer)
            {
                field.UnboundType = UnboundColumnType.Integer;
            }

            else if (mc.IsNumeric)
            {
                field.UnboundType = UnboundColumnType.Decimal;
            }

            else if (mc.DataType == MetaColumnType.Date)
            {
                field.UnboundType = UnboundColumnType.DateTime;
            }

            else
            {
                field.UnboundType = UnboundColumnType.String;
            }

            if (mc.IsKey)
            {
                field.ImageIndex = (int)Bitmaps16x16Enum.Key;
            }
            else
            {
                field.ImageIndex = (int)mc.DataTypeImageIndex;
            }

            field.Options.AllowRunTimeSummaryChange = true;
            field.Options.ShowUnboundExpressionMenu = true;

//				field.SummaryTypeChanged += new System.EventHandler(PivotGridPanel.PivotGridField_SummaryTypeChanged);
        }
Beispiel #12
0
        //void SetMeasureUnits(params DateTimeMeasureUnit[] units)
        //{
        //	object prevUnit = String.IsNullOrEmpty(ChartDataMeasureUnit.SelectedItem.ToString()) ? null : Enum.Parse(typeof(DateTimeMeasureUnit), ChartDataMeasureUnit.SelectedItem.ToString());
        //	string prevItem = "";
        //	ChartDataMeasureUnit.Properties.Items.Clear();
        //	foreach (DateTimeMeasureUnit unit in units)
        //	{
        //		string unitName = Enum.GetName(typeof(DateTimeMeasureUnit), unit);
        //		ChartDataMeasureUnit.Properties.Items.Add(unitName);
        //		if (prevUnit != null && object.Equals(unit, (DateTimeMeasureUnit)prevUnit))
        //			prevItem = unitName;
        //	}
        //	if (!String.IsNullOrEmpty(prevItem))
        //		ChartDataMeasureUnit.SelectedItem = prevItem;
        //	else
        //		ChartDataMeasureUnit.SelectedIndex = 0;
        //}


        //private void cbChartDataMeasureUnit_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //	XYDiagram diagram = null; // (XYDiagram)Chart.Diagram;
        //	DateTimeMeasureUnit unit = (DateTimeMeasureUnit)Enum.Parse(typeof(DateTimeMeasureUnit), ChartDataMeasureUnit.SelectedItem.ToString());
        //	diagram.AxisX.DateTimeScaleOptions.GridAlignment = (DateTimeGridAlignment)unit;
        //	diagram.AxisX.DateTimeScaleOptions.MeasureUnit = unit;
        //	switch (unit)
        //	{
        //		case DateTimeMeasureUnit.Year:
        //			diagram.AxisX.Label.TextPattern = "{A:yyyy}";
        //			break;
        //		case DateTimeMeasureUnit.Quarter:
        //			diagram.AxisX.Label.TextPattern = "{A:yyyy}"; // todo: fix
        //			//diagram.AxisX.Label.DateTimeOptions.Format = DateTimeFormat.QuarterAndYear;
        //			break;
        //		case DateTimeMeasureUnit.Month:
        //			diagram.AxisX.Label.TextPattern = "{A:yyyy}"; // todo: fix
        //			//diagram.AxisX.DateTimeOptions.Format = DateTimeFormat.MonthAndYear;
        //			break;
        //		default:
        //			break;
        //	}
        //}

/// <summary>
/// Field grid cell clicked
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        private void FieldGrid_MouseClick(object sender, MouseEventArgs e)
        {
            GridHitInfo hi = FieldGridView.CalcHitInfo(e.Location);
            int         ri = hi.RowHandle;

            if (ri < 0)
            {
                return;
            }

            PivotGridFieldMx f    = Field = PivotGrid.Fields[ri] as PivotGridFieldMx;
            ResultsField     rfld = f.ResultsField as ResultsField;
            AggregationDef   agg  = f.Aggregation;

            Mobius.Data.QueryColumn qc = rfld.QueryColumn;
            MetaColumn mc = qc.MetaColumn;

            GridColumn gc = hi.Column;

            if (gc == null)
            {
                return;
            }

            FieldGridRow    = hi.RowHandle;
            FieldGridColumn = gc.AbsoluteIndex;

            GridViewInfo viewInfo = (GridViewInfo)FieldGridView.GetViewInfo();
            GridCellInfo cellInfo = viewInfo.GetGridCellInfo(hi);
            Point        menuLoc  = new Point(cellInfo.Bounds.Left, cellInfo.Bounds.Bottom);

            menuLoc = FieldGrid.PointToScreen(menuLoc);

            if (gc.FieldName == "AggRoleCol")             // show appropriate aggregation type menu
            {
                AggregationDefMenus.ShowRoleMenu(qc, f.Aggregation, menuLoc, AggregationRoleChanged);
                return;
            }


            else if (gc.FieldName == "AggTypeCol")             // show appropriate aggregation type menu
            {
                AggregationDefMenus.ShowTypeMenu(qc, f.Aggregation, menuLoc, AggregationTypeChanged);
                return;
            }

            else if (gc.FieldName == "SourceColumnCol" || gc.FieldName == "SourceTableCol")
            {
                return;
            }
        }
Beispiel #13
0
        private void ChangeRole(AggregationRole role)
        {
            PivotGridFieldMx f    = PivotGridField;
            ResultsField     rfld = f.ResultsField as ResultsField;
            MetaColumn       mc   = rfld.MetaColumn;

            f.Aggregation.Role = role;                   // set the role for Mobius
            f.Aggregation.SetDefaultTypeIfUndefined(mc); // and default type if needed
            f.SyncDxAreaToMxRole();                      // sync Dx Area

            if (UpdateViewWhenGridControlChanges)
            {
                View.UpdateViewFieldsFromGridFields();
            }

            return;
        }
Beispiel #14
0
        /// <summary>
        /// The area that a field is located in has changed.
        ///  If changed by the DX UI then the added members in PivotGridFieldMx must be updated
        ///  If changed by Mobius code (InSetup = true) then nothing needed here.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void Grid_FieldAreaChanged(object sender, PivotFieldEventArgs e)
        {
            if (InSetup)
            {
                return;
            }

            try
            {
                InSetup = true;
                PivotGridFieldContext fc = GetPivotGridFieldContext(e.Field);
                if (fc == null)
                {
                    return;
                }

                PivotGridFieldMx f = fc.F;

                f.SyncMxRoleToDxArea();

                ResultsField rfld = fc.ResultsField;
                if (rfld == null || rfld.MetaColumn == null)
                {
                    return;
                }

                f.Aggregation.SetDefaultTypeIfUndefined(rfld.MetaColumn);                 // may need to set default type as well

                PivotGridControlMx.SetFieldCaption(f);

                PivotGrid.RefreshData();                 // recalc summaries

                if (UpdateViewWhenGridControlChanges)
                {
                    View.UpdateViewFieldsFromGridFields();
                }

                return;
            }

            finally
            {
                InSetup = false;
            }
        }
Beispiel #15
0
/// <summary>
/// Key Mobius classes related to and/or extending the DX classes
/// </summary>

        void PivotGridControlMx()
        {
            PivotGridControlMx pgcMx = new PivotGridControlMx();             // Mx method extensions of the DX PivotGridControl


            PivotGridFieldMx pgfMx = pgcMx.Fields[0] as PivotGridFieldMx; // Mx extensions of the DX PivotGridField
            {
                AggregationDef ad = pgfMx.Aggregation;                    // Grouping and summarization for Mx field
                {
                    AggregationRole  ar  = ad.Role;                       // Role of field in agg/pivot (similar to DX Area)
                    SummaryTypeEnum  st  = ad.SummaryType;                // Type of Mx summary
                    GroupingTypeEnum gt  = ad.GroupingType;               // Type of Mx grouping
                    Decimal          nis = ad.NumericIntervalSize;        // interval size for numeric grouping
                }

                ResultsField rfld = pgfMx.ResultsField as ResultsField;                 // Mobius ResultsField, QueryColumn and MetaColumn associated with field
            }
        }
Beispiel #16
0
/// <summary>
///  Get the attributes for the area that a field is currently in
/// </summary>
/// <param name="e"></param>
/// <param name="area"></param>
/// <param name="areaName"></param>
/// <param name="areaImage"></param>

        void GetFieldAreaAttributes(
            PopupMenuShowingEventArgs e,
            out PivotArea area,
            out string areaName,
            out Image areaImage)
        {
            area      = (PivotArea)(-1);
            areaName  = "";
            areaImage = null;

            PivotGridFieldMx f = e.Field as PivotGridFieldMx;

            if (f == null)
            {
                return;
            }

            area     = f.Area;
            areaName = f.Area.ToString();
            if (f.AreaIndex < 0 || f.Visible == false)
            {
                area     = (PivotArea)(-1);
                areaName = "None";
            }

            if (area == PivotArea.ColumnArea)
            {
                areaImage = Bitmaps16x16.Images[0];
            }
            else if (area == PivotArea.RowArea)
            {
                areaImage = Bitmaps16x16.Images[1];
            }
            else if (area == PivotArea.DataArea)
            {
                areaImage = Bitmaps16x16.Images[2];
            }
            else if (area == PivotArea.FilterArea)
            {
                areaImage = Bitmaps16x16.Images[3];
            }

            return;
        }
Beispiel #17
0
/// <summary>
/// Add a new pivot grid field
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        private void AddPivotField_Click(object sender, EventArgs e)
        {
            QueryManager qm = PivotView.Qm;
            Query        q  = qm.Query;

            FieldSelectorControl.Query      = q;
            FieldSelectorControl.MetaColumn = null;
            Point p = AddPivotField.PointToScreen(new Point(0, AddPivotField.Height));

            Mobius.Data.QueryColumn qc = FieldSelectorControl.ShowMenu(p);
            if (qc == null)
            {
                return;
            }

            PivotGridPropertiesMx pp = PivotView.PivotGridPropertiesMx;

            ResultsField rfld = qm.ResultsFormat.GetResultsField(qc);

            if (rfld == null)
            {
                return;
            }

            PivotGridFieldMx field =             // add new field (must add to base view)
                                     PivotGridView.AddField(rfld, pp.PivotFields, null, GroupingTypeEnum.EqualValues);

            PivotGridFieldMx field2 = new PivotGridFieldMx();

            field.CopyField(field2);
            pp.PivotFields.Remove(field);             // remove from base view

            PivotGrid.BeginUpdate();
            object ds = PivotGrid.DataSource;

            PivotGrid.DataSource = null;
            PivotGrid.Fields.Add(field2);             // add to pivot grid
            PivotView.ConfigurePivotGridControlField(field2);
            PivotGrid.DataSource = ds;
            PivotGrid.EndUpdate();

            FillFieldDetailsGrid();
            return;
        }
Beispiel #18
0
        /// <summary>
        /// Copy the grid control fields to the view
        /// </summary>
        /// <param name="p"></param>

        public void UpdateViewFieldsFromGridFields()
        {
            if (PivotGridPropertiesMx == null)
            {
                PivotGridPropertiesMx = new PivotGridPropertiesMx();
            }

            PivotGridPropertiesMx p = PivotGridPropertiesMx;

            p.PivotFields = new List <PivotGridFieldMx>();
            foreach (PivotGridFieldMx f in PivotGridCtl.Fields)
            {
                PivotGridFieldMx f2 = new PivotGridFieldMx();
                f.CopyField(f2);
                p.PivotFields.Add(f2);
            }

            return;
        }
Beispiel #19
0
/// <summary>
/// Build the Grid fields for the PivotGridControl from the persisted Mobius view fields
/// </summary>

        void BuildGridFieldsFromViewFields()
        {
            PivotGridFieldMx gf, gf2;

            PivotGridCtl.Fields.Clear();
            PivotGridCtl.Groups.Clear();

            PivotGridPropertiesMx p = PivotGridPropertiesMx;

            for (int fi = 0; fi < p.PivotFields.Count; fi++)             // build grid fields from view fields
            {
                PivotGridFieldMx pf   = p.PivotFields[fi];
                ResultsField     rfld = pf.ResultsField as ResultsField;
                if (rfld == null)
                {
                    continue;
                }
                PivotGridControlMx.SetFieldCaption(pf);                 // be sure we have a caption

                Mobius.Data.QueryColumn qc = rfld.QueryColumn;
                MetaColumn mc = rfld.MetaColumn;

                gf = new PivotGridFieldMx();
                pf.CopyField(gf);
                pf.SyncDxAreaToMxRole();

                if (mc.IsKey)
                {
                    gf.ImageIndex = (int)Bitmaps16x16Enum.Key;
                }
                else
                {
                    gf.ImageIndex = (int)mc.DataTypeImageIndex;
                }

                gf.Options.AllowRunTimeSummaryChange = true;
                gf.Options.ShowUnboundExpressionMenu = true;

                PivotGridCtl.Fields.Add(gf);
            }

            return;
        }
Beispiel #20
0
        /// <summary>
        /// Add a new field associated with specified ResultsField
        /// </summary>
        /// <param name="rfld"></param>
        /// <param name="Fields"></param>
        /// <param name="area"></param>
        /// <param name="visible"></param>
        /// <param name="pgi"></param>
        /// <returns></returns>

        internal static PivotGridFieldMx AddField(
            ResultsField rfld,
            List <PivotGridFieldMx> Fields,
            PivotArea area,
            bool visible,
            PivotGridGroup group,
            GroupingTypeEnum pgi)
        {
            QueryColumn qc = rfld.QueryColumn;
            MetaColumn  mc = qc.MetaColumn;
            QueryTable  qt = qc.QueryTable;

            PivotGridFieldMx f = new PivotGridFieldMx();

            if (mc.IsKey)
            {
                f.ImageIndex = (int)Bitmaps16x16Enum.Key;
            }
            else
            {
                f.ImageIndex = (int)mc.DataTypeImageIndex;
            }

            f.UnboundFieldName = qt.Alias + "." + mc.Name +       // identify by tableAlias.mcName (allows multiple instances of same metatable in query)
                                 "." + (UnboundFieldNameCount++); // and make unique in case used in multiple PivotGroupIntervals (needed?)

            f.ResultsField             = rfld;                    // store associated results field
            f.SummaryTypeMx            = SummaryTypeEnum.Count;
            f.Area                     = area;
            f.Visible                  = visible; // if not visible then put in list of unused fields
            f.Aggregation.GroupingType = pgi;

            PivotGridControlMx.SetFieldCaption(f);

            Fields.Add(f);

            if (group != null)
            {
                group.Add(f);                            // add to group
            }
            return(f);
        }
Beispiel #21
0
        /// <summary>
        /// Show the panel
        /// </summary>
        /// <param name="f"></param>
        /// <param name="location"></param>

        public void Show(
            PivotGridFieldMx f,
            Point location,
            PivotGridDialog dialog)
        {
            string txt;

#if false
            Field     = f;
            FieldCopy = new PivotGridFieldMx();
            f.CopyField(FieldCopy);
            PgDlg = dialog;

            Control c;
            IntervalBinCount.Text          =
                FixedIntervalSize.Text     =
                    VariableIntervals.Text = "";

            if (f.GroupIntervalMx == PivotGroupIntervalMx.FixedIntervalCount)
            {
                FixedIntervalCountOption.Checked = true;
                txt = f.GroupIntervalCount.ToString();
                if (f.GroupIntervalCount <= 0)
                {
                    txt = "3";
                }
                IntervalBinCount.Text = txt;
                c = IntervalBinCount;
            }

            else if (f.GroupIntervalMx == PivotGroupIntervalMx.FixedIntervalSize)
            {
                FixedIntervalSizeOption.Checked = true;

                txt = f.GroupIntervalSize.ToString();
                if (f.GroupIntervalCount <= 0)
                {
                    txt = "100";
                }
                FixedIntervalSize.Text = txt;
                c = FixedIntervalSize;
            }

            else if (f.GroupIntervalMx == PivotGroupIntervalMx.VariableIntervals)
            {
                VariableIntervalsOption.Checked = true;
                VariableIntervals.Text          = f.GroupVariableIntervals;
                c = VariableIntervals;
            }

            else
            {
                NoInterval.Checked = true;
                c = NoInterval;
            }

            Location = location;
            Show();
            c.Focus();
            return;
#endif
        }
Beispiel #22
0
        /// <summary>
        /// BuildFieldPopupMenu
        /// </summary>
        /// <param name="e"></param>

        void BuildFieldPopupMenu(
            PopupMenuShowingEventArgs e)
        {
            PivotArea     area      = (PivotArea)(-1);
            string        areaName  = "";
            Image         areaImage = null;
            DXSubMenuItem smi;

            PivotGridFieldContext f = GetPivotGridFieldContext(e.Field);

            if (f == null)
            {
                return;
            }
            PivotGridField = f.F;             // save as current field

            ResultsField rfld = f.ResultsField;
            QueryColumn  qc   = f.Qc;

            GetFieldAreaAttributes(e, out area, out areaName, out areaImage);

            DXPopupMenu dxpMenu = e.Menu;             // clear dest menu

            dxpMenu.Items.Clear();

            AggregationDefMenus ats = new AggregationDefMenus();             // used to build menus

            // Build DataArea summary type items

            if (area == PivotArea.DataArea)
            {
                ContextMenuStrip modelMenu = ats.SetupAggregationTypeMenu(qc, f.Aggregation, null, includeGroupingItems: false, includeSummaryItems: true);
                ConvertAndAppendContextMenuStripToDxPopupMenu(modelMenu, dxpMenu);
            }

            // Build ColumnArea or RowArea Grouping items

            if (area == PivotArea.ColumnArea || area == PivotArea.RowArea)
            {
                ContextMenuStrip modelMenu = ats.SetupAggregationTypeMenu(qc, f.Aggregation, null, includeGroupingItems: true, includeSummaryItems: false);
                ConvertAndAppendContextMenuStripToDxPopupMenu(modelMenu, dxpMenu);
            }

            if (dxpMenu.Items.Count == 0)             // just add to menu if nothing there so far
            {
                smi = dxpMenu;
            }

            else             // add to submenu
            {
                smi            = new DXSubMenuItem("Move Field to");
                smi.BeginGroup = true;
                dxpMenu.Items.Add(smi);
            }

            smi.Items.Add(new DXMenuCheckItem("Column Area", area == PivotArea.ColumnArea, Bitmaps16x16.Images[0], ColumnAreaMenuItem_Click));
            smi.Items.Add(new DXMenuCheckItem("Row Area", area == PivotArea.RowArea, Bitmaps16x16.Images[1], RowAreaMenuItem_Click));
            smi.Items.Add(new DXMenuCheckItem("Data Area", area == PivotArea.DataArea, Bitmaps16x16.Images[2], DataAreaMenuItem_Click));
            smi.Items.Add(new DXMenuCheckItem("Filter Area", area == PivotArea.FilterArea, Bitmaps16x16.Images[3], FilterAreaMenuItem_Click));
            smi.Items.Add(new DXMenuCheckItem("None", area == (PivotArea)(-1), null, UnassignedAreaMenuItem_Click));

            return;
        }
Beispiel #23
0
        /// <summary>
        /// Changed summary type
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        internal void PivotGridField_SummaryTypeChanged(object sender, EventArgs e)
        {
            PivotGridFieldMx f = sender as PivotGridFieldMx;

            return;
        }
Beispiel #24
0
        /// <summary>
        /// Value tentatively changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void FieldGridView_CellValueChanging(object sender, CellValueChangedEventArgs e)
        {
            int ri = e.RowHandle;

            if (ri < 0)
            {
                return;
            }
            DataRow dr = FieldGridDataTable.Rows[ri];

            GridColumn gc = e.Column;

            if (gc == null)
            {
                return;
            }
            int gci = gc.AbsoluteIndex;

            PivotGridFieldMx f    = PivotGrid.Fields[ri] as PivotGridFieldMx;
            ResultsField     rfld = f.ResultsField as ResultsField;

            Mobius.Data.QueryColumn qc = rfld.QueryColumn;
            MetaColumn mc = qc.MetaColumn;

            if (gc.FieldName == "FieldNameCol")
            {
                return;                 // wait til move out of cell
            }

            else if (gc.FieldName == "AggRoleCol")
            {
                //e=e;
                //object o = e.Value;
                //DataRow dr2 = FieldGridDataTable.Rows[e.RowHandle];
                //object vo = dr2["AggRoleCol"];
                //FieldGridDataTable

                f.SyncDxAreaToMxRole();                 // sync Dx area
                PivotGrid.RefreshData();                // refresh the PivotGrid to show new agg type results

                //dr["AggRoleCol"] = f.Aggregation.TypeLabel;
                return;                 // throw new NotImplementedException();

                //string txt = e.Value.ToString();
                //if (Lex.IsNullOrEmpty(txt) || Lex.Eq(txt, "None"))
                //{
                //	f.Visible = false;

                //	dr["SummaryTypeCol"] = "";
                //	//dr["HeaderBinningCol"] = "";
                //}
                //else
                //{
                //	f.Area = (PivotArea)Enum.Parse(typeof(PivotArea), txt);
                //	f.Visible = true;

                //	dr["SummaryTypeCol"] = SummaryTypeLabel(f);
                //	//dr["HeaderBinningCol"] = GroupingTypeLabel(f);
                //}

                //PivotGrid.SetFilterHeaderVisibility();
            }

            else if (gc.FieldName == "AggTypeCol")
            {
                return;
            }

            //else if (gc.FieldName == "HeaderBinningCol")
            //{
            //	return;
            //}

            else if (gc.FieldName == "SourceColumnCol" || gc.FieldName == "SourceTableCol")
            {
                return;
            }

            else
            {
                return;              // something else
            }
        }
Beispiel #25
0
        /// <summary>
        /// Synchronize the Mobius pivot view field list with the source query fields
        /// </summary>
        /// <param name="query"></param>
        /// <param name="fieldsMx">The persisted PivotGridProperties.PivotFields for the Mobius view</param>

        public static void SyncMxFieldListWithSourceQuery(
            Query query,
            ref List <PivotGridFieldMx> fieldsMx)
        {
            PivotGridFieldMx f = null;
            int fi;

            Query        q  = query;
            QueryManager qm = q.QueryManager as QueryManager;

            if (qm == null)
            {
                return;
            }

            if (fieldsMx == null)
            {
                fieldsMx = new List <PivotGridFieldMx>();
            }
            foreach (PivotGridFieldMx f0 in fieldsMx)
            {
                f0.ResultsField = null;
            }

            // Add any fields in the source that aren't in the list

            foreach (ResultsTable rt in qm.ResultsFormat.Tables)
            {
                QueryTable qt = rt.QueryTable;
                MetaTable  mt = qt.MetaTable;

                foreach (ResultsField rfld in rt.Fields)
                {
                    Mobius.Data.QueryColumn qc = rfld.QueryColumn;
                    MetaColumn mc = qc.MetaColumn;

                    string ufn = qt.Alias + "." + mc.Name + ".";                     // unbound name without unique id suffix
                    if (mc.Name == "ACTIVITY_CLASS")
                    {
                        mc = mc;                                                     // debug
                    }
                    List <PivotGridFieldMx> matches = new List <PivotGridFieldMx>(); // list of pivot grid fields that match fields in the incoming results set
                    foreach (PivotGridFieldMx f0 in fieldsMx)
                    {                                                                // see if have already
                        if (Lex.StartsWith(f0.UnboundFieldName, ufn))
                        {
                            f0.ResultsField = rfld;                             // store associated results field
                            matches.Add(f0);
                        }
                    }

                    if (matches.Count > 0)
                    {
                        continue;
                    }

                    f = AddField(rfld, fieldsMx, null, GroupingTypeEnum.EqualValues);
                }
            }

            // Remove any fields in the list not in the source

            fi = 0;
            while (fi < fieldsMx.Count)
            {
                f = fieldsMx[fi];
                if (f.ResultsField == null)
                {
                    fieldsMx.Remove(f);                                         // if no resultsField then not seen in source query
                }
                else
                {
                    fi++;
                }
            }

            //if (Ctl.Groups.Count > 0) // debug
            //{
            //  g = Ctl.Groups[0];
            //  PivotGroupFields flds = (PivotGroupFields)g.Fields;
            //  int fCnt = flds.Count;
            //}

            return;
        }