Example #1
0
        public void Add(Theme p_Theme)
        {
            if (p_Theme.Type == ThemeType.Color)
            {

                foreach (Theme _Theme in List)
                {
                    if (_Theme.Type == ThemeType.Color)
                    {
                        _Theme.Visible = false;
                    }
                }
                p_Theme.Visible = true;
                List.Insert(0, p_Theme);

                //*** Always Add New Color Theme at 0th index
            }
            else
            {
                List.Add(p_Theme);
            }
        }
Example #2
0
        /// <summary>
        /// It updates chart theme's basic properties with the chart theme saved in file specified (.plc)
        /// </summary>
        /// <param name="currentChartTheme">chart theme to update</param>
        /// <param name="savedChartThemeFileName">(serialized) saved chart theme file name path</param>
        public void UpdateChartSettings(ref Theme currentChartTheme, string savedChartThemeFileName)
        {
            Theme NewChartTheme = null;

            if (File.Exists(savedChartThemeFileName))
            {
                Theme LoadedTheme = Theme.Load(savedChartThemeFileName);
                if (LoadedTheme.Type == ThemeType.Chart)
                {
                    //- If ChartType is different from currentTheme, then re-create Chart theme
                    if (currentChartTheme.ChartType != LoadedTheme.ChartType)
                    {
                        //-- Create new Chart theme on the basis of ChartType
                        int ThemeIndex = this.m_Themes.ItemIndex(currentChartTheme.ID);
                        currentChartTheme.ID = "TempThemeID";

                        //-- Preserve Old Theme's Excluded Areas List and re-assign to new Theme
                        List<string> ChartThemeAreas = currentChartTheme.ExcludeAreaIDs;

                        //-Pass ChartType and Chart SeriesBy value (Subgroup OR Source)
                        NewChartTheme = this.CreateTheme(currentChartTheme.IndicatorNId[0], currentChartTheme.UnitNId.ToString(), currentChartTheme.SubgroupNId[0], currentChartTheme.Type, LoadedTheme.ChartType, LoadedTheme.ChartSeriestype, ThemeIndex);

                        //-- Assign Excluded Chart Areas List to new theme
                        NewChartTheme.ExcludeAreaIDs = ChartThemeAreas;
                        if (NewChartTheme.ExcludeAreaIDs == null)
                        {
                            NewChartTheme.ExcludeAreaIDs = new List<string>();
                        }

                        //- Remove OLD theme
                        this.m_Themes.Remove(this.m_Themes.ItemIndex("TempThemeID"));

                        NewChartTheme.Name = currentChartTheme.Name;
                        currentChartTheme = NewChartTheme;
                    }
                    else
                    {
                        //- If Chart SeriesBy (Subgroup OR Source) is different
                        if (currentChartTheme.ChartSeriestype != LoadedTheme.ChartSeriestype)
                        {
                            if (LoadedTheme.ChartSeriestype == ChartSeriesType.Source)
                            {
                                this.UpdateChartForMultipleSource(currentChartTheme.SubgroupNId[0].ToString(), ref currentChartTheme);
                            }
                            else if (LoadedTheme.ChartSeriestype == ChartSeriesType.Subgroup)
                            {
                                this.UpdateChartForMultipleSubgroups(currentChartTheme);
                            }
                        }
                    }

                    //- Update common Chart Settings
                    currentChartTheme.ChartAxisColor = LoadedTheme.ChartAxisColor;
                    currentChartTheme.ChartAxisLabelSettings = LoadedTheme.ChartAxisLabelSettings;
                    currentChartTheme.ChartDataLabelSettings = LoadedTheme.ChartDataLabelSettings;

                    currentChartTheme.ChartLeaderColor = LoadedTheme.ChartLeaderColor;
                    currentChartTheme.ChartLeaderStyle = LoadedTheme.ChartLeaderStyle;
                    currentChartTheme.ChartLeaderVisible = LoadedTheme.ChartLeaderVisible;
                    currentChartTheme.ChartLeaderWidth = LoadedTheme.ChartLeaderWidth;
                    currentChartTheme.ChartLineThickness = LoadedTheme.ChartLineThickness;

                    currentChartTheme.RoundDecimals = LoadedTheme.RoundDecimals;
                    currentChartTheme.ChartSize = LoadedTheme.ChartSize;
                    currentChartTheme.ChartWidth = LoadedTheme.ChartWidth;
                    currentChartTheme.ColumnsGap = LoadedTheme.ColumnsGap;
                    currentChartTheme.DisplayChartData = LoadedTheme.DisplayChartData;
                    currentChartTheme.DisplayChartMRD = LoadedTheme.DisplayChartMRD;
                    currentChartTheme.PieAutoSize = LoadedTheme.PieAutoSize;
                    currentChartTheme.PieAutoSizeFactor = LoadedTheme.PieAutoSizeFactor;
                    currentChartTheme.PieSize = LoadedTheme.PieSize;
                    currentChartTheme.ShowChartAxis = LoadedTheme.ShowChartAxis;

                    //- Set Subgroup Fill Colors
                    string[] ColorArr = currentChartTheme.SubgroupFillStyle;

                    for (int i = 0; i < currentChartTheme.SubgroupFillStyle.Length; i++)
                    {
                        if (LoadedTheme.SubgroupFillStyle.Length > i)
                        {
                            ColorArr[i] = LoadedTheme.SubgroupFillStyle[i];
                        }
                    }
                    currentChartTheme.SubgroupFillStyle = ColorArr;

                }
            }
        }
Example #3
0
        public void UpdateChartForMultipleSubgroups(Theme p_Theme)
        {
            string RowFilter = string.Empty;
            string OriginalFilter = string.Empty;

            DataTable SubgroupNIdTable = null;
            DataView ThemeData = null;
            string[] _SPNID = null;
            string[] _SPName = null;
            if (p_Theme != null)
            {
                try
                {
                    p_Theme.ChartSeriestype = ChartSeriesType.Subgroup;

                    OriginalFilter = this.PresentationData.RowFilter;

                    //Get all SourceNIds for given Indicator, unit, Subgroups from Presentation data
                    RowFilter = Indicator.IndicatorNId + " IN(" + p_Theme.IndicatorNId[0] + ") AND " + Unit.UnitNId + " IN (" + p_Theme.UnitNId + ") ";
                    this.PresentationData.RowFilter = RowFilter;

                    //Theme Data
                    ThemeData = this.PresentationData.ToTable().DefaultView;

                    //- Source Table
                    SubgroupNIdTable = ThemeData.ToTable(true, SubgroupVals.SubgroupValNId, SubgroupVals.SubgroupVal);

                    //- Set original Row Filter.
                    this.PresentationData.RowFilter = OriginalFilter;

                    //Initialize Theme.SouceNIds array.
                    _SPNID = new string[SubgroupNIdTable.Rows.Count];
                    _SPName = new string[SubgroupNIdTable.Rows.Count];

                    for (int i = 0; i < SubgroupNIdTable.Rows.Count; i++)
                    {
                        _SPNID[i] = SubgroupNIdTable.Rows[i][SubgroupVals.SubgroupValNId].ToString();
                        _SPName[i] = SubgroupNIdTable.Rows[i][SubgroupVals.SubgroupVal].ToString();
                    }

                    p_Theme.SubgroupName = _SPName;
                    p_Theme.SubgroupNId = _SPNID;

                    // Re create Chart Theme's AreaIndex. This time DataValue will be for Single IUS & Muultiple Sources
                    p_Theme.AreaIndexes = new Hashtable();
                    p_Theme.ChartSeriestype = ChartSeriesType.Subgroup;

                    ThemeData.Sort = DataExpressionColumns.DataType + " ASC," + DataExpressionColumns.NumericData + " ASC";
                    p_Theme.Minimum = (decimal)ThemeData[0][DataExpressionColumns.NumericData];
                    p_Theme.Maximum = (decimal)ThemeData[ThemeData.Count - 1][DataExpressionColumns.NumericData];

                    this.MakeChartTheme(p_Theme.IndicatorNId, p_Theme.SubgroupNId, ThemeData, p_Theme);

                    //- Set SourceNIDs NULL
                    p_Theme.SourceNIds = new string[] { "" };

                    //- Update SourceFillStyle (Fill Colors)
                    p_Theme.SetChartSeriesVisibility();

                    //-- Update Theme ID = IndNid _ UnitNid _ SubgroupNid _ Type
                    p_Theme.ID = p_Theme.IndicatorNId[0] + "_" + p_Theme.UnitNId + "_-1_" + (int)p_Theme.Type;

                    //-- Save GIDs of Indicator, Unit & default SubgroupVal used in theme creation.
                    p_Theme.I_U_S_GIDs = this.GetI_U_S_GIDsByNids(this._DIDataView.MainDataTable.DefaultView, p_Theme.IndicatorNId[0], p_Theme.UnitNId.ToString(), p_Theme.SubgroupNId[0]);
                }
                catch
                {
                }
            }
        }
Example #4
0
        /// <summary>
        /// It updates Chart Theme's AreaIndexes data Values for Multiple Sources against Single IUS.
        /// </summary>
        /// <param name="p_SubgroupNId">SubgroupNId to pair with existing Indicator & Unit in Current Theme.</param>
        /// <param name="p_Theme">Chart Theme object to edit.</param>
        public void UpdateChartForMultipleSource(string p_SubgroupNId, ref Theme p_Theme)
        {
            string RowFilter = string.Empty;
            string OriginalFilter = string.Empty;

            DataTable SourceNIdTable = null;
            DataView ThemeData = null;

            if (p_Theme != null && string.IsNullOrEmpty(p_SubgroupNId) == false)
            {
                try
                {
                    p_Theme.ChartSeriestype = ChartSeriesType.Source;

                    OriginalFilter = this.PresentationData.RowFilter;

                    //Get all SourceNIds for given Indicator, unit, Subgroups from Presentation data
                    RowFilter = Indicator.IndicatorNId + " IN(" + p_Theme.IndicatorNId[0] + ") AND " + Unit.UnitNId + " IN (" + p_Theme.UnitNId + ") AND " + SubgroupVals.SubgroupValNId + " IN (" + p_SubgroupNId + ")";
                    this.PresentationData.RowFilter = RowFilter;

                    //Theme Data
                    ThemeData = this.PresentationData.ToTable().DefaultView;

                    //- Source Table
                    SourceNIdTable = ThemeData.ToTable(true, IndicatorClassifications.ICNId, IndicatorClassifications.ICName);

                    //- Set original Row Filter.
                    this.PresentationData.RowFilter = OriginalFilter;

                    //Initialize Theme.SouceNIds array.
                    p_Theme.SourceNIds = new string[SourceNIdTable.Rows.Count];
                    p_Theme.SourceName = new string[SourceNIdTable.Rows.Count];

                    for (int i = 0; i < SourceNIdTable.Rows.Count; i++)
                    {
                        p_Theme.SourceNIds[i] = SourceNIdTable.Rows[i][IndicatorClassifications.ICNId].ToString();
                        p_Theme.SourceName[i] = SourceNIdTable.Rows[i][IndicatorClassifications.ICName].ToString();
                    }

                    // Re create Chart Theme's AreaIndex. This time DataValue will be for Single IUS & Muultiple Sources
                    p_Theme.AreaIndexes = new Hashtable();
                    p_Theme.ChartSeriestype = ChartSeriesType.Source;

                    ThemeData.Sort = DataExpressionColumns.DataType + " ASC," + DataExpressionColumns.NumericData + " ASC";
                    p_Theme.Minimum = (decimal)ThemeData[0][DataExpressionColumns.NumericData];
                    p_Theme.Maximum = (decimal)ThemeData[ThemeData.Count - 1][DataExpressionColumns.NumericData];

                    //--Passing only one SubgroupNId for ChartSeries == Source
                    this.MakeChartTheme(p_Theme.IndicatorNId, new String[] { p_SubgroupNId }, ThemeData, p_Theme);

                    //- Update subgroupNID
                    //p_Theme.SubgroupNId = new string[] { p_SubgroupNId };

                    //- Update SourceFillStyle (Fill Colors)
                    p_Theme.SetChartSeriesVisibility();

                    //-- Update Theme ID = IndNid _ UnitNid _ SubgroupNid _ Type
                    p_Theme.ID = p_Theme.IndicatorNId[0] + "_" + p_Theme.UnitNId + "_" + p_SubgroupNId + "_" + (int)p_Theme.Type;

                    //-- Save GIDs of Indicator, Unit, Subgroups used in theme creation.
                    p_Theme.I_U_S_GIDs = this.GetI_U_S_GIDsByNids(this._DIDataView.MainDataTable.DefaultView, p_Theme.IndicatorNId[0], p_Theme.UnitNId.ToString(), p_SubgroupNId);
                }
                catch
                {
                    //- Set original Row Filter.
                    this.PresentationData.RowFilter = OriginalFilter;
                }
            }
        }
