Ejemplo n.º 1
0
        /// <summary>
        /// ShowAggregationTypeMenu
        /// </summary>
        /// <param name="qc"></param>
        /// <param name="ad"></param>
        /// <param name="p"></param>
        /// <param name="aggTypeChangedDelegate"></param>

        public static void ShowTypeMenu(
            QueryColumn qc,
            AggregationDef ad,
            Point p,
            AggregationTypeChangedDelegate aggTypeChangedDelegate)
        {
            AggregationDefMenus ats = new AggregationDefMenus();
            //if (qc.Aggregation == null) qc.Aggregation = new AggregationDef();

            int qtCount = -1;

            if (qc.QueryTable != null && qc.QueryTable.Query != null)
            {
                qtCount = qc.QueryTable.Query.Tables.Count;
            }

            bool includeGroupingItems = true;
            bool includeSummaryItems  = true;

            if (qc.IsKey && qtCount > 1)             // if key and more than one table in query then no summarization allowed (only allow grouping on key)
            {
                includeSummaryItems = false;
            }

            ContextMenuStrip menu = ats.SetupAggregationTypeMenu(qc, ad, aggTypeChangedDelegate, includeGroupingItems, includeSummaryItems);

            menu.Show(p);

            return;
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
0
        private void NumericIntervalDialog_OK_Click(object sender, EventArgs e)
        {
            Decimal intervalSize;

            if (!Decimal.TryParse(IntervalSize.Text, out intervalSize) || intervalSize <= 0)
            {
                MessageBoxMx.ShowError("The interval size must be a positive number");
                IntervalSize.Focus();
                return;
            }

// Update the aggregation def

            AggregationDef ad = AggregationDef;

            if (!ad.IsGroupingType)
            {
                ad.Role = AggregationRole.RowGrouping;
            }

            ad.GroupingType = GroupingTypeEnum.NumericInterval;
            AggregationDef.NumericIntervalSize = intervalSize;
            DialogResult = DialogResult.OK;
            return;

            //UpdateGrid();
            //Hide();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Build and show the menu for selecting aggregation type
        /// </summary>
        /// <param name="qc"></param>
        /// <param name="p"></param>
        /// <param name="typeDelegate"></param>

        public void ShowMenu(
            QueryColumn qc,
            AggregationDef ad,
            Point p,
            AggregationTypeChangedDelegate typeDelegate)
        {
            ContextMenuStrip menu = SetupAggregationTypeMenu(qc, ad, typeDelegate);

            menu.Show(p);
            return;
        }
Ejemplo n.º 6
0
/// <summary>
/// Show the aggregation role menu
/// </summary>
/// <param name="qc"></param>
/// <param name="ad"></param>
/// <param name="p"></param>
/// <param name="aggRoleChangedDelegate"></param>

        public static void ShowRoleMenu(
            QueryColumn qc,
            AggregationDef ad,
            Point p,
            AggregationTypeChangedDelegate aggRoleChangedDelegate)
        {
            AggregationDefMenus ats  = new AggregationDefMenus();
            ContextMenuStrip    menu = ats.SetupAggregationRoleMenu(qc, ad, aggRoleChangedDelegate);

            menu.Show(p);
            return;
        }
Ejemplo n.º 7
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;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Show the dialog
        /// </summary>
        /// <param name="f"></param>
        /// <param name="location"></param>
        /// <param name="dialog"></param>

        public static DialogResult ShowDialog(
            AggregationDef ad,
            Point location)
        {
            NumericIntervalDialog nfd = new NumericIntervalDialog();

            nfd.AggregationDef    = ad;          // save def ref for later use
            nfd.IntervalSize.Text = ad.NumericIntervalSize.ToString();
            nfd.Location          = location;
            nfd.IntervalSize.Focus();
            DialogResult dr = nfd.ShowDialog();

            return(dr);
        }
Ejemplo n.º 9
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
            }
        }
