Beispiel #1
0
        /// <summary>
        /// Render the view
        /// </summary>
        /// <param name="queryResultsControl"></param>

        public override void ConfigureRenderingControl()
        {
            if (!BuildUnpivotedResults(false))
            {
                return;
            }

            PivotGridPropertiesMx p = PivotGridPropertiesMx;

            if (p == null)
            {
                return;
            }

            SyncMxFieldListWithSourceQuery(        // be sure main grid & any pivot view fields are in synch
                BaseQuery, ref p.PivotFields);     // be sure

            if (p.PivotFields == null)             // if not defined then show dialog to allow user to define
            {
                PivotGridDialog.ShowDialog(this);
            }

            AssureQueryManagerIsDefined(BaseQuery);
            ConfigurePivotGridControl();                              // configure the control to display the data

            PivotGridCtl.DataSource = Qm.DataTableManager.DataSource; // set the data table to start rendering

            PivotGridCtl.Visible = true;                              // be sure the control is visible
            ConfigureCount++;

            return;
        }
Beispiel #2
0
        /// <summary>
        /// Configure the grid and chart controls to the view properties
        /// </summary>

        internal void ConfigurePivotGridControlOptions()
        {
            PivotGridPropertiesMx p = PivotGridPropertiesMx;

            if (p.CompactLayout)
            {
                PivotGridCtl.OptionsView.ShowRowTotals             = true;
                PivotGridCtl.OptionsView.ShowTotalsForSingleValues = true;
                PivotGridCtl.OptionsView.RowTotalsLocation         = PivotRowTotalsLocation.Tree;
                PivotGridCtl.OptionsBehavior.HorizontalScrolling   = PivotGridScrolling.CellsArea;
            }

            else
            {
                PivotGridCtl.OptionsView.RowTotalsLocation       = PivotRowTotalsLocation.Far;
                PivotGridCtl.OptionsBehavior.HorizontalScrolling = PivotGridScrolling.Control;
            }

            PivotGridCtl.OptionsView.ShowColumnTotals      = p.ShowColumnTotals;
            PivotGridCtl.OptionsView.ShowColumnGrandTotals = p.ShowColumnGrandTotals;
            PivotGridCtl.OptionsView.ShowRowTotals         = p.ShowRowTotals;
            PivotGridCtl.OptionsView.ShowRowGrandTotals    = p.ShowRowGrandTotals;
            PivotGridCtl.OptionsView.ShowFilterHeaders     = p.ShowFilterHeaders;

            PivotGridPanel.ChartType = p.PivotGridChartType;
            PivotGridCtl.OptionsChartDataSource.SelectionOnly        = p.PgcShowSelectionOnly;
            PivotGridCtl.OptionsChartDataSource.ProvideDataByColumns = p.PgcProvideDataByColumns;
            //Chart.SeriesTemplate.LabelsVisibility = DefaultBooleanMx.Convert(p.PgcShowPointLabels);
            PivotGridCtl.OptionsChartDataSource.ProvideColumnGrandTotals = p.PgcShowColumnGrandTotals;
            PivotGridCtl.OptionsChartDataSource.ProvideRowGrandTotals    = p.PgcShowRowGrandTotals;

            return;
        }
Beispiel #3
0
/// <summary>
/// Copy grid/chart control properties to the view
/// </summary>

        void CopyGridPropsToView()
        {
            PivotGridPropertiesMx p = PivotView.PivotGridPropertiesMx;

            if (p == null)
            {
                return;
            }

            PivotView.UpdateViewFieldsFromGridFields();

            p.CompactLayout =
                (PivotGrid.OptionsView.RowTotalsLocation == PivotRowTotalsLocation.Tree);

            p.ShowColumnTotals      = PivotGrid.OptionsView.ShowColumnTotals;
            p.ShowColumnGrandTotals = PivotGrid.OptionsView.ShowColumnGrandTotals;
            p.ShowRowTotals         = PivotGrid.OptionsView.ShowRowTotals;
            p.ShowRowGrandTotals    = PivotGrid.OptionsView.ShowRowGrandTotals;
            p.ShowFilterHeaders     = PivotGrid.OptionsView.ShowFilterHeaders;

            p.PivotGridChartType      = PivotGridPanel.ChartType;
            p.PgcShowSelectionOnly    = PivotGrid.OptionsChartDataSource.SelectionOnly;
            p.PgcProvideDataByColumns = PivotGrid.OptionsChartDataSource.ProvideDataByColumns;
            //p.PgcShowPointLabels = DefaultBooleanMx.Convert(Chart.SeriesTemplate.LabelsVisibility);
            p.PgcShowColumnGrandTotals = PivotGrid.OptionsChartDataSource.ProvideColumnGrandTotals;
            p.PgcShowRowGrandTotals    = PivotGrid.OptionsChartDataSource.ProvideRowGrandTotals;

            return;
        }