Example #5
0
        private void DrawColorTheme(ref Graphics g, Theme _Theme, Matrix mTransMatrix, RectangleF CurExt)
        {
            Legend _Legend;
            Shape _Shape;
            //Polygon : Polyline : Point
            int i;
            int j;
            GraphicsPath gpShp = new GraphicsPath();
            GraphicsPath gpSelShp = new GraphicsPath();
            StringFormat _StringFormat = new StringFormat();
            _StringFormat.Alignment = StringAlignment.Center;
            _StringFormat.LineAlignment = StringAlignment.Center;
            _StringFormat.FormatFlags = StringFormatFlags.NoClip;

            bool BaseLyrVisibility = false;
            //*** Set an array of brush based on current theme legend items
            Brush[] BrLegend = new Brush[_Theme.Legends.Count];
            for (i = 0; i <= _Theme.Legends.Count - 1; i++)
            {
                _Legend = _Theme.Legends[i];
                if (_Legend.FillStyle == FillStyle.Solid)
                {
                    BrLegend[i] = new SolidBrush(_Legend.Color);
                }
                else if (_Legend.FillStyle == FillStyle.Transparent)
                {
                    BrLegend[i] = new SolidBrush(Color.Transparent);
                }
                else
                {
                    BrLegend[i] = new HatchBrush((HatchStyle)_Legend.FillStyle, _Legend.Color, Color.Transparent);
                }
            }

            Pen PnTheme = new Pen(_Theme.BorderColor, _Theme.BorderWidth);
            Pen BorderHighlight = new Pen(_Theme.BorderColor, _Theme.BorderWidth + 0.7F);
            BorderHighlight.Alignment = PenAlignment.Inset;
            BorderHighlight.DashStyle = _Theme.BorderStyle;

            if (_Theme.BorderWidth == 0)
                PnTheme.Color = Color.Transparent;
            //??? Strange that setting Pen width = 0 gives effect of Pen width 1. So this workaround
            PnTheme.DashStyle = _Theme.BorderStyle;

            HatchBrush BrSelection = new HatchBrush(HatchStyle.Percent40, m_SelectionColor, Color.Transparent);
            Pen PnSelection = new Pen(m_SelectionColor);

            //*** If lyr exists in theme.Layervisibility collection
            foreach (Layer Lyr in Layers)
            {
                //Traverse Layers collection
                {
                    if (Lyr.Extent.IntersectsWith(CurExt) || CurExt.Contains(Lyr.Extent) || Lyr.Extent.Contains(CurExt))
                    {
                        // Render layer only if it lies within current map extent
                        if (_Theme.Type == ThemeType.Color)
                        {
                            if (_Theme.LayerVisibility[Lyr.ID] == null)
                                BaseLyrVisibility = false;
                            else
                                BaseLyrVisibility = (bool)_Theme.LayerVisibility[Lyr.ID];
                        }
                        else if (_Theme.Type == ThemeType.Hatch)
                        {
                            BaseLyrVisibility = Lyr.Visible;
                        }

                        Hashtable ht = Lyr.GetRecords(Lyr.LayerPath + "\\" + Lyr.ID);
                        IDictionaryEnumerator dicEnumerator = ht.GetEnumerator();
                        if (Lyr.LayerType == ShapeType.Polygon & BaseLyrVisibility == true)
                        {
                            while (dicEnumerator.MoveNext())
                            {
                                //Traverse Shapes
                                _Shape = (Shape)dicEnumerator.Value;
                                if (_Shape.Extent.IntersectsWith(CurExt))
                                {
                                    //Render shape only if it lies within current map extent
                                    gpShp.Reset();
                                    for (j = 0; j <= _Shape.Parts.Count - 1; j++)
                                    {
                                        gpShp.AddPolygon((PointF[])_Shape.Parts[j]);
                                    }
                                    gpShp.Transform(mTransMatrix);
                                    if (_Theme.AreaIndexes.ContainsKey(_Shape.AreaId))
                                    {
                                        if (_Theme.MultiLegend == true)
                                        {
                                            {
                                                switch (_Theme.MultiLegendCriteria)
                                                {
                                                    case "SRC":
                                                        if (_Theme.MultiLegendCol.ContainsKey(((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).Source))
                                                        {
                                                            //TODO Optimize SolidBrush
                                                            g.FillPath(new SolidBrush(((Legends)_Theme.MultiLegendCol[((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).Source])[(int)((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).RenderingInfo].Color), gpShp);
                                                        }

                                                        break;
                                                    case "SGP":
                                                        if (_Theme.MultiLegendCol.ContainsKey(((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).Subgroup))
                                                        {
                                                            g.FillPath(new SolidBrush(((Legends)_Theme.MultiLegendCol[((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).Subgroup])[(int)((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).RenderingInfo].Color), gpShp);
                                                        }

                                                        break;
                                                    default:
                                                        if (_Theme.MultiLegendCol.ContainsKey(((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).MDFldVal[_Theme.MultiLegendCriteria]))
                                                        {
                                                            g.FillPath(new SolidBrush(((Legends)_Theme.MultiLegendCol[((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).MDFldVal[_Theme.MultiLegendCriteria]])[(int)((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).RenderingInfo].Color), gpShp);
                                                        }

                                                        break;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            g.FillPath(BrLegend[(int)((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).RenderingInfo], gpShp);
                                        }
                                    }

                                    else
                                    {
                                        g.FillPath(BrLegend[BrLegend.Length - 1], gpShp);
                                    }
                                    try
                                    {
                                        //- Draw Specified Area's polygon to hightlight with different border
                                        if (_Shape.AreaId == this.AreaIDToHighlight)
                                        {
                                            g.DrawPath(BorderHighlight, gpShp);
                                        }
                                        else
                                        {
                                            //- Draw Area polygon Path
                                            g.DrawPath(PnTheme, gpShp);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        //Console.Write(ex.Message) '??? AFRERI Eritria problem
                                    }

                                    //*** Draw Base layer selection
                                    if (Lyr.SelectedArea.Contains(_Shape.AreaId))
                                        g.FillPath(BrSelection, gpShp);

                                    //-Exist Drawing Function
                                    if (_Shape.AreaId == this.AreaIDToHighlight)
                                    {
                                        break;
                                    }
                                }
                            }
                            //Traverse Shapes
                        }
                        else if (((Lyr.LayerType == ShapeType.PolygonFeature & BaseLyrVisibility == true) | ((Lyr.LayerType == ShapeType.PolygonCustom | Lyr.LayerType == ShapeType.PolygonBuffer) & Lyr.Visible == true)) & _Theme.Type == ThemeType.Color)
                        {
                            Pen PnLayer = new Pen(Lyr.BorderColor, Lyr.BorderSize);
                            if (Lyr.BorderSize == 0)
                                PnLayer.Color = Color.Transparent;
                            //??? Strange that setting Pen width = 0 gives effect of Pen width 1. So this workaround
                            PnLayer.DashStyle = Lyr.BorderStyle;
                            Brush BrLayer;
                            if (Lyr.FillStyle == FillStyle.Solid)
                            {
                                BrLayer = new SolidBrush(Lyr.FillColor);
                            }
                            else if (Lyr.FillStyle == FillStyle.Transparent)
                            {
                                BrLayer = new SolidBrush(Color.Transparent);
                            }
                            else
                            {
                                BrLayer = new HatchBrush((HatchStyle)Lyr.FillStyle, Lyr.FillColor, Color.Transparent);
                            }
                            gpShp.Reset();
                            gpShp.FillMode = FillMode.Winding;
                            gpSelShp.Reset();
                            gpSelShp.FillMode = FillMode.Winding;
                            while (dicEnumerator.MoveNext())
                            {
                                _Shape = (Shape)dicEnumerator.Value;
                                if (_Shape.Extent.IntersectsWith(CurExt))
                                {
                                    for (j = 0; j <= _Shape.Parts.Count - 1; j++)
                                    {
                                        try
                                        {
                                            gpShp.AddPolygon((PointF[])_Shape.Parts[j]);
                                        }
                                        catch (Exception ex)
                                        {

                                        }
                                        if (Lyr.SelectedArea.Contains(_Shape.AreaId))
                                            gpSelShp.AddPolygon((PointF[])_Shape.Parts[j]);
                                    }
                                }
                            }
                            gpShp.Transform(mTransMatrix);
                            g.FillPath(BrLayer, gpShp);
                            try
                            {
                                g.DrawPath(PnLayer, gpShp);
                            }
                            catch (Exception ex)
                            {
                                Console.Write(ex.Message);
                                //??? AFRERI Eritria problem
                            }
                            if (Lyr.SelectedArea.Count > 0)
                            {
                                gpSelShp.Transform(mTransMatrix);
                                g.FillPath(BrSelection, gpSelShp);
                            }
                            BrLayer.Dispose();
                            PnLayer.Dispose();
                        }
                        else if (Lyr.LayerType == ShapeType.PolyLine & BaseLyrVisibility == true & _Theme.Type == ThemeType.Color)
                        {
                            Pen PnLegend = new Pen(Lyr.BorderColor, Lyr.BorderSize);
                            PnLegend.DashStyle = Lyr.BorderStyle;
                            while (dicEnumerator.MoveNext())
                            {
                                //*** Traverse Shapes
                                _Shape = (Shape)dicEnumerator.Value;
                                gpShp.Reset();
                                for (j = 0; j <= _Shape.Parts.Count - 1; j++)
                                {
                                    gpShp.StartFigure();
                                    gpShp.AddLines((PointF[])_Shape.Parts[j]);
                                }
                                gpShp.Transform(mTransMatrix);
                                PnLegend.Color = _Theme.Legends[(int)((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).RenderingInfo].Color;
                                g.DrawPath(PnLegend, gpShp);
                            }
                            PnLegend.Dispose();
                        }
                        else if (((Lyr.LayerType == ShapeType.PolyLineFeature & BaseLyrVisibility == true) | (Lyr.LayerType == ShapeType.PolyLineCustom & Lyr.Visible == true)) & _Theme.Type == ThemeType.Color)
                        {
                            gpShp.Reset();
                            while (dicEnumerator.MoveNext())
                            {
                                //*** Traverse Shapes
                                _Shape = (Shape)dicEnumerator.Value;
                                for (j = 0; j <= _Shape.Parts.Count - 1; j++)
                                {
                                    gpShp.StartFigure();
                                    gpShp.AddLines((PointF[])_Shape.Parts[j]);
                                }
                            }
                            Pen PnLayer = new Pen(Lyr.BorderColor, Lyr.BorderSize);
                            PnLayer.DashStyle = Lyr.BorderStyle;
                            gpShp.Transform(mTransMatrix);
                            g.DrawPath(PnLayer, gpShp);
                            PnLayer.Dispose();
                        }
                        else if (Lyr.LayerType == ShapeType.Point & BaseLyrVisibility == true)
                        {
                            g.SmoothingMode = SmoothingMode.AntiAlias;
                            {
                                PointF[] Pt = new PointF[1];
                                int LegendItemIndex;
                                int[] MarkerSize = new int[_Theme.Legends.Count];
                                //PtSize based on Legend item
                                char[] MarkerChar = new char[_Theme.Legends.Count];
                                Font[] MarkerFont = new Font[_Theme.Legends.Count];
                                Pen PnCross = (Pen)PnTheme.Clone();
                                for (i = 0; i <= _Theme.Legends.Count - 1; i++)
                                {
                                    _Legend = _Theme.Legends[i];
                                    MarkerSize[i] = _Legend.MarkerSize;
                                    MarkerChar[i] = _Legend.MarkerChar;
                                    MarkerFont[i] = _Legend.MarkerFont;
                                    if (_Legend.MarkerType == MarkerStyle.Cross)
                                        PnCross.Color = _Legend.Color;
                                }
                                while (dicEnumerator.MoveNext())
                                {
                                    //*** Traverse Shapes
                                    _Shape = (Shape)dicEnumerator.Value;
                                    //*** BugFix 04 July 2006 Base point layer missing data rendered with 1st legend information
                                    if (_Theme.AreaIndexes.ContainsKey(_Shape.AreaId))
                                    {
                                        LegendItemIndex = (int)((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).RenderingInfo;
                                    }
                                    else
                                    {
                                        LegendItemIndex = _Theme.Legends.Count - 1;
                                    }
                                    Pt[0] = (PointF)_Shape.Parts[0];
                                    mTransMatrix.TransformPoints(Pt);
                                    switch (_Theme.Legends[LegendItemIndex].MarkerType)
                                    {
                                        case MarkerStyle.Circle:
                                            g.FillEllipse(BrLegend[LegendItemIndex], (int)Pt[0].X - MarkerSize[LegendItemIndex] / 2, (int)Pt[0].Y - MarkerSize[LegendItemIndex] / 2, MarkerSize[LegendItemIndex], MarkerSize[LegendItemIndex]);
                                            g.DrawEllipse(PnTheme, (int)Pt[0].X - MarkerSize[LegendItemIndex] / 2, (int)Pt[0].Y - MarkerSize[LegendItemIndex] / 2, MarkerSize[LegendItemIndex], MarkerSize[LegendItemIndex]);
                                            if (Lyr.SelectedArea.Contains(_Shape.AreaId))
                                                g.FillEllipse(BrSelection, (int)Pt[0].X - MarkerSize[LegendItemIndex] / 2, (int)Pt[0].Y - MarkerSize[LegendItemIndex] / 2, MarkerSize[LegendItemIndex], MarkerSize[LegendItemIndex]);

                                            break;
                                        case MarkerStyle.Square:
                                            g.FillRectangle(BrLegend[LegendItemIndex], (int)Pt[0].X - MarkerSize[LegendItemIndex] / 2, (int)Pt[0].Y - MarkerSize[LegendItemIndex] / 2, MarkerSize[LegendItemIndex], MarkerSize[LegendItemIndex]);
                                            g.DrawRectangle(PnTheme, (int)Pt[0].X - MarkerSize[LegendItemIndex] / 2, (int)Pt[0].Y - MarkerSize[LegendItemIndex] / 2, MarkerSize[LegendItemIndex], MarkerSize[LegendItemIndex]);
                                            if (Lyr.SelectedArea.Contains(_Shape.AreaId))
                                                g.FillRectangle(BrSelection, (int)Pt[0].X - MarkerSize[LegendItemIndex] / 2, (int)Pt[0].Y - MarkerSize[LegendItemIndex] / 2, MarkerSize[LegendItemIndex], MarkerSize[LegendItemIndex]);

                                            break;
                                        case MarkerStyle.Triangle:
                                            //*** 1.Equilateral triangle with altitude = MarkerSize(LegendItemIndex) 2.Equilateral triangle with sides = MarkerSize(LegendItemIndex)
                                            PointF[] Vertex = new PointF[3];
                                            int PtSize;
                                            PtSize = (int)(Math.Sqrt(3) / 4 * MarkerSize[LegendItemIndex]);
                                            Vertex[0] = new PointF(Pt[0].X - PtSize, Pt[0].Y + PtSize);
                                            //altitude = PtSize 'Vertex(0) = New PointF(pt(0).X - PtSize / 2, pt(0).Y + PtSize / 2) 'side = PtSize
                                            Vertex[1] = new PointF(Pt[0].X + PtSize, Pt[0].Y + PtSize);
                                            //altitude = PtSize 'Vertex(1) = New PointF(pt(0).X + PtSize / 2, pt(0).Y + PtSize / 2) 'side = PtSize
                                            Vertex[2] = new PointF(Pt[0].X, Pt[0].Y - PtSize);
                                            g.FillPolygon(BrLegend[LegendItemIndex], Vertex);
                                            g.DrawPolygon(PnTheme, Vertex);
                                            if (Lyr.SelectedArea.Contains(_Shape.AreaId))
                                                g.FillPolygon(BrSelection, Vertex);

                                            Vertex = null;
                                            break;
                                        case MarkerStyle.Cross:
                                            g.DrawLine(PnCross, (int)Pt[0].X - MarkerSize[LegendItemIndex] / 2, (int)Pt[0].Y, (int)Pt[0].X + MarkerSize[LegendItemIndex] / 2, (int)Pt[0].Y);
                                            g.DrawLine(PnCross, (int)Pt[0].X, (int)Pt[0].Y + MarkerSize[LegendItemIndex] / 2, (int)Pt[0].X, (int)Pt[0].Y - MarkerSize[LegendItemIndex] / 2);
                                            break;
                                        case MarkerStyle.Custom:
                                            g.DrawString(MarkerChar[LegendItemIndex].ToString(), MarkerFont[LegendItemIndex], BrLegend[LegendItemIndex], Pt[0].X, Pt[0].Y, _StringFormat);
                                            break;
                                    }
                                }
                                for (i = 0; i <= MarkerFont.Length - 1; i++)
                                {
                                    MarkerFont[i].Dispose();
                                }
                                Pt = null;
                                PnCross.Dispose();
                            }
                            g.SmoothingMode = SmoothingMode.None;
                        }
                        else if (((Lyr.LayerType == ShapeType.PointFeature & BaseLyrVisibility == true) | (Lyr.LayerType == ShapeType.PointCustom & Lyr.Visible == true)) & _Theme.Type == ThemeType.Color)
                        {
                            g.SmoothingMode = SmoothingMode.AntiAlias;
                            Pen PnLayer = new Pen(Lyr.FillColor, 0.01F);
                            Brush BrLayer = new SolidBrush(Lyr.FillColor);
                            PointF[] Pt = new PointF[1];
                            int PtSize = Lyr.MarkerSize;
                            // CInt((_Layer.MarkerSize * m_FullExtent.Width) / (8 * m_CurrentExtent.Width))
                            gpShp.Reset();
                            gpSelShp.Reset();
                            if (Lyr.MarkerStyle == MarkerStyle.Circle)
                            {
                                while (dicEnumerator.MoveNext())
                                {
                                    //*** Traverse Shapes
                                    _Shape = (Shape)dicEnumerator.Value;
                                    Pt[0] = (PointF)_Shape.Parts[0];
                                    mTransMatrix.TransformPoints(Pt);
                                    if (Lyr.SelectedArea.Contains(_Shape.AreaId))
                                    {
                                        gpSelShp.AddEllipse((int)Pt[0].X - PtSize / 2, (int)Pt[0].Y - PtSize / 2, PtSize, PtSize);
                                    }
                                    else
                                    {
                                        gpShp.AddEllipse((int)Pt[0].X - PtSize / 2, (int)Pt[0].Y - PtSize / 2, PtSize, PtSize);
                                    }
                                }
                            }
                            else if (Lyr.MarkerStyle == MarkerStyle.Square)
                            {
                                while (dicEnumerator.MoveNext())
                                {
                                    //*** Traverse Shapes
                                    _Shape = (Shape)dicEnumerator.Value;
                                    Pt[0] = (PointF)_Shape.Parts[0];
                                    mTransMatrix.TransformPoints(Pt);
                                    if (Lyr.SelectedArea.Contains(_Shape.AreaId))
                                    {
                                        gpSelShp.AddRectangle(new RectangleF(Pt[0].X - PtSize / 2, Pt[0].Y - PtSize / 2, PtSize, PtSize));
                                    }
                                    else
                                    {
                                        gpShp.AddRectangle(new RectangleF(Pt[0].X - PtSize / 2, Pt[0].Y - PtSize / 2, PtSize, PtSize));
                                    }
                                }
                            }
                            else if (Lyr.MarkerStyle == MarkerStyle.Triangle)
                            {
                                //*** 1.Equilateral triangle with altitude = PtSize 2.Equilateral triangle with sides = PtSize
                                PointF[] Vertex = new PointF[3];
                                PtSize = (int)(Math.Sqrt(3) / 4 * PtSize);
                                while (dicEnumerator.MoveNext())
                                {
                                    //*** Traverse Shapes
                                    _Shape = (Shape)dicEnumerator.Value;
                                    Pt[0] = (PointF)_Shape.Parts[0];
                                    mTransMatrix.TransformPoints(Pt);
                                    Vertex[0] = new PointF(Pt[0].X - PtSize, Pt[0].Y + PtSize);
                                    //altitude = PtSize 'Vertex(0) = New PointF(pt(0).X - PtSize / 2, pt(0).Y + PtSize / 2) 'side = PtSize
                                    Vertex[1] = new PointF(Pt[0].X + PtSize, Pt[0].Y + PtSize);
                                    //altitude = PtSize 'Vertex(1) = New PointF(pt(0).X + PtSize / 2, pt(0).Y + PtSize / 2) 'side = PtSize
                                    Vertex[2] = new PointF(Pt[0].X, Pt[0].Y - PtSize);
                                    if (Lyr.SelectedArea.Contains(_Shape.AreaId))
                                    {
                                        gpSelShp.AddPolygon(Vertex);
                                    }
                                    else
                                    {
                                        gpShp.AddPolygon(Vertex);
                                    }
                                }
                                Vertex = null;
                            }
                            else if (Lyr.MarkerStyle == MarkerStyle.Cross)
                            {
                                while (dicEnumerator.MoveNext())
                                {
                                    //*** Traverse Shapes
                                    _Shape = (Shape)dicEnumerator.Value;
                                    Pt[0] = (PointF)_Shape.Parts[0];
                                    mTransMatrix.TransformPoints(Pt);
                                    if (Lyr.SelectedArea.Contains(_Shape.AreaId))
                                    {
                                        gpSelShp.AddLine(new PointF(Pt[0].X - PtSize / 2, Pt[0].Y), new PointF(Pt[0].X + PtSize / 2, Pt[0].Y));
                                        gpSelShp.CloseFigure();
                                        gpSelShp.AddLine(new PointF(Pt[0].X, Pt[0].Y + PtSize / 2), new PointF(Pt[0].X, Pt[0].Y - PtSize / 2));
                                        gpSelShp.CloseFigure();
                                    }
                                    else
                                    {
                                        gpShp.AddLine(new PointF(Pt[0].X - PtSize / 2, Pt[0].Y), new PointF(Pt[0].X + PtSize / 2, Pt[0].Y));
                                        gpShp.CloseFigure();
                                        gpShp.AddLine(new PointF(Pt[0].X, Pt[0].Y + PtSize / 2), new PointF(Pt[0].X, Pt[0].Y - PtSize / 2));
                                        gpShp.CloseFigure();
                                    }
                                }
                            }
                            else if (Lyr.MarkerStyle == MarkerStyle.Custom)
                            {
                                Font _MFnt = new Font(Lyr.MarkerFont.FontFamily, PtSize);
                                while (dicEnumerator.MoveNext())
                                {
                                    //*** Traverse Shapes
                                    _Shape = (Shape)dicEnumerator.Value;
                                    Pt[0] = (PointF)_Shape.Parts[0];
                                    mTransMatrix.TransformPoints(Pt);
                                    if (Lyr.SelectedArea.Contains(_Shape.AreaId))
                                    {
                                        g.DrawString(Lyr.MarkerChar.ToString(), _MFnt, BrSelection, Pt[0].X, Pt[0].Y, _StringFormat);
                                    }
                                    else
                                    {
                                        g.DrawString(Lyr.MarkerChar.ToString(), _MFnt, BrLayer, Pt[0].X, Pt[0].Y, _StringFormat);
                                    }
                                }
                                _MFnt.Dispose();
                            }
                            g.FillPath(BrLayer, gpShp);
                            g.DrawPath(PnLayer, gpShp);
                            g.FillPath(BrSelection, gpSelShp);
                            g.DrawPath(PnSelection, gpSelShp);
                            Pt = null;
                            PnLayer.Dispose();
                            BrLayer.Dispose();
                            g.SmoothingMode = SmoothingMode.None;
                        }
                        ht = null;
                    }
                }
                //Lyr = null;
            }
            //Traverse Layers collection

            _Shape = null;
            for (i = 0; i <= BrLegend.Length - 1; i++)
            {
                BrLegend[i].Dispose();
            }
            PnTheme.Dispose();
            BorderHighlight.Dispose();
            BrSelection.Dispose();
            PnSelection.Dispose();
            _StringFormat.Dispose();
            gpSelShp.Dispose();
            gpShp.Dispose();
        }
Example #6
0
        /// <summary>
        /// It updates Legend settings of oldTheme into NewTheme.
        /// <para>Following Theme properties are updated: BreakCount(LegendCount), Layer's Visibility, StartColor, EndColor, Theme.Visible, Legend's Color, Decimal, BorderColor, BorderStyle, BorderWidth.
        /// </para>
        /// </summary>
        /// <param name="oldTheme">Old Theme</param>
        /// <param name="newTheme">New Theme to retain properties of old theme.</param>
        /// <param name="preserveLegendsRanges">true, if oldtheme's Legend range values to be preserved in new theme as well(applicable to Break based Themes)</param>
        public void UpdateThemeLegendSettings(Theme oldTheme, Theme newTheme, bool preserveLegendsRanges)
        {
            try
            {
                if (newTheme != null)
                {
                    // set Theme's common properties

                    //--Layer's Visibility
                    foreach (object key in oldTheme.LayerVisibility.Keys)
                    {
                        //Theme.LayerVisibility[Key, Value]
                        //Key: LayerID
                        //Value: bool
                        if (newTheme.LayerVisibility.ContainsKey(key))
                        {
                            newTheme.LayerVisibility[key] = (bool)oldTheme.LayerVisibility[key];
                        }
                    }

                    newTheme.Visible = oldTheme.Visible;

                    newTheme.BorderColor = oldTheme.BorderColor;
                    newTheme.BorderStyle = oldTheme.BorderStyle;
                    newTheme.BorderWidth = oldTheme.BorderWidth;
                    newTheme.LabelColor = oldTheme.LabelColor;
                    newTheme.LabelFont = oldTheme.LabelFont;
                    newTheme.LabelVisible = oldTheme.LabelVisible;
                    newTheme.LabelField = oldTheme.LabelField;
                    newTheme.LabelMultirow = oldTheme.LabelMultirow;
                    newTheme.LabelIndented = oldTheme.LabelIndented;

                    //-- Legend Settings
                    newTheme.StartColor = oldTheme.StartColor;
                    newTheme.EndColor = oldTheme.EndColor;
                    newTheme.BreakCount = oldTheme.BreakCount;
                    newTheme.BreakType = oldTheme.BreakType;
                    newTheme.Decimals = oldTheme.Decimals;

                    newTheme.LegendBodyColor = oldTheme.LegendBodyColor;
                    newTheme.LegendBodyFont = oldTheme.LegendBodyFont;
                    newTheme.LegendColor = oldTheme.LegendColor;
                    newTheme.LegendFont = oldTheme.LegendFont;

                    newTheme.MultiLegendCriteria = oldTheme.MultiLegendCriteria;
                    newTheme.MultiLegend = oldTheme.MultiLegend;

                    if (newTheme.Type != ThemeType.DotDensity && newTheme.Type != ThemeType.Chart)
                    {
                        newTheme.Legends.Clear();

                        this.setThemeRange(this.Themes.ItemIndex(newTheme.ID));

                        //- Preserve OldTheme's Minimum & Maximum values and Legend Ranges, Caption, Title etc.
                        if (preserveLegendsRanges)
                        {
                            newTheme.Maximum = oldTheme.Maximum;
                            newTheme.Minimum = oldTheme.Minimum;
                            for (int i = 0; i < newTheme.Legends.Count; i++)
                            {
                                if (oldTheme.Legends[i] != null)
                                {
                                    newTheme.Legends[i].Title = oldTheme.Legends[i].Title;
                                    newTheme.Legends[i].Caption = oldTheme.Legends[i].Caption;
                                    newTheme.Legends[i].RangeFrom = oldTheme.Legends[i].RangeFrom;
                                    newTheme.Legends[i].RangeTo = oldTheme.Legends[i].RangeTo;
                                    newTheme.Legends[i].Color = oldTheme.Legends[i].Color;
                                }
                            }
                            newTheme.UpdateLegendBreakCount();
                        }
                        else
                        {
                            //- update only Legend Colors
                            for (int i = 0; i < newTheme.Legends.Count; i++)
                            {
                                if (oldTheme.Legends[i] != null)
                                {
                                    newTheme.Legends[i].Color = oldTheme.Legends[i].Color;
                                }
                            }
                        }
                    }

                    switch (newTheme.Type)
                    {
                        case ThemeType.Symbol:
                            //*** Reset the Symbols legend
                            for (int i = 0; i <= newTheme.Legends.Count - 1; i++)
                            {
                                newTheme.Legends[i].MarkerType = MarkerStyle.Custom;
                                if (i < newTheme.Legends.Count - 1)
                                {
                                    newTheme.Legends[i].MarkerFont = new Font("Webdings", 10 + i * 5);
                                    newTheme.Legends[i].MarkerSize = 10 + i * 5;
                                }
                                else
                                {
                                    newTheme.Legends[i].MarkerFont = new Font("Webdings", 10);
                                    newTheme.Legends[i].MarkerSize = 10;
                                    newTheme.Legends[i].Color = Color.FromArgb(128, newTheme.MissingColor);
                                }

                                newTheme.Legends[i].MarkerChar = Strings.Chr(110);
                            }

                            break;
                        case ThemeType.Label:
                            //*** Reset the legend
                            Font fnt = new Font("Arial", 8);
                            for (int i = 0; i <= newTheme.Legends.Count - 1; i++)
                            {
                                newTheme.Legends[i].MarkerFont = fnt;
                            }

                            break;
                    }

                }

            }
            catch
            {

            }
        }
Example #7
0
 private void DrawChart(ref Graphics g, Theme _Theme, Matrix mTransMatrix, RectangleF CurExt)
 {
     bool bSearch = false;
     float PtX = 0;
     float PtY = 0;
     string LayerId = "";
     string AreaId = "";
     GraphicsPath gPath = null;
     DrawChart(ref g, _Theme, mTransMatrix, CurExt, bSearch, PtX, PtY, ref LayerId, ref AreaId, ref gPath);
 }
Example #8
0
        /// <summary>
        /// It compares two themes and updates properties of oldTheme into NewTheme.
        /// <para>Following Theme properties are updated: BreakCount(LegendCount), Layer's Visibility, StartColor, EndColor, Theme.Visible, Legend's Color, Decimal, BorderColor, BorderStyle, BorderWidth, DotColor, DotFont, DotSize, LabelColor, LabelFont, LabelVisible.
        /// </para>
        /// </summary>
        /// <param name="oldTheme">Old Theme</param>
        /// <param name="newTheme">New Theme to retain properties of old theme.</param>
        /// <param name="preserveRoundingDecimals">true, if oldtheme's rounding Decmial to be preserved in new theme as well(applicable to Break based Themes)</param>
        private void UpdateThemeProperties(Theme oldTheme, Theme newTheme, bool preserveLegendsRanges, bool preserveRoundingDecimals)
        {
            IDictionaryEnumerator dicEnumerator = null;

            try
            {
                if (newTheme != null)
                {
                    // set Theme's common properties
                    foreach (object key in oldTheme.LayerVisibility.Keys)
                    {
                        if (newTheme.LayerVisibility.ContainsKey(key))
                        {
                            newTheme.LayerVisibility[key] = (bool)oldTheme.LayerVisibility[key];
                        }
                    }

                    //--  Set Theme Name
                    if (string.IsNullOrEmpty(newTheme.Name))
                    {
                        if (newTheme.IndicatorName[0] == oldTheme.IndicatorName[0])
                        {
                            newTheme.Name = oldTheme.Name;
                        }
                        else
                        {
                            if (newTheme.Type == ThemeType.Chart)
                            {
                                newTheme.Name = newTheme.IndicatorName[0] + " - " + newTheme.UnitName[0] + " - " + newTheme.SubgroupName[0];
                            }
                            else
                            {
                                newTheme.Name = newTheme.IndicatorName[0] + " - " + newTheme.UnitName[0];
                            }
                        }
                    }

                    newTheme.Visible = oldTheme.Visible;

                    newTheme.BorderColor = oldTheme.BorderColor;
                    newTheme.BorderStyle = oldTheme.BorderStyle;
                    newTheme.BorderWidth = oldTheme.BorderWidth;
                    newTheme.LabelColor = oldTheme.LabelColor;
                    newTheme.LabelFont = oldTheme.LabelFont;
                    newTheme.LabelVisible = oldTheme.LabelVisible;
                    newTheme.LabelField = oldTheme.LabelField;
                    newTheme.LabelMultirow = oldTheme.LabelMultirow;
                    newTheme.LabelIndented = oldTheme.LabelIndented;

                    //-- Set each Layer's Label visible properties
                    foreach (Layer layer in this.Layers)
                    {
                        if (oldTheme.LabelVisible)
                        {
                            layer.LabelVisible = oldTheme.LabelVisible;
                        }

                        //- If new Layers are added in collection (i.e case of Area Replication)
                        // then apply preserved Theme's Label Settings
                        if (oldTheme.LayerVisibility.ContainsKey(layer.ID) == false)
                        {
                            layer.LabelField = oldTheme.LabelField;
                            layer.LabelMultirow = oldTheme.LabelMultirow;
                            layer.LabelIndented = oldTheme.LabelIndented;

                            //////** Label Font
                            layer.LabelFont = oldTheme.LabelFont;
                            layer.LabelColor = oldTheme.LabelColor;
                        }
                    }

                    //--Layer's Visibility
                    dicEnumerator = oldTheme.LayerVisibility.GetEnumerator();
                    while (dicEnumerator.MoveNext())
                    {
                        //Theme.LayerVisibility[Key, Value]
                        //Key: LayerID
                        //Value: bool
                        if (newTheme.LayerVisibility.ContainsKey(dicEnumerator.Key))
                        {
                            newTheme.LayerVisibility[dicEnumerator.Key] = oldTheme.LayerVisibility[dicEnumerator.Key];
                        }
                    }

                    //-- Legend Settings
                    newTheme.StartColor = oldTheme.StartColor;
                    newTheme.EndColor = oldTheme.EndColor;
                    newTheme.BreakCount = oldTheme.BreakCount;
                    newTheme.BreakType = oldTheme.BreakType;
                    if (preserveRoundingDecimals)
                    {
                        newTheme.Decimals = oldTheme.Decimals;
                    }

                    newTheme.LegendBodyColor = oldTheme.LegendBodyColor;
                    newTheme.LegendBodyFont = oldTheme.LegendBodyFont;
                    newTheme.LegendColor = oldTheme.LegendColor;
                    newTheme.LegendFont = oldTheme.LegendFont;

                    newTheme.MultiLegendCriteria = oldTheme.MultiLegendCriteria;
                    newTheme.MultiLegend = oldTheme.MultiLegend;

                    if (newTheme.Type != ThemeType.DotDensity && newTheme.Type != ThemeType.Chart)
                    {
                        newTheme.Legends.Clear();

                        this.setThemeRange(this.Themes.ItemIndex(newTheme.ID));

                        //- Preserve OldTheme's Minimum & Maximum values and Legend Ranges, Caption, Title etc.
                        if (preserveLegendsRanges)
                        {
                            newTheme.Maximum = oldTheme.Maximum;
                            newTheme.Minimum = oldTheme.Minimum;
                            for (int i = 0; i < newTheme.Legends.Count; i++)
                            {
                                if (oldTheme.Legends[i] != null)
                                {
                                    newTheme.Legends[i].Title = oldTheme.Legends[i].Title;
                                    newTheme.Legends[i].Caption = oldTheme.Legends[i].Caption;
                                    newTheme.Legends[i].RangeFrom = oldTheme.Legends[i].RangeFrom;
                                    newTheme.Legends[i].RangeTo = oldTheme.Legends[i].RangeTo;
                                }
                            }
                            newTheme.UpdateLegendBreakCount();
                        }
                    }

                    //-Set Legend Title only if OldTReme's  IUS is same as NewTheme's IUS
                    if (newTheme.I_U_S_GIDs.Length == oldTheme.I_U_S_GIDs.Length)
                    {
                        if (newTheme.I_U_S_GIDs[0] == oldTheme.I_U_S_GIDs[0] && newTheme.I_U_S_GIDs[0] == oldTheme.I_U_S_GIDs[0] && newTheme.I_U_S_GIDs[0] == oldTheme.I_U_S_GIDs[0])
                        {
                            newTheme.LegendTitle = oldTheme.LegendTitle;
                        }
                    }

                    //-- set Theme Type specific properties
                    switch (oldTheme.Type)
                    {
                        case ThemeType.Color:
                            // set Legend Colors
                            for (int i = 0; i < newTheme.Legends.Count; i++)
                            {
                                if (oldTheme.Legends[i] != null)
                                {
                                    newTheme.Legends[i].Color = oldTheme.Legends[i].Color;
                                }
                            }

                            //MultiLegends  TODO confirm
                            if (oldTheme.MultiLegend == true)
                            {
                                newTheme.MultiLegend = oldTheme.MultiLegend;
                                newTheme.MultiLegendCriteria = oldTheme.MultiLegendCriteria;
                                newTheme.MultiLegendCol.Clear();
                                foreach (object m_Keys in oldTheme.MultiLegendCol.Keys)
                                {
                                    newTheme.MultiLegendCol.Add(m_Keys, oldTheme.MultiLegendCol[m_Keys]);
                                }
                            }

                            break;
                        case ThemeType.DotDensity:
                            newTheme.DotColor = oldTheme.DotColor;
                            newTheme.DotFont = oldTheme.DotFont;
                            newTheme.DotSize = oldTheme.DotSize;
                            newTheme.DotChar = oldTheme.DotChar;
                            newTheme.DotStyle = oldTheme.DotStyle;
                            newTheme.DotValue = oldTheme.DotValue;
                            break;
                        case ThemeType.Chart:
                            newTheme.Name = oldTheme.Name;
                            newTheme.ChartLeaderColor = oldTheme.ChartLeaderColor;
                            newTheme.ChartLeaderStyle = oldTheme.ChartLeaderStyle;
                            newTheme.ChartLeaderVisible = oldTheme.ChartLeaderVisible;
                            newTheme.ChartLeaderWidth = oldTheme.ChartLeaderWidth;
                            newTheme.RoundDecimals = oldTheme.RoundDecimals;
                            newTheme.ColumnsGap = oldTheme.ColumnsGap;
                            newTheme.ShowChartAxis = oldTheme.ShowChartAxis;
                            newTheme.ChartSize = oldTheme.ChartSize;
                            newTheme.ChartType = oldTheme.ChartType;
                            newTheme.ChartWidth = oldTheme.ChartWidth;
                            newTheme.DisplayChartData = oldTheme.DisplayChartData;
                            newTheme.ChartSeriestype = oldTheme.ChartSeriestype;
                            newTheme.DisplayChartMRD = oldTheme.DisplayChartMRD;
                            newTheme.PieAutoSize = oldTheme.PieAutoSize;
                            newTheme.PieSize = oldTheme.PieSize;
                            newTheme.PieAutoSizeFactor = oldTheme.PieAutoSizeFactor;
                            newTheme.ChartLineThickness = oldTheme.ChartLineThickness;
                            newTheme.ChartAxisLabelSettings = oldTheme.ChartAxisLabelSettings;
                            newTheme.ChartDataLabelSettings = oldTheme.ChartDataLabelSettings;

                            newTheme.ExcludeAreaIDs = oldTheme.ExcludeAreaIDs;

                            if (newTheme.SubgroupNId.Length == oldTheme.SubgroupNId.Length)
                            {
                                newTheme.SubgroupVisible = oldTheme.SubgroupVisible;
                                newTheme.SubgroupFillStyle = oldTheme.SubgroupFillStyle;
                            }

                            if (newTheme.SourceNIds != null && oldTheme.SourceNIds != null)
                            {
                                if (newTheme.SourceNIds.Length == oldTheme.SourceNIds.Length)
                                {
                                    newTheme.SourceVisible = oldTheme.SourceVisible;
                                }
                            }

                            for (int i = 0; i < Math.Min(newTheme.ChartTimePeriods.Count, oldTheme.ChartTimePeriods.Count); i++)
                            {
                                string timePeriodKey = oldTheme.ChartTimePeriods.Keys[i];
                                if (oldTheme.ChartTimePeriods.ContainsKey(timePeriodKey))
                                {
                                    newTheme.ChartTimePeriods[timePeriodKey] = oldTheme.ChartTimePeriods[timePeriodKey];
                                }
                            }
                            foreach (object key in oldTheme.ModifiedCharts.Keys)
                            {
                                if (newTheme.ModifiedCharts.ContainsKey(key) == false)
                                {
                                    newTheme.ModifiedCharts.Add(key, oldTheme.ModifiedCharts[key]);
                                }
                            }

                            break;
                        case ThemeType.Hatch:
                            for (int i = 0; i < newTheme.Legends.Count; i++)
                            {
                                newTheme.Legends[i].Color = oldTheme.Legends[i].Color;
                                newTheme.Legends[i].FillStyle = oldTheme.Legends[i].FillStyle;
                            }
                            break;
                        case ThemeType.Symbol:
                            // set Legend Symbols
                            for (int i = 0; i < newTheme.Legends.Count; i++)
                            {
                                if (oldTheme.Legends[i] != null)
                                {
                                    newTheme.Legends[i].Color = oldTheme.Legends[i].Color;
                                    newTheme.Legends[i].SymbolImage = oldTheme.Legends[i].SymbolImage;
                                    newTheme.Legends[i].MarkerType = oldTheme.Legends[i].MarkerType;
                                    newTheme.Legends[i].MarkerSize = oldTheme.Legends[i].MarkerSize;
                                    newTheme.Legends[i].MarkerFont = oldTheme.Legends[i].MarkerFont;
                                    newTheme.Legends[i].MarkerChar = oldTheme.Legends[i].MarkerChar;
                                }
                            }

                            newTheme.X_Offset = oldTheme.X_Offset;
                            newTheme.Y_Offset = oldTheme.Y_Offset;
                            break;
                        case ThemeType.Label:
                            newTheme.LabelField = oldTheme.LabelField;
                            for (int i = 0; i < newTheme.Legends.Count; i++)
                            {
                                if (oldTheme.Legends[i] != null)
                                {
                                    newTheme.Legends[i].Color = oldTheme.Legends[i].Color;
                                    newTheme.Legends[i].MarkerFont = oldTheme.Legends[i].MarkerFont;
                                }
                            }

                            newTheme.X_Offset = oldTheme.X_Offset;
                            newTheme.Y_Offset = oldTheme.Y_Offset;

                            break;
                        default:
                            break;
                    }

                }

            }
            catch
            {

            }
        }
Example #9
0
        public Theme CreateTheme(string p_IndicatorNId, string p_UnitNId, string p_SubgroupValNId, ThemeType p_ThemeType, ChartType chartType, ChartSeriesType chartGroupBy, int p_Position)
        {
            //*** Create New Theme.
            Theme RetVal = null;
            string sSubgroupValNId = string.Empty;
            string sRowFilter = string.Empty;
            string DefaultIndicatorNId = string.Empty;
            string DefaultUnitNId = string.Empty;

            foreach (Theme _TempTheme in m_Themes)
            {
                if (_TempTheme.ID == p_IndicatorNId + "_" + p_UnitNId + "_" + p_SubgroupValNId + "_" + ((int)p_ThemeType).ToString())
                {
                    //If theme already exists exception will be thrown
                    throw new ApplicationException("3"); //TODO return null or some other approach
                }
            }

            Theme _Theme = new Theme();
            DataView _ThemeData;

            //-- If indicatorNID and UnitNId are -1 ,then Get default indicatorNId , UnitNIds from PresentationData's first row.
            //-- It is required because, for creating any theme (Chart or color) first time, we need some indicator, unit NIDs.
            if (p_IndicatorNId == "-1")
            {
                DefaultIndicatorNId = this.MRDData[0][Indicator.IndicatorNId].ToString();
                sRowFilter += Indicator.IndicatorNId + " IN (" + DefaultIndicatorNId + ")";
            }
            else
            {
                sRowFilter += Indicator.IndicatorNId + " IN (" + p_IndicatorNId + ")";
                DefaultIndicatorNId = p_IndicatorNId;
            }

            if (p_UnitNId == "-1")
            {
                DefaultUnitNId = this.MRDData[0][Unit.UnitNId].ToString();
                sRowFilter += " AND " + Unit.UnitNId + " IN (" + DefaultUnitNId + ")";
            }
            else
            {
                sRowFilter += " AND " + Unit.UnitNId + " IN (" + p_UnitNId + ")";
                DefaultUnitNId = p_UnitNId;
            }

            //DataTable SubGroupDataTable = DIConnection.ExecuteDataTable(DIQueries.IUS.GetSubgroupValByIU(Convert.ToInt32(DefaultIndicatorNId), Convert.ToInt32(DefaultUnitNId)));

            if (p_ThemeType == ThemeType.Chart)
            {
                string sSql = string.Empty;
                //foreach (DataRow dr in SubGroupDataTable.Rows)
                foreach (DataRow dr in this.GetSubgroupsNIDsBy_IndicatorUnit(DefaultIndicatorNId, DefaultUnitNId).Rows)
                {
                    if (sSubgroupValNId.Length > 0)
                    {
                        sSubgroupValNId += ",";
                    }
                    sSubgroupValNId += dr[SubgroupVals.SubgroupValNId].ToString();
                }
                if (!string.IsNullOrEmpty(sSubgroupValNId))
                {
                    //Get all records for Selected Indicator, Subgroups and Unit
                    sRowFilter = Indicator.IndicatorNId + " IN (" + DefaultIndicatorNId + ") AND " + Unit.UnitNId + " IN (" + DefaultUnitNId + ") AND " + SubgroupVals.SubgroupValNId + " IN (" + sSubgroupValNId + ")";
                }
                else
                {
                    sRowFilter = Indicator.IndicatorNId + " IN (" + DefaultIndicatorNId + ") AND " + Unit.UnitNId + " IN (" + DefaultUnitNId + ")";
                }

                //////-- If Pie chart, then TimeSeries shud be OFF. Use MRD data
                ////if (chartType == ChartType.Pie)
                ////{
                ////    this.MRDData.RowFilter = sRowFilter;
                ////    _ThemeData = new DataView(this.MRDData.ToTable());
                ////    this.MRDData.RowFilter = "";
                ////}
                ////else
                ////{
                ////    this.PresentationData.RowFilter = sRowFilter;
                ////    _ThemeData = new DataView(this.PresentationData.ToTable());
                ////    this.PresentationData.RowFilter = "";
                ////}

                this.PresentationData.RowFilter = sRowFilter;
                _ThemeData = new DataView(this.PresentationData.ToTable());
                this.PresentationData.RowFilter = "";
            }
            else
            {
                //_ThemeData = m_QueryBase.Map_GetData(int.Parse(p_IndicatorNId), int.Parse(p_UnitNId), int.Parse(p_Subgroup_NId), 0, -1);
                //_ThemeData = this.MRDData;

                if (p_SubgroupValNId == "-1")
                {
                    //-- Set Subgroup filter only for new theme case.
                    //-- In case of Subgroup = Select all case discard subgroup filter
                    if (p_IndicatorNId == "-1" && p_UnitNId == "-1" && p_SubgroupValNId == "-1")
                    {
                        sRowFilter += " AND " + SubgroupVals.SubgroupValNId + " IN (" + MRDData[0][SubgroupVals.SubgroupValNId] + ")";
                    }
                    else
                    {
                        //-- SubgroupNid = -1 and IndicatorNid <> -1 , indicates that Subgroup = "Select ALL" case.
                        //-- then set bool variable of Theme.SubgroupSelectAll = true
                        _Theme.SubgroupSelectAll = true;
                    }
                }
                else
                {
                    sRowFilter += " AND " + SubgroupVals.SubgroupValNId + " IN (" + p_SubgroupValNId + ")";
                }
                this.MRDData.RowFilter = sRowFilter;
                _ThemeData = new DataView(this.MRDData.ToTable());
                this.MRDData.RowFilter = "";

            }

            //--Ckeck if Theme Data Has some record. Exit function if NO record Found.
            if (_ThemeData.Count > 0)
            {

                //*** Add Metadata Columns
                int i;

                if (_ThemeData.Count == 0)
                {
                    throw new ApplicationException("5");
                }

                //*** Update Metadata Column values if metadata column exists
                //UpdateMetadataInfo(ref _ThemeData);

                //GenerateLayerInformation(_Theme, _ThemeData)

                foreach (Layer _Layer in m_Layers)
                {
                    {
                        if (!_Theme.LayerVisibility.ContainsKey(_Layer.ID))
                        {
                            switch (_Layer.LayerType)
                            {
                                case ShapeType.Point:
                                case ShapeType.Polygon:
                                case ShapeType.PolyLine:
                                    _Theme.LayerVisibility.Add(_Layer.ID, true);
                                    break;
                                case ShapeType.PointFeature:
                                case ShapeType.PolygonFeature:
                                case ShapeType.PolyLineFeature:
                                    _Theme.LayerVisibility.Add(_Layer.ID, false);
                                    break;
                            }
                        }
                    }
                }
                // _Layer = null;

                //object[] oMDKeys = new object[MDKeys.Keys.Count];
                //MDKeys.Keys.CopyTo(oMDKeys, 0);
                object[] oMDKeys = this.MDColumns;
                _Theme.MetaDataKeys = oMDKeys;
                _Theme.Type = p_ThemeType;

                //_Theme.LegendTitle = _ThemeData[0][Unit.UnitName].ToString();;
                _Theme.SetLegendTitle(_ThemeData[0][Indicator.IndicatorName].ToString(), _ThemeData[0][Unit.UnitName].ToString(), _ThemeData[0][SubgroupVals.SubgroupVal].ToString());

                //*** Bugfix 26 Apr 2006 For the second map theme, the legend doesn’t automatically append a title…
                _Theme.StartColor = m_FirstColor;
                _Theme.EndColor = m_FourthColor;
                if ((m_Layers.RecordCounts() == 0) || m_Layers.RecordCounts() == 0)
                {
                    _Theme.ShapeCount = m_Layers.RecordCounts(m_SpatialMapFolder);
                }
                else
                {
                    _Theme.ShapeCount = m_Layers.RecordCounts();
                }

                _Theme.MissingColor = this._MissingColor;

                switch (_Theme.Type)
                {
                    case ThemeType.Color:
                        _Theme.SetRange(_ThemeData);
                        _Theme.Legends[0].Color = FirstColor;
                        _Theme.Legends[1].Color = SecondColor;
                        _Theme.Legends[2].Color = ThirdColor;
                        _Theme.Legends[3].Color = FourthColor;
                        _Theme.Legends[_Theme.Legends.Count - 1].Caption = m_MissingValue;
                        _Theme.BreakType = BreakType.Continuous;
                        //$$$ By Default create the theme on the basis of equal count and set it as continuous
                        break;
                    case ThemeType.Hatch:
                        _Theme.SetRange(_ThemeData);
                        _Theme.Legends[0].Color = Color.LightGray;
                        _Theme.Legends[1].Color = Color.LightGray;
                        _Theme.Legends[2].Color = Color.LightGray;
                        _Theme.Legends[3].Color = Color.LightGray;
                        _Theme.Legends[_Theme.Legends.Count - 1].Caption = m_MissingValue;
                        _Theme.BreakType = BreakType.Continuous;
                        //$$$ By Default create the theme on the basis of equal count and set it as continuous
                        break;
                    case ThemeType.Symbol:
                        _Theme.SetRange(_ThemeData);
                        for (i = 0; i <= _Theme.Legends.Count - 1; i++)
                        {
                            _Theme.Legends[i].MarkerType = MarkerStyle.Custom;
                            _Theme.Legends[i].MarkerChar = Strings.Chr(110);            //-- (65 + i)  - previous used
                            if (i <= 3)
                            {
                                //-- Default color is red for all with 50% transparency
                                _Theme.Legends[i].Color = Color.FromArgb(128, 255, 0, 0);
                                _Theme.Legends[i].MarkerFont = new Font("Webdings", 10 + i * 5);
                                _Theme.Legends[i].MarkerSize = 10 + i * 5;
                            }
                            else
                            {
                                //-- Missing legend info
                                _Theme.Legends[i].Color = Color.FromArgb(128, _Theme.MissingColor);
                                _Theme.Legends[i].MarkerFont = new Font("Webdings", 10);
                                _Theme.Legends[i].MarkerSize = 10;
                            }
                        }

                        _Theme.Legends[_Theme.Legends.Count - 1].Caption = m_MissingValue;
                        _Theme.BreakType = BreakType.Continuous;
                        //$$$ By Default create the theme on the basis of equal count and set it as continuous
                        break;
                    case ThemeType.Label:
                        _Theme.SetRange(_ThemeData);
                        Font fnt = new Font("Arial", 8);
                        for (i = 0; i <= _Theme.Legends.Count - 1; i++)
                        {
                            switch (i)
                            {
                                case 0:
                                    _Theme.Legends[i].Color = Color.FromArgb(255 - FirstColor.R, 255 - FirstColor.G, 255 - FirstColor.B);
                                    break;
                                case 1:
                                    _Theme.Legends[i].Color = Color.FromArgb(255 - SecondColor.R, 255 - SecondColor.G, 255 - SecondColor.B);
                                    break;
                                case 2:
                                    _Theme.Legends[i].Color = Color.FromArgb(255 - ThirdColor.R, 255 - ThirdColor.G, 255 - ThirdColor.B);
                                    break;
                                case 3:
                                    _Theme.Legends[i].Color = Color.FromArgb(255 - FourthColor.R, 255 - FourthColor.G, 255 - FourthColor.B);
                                    break;
                                default:    //Missing Data
                                    _Theme.Legends[i].Color = Color.LightYellow;
                                    break;
                            }
                            _Theme.Legends[i].MarkerFont = fnt;
                        }

                        _Theme.Legends[_Theme.Legends.Count - 1].Caption = m_MissingValue;
                        _Theme.BreakType = BreakType.Continuous;
                        //$$$ By Default create the theme on the basis of equal count and set it as continuous
                        break;
                    case ThemeType.DotDensity:
                        _Theme.DotSize = 3;
                        _Theme.SetThemeId(ref _ThemeData);
                        CalcDotDensity(_ThemeData, ref _Theme);
                        break;
                    case ThemeType.Chart:

                        //-- Chart dataValue are plotted against multiple SubgroupVal OR Sources.
                        _Theme.ChartSeriestype = chartGroupBy;
                        _Theme.ChartType = chartType;

                        //-- Get SubgroupValNIDs which are available in ThemeData
                        sSubgroupValNId = string.Empty;
                        // foreach (DataRow drow in SubGroupDataTable.Rows)
                        foreach (DataRow drow in _ThemeData.ToTable(true, SubgroupVals.SubgroupValNId).Rows)
                        {
                            if (sSubgroupValNId.Length == 0)
                            {
                                sSubgroupValNId = drow[SubgroupVals.SubgroupValNId].ToString();
                            }
                            else
                            {
                                sSubgroupValNId += "," + drow[SubgroupVals.SubgroupValNId].ToString();
                            }
                        }
                        string[] _Inds = Strings.Split(DefaultIndicatorNId, ",", -1, CompareMethod.Text);
                        string[] _SPs = Strings.Split(sSubgroupValNId, ",", -1, CompareMethod.Text);

                        //*** Bugfix 15 June 2006 Improper Max data value for Chart theme type
                        //float MinVal = 0;
                        //float MaxVal = 0;
                        //GetMinMaxDataValue(ref _ThemeData, ref MinVal, ref MaxVal);
                        //_Theme.Minimum = MinVal;
                        //_Theme.Maximum = MaxVal;

                        _ThemeData.Sort = DataExpressionColumns.DataType + " ASC," + DataExpressionColumns.NumericData + " ASC";
                        _Theme.Minimum = (decimal)_ThemeData[0][DataExpressionColumns.NumericData];
                        _Theme.Maximum = (decimal)_ThemeData[_ThemeData.Count - 1][DataExpressionColumns.NumericData];

                        if (chartGroupBy == ChartSeriesType.Subgroup)
                        {
                            //-- ChartGroupBy will be Subgroup by default.
                            MakeChartTheme(_Inds, _SPs, _ThemeData, _Theme);
                        }

                        if (_Theme.ChartType != ChartType.Line)
                        {
                            _Theme.DisplayChartMRD = true;      //-- default
                        }

                        //color array
                        string[] _IndColor = new string[_Inds.Length];
                        VBMath.Randomize();
                        for (i = 0; i <= _Inds.Length - 1; i++)
                        {
                            //Initially it was VBMath.rnd() function using for getting random no.
                            _IndColor[i] = Color.FromArgb((int)(_random.NextDouble() * 255), (int)(_random.NextDouble() * 255), (int)(_random.NextDouble() * 255)).Name;
                        }

                        string _INDName = "";
                        string _INDNid = "";
                        string _SPName = "";
                        string _SPNId = "";

                        string sSql = DIQueries.IUS.GetIUSNIdByI_U_S(DefaultIndicatorNId, "", "");
                        System.Data.IDataReader dr = DIConnection.ExecuteReader(sSql);
                        string sIUSNIds = string.Empty;
                        while (dr.Read())
                        {
                            if (sIUSNIds.Length > 0)
                                sIUSNIds += ",";
                            sIUSNIds += dr[Indicator_Unit_Subgroup.IUSNId].ToString();
                        }
                        dr.Close();
                        dr.Dispose();

                        sSql = DIQueries.IUS.GetIUS(FilterFieldType.NId, sIUSNIds, FieldSelection.Light);
                        DataView _Dv = DIConnection.ExecuteDataTable(sSql).DefaultView;

                        //DataView _Dv = m_QueryBase.Indicator_GetIUSSelections(p_IndicatorNId, sSubgroup_NId, -1);   //Default p_UnitNId = -1 is passed as defined in function signaure.
                        string[] SubGroupArr;
                        SubGroupArr = sSubgroupValNId.Split(',');
                        for (i = 0; i <= SubGroupArr.Length - 1; i++)
                        {
                            _Dv.RowFilter = "Subgroup_Val_NId = " + SubGroupArr[i];
                            if (_INDNid.IndexOf("{~}" + _Dv[0]["Indicator_NId"].ToString() + "@") == -1)
                            {
                                if (_INDName.Length > 0)
                                    _INDName += "{~}";
                                _INDNid += "{~}";
                                _INDName += _Dv[0]["Indicator_Name"].ToString();
                                _INDNid += _Dv[0]["Indicator_NId"].ToString() + "@";

                                _Theme.UnitName = _Dv[0]["Unit_Name"].ToString();

                            }

                            if (_SPNId.IndexOf("{~}" + _Dv[0]["Subgroup_Val_NId"].ToString() + "@") == -1)
                            {
                                if (_SPName.Length > 0)
                                    _SPName += "{~}";
                                _SPNId += "{~}";
                                _SPName += _Dv[0]["Subgroup_Val"].ToString();
                                _SPNId += _Dv[0]["Subgroup_Val_NId"].ToString() + "@";
                            }
                        }
                        _INDNid = _INDNid.Replace("@", "");
                        _SPNId = _SPNId.Replace("@", "");
                        _Theme.IndicatorName = Strings.Split(_INDName, "{~}", -1, CompareMethod.Text);
                        _Theme.IndicatorNId = Strings.Split(_INDNid, "{~}", -1, CompareMethod.Text);
                        _Theme.SubgroupName = Strings.Split(_SPName, "{~}", -1, CompareMethod.Text);
                        _Theme.SubgroupNId = Strings.Split(_SPNId, "{~}", -1, CompareMethod.Text);
                        _Theme.UnitNId = int.Parse(DefaultUnitNId);     //p_unitNid

                        _Theme.IndicatorColor = _IndColor;

                        p_IndicatorNId = DefaultIndicatorNId;
                        p_UnitNId = DefaultUnitNId;

                        string[] _SPFill = new string[_Theme.SubgroupName.Length];
                        string[] _SPVisible = new string[_Theme.SubgroupName.Length];
                        for (i = 0; i <= _Theme.SubgroupName.Length - 1; i++)
                        {
                            //Initiallly it was VBMath.rnd() function using for getting random no.
                            //-- Default transparency is 60% i.e 153 value.
                            _SPFill[i] = Color.FromArgb(153, (int)(_random.NextDouble() * 255), (int)(_random.NextDouble() * 255), (int)(_random.NextDouble() * 255)).ToArgb().ToString();
                            _SPVisible[i] = "1";
                        }

                        _Theme.SubgroupFillStyle = _SPFill;
                        _Theme.SubgroupVisible = _SPVisible;

                        //--If ChartGroupBy = source, then update Chart accordingly
                        if (chartGroupBy == ChartSeriesType.Source)
                        {
                            //-- Take default subgroupNId
                            string SubgroupNIdForSource = p_SubgroupValNId;

                            if (SubgroupNIdForSource == "-1")
                            {
                                //-- Take first subgroup in collection
                                SubgroupNIdForSource = _Theme.SubgroupNId[0];
                            }
                            this.UpdateChartForMultipleSource(SubgroupNIdForSource, ref _Theme);
                        }
                        break;
                }

                if (p_IndicatorNId == "-1" & p_UnitNId == "-1" & p_SubgroupValNId == "-1")
                {
                }
                else
                {
                    if (p_UnitNId == "-1")
                    {
                        _Theme.UnitNId = -1;
                    }

                    if (p_SubgroupValNId == "-1" && _Theme.SubgroupNId.Length > 0 && _Theme.SubgroupNId[0] == "-1")
                    {
                        string[] SNID = new string[1];
                        SNID[0] = "-1";
                        _Theme.SubgroupNId = SNID;
                    }
                    _Theme.ID = p_IndicatorNId + "_" + p_UnitNId + "_" + p_SubgroupValNId + "_" + (int)p_ThemeType;
                    //$$$ Convention for Theme Id -> I_U_S_ThemeType
                }

                //-- Save GIDs of Indicator, Unit, Subgroups used in theme creation.
                _Theme.I_U_S_GIDs = this.GetI_U_S_GIDsByNids(this.DIDataView.MainDataTable.DefaultView, DefaultIndicatorNId, DefaultUnitNId, _Theme.SubgroupNId[0]);

                if (p_Position == -1)
                {
                    m_Themes.Add(_Theme);
                }
                else
                {
                    m_Themes.Insert(p_Position, _Theme);
                }
            }

            //- Apply Default setting of Map.TemplateStyle
            if (this.TemplateStyle != null)
            {
                _Theme.LegendFont = new Font(this.TemplateStyle.LegendTitle.FontTemplate.FontName, this.TemplateStyle.LegendTitle.FontTemplate.FontSize, this.TemplateStyle.LegendTitle.FontTemplate.FontStyle);
                _Theme.LegendColor = this.TemplateStyle.LegendTitle.FontTemplate.ForeColor;

                _Theme.LegendBodyFont = new Font(this.TemplateStyle.Legends.FontTemplate.FontName, this.TemplateStyle.Legends.FontTemplate.FontSize, this.TemplateStyle.Legends.FontTemplate.FontStyle);
                _Theme.LegendBodyColor = this.TemplateStyle.Legends.FontTemplate.ForeColor;
            }

            RetVal = _Theme;

            return RetVal;
        }
Example #10
0
        private void MakeChartTheme(string[] p_indicator, string[] p_Subgroup, DataView p_ThemeData, Theme p_Theme)
        {
            string _Value = string.Empty;
            string ChartDataTimeKey = string.Empty; // Key represents TimePeriod.
            string _RowFilter = p_ThemeData.RowFilter;
            string _LocalFilter = "";
            string[] SubgroupArray = null;
            string ID = string.Empty;
            string[] ChartSeriesTypeNIDs = null;
            bool DataFoundForTimePeriod = false;
            string ChartMRD = string.Empty;

            //--IMP: some dataValue might have decimal,
            //--and in French Setting, decimals are treated as "," which was causing error while rendering ChartMap

            //-- Set Culture Info setting to US-English, and then reset original CultureSetting at the end.
            //-- Get the current culture.
            System.Globalization.CultureInfo OldCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
            //-- Reset the culture to english - US
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

            //-- set Chart Series NIds on the basis of Source(multiple Sources) OR Subgroup ( Multiple Subgroups)
            if (p_Theme.ChartSeriestype == ChartSeriesType.Source)
            {
                ChartSeriesTypeNIDs = p_Theme.SourceNIds;
            }
            else
            {
                ChartSeriesTypeNIDs = p_Subgroup;
            }

            //object[] oMDKeys = new object[MDKeys.Keys.Count];
            //MDKeys.Keys.CopyTo(oMDKeys, 0);

            object[] oMDKeys = this.MDColumns;
            {
                //p_Theme.ChartVisibleTimePeriods.Clear();
                p_Theme.ChartTimePeriods.Clear();

                foreach (DataRowView _DRV in p_ThemeData)
                {
                    if (!p_Theme.AreaIndexes.ContainsKey((string)_DRV[Area.AreaID]))
                    {
                        ID = (string)_DRV[Area.AreaID];
                        _Value = "";
                        ChartMRD = "";
                        AreaInfo _AreaInfo = new AreaInfo();
                        _AreaInfo.ChartData = new Hashtable();
                        {
                            _AreaInfo.IndicatorGID = (string)_DRV[Indicator.IndicatorGId];
                            _AreaInfo.SubgroupGID = (string)_DRV[SubgroupVals.SubgroupValGId];
                            _AreaInfo.UnitGID = (string)_DRV[Unit.UnitGId];
                            _AreaInfo.Subgroup = (string)_DRV[SubgroupVals.SubgroupVal];
                            _AreaInfo.Time = (string)_DRV[Timeperiods.TimePeriod];
                            _AreaInfo.AreaName = (string)_DRV[Area.AreaName];
                            _AreaInfo.Source = (string)_DRV[IndicatorClassifications.ICName];

                            //*** Metadata
                            _AreaInfo.MDFldVal = new Hashtable();
                            for (int i = 0; i <= oMDKeys.Length - 1; i++)
                            {
                                if (p_ThemeData.Table.Columns.Contains(oMDKeys[i].ToString()))
                                {
                                    _AreaInfo.MDFldVal.Add(oMDKeys[i], _DRV[(string)oMDKeys[i]]);
                                }
                            }

                            _AreaInfo.DataValue = (decimal)Conversion.Val(_DRV[DataExpressionColumns.NumericData]);
                            //.RenderingInfo = CInt(Val(_DRV("Data_Value")) * _Count / p_Theme.Maximum)

                            //-- Loop each timeperiod and Get Delimieted dataValue for multiple Source/Subgroup
                            foreach (DataRowView drow in this.GetTimePeriods())
                            {
                                _Value = "";
                                ChartDataTimeKey = string.Empty;
                                DataFoundForTimePeriod = false;
                                foreach (string _Ind in p_indicator)
                                {
                                    foreach (string _SP in ChartSeriesTypeNIDs)
                                    {
                                        //-- Apply RowFilter
                                        _LocalFilter = " Indicator_Nid=" + (string)_Ind + " AND Area_NId=" + _DRV["Area_NId"].ToString();

                                        //In Pie chart - Multiple Subgroups , No timePeriod, NO Sources
                                        if (p_Theme.ChartType == ChartType.Pie)
                                        {
                                            _LocalFilter += " AND Subgroup_Val_NId=" + (string)_SP;
                                        }
                                        else
                                        {
                                            //- In Bar/Line chart, timeSeries will be ON, with multiple Source/Subgroups.
                                            if (p_Theme.ChartSeriestype == ChartSeriesType.Source)
                                            {
                                                _LocalFilter += " AND Subgroup_Val_NId=" + (string)p_Subgroup[0];
                                                _LocalFilter += " AND " + IndicatorClassifications.ICNId + " = " + (string)_SP;
                                            }
                                            else if (p_Theme.ChartSeriestype == ChartSeriesType.Subgroup)
                                            {
                                                _LocalFilter += " AND Subgroup_Val_NId=" + (string)_SP;
                                            }
                                        }

                                        _LocalFilter += " AND " + Timeperiods.TimePeriod + " = '" + drow[Timeperiods.TimePeriod].ToString() + "'";

                                        if (_RowFilter.Length > 0)
                                        {
                                            p_ThemeData.RowFilter += " AND " + _LocalFilter;
                                        }
                                        else
                                        {
                                            p_ThemeData.RowFilter = _LocalFilter;
                                        }
                                        //-- Get chart Data
                                        if (_Value.Length > 0)
                                            _Value += ",";

                                        if (p_ThemeData.Count > 0)
                                        {
                                            DataFoundForTimePeriod = true;      // indicating that data is found for at least one Subgroup/Source
                                            _Value += (p_ThemeData[0][DataExpressionColumns.NumericData]).ToString();
                                            ChartDataTimeKey = p_ThemeData[0][Timeperiods.TimePeriod].ToString();

                                            //-Set TimePeriod visibilty true (default)
                                            if (p_Theme.ChartTimePeriods.Keys.Contains(ChartDataTimeKey) == false)
                                            {
                                                //p_Theme.ChartVisibleTimePeriods.Add(ChartDataTimeKey);
                                                p_Theme.ChartTimePeriods.Add(ChartDataTimeKey, true);
                                            }
                                        }
                                        else
                                        {
                                            if (ChartDataTimeKey.Length == 0)
                                            {
                                                ChartDataTimeKey = drow[Timeperiods.TimePeriod].ToString();
                                            }
                                            // then insert '{^}' so that Pie chart can sense the 0 value for given SubgroupVal
                                            _Value += "{^}";
                                        }

                                        p_ThemeData.RowFilter = _RowFilter;

                                    }
                                }

                                if (DataFoundForTimePeriod)
                                {
                                    _Value = _Value.Replace("{^}", "");

                                    //_AreaInfo.ChartData = _Value;
                                    _AreaInfo.ChartData.Add(ChartDataTimeKey, _Value);
                                }
                                ////if (p_Theme.ChartType == ChartType.Pie)
                                ////{
                                ////    break;  // Only one TimePeriod is needed.
                                ////}
                            }
                        }

                        //-- Get Most recent Data for IUS + Area + Souce
                        foreach (string _SGNId in ChartSeriesTypeNIDs)
                        {
                            if (p_Theme.ChartSeriestype == ChartSeriesType.Subgroup)
                            {
                                ChartMRD += "," + this.GetMRDForThemeArea(p_ThemeData, p_indicator[0], string.Empty, (string)_SGNId, _DRV[Area.AreaNId].ToString(), string.Empty);
                            }
                            else if (p_Theme.ChartSeriestype == ChartSeriesType.Source)
                            {
                                ChartMRD += "," + this.GetMRDForThemeArea(p_ThemeData, p_indicator[0], string.Empty, p_Subgroup[0], _DRV[Area.AreaNId].ToString(), (string)_SGNId);
                            }
                        }

                        _AreaInfo.ChartMostRecentData = ChartMRD.Substring(1);  //removing first comma
                        _AreaInfo.ChartMostRecentDataCopy = ChartMRD.Substring(1);

                        p_Theme.AreaIndexes.Add(ID, _AreaInfo);
                    }
                }
            }

            //-- Restore the culture.
            System.Threading.Thread.CurrentThread.CurrentCulture = OldCulture;
        }
Example #11
0
        /// <summary>
        /// It updates the Chart Theme's MOST recent data information for specified TimePeriod.
        /// </summary>
        /// <param name="_Theme">Chart Theme instance</param>
        /// <param name="p_TimePeriod"></param>
        private void UpdateChartMostRecentData(Theme _Theme, int p_TimePeriod)
        {
            //-- Allow Updating Data Only for Column & Pie Chart
            // as Line Chart works only for Time Series
            if (_Theme.Type == ThemeType.Chart && _Theme.ChartType != ChartType.Line)
            {
                //Get TimePeriod by NId
                string TimePeriod = string.Empty;
                DataRow[] DRow = this._DIDataView.MainDataTable.Select(Timeperiods.TimePeriodNId + " = " + p_TimePeriod);
                if (DRow.Length > 0)
                {
                    TimePeriod = DRow[0][Timeperiods.TimePeriod].ToString();
                }

                object[] _Keys = new object[_Theme.AreaIndexes.Keys.Count];
                _Theme.AreaIndexes.Keys.CopyTo(_Keys, 0);

                foreach (string _Key in _Keys)
                {
                    AreaInfo _AreaInfo = (AreaInfo)_Theme.AreaIndexes[_Key];
                    if (string.IsNullOrEmpty(TimePeriod) == false)
                    {
                        // Update MostRecent Data with the Chart Data of specified TimePeriod
                        if (_AreaInfo.ChartData.ContainsKey(TimePeriod))
                        {
                            _AreaInfo.ChartMostRecentData = _AreaInfo.ChartData[TimePeriod].ToString();
                        }
                        else
                        {
                            _AreaInfo.ChartMostRecentData = string.Empty;
                        }
                    }
                    else
                    {
                        //-- Restore original Chart's MOST recent Data of every Area
                        _AreaInfo.ChartMostRecentData = _AreaInfo.ChartMostRecentDataCopy;
                    }

                    _Theme.AreaIndexes[_Key] = _AreaInfo;
                }
            }
        }
Example #12
0
        /// <summary>
        /// Set the layer visibility based on time period
        /// </summary>
        /// <param name="p_Theme"></param>
        /// <param name="p_ThemeData"></param>
        private void GenerateLayerInformation(ref Theme p_Theme, ref DataView p_ThemeData)
        {
            foreach (DataRowView _DRV in p_ThemeData)
            {
                Layer[] TimeLayers = GetTimeLayer(_DRV["TimePeriod"].ToString());
                if (TimeLayers != null)
                {
                    foreach (Layer _Layer in TimeLayers)
                    {
                        {
                            if (!p_Theme.LayerVisibility.ContainsKey(_Layer.ID))
                            {
                                switch (_Layer.LayerType)
                                {
                                    case ShapeType.Point:
                                    case ShapeType.Polygon:
                                    case ShapeType.PolyLine:
                                        p_Theme.LayerVisibility.Add(_Layer.ID, true);
                                        break;
                                    case ShapeType.PointFeature:
                                    case ShapeType.PolygonFeature:
                                    case ShapeType.PolyLineFeature:
                                        p_Theme.LayerVisibility.Add(_Layer.ID, false);
                                        break;
                                }
                            }
                        }
                    }
                }
            }

            foreach (Layer _Layer in m_Layers)
            {
                if (!p_Theme.LayerVisibility.ContainsKey(_Layer.ID))
                {
                    p_Theme.LayerVisibility.Add(_Layer.ID, false);
                }
            }
        }
Example #13
0
        private void DrawSymbolTheme(ref Graphics g, Theme _Theme, Matrix mTransMatrix, RectangleF CurExt)
        {
            Shape _Shape;
            //Polygon : Polyline : Point
            PointF[] Centroid = new PointF[1];
            Size Offset = new Size();
            Offset.Width = _Theme.X_Offset;
            Offset.Height = -(_Theme.Y_Offset);

            StringFormat _StringFormat = new StringFormat();
            _StringFormat.Alignment = StringAlignment.Center;
            _StringFormat.LineAlignment = StringAlignment.Center;
            _StringFormat.FormatFlags = StringFormatFlags.NoClip;
            //object[] BrLegend = new object[_Theme.Legends.Count];
            SolidBrush[] SolidBrushArray = new SolidBrush[_Theme.Legends.Count];
            Image[] ImageArray = new Image[_Theme.Legends.Count];

            Legend _Legend;
            int LegendItemIndex;
            for (int i = 0; i <= _Theme.Legends.Count - 1; i++)
            {
                _Legend = _Theme.Legends[i];
                if (_Legend.SymbolImage == "" || File.Exists(_Legend.SymbolImage) == false)
                {
                    SolidBrushArray[i] = new SolidBrush(_Legend.Color);
                }
                else
                {
                    ImageArray[i] = Image.FromFile(_Legend.SymbolImage);
                }
            }

            g.SmoothingMode = SmoothingMode.AntiAlias;        //AntiAlias
            foreach (Layer Lyr in Layers)
            {
                //Traverse Layers collection
                {
                    if ((Lyr.LayerType == ShapeType.Polygon | Lyr.LayerType == ShapeType.PolyLine | Lyr.LayerType == ShapeType.Point) & Lyr.Visible == true)
                    {
                        if (Lyr.Extent.IntersectsWith(CurExt) || CurExt.Contains(Lyr.Extent) || Lyr.Extent.Contains(CurExt))
                        {
                            // Render layer only if it lies within current map extent
                            Hashtable ht = Lyr.GetRecords(Lyr.LayerPath + "\\" + Lyr.ID);
                            IDictionaryEnumerator dicEnumerator = ht.GetEnumerator();
                            while (dicEnumerator.MoveNext())
                            {
                                //Traverse Shapes
                                _Shape = (Shape)dicEnumerator.Value;
                                switch (Lyr.LayerType)
                                {
                                    case ShapeType.Point:
                                        Centroid[0] = (PointF)_Shape.Parts[0];
                                        break;
                                    case ShapeType.PolyLine:
                                        Centroid[0] = (PointF)_Shape.Parts[(int)_Shape.Parts.Count / 2 - 1];
                                        break;
                                    case ShapeType.Polygon:
                                        Centroid[0] = _Shape.Centroid;
                                        break;
                                }
                                if (CurExt.Contains(Centroid[0]))
                                {
                                    //Render shape only if it lies within current map extent
                                    mTransMatrix.TransformPoints(Centroid);
                                    //*** Apply Offset values
                                    Centroid[0] = PointF.Add(Centroid[0], Offset);
                                    {
                                        //TODO Handle MultiLegend case
                                        if (_Theme.AreaIndexes.ContainsKey(_Shape.AreaId))
                                        {
                                            LegendItemIndex = (int)((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).RenderingInfo;
                                        }
                                        else
                                        {
                                            LegendItemIndex = _Theme.Legends.Count - 1;
                                        }
                                        if (_Theme.Legends[LegendItemIndex].SymbolImage == "" || File.Exists(_Theme.Legends[LegendItemIndex].SymbolImage) == false)
                                        {
                                            g.DrawString(_Theme.Legends[LegendItemIndex].MarkerChar.ToString(), _Theme.Legends[LegendItemIndex].MarkerFont, SolidBrushArray[LegendItemIndex], Centroid[0].X, Centroid[0].Y, _StringFormat);
                                        }
                                        else
                                        {
                                            Centroid[0].X = Centroid[0].X - (ImageArray[LegendItemIndex]).Width / 2;
                                            Centroid[0].Y = Centroid[0].Y - (ImageArray[LegendItemIndex]).Height / 2;
                                            g.DrawImage(ImageArray[LegendItemIndex], Centroid[0]);
                                        }
                                    }
                                }
                            }
                            //Traverse Shapes
                            ht = null;
                        }
                    }
                }

            }
            //Traverse Layers collection
            g.SmoothingMode = SmoothingMode.None;

            for (int i = 0; i <= _Theme.Legends.Count - 1; i++)
            {
                if (SolidBrushArray[i] != null)
                {
                    SolidBrushArray[i].Dispose();
                }

                if (ImageArray[i] != null)
                {
                    ImageArray[i].Dispose();
                }
            }
            _StringFormat.Dispose();
            _Shape = null;
        }
Example #14
0
        private void DrawLabelTheme(ref Graphics g, Theme _Theme, Matrix mTransMatrix, RectangleF CurExt)
        {
            string Label = "";
            Shape _Shape;
            //Polygon : Polyline : Point
            PointF[] Centroid = new PointF[1];
            Size Offset = new Size(0, 0);
            Offset.Width = _Theme.X_Offset;
            Offset.Height = -(_Theme.Y_Offset);

            StringFormat _StringFormat = new StringFormat();
            _StringFormat.Alignment = StringAlignment.Center;
            _StringFormat.LineAlignment = StringAlignment.Center;
            _StringFormat.FormatFlags = StringFormatFlags.NoClip;

            SolidBrush[] BrLegend = new SolidBrush[_Theme.Legends.Count];
            Legend _Legend;
            int LegendItemIndex;
            for (int i = 0; i <= _Theme.Legends.Count - 1; i++)
            {
                _Legend = _Theme.Legends[i];
                BrLegend[i] = new SolidBrush(_Legend.Color);
            }

            g.SmoothingMode = SmoothingMode.AntiAlias;
            foreach (Layer Lyr in Layers)
            {
                //Traverse Layers collection
                {
                    if ((Lyr.LayerType == ShapeType.Polygon | Lyr.LayerType == ShapeType.PolyLine | Lyr.LayerType == ShapeType.Point) & Lyr.Visible == true)
                    {
                        if (Lyr.Extent.IntersectsWith(CurExt) || CurExt.Contains(Lyr.Extent) || Lyr.Extent.Contains(CurExt))
                        {
                            // Render layer only if it lies within current map extent
                            Hashtable ht = Lyr.GetRecords(Lyr.LayerPath + "\\" + Lyr.ID);
                            IDictionaryEnumerator dicEnumerator = ht.GetEnumerator();
                            while (dicEnumerator.MoveNext())
                            {
                                //Traverse Shapes
                                _Shape = (Shape)dicEnumerator.Value;
                                switch (Lyr.LayerType)
                                {
                                    case ShapeType.Point:
                                        Centroid[0] = (PointF)_Shape.Parts[0];
                                        break;
                                    case ShapeType.PolyLine:
                                        Centroid[0] = (PointF)_Shape.Parts[(int)_Shape.Parts.Count / 2 - 1];
                                        break;
                                    case ShapeType.Polygon:
                                        Centroid[0] = _Shape.Centroid;
                                        break;
                                }
                                if (CurExt.Contains(Centroid[0]))
                                {
                                    //Render shape only if it lies within current map extent
                                    mTransMatrix.TransformPoints(Centroid);
                                    //*** Apply Offset values
                                    Centroid[0] = PointF.Add(Centroid[0], Offset);
                                    {
                                        if (_Theme.AreaIndexes.ContainsKey(_Shape.AreaId))
                                        {
                                            LegendItemIndex = (int)((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).RenderingInfo;
                                        }
                                        else
                                        {
                                            LegendItemIndex = _Theme.Legends.Count - 1;
                                        }
                                        _Legend = _Theme.Legends[LegendItemIndex];
                                        if (_Legend.LabelVisible == true)
                                        {
                                            Label = GetLabel(Lyr, ref _Shape, ref _Theme, null, ref _Legend);
                                            if (_Legend.LabelMultiRow == true)
                                                Centroid[0].X = Centroid[0].X - g.MeasureString(Label, _Legend.MarkerFont).Width / 4;
                                            if (_Legend.LabelMultiRow == true)
                                            {
                                                _StringFormat.Alignment = StringAlignment.Near;
                                            }
                                            else
                                            {
                                                _StringFormat.Alignment = StringAlignment.Center;
                                            }
                                            g.DrawString(Label, _Legend.MarkerFont, BrLegend[LegendItemIndex], Centroid[0].X, Centroid[0].Y, _StringFormat);
                                        }
                                    }
                                }
                            }
                            //Traverse Shapes
                            ht = null;
                        }
                    }
                }
                // Lyr = null;
            }
            //Traverse Layers collection
            g.SmoothingMode = SmoothingMode.None;

            for (int i = 0; i <= BrLegend.Length - 1; i++)
            {
                BrLegend[i].Dispose();
            }
            _StringFormat.Dispose();
            _Shape = null;
        }
Example #15
0
        /// <summary>
        /// It updated Dot theme's basic properties with the theme saved in file name specified.
        /// </summary>
        /// <param name="currentDotTheme">Dot theme to update</param>
        /// <param name="savedChartThemeFileName">(serialized) saved chart theme file name path</param>
        public void UpdateDotThemeSettings(Theme currentDotTheme, string savedDotThemeFileName)
        {
            if (File.Exists(savedDotThemeFileName))
            {
                Theme LoadedTheme = Theme.Load(savedDotThemeFileName);

                if (LoadedTheme.Type == ThemeType.DotDensity)
                {
                    //- Update common Chart Settings
                    currentDotTheme.DotChar = LoadedTheme.DotChar;
                    currentDotTheme.DotColor = LoadedTheme.DotColor;
                    currentDotTheme.DotFont = LoadedTheme.DotFont;
                    currentDotTheme.DotSize = LoadedTheme.DotSize;
                    currentDotTheme.DotStyle = LoadedTheme.DotStyle;
                }
            }
        }
Example #16
0
 public string GetLabel(Layer _Layer, ref Shape _Shape, ref Theme _Theme, CustomLabel _CustomLabel)
 {
     Legend _Legend = null;
     return GetLabel(_Layer, ref _Shape, ref _Theme, _CustomLabel, ref _Legend);
 }
Example #17
0
        /// <summary>
        /// It Updates specified Theme with new Indicator, Units, Subgroups. ThemeType will be same for new Theme.
        /// </summary>
        /// <param name="OldTheme">Old theme to update.</param>
        /// <param name="newIndicatorNid">new Indicator NID for new Theme</param>
        /// <param name="newUnitNid">new UNit NID for new Theme</param>
        /// <param name="subgroupValNid">new Subgroup NID for new Theme</param>
        /// <returns>true, if updated success.</returns>
        public bool UpdateTheme(Theme OldTheme, string newIndicatorNid, string newUnitNid, string newSubgroupValNid)
        {
            bool RetVal = false;
            Theme NewTheme = null;
            Theme OldThemeClone = null;

            try
            {
                if ((OldTheme != null) && string.IsNullOrEmpty(newIndicatorNid) == false && string.IsNullOrEmpty(newUnitNid) == false
                    && string.IsNullOrEmpty(newSubgroupValNid) == false)
                {
                    OldTheme.ID = "TempThemeID";

                    OldThemeClone = (Theme)(OldTheme.Clone());

                    //'- Adding new Theme.
                    NewTheme = this.CreateTheme(newIndicatorNid, newUnitNid, newSubgroupValNid, OldTheme.Type);

                    if ((NewTheme == null) == false)
                    {
                        //-- Update new Theme's properties with Old theme.
                        //-- Passing false because Legend's ranges and decimals will be re constructed from new dataValues fo new IUS
                        this.UpdateThemeProperties(OldThemeClone, NewTheme, false, false);

                        //-- Remove old theme from Collection.
                        this.Themes.Remove(this.Themes.ItemIndex(OldTheme.ID));
                    }

                    //-- update Map Title and Subtitle
                    this.SetMapTitle();

                    RetVal = true;
                }

            }
            catch (Exception)
            {

            }
            return RetVal;
        }
Example #18
0
        public string GetLabel(Layer _Layer, ref Shape _Shape, ref Theme _Theme, CustomLabel _CustomLabel, ref Legend _Legend)
        {
            int i;
            int j;
            string Label = "";
            //*** BugFix 06 Feb 2006 No label field selected
            string Delimiter = " ";
            int IndentSpace = 3;
            char[] Fields;
            bool Indented;

            if ((_Theme == null))
            {
                //*** Custom and Feature Layers
                if (_CustomLabel == null)
                {
                    if (_Layer.LabelMultirow == true)
                        Delimiter = "\r\n";  //initially it was: ControlChars.CrLf (line feed)
                    Fields = _Layer.LabelField.Replace(",", "").ToCharArray();
                }
                else
                {
                    if (_CustomLabel.MultiRow == true)
                        Delimiter = "\r\n";  //initially it was: ControlChars.CrLf (line feed)
                    Fields = _CustomLabel.LabelField.Replace(",", "").ToCharArray();
                }

                if (Array.IndexOf(Fields, "0"[0]) > -1)
                    Label = _Shape.AreaId + Delimiter;
                if (Array.IndexOf(Fields, char.Parse("1")) > -1)
                {
                    if (_Layer.LabelMultirow == true)
                    {
                        if (Label == "")
                        {
                            Label += _Shape.AreaName;
                        }
                        else
                        {
                            if (_Layer.LabelIndented == true)
                                Label += new string(' ', IndentSpace);
                            Label += _Shape.AreaName;
                        }
                    }
                    else
                    {
                        Label += _Shape.AreaName;
                    }
                }
            }
            else
            {
                //*** Base Layers
                if (_CustomLabel == null)
                {
                    if (_Legend == null)
                    {
                        if (_Layer.LabelMultirow == true)
                            Delimiter = "\r\n";  //initially it was: ControlChars.CrLf (line feed)
                        Fields = _Layer.LabelField.Replace(",", "").ToCharArray();
                        Indented = _Layer.LabelIndented;
                    }
                    else
                    {
                        if (_Legend.LabelMultiRow == true)
                            Delimiter = "\r\n";  //initially it was: ControlChars.CrLf (line feed)
                        Fields = _Legend.LabelField.Replace(",", "").ToCharArray();
                        Indented = _Legend.LabelIndented;
                    }
                }
                else
                {
                    if (_CustomLabel.MultiRow == true)
                        Delimiter = "\r\n";  //initially it was: ControlChars.CrLf (line feed)
                    Fields = _CustomLabel.LabelField.Replace(",", "").ToCharArray();
                    Indented = _CustomLabel.Indent;
                }
                if (_Theme.AreaIndexes.ContainsKey(_Shape.AreaId))
                {
                    j = 0;
                    for (i = 0; i <= Fields.Length - 1; i++)
                    {
                        switch (Fields[i])
                        {
                            case '0':
                                Label += _Shape.AreaId + Delimiter;
                                j = j + 1;
                                break;
                            case '1':
                                if (Indented == true)
                                    Label += new string(' ', j * IndentSpace);

                                Label += ((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).AreaName + Delimiter;
                                j = j + 1;
                                break;
                            case '2':
                                if (Indented == true)
                                    Label += new string(' ', j * IndentSpace);

                                //Label += ((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).DataValue + Delimiter;
                                //Textual dataValue is also displayed on Map Label, so property AreaInfo.DisplayInfo is used.
                                Label += ((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).DisplayInfo + Delimiter;
                                j = j + 1;
                                break;
                            case '3':
                                if (Indented == true)
                                    Label += new string(' ', j * IndentSpace);

                                Label += _Theme.UnitName + Delimiter;
                                j = j + 1;
                                break;
                            case '4':
                                if (Indented == true)
                                    Label += new string(' ', j * IndentSpace);

                                //Label += _Theme.SubgroupName(0) & Delimiter
                                //*** BugFix 21 Sep 2006 Subgroup label error
                                Label += ((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).Subgroup + Delimiter;
                                j = j + 1;
                                break;
                            case '5':
                                if (Indented == true)
                                    Label += new string(' ', j * IndentSpace);

                                Label += ((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).Time + Delimiter;
                                break;
                        }
                    }
                    Label = Label.Trim(Delimiter.ToCharArray());
                }
                else
                {
                    if (this._ShowLabelWhereDataExists)
                    {
                        //- If label is not required for Areas NOT having Data,
                        // then set blank label.
                        Label = string.Empty;
                    }
                    else
                    {
                        Hashtable AreaNames = _Layer.AreaNames;
                        string AreaName;
                        if (Array.IndexOf(Fields, "0"[0]) > -1)
                            Label = _Shape.AreaId + Delimiter;
                        if (Array.IndexOf(Fields, char.Parse("1")) > -1)
                        {
                            if (AreaNames.ContainsKey(_Shape.AreaId))
                            {
                                //Get language specific AreaName from Database if it exists
                                AreaName = (string)AreaNames[_Shape.AreaId];
                            }
                            else
                            {
                                //Get Shapefile Area Name
                                AreaName = _Shape.AreaName;
                            }
                            if (_Layer.LabelMultirow == true)
                            {
                                if (Label == "")
                                {
                                    Label += AreaName;
                                }
                                else
                                {
                                    if (_Layer.LabelIndented == true)
                                        Label += new string(' ', IndentSpace);
                                    Label += AreaName;
                                }
                            }
                            else
                            {
                                Label += AreaName;
                            }
                        }
                    }
                }
            }
            return Label;
        }
Example #19
0
        private void CalcDotDensity(DataView p_ThemeData, ref Theme p_Theme)
        {
            //*** Bugfix Feb 2006 Improper Dot Value logic

            decimal MinVal = 0;
            decimal MaxVal = 0;
            decimal DotValue;

            //*** Get Min and Max datavalues for current dataview
            //GetMinMaxDataValue(ref p_ThemeData, ref MinVal, ref MaxVal);
            p_ThemeData.Sort = DataExpressionColumns.DataType + " ASC," + DataExpressionColumns.NumericData + " ASC";
            MinVal = (decimal)p_ThemeData[0][DataExpressionColumns.NumericData];
            MaxVal = (decimal)p_ThemeData[p_ThemeData.Count - 1][DataExpressionColumns.NumericData];

            //*** Set the DotValues
            if (MaxVal > 0 & MaxVal < 1)
            {
                //For cases like Index datavalues
                DotValue = MinVal;
            }
            else if (MaxVal < 100)
            {
                //*** For cases like ALR where datavalues are less than 100
                DotValue = 1;
            }
            else
            {
                //-- Bug fix: When minValue = 0 and Max value > 100 , then max / min became infinity.
                if (MaxVal > 100 && MinVal == 0)
                {
                    MinVal = 1;
                }

                //*** For cases like population size where data values can be in lakhs
                if (MaxVal / MinVal > 500)
                {
                    //*** too much variation
                    DotValue = MaxVal / 500;
                }
                else
                {
                    DotValue = MinVal;
                }
            }

            p_Theme.Maximum = MaxVal;
            if (DotValue < 1)
            {
                p_Theme.DotValue = (double)Math.Round(DotValue, 2);
            }
            else if (DotValue < 10)
            {
                p_Theme.DotValue = (double)Math.Round(DotValue, 1);

            }
            else
            {
                p_Theme.DotValue = (double)Math.Round(DotValue, 0);
            }

            //object[] oMDKeys = new object[MDKeys.Keys.Count];
            //MDKeys.Keys.CopyTo(oMDKeys, 0);
            object[] oMDKeys = this.MDColumns;
            {
                foreach (DataRowView _DRV in p_ThemeData)
                {
                    if (!p_Theme.AreaIndexes.ContainsKey((string)_DRV[Area.AreaID]))            //"Area_ID"
                    {
                        AreaInfo _AreaInfo = new AreaInfo();
                        {
                            _AreaInfo.IndicatorGID = (string)_DRV[Indicator.IndicatorGId];      //"Indicator_GId"
                            _AreaInfo.UnitGID = (string)_DRV[Unit.UnitGId];                     //"Unit_GId"
                            _AreaInfo.SubgroupGID = (string)_DRV[SubgroupVals.SubgroupValGId];  //"Subgroup_Val_GId"
                            _AreaInfo.Subgroup = (string)_DRV[SubgroupVals.SubgroupVal];        //"Subgroup_Val"
                            _AreaInfo.Time = (string)_DRV[Timeperiods.TimePeriod];              //"TimePeriod"
                            _AreaInfo.AreaName = (string)_DRV[Area.AreaName];                   //"Area_Name"
                            _AreaInfo.Source = (string)_DRV[IndicatorClassifications.ICName];   //"IC_Name"

                            //*** Metadata
                            _AreaInfo.MDFldVal = new Hashtable();
                            for (int i = 0; i <= oMDKeys.Length - 1; i++)
                            {
                                if (p_ThemeData.Table.Columns.Contains(oMDKeys[i].ToString()))
                                {
                                    _AreaInfo.MDFldVal.Add(oMDKeys[i], _DRV[(string)oMDKeys[i]]);
                                }
                            }

                            _AreaInfo.DataValue = (decimal)Conversion.Val(_DRV[DataExpressionColumns.NumericData]); //"Data_Value"

                            //DisplayInfo stores textual DataValue (e.g. yes, no) and will be used as part map label
                            _AreaInfo.DisplayInfo = Convert.ToString(_DRV[Data.DataValue]);
                        }
                        //.RenderingInfo = CInt(Val(_DRV("Data_Value")) * DotValue / MaxVal)
                        p_Theme.AreaIndexes.Add((string)_DRV[Area.AreaID], _AreaInfo);      //"Area_ID"
                    }
                }
            }
        }
Example #20
0
        /// <summary>
        /// Returns the SubgroupNId used in specified Chart theme. Returns -1 if theme is not a Chart theme.
        /// </summary>
        /// <returns></returns>
        public string GetSubgroupNameUsedInChartTheme(Theme chartTheme)
        {
            string RetVal = string.Empty;

            try
            {
                if (chartTheme != null && chartTheme.Type == ThemeType.Chart)
                {
                    // Theme.I_U_S_GIDs array represents GID in form of :-
                    // Theme.I_U_S_GIDs[0] - IndicatorGID
                    // Theme.I_U_S_GIDs[1] - UnitGID
                    // Theme.I_U_S_GIDs[2] - SubgroupValGID
                    if (chartTheme.I_U_S_GIDs != null && chartTheme.I_U_S_GIDs.Length == 3)
                    {
                        //- Get SubgroupVal Name from SubgroupValGID used in ChartTheme
                        DataRow[] DRows = this._DIDataView.SubgroupVals.Select(SubgroupVals.SubgroupValGId + "='" + chartTheme.I_U_S_GIDs[2] + "'");

                        if (DRows.Length > 0)
                        {
                            RetVal = Convert.ToString(DRows[0][SubgroupVals.SubgroupVal]);
                        }
                    }
                }
            }
            catch
            {
            }
            return RetVal;
        }
Example #21
0
        private void DrawChart(ref Graphics g, Theme _Theme, Matrix mTransMatrix, RectangleF CurExt, bool bSearch, float PtX, float PtY, ref string LayerId, ref string AreaId, ref GraphicsPath gPath)
        {
            #region "-- local Variables --"

            int i;

            Brush[] BrIS = new Brush[(_Theme.IndicatorColor.Length * _Theme.SubgroupFillStyle.Length)];

            StringFormat _StringFormat = new StringFormat();
            _StringFormat.Alignment = StringAlignment.Center;
            _StringFormat.LineAlignment = StringAlignment.Center;
            _StringFormat.FormatFlags = StringFormatFlags.NoClip;

            for (i = 0; i <= _Theme.SubgroupFillStyle.Length - 1; i++)
            {
                BrIS[i] = new SolidBrush(Color.FromArgb(int.Parse(_Theme.SubgroupFillStyle[i])));
            }

            int VisibleTimePeriods = 0;
            int SpCnt = 0;                      // ChartSeriesNames (Subgroup / Source) visible count.
            int TotalBarColumns = 0;            // Totol Bar columns to draw for ONE Area
            int BarCtr = 0;
            int TimeVisibleCtr = 0;              // TimePeriod Counter for visible TimePeriods.
            int LineCtr = 0;
            float ColumnGap = 0;                // Distance between Column Charts of two consecutive TimePeriods
            double UnitWidth;
            decimal MaxData = _Theme.Maximum;
            float MapTop = m_FullExtent.Top;
            Font TextFont = null;               // maximum limit for Text Size of chart data value.
            Brush ChartDataLabelBrush = null;
            Font ChartAxisLabelFont = null;
            Brush ChartAxisLabelBrush = null;

            float TextFontSize = 6.2F;           // Text size for Chart data value.
            decimal DataValue = 0;
            PointF Pt = new PointF();
            PointF[] Pts = new PointF[] { Pt };
            PointF[] PtData = new PointF[1];
            PointF[] LeaderPts = new PointF[2];
            Pen PnLeader = new Pen(_Theme.ChartLeaderColor, _Theme.ChartLeaderWidth);
            PointF Centroid = new PointF(0, 0);
            GraphicsPath gpShp = new GraphicsPath();
            AreaInfo _AreaInfo;
            string[] DataArr;
            Hashtable ChartData = null; // Collection of TimePeriod wise delimited DataValue for multiple Subgroup/Source
            string ChartMRD = string.Empty;
            bool DataFoundForTimePeriod = false;

            //-- Pie variables
            float StartAngle = 0;     // Start angle for first Pie section , starting from 0 degree in clockwise direction
            float PieAngle = 0;
            float PieDiameter = 0;
            float PieMinDiameter = 0;
            float PieMaxDiameter = 0;
            decimal DataValueSum = 0;   // sum
            RectangleF ChartExtent = new RectangleF();  // Applicable for Pie & Line Chart

            // Line variables
            PointF LineStartPoint = new PointF();
            PointF LineEndPoint = new PointF();
            PointF[] LinePoints = new PointF[2];
            object[] LineSubgroupPoints = null; // Line points for visible Subgroup for any TimePeriod
            float LineChartYAxisLenght = 0F;
            float LineThickness = (float)_Theme.ChartLineThickness;
            bool AxisDrawn = false;         // indicates whether X, Y Axis are drawn one time.
            PointF AxisPoint1 = new PointF();
            PointF AxisPoint2 = new PointF();
            PointF[] AxisPoints = new PointF[2];
            decimal LineMaxDataValue = 0;

            PnLeader.DashStyle = _Theme.ChartLeaderStyle;
            #endregion

            //-- visible series - Subgroups / Sources
            string[] ChartVisibleSeries;

            if (_Theme.ChartSeriestype == ChartSeriesType.Subgroup)
            {
                ChartVisibleSeries = _Theme.SubgroupVisible;
            }
            else
            {
                ChartVisibleSeries = _Theme.SourceVisible;
            }

            //- Count Visible Series (either Subgroup Or Sources)
            for (i = 0; i <= ChartVisibleSeries.Length - 1; i++)
            {
                if (ChartVisibleSeries[i] == "1")
                    SpCnt += 1;
            }

            //-- Set TextFont Size on the basis of Map's Current Extent
            if (CurExt.Width < 40 && CurExt.Width >= 25)
            {
                TextFontSize = 7;
            }
            else if (CurExt.Width < 25)
            {
                TextFontSize = 8;
            }
            //TextFont = new Font(_Theme.LabelFont.Name, TextFontSize);

            //-- Set Font used to render Data Value & Chart Axis Labels
            CustomLabelSetting labelSetting = _Theme.ChartDataLabelSettings;
            if (labelSetting == null)
            {
                labelSetting = new CustomLabelSetting();
            }
            TextFont = labelSetting.LabelFont;
            ChartDataLabelBrush = new SolidBrush(labelSetting.LabelColor);

            labelSetting = _Theme.ChartAxisLabelSettings;
            if (labelSetting == null)
            {
                labelSetting = new CustomLabelSetting();
            }
            ChartAxisLabelFont = labelSetting.LabelFont;
            ChartAxisLabelBrush = new SolidBrush(labelSetting.LabelColor);

            //*** Bugfix / Enhancement 02 May 2006 Controling chart width
            //*** Bugfix / Enhancement 15 Jun 2006 Controling chart width
            //*** Set the unit width to 1/20th of the Screen width.
            //*** If there are multiple subgroup that should be accomodated then they should be accomodated within unit width
            //*** Set Width of Bars based on FullExtentWidth(/) + Subgroup Count(\) + Chart Size(/)
            UnitWidth = ((m_FullExtent.Width) / (SpCnt * 20)) * Math.Pow(1.5, _Theme.ChartWidth - 10);
            //UnitWidth = ((m_FullExtent.Width) / (50)) + ((float)_Theme.ChartWidth /  20);
            //Exponential Rise (_Theme.ChartWidth / 10) '
            //UnitWidth = (1 / SpCnt) * (_Theme.ChartWidth / 10) '*** Set Width of Bars based on FullExtentWidth(/) + Subgroup Count(\) + Chart Size(/)
            ColumnGap = (float)((UnitWidth * 0.5) * (_Theme.ColumnsGap));

            Theme _ATheme = m_Themes.GetActiveTheme();
            bool bLayerVisibility;

            Shape _Shape;
            //Polygon : Polyline : Point
            if (SpCnt > 0)
            {
                // and calculate the PieDiameter (Max & Min) on the basis of Map FullExtent.
                // Maximum PieDiameter is kept at 1/5 th of FullExtent.
                if (_Theme.ChartType != ChartType.Column)
                {

                    if ((PieMaxDiameter < m_FullExtent.Height / 5F) || (PieMaxDiameter < m_FullExtent.Width / 5F))
                    {
                        //- max
                        if (m_FullExtent.Height > m_FullExtent.Width)
                        {
                            PieMaxDiameter = (m_FullExtent.Width) / 5F;
                        }
                        else
                        {
                            PieMaxDiameter = (m_FullExtent.Height) / 5F;
                        }
                        //- Validate Maximum Piediameter shoukd be > 3F
                        if (PieMaxDiameter < 3F)
                        {
                            PieMaxDiameter = 3F;
                        }
                        //- Mimimum PieDiameter is Kept 1/3rd of Maximim.
                        PieMinDiameter = PieMaxDiameter * 0.3F;
                    }

                    //-- Maximum Diameter must be less than Total Extent / 5
                    if ((PieMaxDiameter > CurExt.Width / 4))
                    {
                        PieMaxDiameter = CurExt.Width / 4;
                        //- Mimimum PieDiameter is Kept 1/3rd of Maximim.
                        PieMinDiameter = PieMaxDiameter * 0.3F;
                    }
                }

                //*** If all subgroup are unchecked then no need of rendering
                foreach (Layer Lyr in Layers)
                {
                    //--Reset Chart variables
                    StartAngle = 0;
                    PieAngle = 0;
                    DataValueSum = 0;
                    AxisDrawn = false;
                    VisibleTimePeriods = 0;

                    //Traverse Layers collection
                    if ((_ATheme == null))
                    {
                        bLayerVisibility = Lyr.Visible;
                    }
                    else
                    {
                        if (_ATheme.LayerVisibility[Lyr.ID] == null)
                        {
                            bLayerVisibility = false;
                        }
                        else
                        {
                            bLayerVisibility = (bool)_ATheme.LayerVisibility[Lyr.ID];
                        }
                    }
                    if (Lyr.LayerType == ShapeType.Polygon & bLayerVisibility == true & Lyr.Extent.IntersectsWith(CurExt))
                    {
                        // Render layer only if it lies within current map extent
                        Hashtable ht = Lyr.GetRecords(Lyr.LayerPath + "\\" + Lyr.ID);
                        IDictionaryEnumerator dicEnumerator = ht.GetEnumerator();
                        while (dicEnumerator.MoveNext())
                        {
                            //Traverse Shapes
                            _Shape = (Shape)dicEnumerator.Value;

                            //--Check AreaID exists in AreaIndexes. AND AreaID should NOT be excluded explicitly.
                            if (_Theme.AreaIndexes.ContainsKey(_Shape.AreaId) && _Theme.ExcludeAreaIDs.Contains(_Shape.AreaId) == false)
                            {
                                _AreaInfo = (AreaInfo)_Theme.AreaIndexes[_Shape.AreaId];

                                //-- get ChartData and ChartMRDData.
                                ChartData = _AreaInfo.ChartData;
                                ChartMRD = _AreaInfo.ChartMostRecentData;

                                //*** Get Shape Centroid
                                if (_Theme.ModifiedCharts.ContainsKey(Lyr.ID + "_" + _Shape.AreaId))
                                {
                                    //*** Get Modified Centroid for Nudged Chart
                                    Centroid = (PointF)_Theme.ModifiedCharts[Lyr.ID + "_" + _Shape.AreaId];

                                    //*** Draw Leader Line for Nudged Chart if atleast one subgroup bar is visible
                                    if (SpCnt > 0 & _Theme.ChartLeaderVisible == true)
                                    {
                                        LeaderPts[0] = Centroid;
                                        if (Lyr.LayerType == ShapeType.Polygon)
                                        {
                                            LeaderPts[1] = _Shape.Centroid;
                                        }
                                        else if (Lyr.LayerType == ShapeType.Point)
                                        {
                                            LeaderPts[1] = (PointF)_Shape.Parts[0];
                                        }
                                        mTransMatrix.TransformPoints(LeaderPts);
                                        g.DrawLine(PnLeader, LeaderPts[0], LeaderPts[1]);
                                    }
                                }
                                else
                                {
                                    //*** Get default Shape Centroid
                                    if (Lyr.LayerType == ShapeType.Polygon)
                                    {
                                        Centroid = _Shape.Centroid;
                                    }
                                    else if (Lyr.LayerType == ShapeType.Point)
                                    {
                                        Centroid = (PointF)_Shape.Parts[0];
                                    }
                                }

                                //--Reset Chart variables
                                AxisDrawn = false;
                                VisibleTimePeriods = 0;
                                DataValueSum = 0;
                                TimeVisibleCtr = 0;
                                StartAngle = 0;
                                PieAngle = 0;

                                #region "-- Set Pie / Line Chart Extent "

                                //-- Get X, Y position & Diameter of Pie Circle / Extent for Line Chart .
                                if (_Theme.ChartType == ChartType.Pie || _Theme.ChartType == ChartType.Line)
                                {
                                    //-- Pie drawn should be fitted in the Area.
                                    // so reduce the Area of Pie to 40% of Total Area Extent
                                    ChartExtent = _Shape.Extent;

                                    ChartExtent.Width = ChartExtent.Width * 0.5F;
                                    ChartExtent.Height = ChartExtent.Height * 0.5F;
                                    //-- Set the Pie Diameter according to layer's width and height
                                    if (_Theme.PieAutoSize)            //|| (!(_Theme.PieAutoSize) & _Theme.PieSize <= 0))
                                    {
                                        //-- If Shape Area is very small i.e. < Minumum Diameter set,
                                        // then
                                        if (ChartExtent.Width < PieMinDiameter || ChartExtent.Height < PieMinDiameter)
                                        {
                                            PieDiameter = PieMinDiameter;
                                        }
                                        else if (ChartExtent.Width > PieMaxDiameter && ChartExtent.Height > PieMaxDiameter)
                                        {
                                            //If PieDiameter is too high i.e. > Maximum Diameter set,
                                            PieDiameter = PieMaxDiameter;
                                        }
                                        else if (ChartExtent.Height < ChartExtent.Width)
                                        {
                                            if (ChartExtent.Height * 0.9 < PieMinDiameter)
                                            {
                                                PieDiameter = PieMinDiameter;
                                            }
                                            else
                                            {
                                                PieDiameter = ChartExtent.Height * 0.9F;
                                                //PieDiameter = PieRectExtent.Height * 0.5F + (1 - PieRectExtent.Height / PieRectExtent.Width);
                                            }
                                        }
                                        else
                                        {
                                            if (ChartExtent.Width * 0.9 < PieMinDiameter)
                                            {
                                                PieDiameter = PieMinDiameter;
                                            }
                                            else
                                            {
                                                PieDiameter = ChartExtent.Width * 0.9F;
                                                //PieDiameter = PieRectExtent.Height * 0.5F + (1 - PieRectExtent.Height / PieRectExtent.Width);
                                            }
                                            //PieDiameter = PieRectExtent.Width * 0.5F + (1 - PieRectExtent.Width / PieRectExtent.Height);
                                        }

                                        //-- Multiply by Auto size Factor value.
                                        PieDiameter *= _Theme.PieAutoSizeFactor;
                                    }
                                    else if (_Theme.PieSize > 0)
                                    {
                                        //-- Fixed size of each pie is started at minium from curExtent / 12
                                        PieMaxDiameter = CurExt.Height / 12;
                                        //-- Then add (PieSize / 10) to it.
                                        PieDiameter = (PieMaxDiameter) * (1 + (float)_Theme.PieSize / 10);
                                    }

                                    ChartExtent.Width = PieDiameter;
                                    ChartExtent.Height = PieDiameter;

                                    if (_Theme.ModifiedCharts.ContainsKey(Lyr.ID + "_" + _Shape.AreaId))
                                    {
                                        //-- IF Chart is nudged then keep Pie center on Centroid.
                                        ChartExtent.X = Centroid.X - PieDiameter * 0.5F;
                                        ChartExtent.Y = Centroid.Y - PieDiameter * 0.5F;
                                    }
                                    else
                                    {
                                        //else, Keep pie center little displaced from Centroid towards downwards
                                        ChartExtent.X = Centroid.X - PieDiameter * 0.6F;
                                        ChartExtent.Y = Centroid.Y - PieDiameter * 0.7F;
                                    }

                                    if (_Theme.ChartType == ChartType.Line)
                                    {
                                        ChartExtent.Y = Centroid.Y - ChartExtent.Height * 0.1F;
                                        ChartExtent.Height = PieDiameter;
                                        ChartExtent.Width = ChartExtent.Height * 1.4F;
                                    }
                                }

                                #endregion

                                //- Get Visible TimePeriods (used in calculating X-Axis length)
                                foreach (string KeyTimePeriod in ChartData.Keys)
                                {
                                    if ((bool)_Theme.ChartTimePeriods[KeyTimePeriod] == true)
                                    {
                                        //- Count TimePeriods only if DataValue exists for visible Subgroups
                                        string[] TempDataArr = ChartData[KeyTimePeriod].ToString().Split(',');
                                        for (i = 0; i < TempDataArr.Length; i++)
                                        {
                                            if (string.IsNullOrEmpty(TempDataArr[i]) == false)
                                            {
                                                if (ChartVisibleSeries[i] == "1")
                                                {
                                                    VisibleTimePeriods++;
                                                    break;
                                                }
                                            }
                                        }

                                    }
                                }
                                if (VisibleTimePeriods == 0 || _Theme.DisplayChartMRD)
                                {
                                    VisibleTimePeriods = 1;
                                }

                                //--Total bar column to draw for single Area. (Total Subroups * Total TimePeriod)
                                TotalBarColumns = VisibleTimePeriods * SpCnt;
                                BarCtr = 0;
                                LineSubgroupPoints = new object[ChartVisibleSeries.Length]; // holds line Points drawn

                                //-- Loop TimePeriods  for Column OR Line chart. Column/ Line will be plotted for each TimePeriod
                                foreach (string TimePeriodKey in _Theme.ChartTimePeriods.Keys)
                                {
                                    if (string.IsNullOrEmpty(TimePeriodKey.ToString()) == false)
                                    {
                                        //-- Check TimePeriod visibiliy and visibleTime < 2 for LineChart
                                        if (!(_Theme.ChartType == ChartType.Line && VisibleTimePeriods < 2))
                                        {
                                            //-- Check if TimePeriod visibilty is ON, And ChartData must have data against timePeriod
                                            if ((_Theme.ChartTimePeriods[TimePeriodKey.ToString()] == true && ChartData.ContainsKey(TimePeriodKey)) || _Theme.DisplayChartMRD)
                                            {
                                                if (TimeVisibleCtr < VisibleTimePeriods)
                                                {
                                                    TimeVisibleCtr++;
                                                }
                                                LineCtr = 0;
                                                DataValueSum = 0;
                                                DataFoundForTimePeriod = false;

                                                //-- If MRD for Chart is ON, Get mostRecent DataValues
                                                if (_Theme.DisplayChartMRD)
                                                {
                                                    DataArr = ChartMRD.Split(',');
                                                }
                                                else    //IF MRD is Off, get TimePeriodwise DataValues.
                                                {
                                                    DataArr = ChartData[TimePeriodKey].ToString().Split(',');
                                                }

                                                //-- Get sum of all dataValues, will be used in PieChart, LineChart
                                                // sum for only visible subgroups
                                                for (i = 0; i < DataArr.Length; i++)
                                                {
                                                    if (string.IsNullOrEmpty(DataArr[i]) == false)
                                                    {

                                                        decimal decVal = Convert.ToDecimal(DataArr[i], CultureInfo.InvariantCulture.NumberFormat);
                                                        if (decVal > 0 && ChartVisibleSeries[i] == "1")
                                                        {
                                                            DataFoundForTimePeriod = true;  //-- Indicates that some Data is found for visible Subgroup

                                                            //-- Round DataValues
                                                            decVal = Math.Round(decVal, _Theme.RoundDecimals);
                                                            DataArr[i] = decVal.ToString().Replace(",", ".");

                                                            DataValueSum += decVal;
                                                        }
                                                    }
                                                }

                                                // -- Get maximum DataValue for LineChart
                                                if (_Theme.ChartType == ChartType.Line)
                                                {
                                                    if (_Theme.DisplayChartMRD)
                                                    {
                                                        LineMaxDataValue = this.GetMaximumChartDataValue(DataArr);
                                                    }
                                                    else
                                                    {
                                                        LineMaxDataValue = this.GetMaximumChartDataValue(ChartData);
                                                    }
                                                    LineMaxDataValue *= 1.3M;
                                                }

                                                int j = 0;
                                                //*** Counter for Visible Series (subgroup / Sources)
                                                for (i = 0; i <= _Theme.SubgroupFillStyle.Length - 1; i++)
                                                {
                                                    if (ChartVisibleSeries[i] == "1" && DataFoundForTimePeriod)
                                                    {
                                                        BarCtr++;   //This is Nth Bar Column drawing (after increment)
                                                        try
                                                        {
                                                            if (DataArr[i] == "")
                                                            {
                                                                DataValue = 0;
                                                            }
                                                            else
                                                            {
                                                                DataValue = Convert.ToDecimal(Conversion.Val(DataArr[i]), CultureInfo.InvariantCulture.NumberFormat);
                                                                //DataValue = (decimal)Microsoft.VisualBasic.Conversion.Val(DataArr[i]);
                                                                //Cdbl
                                                            }

                                                            //-- If DataValue is NOT Zero, NOT Pie chart
                                                            if (DataArr[i] != "" && DataValueSum != 0)
                                                            {
                                                                #region "-- Column --"

                                                                if (_Theme.ChartType == ChartType.Column)
                                                                {
                                                                    Pt = Centroid;
                                                                    if (_Theme.ModifiedCharts.ContainsKey(Lyr.ID + "_" + _Shape.AreaId))
                                                                    {
                                                                        Pt.X = Pt.X + ((BarCtr - 1) * (float)UnitWidth) + (ColumnGap * (TimeVisibleCtr - 1));
                                                                    }
                                                                    else
                                                                    {
                                                                        //-Chart Mid point should coincide with the Centroid of Shape
                                                                        //- get Totol width of Column Chart , and get mid point of chart
                                                                        float ChartWidth = (float)(UnitWidth * TotalBarColumns) + ((VisibleTimePeriods - 1) * ColumnGap);

                                                                        Pt.X = Pt.X - ChartWidth / 2F + ((BarCtr - 1) * (float)UnitWidth) + (ColumnGap * (TimeVisibleCtr - 1));
                                                                        //Pt.Y = Pt.Y + (_Shape.Extent.Height) / 20;
                                                                        Pt.Y = Pt.Y - (CurExt.Height) / 40;
                                                                    }

                                                                    Pts = new PointF[4];
                                                                    Pts[0] = Pt;
                                                                    //1st

                                                                    Pt.X = Pt.X + (float)UnitWidth;
                                                                    Pts[1] = Pt;
                                                                    //2nd

                                                                    //*** Bugfix / Enhancement 15 Jun 2006 Controling Chart Height
                                                                    //*** Set Height of Bars based on FullExtentWidth(/) + DataValue(\) + Chart Size(/)
                                                                    Pt.Y = Pt.Y + (float)((m_FullExtent.Height / 2) * (float)(DataValue / MaxData) * Math.Pow(1.5, _Theme.ChartSize - 10));
                                                                    // exponential rise (_Theme.ChartSize / 10))

                                                                    //--AXIS X & Y
                                                                    //-- First Draw the X for Column Chart.
                                                                    //-- Axis should be drawn only first time.
                                                                    // Axis for Column to be drawn only for multiple TimePeriods.
                                                                    gpShp.Reset();
                                                                    if (AxisDrawn == false && _Theme.DisplayChartMRD == false)
                                                                    {
                                                                        //--Get Origin of Axis to be drawn, starting near first Column bar.
                                                                        //- Get coordinates of First Column bar
                                                                        AxisPoint1 = Centroid;
                                                                        if (_Theme.ModifiedCharts.ContainsKey(Lyr.ID + "_" + _Shape.AreaId))
                                                                        {
                                                                        }
                                                                        else
                                                                        {
                                                                            //-Chart Mid point should coincide with the Centroid of Shape
                                                                            //- get Totol width of Column Chart , and get mid point of chart
                                                                            float ChartWidth = (float)(UnitWidth * TotalBarColumns) + ((VisibleTimePeriods - 1) * ColumnGap);

                                                                            AxisPoint1.X = AxisPoint1.X - ChartWidth / 2F;
                                                                            AxisPoint1.Y = Pts[0].Y;
                                                                        }

                                                                        //-- Adding Axis buffer
                                                                        AxisPoint1.X = AxisPoint1.X - ((float)UnitWidth / 6F);
                                                                        AxisPoint1.Y = AxisPoint1.Y;

                                                                        AxisPoint2.X = AxisPoint1.X + ((float)UnitWidth * TotalBarColumns) + (ColumnGap * (VisibleTimePeriods - 1)) + ((float)UnitWidth / 3F);

                                                                        AxisPoint2.Y = AxisPoint1.Y;

                                                                        // X Axis
                                                                        if (_Theme.ShowChartAxis)
                                                                        {
                                                                            //gpShp.AddLine(AxisPoint1, AxisPoint2);
                                                                            AxisPoints[0] = AxisPoint1;
                                                                            AxisPoints[1] = AxisPoint2;
                                                                            mTransMatrix.TransformPoints(AxisPoints);
                                                                            g.DrawLine(new Pen(new SolidBrush(_Theme.ChartAxisColor), 1), AxisPoints[0], AxisPoints[1]);
                                                                        }
                                                                        AxisDrawn = true;
                                                                        AxisPoint1.X += (float)UnitWidth / 6F;
                                                                        AxisPoint2.X -= 0.1F;
                                                                    }

                                                                    if (Pt.Y > MapTop)
                                                                    {
                                                                        // ReDimStatement not supported in C#, so Pts array is copied into new array PtsTemp
                                                                        PointF[] PtsTemp = new PointF[7];      //PtsTemp[] is resized as desired
                                                                        Array.Copy(Pts, PtsTemp, Math.Min(Pts.Length, PtsTemp.Length));
                                                                        Pts = PtsTemp;      // PtsTemp elements are copied back into Pts[]

                                                                        Pt.Y = MapTop - 2 * (float)UnitWidth;
                                                                        Pts[2] = Pt;
                                                                        //3rd
                                                                        Pt.X = Pt.X - (float)UnitWidth / 4;
                                                                        Pts[3] = Pt;
                                                                        //4rd
                                                                        Pt.Y = Pt.Y - (float)UnitWidth / 4;
                                                                        Pt.X = Pt.X - (float)UnitWidth / 4;
                                                                        Pts[4] = Pt;
                                                                        //5th
                                                                        Pt.Y = MapTop - 2 * (float)UnitWidth;
                                                                        Pts[5] = Pt;
                                                                        //6th
                                                                        Pt.X = Pt.X - (float)UnitWidth / 2;
                                                                        Pts[6] = Pt;
                                                                        //7th
                                                                        //gpShp.Reset();
                                                                        gpShp.AddPolygon(Pts);

                                                                        //*** Set Bar Break
                                                                        Array.Clear(Pts, 0, 7);
                                                                        Pt.Y = Pt.Y + (float)UnitWidth / 4;
                                                                        Pts[0] = Pt;
                                                                        Pt.X = Pt.X + (float)UnitWidth / 2;
                                                                        Pts[1] = Pt;
                                                                        Pt.Y = Pt.Y + (float)UnitWidth / 4;
                                                                        Pt.X = Pt.X + (float)UnitWidth / 4;
                                                                        Pts[2] = Pt;
                                                                        Pt.Y = Pt.Y - (float)UnitWidth / 4;
                                                                        Pts[3] = Pt;
                                                                        Pt.X = Pt.X + (float)UnitWidth / 4;
                                                                        Pts[4] = Pt;
                                                                        Pt.Y = MapTop - (float)UnitWidth;
                                                                        Pts[5] = Pt;
                                                                        Pt.X = Pt.X - (float)UnitWidth;
                                                                        Pts[6] = Pt;
                                                                        //gpShp.AddPolygon(Pts);
                                                                    }
                                                                    else
                                                                    {
                                                                        Pts[2] = Pt;
                                                                        //3rd
                                                                        Pt.X = Pt.X - (float)UnitWidth;
                                                                        Pts[3] = Pt;
                                                                        //4th
                                                                        //gpShp.Reset();
                                                                        //gpShp.AddPolygon(Pts);
                                                                    }

                                                                    //-- Add Bar polygon
                                                                    gpShp.AddPolygon(Pts);
                                                                }

                                                                #endregion

                                                                #region "-- LINE --"

                                                                if (_Theme.ChartType == ChartType.Line)
                                                                {
                                                                    LineCtr++;

                                                                    //-- First Draw the X, Y axis for Line Chart.
                                                                    //-- Axis should be drawn only first time.
                                                                    gpShp.Reset();
                                                                    if (AxisDrawn == false && VisibleTimePeriods > 1)
                                                                    {

                                                                        // X Axis
                                                                        AxisPoint1 = new PointF(ChartExtent.Left, ChartExtent.Top);
                                                                        AxisPoint2 = new PointF(ChartExtent.Left + ChartExtent.Width, ChartExtent.Top);

                                                                        if (_Theme.ShowChartAxis)
                                                                        {
                                                                            //gpShp.AddLine(AxisPoint1, AxisPoint2);
                                                                            AxisPoints[0] = AxisPoint1;
                                                                            AxisPoints[1] = AxisPoint2;
                                                                            mTransMatrix.TransformPoints(AxisPoints);
                                                                            g.DrawLine(new Pen(new SolidBrush(_Theme.ChartAxisColor), 1), AxisPoints[0], AxisPoints[1]);
                                                                        }

                                                                        // Y Axis
                                                                        AxisPoint2 = new PointF(ChartExtent.Left, ChartExtent.Top + ChartExtent.Height);
                                                                        if (_Theme.ShowChartAxis)
                                                                        {
                                                                            //gpShp.AddLine(AxisPoint1, AxisPoint2);
                                                                            AxisPoints[0] = AxisPoint1;
                                                                            AxisPoints[1] = AxisPoint2;
                                                                            mTransMatrix.TransformPoints(AxisPoints);
                                                                            g.DrawLine(new Pen(new SolidBrush(_Theme.ChartAxisColor), 1), AxisPoints[0], AxisPoints[1]);
                                                                        }

                                                                        // Get Y Axis height
                                                                        LineChartYAxisLenght = ChartExtent.Height;

                                                                        // - Get horizontal distance between two consecutive points
                                                                        UnitWidth = ChartExtent.Width / (VisibleTimePeriods + 1);

                                                                        // -- Set Start Point same as
                                                                        LineStartPoint = new PointF(ChartExtent.Left + (float)(UnitWidth * TimeVisibleCtr), ChartExtent.Top + (float)(DataValue / LineMaxDataValue) * LineChartYAxisLenght);

                                                                        AxisDrawn = true;
                                                                    }

                                                                    //-- Draw Points for given DataValue
                                                                    LineEndPoint = new PointF(ChartExtent.Left + (float)(UnitWidth * TimeVisibleCtr), ChartExtent.Top + (float)(DataValue / LineMaxDataValue) * LineChartYAxisLenght);

                                                                    if (LineSubgroupPoints[i] != null)
                                                                    {
                                                                        //-- Join  Line from previous Point to New Point
                                                                        //-  In first loop, line will start from origin
                                                                        LineStartPoint = (PointF)LineSubgroupPoints[i];
                                                                        //PointF[] Line = { LineStartPoint, LineEndPoint, new PointF(LineEndPoint.X, LineEndPoint.Y - 0.02F), new PointF(LineStartPoint.X, LineStartPoint.Y - 0.02F) };
                                                                        //gpShp.AddPolygon(Line);
                                                                        LinePoints = new PointF[] { LineStartPoint, LineEndPoint };
                                                                        mTransMatrix.TransformPoints(LinePoints);
                                                                        g.DrawLine(new Pen(BrIS[i], LineThickness), LinePoints[0], LinePoints[1]);
                                                                    }
                                                                    //-- Draw a dot circle on Point
                                                                    float PointDiameter = CurExt.Height / 400;
                                                                    gpShp.AddEllipse(LineEndPoint.X - PointDiameter, LineEndPoint.Y - PointDiameter, PointDiameter * 2, PointDiameter * 2);

                                                                    //- Set End point as Starting point for next Point to draw.
                                                                    LineSubgroupPoints[i] = LineEndPoint;
                                                                }
                                                                #endregion

                                                                #region "-- PIE --"

                                                                else if (_Theme.ChartType == ChartType.Pie)
                                                                {
                                                                    if (!(string.IsNullOrEmpty(DataArr[i])) && DataValue > -1 && DataValueSum > 0)
                                                                    {
                                                                        //--Increment Start Angle for next Pie in loop
                                                                        StartAngle += PieAngle;

                                                                        if (j == SpCnt - 1)
                                                                        {
                                                                            PieAngle = 360 - StartAngle;
                                                                        }
                                                                        else
                                                                        {
                                                                            PieAngle = (int)(DataValue / DataValueSum * 360);    // (decimal.Parse(DataArr[i])
                                                                        }
                                                                        gpShp.Reset();
                                                                        //gpShp.AddPie((int)(PieRectExtent.X + PieRectExtent.Width * 0.5), (int)(PieRectExtent.Y + PieRectExtent.Height * 0.4), (int)(PieRectExtent.Height * 0.5), (int)(PieRectExtent.Height * 0.5), StartAngle, PieAngle);
                                                                        //gpShp.AddPie((int)(PieRectExtent.X), (int)PieRectExtent.Y, (int)PieRectExtent.Width , (int)PieRectExtent.Height, StartAngle, PieAngle);
                                                                        if (StartAngle == 0 && PieAngle == 360)
                                                                        {
                                                                            gpShp.AddEllipse(ChartExtent);
                                                                        }
                                                                        else
                                                                        {
                                                                            gpShp.AddPie(ChartExtent.X, ChartExtent.Y, ChartExtent.Width, ChartExtent.Height, StartAngle, PieAngle);
                                                                        }

                                                                    }
                                                                }

                                                                #endregion

                                                                #region "-- Draw Chart Shape --"

                                                                //*** Draw Column or Pie, or Line Chart
                                                                gpShp.Transform(mTransMatrix);

                                                                if (bSearch)
                                                                {
                                                                    if (gpShp.IsVisible(PtX, PtY))
                                                                    {
                                                                        AreaId = _Shape.AreaId;
                                                                        LayerId = Lyr.ID;
                                                                    }
                                                                    if (_Theme.ChartType == ChartType.Column)
                                                                    {
                                                                        gPath.AddPolygon(Pts);
                                                                    }
                                                                    else if (_Theme.ChartType == ChartType.Line)
                                                                    {
                                                                        gPath.AddRectangle(ChartExtent);
                                                                    }
                                                                    else if (_Theme.ChartType == ChartType.Pie)
                                                                    {
                                                                        gPath.AddPie(ChartExtent.X, ChartExtent.Y, ChartExtent.Width, ChartExtent.Height, StartAngle, PieAngle);
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    g.SmoothingMode = SmoothingMode.AntiAlias;
                                                                    g.PixelOffsetMode = PixelOffsetMode.HighQuality;
                                                                    //PathGradientBrush LBrush = new PathGradientBrush(gpShp);
                                                                    //LBrush.SurroundColors = new Color[] { Color.Red, Color.Green, Color.Blue };
                                                                    // LBrush.CenterColor = Color.Gray;

                                                                    g.FillPath(BrIS[i], gpShp);  //LBrush

                                                                    //LBrush.Dispose();
                                                                    if (_Theme.ChartType == ChartType.Pie)
                                                                    {
                                                                        //-- In case of Pie, draw shape border with gray
                                                                        g.DrawPath(Pens.DarkGray, gpShp);
                                                                    }
                                                                    else
                                                                    {
                                                                        g.DrawPath(Pens.Black, gpShp);
                                                                    }

                                                                    //*** Draw Data Value
                                                                    // Draw data Value if DataValueSum is >0 OR ( visible TimePeriods >= 2 in Line Chart)
                                                                    if (!(string.IsNullOrEmpty(DataArr[i])) && (_Theme.DisplayChartData == true && DataValueSum != 0) && (!(_Theme.ChartType == ChartType.Line && VisibleTimePeriods < 2)))
                                                                    {
                                                                        //--DataValue Label's X, Y position
                                                                        switch (_Theme.ChartType)
                                                                        {
                                                                            case ChartType.Column:
                                                                                Pt.X = Pt.X + (float)UnitWidth / 2;
                                                                                Pt.Y = Pt.Y;        // + 0.4F;
                                                                                break;
                                                                            case ChartType.Pie:
                                                                                //--Label's X, Y position will be calculated
                                                                                // on the basis of StartAngle & PieAngle of next subsequent Pie.
                                                                                if (!(string.IsNullOrEmpty(DataArr[i])) && DataValue > -1 && DataValueSum > 0)
                                                                                {
                                                                                    //- X
                                                                                    double angle;
                                                                                    angle = Math.PI * (StartAngle + (PieAngle / 2)) / 180.0;
                                                                                    double p = Math.Cos(angle);
                                                                                    Pt.X = (float)(((ChartExtent.Left + ChartExtent.Right) / 2) + (ChartExtent.Width / 1.7) * p);

                                                                                    //-Y
                                                                                    p = Math.Sin(angle);
                                                                                    Pt.Y = (float)(((ChartExtent.Top + ChartExtent.Bottom) / 2) + (ChartExtent.Height / 1.7) * p);
                                                                                }
                                                                                break;
                                                                            case ChartType.Line:
                                                                                Pt = LineEndPoint;
                                                                                Pt.Y += CurExt.Height / 100;    //- Drawing dataValue at some distance from actual plotted point.
                                                                                break;
                                                                        }

                                                                        PtData[0] = Pt;
                                                                        mTransMatrix.TransformPoints(PtData);
                                                                        //g.DrawString(DataValue.ToString(), TextFont, SystemBrushes.WindowText, PtData[0], _StringFormat);

                                                                        //-- Draw Data Value with orientation
                                                                        this.DrawString(g, DataValue.ToString(), true, TextFont, ChartDataLabelBrush, PtData[0], _Theme.ChartDataLabelSettings.YOffset, _StringFormat, _Theme.ChartDataLabelSettings.TextOrientationAngle);
                                                                    }

                                                                }
                                                                Pts = null;
                                                                #endregion
                                                            }
                                                        }
                                                        catch (Exception ex)
                                                        {
                                                            Console.Write(ex.Message);
                                                        }

                                                        j += 1;
                                                    }
                                                    //Subgroup Visibility
                                                }// Subgroups loop ends here.

                                                //BarCtr++;   // Bar counter increment to give gap between two timeSeries
                                            }

                                            #region "-- Draw TimePeriod in X Axis--"

                                            //-- Draw TimePeriod Text in X- Axis (Applicable in Column & Line)
                                            if (!(_Theme.DisplayChartMRD) && _Theme.ShowChartAxis && ChartData.Contains(TimePeriodKey) && _Theme.ChartTimePeriods[TimePeriodKey] == true && SpCnt > 0 && _Theme.ChartType != ChartType.Pie)
                                            {
                                                if (DataValueSum != 0)
                                                {
                                                    if (_Theme.ChartType == ChartType.Column)
                                                    {
                                                        //Pt.X = AxisPoint1.X + ((float)UnitWidth * SpCnt * TimeCtr) + (float)UnitWidth;
                                                        Pt.X = AxisPoint1.X + ((float)UnitWidth * (TimeVisibleCtr - 1) * SpCnt) + (ColumnGap * (TimeVisibleCtr - 1)) + (float)UnitWidth * 0.5F * SpCnt;
                                                        Pt.Y = AxisPoint1.Y - (CurExt.Height / 90);
                                                        PtData[0] = Pt;
                                                        mTransMatrix.TransformPoints(PtData);
                                                    }
                                                    else if (_Theme.ChartType == ChartType.Line && VisibleTimePeriods > 1)
                                                    {
                                                        PtData[0].X = LineEndPoint.X;
                                                        PtData[0].Y = AxisPoint1.Y - (CurExt.Height / 70);
                                                        mTransMatrix.TransformPoints(PtData);
                                                    }

                                                    //g.DrawString(TimePeriodKey.ToString(), ChartAxisLabelFont, ChartAxisLabelBrush, PtData[0], _StringFormat);

                                                    //-- Draw Data Value with orientation
                                                    this.DrawString(g, TimePeriodKey.ToString(), false, ChartAxisLabelFont, ChartAxisLabelBrush, PtData[0], _Theme.ChartAxisLabelSettings.YOffset, _StringFormat, _Theme.ChartAxisLabelSettings.TextOrientationAngle);
                                                }
                                            }

                                            if (((_Theme.DisplayChartMRD) && _Theme.ChartType == ChartType.Column) || (_Theme.ChartType == ChartType.Pie))
                                            {
                                                break;      // in MRD case, only Only Most recent dataValue for Subgroup/ Source series will be plotted in Column chart
                                            }
                                            #endregion

                                        }
                                    }

                                } // TimePeriod Loop ends

                                //For each subgroup
                                if (bSearch)
                                {
                                    if (AreaId != "")
                                    {
                                        gPath.Transform(mTransMatrix);
                                        return;
                                    }
                                    //TODO dispose objects
                                    //TODO case when same areaid might belong to multiple layers
                                    else
                                    {
                                        gPath.Reset();
                                    }
                                }
                            }
                            //Non Missing data Shapes
                        }
                        //Traverse Shapes
                    }
                    //Extent-Visibility-Type

                }
                //Traverse Layers collection

            }

            //*** Dispose
            //gPath = New GraphicsPath
            _Shape = null;
            // Pt = null;

            for (i = 0; i <= BrIS.Length - 1; i++)
            {
                BrIS[i].Dispose();
            }
            PnLeader.Dispose();
        }
Example #22
0
        /// <summary>
        /// It initializes Map by adding layers in it and creating Theme on the basis of current userSelections & PresentationDataView.
        /// </summary>
        /// <param name="preserveLegendsRanges">true, if Map's existing Legend's settings are required to preserve in new Legends when Map will initialize again.</param>
        public void Initialize(string p_ImageFolder, string spatialMapFolder, string CFLFolder, bool preserveLegendsRanges)
        {
            this.m_ImagePath = p_ImageFolder.Replace("\\", @"\");
            this.m_SpatialMapFolder = spatialMapFolder;
            this.m_CFLPath = CFLFolder;
            string ExistingPolygonLayers = string.Empty;
            DataView dvAreaMapLayerInfo;

            DateTime dtStartDate;
            DateTime dtEndDate;
            DateTime dtTempStartDate = DateTime.Parse(DEFAULT_START_DATE).Date;
            DateTime dtTempEndDate = DateTime.Parse(DEFAULT_START_DATE).Date;
            CultureInfo ociEnUS = new CultureInfo("en-US", false);
            this.sbLayerNIDs = new StringBuilder();
            this.sbLayerNames = new StringBuilder();

            //-- Get the date range for which shapefiles are to be considered
            //-- handle different Reginal Settings - Thai, Arabic etc
            dtStartDate = DateTime.Parse(DEFAULT_START_DATE, ociEnUS).Date;
            dtEndDate = DateTime.Parse(DEFAULT_END_DATE, ociEnUS).Date;

            //-- CHECK if PresentationData has any record in it.
            //-- If NO Record found, then clear Themes and Layers.
            if (this.PresentationData != null && this.PresentationData.Count > 0)
            {
                string sSql = string.Empty;
                if (this.UserPreference.UserSelection.TimePeriodNIds.Length > 0)
                {
                    // Get TimePeriod from Userselection.
                    sSql = DIQueries.Timeperiod.GetTimePeriod(FilterFieldType.NId, this.UserPreference.UserSelection.TimePeriodNIds);
                }
                else
                {
                    // Get TimePeriod from PresentationData.
                    DataView dvTimeperiods = this.GetTimePeriods();
                    string TimeNids = string.Empty;
                    for (int k = 0; k < dvTimeperiods.Count; k++)
                    {
                        if (TimeNids.Length > 0)
                        {
                            TimeNids += ",";
                        }
                        TimeNids += dvTimeperiods[k][Timeperiods.TimePeriodNId].ToString();
                    }
                    sSql = DIQueries.Timeperiod.GetTimePeriod(FilterFieldType.NId, TimeNids);
                }

                //string sSql = DIQueries.Timeperiod.GetTimePeriod(FilterFieldType.NId, "");
                System.Data.IDataReader dr = DIConnection.ExecuteReader(sSql);

                int i = 0;
                while (dr.Read())
                {
                    dtStartDate = DateTime.Parse(DEFAULT_START_DATE, ociEnUS).Date;
                    dtEndDate = DateTime.Parse(DEFAULT_END_DATE, ociEnUS).Date;

                    TimePeriodFacade.SetStartDateEndDate(dr[Timeperiods.TimePeriod].ToString(), ref dtTempStartDate, ref dtTempEndDate);

                    if (i == 0) //For first time set dtStartDate dtEndDate
                    {
                        dtStartDate = dtTempStartDate;
                        dtEndDate = dtTempEndDate;
                    }
                    else
                    {
                        if (System.DateTime.Compare(dtTempStartDate, dtStartDate) < 0)
                            dtStartDate = dtTempStartDate;

                        if (System.DateTime.Compare(dtTempEndDate, dtEndDate) > 0)
                            dtEndDate = dtTempEndDate;
                    }
                    i++;
                }
                dr.Close();
                dr.Dispose();

                //*** Add Layer to Layers collection
                //-- get Areas present in DataView.
                string sAreaNIds = GetAreaNIds();

                //-- Get & Merge Areas from DrillDown Collection.
                if (this._DrillDownAreaNIds.Count > 0)
                {
                    sAreaNIds += "," + string.Join(",", this._DrillDownAreaNIds.ToArray());
                }

                List<string> AreaNIds = new List<string>(sAreaNIds.Split(','));

                /// Very Important: If total Area selected is more than 1000 then the
                /// "Query for All Areas and Area Map relation with complete info of Area Map Layer without SHP, SHX and DBF"
                /// takes a lot of time to execute.
                /// This also effects the loop below
                /// Query for All Areas and Area Map relation with complete info of Area Map Layer without SHP, SHX and DBF
                if (AreaNIds.Count > 1000)
                {
                    /// TODO: Database based: One Time Process - Could be moved to some better location
                    sSql = this.DIQueries.Area.GetAreaMapLayer(DevInfo.Lib.DI_LibDAL.Queries.Area.Select.MapFilterFieldType.AreaNId, "", FieldSelection.Light);
                }
                else
                {
                    sSql = this.DIQueries.Area.GetAreaMapLayer(DevInfo.Lib.DI_LibDAL.Queries.Area.Select.MapFilterFieldType.AreaNId, sAreaNIds, FieldSelection.Light);
                }
                dvAreaMapLayerInfo = this.DIConnection.ExecuteDataTable(sSql).DefaultView;

                // Filter on Selected Area NIDs
                //dvAreaMapLayerInfo.RowFilter = Area.AreaNId + " in(" + sAreaNIds + ")";
                //StringBuilder sbSortedAreaNIDs = new StringBuilder();
                //sAreaNIds = "," + sAreaNIds + ",";
                //AreaNIds = DIConnection.GetDelimitedValuesFromDataTable(dvAreaMapLayerInfo.Table, Area.AreaNId).Split(',');

                // Query: Get all Shapes from the database (Layer_NId, SHP, SHX and DBF)
                // Prepare a DataView for that - LayerDataView
                // TODO: Database based: One Time Process - Could be moved to some better location
                //--sSql = this.DIQueries.Area.GetAreaMapLayerByNid("", FieldSelection.Light);
                //--DataTable dtLayerDataTable = this.DIConnection.ExecuteDataTable(sSql);

                //-- Get all Polygon layers (if existed in previous Layers Collection).
                //-- Important DO NOT Delete custom & Feature Layers as not required to be deleted in case of Gallery refresh.
                for (int p = 0; p < this.Layers.Count; p++)
                {
                    if (this.Layers[p].LayerType == ShapeType.Polygon)
                    {
                        ExistingPolygonLayers += this.Layers[p].ID + "^";
                    }
                }

                //-- remove polygon layers which are NOT present in new Layer DataView
                foreach (string lyrId in ExistingPolygonLayers.Split('^'))
                {
                    if (this.m_Layers.LayerIndex(lyrId.Trim()) >= 0)
                    {
                        // If DataView has a row for perticular LayerName, then delete it from Layers Collection
                        if (dvAreaMapLayerInfo.Table.Select(Area_Map_Metadata.LayerName + " ='" + DICommon.RemoveQuotes(lyrId.Trim()) + "'").Length == 0)
                        {
                            this.m_Layers.RemoveAt(this.m_Layers.LayerIndex(lyrId.Trim()));
                        }
                    }
                }

                dvAreaMapLayerInfo.Sort = Area.AreaID + "," + Area_Map_Layer.EndDate;

                //get distinct layers by max end date
                dvAreaMapLayerInfo = this.GetDistinctLayersByMaxEndDate(dvAreaMapLayerInfo.Table).DefaultView;

                // Loop through the SELECTED Areas OR ALL AREAS of the database depending on the number of Areas selected. See above for more details
                //TODO preserve order of adding feature layer while adding to layer collection
                //foreach (string AreaNId in AreaNIds)
                //{

                //// Make _drv for selected AreaNId
                //DataRow[] AreaMapRows = dvAreaMapLayerInfo.Table.Select(Area.AreaNId + " = " + AreaNId);

                //-- Loop each layer associated with this AreaNid, & add that layer in collection
                //foreach (DataRow drAreaMap in AreaMapRows)
                foreach (DataRow drAreaMap in dvAreaMapLayerInfo.Table.Rows)
                {

                    try
                    {
                        if (AreaNIds.Contains(drAreaMap[Area.AreaNId].ToString()))
                        {
                            //Extarct Shape File from database
                            // Get DataRow from the LayerDataView on the basis of the Layer NID available in the Loop
                            //DataRow drLayer = dtLayerDataTable.Select(Area_Map_Layer.LayerNId + " = " + drAreaMap[Area_Map_Layer.LayerNId])[0];

                            string sShapeFileNamewoExtension = Path.Combine(spatialMapFolder, drAreaMap[Area_Map_Metadata.LayerName].ToString());
                            DateTime dUpdateTimeStamp = (DateTime)drAreaMap[Area_Map_Layer.UpdateTimestamp];

                            //*** Extract Files from database only if they doesn't exist in SpatialMap Folder or database contains a newer version of shape file
                            if (!(File.Exists(sShapeFileNamewoExtension + ".shp") == true & System.DateTime.Compare(dUpdateTimeStamp, File.GetCreationTime(sShapeFileNamewoExtension + ".shp")) <= 0))
                            {
                                Map.ExtractShapeFileByLayerId(drAreaMap[Area_Map_Layer.LayerNId].ToString(), this.SpatialMapFolder, this.DIConnection, this.DIQueries);
                            }

                            //Checking if same Layer ID already exists in Layers Collection, if yes then skip..
                            if (Layers[drAreaMap[Area_Map_Metadata.LayerName].ToString()] == null)  //"Layer_Name"
                            {

                                #region "Old"

                                ////*** BugFix 01 Feb 2006 Problem with different Reginal Settings - Thai, Arabic etc
                                //dtTempStartDate = (System.DateTime)(Information.IsDBNull(drAreaMap[Area_Map_Layer.StartDate]) ? DateTime.Parse(DEFAULT_START_DATE, ociEnUS) : DateTime.Parse(((System.DateTime)drAreaMap[Area_Map_Layer.StartDate]).Month + "/" + ((System.DateTime)drAreaMap[Area_Map_Layer.StartDate]).Day + "/" + ((System.DateTime)drAreaMap[Area_Map_Layer.StartDate]).Year, ociEnUS));
                                //dtTempEndDate = (System.DateTime)(Information.IsDBNull(drAreaMap[Area_Map_Layer.EndDate]) ? DateTime.Parse(DEFAULT_END_DATE, ociEnUS) : DateTime.Parse(((System.DateTime)drAreaMap[Area_Map_Layer.EndDate]).Month + "/" + ((System.DateTime)drAreaMap[Area_Map_Layer.EndDate]).Day + "/" + ((System.DateTime)drAreaMap[Area_Map_Layer.EndDate]).Year, ociEnUS));

                                ////Get only those map files whose start date and end date are between Selected TimePeriods / Presentation data time periods
                                //if (System.DateTime.Compare(dtTempEndDate, dtStartDate) < 0 | System.DateTime.Compare(dtTempStartDate, dtEndDate) > 0)
                                //{
                                //    //--- Do nothing
                                //    Console.Write("");

                                //}
                                //else
                                //{

                                //}

                                #endregion

                                ////Add Layer to Layers collection
                                Layer _Layer = m_Layers.AddSpatialLayer(spatialMapFolder, drAreaMap[Area_Map_Metadata.LayerName].ToString());

                                if ((_Layer != null)) //if error while adding layer
                                {
                                    // Store the Layer NIDs in the StringBuilder
                                    this.sbLayerNIDs.Append("," + drAreaMap[Area_Map_Layer.LayerNId]);
                                    this.sbLayerNames.Append("," + drAreaMap[Area_Map_Metadata.LayerName]);

                                    //////Set AreaNames for Layer
                                    ////sSql = this.DIQueries.Area.GetAreaByLayer(drAreaMap[Area_Map_Layer.LayerNId].ToString());
                                    //////foreach (DataRowView _DRVL in m_QueryBase.Map_GetLayerNames(drAreaMap[Area_Map_Layer.LayerNId].ToString()))
                                    ////foreach (DataRowView _DRVL in this.DIConnection.ExecuteDataTable(sSql).DefaultView)
                                    ////{
                                    ////    _Layer.AreaNames.Add(_DRVL["Area_ID"].ToString(), _DRVL["Area_Name"].ToString());
                                    ////}

                                    //Set Layer properties
                                    _Layer.LayerName = drAreaMap[Area_Map_Metadata.LayerName].ToString();
                                    _Layer.Area_Level = int.Parse(drAreaMap[Area.AreaLevel].ToString());
                                    _Layer.LayerType = (ShapeType)(int)drAreaMap[Area_Map_Layer.LayerType];
                                    _Layer.StartDate = dtTempStartDate;
                                    _Layer.EndDate = dtTempEndDate;

                                    //Set property that point layer exists
                                    if (_Layer.LayerType == ShapeType.Point)
                                        this.m_PointShapeIncluded = true;

                                    //Set visibility off for feature layers by default
                                    switch (_Layer.LayerType)
                                    {
                                        case ShapeType.PointFeature:
                                        case ShapeType.PolygonFeature:
                                        case ShapeType.PolyLineFeature:
                                            _Layer.Visible = false;
                                            break;
                                    }
                                }

                            }
                        }
                    }
                    catch (Exception ex)
                    {

                        //throw;
                    }
                }

                // Get Area Names for all the Layer NIDs used - Background Process
                //FillAreaWorker = new Thread(new ThreadStart(this.FillAreaWorker_DoWork));
                //FillAreaWorker.Start();
                //-- Threading approch discared as it results into reader alreday open error sometimes
                this.FillAreaWorker_DoWork();

                this.AddCustomFeatureLayers();

                //Set Full Extent by default
                SetFullExtent();

                //Create default theme implicitly for first time
                //In case of map loading from report need not to create this default theme
                if (this.m_Themes.Count == 0)
                {
                    this.CreateTheme("-1", "-1", "-1", ThemeType.Color);   // for default Theme, use "-1" as NIDs
                }
                else
                {
                    // If Themes are already present then preserve IUS and ThemeType , and re-create Theme again.
                    // New Theme is re-created on the basis of new PresentationData , new userSelection, and new Layers added..
                    // So Old Theme's settings must be restored in New Theme.
                    Theme TempTheme = new Theme();
                    Theme NewTheme = null;
                    string[] ThemeIdSettings;
                    string ThemeId;
                    string[] I_U_S_NIds = null;     //-- NIds of I, U, S used in  Theme

                    for (int c = 0; c < this.Themes.Count; c++)
                    {

                        //_Theme.ID = p_IndicatorNId + "_" + p_UnitNId + "_" + p_SubgroupValNId + "_" + (int)p_ThemeType;

                        TempTheme = this.Themes[c];
                        ThemeId = TempTheme.ID;
                        TempTheme.ID = "TempThemeID";   // ID changed temperarily.
                        TempTheme = (Theme)(TempTheme.Clone());

                        int TempThemeIndex = this.Themes.ItemIndex(ThemeId);

                        ThemeIdSettings = ThemeId.Split('_');

                        //-- Get Nids of Indicator, Unit, Subgroupval used in Theme. on the basis of their GIDs
                        I_U_S_NIds = this.GetI_U_S_NidsByGIDs(this._DIDataView.MainDataTable.DefaultView, TempTheme.I_U_S_GIDs[0], TempTheme.I_U_S_GIDs[1], TempTheme.I_U_S_GIDs[2]);

                        //--Create Theme again and add it in same i th position in collection.
                        try
                        {
                            // Check whather there is only one IUS in userSelection
                            // if one, then IUS must have been changed outside(in Dynamic reports). so, createTheme for default.
                            // if more than one, then createTheme for previus IUS
                            if (this.UserPreference.UserSelection.ShowIUS)
                            {
                                if (this.UserPreference.UserSelection.IndicatorNIds.Split(',').Length == 1)
                                {
                                    //if Single IUS, then create Default theme.
                                    if (TempTheme.Type == ThemeType.Chart)
                                    {
                                        NewTheme = this.CreateTheme("-1", "-1", "-1", (ThemeType)int.Parse(ThemeIdSettings[3]), TempTheme.ChartType, TempTheme.ChartSeriestype, c);
                                    }
                                    else
                                    {
                                        NewTheme = this.CreateTheme("-1", "-1", "-1", (ThemeType)int.Parse(ThemeIdSettings[3]), c);
                                    }
                                }
                                else
                                {
                                    // Multiple IUS indicates that IUS are same as previous
                                    // so, UpdateTheme for same IUS
                                    if (TempTheme.Type == ThemeType.Chart)
                                    {
                                        NewTheme = this.CreateTheme(I_U_S_NIds[0], I_U_S_NIds[1], I_U_S_NIds[2], (ThemeType)int.Parse(ThemeIdSettings[3]), TempTheme.ChartType, TempTheme.ChartSeriestype, c);
                                    }
                                    else
                                    {
                                        NewTheme = this.CreateTheme(I_U_S_NIds[0], I_U_S_NIds[1], I_U_S_NIds[2], (ThemeType)int.Parse(ThemeIdSettings[3]), c);
                                    }

                                    //-- Set Theme Name same as Previous
                                    NewTheme.Name = TempTheme.Name;
                                }
                            }
                            else
                            {
                                if (this.UserPreference.UserSelection.IndicatorNIds.Split(',').Length == 1 && this.UserPreference.UserSelection.UnitNIds.Split(',').Length == 1 && this.UserPreference.UserSelection.SubgroupValNIds.Split(',').Length == 1)
                                {
                                    //if Single IUS, then create Default theme.
                                    NewTheme = this.CreateTheme("-1", "-1", "-1", (ThemeType)int.Parse(ThemeIdSettings[3]), c);
                                }
                                else
                                {
                                    // Multiple IUS indicates that IUS is same as previous IUS in current Theme
                                    // so, UpdateTheme for prevoius IUS
                                    NewTheme = this.CreateTheme(I_U_S_NIds[0], I_U_S_NIds[1], I_U_S_NIds[2], (ThemeType)int.Parse(ThemeIdSettings[3]), c);

                                    //-- Set Theme Name same as Previous
                                    NewTheme.Name = TempTheme.Name;
                                }
                            }
                            // Update new Theme with Old Theme's properties
                            this.UpdateThemeProperties(TempTheme, NewTheme, preserveLegendsRanges, true);

                            // remove old Theme
                            this.Themes.Remove(this.Themes.ItemIndex("TempThemeID"));

                        }
                        catch (Exception ex)
                        {
                            //If theme already exists exception will be thrown ApplicationException("3")
                            //If ThemeData.Count == 0 exception will be thrown ApplicationException("5")
                            // Exception to be handled in Desktop web and reporting panel which call Initialize method
                            throw ex;
                        }
                    }
                    int RecordCount = m_Layers.RecordCounts(m_SpatialMapFolder);

                    //-- Set visibility of color theme which was earlier set true when Map Serialized.
                    this.ResetColorThemeVisibility();

                    //- Clear inset images of previous Themes (if any)
                    try
                    {
                        foreach (Inset inset in this.m_Insets)
                        {
                            if (inset.InsetImage != null)
                            {
                                inset.InsetImage.Dispose();
                                inset.InsetImage = null;
                            }
                        }
                    }
                    catch
                    {
                    }
                }

                this.SetMapTitle();
            }
            else   // If No Record Found in Presentation Data, then Clear Themes & Layers collection.
            {
                this.Themes.Clear();
                this.Layers.Clear();
            }
        }
Example #23
0
        private void DrawDotDensity(ref Graphics g, Theme _Theme, Matrix mTransMatrix, RectangleF CurExt)
        {
            int DotCount;
            int DotSize = (int)_Theme.DotSize;
            double DotValue = _Theme.DotValue;

            Brush BrDot = new SolidBrush(_Theme.DotColor);
            Pen PnDot = new Pen(_Theme.DotColor);
            PointF[] Pt = new PointF[1];

            int j;
            int TrialCount;

            Shape _Shape;
            GraphicsPath gpShp = new GraphicsPath();
            RectangleF RectRnd = new RectangleF();
            Matrix _Matrix = new Matrix();
            StringFormat _StringFormat = new StringFormat();
            _StringFormat.Alignment = StringAlignment.Center;
            _StringFormat.LineAlignment = StringAlignment.Center;
            _StringFormat.FormatFlags = StringFormatFlags.NoClip;

            Theme _ATheme = m_Themes.GetActiveTheme();
            bool bLayerVisibility;

            g.SmoothingMode = SmoothingMode.AntiAlias;
            //*** Traverse Layers collection
            foreach (Layer _Layer in Layers)
            {
                if (DotValue == 0)
                    break;

                if ((_ATheme == null))
                {
                    bLayerVisibility = _Layer.Visible;
                }
                else
                {
                    bLayerVisibility = (bool)(_ATheme.LayerVisibility[_Layer.ID]);
                }
                //*** Consider polygon layers lying within current map extent and visibility is on
                if (_Layer.LayerType == ShapeType.Polygon & _Layer.Extent.IntersectsWith(CurExt) & bLayerVisibility)
                {
                    //Render layer only if it lies within current map extent
                    Hashtable ht = _Layer.GetRecords(_Layer.LayerPath + "\\" + _Layer.ID);
                    IDictionaryEnumerator dicEnumerator = ht.GetEnumerator();
                    //*** Traverse each Shape of the layer
                    while (dicEnumerator.MoveNext())
                    {
                        _Shape = (Shape)dicEnumerator.Value;
                        //*** Consider shape only if it lies within current map extent
                        if (_Shape.Extent.IntersectsWith(CurExt))
                        {
                            if (_Theme.AreaIndexes.ContainsKey(_Shape.AreaId))
                            {
                                DotCount = (int)((double)((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).DataValue / DotValue);
                                Region Rgn = new Region();
                                RectangleF[] Rect;
                                PointF[] Vertex = new PointF[3];
                                //*** for triangle
                                object MarkerSize = Math.Sqrt(3) / 4 * DotSize;
                                //*** for triangle

                                if (DotCount > 0)
                                {
                                    gpShp.Reset();
                                    for (j = 0; j <= _Shape.Parts.Count - 1; j++)
                                    {
                                        gpShp.AddPolygon((PointF[])_Shape.Parts[j]);
                                    }
                                    Rgn = new Region(gpShp);
                                    //Rgn.Intersect(CurExt)
                                    Rgn.Transform(mTransMatrix);
                                    Rect = Rgn.GetRegionScans(_Matrix);
                                    //http://www.dotnet247.com/247reference/a.aspx?u=http://www.bobpowell.net/gdiplus_faq.htm
                                    //Rect.Sort(Rect)
                                }
                                else
                                {
                                    Rect = new RectangleF[0];   // Rect[] length is set to 0 because Rect.length was required in If condition below.
                                }

                                //*** Draw random dots inside region
                                j = 1;
                                TrialCount = 1;

                                //*** Bugfix / Enhancement 19 Jun 2006 Distribution of Dots
                                while (j <= DotCount)
                                {
                                    if (DotCount == 0)
                                        break;

                                    if (Rect.Length == 0)
                                        break;

                                    VBMath.Randomize();

                                    try
                                    {
                                        if (Rect.Length / 2 > j + 1)
                                        {
                                            if ((double)j / 2 == (int)(j / 2))  //Math.Round((double)(j / 2)))
                                            {
                                                if ((double)j / 8 == Math.Round((double)(j / 8)))
                                                {
                                                    RectRnd = Rect[j];
                                                }
                                                else
                                                {
                                                    RectRnd = Rect[(int)(Rect.Length / 2) - j];
                                                }
                                            }
                                            else
                                            {
                                                if ((double)j / 6 == Math.Round((double)(j / 6)))
                                                {
                                                    RectRnd = Rect[Rect.Length - j];
                                                }
                                                else
                                                {
                                                    RectRnd = Rect[(int)(Rect.Length / 2) + j];
                                                }
                                            }
                                        }
                                        else
                                        {
                                            RectRnd = Rect[(int)(VBMath.Rnd() * (Rect.Length - 1))];
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.Write(ex.Message);
                                    }

                                    Pt[0].X = RectRnd.X + RectRnd.Width * (float)(0.6 * (float)VBMath.Rnd() + 0.2);
                                    Pt[0].Y = RectRnd.Y - RectRnd.Height / 2;
                                    //* Rnd()

                                    if (Rgn.IsVisible(Pt[0]))
                                    {
                                        switch (_Theme.DotStyle)
                                        {
                                            case MarkerStyle.Circle:
                                                g.FillEllipse(BrDot, (int)(Pt[0].X - DotSize / 2), (int)(Pt[0].Y - DotSize / 2), (int)DotSize, (int)DotSize);
                                                break;
                                            case MarkerStyle.Square:
                                                g.FillRectangle(BrDot, (int)(Pt[0].X - DotSize / 2), (int)(Pt[0].Y - DotSize / 2), (int)DotSize, (int)DotSize);
                                                break;
                                            case MarkerStyle.Triangle:
                                                Vertex[0] = new PointF(Pt[0].X - float.Parse(MarkerSize.ToString()), Pt[0].Y + float.Parse(MarkerSize.ToString()));
                                                Vertex[1] = new PointF(Pt[0].X + float.Parse(MarkerSize.ToString()), Pt[0].Y + float.Parse(MarkerSize.ToString()));
                                                Vertex[2] = new PointF(Pt[0].X, Pt[0].Y - float.Parse(MarkerSize.ToString()));
                                                g.FillPolygon(BrDot, Vertex);
                                                break;
                                            case MarkerStyle.Cross:
                                                g.DrawLine(PnDot, (int)(Pt[0].X - DotSize / 2), (int)Pt[0].Y, (int)(Pt[0].X + DotSize / 2), (int)Pt[0].Y);
                                                g.DrawLine(PnDot, (int)Pt[0].X, (int)(Pt[0].Y + DotSize / 2), (int)Pt[0].X, (int)(Pt[0].Y - DotSize / 2));
                                                break;
                                            case MarkerStyle.Custom:
                                                g.DrawString(_Theme.DotChar.ToString(), _Theme.DotFont, BrDot, Pt[0].X, Pt[0].Y, _StringFormat);
                                                break;
                                        }
                                        j = j + 1;
                                    }

                                    if (TrialCount > DotCount + 2)
                                        break;

                                    TrialCount += 1;
                                }
                                Rgn.Dispose();
                                Rect = null;
                            }
                        }
                    }
                    ht = null;
                    dicEnumerator = null;
                }
                // _Layer = null;
            }
            g.SmoothingMode = SmoothingMode.None;

            _Matrix = null;
            // RectRnd = null;
            Pt = null;
            // _Layer = null;
            _Shape = null;
            BrDot.Dispose();
            PnDot.Dispose();
            gpShp.Dispose();
            _StringFormat.Dispose();
        }
Example #24
0
 public void Insert(int p_Position, Theme p_Theme)
 {
     List.Insert(p_Position, p_Theme);
 }