Beispiel #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;
        }
Beispiel #2
0
/// <summary>
/// Aggregation role changed
/// </summary>
/// <param name="ats"></param>

        private void AggregationRoleChanged(AggregationDefMenus ats)
        {
            FieldGridView.SetRowCellValue(FieldGridRow, "AggRoleCol", Field.Aggregation.RoleLabel);
            FieldGridView.SetRowCellValue(FieldGridRow, "AggTypeCol", Field.Aggregation.TypeLabel);
            Field.SyncDxAreaToMxRole();          // sync Dx area
            PivotGrid.RefreshData();             // refresh the PivotGrid to show new agg type results
        }
Beispiel #3
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;
        }
Beispiel #4
0
        /// <summary>
        /// Store selected group interval type
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void AggregationTypeChanged(AggregationDefMenus ats)
        {
            FieldGridView.SetRowCellValue(FieldGridRow, "AggTypeCol", Field.Aggregation.TypeLabel);
            Field.SyncDxAreaToMxRole();          // sync Dx area
            PivotGrid.RefreshData();             // refresh the PivotGrid to show new agg type results

            //PivotGrid.BeginUpdate();
            //object ds = PivotGrid.DataSource;
            //PivotGrid.DataSource = null;
            // -make changes
            //PivotGrid.DataSource = ds;
            //PivotGrid.EndUpdate();
        }
Beispiel #5
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 #6
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;
        }