Beispiel #4
0
        PivotGridField GetViewField(PivotGridField f)
        {
            PivotGridPropertiesMx p = View.PivotGridPropertiesMx;

            foreach (PivotGridField f0 in p.PivotFields)
            {
                if (f0.UnboundFieldName == f.UnboundFieldName)
                {
                    return(f0);
                }
            }

            throw new Exception("PivotGridField not found: " + f.UnboundFieldName);
        }
Beispiel #5
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 #6
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 #7
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 #8
0
        /// <summary>
        /// Create and configure the PivotGridFields for the grid control
        /// </summary>

        internal void ConfigurePivotGridControl()
        {
            PivotGridCtl.View         = this;
            PivotGridCtl.DataSource   = null;           // be sure source is clear while configuring
            PivotGridCtl.HeaderImages = Bitmaps.Bitmaps16x16;

            PivotGridCtl.BeginUpdate();

            PivotGridPropertiesMx p = PivotGridPropertiesMx;

            SyncMxFieldListWithSourceQuery(BaseQuery, ref p.PivotFields);             // be sure initialized

            BuildGridFieldsFromViewFields();

            ConfigurePivotGridControlFields();

            ConfigurePivotGridControlOptions();

            PivotGridCtl.EndUpdate();

            return;
        }
Beispiel #9
0
        /// <summary>
        /// BeginSerialization
        /// </summary>
        /// <param name="tw"></param>

        public override void BeginSerialization(XmlTextWriter tw)
        {
            base.BeginSerialization(tw);

            PivotGridPropertiesMx p = PivotGridPropertiesMx;

            if (p == null)
            {
                return;
            }

            tw.WriteStartElement("PivotGridView");

            tw.WriteAttributeString("CompactLayout", p.CompactLayout.ToString());
            tw.WriteAttributeString("ShowColumnTotals", p.ShowColumnTotals.ToString());
            tw.WriteAttributeString("ShowColumnGrandTotals", p.ShowColumnGrandTotals.ToString());
            tw.WriteAttributeString("ShowRowTotals", p.ShowRowTotals.ToString());
            tw.WriteAttributeString("ShowRowGrandTotals", p.ShowRowGrandTotals.ToString());
            tw.WriteAttributeString("ShowFilterHeaders", p.ShowFilterHeaders.ToString());

            tw.WriteAttributeString("PivotGridChartType", p.PivotGridChartType);
            tw.WriteAttributeString("PgcShowSelectionOnly", p.PgcShowSelectionOnly.ToString());
            tw.WriteAttributeString("PgcDataVertical", p.PgcProvideDataByColumns.ToString());
            tw.WriteAttributeString("PgcShowPointLabels", p.PgcShowPointLabels.ToString());
            tw.WriteAttributeString("PgcShowColumnGrandTotals", p.PgcShowColumnGrandTotals.ToString());
            tw.WriteAttributeString("PgcShowRowGrandTotals", p.PgcShowRowGrandTotals.ToString());

            if (p.PivotFields != null)
            {
                tw.WriteStartElement("PivotGridFields");
                foreach (PivotGridFieldMx f in p.PivotFields)
                {
                    ResultsField rfld = f.ResultsField as ResultsField;

                    tw.WriteStartElement("PivotGridField");

                    if (rfld == null || f.Caption != PivotGridControlMx.BuildFieldCaption(f))                     // write caption if different than field name
                    {
                        tw.WriteAttributeString("Caption", f.Caption);
                    }

                    tw.WriteAttributeString("UnboundFieldName", f.UnboundFieldName);                     // tableAlias.mcName link to source query table/column

                    tw.WriteAttributeString("Role", f.Role.ToString());
                    tw.WriteAttributeString("AreaIndex", f.AreaIndex.ToString());

                    if (f.SummaryTypeMx != AggregationDef.Model.SummaryType)
                    {
                        tw.WriteAttributeString("SummaryType", f.SummaryTypeMx.ToString());
                    }

                    if (f.GroupingType != AggregationDef.Model.GroupingType)
                    {
                        tw.WriteAttributeString("GroupingType", f.GroupingType.ToString());
                    }

                    if (f.NumericIntervalSize != AggregationDef.Model.NumericIntervalSize)
                    {
                        tw.WriteAttributeString("NumericIntervalSize", f.NumericIntervalSize.ToString());
                    }

                    if (f.Width != PivotGridField.DefaultWidth)
                    {
                        tw.WriteAttributeString("Width", f.Width.ToString());
                    }

                    tw.WriteEndElement();             // PivotGridField
                }
                tw.WriteEndElement();                 // PivotGridFields
            }

            tw.WriteEndElement();             // PivotGridView

            return;
        }