Ejemplo n.º 10
0
        public ContextMenuStrip SetupAggregationRoleMenu(
            QueryColumn qc,
            AggregationDef ad,
            AggregationTypeChangedDelegate aggRoleChangedDelegate = null)
        {
            Qc = qc;             // save call parms
            if (qc != null)
            {
                Qt = qc.QueryTable;
            }
            AggregationDef             = ad;
            AggregationChangedDelegate = aggRoleChangedDelegate;

            AggregationRole r = ad.Role;

            ColumnAreaMenuItem.Checked    = (ad.Role == AggregationRole.ColumnGrouping);
            RowAreaMenuItem.Checked       = (ad.Role == AggregationRole.RowGrouping);
            DataAreaMenuItem.Checked      = (ad.Role == AggregationRole.DataSummary);
            FilterAreaMenuItem.Checked    = (ad.Role == AggregationRole.Filtering);
            UndefinedAreaMenuItem.Checked = (ad.Role == AggregationRole.Undefined);

            return(AggRoleMenu);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Build aggregation type menu for specific field
        /// </summary>
        /// <param name="qc"></param>
        /// <returns></returns>

        public ContextMenuStrip SetupAggregationTypeMenu(
            QueryColumn qc,
            AggregationDef ad,
            AggregationTypeChangedDelegate typeDelegate = null,
            bool includeGroupingItems = true,
            bool includeSummaryItems  = true)
        {
            Qc                         = qc; // save call parms
            Qt                         = qc.QueryTable;
            AggregationDef             = ad;
            AggregationChangedDelegate = typeDelegate;

            MetaColumn mc = Qc.MetaColumn;

            // Set Visibility for menu items as appropriate for data type and args

            InitMenuItems();

            if (includeGroupingItems)
            {
                GroupByHeaderMenuItem.Available     =
                    AggregationSeparator1.Available = true;
            }

            if (includeSummaryItems)             // summary types allowed for all data types
            {
                SummarizationHeaderMenuItem.Available                                     =
                    AggregationSeparator1.Available                                       =
                        CountMenuItem.Available                                           =
                            CountDistinctMenuItem.Available                               =
                                MinMenuItem.Available                                     =
                                    MaxMenuItem.Available                                 =
                                        MedianMenuItem.Available                          =
                                            ModeMenuItem.Available                        =
                                                ConcatenateMenuItem.Available             =
                                                    ConcatenateDistinctMenuItem.Available =
                                                        AggregationSeparator2.Available   = true;
            }

            if (mc.IsKey)
            {
                if (includeGroupingItems)
                {
                    MatchingValuesMenuItem.Available = true;
                }
            }

            else if (mc.DataType == MetaColumnType.String)
            {
                if (includeGroupingItems)
                {
                    MatchingValuesMenuItem.Available  =
                        FirstLetterMenuItem.Available = true;
                }
            }

            else if (mc.IsNumeric)
            {
                if (includeGroupingItems)
                {
                    MatchingValuesMenuItem.Available      =
                        NumericIntervalMenuItem.Available = true;
                }

                if (includeSummaryItems)
                {
                    SumMenuItem.Available = true;

                    ArithmeticMeanMenuItem.Available    =
                        GeometricMeanMenuItem.Available = true;

                    if (UnpivotedAssayResult.IsSpAndCrcUnpivotedAssayResultColumn(mc))                     // col contains both SP and CRC values
                    {
                        MostPotentMenuItem.Available     =
                            ResultMeanMenuItem.Available = true;

                        ArithmeticMeanMenuItem.Available    =
                            GeometricMeanMenuItem.Available = false;
                    }
                }
            }

            else if (mc.DataType == MetaColumnType.Date)
            {
                if (includeGroupingItems)
                {
                    GroupByDateMenuItem.Available             =
                        QuarterYearMenuItem.Available         =
                            MonthYearMenuItem.Available       =
                                GroupByYearMenuItem.Available = true;
                }
            }

            else if (mc.DataType == MetaColumnType.Structure)             // no grouping, count only for summary for now
            {
                InitMenuItems();

                if (includeGroupingItems)
                {
                    //GroupByHeaderMenuItem.Available =
                    //AggregationSeparator1.Available = true;

                    includeGroupingItems = false;                       // todo, grouping on frag
                }

                if (includeSummaryItems)
                {
                    SummarizationHeaderMenuItem.Available   =
                        CountMenuItem.Available             =
                            AggregationSeparator2.Available = true;
                }
            }

            else if (mc.DataType == MetaColumnType.Image)             // no grouping, count only for summary
            {
                InitMenuItems();

                if (includeGroupingItems)
                {
                    includeGroupingItems = false;                     // not allowed
                }

                if (includeSummaryItems)                 // summary types allowed for all data types
                {
                    SummarizationHeaderMenuItem.Available   =
                        CountMenuItem.Available             =
                            AggregationSeparator2.Available = true;
                }
            }

            else             // other types
            {
                if (includeGroupingItems)
                {
                    MatchingValuesMenuItem.Available = true;
                }

                if (includeSummaryItems)
                {
                    NumberQualifierMenuItem.Available = Qc.IsPotentialNumberQualifier;
                }
                //SingleValueMenuItem.Available = true; // (Not currently used)
            }

            if (!includeGroupingItems || !includeSummaryItems)
            {
                AggregationSeparator1.Available = AggregationSeparator2.Available = false;
            }

            //  Checkmark current selection

            string typeName = ad.TypeName;

            foreach (ToolStripItem tsi in AggTypeMenu.Items)
            {
                ToolStripMenuItem tsmi = tsi as ToolStripMenuItem;
                if (tsmi == null)
                {
                    continue;                               // separator of other non-ToolStripMenuItem
                }
                string menuItemTypeName = tsmi.Tag != null?tsmi.Tag.ToString() : "<null>";

                if (Lex.Eq(menuItemTypeName, typeName))
                {
                    tsmi.Checked = true;
                }
                else
                {
                    tsmi.Checked = false;
                }
            }

            return(AggTypeMenu);
        }