Beispiel #10
0
        internal static int UnboundFieldNameCount = 0;         // assign unique unbound field names

        /// <summary>
        /// Basic constructor
        /// </summary>

        public PivotGridView()
        {
            ViewType = ResultsViewType.PivotGrid;
            Title    = "Pivot View";
            PivotGridPropertiesMx = new PivotGridPropertiesMx();
        }
Beispiel #11
0
        /// <summary>
        /// Render the view into the specified results control
        /// </summary>

        public override void ConfigureRenderingControl()
        {
            Query         q;
            ResultsFormat rf = ResultsFormat;

            ResultsTable rt;
            QueryTable   qt;
            MetaTable    mt;

            ResultsField rfld;

            Mobius.Data.QueryColumn qc;
            MetaColumn mc;

            PivotGridField pgf;

            bool includeActivityClass = true;

            if (!BuildUnpivotedResults(includeActivityClass))
            {
                return;
            }

            PivotGridPropertiesMx p = PivotGridPropertiesMx;

            if (p == null)
            {
                return;
            }

            if (p.PivotFields == null)             // if not defined then configure
            {
                PivotGridCtl.Fields.Clear();       // clear any prev display
                PivotGridCtl.Groups.Clear();

                if (DataIncludesDates)
                {
                    DialogResult dr = DateGroupingDialog.ShowDialog(ref DateGroupInterval);
                }

                p.PivotFields = new List <PivotGridFieldMx>();

                foreach (ResultsTable rt0 in rf.Tables)                 // determine visible fields
                {
                    rt = rt0;
                    qt = rt.QueryTable;
                    mt = qt.MetaTable;
                    if (Lex.Eq(mt.Name, MultiDbAssayDataNames.CombinedNonSumTableName))
                    {
                        if ((rfld = rt.GetResultsFieldByName("activity_bin")) != null)
                        {
                            pgf = PivotGridView.AddField(rfld, p.PivotFields, PivotArea.RowArea, true, null, GroupingTypeEnum.EqualValues);
                        }

                        if ((rfld = rt.GetResultsFieldByName("run_dt")) != null &&
                            DataIncludesDates && DateGroupInterval != GroupingTypeEnum.EqualValues)
                        {
                            GroupingTypeEnum pgi = DateGroupInterval;

                            int  intervalCnt = 0;
                            bool week = false, month = false, year = false;                             // include larger date units up to year
                            if (pgi == GroupingTypeEnum.DateDayOfWeek)
                            {
                                week        = month = year = true;
                                intervalCnt = 3;
                            }

                            else if (pgi == GroupingTypeEnum.DateWeekOfMonth)
                            {
                                intervalCnt = 3;

                                month = year = true;
                            }

                            else if (pgi == GroupingTypeEnum.DateMonth ||
                                     pgi == GroupingTypeEnum.DateQuarter)
                            {
                                year = true;
                            }

                            PivotGridGroup g = null;

                            if (intervalCnt > 1)
                            {
                                g = new PivotGridGroup();
                                PivotGridCtl.Groups.Add(g);
                            }

                            if (year)
                            {
                                PivotGridView.AddField(rfld, p.PivotFields, PivotArea.ColumnArea, true, g, GroupingTypeEnum.DateYear);
                            }
                            if (month)
                            {
                                PivotGridView.AddField(rfld, p.PivotFields, PivotArea.ColumnArea, true, g, GroupingTypeEnum.DateMonth);
                            }
                            if (week)
                            {
                                PivotGridView.AddField(rfld, p.PivotFields, PivotArea.ColumnArea, true, g, GroupingTypeEnum.DateWeekOfMonth);
                            }
                            PivotGridView.AddField(rfld, p.PivotFields, PivotArea.ColumnArea, true, g, pgi);
                        }

                        if ((rfld = rt.GetResultsFieldByName("assy_nm")) != null)
                        {
                            pgf = PivotGridView.AddField(rfld, p.PivotFields, PivotArea.ColumnArea, true, null, GroupingTypeEnum.EqualValues);
                        }

                        if ((rfld = rt.GetResultsFieldByName("rslt_val")) != null)
                        {
                            pgf = PivotGridView.AddField(rfld, p.PivotFields, PivotArea.DataArea, true, null, GroupingTypeEnum.EqualValues);
                        }
                    }

                    else                     // tables other than the standard pivoted table
                    {
                        foreach (ResultsField rfld0 in rt.Fields)
                        {
                            rfld = rfld0;
                            qc   = rfld.QueryColumn;
                            mc   = qc.MetaColumn;
                        }
                    }
                }
            }                                                             // done defining initial set of fields

            SyncMxFieldListWithSourceQuery(BaseQuery, ref p.PivotFields); // be sure main grid & pivot view fields are in synch

            ConfigurePivotGridControl();                                  // configure the control to display the data

            PivotGridCtl.DataSource = Qm.DataTableManager.DataSource;     // set the data table to start rendering

            return;
        }